| --- |
| license: apache-2.0 |
| tags: |
| - gemma4 |
| --- |
| |
| Inference |
|
|
| ```python |
| from PIL import Image |
| from transformers import Gemma4ImageProcessor, Gemma4VisionModel |
| |
| if __name__ == '__main__': |
| device = 'cuda' |
| vision = Gemma4VisionModel.from_pretrained('nebulette/gemma-4-vision-module').to(device) |
| processor = Gemma4ImageProcessor.from_pretrained('nebulette/gemma-4-vision-module') |
| inputs = processor.preprocess(Image.open('path/to/image.png'), return_tensors='pt').to(device) |
| outputs = vision.forward(pixel_values=inputs.pixel_values, pixel_position_ids=inputs.image_position_ids) |
| hidden_state = outputs.last_hidden_state |
| ``` |