Creating a variable to track the number of objects detected in a series of images #2473
Unanswered
matt-humphrey
asked this question in
Q&A
Replies: 1 comment
-
@matt-humphrey you might want to use YOLOv5 PyTorch Hub models for more customizable python workflows. To count the number of objects in an image: import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
# Images
dir = 'https://github.com/ultralytics/yolov5/raw/master/data/images/'
imgs = [dir + f for f in ('zidane.jpg', 'bus.jpg')] # batch of images
# Inference
results = model(imgs)
results.print() # or .show(), .save() See PyTorch Hub Tutorial to get started: YOLOv5 Tutorials |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm developing a model that counts the number of snails on a farm, and have then got a function which will take a static image from google maps and place a marker where each image was taken. I'm trying to link each location/image and the number of snails in that area.
Is it possible to create a variable or a dictionary (or otherwise) which links the number of snails and the image that the count was obtained from, such that I can call that variable after detection?
At the moment, the best method I can think of is using --save-txt when using detect.py, and then parsing through each text file to count the number of snails detected. I'd then create a dictionary with the name of each image as the key, and the number of snails as the value.
Is there a better way to do this?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions