Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.
5546 Discussions

How to use neural compute stick2 run my own caffe model?

Shaw__Louis
Beginner
100 Views

I think the only modification I should do is on my preprocess part.Here are my preprocess part code:

def TransmissionEstimate(im_path, height, width):
    caffe.set_mode_cpu()
    #net = caffe.Net('DehazeNet-new122.prototxt', 'solver-new122_iter_57198.caffemodel', caffe.TEST)
    plugin = IEPlugin(device="MYRIAD")
        
    net = IENetwork.from_ir(model="/home/louis/intel/computer_vision_sdk_2018.5.455/deployment_tools/model_optimizer/solver-new122_iter_100000.xml", weights="/home/louis/intel/computer_vision_sdk_2018.5.455/deployment_tools/model_optimizer/solver-new122_iter_100000.bin")
    input_blob = next(iter(net.inputs))
    out_blob = next(iter(net.outputs))
    exec_net = plugin.load(network=net)
    im = caffe.io.load_image(im_path)
    im = im*255
    npad = ((7,8), (7,8), (0,0))
    im = np.pad(im, npad, 'symmetric')
    transformers = caffe.io.Transformer({'data':net.inputs[input_blob].shape})
    transformers.set_transpose('data', (2,0,1))
    transformers.set_raw_scale('data',255)
    transformers.set_channel_swap('data', (2,1,0))
    
    out = exec_net.infer(inputs={input_blob:np.array([transformers.preprocess('data', im)])})
    
    transmission = np.reshape(out['convC'], (height,width))
    return transmission

 

After I run my code and the error is:

Traceback (most recent call last):
  File "DehazeNet-new1222.py", line 99, in <module>
    te = TransmissionEstimate(im_path, height, width)
  File "DehazeNet-new1222.py", line 35, in TransmissionEstimate
    transmission = np.reshape(out['convC'], (height,width))
KeyError: 'convC'

 

but I checked the file solver-new122_iter_100000.xml ,there do have the Key 'convC'. So what I suppose to do with my code?where I should do some modification?Help me please!!!!I am begging you !!

0 Kudos
1 Reply
Shubha_R_Intel
Employee
100 Views

Dear Shaw, Louis,

The error you're getting means that there is no output layer named 'convC'. Layer names are usually hierarchical, meaning, they're not just "convC" but rather something like "layer1/output/convC" . 

Hope it helps,

Thanks,

Shubha

Reply