File size: 625 Bytes
4fbb4ec
 
 
 
 
d298c03
 
 
 
 
 
 
 
 
 
 
 
f6d0cab
 
d298c03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
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
```