0
$\begingroup$

I would just like to get the class names of the predictions. I can get the class names on the images that I trained the model. But if I predict an image (say which is not trained but already belongs to the pre-trained model (VGG16) I cannot get its class name).

My scenario: I used VGG16 pre-trained and added new datasets (like logos, stars, hills etc which are not present in VGG16 (say) )

Now I trained this model in those datasets, when i predicted an image, it gave the correct class-name (logos, stars, hills etc..)

But when I predict an image that was already in VGG16 (say Dog, Cat), it is not giving me the right class name i.e Dog, Cat etc.

I need some help in this scenario.

Is there any way to get the get the class name?

$\endgroup$
  • $\begingroup$ In the original training session, there will have been the mapping between class name and numerical class ID (e.g. Cat = 0, Dog = 1, ...). The model you use will output just the IDs and you need to find the mapping that was used. $\endgroup$ – n1k31t4 Jul 3 '19 at 13:58
  • $\begingroup$ Kerala generally sorts the labels lexicographically; in torch there's class_to_idx as well (which is generally cached by user)! Easiest way is just give it an image and see what it outputs.. $\endgroup$ – Aditya Jul 3 '19 at 18:16
0
$\begingroup$

In the original training session, there will have been the mapping between class name and numerical class ID (e.g. Cat = 0, Dog = 1, ...). The model you use will output just the IDs and you need to find the mapping that was used.

If your new data has been added in addition to the old classes, they should each have a new unique ID. If you used VGG architecture to train on your new classes from scratch, then the model will not be able to make predictions for the original VGG classes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.