glenn-jocher
commited on
Commit
•
b810b21
1
Parent(s):
d5d1604
augmented inference
Browse files- models/yolo.py +2 -2
- utils/torch_utils.py +1 -1
models/yolo.py
CHANGED
@@ -72,8 +72,8 @@ class Model(nn.Module):
|
|
72 |
s = [0.83, 0.67] # scales
|
73 |
y = []
|
74 |
for i, xi in enumerate((x,
|
75 |
-
torch_utils.scale_img(x.flip(3), s[0]
|
76 |
-
torch_utils.scale_img(x, s[1]
|
77 |
)):
|
78 |
# cv2.imwrite('img%g.jpg' % i, 255 * xi[0].numpy().transpose((1, 2, 0))[:, :, ::-1])
|
79 |
y.append(self.forward_once(xi)[0])
|
|
|
72 |
s = [0.83, 0.67] # scales
|
73 |
y = []
|
74 |
for i, xi in enumerate((x,
|
75 |
+
torch_utils.scale_img(x.flip(3), s[0]), # flip-lr and scale
|
76 |
+
torch_utils.scale_img(x, s[1]), # scale
|
77 |
)):
|
78 |
# cv2.imwrite('img%g.jpg' % i, 255 * xi[0].numpy().transpose((1, 2, 0))[:, :, ::-1])
|
79 |
y.append(self.forward_once(xi)[0])
|
utils/torch_utils.py
CHANGED
@@ -135,7 +135,7 @@ def load_classifier(name='resnet101', n=2):
|
|
135 |
return model
|
136 |
|
137 |
|
138 |
-
def scale_img(img, ratio=1.0, same_shape=
|
139 |
# scales img(bs,3,y,x) by ratio
|
140 |
h, w = img.shape[2:]
|
141 |
s = (int(h * ratio), int(w * ratio)) # new size
|
|
|
135 |
return model
|
136 |
|
137 |
|
138 |
+
def scale_img(img, ratio=1.0, same_shape=False): # img(16,3,256,416), r=ratio
|
139 |
# scales img(bs,3,y,x) by ratio
|
140 |
h, w = img.shape[2:]
|
141 |
s = (int(h * ratio), int(w * ratio)) # new size
|