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

RuntimeError: selected index k out of range #1

Closed
Lagunaxx opened this issue Dec 20, 2023 · 3 comments
Closed

RuntimeError: selected index k out of range #1

Lagunaxx opened this issue Dec 20, 2023 · 3 comments

Comments

@Lagunaxx
Copy link

hi, playin with example zero_shot.py and got error RuntimeError: selected index k out of range (line 174).
what can be metter of this? how to avoid error?

@samuelstevens
Copy link
Collaborator

Hi! Can you provide the exact command you used? And a description of the dataset and its structure on the disk? When I run the command below, I don't get any errors.

python examples/zero_shot.py --datasets insects2=data/examples/val/

data/examples/val has the following structure:

val
├── Apple leaf
│   ├── 10124.jpg
│   ├── ...
│   └── 9881.jpg
├── Apple rust leaf
│   ├── 10292.jpg
│   ├── ...
│   └── 1320.jpg
├── ...

The zero-shot classnames are the folder names.

If you provide more details, I'm happy to help.

@work4cs
Copy link
Contributor

work4cs commented Dec 21, 2023

May I ask how many classes you use and how many images you use?

@samuelstevens
Copy link
Collaborator

samuelstevens commented Dec 21, 2023

My co-author suggests that if you have less than five classes, top5 accuracy is meaningless. In this case, you can remove all references to top5 accuracy (lines 193, 210, 214) and only calculate top1 accuracy. Line 208 should be changed:

acc1, acc5 = accuracy(logits, targets, topk=(1, 5))

to

acc1 = accuracy(logits, targets, topk=(1,))[0]

If you have zero classes, then this script will not work at all.

samuelstevens added a commit that referenced this issue Mar 29, 2024
Add butterflies field guides and bird datasets
@work4cs work4cs closed this as completed Jun 20, 2024
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

3 participants