Browse Source

augmented inference

5.0
Glenn Jocher 4 years ago
parent
commit
b810b21299
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      models/yolo.py
  2. +1
    -1
      utils/torch_utils.py

+ 2
- 2
models/yolo.py View File

s = [0.83, 0.67] # scales s = [0.83, 0.67] # scales
y = [] y = []
for i, xi in enumerate((x, for i, xi in enumerate((x,
torch_utils.scale_img(x.flip(3), s[0], same_shape=False), # flip-lr and scale
torch_utils.scale_img(x, s[1], same_shape=False), # scale
torch_utils.scale_img(x.flip(3), s[0]), # flip-lr and scale
torch_utils.scale_img(x, s[1]), # scale
)): )):
# cv2.imwrite('img%g.jpg' % i, 255 * xi[0].numpy().transpose((1, 2, 0))[:, :, ::-1]) # cv2.imwrite('img%g.jpg' % i, 255 * xi[0].numpy().transpose((1, 2, 0))[:, :, ::-1])
y.append(self.forward_once(xi)[0]) y.append(self.forward_once(xi)[0])

+ 1
- 1
utils/torch_utils.py View File

return model return model




def scale_img(img, ratio=1.0, same_shape=True): # img(16,3,256,416), r=ratio
def scale_img(img, ratio=1.0, same_shape=False): # img(16,3,256,416), r=ratio
# scales img(bs,3,y,x) by ratio # scales img(bs,3,y,x) by ratio
h, w = img.shape[2:] h, w = img.shape[2:]
s = (int(h * ratio), int(w * ratio)) # new size s = (int(h * ratio), int(w * ratio)) # new size

Loading…
Cancel
Save