khaclinh commited on
Commit
ea64030
·
1 Parent(s): f69ed0f

Update testdata.py

Browse files
Files changed (1) hide show
  1. testdata.py +2 -2
testdata.py CHANGED
@@ -128,7 +128,7 @@ class TestData(datasets.GeneratorBasedBuilder):
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,7 +138,7 @@ class TestData(datasets.GeneratorBasedBuilder):
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
 
 
128
 
129
  gt_path = os.path.join(annotation_dir, gt_relative_path)
130
  img = cv2.imread(i_file)
131
+ img_h, img_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 * img_w), round(y1 * img_h), round(x2 * img_w), round(y2 * img_h)
142
  annotation[cls].append([x1, y1, x2, y2])
143
  line = f.readline().strip()
144