Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -127,16 +127,34 @@ task_categories:
|
|
| 127 |
## Usage
|
| 128 |
|
| 129 |
```python
|
| 130 |
-
from datasets import load_dataset
|
| 131 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
-
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
-
plt.
|
| 139 |
-
plt.axis("off")
|
| 140 |
plt.show()
|
| 141 |
```
|
| 142 |
|
|
|
|
| 127 |
## Usage
|
| 128 |
|
| 129 |
```python
|
|
|
|
| 130 |
import matplotlib.pyplot as plt
|
| 131 |
+
import matplotlib.patches as patches
|
| 132 |
+
from datasets import load_dataset
|
| 133 |
+
|
| 134 |
+
dataset = load_dataset("CorentinDumery/MixCount", split="train", streaming=True)
|
| 135 |
+
example = next(iter(dataset))
|
| 136 |
+
|
| 137 |
+
for name, count, desc in zip(example['class_names'], example['class_counts'], example['class_descriptions']):
|
| 138 |
+
print(f" - {name}: {count} instance(s)")
|
| 139 |
+
print(f" Description: {desc}")
|
| 140 |
+
|
| 141 |
+
objects = example['objects']
|
| 142 |
|
| 143 |
+
fig, ax = plt.subplots(1, figsize=(10, 8))
|
| 144 |
+
ax.imshow(example['image'])
|
| 145 |
|
| 146 |
+
for bbox, category_id in zip(objects['bbox'], objects['category']):
|
| 147 |
+
x, y, w, h = bbox
|
| 148 |
+
color = plt.colormaps['tab20'](category_id % 20)
|
| 149 |
+
rect = patches.Rectangle(
|
| 150 |
+
(x, y), w, h,
|
| 151 |
+
linewidth=2,
|
| 152 |
+
edgecolor=color,
|
| 153 |
+
facecolor='none',
|
| 154 |
+
)
|
| 155 |
+
ax.add_patch(rect)
|
| 156 |
|
| 157 |
+
plt.axis('off')
|
|
|
|
| 158 |
plt.show()
|
| 159 |
```
|
| 160 |
|