priya-zha / Software-Engineering-Project

0 stars 2 forks source link

YOLO processing API returning object ID label instead of object name and object prediction ID. #20

Closed preddythandra closed 1 year ago

preddythandra commented 1 year ago

Detailed Description:

The server returns a image with the boundary box, but since labels information is not generated from the detection metadata, it return just the class number of the object identified.

Steps to Reproduce:

Change the detection's unloading from 5 (for ,, confidence, classid, in detection) variable to 3 variable (for confidence,classid, in detection)

Expected Behavior:

The server sends the image with object boundary box along with label and probability of label .

Actual Behavior:

The server only send the image with object boundary box, the labels are the class number with not label or probability information.

Before Fixing the bug:

image

After Fixing the bug: image

preddythandra commented 1 year ago

Fixed solution: Change the number of unrolling arguments to 5 to properly unfold the detection arguments.

https://github.com/priya-zha/Software-Engineering-Project/blob/730078b530c4372f3df1fa57047adcfd5f04c918/ML/main.py

 detections = sv.Detections.from_ultralytics(result)
            labels = [
                f"{model.model.names[class_id]} {confidence:0.2f}"
                for _,_, confidence, class_id, _ in detections
            ]
            image = sv.BoxAnnotator(thickness=2, text_thickness=2, text_scale=1).annotate(image, detections, labels)
            success, encoded_image = cv2.imencode(".jpg", image)