allanzelener / YAD2K

YAD2K: Yet Another Darknet 2 Keras
Other
2.72k stars 880 forks source link

Quick Question #52

Open farzaa opened 7 years ago

farzaa commented 7 years ago

Hey there!

I want to use pascal_classes.txt. (default is coco)

But I get an error with the anchors and don't quite understand what's going on or how to fix it. Any help would be awesome! Note: Everything works perfectly with coco.

AssertionError: Mismatch between model and given anchor and class sizes. Specify matching anchors and classes with --anchors_path and --classes_path flags.

Firyuza commented 7 years ago

Hi! You have to download yolo-voc.cfg and yolo-voc.weights and then run command in yad2k environment: ./yad2k.py yolo-voc.cfg yolo-voc.weights model_data/yolo-voc.h5 After running this command anchors-voc will be generated. In darknet you can find these files: config and weights.

farzaa commented 7 years ago

Ahh, understood! Appreciate it, I shall do that :).

One more thing, if I want to only predict 5 classes from the Coco dataset, how can I do this? I know one idea is to just ignore the other 75 classes but that seems odd to me.

Let me know if you have a good solution!

Thanks

allanzelener commented 7 years ago

If you want the model to predict only 5 target classes then you have to retrain the final layer, but there's no guarantee that training on a restricted class set will give better performance and you may not want to go through the trouble of training.

If you just want a probability estimate among the five classes then you can renormalize the output class probabilities. That is, p(class | class is in {a, b, c, d, e}) = p(class) / (p(a) + p(b) + p(c) + p(d) + p(e)).