Comments (2)
Thank you very much @amyeroberts, l change my code to resize images bigger than the target size and then crop to target size. And it works well.
from transformers.
Hi @lesjie-wen, thanks for opening this issue!
The CLIPImageProcessor defines a series of steps which will prepare raw images in the format expected by the CLIP model. It follows the preprocessing steps done for the original model.
The first resize will resize according to processor.size
. You can modify the output size by passing size={"shortest_edge: x"}
or size={"height": h, "width": w}
when calling the image processor e.g. processor(images, size={"height": h, "width": w})
.
The reason the image is (324, 324)
when output, is because this is the crop size specified in the example provided:
image = self.processor.preprocess(image, return_tensors='pt', do_normalize=False, do_rescale=False, do_center_crop=True, crop_size={'height':324,'width':324})['pixel_values']
If you want a size that matches the target size you can either:
- Change
crop_size
when calling the processor to match your needs i.e crop_size is the target size. This is the most common behaviour when processing images.
image = self.processor.preprocess(image, return_tensors='pt', do_normalize=False, do_rescale=False, do_center_crop=True, crop_size={'height': target_height, 'width': target_width})['pixel_values']
- Call
processor.resize
on the output images
from transformers.image_processing_utils import BatchFeature
images = self.processor.preprocess(image, do_normalize=False, do_rescale=False, do_center_crop=True, crop_size={'height': target_height, 'width': target_width})['pixel_values']
images = [self.processor.resize(image, size={"height": target_height, "width": target_width}) for image in images]
images = BatchFeature({"pixel_values": images}, tensor_type="pt")
from transformers.
Related Issues (20)
- Add ability to specify input device for ffmpeg_microphone() HOT 1
- Slow tokenizer not loading mixtral 8x22b tokenizer correctly HOT 2
- Multi input of owlv2 cause RuntimeError: Boolean value of Tensor with more than one value is ambiguous HOT 2
- Log multiple losses used along with the combined losses when a model returns a dictionary of losses.
- get_wsd_schedule gets passed num_training_steps because not handled HOT 1
- rework `test_multi_gpu_data_parallel_forward`
- Convert_mistral_weights_to_hf fails loading consolidated.safetensors HOT 3
- Caching Past Key values of any length for Vision LLM's HOT 2
- LLAMA3's special_token is not the same in a file as it is used HOT 1
- Pre-training reference URL in Idefics2 codebase HOT 4
- Add HelpingAIForCausalLM to it HOT 7
- NotImplementedError: Cannot copy out of meta tensor; no data! HOT 3
- need better token_type_id processing on transformer GPT2Model HOT 3
- OverflowError: out of range integral type conversion attempted HOT 4
- TypeError: Cannot convert [array([322., 1.])] to EagerTensor of dtype int64
- Hey @JohnHerry, I'm not sure I understand what's the issue. Could you provide a code sample of what seems to be limiting you?
- BitsAndBytesConfig missing a validation
- Understanding loss in Training LLM HOT 2
- Request for Static Cache Support for XLA Compiler in Transformers
- Inconsistency in logit values between generation and direct model prediction HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers.