Speed up by transport byte

This commit is contained in:
hzwer
2020-11-20 12:47:33 +08:00
parent bbc85b1af3
commit a3a0973d1d
3 changed files with 7 additions and 7 deletions

View File

@@ -44,4 +44,4 @@ for i in range(args.exp):
if not os.path.exists('output'):
os.mkdir('output')
for i in range(len(img_list)):
cv2.imwrite('output/img{}.png'.format(i), img_list[i][0].cpu().numpy().transpose(1, 2, 0)[:h, :w] * 255)
cv2.imwrite('output/img{}.png'.format(i), (img_list[i][0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w])

View File

@@ -92,10 +92,10 @@ while success:
mid1 = model.inference(I0, I1)
if args.exp == 4:
mid = model.inference(torch.cat((I0, mid1), 0), torch.cat((mid1, I1), 0))
mid1 = (((mid1[0] * 255.).cpu().detach().numpy().transpose(1, 2, 0))).astype('uint8')
mid1 = (((mid1[0] * 255.).byte().cpu().detach().numpy().transpose(1, 2, 0)))
if args.exp == 4:
mid0 = (((mid[0] * 255.).cpu().detach().numpy().transpose(1, 2, 0))).astype('uint8')
mid2 = (((mid[1]* 255.).cpu().detach().numpy().transpose(1, 2, 0))).astype('uint8')
mid0 = (((mid[0] * 255.).byte().cpu().detach().numpy().transpose(1, 2, 0)))
mid2 = (((mid[1] * 255.).byte().cpu().detach().numpy().transpose(1, 2, 0)))
if args.montage:
writeframe(np.concatenate((lastframe, lastframe), 1))
if args.exp == 4:

View File

@@ -112,9 +112,9 @@ while success:
I1 = F.pad(I1, padding)
inferences = make_inference(model, I0, I1, exp=args.exp)
I0 = ((I0[:, :, :h, :w] * 255.).cpu().detach().numpy().transpose(0, 2, 3, 1)).astype('uint8')
I1 = ((I1[:, :, :h, :w] * 255.).cpu().detach().numpy().transpose(0, 2, 3, 1)).astype('uint8')
inferences = list(map(lambda x: ((x[:, :, :h, :w] * 255.).cpu().detach().numpy().transpose(0, 2, 3, 1)).astype('uint8'), inferences))
I0 = ((I0[:, :, :h, :w] * 255.).byte().cpu().detach().numpy().transpose(0, 2, 3, 1))
I1 = ((I1[:, :, :h, :w] * 255.).byte().cpu().detach().numpy().transpose(0, 2, 3, 1))
inferences = list(map(lambda x: ((x[:, :, :h, :w] * 255.).byte().cpu().detach().numpy().transpose(0, 2, 3, 1)), inferences))
write_frame(vid_out, I0, inferences, I1, p.mean(3).mean(2).mean(1), args)
pbar.update(4)