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
Make CLIPFeatureExtractor accept batch of images as torch.Tensor.
#14650
Comments
|
@fcakyon, why was I mentioned here? The only time I edited this file was to add a missing space in an error message. |
|
My apologies @aphedges. Saw your name on PR. |
|
Thanks for the issue! Since a batch of images is a very common input I think we should support this. Pinging @NielsRogge, @sgugger @fcakyon Also note that when resizing, the feature extractors convert the tensors to PIL images, so the most efficient way to use these is to pass a list of PIL images. |
|
@patil-suraj I was using as:
But in this workflow Is the intended usage different? |
|
We could support batch as tensors but as explained in the above comment it won't be efficient. So I would recommend passing a list of PIL images. |
|
@patil-suraj Do you still see supporting batched tensors as necessary/beneficial? It seems pretty straightforward (e.g. checking |
Make
CLIPFeatureExtractor(or any FeatureExtractor in general) accept batch of images astorch.Tensor.Motivation
Currently batch of images as
torch.Tensorare not treated as a batch, it has to be aList[torch.Tensor]but it is not the case when using native Pytorch DataLoader. Can we update this line so that it accepts batches astorch.Tensor. Maybe we can check if the tensor has 4 dimension then assume it is a batch?transformers/src/transformers/models/clip/feature_extraction_clip.py
Line 136 in 75ae287
@patil-suraj @TobiasNorlund
The text was updated successfully, but these errors were encountered: