khaclinh commited on
Commit
a23994e
·
1 Parent(s): d6b27ea

Update testdata.py

Browse files
Files changed (1) hide show
  1. testdata.py +6 -6
testdata.py CHANGED
@@ -102,14 +102,14 @@ class TestData(datasets.GeneratorBasedBuilder):
102
  files = []
103
 
104
  idx = 0
105
- for img_file in glob(os.path.join(image_dir, "*.png")):
106
- img_relative_file = os.path.relpath(img_file, image_dir)
107
- gt_relative_path = img_relative_file.replace("png", "txt")
108
 
109
- gt_path = os.path.join(annotation_dir, gt_relative_path)
110
 
111
  annotation = defaultdict(list)
112
- with open(gt_path, 'r') as f:
113
  line = f.readline().strip()
114
  while line:
115
  assert re.match(r'^\d( [\d\.]+){4,5}$', line), 'Incorrect line: %s' % line
@@ -127,7 +127,7 @@ class TestData(datasets.GeneratorBasedBuilder):
127
  else:
128
  plates([x1, y1, x2, y2])
129
 
130
- yield idx, {"image": str(img_file), "faces": faces, "plates": plates}
131
 
132
  idx += 1
133
 
 
102
  files = []
103
 
104
  idx = 0
105
+ for gt_file in glob(os.path.join(annotation_dir, "*.txt")):
106
+ gt_relative_file = os.path.relpath(gt_file, annotation_dir)
107
+ img_relative_path = gt_relative_file.replace(".txt", ".png")
108
 
109
+ img_path = os.path.join(image_dir, img_relative_path)
110
 
111
  annotation = defaultdict(list)
112
+ with open(gt_file, 'r') as f:
113
  line = f.readline().strip()
114
  while line:
115
  assert re.match(r'^\d( [\d\.]+){4,5}$', line), 'Incorrect line: %s' % line
 
127
  else:
128
  plates([x1, y1, x2, y2])
129
 
130
+ yield idx, {"image": str(img_path), "faces": faces, "plates": plates}
131
 
132
  idx += 1
133