--- dataset_info: features: - name: image dtype: image - name: image_id dtype: int64 - name: annotations sequence: - name: file_name dtype: string - name: image_id dtype: int64 - name: category_id dtype: class_label: names: '0': bin '1': hand '2': not_bin '3': not_hand '4': not_trash '5': trash '6': trash_arm - name: bbox sequence: float32 length: 4 - name: iscrowd dtype: int64 - name: area dtype: float32 - name: label_source dtype: string - name: image_source dtype: string splits: - name: train num_bytes: 1022952485.728 num_examples: 1128 download_size: 1026537298 dataset_size: 1022952485.728 configs: - config_name: default data_files: - split: train path: data/train-* --- ## Load data ```python import datasets dataset = datasets.load_dataset("mrdbourke/trashify_manual_labelled_images") dataset ``` ## View a sample ```python dataset["train"][0] ``` Output: ``` {'image': , 'image_id': 292, 'annotations': {'file_name': ['00347467-13f1-4cb9-94aa-4e4369457e0c.jpeg', '00347467-13f1-4cb9-94aa-4e4369457e0c.jpeg'], 'image_id': [292, 292], 'category_id': [1, 0], 'bbox': [[523.7000122070312, 545.0999755859375, 402.79998779296875, 336.1000061035156], [10.399999618530273, 163.6999969482422, 943.4000244140625, 1101.9000244140625]], 'iscrowd': [0, 0], 'area': [135381.078125, 1039532.4375]}, 'label_source': 'manual_prodigy_label', 'image_source': 'manual_taken_photo'} ``` **Note:** Boxes in "bbox" key are in `XYWH` format or `[x_min, y_min, box_width, box_height]`. If you'd like them in `XYXY` format, you'll have to convert them. ## Get categories ```python # Get the categories from the dataset # Note: this requires the dataset to have been uploaded with this feature setup categories = dataset["train"].features["annotations"].feature["category_id"] # Get the names attribute categories.names >>> ['bin', 'hand', 'not_bin', 'not_hand', 'not_trash', 'trash', 'trash_arm'] ``` ## Create label2id and id2label ```python id2label = {i: class_name for i, class_name in enumerate(categories.names)} label2id = {value: key for key, value in id2label.items()} id2label, label2id ``` Output: ``` ({0: 'bin', 1: 'hand', 2: 'not_bin', 3: 'not_hand', 4: 'not_trash', 5: 'trash', 6: 'trash_arm'}, {'bin': 0, 'hand': 1, 'not_bin': 2, 'not_hand': 3, 'not_trash': 4, 'trash': 5, 'trash_arm': 6}) ```