# Pretrained model preform wrong

**URL:** <https://discuss.pytorch.org/t/pretrained-model-preform-wrong/16004>\
**Category:** vision\
**Created:** [April 5, 2018, 12:38pm UTC](https://discuss.pytorch.org/t/pretrained-model-preform-wrong/16004 "2018-04-05T12:38:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tztztztztz](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tztztztztz/32/3748_2.png) [@tztztztztz](https://discuss.pytorch.org/u/tztztztztz)\
**Post date:** [April 5, 2018, 12:38pm UTC](https://discuss.pytorch.org/t/pretrained-model-preform-wrong/16004/1 "2018-04-05T12:38:22Z")

</div>

hi, I used a pre-trained model(res101) from official model zoo, and I input a image to test if every thing works well.

I did the necessary preprocessing, and I found the result was totally wrong. Can any one help me??

```auto
# load model
resnet101 = models.resnet101(pretrained=True)

# img_path : VOCdevkit2007/VOC2007/JPEGImages/000007.jpg
img = Image.open(img_path)

"""
1. resize to 224, 224
2. normalize to [0,1]
3. normalize by specified mean and std
"""
transform = transforms.Compose([
        transforms.Scale((224, 224)),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

img = transform(img)

out = resnet101(Variable(img).unsqueeze(0)).data

# load imagenet classes labels
import json
class_idx = json.load(open("imagenet_class_index.json"))
idx2label = [class_idx[str(k)][1] for k in range(len(class_idx))]

# get the top 10 result
for idx in out[0].sort()[1][-10:]:
    print(idx2label[idx])

```

and the result is

```auto
paper_towel
sunglass
ladle
crutch
cowboy_hat
ashcan
pole
hook
plunger
bucket

```

the result is completely wrong, I think it should be a `car` or something？？？

and this is my input image

 ![figure_1](https://discuss.pytorch.org/uploads/default/original/2X/b/bbf942cd9be0cc7cc771ba00efe6db436a806806.jpg)

---

<div class="post-metadata">

**Author:** ![tztztztztz](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tztztztztz/32/3748_2.png) [@tztztztztz](https://discuss.pytorch.org/u/tztztztztz)\
**Post date:** [April 5, 2018, 1:09pm UTC](https://discuss.pytorch.org/t/pretrained-model-preform-wrong/16004/2 "2018-04-05T13:09:13Z")

</div>

finally, I got it. use model.eval() will help:joy:
