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

Batch predictions Image Captioning task #58

Open
MikeMACintosh opened this issue May 18, 2022 · 3 comments
Open

Batch predictions Image Captioning task #58

MikeMACintosh opened this issue May 18, 2022 · 3 comments

Comments

@MikeMACintosh
Copy link

MikeMACintosh commented May 18, 2022

Hi, glad to see and use this cool project, thanks you.
I have a question: if it possible to batch predictions on Image captioning task?
I see #48 but it's not my case.

i do something like:

base_model_path = 'path_to_base_model'
model_base = blip_decoder(pretrained=base_model_path, vit='base', image_size=IMAGE_SIZE)
model_base.eval()
model_base.to(device)

img = transform(sample).unsqueeze(0).to(device)
with torch.no_grad():
caption_bs_base=model_base.generate(img, sample=False, num_beams=7, max_length=16, min_length=5)

It works good, but i want to inference 4 models(vit base/large and beam search/nucleus sampling) and it's to long. On my server signature 12 pictures 4 models takes ~34 sec (12*4 = 48 signature).

Thanks you.

@LiJunnan1992
Copy link
Contributor

Yes you can do batch inference.

@MikeMACintosh
Copy link
Author

@LiJunnan1992 Сould you explain how i can do that? Should I write my own Dataloader?

@poipiii
Copy link

poipiii commented May 26, 2022

yes you have to write your own data loader I just done it myself

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

3 participants