pytorch / pytorch/vision

Attribute for size of classes in vision/torchvision/datasets/folder.py

Open
#431 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

module: datasets
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.