hollance / YOLO-CoreML-MPSNNGraph

Tiny YOLO for iOS implemented using CoreML but also using the new MPS graph API.
MIT License
933 stars 252 forks source link

0 boxes found #19

Closed tgwagner closed 5 years ago

tgwagner commented 6 years ago

@hollance Thanks for your great work. Fantastic writeup. However, I am running into a small issue.

I've successfully trained the NFPA tiny-yolo model with darknet. Great news is I can successfully find an NFPA tag within an image after the model was trained with the darknet detector command. However, after converting to .h5 with yad2k, i run the test with the converted model against the same test image and 0 boxes are found.

Note that I am able to successfully test the yolo (not the tiny yolo) model pre and post convert and it works. What am I missing?

Summary of results below: a) pre converted tiny-yolo model (success) b) post converted tiny-yolo model (fail) c) pre converted yolo model (success) d) pre converted yolo model (success)

//a) testing pre converted tiny yolo model: ./darknet detector test cfg/NFPA.data cfg/tiny-yolo-NFPA.cfg backup/tiny-yolo-NFPA_6100.weights data/nfpadrum.jpg

layer filters size input output 0 conv 16 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 16 1 max 2 x 2 / 2 416 x 416 x 16 -> 208 x 208 x 16 2 conv 32 3 x 3 / 1 208 x 208 x 16 -> 208 x 208 x 32 3 max 2 x 2 / 2 208 x 208 x 32 -> 104 x 104 x 32 4 conv 64 3 x 3 / 1 104 x 104 x 32 -> 104 x 104 x 64 5 max 2 x 2 / 2 104 x 104 x 64 -> 52 x 52 x 64 6 conv 128 3 x 3 / 1 52 x 52 x 64 -> 52 x 52 x 128 7 max 2 x 2 / 2 52 x 52 x 128 -> 26 x 26 x 128 8 conv 256 3 x 3 / 1 26 x 26 x 128 -> 26 x 26 x 256 9 max 2 x 2 / 2 26 x 26 x 256 -> 13 x 13 x 256 10 conv 512 3 x 3 / 1 13 x 13 x 256 -> 13 x 13 x 512 11 max 2 x 2 / 1 13 x 13 x 512 -> 13 x 13 x 512 12 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 13 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024 14 conv 30 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 30 15 detection Loading weights from backup/tiny-yolo-NFPA_6100.weights... seen 32 Done! data/nfpadrum.jpg: Predicted in 0.446766 seconds. NFPA: 94% Not compiled with OpenCV, saving to predictions.png instead

//b) testing post converted tiny yolo model: python3 test_yolo.py model_data/tiny-yolo-NFPA.h5 -a model_data/tiny-yolo-NFPA_anchors.txt -c model_data/NFPA_classes.txt

Using TensorFlow backend. model_data/tiny-yolo-NFPA.h5 model, anchors, and classes loaded. Found 0 boxes for nfpadrum.jpg

//c) Testing pre conversion yolo (not tiny yolo) model ./darknet detector test cfg/NFPA.data cfg/yolo-NFPA.cfg-WORKS backup/yolo-NFPA_2700.weights data/nfpadrum.jpg

layer filters size input output 0 conv 32 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 32 1 max 2 x 2 / 2 416 x 416 x 32 -> 208 x 208 x 32 2 conv 64 3 x 3 / 1 208 x 208 x 32 -> 208 x 208 x 64 3 max 2 x 2 / 2 208 x 208 x 64 -> 104 x 104 x 64 4 conv 128 3 x 3 / 1 104 x 104 x 64 -> 104 x 104 x 128 5 conv 64 1 x 1 / 1 104 x 104 x 128 -> 104 x 104 x 64 6 conv 128 3 x 3 / 1 104 x 104 x 64 -> 104 x 104 x 128 7 max 2 x 2 / 2 104 x 104 x 128 -> 52 x 52 x 128 8 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 9 conv 128 1 x 1 / 1 52 x 52 x 256 -> 52 x 52 x 128 10 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 11 max 2 x 2 / 2 52 x 52 x 256 -> 26 x 26 x 256 12 conv 512 3 x 3 / 1 26 x 26 x 256 -> 26 x 26 x 512 13 conv 256 1 x 1 / 1 26 x 26 x 512 -> 26 x 26 x 256 14 conv 512 3 x 3 / 1 26 x 26 x 256 -> 26 x 26 x 512 15 conv 256 1 x 1 / 1 26 x 26 x 512 -> 26 x 26 x 256 16 conv 512 3 x 3 / 1 26 x 26 x 256 -> 26 x 26 x 512 17 max 2 x 2 / 2 26 x 26 x 512 -> 13 x 13 x 512 18 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 19 conv 512 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 512 20 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 21 conv 512 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 512 22 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 23 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024 24 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024 25 route 16 26 conv 64 1 x 1 / 1 26 x 26 x 512 -> 26 x 26 x 64 27 reorg / 2 26 x 26 x 64 -> 13 x 13 x 256 28 route 27 24 29 conv 1024 3 x 3 / 1 13 x 13 x1280 -> 13 x 13 x1024 30 conv 30 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 30 31 detection Loading weights from backup/yolo-NFPA_2700.weights... seen 32 Done! data/nfpadrum.jpg: Predicted in 0.573800 seconds. NFPA: 88% Not compiled with OpenCV, saving to predictions.png instead

//d) Testing post conversion yolo (not tiny yolo) model python3 test_yolo.py model_data/yolo-NFPA.h5 -a model_data/yolo-NFPA_anchors.txt -c model_data/NFPA_classes.txt

model_data/yolo-NFPA.h5 model, anchors, and classes loaded. Found 1 boxes for nfpadrum.jpg NFPA 0.91 (144, 172) (251, 256)

Thanks! Todd

link to test image file nfpadrum.jpg link to cfg file tiny-yolo-NFPA.cfg link to weights file tiny-yolo-NFPA_6100.weights

hollance commented 6 years ago

Not sure. I did not write YAD2K but that's where the problem seems to be. There's another issue open in this repo that talks about a similar problem with potential solutions.