Update testdata.py
Browse files- testdata.py +1 -19
testdata.py
CHANGED
|
@@ -110,26 +110,8 @@ class TestData(datasets.GeneratorBasedBuilder):
|
|
| 110 |
img_relative_path = gt_relative_file.replace(".txt", ".png")
|
| 111 |
|
| 112 |
img_path = os.path.join(image_dir, img_relative_path)
|
| 113 |
-
|
| 114 |
-
annotation = defaultdict(list)
|
| 115 |
-
with open(gt_file, "r", encoding="utf-8") as f:
|
| 116 |
-
line = f.readline().strip()
|
| 117 |
-
while line:
|
| 118 |
-
assert re.match(r"^\d( [\d\.]+){4,5}$", line), "Incorrect line: %s" % line
|
| 119 |
-
cls, cx, cy, w, h = line.split()[:5]
|
| 120 |
-
cls, cx, cy, w, h = int(cls), float(cx), float(cy), float(w), float(h)
|
| 121 |
-
x1, y1, x2, y2 = cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2
|
| 122 |
-
annotation[cls].append([x1, y1, x2, y2])
|
| 123 |
-
line = f.readline().strip()
|
| 124 |
-
|
| 125 |
-
for cls, bboxes in annotation.items():
|
| 126 |
-
for x1, y1, x2, y2 in bboxes:
|
| 127 |
-
if cls == 0:
|
| 128 |
-
faces.append([x1, y1, x2, y2])
|
| 129 |
-
else:
|
| 130 |
-
plates([x1, y1, x2, y2])
|
| 131 |
-
|
| 132 |
yield idx, {"image": img_path, "faces": faces, "plates": plates}
|
| 133 |
|
| 134 |
idx += 1
|
|
|
|
| 135 |
|
|
|
|
| 110 |
img_relative_path = gt_relative_file.replace(".txt", ".png")
|
| 111 |
|
| 112 |
img_path = os.path.join(image_dir, img_relative_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
yield idx, {"image": img_path, "faces": faces, "plates": plates}
|
| 114 |
|
| 115 |
idx += 1
|
| 116 |
+
|
| 117 |
|