Update testdata.py
Browse files- testdata.py +4 -1
testdata.py
CHANGED
|
@@ -22,7 +22,7 @@ from typing import List
|
|
| 22 |
import re
|
| 23 |
from collections import defaultdict
|
| 24 |
import datasets
|
| 25 |
-
|
| 26 |
|
| 27 |
|
| 28 |
_HOMEPAGE = "http://shuoyang1213.me/WIDERFACE/"
|
|
@@ -127,6 +127,8 @@ class TestData(datasets.GeneratorBasedBuilder):
|
|
| 127 |
gt_relative_path = img_relative_file.replace(".png", ".txt")
|
| 128 |
|
| 129 |
gt_path = os.path.join(annotation_dir, gt_relative_path)
|
|
|
|
|
|
|
| 130 |
|
| 131 |
annotation = defaultdict(list)
|
| 132 |
with open(gt_path, "r", encoding="utf-8") as f:
|
|
@@ -136,6 +138,7 @@ class TestData(datasets.GeneratorBasedBuilder):
|
|
| 136 |
cls, cx, cy, w, h = line.split()[:5]
|
| 137 |
cls, cx, cy, w, h = int(cls), float(cx), float(cy), float(w), float(h)
|
| 138 |
x1, y1, x2, y2 = cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2
|
|
|
|
| 139 |
annotation[cls].append([x1, y1, x2, y2])
|
| 140 |
line = f.readline().strip()
|
| 141 |
|
|
|
|
| 22 |
import re
|
| 23 |
from collections import defaultdict
|
| 24 |
import datasets
|
| 25 |
+
import cv2
|
| 26 |
|
| 27 |
|
| 28 |
_HOMEPAGE = "http://shuoyang1213.me/WIDERFACE/"
|
|
|
|
| 127 |
gt_relative_path = img_relative_file.replace(".png", ".txt")
|
| 128 |
|
| 129 |
gt_path = os.path.join(annotation_dir, gt_relative_path)
|
| 130 |
+
img = cv2.imread(i_file)
|
| 131 |
+
h, w = img.shape[:2]
|
| 132 |
|
| 133 |
annotation = defaultdict(list)
|
| 134 |
with open(gt_path, "r", encoding="utf-8") as f:
|
|
|
|
| 138 |
cls, cx, cy, w, h = line.split()[:5]
|
| 139 |
cls, cx, cy, w, h = int(cls), float(cx), float(cy), float(w), float(h)
|
| 140 |
x1, y1, x2, y2 = cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2
|
| 141 |
+
x1, y1, x2, y2 = round(x1 * w), round(y1 * h), round(x2 * w), round(y2 * h)
|
| 142 |
annotation[cls].append([x1, y1, x2, y2])
|
| 143 |
line = f.readline().strip()
|
| 144 |
|