ultralytics / ultralytics

Ultralytics YOLO11 πŸš€
https://docs.ultralytics.com
GNU Affero General Public License v3.0
33.09k stars 6.37k forks source link

crash when use ObjectCounter in background terminal environment without a graphical user interface #16099

Open sinopec opened 2 months ago

sinopec commented 2 months ago

Search before asking

Ultralytics YOLO Component

Other

Bug

I use the solutions.ObjectCounter for object counting ,but in background app, without a user interface,. So I set view_img=False, when init ObjectCounter, But the app crashed unexpected. And I track the program, found it crash in utils/checks.py:check_imshow. I think when i set view_img=False, we should not check the imshow again.

Environment

Ultralytics YOLOv8.2.78 πŸš€ Python-3.8.10 torch-2.1.1+cu121 CUDA:0 (NVIDIA GeForce RTX 3090, 24260MiB) Setup complete βœ… (16 CPUs, 62.5 GB RAM, 433.5/467.9 GB disk)

OS Linux-5.15.0-119-generic-x86_64-with-glibc2.29 Environment Linux Python 3.8.10 Install pip RAM 62.52 GB CPU 11th Gen Intel Core(TM) i7-11700 2.50GHz CUDA 12.1

numpy βœ… 1.24.4<2.0.0,>=1.23.0 matplotlib βœ… 3.7.2>=3.3.0 opencv-python βœ… 4.6.0.66>=4.6.0 pillow βœ… 10.3.0>=7.1.2 pyyaml βœ… 6.0>=5.3.1 requests βœ… 2.32.2>=2.23.0 scipy βœ… 1.8.1>=1.4.1 torch βœ… 2.1.1>=1.8.0 torchvision βœ… 0.16.1>=0.9.0 tqdm βœ… 4.64.1>=4.64.0 psutil βœ… 5.9.5 py-cpuinfo βœ… 9.0.0 pandas βœ… 1.4.3>=1.1.4 seaborn βœ… 0.11.2>=0.11.0 ultralytics-thop βœ… 2.0.3>=2.0.0

Minimal Reproducible Example

counter = solutions.ObjectCounter( view_img=False, reg_pts=roi_xy, names=self.model.names, draw_tracks=False, line_thickness=2, )

Additional

No response

Are you willing to submit a PR?

CharanPrasadK commented 2 months ago

@sinopec When you are using view_img=False, then your cv2 window won't be opened then just install opencv-python-headless. If you using own user interface then install this library 'pip install opencv-python-headless'.