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.
6392 Discussions

A raspberrypi 3 program, pidentify, that worked OK on V1 ncsdk but fails on V2 ncsdk

idata
Employee
704 Views

Hi

 

1) I previously successfully executed the raspberrypi3 pidentify program on V1 ncsdk.

 

(reference https://www.rs-online.com/designspark/ai-powered-identification-with-the-pidentifier )

 

2) After building a clean V2 ncsdk and ncappzoo I failed to obtain any correct

 

result for pidentify after converting from V1 to V2 as per Movidius documentation.

 

3) I further tried the shim conversion method so that the V1 pidentify need not be changed

 

the failed result was similar, ie execution with no reported error, but incorrect results.

 

a) I noticed that the last few 'output' indexes did not change even when the camera lens was blocked.

 

Earlier indexes do change from cycle to cycle and from camera blocked/unblocked states.

 

Since the last output is used to report the highest priority this implies that the statement:

 

graph.queue_inference_with_fifo_elem(input_fifo, output_fifo, tensor,None) returns the wrong probabilities. This erroneous result is also true for the shim version's statement: graph.LoadTensor( img.astype( numpy.float16 ), 'user object' )

 

b) the camera provides credible image data at:

 

IMAGE_PATH = '/tmp/i-spy.jpg'

 

c) The Oled device correctly operates, though the ouput text is incorrect and does

 

not change from sample to sample.

 

4) In order to build confidence in my V2 installation I tried the TinyYolo example. Though this worked

 

it produces warnings as follows:

 

** (TinyYolo (hit key to exit):1274): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files

 

/usr/local/lib/python3.5/dist-packages/mvnc/mvncapi.py:406: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead

 

tensor = numpy.fromstring(tensor.raw, dtype=numpy.float32)

 

Running NCS Caffe TinyYolo example

 

Displaying image with objects detected in GUI

 

Click in the GUI window and hit any key to exit

 

Found this many objects in the image: 1

 

box at index 0 is… left: 227, top: 182, right: 589, bottom: 678

 

Finished

 

5) The above fromstring() frombuffer() warning also occured in the pidentify V2 version. Is this symptomatic of the deeper problem?

 

6) My shim version of pidentify is given below:

 

#!/usr/bin/python3 import os import sys import time import numpy #import mvnc.mvncapi as mvnc sys.path.insert(0,"../../../ncappzoo/ncapi2_shim") import mvnc_simple_api as mvnc import picamera import skimage from skimage import io, transform from DesignSpark.Pmod.HAT import createPmod from luma.core.render import canvas from luma.oled.device import ssd1331 NCAPPZOO_PATH = os.path.expanduser( '~/ncappzoo' ) GRAPH_PATH = NCAPPZOO_PATH + '/caffe/GoogLeNet/graph' IMAGE_PATH = '/tmp/i-spy.jpg' IMAGE_MEAN = [ 104.00698793, 116.66876762, 122.67891434] IMAGE_STDDEV = 1 IMAGE_DIM = ( 224, 224 ) NETWORK_STAT_TXT = NCAPPZOO_PATH + '/apps/stream_infer/googlenet_stat.txt' NETWORK_CATEGORIES_TXT = NCAPPZOO_PATH + '/apps/stream_infer/googlenet_categories.txt' camera = picamera.PiCamera() camera.resolution = IMAGE_DIM pmoddev = createPmod('OLEDrgb','JA') oled = pmoddev.getDevice() ncsdevices = mvnc.EnumerateDevices() if len( ncsdevices ) == 0: print( 'No NCS devices found' ) quit() ncs = mvnc.Device( ncsdevices[0] ) ncs.OpenDevice() with open( GRAPH_PATH, mode='rb' ) as f: blob = f.read() graph = ncs.AllocateGraph( blob ) gNetworkCategories = [] with open(NETWORK_CATEGORIES_TXT, 'r') as f: for line in f: cat = line.split('\n')[0] if cat != 'classes': gNetworkCategories.append(cat) f.close() last = len(gNetworkCategories)-1 print("last = ", last ) def getTopInference(img): img = print_img = skimage.io.imread( IMAGE_PATH ) img = skimage.transform.resize( img, IMAGE_DIM, preserve_range=True ) img = img[:, :, ::-1] img = img.astype( numpy.float32 ) img = ( img - IMAGE_MEAN ) * IMAGE_STDDEV graph.LoadTensor( img.astype( numpy.float16 ), 'user object' ) output, userobj = graph.GetResult() order = output.argsort() print(order) top = gNetworkCategories[order[last-0]] return top def display(message): with canvas(oled) as draw: draw.text((16,20), message, fill="white") try: while True: camera.capture(IMAGE_PATH) thing = getTopInference(IMAGE_PATH) display(thing) print("done") time.sleep(1) except KeyboardInterrupt: print("done") pass finally: graph.DeallocateGraph() ncs.CloseDevice() oled.cleanup()

 

Summary

 

a)For the pidentify program with V1 to V2 translation using the shim method or converting using the Movidius

 

translation documentation resulted in neither program versioins working on a V2 installation.

 

b) TinyYolo reports a tensor related (warning) errors though did produce a credible result on the V2 installation

 

Any identification/correction of the anomalies' source appreciated.

0 Kudos
4 Replies
idata
Employee
365 Views

@jslawton Hi, I don't see anything obviously wrong with your code. What kind of results are you seeing? Can you try using an image from the ncsdk/examples/data/images directory and let me know what the result is? Try cat.jpg and 512_Electricguitar.jpg. Thanks.

0 Kudos
idata
Employee
365 Views

Hi

 

I tried your suggestion but unfortunately to no avail. I tried a series of checks on this and other examples in the ncsdk. They work with a caveat warning on 'fromstring'. The camera and oled display also appear to work in the script(s) so I remain puzzled!

 

Checks 1,…,5 listed below:

 

I guess my best approach is to rewrite this simple app around another V2 example.

 

Thank you for your help

 

1) checked Movidius access via hello_ncs.cpp. Result executes OK

 

2) checked program executes with camera connected. Result fails to identify a mug or other object placed in camera field of view

 

3) check a valid image is returned rom the camera. Result /temp/i-spy.jpg contains a valid image.

 

4) try detecting the 512_ElectricGuitar.jpg with the image path set:

 

IMAGE_PATH = '/home/pi/ncsdk/examples/data/images/512_ElectricGuitar.jpg'

 

Note the camera acquisition is stopped:

 

camera.capture(IMAGE_PATH)

 

Result. Fails to identify and an error/warning given for the first pass

 

ERROR and WARNING REPORT

 

/usr/local/lib/python3.5/dist-packages/skimage/transform/_warps.py:105: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.

 

warn("The default mode, 'constant', will be changed to 'reflect' in "

 

/usr/local/lib/python3.5/dist-packages/skimage/transform/_warps.py:110: UserWarning: Anti-aliasing will be enabled by default in skimage 0.15 to avoid aliasing artifacts when down-sampling images.

 

warn("Anti-aliasing will be enabled by default in skimage 0.15 to "

 

/usr/local/lib/python3.5/dist-packages/mvnc/mvncapi.py:408: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead

 

tensor = numpy.fromstring(tensor.raw, dtype=numpy.float16)

 

5)Tried /home/pi/ncsdk/examples/caffe/GoogLeNet/run.py to determine if the (same) graph can be detected

 

for this example. Result: Works OK but the error/warning 'fromstring'as 4) is returned.

 

Summary: Both V1 and V2 versions fail in the same manner.

 

Both incorrectly report 'teddy' on the oled display.

 

Both do not change the reported classification when the camera optics are blocked.
0 Kudos
idata
Employee
365 Views

Hi Tome_at_Intel

 

I modified /home/pi/ncsdk/examples/caffe/GoogLeNet/run.py to accept the camera input. This works OK! I'll add the oled display next.

 

Thank you for your prompt.
0 Kudos
idata
Employee
365 Views

Hi

 

The oled device also works in this Version 2 context.

 

Thanks again
0 Kudos
Reply