yolov9
yolov9 copied to clipboard
How should I run inference on an RTSP stream for person detection?
I want to run an inference on an RTSP stream, for person detection. I have cloned the repo, downloaded model C - yolov9-c.pt, and stored it in the weights directory.
I am running the code with the following command:
python3 detect.py --weights weights/yolov9-c.pt --conf 0.1 --source rtsp://mystream
But it throws an error:
detect: weights=['weights/yolov9-c.pt'], source=rtsp://mystream, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLOv5 🚀 1e33dbb Python-3.8.10 torch-2.2.1+cu121 CUDA:0 (NVIDIA GeForce GTX 1060 6GB, 6072MiB)
Fusing layers...
Model summary: 724 layers, 51141120 parameters, 0 gradients, 238.7 GFLOPs
WARNING ⚠️ Environment does not support cv2.imshow() or PIL Image.show()
OpenCV(4.9.0) /io/opencv/modules/highgui/src/window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
1/1: rtsp://mystream... Success (inf frames 3840x2160 at 20.00 FPS)
Traceback (most recent call last):
File "detect.py", line 232, in <module>
main(opt)
File "detect.py", line 227, in main
run(**vars(opt))
File "/home/demopc/yolov9/myenv/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "detect.py", line 87, in run
for path, im, im0s, vid_cap, s in dataset:
File "/home/demopc/yolov9/utils/dataloaders.py", line 406, in __next__
if not all(x.is_alive() for x in self.threads) or cv2.waitKey(1) == ord('q'): # q to quit
cv2.error: OpenCV(4.9.0) /io/opencv/modules/highgui/src/window.cpp:1338: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
terminate called without an active exception
Aborted (core dumped)
I have installed all the required packages from requirements.txt and I have GUI support on my server
- What is this error about?
- How should I specify only person detection?
Hello.
what brand and model is your camera? That rtsp link you have seems fishy.
I have an Axis M1125 with a custom trained model. I run the model with these parameters:
python detect.py --weights runs\train\exp3\weights\best_striped.pt --conf 0.5 --source "rtsp://user:[email protected]:8554/axis-media/media.amp" --device 0 --nosave.
And it works fine.
Do not forget to create a clean environment and apply pip install -r requirements.txt
Have a great day.