Datasets:
fix: json format
Browse files- visible-watermark-pita.py +14 -16
visible-watermark-pita.py
CHANGED
@@ -67,7 +67,6 @@ class WatermarkPita(datasets.GeneratorBasedBuilder):
|
|
67 |
),
|
68 |
}
|
69 |
),
|
70 |
-
supervised_keys=None,
|
71 |
description=_DESCRIPTION,
|
72 |
)
|
73 |
|
@@ -90,25 +89,24 @@ class WatermarkPita(datasets.GeneratorBasedBuilder):
|
|
90 |
label_dir = os.path.join(data_dir, "labels")
|
91 |
|
92 |
image_paths = sorted(glob(image_dir + "/*.jpg"))
|
93 |
-
|
94 |
-
|
95 |
-
print(label_paths)
|
96 |
|
97 |
for idx, (image_path, label_path) in enumerate(zip(image_paths, label_paths)):
|
98 |
with open(label_path, "r") as f:
|
99 |
bbox = json.load(f)
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
|
114 |
yield idx, {"image": image_path, "objects": objects}
|
|
|
67 |
),
|
68 |
}
|
69 |
),
|
|
|
70 |
description=_DESCRIPTION,
|
71 |
)
|
72 |
|
|
|
89 |
label_dir = os.path.join(data_dir, "labels")
|
90 |
|
91 |
image_paths = sorted(glob(image_dir + "/*.jpg"))
|
92 |
+
label_paths = sorted(glob(label_dir + "/*.json"))
|
93 |
+
|
|
|
94 |
|
95 |
for idx, (image_path, label_path) in enumerate(zip(image_paths, label_paths)):
|
96 |
with open(label_path, "r") as f:
|
97 |
bbox = json.load(f)
|
98 |
|
99 |
+
objects = []
|
100 |
+
objects.append(
|
101 |
+
{
|
102 |
+
"label": bbox["label"],
|
103 |
+
"bbox": [
|
104 |
+
bbox["x"],
|
105 |
+
bbox["y"],
|
106 |
+
bbox["width"],
|
107 |
+
bbox["height"],
|
108 |
+
],
|
109 |
+
}
|
110 |
+
)
|
111 |
|
112 |
yield idx, {"image": image_path, "objects": objects}
|