Image Feature Extraction
Transformers
Safetensors
hy4_flash_vision
feature-extraction
vision
siglip2
custom_code
Instructions to use immanuelpeter/Hy4-Flash-Vision with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use immanuelpeter/Hy4-Flash-Vision with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="immanuelpeter/Hy4-Flash-Vision", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("immanuelpeter/Hy4-Flash-Vision", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Keep hidden states only when output_hidden_states is set
Browse files
modeling_hy4_flash_vision.py
CHANGED
|
@@ -164,12 +164,13 @@ class Hy4FlashVisionModel(PreTrainedModel):
|
|
| 164 |
last_hidden_state is the last block's output and pooler_output the Projector's, with newlines."""
|
| 165 |
grid = (pixel_values.shape[-2] // self.config.patch_size, pixel_values.shape[-1] // self.config.patch_size)
|
| 166 |
hidden_states = self.embeddings(pixel_values)
|
| 167 |
-
states = [hidden_states]
|
| 168 |
for layer in self.layers:
|
| 169 |
hidden_states = layer(hidden_states)
|
| 170 |
-
states
|
|
|
|
| 171 |
return BaseModelOutputWithPooling(
|
| 172 |
last_hidden_state=hidden_states,
|
| 173 |
pooler_output=self.perceive(hidden_states, grid),
|
| 174 |
-
hidden_states=tuple(states) if
|
| 175 |
)
|
|
|
|
| 164 |
last_hidden_state is the last block's output and pooler_output the Projector's, with newlines."""
|
| 165 |
grid = (pixel_values.shape[-2] // self.config.patch_size, pixel_values.shape[-1] // self.config.patch_size)
|
| 166 |
hidden_states = self.embeddings(pixel_values)
|
| 167 |
+
states = [hidden_states] if output_hidden_states else None
|
| 168 |
for layer in self.layers:
|
| 169 |
hidden_states = layer(hidden_states)
|
| 170 |
+
if states is not None:
|
| 171 |
+
states.append(hidden_states)
|
| 172 |
return BaseModelOutputWithPooling(
|
| 173 |
last_hidden_state=hidden_states,
|
| 174 |
pooler_output=self.perceive(hidden_states, grid),
|
| 175 |
+
hidden_states=tuple(states) if states is not None else None,
|
| 176 |
)
|