Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Alert: Beginning Tuesday, June 25th, we will be freezing this site and migrating the content and forums to our new home at Check it out now!

MobileNet+YOLOv2 problem

I try to porting my mobileNet-yolov2 and darknet-yolov2 caffemodel into NCS , the result of darknet-yolov2 is correct, but mobileNet-yolov2 is wrong , is there any layer or parameter can not be use ?

project link

trainning project :


  • 12 Comments sorted by Votes Date Added
  • @amirFO Tiny Yolo networks require post processing. You can see examples of Yolo post processing in ncappzoo Tiny Yolo sample. Here is a good reference that can be used for Tiny Yolo v2 TensorFlow:

    You can also check out a quick sample I created at

  • @ceciliapeng You can visit for more information on Darknet YOLO. SSD MobileNet and YOLO are similar in that they are single shot detection Object Detectors, but the difference is that SSD MobileNet makes predictions based off various scales of feature maps while YOLO only makes predictions based off one feature map. Theoretically, this means that SSD MobileNet is better at detecting smaller objects (in relation to the image) than YOLO. You can convert the Darknet model to TensorFlow for use on an NC device.

    You can generate the Tiny Yolo V2 pb file by doing the following:

    1. Install Darkflow by cloning and following the getting started instructions on the github:

    2. Visit and download the cfg and weights file for "Tiny Yolo". This will actually be Tiny Yolo V2.

    3. Put the cfg file inside of your darkflow/cfg directory and the weights file inside of the darkflow/bin directory.

    4. Edit the labels.txt file inside of the darkflow root directory and replace the contents of the file with the list of items below (aeroplane, bicycle, etc.)

    5. Generate the frozen pb file with the command flow --model cfg/yolov2-tiny-voc.cfg --load bin/yolov2-tiny-voc.weights --savepb

    If you receive the error "TypeError: makedirs() got an unexpected keyword argument 'exist_ok'", open darkflow/darkflow/net/build,py and darkflow/test/ in a text editor and remove the "exist_ok" from lines 171 and 49 respectively. You will need to delete the dakrflow/built_graph directory before you try generating the frozen model file again.

  • @eric612 A list of supported layers for Caffe can be found @ Also we do have support for Tensorflow TinyYoloV2. See release notes @

  • @eric612

    What is "darknet-yolov2 caffemodel" you mentioned?
    And for "mobileNet-yolov2", what is it? What's the connection between mobileNet and yolov2? Do you train it with a modified caffe, which support the missing layer, like route, reorg and detection layers? Or do you convert it from darknet model?

  • @Tome_at_Intel Hi, I generated the tiny Yolo v2 pb file also, I compiled with mvNCCompile command and I generated the graph file (mvNCCompile yolov2-tiny-voc.pb -o yolov2-tiny-voc.graph).
    Now, I am reading this graph file and when I got the result from the device using this code ( output, userobj = fifo_out.read_elem() ) the strange thing was that the length of the output was 21156 that I think it should be 20 (Number of our classes). Is there any problem in my graph file or I do not know I should send this graph to NCS with another function?

  • @Tome_at_Intel Hi, I used your sample code (Tiny-Yolo v2 in Tensorflow) in my code and it worked with RGB images perfectly. I am working with grayscale images and last week when I wanted to run my code I got a math error in sgmoid function result but today I upgraded my SDK to ncsdk- and now there is no error. But, it can not detect any objects in the sample image. I tried to change the grayscale image into a 3 channel image but it did not work. Please let me know, for grayscale images should I change some values in post-processing part? or there is a problem on Movidius SDK?

  • @amirFO The Tiny Yolo V2 model was trained on the Pascal VOC 2007 dataset. This dataset contained RGB images so I don't think they will work with grayscale images. You will have to retrain the model with grayscale images and edit the code to use grayscale images like in

  • @Tome_at_Intel Thanks for your help, I changed the code to use grayscale images and I could train the grayscale images and I tested in darkflow, it worked perfectly but when I converted the pb file to movidius graph file, the output after postprocessing function is completely different and all of the values are negative. I think something in graph.queue_inference_with_fifo_elem function is not right, I mean the elements of fifo_out are not what we expect. I would be grateful if you could help me.

  • @amirFO Since your model is now trained with 1 channel images, make sure the code reflects this. Namely the image preprocessing steps right after reading in the image as the code was meant for 3 channel images.

  • @Tome_at_Intel Almost I am sure that the code is correct, I am using the following code in preprocessing part:
    img = cv2.imread(IMAGE, 0)
    img_cv = img
    img = np.divide(img, 255.0)
    img = np.resize(img, (192, 224, 1))
    img = img.astype(np.float32)
    mvnc.global_set_option(mvnc.GlobalOption.RW_LOG_LEVEL, 2)

  • @amirFO can you try using mvNCCheck with your model and and a sample grayscale image and see what result you get? Also if you can provide me a link to your model, I can help you check it out. Thanks.

  • Hi @Tome_at_Intel , can we use any tiny yolo v2 cfg to run on movidius or must it be tiny yolo v2 voc cfg?

This discussion has been closed.