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

add support for num_return_sequences to BLIP_Decoder.generate ? #64

Open
labenz opened this issue Jun 12, 2022 · 3 comments
Open

add support for num_return_sequences to BLIP_Decoder.generate ? #64

labenz opened this issue Jun 12, 2022 · 3 comments

Comments

@labenz
Copy link

labenz commented Jun 12, 2022

Congrats on creating such an effective image captioner! I'm using it in a project, and noticing that it's popping up in quite a few other places as well.

Inspired in part by this paper – https://arxiv.org/pdf/2205.10747.pdf  – I was wondering if it would be possible to generate multiple candidate captions instead of just one?

It looks like it is possible, at least using the nucleus sampling method, but the value of num_return_sequences is hard-coded = 1 in the Blip_Decoder generate method – see here: https://github.com/salesforce/BLIP/blob/main/models/blip.py#L149

Would it be possible to add num_return_sequences to the generate method arguments and thus get multiple candidate captions?

Thank you!

@LiJunnan1992
Copy link
Contributor

Thanks for the suggestion. It is definitely possible to generate multiple sentences. We do not plan to change the code now in case it break other codes, but feel free to clone the code and change num_return_sequences for yourself.

@labenz
Copy link
Author

labenz commented Jun 13, 2022

Thank you! It seems this only works for nucleus sampling method – is that right? Thanks again. :)

@LiJunnan1992
Copy link
Contributor

You can also return multiple sentences with beam search, please refer to the generate function description here: https://huggingface.co/docs/transformers/main/en/main_classes/text_generation

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