Skip to content

Commit c16f1a0

Browse files
committed
Add detection_items.py to list YOLOS detectable object names and update README.md
1 parent 08c00ba commit c16f1a0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ phone,42,38,20
7171
bottle,100,0,0
7272
```
7373

74-
- `label`: The item name (must match YOLOS labels for detection).
74+
- `label`: The item name (must match YOLOS labels; you can list them by running `python detection_items.py`)
7575
- `plastic`, `metal`, `glass`: Composition percentages (should sum to ~100).
7676

7777
---

detection_items.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
3+
os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
4+
from transformers import YolosForObjectDetection
5+
6+
# Load the model config
7+
model = YolosForObjectDetection.from_pretrained("hustvl/yolos-base")
8+
9+
# Get all detectable object names
10+
object_names = list(model.config.id2label.values())
11+
12+
# Display the object names
13+
for name in object_names:
14+
print(name)

0 commit comments

Comments
 (0)