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

is it valuable that add --cache-images option to detect.py? #2004

Closed
kyshel opened this issue Jan 21, 2021 · 4 comments
Closed

is it valuable that add --cache-images option to detect.py? #2004

kyshel opened this issue Jan 21, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@kyshel
Copy link

kyshel commented Jan 21, 2021

🚀 Feature

Add --cache-images option to detect.py like train.py

Motivation

There R about 300k images in my--source directory, when i run detect.py, I noticed that it seems like load and test images one by one , and my pc sound "pew-pew-pew-pew..." like a rushing laser weapon, maybe the disk is trembling. And it consumes a long time.

Maybe cached option(read from disk, and test direct in RAM) can speedup ? Or yolov5 has integrated this featue and just not provide visible option for users?

Pitch

Add --cache-images option to detect.py like train.py

Alternatives

Maybe add a script that make a big cache file from --src imgs?

Additional context

None.

@kyshel kyshel added the enhancement New feature or request label Jan 21, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2021

👋 Hello @kyshel, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@kyshel kyshel closed this as completed Jan 21, 2021
@kyshel kyshel changed the title is it valuable that add --cache-images option to test.py? is it valuable that add --cache-images option to detect.py? Jan 21, 2021
@kyshel kyshel reopened this Jan 21, 2021
@glenn-jocher
Copy link
Member

@kyshel the purpose of caching images into RAM during training is that each image may be loaded hundreds or thousands of times during training.

Inference loads each image once, therefore caching images is a meaningless concept in this setting.

@glenn-jocher
Copy link
Member

glenn-jocher commented Jan 21, 2021

@kyshel I think what you're looking for is batched inference. You can use test.py for batched inference, or you can create your own inference loop using a PyTorch Hub autoshape YOLOv5 model that also runs batched inference automatically:

PyTorch Hub

To run batched inference with YOLOv5 and PyTorch Hub:

import torch
from PIL import Image

# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)

# Images
img1 = Image.open('zidane.jpg')
img2 = Image.open('bus.jpg')
imgs = [img1, img2]  # batched list of images

# Inference
result = model(imgs)

@kyshel
Copy link
Author

kyshel commented Jan 22, 2021

@glenn-jocher Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants