Using a resnet18.onnx model

Hello Dustin,

I was using the tutorial “Hello AI WORD” for creating my trained model. Everything was ok until I obtained the onnx model.
I was trying to make an example in python but I get an error that I cannot find the solution.

The code is:

import jetson.inference
import jetson.utils
import cv2
import numpy as np
import time
width=800
height=600
dispW=width
dispH=height

cam1=cv2.VideoCapture(’/dev/video0’)
cam1.set(cv2.CAP_PROP_FRAME_WIDTH,dispW)
cam1.set(cv2.CAP_PROP_FRAME_HEIGHT,dispH)
net = jetson.inference.imageNet(‘alexnet’,[’–model=/home/pc/jetson-inference/python/training/classification/myModel/resnet18.onnx’,’–input_blob=input_0’,’–output_blob=output_0’,’–labels=/home/pc/Documents/jetsonr/mytrain/labels.txt’])

font=cv2.FONT_HERSHEY_SIMPLEX
timeMark=time.time()
fpsFilter=0
while True:
_,frame=cam1.read()
img=cv2.cvtColor(frame,cv2.COLOR_BGR2RGBA).astype(np.float32)
img=jetson.utils.cudaFromNumpy(img)
classID, confidence =net.Classify(img, width, height)
item=’’
item =net.GetClassDesc(classID)
dt=time.time()-timeMark
fps=1/dt
fpsFilter=.95fpsFilter +.05fps
timeMark=time.time()
cv2.putText(frame,str(round(fpsFilter,1))+’ fps '+item,(0,30),font,1,(0,0,255),2)
cv2.imshow(‘recCam’,frame)
cv2.moveWindow(‘recCam’,0,0)
if cv2.waitKey(1)==ord(‘q’):
break
cam1.releast()
cv2.destroyAllWindows()

The error of the compilation is:

jetson.inference.init.py
jetson.inference – initializing Python 3.6 bindings…
jetson.inference – registering module types…
jetson.inference – done registering module types
jetson.inference – done Python 3.6 binding initialization
jetson.utils.init.py
jetson.utils – initializing Python 3.6 bindings…
jetson.utils – registering module functions…
jetson.utils – done registering module functions
jetson.utils – registering module types…
jetson.utils – done registering module types
jetson.utils – done Python 3.6 binding initialization
Traceback (most recent call last):
File “my-detection4.py”, line 3, in
import cv2
File “/usr/local/lib/python3.6/dist-packages/cv2/init.py”, line 89, in
bootstrap()
File “/usr/local/lib/python3.6/dist-packages/cv2/init.py”, line 79, in bootstrap
import cv2
ImportError: /usr/local/lib/libopencv_cudaarithm.so.4.1: undefined symbol: _ZN2cv4cuda14StreamAccessor9getStreamERKNS0_6StreamE

Do you know how I can fix this error of cuda?

Thank you and best regards,
Salva