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

Inference with tensor input #273

Open
DelinQu opened this issue Jan 14, 2023 · 1 comment
Open

Inference with tensor input #273

DelinQu opened this issue Jan 14, 2023 · 1 comment

Comments

@DelinQu
Copy link

DelinQu commented Jan 14, 2023

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. I have read the FAQ documentation but cannot get the expected help.
  3. The bug has not been fixed in the latest version.

Describe the bug
I use mmflow as a third-party package and install it with pip. I want use the mmflow's specific model such as FlowNet, GMA or RAFT ... as a flow estimator without the need to train or fine-tune. But instead of providing as image path or ndarray to the function inference_model, I want to Inference with tensor input:

config_file = osp.join(MIN_CACHE, 'pwcnet_ft_4x1_300k_sintel_final_384x768.py')
checkpoint_file = osp.join(MIN_CACHE, 'pwcnet_ft_4x1_300k_sintel_final_384x768.pth')

model = init_model(config_file, checkpoint_file, device=device)
# [x] flow = inference_model(model, osp.join(ROOT, 'data/Wall/img1.png'), osp.join(ROOT, 'data/Wall/img2.png'))

# Inference with tensor input:
img1, img2 = get_image_tensor(osp.join(ROOT, 'data/Wall/img1.png')), get_image_tensor(osp.join(ROOT, 'data/Wall/img2.png'))
flow = model(image1, img2)

res = visualize_flow(flow, osp.join(ROOT, 'res', 'test.png'))

However the error catchs me:
image

could you please provide any suggestions? Thanks in advance!

@sjokic
Copy link

sjokic commented Feb 22, 2023

I think the reason it doesn't work is because the images need to first be passed through a data pipeline that applies various transformations to the images before they can be used as input to the model (cf. inference_model function, in particular test_pipeline = Compose(cfg.pipeline)). This pipeline appears to be applied to each image one by one, rather than processing the whole batch, and also seems to have been implemeted for numpy arrays only. This is very unfortunate, because I would also like inference to work with batches of tensors... :/

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