add loc_inspect script
Browse files- loc_inspect.py +32 -0
loc_inspect.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# dependencies = ["datasets", "huggingface_hub"]
|
| 3 |
+
# ///
|
| 4 |
+
import json
|
| 5 |
+
from datasets import load_dataset
|
| 6 |
+
|
| 7 |
+
ds = load_dataset("biglam/loc_beyond_words")
|
| 8 |
+
for split in ds:
|
| 9 |
+
print("=== SPLIT:", split, len(ds[split]))
|
| 10 |
+
f = ds[split].features
|
| 11 |
+
print("features:", list(f.keys()))
|
| 12 |
+
print("features detail:", {k: str(v) for k, v in f.items()})
|
| 13 |
+
|
| 14 |
+
# look at labels in a sample row
|
| 15 |
+
row = ds["validation"][0]
|
| 16 |
+
print("sample keys:", list(row.keys()))
|
| 17 |
+
for k, v in row.items():
|
| 18 |
+
if k != "image":
|
| 19 |
+
print(" ", k, ":", v)
|
| 20 |
+
|
| 21 |
+
# gather all training classes
|
| 22 |
+
train = ds["train"]
|
| 23 |
+
classes = set()
|
| 24 |
+
imgs_per_class = {}
|
| 25 |
+
N = len(train)
|
| 26 |
+
for i in range(N):
|
| 27 |
+
objs = train[i]["objects"]
|
| 28 |
+
for el in objs.get("label", []):
|
| 29 |
+
el = el if isinstance(el, int) else int(el)
|
| 30 |
+
classes.add(el)
|
| 31 |
+
print("\nnum rows train:", N)
|
| 32 |
+
print("label set in train:", sorted(classes))
|