rishizek / tensorflow-deeplab-v3-plus

DeepLabv3+ built in TensorFlow
MIT License
833 stars 307 forks source link

How to output Class names #15

Closed saivineethkumar closed 6 years ago

saivineethkumar commented 6 years ago

@rishizek Hi I am able to run the tool and get image output but I want to store the output data in a json file. I cannot understand how I to get the name of the classes from the "_preddict" defined in the code. I am able to get the class index but unable to get class names. can any one help me with that.

And I want to know about total possible output classes. Are there only 21 possible output classes? if no, how can I get all the possible class outputs in an array or list. if yes, is there a way to increase the number? thanks

rishizek commented 6 years ago

Hi @saivineethkumar , thank you for your interest in the repo.

pred_dict called here is defined in here. And you can get predicted class indices by unique_labels = np.unique(pred_dict['classes']) as you already know. But mapping from class index to name is currently not implemented. The name mapping follows standard PASCAL VOC dataset convention shown in here and here, for example. You need to implement the mapping by yourself if you need one.

Are there only 21 possible output classes?

Yes, because the model is trained with Pascal VoC dataset, which is 20 classes + background class (1 class).

if yes, is there a way to increase the number?

By modifying _NUM_CLASSES given in the codes and training model with new dataset with different number of class, you can increase (or decrease) the number of class.

saivineethkumar commented 6 years ago

thank you very much for the detailed explanation, that answers my question very well and thanks for sharing your work, it helped a lot!