You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the YOLOv6 issues and found no similar feature requests.
Description
when i try to implement YOLOv6 over TensorRT in a jetson orin , i have errors using the module Processor.py , i solved this with it:
Changes in the post_process method: The line self.scale_coords(self.input_shape, det_t[0][:, :4], img_shape[0], img_shape[1]) in the post_process method was commented out to avoid an error. This line was responsible for scaling the object detection coordinates, but passing img_shape[0] and img_shape[1] as arguments caused an error because these values did not meet the expectations of the scale_coords function.
Use case
Final code used (save in root path: YOLOv6\testRT.py):
import cv2
import deploy.TensorRT.Processor as YOLORT
ratio_pat = None # No ratio_pad provided
img_shape = [img_model_size, ratio_pat] # Input image size to the model
detected_objects = processor.post_process(outputs, img_shape)
Print the detected objects
print(detected_objects)
Draw bounding boxes around the detected objects
for detection in detected_objects:
x1, y1, x2, y2, conf, cls = detection
color = (0, 255, 0) # Green color for the bounding box
label = f"Class: {int(cls)}, Confidence: {conf:.2f}"
cv2.rectangle(image, (int(x1), int(y1)), (int(x2), int(y2)), color, 2)
cv2.putText(image, label, (int(x1), int(y1) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
Display the resulting image
cv2.imshow("Detected Objects", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
In this code, an image is loaded, objects are detected using a TensorRT model, post-processing of the outputs is performed, and the detected objects are visualized by drawing bounding boxes around them in the original image. The calculation of ratio_pad has been omitted as it was not used in the scale_coords function.
Use:
cd YOLOv6
python3 testRT.py
Additional
No response
Are you willing to submit a PR?
Yes I'd like to help by submitting a PR!
The text was updated successfully, but these errors were encountered:
Gain ratio is not a part of tensorrt model. In tensorrt inference, you need to preprocess image (get the padding and scale ratio), tensorrt inference, post process(use padding and scale ratio to rescale the coordinates).
Search before asking
Description
when i try to implement YOLOv6 over TensorRT in a jetson orin , i have errors using the module Processor.py , i solved this with it:
Changes in the post_process method: The line self.scale_coords(self.input_shape, det_t[0][:, :4], img_shape[0], img_shape[1]) in the post_process method was commented out to avoid an error. This line was responsible for scaling the object detection coordinates, but passing img_shape[0] and img_shape[1] as arguments caused an error because these values did not meet the expectations of the scale_coords function.
Use case
Final code used (save in root path: YOLOv6\testRT.py):
import cv2
import deploy.TensorRT.Processor as YOLORT
Load the image
image_path = "IMG_DIR/22.png"
image = cv2.imread(image_path)
Instantiate the processor with the TensorRT model
model_path = "best.trt"
img_model_size = 192
processor = YOLORT.Processor(model_path,)
Detect objects in the image
outputs = processor.detect(image)
Post-process the outputs
ratio_pat = None # No ratio_pad provided
img_shape = [img_model_size, ratio_pat] # Input image size to the model
detected_objects = processor.post_process(outputs, img_shape)
Print the detected objects
print(detected_objects)
Draw bounding boxes around the detected objects
for detection in detected_objects:
x1, y1, x2, y2, conf, cls = detection
color = (0, 255, 0) # Green color for the bounding box
label = f"Class: {int(cls)}, Confidence: {conf:.2f}"
cv2.rectangle(image, (int(x1), int(y1)), (int(x2), int(y2)), color, 2)
cv2.putText(image, label, (int(x1), int(y1) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
Display the resulting image
cv2.imshow("Detected Objects", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
In this code, an image is loaded, objects are detected using a TensorRT model, post-processing of the outputs is performed, and the detected objects are visualized by drawing bounding boxes around them in the original image. The calculation of ratio_pad has been omitted as it was not used in the scale_coords function.
Use:
cd YOLOv6
python3 testRT.py
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: