ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.09k stars 16.42k forks source link

How to change the thickness & the transparency of the bounding boxes ? #13412

Open andreade11 opened 2 weeks ago

andreade11 commented 2 weeks ago

Search before asking

Question

Basically i would like my bounding boxes to become nearly transparent as my program is to detect text that is near them and sometimes they hide the text and my OCR model cannot detect them completely. So ideally I would like to make them nearly transparent or with the smallest thickness possible. I tried looking in detect.py and changing the line_thickness=1 but it doesnt produce anything...

Additional

No response

UltralyticsAssistant commented 2 weeks ago

👋 Hello @andreade11, thank you for your interest in YOLOv5 🚀! This is an automated response to help get you started. An Ultralytics engineer will also assist you soon.

To adjust the thickness and transparency of bounding boxes in YOLOv5, you might need to modify certain parts of the code, such as in the detect.py script. If simply changing line_thickness didn't yield the desired results, you may want to ensure that your adjustments are in the correct sections of the code where the boxes are actually drawn.

For a more precise solution, please provide a minimum reproducible example with details on how you're invoking the detection and where exactly you've tried to make changes. This will greatly help us in debugging the issue.

For customizations and visualization improvements, make sure your setup satisfies all requirements. YOLOv5 is compatible with Python 3.8 and above, and requires all necessary packages as listed in our requirements.txt.

You can also try running YOLOv5 in any of our verified environments, including web-based notebooks or cloud services, where all dependencies are pre-installed. Check if similar behavior is observed in these environments to rule out local setup issues.

If CI tests are passing (indicated by a green badge), YOLOv5 functionalities related to training, validation, inference, and export are working as expected across various platforms.

Thanks for your patience and hope you find this information helpful! 😊

andreade11 commented 2 weeks ago

👋 Hello @andreade11, thank you for your interest in YOLOv5 🚀! This is an automated response to help get you started. An Ultralytics engineer will also assist you soon.

To adjust the thickness and transparency of bounding boxes in YOLOv5, you might need to modify certain parts of the code, such as in the detect.py script. If simply changing line_thickness didn't yield the desired results, you may want to ensure that your adjustments are in the correct sections of the code where the boxes are actually drawn.

For a more precise solution, please provide a minimum reproducible example with details on how you're invoking the detection and where exactly you've tried to make changes. This will greatly help us in debugging the issue.

For customizations and visualization improvements, make sure your setup satisfies all requirements. YOLOv5 is compatible with Python 3.8 and above, and requires all necessary packages as listed in our requirements.txt.

You can also try running YOLOv5 in any of our verified environments, including web-based notebooks or cloud services, where all dependencies are pre-installed. Check if similar behavior is observed in these environments to rule out local setup issues.

If CI tests are passing (indicated by a green badge), YOLOv5 functionalities related to training, validation, inference, and export are working as expected across various platforms.

Thanks for your patience and hope you find this information helpful! 😊

I changed line_thickness=1 in the def run()function

pderrenger commented 2 weeks ago

@andreade11 to adjust the transparency of bounding boxes, you can modify the plot_one_box function in utils/plots.py to include an alpha channel for transparency. For thickness, ensure line_thickness is set correctly in the detect.py script. If changes aren't reflecting, double-check that you're editing the correct instance of the function where the boxes are drawn. If you need further assistance, please provide a minimal reproducible example.