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
Tighten model card
Browse files
README.md
CHANGED
|
@@ -14,46 +14,42 @@ base_model:
|
|
| 14 |
|
| 15 |
# Hy4-Flash-Vision
|
| 16 |
|
| 17 |
-
This repository packages the vision Tower and Projector from [Hy4 flash](https://huggingface.co/tencent/Hy4-flash)
|
| 18 |
|
| 19 |
## Contents
|
| 20 |
|
| 21 |
| File | Tensors | What it holds |
|
| 22 |
|---|---|---|
|
| 23 |
-
| `model.safetensors` | 441 |
|
| 24 |
-
| `modeling_hy4_flash_vision.py` | | Standalone Tower and Projector
|
| 25 |
| `config.json` | | Vision configuration |
|
| 26 |
-
| `export_manifest.json` | | Source pin,
|
| 27 |
-
| `LICENSE`, `LICENSE-CODE`, `NOTICE` | | Weight license, code license and attribution |
|
| 28 |
|
| 29 |
## Architecture
|
| 30 |
|
| 31 |
| Component | Details |
|
| 32 |
|---|---|
|
| 33 |
-
| Tower | 27
|
| 34 |
-
|
|
| 35 |
-
| Positions | Learned absolute only. The 128 x 128 table (`[16385, 1152]`, row 0 unused) is interpolated bilinearly with `scale_factor = (size + 0.1) / 128` and `align_corners=False` |
|
| 36 |
-
| Output | No final norm and no class or register tokens: the last block feeds the Projector |
|
| 37 |
-
| Projector | RMSNorm (eps 1e-5), `Conv2d(1152, 4608, 2, stride 2)`, GELU, `Conv2d(4608, 3072, 1)`, then a learned `image_newline` token after each row |
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
## Usage
|
| 42 |
|
| 43 |
-
See [`examples/inference.py`](examples/inference.py) for image feature extraction. `AutoModel.from_pretrained(..., trust_remote_code=True)` loads `modeling_hy4_flash_vision.py`
|
| 44 |
|
| 45 |
## Validation
|
| 46 |
|
| 47 |
-
The [parity check](https://github.com/immanuel-peter/vision-tower-bench/blob/main/vtb/parity/hy4_flash.py)
|
| 48 |
|
| 49 |
## Reproduction
|
| 50 |
|
| 51 |
-
The [export script](https://github.com/immanuel-peter/vision-tower-bench/blob/main/vtb/adapters/hy4_flash.py) range-reads the 441 `vit.*` tensors from
|
| 52 |
|
| 53 |
## Credits
|
| 54 |
|
| 55 |
-
Tencent released the Hy4 flash weights
|
| 56 |
|
| 57 |
## License
|
| 58 |
|
| 59 |
-
Weights
|
|
|
|
| 14 |
|
| 15 |
# Hy4-Flash-Vision
|
| 16 |
|
| 17 |
+
This repository packages the vision Tower and Projector from [Hy4 flash](https://huggingface.co/tencent/Hy4-flash), initialized from [SigLIP 2 So400m](https://huggingface.co/google/siglip2-so400m-patch14-384) and extended to native resolutions from 512 to 2048 px.
|
| 18 |
|
| 19 |
## Contents
|
| 20 |
|
| 21 |
| File | Tensors | What it holds |
|
| 22 |
|---|---|---|
|
| 23 |
+
| `model.safetensors` | 441 | 435 Tower and 6 Projector (`perceive.*`) tensors from `vit.*` |
|
| 24 |
+
| `modeling_hy4_flash_vision.py` | | Standalone Tower and Projector (`trust_remote_code=True`) |
|
| 25 |
| `config.json` | | Vision configuration |
|
| 26 |
+
| `export_manifest.json` | | Source pin, shards and tensor counts |
|
|
|
|
| 27 |
|
| 28 |
## Architecture
|
| 29 |
|
| 30 |
| Component | Details |
|
| 31 |
|---|---|
|
| 32 |
+
| Tower | 27 blocks, 1152 hidden, 4304 MLP, 16 heads, patch size 16, GELU, learned 128 x 128 absolute positions |
|
| 33 |
+
| Projector | RMSNorm, `Conv2d(1152, 4608, 2, stride 2)`, GELU, `Conv2d(4608, 3072, 1)`, learned `image_newline` per row |
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
At 512 px this gives 1024 Tower tokens (1152-d), 256 merged tokens (4608-d), and 256 projected tokens (3072-d) plus 16 newline tokens.
|
| 36 |
|
| 37 |
## Usage
|
| 38 |
|
| 39 |
+
See [`examples/inference.py`](examples/inference.py) for image feature extraction. `AutoModel.from_pretrained(..., trust_remote_code=True)` loads `modeling_hy4_flash_vision.py`.
|
| 40 |
|
| 41 |
## Validation
|
| 42 |
|
| 43 |
+
The [parity check](https://github.com/immanuel-peter/vision-tower-bench/blob/main/vtb/parity/hy4_flash.py) verifies all 441 tensors against the pinned parent with `torch.equal` and compares forward outputs against the `hy_v4_flash` reference in Transformers [PR #50903](https://github.com/huggingface/transformers/pull/50903).
|
| 44 |
|
| 45 |
## Reproduction
|
| 46 |
|
| 47 |
+
The [export script](https://github.com/immanuel-peter/vision-tower-bench/blob/main/vtb/adapters/hy4_flash.py) range-reads the 441 `vit.*` tensors from the pinned parent and writes the original BF16 tensors.
|
| 48 |
|
| 49 |
## Credits
|
| 50 |
|
| 51 |
+
Tencent released the Hy4 flash weights; Google released SigLIP 2. The vision forward follows Hugging Face Transformers.
|
| 52 |
|
| 53 |
## License
|
| 54 |
|
| 55 |
+
Weights use the [Tencent Hy License, Version 1.0](LICENSE) (Section 10 adds terms for large Model-as-a-Service businesses). Code is [MIT](LICENSE-CODE); see [NOTICE](NOTICE) for attribution.
|