-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Example images always inferred when running detect.py - how can I stop this? #13457
Comments
👋 Hello @essair, thank you for your interest in YOLOv5 🚀! Please make sure you have reviewed the YOLOv5 documentation and guides to help troubleshoot. They include helpful resources for topics ranging from custom data training to model debugging. If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it. This will help us investigate the issue effectively. If this is a custom training ❓ Question, please include as much information as possible, such as your dataset structure, image examples, and any training logs. Make sure you are following the best practices for achieving optimal training results. RequirementsEnsure you are using Python>=3.8.0 with all dependencies installed, including PyTorch>=1.8. You can set up YOLOv5 locally by cloning the repository, navigating to the folder, and installing the required dependencies. EnvironmentsYOLOv5 can run in various verified environments, including cloud notebooks with free GPUs, Google Cloud Deep Learning VMs, AWS Deep Learning AMIs, and Docker images with all dependencies preinstalled. Make sure your selected environment is up to date. StatusVerify the status of YOLOv5 GitHub Actions Continuous Integration (CI) tests for the latest functionality. These tests verify proper model operation across various tasks such as training, validation, inference, and export. This is an automated response to ensure you get help as quickly as possible. An Ultralytics engineer will respond soon to provide additional assistance. Thank you for your patience! 😊 |
Does anyone have ideas how to solve this problem? Its slowing my work down and I'd be really grateful if someone has advice on how to stop it! |
@essair it seems like your |
Thank you for your help, I found out that it's caused by the way I'm calling the script, reticulate is not only sourcing but also running the script once before inferring with my settings! It turns out though that calling the script with reticulate is still quicker for me than using a system call! I'm assuming there is no way to remove the default values in the detect.py script to prevent it from running when initialised? |
You're correct that |
Search before asking
YOLOv5 Component
Detection
Bug
This is the output I get when running detect.py - each single time it runs the example images with the default model and then infers on my images with my model!
detect: weights=../../yolov5/yolov5s.pt, source=../../yolov5/data/images, data=../../yolov5/data/coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_format=0, save_csv=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=../../yolov5/runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLOv5 🚀 v7.0-389-ge62a31b6 Python-3.8.10 torch-2.4.1+cu121 CPU
Fusing layers...
YOLOv5s summary: 213 layers, 7225885 parameters, 0 gradients, 16.4 GFLOPs
image 1/2 /home/name/yolov5/data/images/bus.jpg: 640x480 4 persons, 1 bus, 37.6ms
image 2/2 /home/name/yolov5/data/images/zidane.jpg: 384x640 2 persons, 2 ties, 32.2ms
Speed: 0.2ms pre-process, 34.9ms inference, 0.9ms NMS per image at shape (1, 3, 640, 640)
Results saved to ../../yolov5/runs/detect/exp418
YOLOv5 🚀 v7.0-389-ge62a31b6 Python-3.8.10 torch-2.4.1+cu121 CPU
Fusing layers...
Model summary: 157 layers, 7012822 parameters, 0 gradients, 15.8 GFLOPs
image 1/2 /dev/shm/2024-12-09/0299/3f2a3b04-70d0-4c88-a17d-9dec8fbfe9fb_00000000f6acf5d2_Z2EnnHkxxRg_day_2024-12-09T120039.jpg: 384x640 (no detections), 34.0ms
image 2/2 /dev/shm/2024-12-09/0299/9425430e-21f5-435c-a613-1dc4d0d60585_00000000f6acf5d2_G1yv3N-8gWM_night_2024-12-09T000035.jpg: 384x640 (no detections), 30.6ms
Environment
YOLOv5 🚀 v7.0-389-ge62a31b6 Python-3.8.10 torch-2.4.1+cu121 CPU
OS: Pop OS 20.04
Minimal Reproducible Example
I'm running detect.py as part of a pipeline processing many images. The pipeline is in R, here is where I call detect.py:
reticulate::use_virtualenv(virtualenv = file.path(user_path, "yolov5/venv"), required=TRUE)
reticulate::source_python(file.path(user_path, "yolov5/detect.py"))
run(source = image_folder, weights = model,
save_csv = TRUE, save_conf = TRUE, save_crop = TRUE, save_txt = TRUE,
exist_ok = FALSE, name= results_temp_folder, nosave = nosave_settings)
Every single time I run this line for each batch of images - thats several thousand times! - it first runs the detection on the example images, saving the results to the nth run in the yolov5 folder and then it runs on my images. Its costing me time and space on my computer! And I would be very grateful if someone can help me to prevent it from running!
Additional
I've tried running my script on another computer with a more up to date OS: Ubuntu 24 and Python 3.12 the exact same things happens!
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: