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

how to count number of objects in an image #4

Open
Shivani175 opened this issue Jun 4, 2022 · 1 comment
Open

how to count number of objects in an image #4

Shivani175 opened this issue Jun 4, 2022 · 1 comment

Comments

@Shivani175
Copy link

I have trained a model for detecting bottles, now how to count number of bottles in an image?

@jurvanwijk
Copy link

For a subdirectory with all the label txt files, exports a excel file with the counting per label file:

labeldir = 'insert label subdirectory'
names={}
for fn in glob.glob(labeldir + '*.txt'):
with open(fn) as f:
print(f)
names[fn]=sum(1 for line in f if line.strip() and not line.startswith('#'))

with open('yolov5/runs_pool/detect_test/true_det.csv', 'w') as f:
for key in names.keys():
f.write("%s, %s\n" %(key, names[key]))

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

No branches or pull requests

2 participants