khaclinh commited on
Commit
5a9a0ca
1 Parent(s): b2eb8b5

Update testdata.py

Browse files
Files changed (1) hide show
  1. testdata.py +1 -23
testdata.py CHANGED
@@ -107,31 +107,9 @@ class TestData(datasets.GeneratorBasedBuilder):
107
 
108
  idx = 0
109
  for image_path in tqdm(files):
110
- img_relative_path = image_path.relative_to(image_dir)
111
- gt_pah = (Path(annotation_dir) / img_relative_path).with_suffix('.txt')
112
-
113
-
114
- annotation = defaultdict(list)
115
- with open(gt_pah, 'r') 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
  faces = []
126
  plates = []
127
-
128
- for cls, bboxes in annotation.items():
129
- for x1, y1, x2, y2 in bboxes:
130
- if cls == 0:
131
- faces.append([x1, y1, x2, y2])
132
- else:
133
- plates.append([x1, y1, x2, y2])
134
-
135
  yield idx, {"image": str(image_path), "faces": faces, "plates": plates}
 
136
  idx += 1
137
 
 
107
 
108
  idx = 0
109
  for image_path in tqdm(files):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  faces = []
111
  plates = []
 
 
 
 
 
 
 
 
112
  yield idx, {"image": str(image_path), "faces": faces, "plates": plates}
113
+
114
  idx += 1
115