-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenImagesDownloader.py
More file actions
51 lines (41 loc) · 1.44 KB
/
OpenImagesDownloader.py
File metadata and controls
51 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import fiftyone as fo
import fiftyone.zoo as foz
import os
OUTDIR = "./indoor-open-images-data"
CLASSES = [
"Door", "Door handle", "Chair", "Table", "Bed", "Toilet", "Sink",
"Bathtub", "Shower", "Stairs", "Couch", "Lamp", "Light switch",
"Refrigerator", "Microwave oven", "Oven", "Gas stove", "Washing machine",
"Computer keyboard", "Computer monitor", "Laptop", "Television", "Clock",
"Waste container", "Plate", "Knife", "Fork", "Spoon", "Person", "Car", "Desk"
]
os.makedirs(OUTDIR, exist_ok=True)
print("Output directory:", OUTDIR)
fo.config.default_ml_backend = "torch"
fo.config.dataset_zoo_dir = OUTDIR
import fiftyone.utils.annotations as foua
if hasattr(foua, 'num_workers'):
foua.num_workers = 32
splits_config = [
("train", "train", 64000),
("valid", "validation", 8000),
("test", "test", 8000),
]
for split, fo_split, max_samples in splits_config:
print(f"Downloading {split} split ({max_samples} samples)")
try:
dataset = foz.load_zoo_dataset(
"open-images-v7",
split=fo_split,
label_types=["detections"],
classes=CLASSES,
max_samples=max_samples,
dataset_name=f"oi_{split}_{max_samples}",
shuffle=True,
seed=42,
)
print(f" Downloaded {len(dataset)} images")
except Exception as e:
print(f"Exception: {e}")
continue
print("Downloading finished.")