jetson_yolov5_tensorrt icon indicating copy to clipboard operation
jetson_yolov5_tensorrt copied to clipboard

how can i use this code to two-category yolov5.trt

Open little-siskin opened this issue 3 years ago • 3 comments

i use this code but i got wrong resuit

little-siskin avatar Jan 04 '22 15:01 little-siskin

i use this code without docker

little-siskin avatar Jan 04 '22 15:01 little-siskin

`import cv2 from yolov5_trt import Yolov5TRTWrapper

engine_path = '/home/o/zrl/models/short/ki67.trt' labels = ['Y_3', 'B_1'] # List of class names for your model conf_th = 0.25 # Confidence threshold

wrapper = Yolov5TRTWrapper(engine_path, labels=labels, conf_thresh=conf_th) # See additional options in trt/examples/yolov5_detect.py

images_paths = ["/home/o/zrl/test/2100868-20211012124523_11_8_0.jpg", "/home/o/zrl/test/2101192C-20211012124324_11_13.jpg"] # Path to images

_images_paths = images_paths.split(',')

images_batch = [cv2.imread(image_path) for image_path in images_paths] # read images batch

for image, bboxes in wrapper.detect_from_itterator(images_batch): # Gets detection and image from the itterator image = wrapper.draw_detections(image, bboxes) # Drawing bboxes on the image cv2.imwrite('demo.jpg', image) print(bboxes)`

my code is here could you give me some advice thanks

little-siskin avatar Jan 04 '22 15:01 little-siskin

@little-siskin Hello, you are do not provide an example of the model wrong output. By the way, it may depend on your model or environment, the inference code is simple and straightforward. The first a wall, are you sure, that's you running your code on Jetson? Jetson has different memory management than regular PC, it used the same memory for GPU and CPU, and code uses this feature for the inference speedup.

alxmamaev avatar Jan 18 '22 08:01 alxmamaev