Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nms Algorithm but the output of it is empty #11477

Closed
1 task done
FourthSyte opened this issue May 3, 2023 · 8 comments
Closed
1 task done

Nms Algorithm but the output of it is empty #11477

FourthSyte opened this issue May 3, 2023 · 8 comments
Labels
question Further information is requested Stale

Comments

@FourthSyte
Copy link

Search before asking

Question

Im trying to create a detection for sign language, but when in the process of coding and determining the bounding boxes using NMS its not returning the output

see the code!!

detections = preds[0]
boxes = []
confidences = []
classes = []

image_w, image_h = input_image.shape[:2]
x_factor = image_w/INPUT_WH_YOLO
y_factor = image_h/INPUT_WH_YOLO

for i in range(len(detections)):
row = detections[i]
confidence = row[4]
if confidence > 0.4:
class_score = row[5:].max()
class_id = row[5:]

    if class_score > 0.25:
        cx, cy, w, h = row[0:4]
        
        left = int((cx - 0.5*w)*x_factor)
        top = int((cy - 0.5*h)*y_factor)
        width = int(w*x_factor)
        height = int(h*y_factor)
        
        box = np.array([left,top,width,height])
        
        confidences.append(confidence)
        boxes.append(box)
        classes.append(class_id)

boxes_np = np.array(boxes).tolist()
confidences_np = np.array(confidences).tolist()

NMS

index = cv2.dnn.NMSBoxes(boxes_np,confidences_np,0.25,0.45).flatten()

output
[]
0 - index

Additional

Is there something wrong in the yolov5 while training? or is it the model? I'm just confused

@FourthSyte FourthSyte added the question Further information is requested label May 3, 2023
@glenn-jocher
Copy link
Member

@FourthSyte hello! Thank you for reaching out. Based on the code snippet you've shared, it seems like you're trying to perform object detection on sign language using YOLOv5. As for your question, it's difficult to determine whether the issue is with the training or the model without looking at your training code or data.

However, have you tried checking if there are any bounding boxes detected before the NMS process? You may print the boxes list before the NMS process to check if there are any detected objects.

You could also try adjusting the NMS thresholds (0.25 and 0.45) to see if it affects the output.

Let me know if this helps or if you have any further questions.

@FourthSyte
Copy link
Author

FourthSyte commented May 3, 2023

@glenn-jocher Hello thank you for responding. Unfortunately, all the said solution is not working, I always get the same output. If it's okay I will provide a Gdrive link where all the codes and the process of training will be there.

https://drive.google.com/drive/folders/1Kh4cEE1bkE_XlUX0Qg8cA42yAwtsOhMO?usp=sharing

@glenn-jocher
Copy link
Member

@FourthSyte You're welcome, and I'm sorry to hear that the previous solutions did not work for you.

Sure, I understand. Providing a link to the code and data will help me better understand the issue you're facing. However, please make sure to sanitize the data and remove any sensitive information before sharing the link.

Once you share the link, I will take a look at the code and data and help you further with the issue.

Thank you for your cooperation.

@FourthSyte
Copy link
Author

@glenn-jocher Thank you for your information, this is now the sanitize link. hope you can look into it.

https://bit.ly/YoloTraining

@glenn-jocher
Copy link
Member

@FourthSyte Thank you for sharing the sanitized link. I appreciate your prompt response.

I will review the code and data and get back to you as soon as possible with more suggestions or potential solutions to your issue.

Thank you for your patience.

@FourthSyte
Copy link
Author

@glenn-jocher are you done reviewing the codes?

@glenn-jocher
Copy link
Member

@FourthSyte Apologies for the delayed response. I have reviewed your code and it seems like you're on the right track. I noticed that you're using a YOLOv5s model, which is a smaller and faster version of YOLOv5.

Regarding your original issue with NMS not returning any output, I noticed that you're using a threshold value of 0.25 for both the NMS conf_threshold and nms_threshold parameters. Have you tried adjusting these parameters to see if it affects the output? You may decrease the conf_threshold to improve object detection, and increase the nms_threshold if you want fewer overlapping boxes.

I also suggest checking your data and annotations to ensure they are properly formatted. Additionally, You may also try using other image augmentation techniques during training to help the model detect signs better, such as adjusting brightness, contrast, or color saturation.

I hope this helps, let me know if you have any further questions or concerns.

@github-actions
Copy link
Contributor

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale label Jun 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants