Synset.txt generation #268
-
QuestionI am curious about the proper generation of the synset.txt file for custom model loading. To begin with a toy problem I began with 17 flowers, if that helps in any way. The question is, what is the proper way to generate the synset.txt file? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
@jesse-schallenberger The sysnet doesn't have to be a file. It can be List. See: https://github.com/awslabs/djl/blob/master/api/src/main/java/ai/djl/modality/cv/translator/BaseImageTranslator.java#L259-L266 Synset usually comes with your training dataset, see: https://github.com/awslabs/djl/blob/master/basicdataset/src/main/java/ai/djl/basicdataset/AbstractImageFolder.java#L90-L93 If you use ImageFolder as your dataset, you can get it already. |
Beta Was this translation helpful? Give feedback.
-
It looks like this: https://mlrepo.djl.ai/model/cv/image_classification/ai/djl/mxnet/synset.txt Just use |
Beta Was this translation helpful? Give feedback.
-
Regarding the entries here in the listed file, they seem to be consistently given as similar to |
Beta Was this translation helpful? Give feedback.
-
@jesse-schallenberger |
Beta Was this translation helpful? Give feedback.
-
If the NN mapping is integer to class name, would clarification be possible for what the synset should look like in that case? Would both values be needed per line? |
Beta Was this translation helpful? Give feedback.
-
use ImageNet as example, it contains 1000 classes, each line is the label of the class, the content/format of the label doesn't really matter to the deep learning. The output of NN contains 1000 floating numbers, each of value represent the probability of corresponding class. |
Beta Was this translation helpful? Give feedback.
-
To summarize, it seems the synset is required for inference and a 1:1 mapping of the labels is needed for proper functionality. It seems to make the most sense to leverage proper labels, but ultimately the values themselves don't matter? I have found the case of an empty synset, and also no synset to cause errors trying to run inference. |
Beta Was this translation helpful? Give feedback.
-
For a classification use case, it's required you provide a 1:1 mapping between index to the label. otherwise your output processing will hit ArrayIndexOutOfBoundException. |
Beta Was this translation helpful? Give feedback.
use ImageNet as example, it contains 1000 classes, each line is the label of the class, the content/format of the label doesn't really matter to the deep learning. The output of NN contains 1000 floating numbers, each of value represent the probability of corresponding class.