Attribute for size of classes in vision/torchvision/datasets/folder.py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
It would be great if you can provide one method inside ImageFolder class or Dataset class which can provide number of samples for each loaded class/label.
Though we can do this outside ImageFolder class, but as we always use ImageFolder for loading image dataset hence a class_size attribute will quickly tell us how many samples of each class/label are loaded.
Counting num of samples outside ImageFolder class:
from collections import Counter
image_datasets['train'] = datasets.ImageFolder(os.path.join(DATA_DIR, 'train'))
class_counts['train'] = dict(Counter(sample_tup[1] for sample_tup in image_datasets['train''].imgs))
cc @pmeier
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ImageFolder in vision/torchvision/datasets/folder.py and inspect how loaded samples and labels are stored. Implement the requested class or dataset access for the number of samples in each loaded class or label, then verify that counts can be retrieved for an ImageFolder dataset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100