facebookarchive / fb.resnet.torch

Torch implementation of ResNet from http://arxiv.org/abs/1512.03385 and training scripts
Other
2.29k stars 665 forks source link

Using classify.lua for custom dataset #83

Closed dapurv5 closed 8 years ago

dapurv5 commented 8 years ago

I re-trained the resnet model for my custom labels. To see the results, I am trying to predict the labels for some hand picked images using the classify.lua script. This script depends on hardcoded imagenet classes in the file https://github.com/facebook/fb.resnet.torch/blob/master/pretrained/imagenet.lua

What order should I replace the labels in this file with? I don't see the labels in ascending or descending order of names. Or does order not matter?

colesbury commented 8 years ago

You should sort them alphabetically, assuming your labels match the directory names inside the train/ dir.

The imagenet labels are sorted based on their synset ID (the directory names). If you looked at the list with synset IDs it would look like:

n01440764,tench
n01443537,goldfish
n01484850,great white shark
n01491361,tiger shark
n01494475,hammerhead
n01496331,electric ray
n01498041,stingray
n01514668,cock
n01514859,hen
...

You can get the sorted class list from the generated gen/imagenet.t7 file:

th> print(torch.load('gen/imagenet.t7').classList)
dapurv5 commented 8 years ago

Awesome, thank you.