yolov7 icon indicating copy to clipboard operation
yolov7 copied to clipboard

How to use cv2.dnn.readNetFromONNX import yolov7-tiny.onnx?

Open Barry-Chen-yup opened this issue 1 year ago • 0 comments

I use opencv dnn to get scores, classID, and confidence. But the scores result is still "[ ]". I can use opencv dnn in yolov4-tiny.weight. However, yolov7-tiny.onnx cannot use. How can I fix it?

a = '/workspace/tracker/code/yolo/yolov7-tiny.onnx' net = cv2.dnn.readNetFromONNX(a) net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA) blob = cv2.dnn.blobFromImage(frame, 1 / 255.0, (640, 640), swapRB=True, crop=False) net.setInput(blob) start = time.time() layerOutputs = net.forward(ln) boxes = [] confidences = [] classIDs = [] for output in layerOutputs: for detection in output: scores = detection[4:5] classID = np.argmax(scores) confidence = scores[classID]

Barry-Chen-yup avatar Aug 01 '22 19:08 Barry-Chen-yup