Harly-1506 / Faster-Inference-yolov8

Faster inference YOLOv8: Optimize and export YOLOv8 models for faster inference using OpenVINO and Numpy 🔢
4 stars 1 forks source link

Having issues in yolov8n detection model? #1

Closed ganesharavindh closed 1 month ago

ganesharavindh commented 1 month ago

I tried to use the yolov8n mode in Openvino and found that your repo has the numpy implementation of NMS, I commented some of your code to work for the detection model not only the segmented models and got the below error

[2024-07-29 18:09:28,219] [ERROR] too many values to unpack (expected 6) Traceback (most recent call last): File "./Faster-Inference-yolov8/main_faster.py", line 140, in main xmin, ymin, xmax, ymax, score, cls_id = bbox ValueError: too many values to unpack (expected 6)

To reproduce the same error do the following,

  1. yolo-v8 model conversion

from ultralytics import YOLO model = YOLO("yolov8n.pt") path = model.export(format="openvino")

  1. comment the line numbers from 139 to 192 and 207 to 235
  2. change the line no. 136 like this bboxes_, masks = detections['det'].tolist() if len(detections['det'])>0 else [], [] #detections['segment']
Harly-1506 commented 1 month ago

Hello @ganesharavindh,

Have you checked the requirements.txt file to ensure the library versions are the same? The error might occur with different library versions.

Could you also send me the output of the following code?

print(detections['det'])

And if possible, can you provide the code (or screenshot) that you are modified

ganesharavindh commented 1 month ago

Hello @Harly-1506 , You are correct, because of the version conflict I got that error and I found one more issue if you try to predict the small size images, the scaling bounding boxes to its original image size is not perfect, here I resized the bus image to (205, 270) and here is the resized image resized_image Output: image_with_bbox

Actually, the detection was correct but not the scaling it seems.

Harly-1506 commented 1 month ago

what about the model you have trained? the image size? I have tested with the image > 640 x 640 working well. Please confirm me this information

ganesharavindh commented 1 month ago

@Harly-1506 I didn't train the model, I used the default yolov8n openvino converted model using the below code

from ultralytics import YOLO model = YOLO("yolov8n.pt") path = model.export(format="openvino")

Harly-1506 commented 1 month ago

I highly recommend using images larger than 640x640 for better performance with YOLOv8. Larger images often provide more detail, which can lead to more accurate object detection and segmentation.

To resize your images, you can use methods available in libraries such as OpenCV, PIL (Pillow)...

I apologize for not being able to check the issue right now due to time constraints. However, these resizing methods should help you prepare your images for YOLOv8.

Additionally, I would appreciate it if you could star my repository on GitHub. It helps support the project and makes it more visible to others.

Thank you for your understanding and support!

ganesharavindh commented 1 month ago

Sure @Harly-1506 , Thank you for your support.