glenn-jocher
commited on
Commit
•
da35727
1
Parent(s):
ebafd1e
--save-txt bug fix (#763)
Browse files
test.py
CHANGED
@@ -128,11 +128,11 @@ def test(data,
|
|
128 |
# Append to text file
|
129 |
if save_txt:
|
130 |
gn = torch.tensor(shapes[si][0])[[1, 0, 1, 0]] # normalization gain whwh
|
131 |
-
|
132 |
-
|
133 |
-
for *xyxy, conf, cls in
|
134 |
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
135 |
-
with open(
|
136 |
f.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format
|
137 |
|
138 |
# Clip boxes to image bounds
|
|
|
128 |
# Append to text file
|
129 |
if save_txt:
|
130 |
gn = torch.tensor(shapes[si][0])[[1, 0, 1, 0]] # normalization gain whwh
|
131 |
+
x = pred.clone()
|
132 |
+
x[:, :4] = scale_coords(img[si].shape[1:], x[:, :4], shapes[si][0], shapes[si][1]) # to original
|
133 |
+
for *xyxy, conf, cls in x:
|
134 |
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
135 |
+
with open(str(out / Path(paths[si]).stem) + '.txt', 'a') as f:
|
136 |
f.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format
|
137 |
|
138 |
# Clip boxes to image bounds
|