Skip to content
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

How to inference on my own images? #3

Open
TengFeiHan0 opened this issue Jun 10, 2020 · 1 comment
Open

How to inference on my own images? #3

TengFeiHan0 opened this issue Jun 10, 2020 · 1 comment

Comments

@TengFeiHan0
Copy link

Thank you for your great work! what are the necessary steps to test your given model on my own datasets?

@jeffbaena
Copy link

jeffbaena commented Apr 14, 2021

Dear @avirambh I have a similar problem. I have adapted the testing script from the IRR repository , however I get nonsense outputs using your checkpoints and model. Is there some preprocessing or post processing I should apply to the inputs or outputs. Attached you can find a snippet of my testing script and an output sample.

`checkpoint_path = '/home/USER/optical_flow_networks/ScopeFlow/checkpoints/'
model_ckpt = 'T3/checkpoint_best.ckpt'

model_checkpoint_path = os.path.join(checkpoint_path,model_ckpt)

output_png_pth = '/home/USER/training/plots/test_scopeflow.png'

img1 = imread(im1_pth).astype(np.float32)/ np.float32(255.0)
img2 = imread(im2_pth).astype(np.float32)/ np.float32(255.0)
im1_tensor = vision_transforms.transforms.ToTensor()(img1).unsqueeze(0).cuda()
im2_tensor = vision_transforms.transforms.ToTensor()(img2).unsqueeze(0).cuda()

@DataClass
class Config:
bilateral_mask = False
model = PWCNet(args=Config())

checkpoint = torch.load(model_checkpoint_path, map_location=torch.device('cpu'))
model = torch.nn.DataParallel(model)
model.load_state_dict(checkpoint, strict=False)
model.cuda().eval()

input_dict = {'input1' : im1_tensor, 'input2' : im2_tensor}
output_dict = model.forward(input_dict)

flow = output_dict['flow'].squeeze(0).detach().cpu().numpy()
imsave(output_png_pth, flow_to_png_middlebury(flow))`

test_scopeflow
gnd_scopeflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants