diff --git a/inference_img.py b/inference_img.py index c786513..f926b97 100644 --- a/inference_img.py +++ b/inference_img.py @@ -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]) diff --git a/inference_video.py b/inference_video.py index a627a36..c3f2a71 100644 --- a/inference_video.py +++ b/inference_video.py @@ -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: diff --git a/inference_video_parallel.py b/inference_video_parallel.py index a9403d7..f06bcea 100644 --- a/inference_video_parallel.py +++ b/inference_video_parallel.py @@ -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)