learnables / learn2learn

A PyTorch Library for Meta-learning Research
http://learn2learn.net
MIT License
2.59k stars 348 forks source link

Aircraft dataset num classes = 51? #402

Closed AntreasAntoniou closed 1 year ago

AntreasAntoniou commented 1 year ago

Hey everyone,

I've been trying to use the aircraft dataset and somehow I can only find 51 classes in it with the preset splits. If I remove the 'if' clause that checks for adherence to the splits I get 70 classes.

What's going on? Any ideas?

import learn2learn as l2l
from tqdm.auto import tqdm

data = l2l.vision.datasets.FGVCAircraft(
    root="data/",
    mode="all",
    download=True,
    bounding_box_crop=False,
)

label_set = set()

with tqdm(total=len(data)) as pbar:
    for item in data:
        label_set.add(item[1])
        pbar.update(1)
        pbar.set_description(f"Found {len(label_set)} labels")

If one runs the above, it returns "Found 51 labels"

seba-1511 commented 1 year ago

Hello @AntreasAntoniou,

Thanks, I also don't find all the classes using your script. Looking at the data it seems like some of the class names in SPLITS are wrong or non-existent; for example, I can't find A318 as a plane family when inspecting the labels in image_labels. I remember getting those class names from the MetaDataset repo but don't know where the discrepancy comes from.

This needs a bit more investigation. Would you be interested in tackling this?

AntreasAntoniou commented 1 year ago

I need to resolve this for my work. The idea I have right now is to use the tensorflow hub's aircraft dataset, and convert it to a hugging face dataset because I hate the tf datasets package, and then use the hf dataset that I make as the data resource for the l2l class.

seba-1511 commented 1 year ago

That sounds good, I'm curious to see if we could reuse the HuggingFace interface you'll write to provide other few-shot datasets with learn2learn.

Maybe a more immediate solution is to fix the names in the SPLITS dict? For example, there are label names in $DATA/fgvc_aircraft/fgvc-aircraft-2013b/data/images_family_test.txt but I'm not sure if those are the same splits as in MetaDataset.

seba-1511 commented 1 year ago

Quick follow-up: the issue is that image_labels.pkl maps images to families but the Meta-Dataset splits use variants as class names. So the right fix is to load, say, images_variant_train.txt and use it to load all the images for a class (while using the Meta-Dataset class splits, which might or might not be the same as the original Aircraft variant splits).