Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

MobileNet+YOLOv2 problem

idata
Employee
4,356 Views

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

 

https://github.com/eric612/YoloV2-MobileNet-NCS

 

trainning project :

 

https://github.com/eric612/Caffe-YOLOv2-Windows
0 Kudos
12 Replies
idata
Employee
3,885 Views

@eric612 A list of supported layers for Caffe can be found @ https://movidius.github.io/ncsdk/Caffe.html. Also we do have support for Tensorflow TinyYoloV2. See release notes @ https://github.com/movidius/ncsdk/releases/tag/v1.12.00.01.

0 Kudos
idata
Employee
3,885 Views

@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?
0 Kudos
idata
Employee
3,885 Views

@ceciliapeng You can visit https://pjreddie.com/darknet/yolov2/ 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: https://github.com/thtrieu/darkflow

  2.  

  3. Visit https://pjreddie.com/darknet/yolov2/ and download the cfg and weights file for "Tiny Yolo". This will actually be Tiny Yolo V2.

  4.  

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

  6.  

  7. 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.)

  8.  

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

  10.  

 

If you receive the error "TypeError: makedirs() got an unexpected keyword argument 'exist_ok'", open darkflow/darkflow/net/build,py and darkflow/test/test_darkflow.py 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.

 

aeroplane bicycle bird boat bottle bus car cat chair cow diningtable dog horse motorbike person pottedplant sheep sofa train tvmonitor
0 Kudos
idata
Employee
3,885 Views

@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?
0 Kudos
idata
Employee
3,885 Views

@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: https://github.com/simo23/tinyYOLOv2/blob/master/test.py.

 

You can also check out a quick sample I created at https://github.com/tomepetty/TinyYoloV2_NCS.

0 Kudos
idata
Employee
3,885 Views

@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-2.05.00.02 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?

0 Kudos
idata
Employee
3,885 Views

@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 https://github.com/pjreddie/darknet/issues/468.

0 Kudos
idata
Employee
3,884 Views

@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.

0 Kudos
idata
Employee
3,884 Views

@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.

0 Kudos
idata
Employee
3,884 Views

@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)
0 Kudos
idata
Employee
3,884 Views

@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.

0 Kudos
idata
Employee
3,884 Views

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?

0 Kudos
Reply