Update README.md
Browse files
README.md
CHANGED
|
@@ -46,4 +46,83 @@ configs:
|
|
| 46 |
path: data/train-*
|
| 47 |
---
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
path: data/train-*
|
| 47 |
---
|
| 48 |
|
| 49 |
+
## Load data
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import datasets
|
| 53 |
+
|
| 54 |
+
dataset = datasets.load_dataset("mrdbourke/trashify_manual_labelled_images")
|
| 55 |
+
dataset
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## View a sample
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
dataset["train"][0]
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Output:
|
| 65 |
+
|
| 66 |
+
```
|
| 67 |
+
{'image': <PIL.Image.Image image mode=RGB size=960x1280>,
|
| 68 |
+
'image_id': 292,
|
| 69 |
+
'annotations': {'file_name': ['00347467-13f1-4cb9-94aa-4e4369457e0c.jpeg',
|
| 70 |
+
'00347467-13f1-4cb9-94aa-4e4369457e0c.jpeg'],
|
| 71 |
+
'image_id': [292, 292],
|
| 72 |
+
'category_id': [1, 0],
|
| 73 |
+
'bbox': [[523.7000122070312,
|
| 74 |
+
545.0999755859375,
|
| 75 |
+
402.79998779296875,
|
| 76 |
+
336.1000061035156],
|
| 77 |
+
[10.399999618530273,
|
| 78 |
+
163.6999969482422,
|
| 79 |
+
943.4000244140625,
|
| 80 |
+
1101.9000244140625]],
|
| 81 |
+
'iscrowd': [0, 0],
|
| 82 |
+
'area': [135381.078125, 1039532.4375]},
|
| 83 |
+
'label_source': 'manual_prodigy_label',
|
| 84 |
+
'image_source': 'manual_taken_photo'}
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
**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.
|
| 88 |
+
|
| 89 |
+
## Get categories
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
# Get the categories from the dataset
|
| 93 |
+
# Note: this requires the dataset to have been uploaded with this feature setup
|
| 94 |
+
categories = dataset["train"].features["annotations"].feature["category_id"]
|
| 95 |
+
|
| 96 |
+
# Get the names attribute
|
| 97 |
+
categories.names
|
| 98 |
+
|
| 99 |
+
>>> ['bin', 'hand', 'not_bin', 'not_hand', 'not_trash', 'trash', 'trash_arm']
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
## Create label2id and id2label
|
| 103 |
+
|
| 104 |
+
```python
|
| 105 |
+
id2label = {i: class_name for i, class_name in enumerate(categories.names)}
|
| 106 |
+
label2id = {value: key for key, value in id2label.items()}
|
| 107 |
+
|
| 108 |
+
id2label, label2id
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
Output:
|
| 112 |
+
|
| 113 |
+
```
|
| 114 |
+
({0: 'bin',
|
| 115 |
+
1: 'hand',
|
| 116 |
+
2: 'not_bin',
|
| 117 |
+
3: 'not_hand',
|
| 118 |
+
4: 'not_trash',
|
| 119 |
+
5: 'trash',
|
| 120 |
+
6: 'trash_arm'},
|
| 121 |
+
{'bin': 0,
|
| 122 |
+
'hand': 1,
|
| 123 |
+
'not_bin': 2,
|
| 124 |
+
'not_hand': 3,
|
| 125 |
+
'not_trash': 4,
|
| 126 |
+
'trash': 5,
|
| 127 |
+
'trash_arm': 6})
|
| 128 |
+
```
|