frame

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!

mobilenet-ssd‘s some layers output is nan when use the size of image larger than 300×300

when the size of input image is larger than 300×300, my grah’s conv2 and topper layer‘s output is nan,why?

Comments

  • 11 Comments sorted by Votes Date Added
  • Have you found the way to fix issue with higher resolution input? The latest version of NCSDK v1 still doesn't allow to use images with resolution higher than 300x300 for mobilenet ssd. I tried the model trained on 400x400 and 500x500, the mvNCCheck of movidius model returns nan . When using 300x300 everything is ok. This model was used https://github.com/chuanqi305/MobileNet-SSD

  • thanks for ans, I have change this codes from 300300 to 512512, but still receive NaN at conv2 and topper layer out

  • I have the same problem! Image with 300x300 is too small for some task, so I try to use 500,448,350, but all the output is nan!
    @batigol, did you solve the problem?

  • @batigol @z_huabao I have tested several images with resolution higher than 300 x 300 (500 x 500, 350 x 350, 450 x 450) and I was unable to reproduce your issue. SSD-MobileNet expects an image of size 300 x 300 and the included example in the NCAppZoo does image resizing so there should not be an issue. If you are using a different program, you may need to use the image resizing code provided in my post above to get the network to work.

  • @Tome_at_Intel If resize the image to 300x300 before inference, it will be OK in my program too!
    You say "SSD-MobileNet expects an image of size 300 x 300 ", but I have retrained a new SSD-MobileNet with 500x500 refer to "https://github.com/chuanqi305/MobileNet-SSD", you can reproduce it quickly(just initialize network and get *.caffemodel)

    then mvNCCompile my 500x500 SSD-MobileNet to get "graph" ,
    finally, modify and run the code as follow :

    def preprocess_image(src):
        # scale the image
        img = cv2.resize(src, (500, 500))
        # adjust values to range between -1.0 and + 1.0
        img = img - 127.5
        img = img * 0.007843
        return img

    Every thing seen to be right before I get the nan output !
  • The same to @batigol , my grah’s conv2 and topper layer‘s output is nan, check output as follow:

    zhb@zhb-pc:~/caffe-objects/MobileNet-SSD/example$ mvNCCheck MobileNetSSD_deploy.prototxt -w MobileNetSSD_deploy.caffemodel -s 12 -on conv1
    mvNCCheck v02.00, Copyright @ Movidius Ltd 2016
    
    /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance
      "Consider reducing your data sizes for best performance\033[0m")
    USB: Transferring Data...
    USB: Myriad Execution Finished
    USB: Myriad Connection Closing.
    USB: Myriad Connection Closed.
    Result:  (64, 256, 256)
    1) 2048968 294.0
    2) 2080868 286.5
    3) 2089761 277.0
    4) 2067065 276.5
    5) 2059346 262.0
    Expected:  (64, 256, 256)
    1) 2048968 293.75
    2) 2080868 287.0
    3) 2067065 276.75
    4) 2089761 276.75
    5) 2059346 262.0
    ------------------------------------------------------------
     Obtained values 
    ------------------------------------------------------------
     Obtained Min Pixel Accuracy: 0.21276595070958138% (max allowed=2%), Pass
     Obtained Average Pixel Accuracy: 0.002812110324157402% (max allowed=1%), Pass
     Obtained Percentage of wrong values: 0.0% (max allowed=0%), Pass
     Obtained Pixel-wise L2 error: 0.006101535874952356% (max allowed=1%), Pass
     Obtained Global Sum Difference: 34647.359375
    

    ------------------------------------------------------------

    zhb@zhb-pc:~/caffe-objects/MobileNet-SSD/example$ mvNCCheck MobileNetSSD_deploy.prototxt -w MobileNetSSD_deploy.caffemodel -s 12 -on conv2/dw
    mvNCCheck v02.00, Copyright @ Movidius Ltd 2016
    
    /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance
      "Consider reducing your data sizes for best performance\033[0m")
    USB: Transferring Data...
    USB: Myriad Execution Finished
    USB: Myriad Connection Closing.
    USB: Myriad Connection Closed.
    Result:  (64, 128, 128)
    1) 510139 261.0
    2) 515273 248.38
    3) 509039 244.12
    4) 522444 233.38
    5) 519339 232.62
    Expected:  (64, 128, 128)
    1) 775922 124.88
    2) 777241 120.12
    3) 783205 118.88
    4) 783859 110.19
    5) 781361 108.5
    ------------------------------------------------------------
     Obtained values 
    ------------------------------------------------------------
     Obtained Min Pixel Accuracy: 221.6341257095337% (max allowed=2%), Fail
     Obtained Average Pixel Accuracy: 7.541597634553909% (max allowed=1%), Fail
     Obtained Percentage of wrong values: 76.00011825561523% (max allowed=0%), Fail
     Obtained Pixel-wise L2 error: 13.444180850892486% (max allowed=1%), Fail
     Obtained Global Sum Difference: 9875038.0
    

    ------------------------------------------------------------

    zhb@zhb-pc:~/caffe-objects/MobileNet-SSD/example$ mvNCCheck MobileNetSSD_deploy.prototxt -w MobileNetSSD_deploy.caffemodel -s 12 -on conv2
    mvNCCheck v02.00, Copyright @ Movidius Ltd 2016
    
    /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance
      "Consider reducing your data sizes for best performance\033[0m")
    USB: Transferring Data...
    USB: Myriad Execution Finished
    USB: Myriad Connection Closing.
    USB: Myriad Connection Closed.
    Result:  (128, 128, 128)
    1) 2097151 nan
    2) 881284 nan
    3) 881272 nan
    4) 881273 nan
    5) 881274 nan
    Expected:  (128, 128, 128)
    1) 1609215 294.5
    2) 1618142 288.5
    3) 1611612 280.75
    4) 1610329 278.75
    5) 1620793 274.5
    /usr/local/bin/ncsdk/Controllers/Metrics.py:75: RuntimeWarning: invalid value encountered in greater
      diff)) / total_values * 100
    ------------------------------------------------------------
     Obtained values 
    ------------------------------------------------------------
     Obtained Min Pixel Accuracy: nan% (max allowed=2%), Fail
     Obtained Average Pixel Accuracy: nan% (max allowed=1%), Fail
     Obtained Percentage of wrong values: 39.70165252685547% (max allowed=0%), Fail
     Obtained Pixel-wise L2 error: nan% (max allowed=1%), Fail
     Obtained Global Sum Difference: nan
    ------------------------------------------------------------
    
  • @z_huabao Thanks for explaining that in detail. Can you supply your model so that I can test it? Thanks.

  • edited February 9 Vote Up0Vote Down

    @Tome_at_Intel yes, here are my prototxt and caffemodel : https://1drv.ms/f/s!AkW0b0sxkXkhgl5Xg7SGPnFhAOvG

  • edited March 30 Vote Up0Vote Down

    @Tome_at_Intel I have same problem. I simply modified 300x300 to 400x400 then SSD returns nothing.

    def preprocess_image(src):
        # scale the image
        NETWORK_WIDTH = 400
        NETWORK_HEIGHT = 400
        img = cv2.resize(src, (NETWORK_WIDTH, NETWORK_HEIGHT))
        # adjust values to range between -1.0 and + 1.0
        img = img - 127.5
        img = img * 0.007843
        return img

    Do you mean I have to use only 300x300 for SDD?
    The caffemodel and prototxt I used are from Ncappzoo.

    What should I do to change the model input size?

  • @hra.kim At the moment, you can only use 300x300 input size with SSD MobileNet. This is an issue that we are aware of and are working to fix at the moment.

  • @batigol If a model expects a specific input size and you do not perform an image resize before sending it for inference, you may receive errors or incorrect results.

    Just curious if you using the Mobilnet SSD example found in the Ncappzoo (https://github.com/movidius/ncappzoo/tree/master/caffe/SSD_MobileNet). The model included in the Ncappzoo Mobilenet-SSD example expects an image input size of 300 x 300 and performs an image resize before sending it to the NCS for an inference.

    Below you can find the image resizing code:

    def preprocess_image(src):
        # scale the image
        NETWORK_WIDTH = 300
        NETWORK_HEIGHT = 300
        img = cv2.resize(src, (NETWORK_WIDTH, NETWORK_HEIGHT))
    
        # adjust values to range between -1.0 and + 1.0
        img = img - 127.5
        img = img * 0.007843
        return img
    
Sign In or Register to comment.