Squeezenet1.0 models give wrong prediction results
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 9.8k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Bug Report
Which model does this pertain to?
All squeezenet 1.0 models from https://github.com/onnx/models/tree/main/validated/vision/classification/squeezenet
Describe the bug
These squeezenet 1.0 models can't provide correct prediction results:
Reproduction instructions
System Information
Win11
Select any one squeezenet 1.0 model to try:
import onnx
import onnxruntime
import numpy as np
from PIL import Image
# Load SqueezeNet ONNX
model_path = 'squeezenet1.0-12-fp32.onnx'
model = onnx.load(model_path)
# Create ONNX session
session = onnxruntime.InferenceSession(model_path)
# Load image
image_path = 'dog.jpg'
image = Image.open(image_path)
image = image.resize((224, 224))
# Image preprocessing
image = np.array(image).astype(np.float32)
image /= 255.0
# Normalize image
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
image = (image - mean) / std
image = np.transpose(image, (2, 0, 1)) # Adjust channel order of the image
image = np.expand_dims(image, axis=0) # Add batch dimension
# convert the input tensor to float type
image = image.astype(np.float32)
# Predict
input_name = session.get_inputs()[0].name
output_name = session.get_outputs()[0].name
input_feed = {input_name: image}
output = session.run([output_name], input_feed)
# Load the labels file
labels_path = 'synset.txt'
with open(labels_path, 'r') as f:
labels = f.read().splitlines()
# Get results
predicted_idx = np.argmax(output[0])
predicted_label = labels[predicted_idx]
print("Predicted label:", predicted_label)
...
The prediction result is always:
Predicted label: n03788365 mosquito net
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the models under validated/vision/classification/squeezenet, then run the provided Python reproduction using squeezenet1.0-12-fp32.onnx and synset.txt. Check the model input, preprocessing, and output indexing against the SqueezeNet model files. Done means the SqueezeNet 1.0 models no longer always produce the reported mosquito-net label and their predictions are validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100