mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #175] having trouble when doing batch inference #152
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#152
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @WilliamHoo on GitHub (Nov 7, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/175
Hi CLIP authors,
so i was trying to run the clip using the code below, but when i doing this in batch, i am having trouble with model.encode_text method, as it will show error message below

my only difference with your sample code below is that, my text has a shape of (batch_size, num_class, n_ctx). My code will run perfectly is my input is of shape (num_class, n_ctx), but i was trying to speed up the process by doing it in batch.
Any advice or help will be really appreciated!
@jongwook commented on GitHub (Nov 16, 2021):
Can you try reshaping the array to (batch_size * num_class, n_ctx) and feed it to the model?
@hanxiao commented on GitHub (Apr 10, 2022):
for batch inference, you can use https://github.com/jina-ai/clip-as-service/
@Angtrim commented on GitHub (Feb 28, 2023):
Did you find a solution?
@ahmadmustafaanis commented on GitHub (Apr 19, 2023):
The best working solution is to torch.stack to do batch inference.
@lucasjinreal commented on GitHub (Aug 14, 2024):
this func is very slow.