-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inference on single stereo image pairs #12
Comments
Hi,I also encountered this problem,and I use torchvision.utils.save_image to save the tensor, but get blank pic. |
@JF-Lee I found a solution to the issue: I wrote a function that stores the output of the network (keep in mind, you get 4 different images, one image per stage multiplied by the batch size - so say you have a batch size of 8, you get 8 images in one tensor as output, 4 times). Then the code in the separate file looks something like this:
I hope that helps! |
Oh, It's great, thank you for your reply!!!
…------------------ 原始邮件 ------------------
发件人: "CMartinETH"<notifications@github.com>;
发送时间: 2020年6月3日(星期三) 晚上9:18
收件人: "mileyan/AnyNet"<AnyNet@noreply.github.com>;
抄送: "走走停停ゝ"<445099619@qq.com>;"Mention"<mention@noreply.github.com>;
主题: Re: [mileyan/AnyNet] Inference on single stereo image pairs (#12)
@JF-Lee I found a solution to the issue: I wrote a function that stores the output of the network (keep in mind, you get 4 different images, one image per stage multiplied by the batch size - so say you have a batch size of 8, you get 8 images in one tensor as output, 4 times).
This can be done from within the test function. I hand over the output and x (to know which is the current stage I am saving the image of, or to only save the image of stage 3).
Then the code in the separate file looks something like this:
for i in range(output.size()[0]): img_cpu = np.asarray(output.cpu()) img_save = np.clip(img_cpu[i, :, :], 0, 2**16) img_save = (img_save * 256.0).astype(np.uint16) name = "some path name" cv2.imwrite(name, img_save)
I hope that helps!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@CMartinETH, thanks too much for helping solve this issue. I will update this function to the master branch. |
hi,Could you show me some more details? I'm not sure where the above code should be placed in the test function |
you can put it in the test() function in the file finetune.py def test(dataloader, model, log):
stages = 3 + args.with_spn
D1s = [AverageMeter() for _ in range(stages)]
length_loader = len(dataloader)
model.eval()
for batch_idx, (imgL, imgR, disp_L) in enumerate(dataloader):
imgL = imgL.float().cuda()
imgR = imgR.float().cuda()
disp_L = disp_L.float().cuda()
with torch.no_grad():
outputs = model(imgL, imgR)
print(f"[test] : len(outputs)={len(outputs)}") # 4
for x in range(stages):
output = torch.squeeze(outputs[x], 1)
print(f"[test] : output.shape={output.shape}") # torch.Size([8, 1, 368, 1232])
for i in range(output.size()[0]): # 8
img_cpu = np.asarray(output.cpu())
img_save = np.clip(img_cpu[i, :, :], 0, 2**16)
img_save = (img_save * 256.0).astype(np.uint16)
name = "/home/lzy/Project/DepthEstimateBasedOnDeepLearning/AnyNet/results/test/"+str(x)+"_"+str(i)+".png"
cv2.imwrite(name, img_save)
D1s[x].update(error_estimating(output, disp_L).item()) |
Thanks for your work.
I want to perform inference on a single stereo image pair. This repo only contains evaluation on KITTI dataset images.
The text was updated successfully, but these errors were encountered: