-
Notifications
You must be signed in to change notification settings - Fork 7.2k
migrate caltech prototype datasets #5749
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -370,8 +370,8 @@ def cifar100(root, config): | |||||||||||||||||
| return len(train_files if config["split"] == "train" else test_files) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # @register_mock | ||||||||||||||||||
| def caltech101(info, root, config): | ||||||||||||||||||
| @register_mock(configs=[dict()]) | ||||||||||||||||||
| def caltech101(root, config): | ||||||||||||||||||
| def create_ann_file(root, name): | ||||||||||||||||||
| import scipy.io | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -390,15 +390,17 @@ def create_ann_folder(root, name, file_name_fn, num_examples): | |||||||||||||||||
| images_root = root / "101_ObjectCategories" | ||||||||||||||||||
| anns_root = root / "Annotations" | ||||||||||||||||||
|
|
||||||||||||||||||
| ann_category_map = { | ||||||||||||||||||
| "Faces_2": "Faces", | ||||||||||||||||||
| "Faces_3": "Faces_easy", | ||||||||||||||||||
| "Motorbikes_16": "Motorbikes", | ||||||||||||||||||
| "Airplanes_Side_2": "airplanes", | ||||||||||||||||||
| image_category_map = { | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The map was inversed before and did nothing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the annotation folder had the same name as the image folder. I'm wondering why the test didn't fail then. Is it because the dataset code doesn't actually care about the annotation folder names? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To give some context: Caltech101 uses folders to separate the categories. The folder names match between the images and annotations except for four exceptions. The implementation matches the annotations folder names with this map vision/torchvision/prototype/datasets/_builtin/caltech.py Lines 45 to 50 in 08cc9a7
and this logic vision/torchvision/prototype/datasets/_builtin/caltech.py Lines 72 to 73 in 08cc9a7
The old mock data used the already matched names for the annotations so the dataset didn't need to do any matching. This means that the test were passing fine, although the implementation might be broken (it wasn't), since the matching was never tested. |
||||||||||||||||||
| "Faces": "Faces_2", | ||||||||||||||||||
| "Faces_easy": "Faces_3", | ||||||||||||||||||
| "Motorbikes": "Motorbikes_16", | ||||||||||||||||||
| "airplanes": "Airplanes_Side_2", | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| categories = ["Faces", "Faces_easy", "Motorbikes", "airplanes", "yin_yang"] | ||||||||||||||||||
|
|
||||||||||||||||||
| num_images_per_category = 2 | ||||||||||||||||||
| for category in info.categories: | ||||||||||||||||||
| for category in categories: | ||||||||||||||||||
| create_image_folder( | ||||||||||||||||||
| root=images_root, | ||||||||||||||||||
| name=category, | ||||||||||||||||||
|
|
@@ -407,7 +409,7 @@ def create_ann_folder(root, name, file_name_fn, num_examples): | |||||||||||||||||
| ) | ||||||||||||||||||
| create_ann_folder( | ||||||||||||||||||
| root=anns_root, | ||||||||||||||||||
| name=ann_category_map.get(category, category), | ||||||||||||||||||
| name=image_category_map.get(category, category), | ||||||||||||||||||
| file_name_fn=lambda idx: f"annotation_{idx + 1:04d}.mat", | ||||||||||||||||||
| num_examples=num_images_per_category, | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
@@ -417,27 +419,34 @@ def create_ann_folder(root, name, file_name_fn, num_examples): | |||||||||||||||||
|
|
||||||||||||||||||
| make_tar(root, f"{anns_root.name}.tar", anns_root) | ||||||||||||||||||
|
|
||||||||||||||||||
| return num_images_per_category * len(info.categories) | ||||||||||||||||||
| return num_images_per_category * len(categories) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # @register_mock | ||||||||||||||||||
| def caltech256(info, root, config): | ||||||||||||||||||
| @register_mock(configs=[dict()]) | ||||||||||||||||||
| def caltech256(root, config): | ||||||||||||||||||
| dir = root / "256_ObjectCategories" | ||||||||||||||||||
| num_images_per_category = 2 | ||||||||||||||||||
|
|
||||||||||||||||||
| for idx, category in enumerate(info.categories, 1): | ||||||||||||||||||
| categories = [ | ||||||||||||||||||
| (1, "ak47"), | ||||||||||||||||||
| (127, "laptop-101"), | ||||||||||||||||||
| (198, "spider"), | ||||||||||||||||||
| (257, "clutter"), | ||||||||||||||||||
| ] | ||||||||||||||||||
|
|
||||||||||||||||||
| for category_idx, category in categories: | ||||||||||||||||||
| files = create_image_folder( | ||||||||||||||||||
| dir, | ||||||||||||||||||
| name=f"{idx:03d}.{category}", | ||||||||||||||||||
| file_name_fn=lambda image_idx: f"{idx:03d}_{image_idx + 1:04d}.jpg", | ||||||||||||||||||
| name=f"{category_idx:03d}.{category}", | ||||||||||||||||||
| file_name_fn=lambda image_idx: f"{category_idx:03d}_{image_idx + 1:04d}.jpg", | ||||||||||||||||||
| num_examples=num_images_per_category, | ||||||||||||||||||
| ) | ||||||||||||||||||
| if category == "spider": | ||||||||||||||||||
| open(files[0].parent / "RENAME2", "w").close() | ||||||||||||||||||
|
|
||||||||||||||||||
| make_tar(root, f"{dir.name}.tar", dir) | ||||||||||||||||||
|
|
||||||||||||||||||
| return num_images_per_category * len(info.categories) | ||||||||||||||||||
| return num_images_per_category * len(categories) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @register_mock(configs=combinations_grid(split=("train", "val", "test"))) | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.