khaclinh commited on
Commit
6847ca4
·
1 Parent(s): 6caeb24

Update testdata.py

Browse files
Files changed (1) hide show
  1. testdata.py +20 -2
testdata.py CHANGED
@@ -111,8 +111,26 @@ class TestData(datasets.GeneratorBasedBuilder):
111
  gt_path = gt_path.replace(i, j)
112
  faces = []
113
  plates = []
114
- faces.append([1,2,3,4])
115
- plates.append([1,2,3,4])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  yield idx, {"image": str(img_file), "faces": faces, "plates": plates}
117
 
118
  idx += 1
 
111
  gt_path = gt_path.replace(i, j)
112
  faces = []
113
  plates = []
114
+
115
+ annotation = defaultdict(list)
116
+ with open(gt_pah, 'r') as f:
117
+ line = f.readline().strip()
118
+ while line:
119
+ assert re.match(r'^\d( [\d\.]+){4,5}$', line), 'Incorrect line: %s' % line
120
+ cls, cx, cy, w, h = line.split()[:5]
121
+ cls, cx, cy, w, h = int(cls), float(cx), float(cy), float(w), float(h)
122
+ x1, y1, x2, y2 = cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2
123
+ annotation[cls].append([x1, y1, x2, y2])
124
+ line = f.readline().strip()
125
+
126
+ for cls, bboxes in annotation.items():
127
+ for x1, y1, x2, y2 in bboxes:
128
+ print(x1, y1, x2, y2)
129
+ if cls == 0:
130
+ faces.append([x1, y1, x2, y2])
131
+ else:
132
+ plates([x1, y1, x2, y2])
133
+
134
  yield idx, {"image": str(img_file), "faces": faces, "plates": plates}
135
 
136
  idx += 1