--- license: mit --- # ImageNet-1k Individual Class Datasets Hub This dataset serves as a central hub and index for the **1,000 individual class datasets** derived from the original `imagenet-1k` dataset. Each class has been separated into its own repository for easy access and analysis. This repository does not contain any images itself. Instead, it provides a `class_mapping.csv` file that maps each class ID and name to its corresponding dataset repository on the Hugging Face Hub. ## How to Use The intended workflow is to use this repository to find the `repo_id` for a class you are interested in, and then load that specific dataset. ### 1. Load the Class Mapping File First, load the `class_mapping.csv` file from this repository. You can do this directly using `pandas`. ```python import pandas as pd from datasets import load_dataset # Load the mapping file from the Hub mapping_csv_url = "[https://huggingface.co/datasets/](https://huggingface.co/datasets/)mlnomad/imagenet1k_classes/resolve/main/class_mapping.csv" class_df = pd.read_csv(mapping_csv_url) print("Class mapping loaded. Here's a preview:") print(class_df.head()) ``` ### 2. Find and Load a Specific Class Dataset Once you have the `class_df` DataFrame, you can easily find the repository for any class and load it using `datasets.load_dataset`. #### Example: Loading the 'goldfish' class ```python # Find the entry for 'goldfish' # The class names can be long, so we use .str.contains() for a flexible search goldfish_entry = class_df[class_df['class_name'].str.contains("goldfish", case=False)] if not goldfish_entry.empty: # Get the repo_id from the DataFrame goldfish_repo_id = goldfish_entry.iloc[0]['repo_id'] print(f"Found 'goldfish' dataset at: {goldfish_repo_id}") # Load the actual dataset containing the images print("Loading dataset...") goldfish_dataset = load_dataset(goldfish_repo_id) print("\nSuccessfully loaded!") print(goldfish_dataset) # You can now access the images # example_image = goldfish_dataset['train'][0]['image'] # example_image.show() else: print("Could not find the 'goldfish' class.") ``` ## Class Mapping Preview (`class_mapping.csv`) Here are the first 10 entries in the mapping file: ``` | class_id | class_name | repo_id | |-----------:|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------| | 0 | tench, Tinca tinca | mlnomad/imnet1k_tench_Tinca_tinca | | 1 | goldfish, Carassius auratus | mlnomad/imnet1k_goldfish_Carassius_auratus | | 2 | great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias | mlnomad/imnet1k_great_white_shark_white_shark_man-eater_man-eating_shark_Carcharodon_carcharias | | 3 | tiger shark, Galeocerdo cuvieri | mlnomad/imnet1k_tiger_shark_Galeocerdo_cuvieri | | 4 | hammerhead, hammerhead shark | mlnomad/imnet1k_hammerhead_hammerhead_shark | | 5 | electric ray, crampfish, numbfish, torpedo | mlnomad/imnet1k_electric_ray_crampfish_numbfish_torpedo | | 6 | stingray | mlnomad/imnet1k_stingray | | 7 | cock | mlnomad/imnet1k_cock | | 8 | hen | mlnomad/imnet1k_hen | | 9 | ostrich, Struthio camelus | mlnomad/imnet1k_ostrich_Struthio_camelus | ```