alt.freeweights.gemma / gemma4_vit_167m_enc.gemma4_e4b_it
From: timm <huggingface.co/timm>Newsgroups: alt.freeweights.gemmaSubject:

gemma4_vit_167m_enc.gemma4_e4b_it

Date: 2026-11-15Commit: fdf8f81Signed: 2DC28CC7B26A283B ✓

Image feature extraction model with 167M parameters. Safetensors weights, 670 MB in all. Published by timm under Apache-2.0.

167M params670MBgemma4_vit_167m_enc.gemma4_e4b_itsafetensorspermissive
FactsParams167MSize670 MBFormatssafetensorsTaskimage feature extractionLicenseApache-2.0From sourcepermissive
$ fw get timm/gemma4_vit_167m_enc.gemma4_e4b_it
# manifest sha256 bb17855e2eea… · 670 MB · 4 files
$ fw verify ./gemma4_vit_167m_enc.gemma4_e4b_it timm/gemma4_vit_167m_enc.gemma4_e4b_it
From sourceHosted (signed)timm/gemma4_vit_167m_enc.gemma4_e4b_itLast check: 2026-11-15 03:38 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Works with

Runs with

Ranked by fit to this model (safetensors), then by GitHub stars.

Overview

Size
670 MB
Weights
670 MB (safetensors)
Parameters
167M
Formats
safetensors
Task
image feature extraction
License
Apache-2.0 (permissive)
Files
4, each with a sha256
Publisher
timm
Added
2026-11-15
Section
alt.freeweights.gemma
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 03:38 UTCpassed

Model card

From the publisher at commit fdf8f81. Shown as plain text with links; images open at the publisher.

Model card for gemma4_vit_167m_enc.gemma4_e4b_it#

A Gemma 4 ViT image feature encoder extracted from Google's Gemma 4 E4B-it multimodal language model. This is the native VLM vision encoder with a spatial k×k soft-token pool + √D scale (bit-perfect with the HuggingFace Gemma4VisionModel reference implementation). The architecture is a custom ViT with 2D RoPE, gated MLP (GELU-tanh), RMS normalization on Q/K/V, and a 4-norm sandwich block layout.

Model Notes#

  • Weights were imported directly from the source VLM's vision tower (Gemma 4 E4B-it); outputs match the transformers Gemma4VisionModel implementation bit-for-bit on matching inputs.
  • Gemma 4 expects raw [0, 1]-range pixel tensors — the model maps them internally to [-1, 1] via 2 * (x - 0.5). The pretrained_cfg therefore declares mean=(0, 0, 0) / std=(1, 1, 1) to disable normalization in timm's standard transform pipeline and avoid double-normalization.
  • The encoder supports NaFlex-style variable-resolution inputs and integrates with timm's NaFlex data pipeline (see timm.data.naflex_loader / --naflex-loader in train.py). Both raw (B, C, H, W) images and pre-patchified (B, N, ...) tensors (plus patch_coord / patch_valid) are accepted — so the same model can be trained or fine-tuned with dynamic batch sizing that preserves native aspect ratios at flexible resolutions, or run at a fixed square input size.

Model Details#

Model Usage#

Feature Map Extraction#
from urllib.request import urlopen
from PIL import Image
import timm

img = Image.open(urlopen(
    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))

model = timm.create_model(
    'gemma4_vit_167m_enc.gemma4_e4b_it',
    pretrained=True,
    features_only=True,
)
model = model.eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

output = model(transforms(img).unsqueeze(0))  # unsqueeze single image into batch of 1

for o in output:
    # print shape of each feature map in output
    # e.g.:
    #  torch.Size([1, 768, 48, 48])
    #  torch.Size([1, 768, 48, 48])
    #  torch.Size([1, 768, 48, 48])

    print(o.shape)
Image Embeddings#
from urllib.request import urlopen
from PIL import Image
import timm

img = Image.open(urlopen(
    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))

model = timm.create_model(
    'gemma4_vit_167m_enc.gemma4_e4b_it',
    pretrained=True,
    num_classes=0,  # remove classifier nn.Linear
)
model = model.eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

output = model(transforms(img).unsqueeze(0))  # output is (batch_size, num_features) shaped tensor

# or equivalently (without needing to set num_classes=0)

output = model.forward_features(transforms(img).unsqueeze(0))
# output is unpooled, a (1, 2304, 768) shaped tensor

output = model.forward_head(output, pre_logits=True)
# output is a (1, num_features) shaped tensor

Citation#

@misc{gemma4_2025,
  title={Gemma 4},
  author={{Gemma Team, Google DeepMind}},
  year={2025},
  howpublished={\url{https://ai.google.dev/gemma/docs/core/model_card_4}}
}
@misc{rw2019timm,
  author = {Ross Wightman},
  title = {PyTorch Image Models},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  doi = {10.5281/zenodo.4414861},
  howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
}

Files

4 files · 670 MBWeights 670 MB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 4 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
README.md4.45 KBa7aeb6024125fcbd09fa4ab12b955e632c8154c9d99f739ca444d4c127601f22
config.json667 B9228b142e38b33eaa680e7ecee5be08a9f014d5477b10904702b3408f5d567bd
model.safetensors670 MBbe17d43a474277ae1deb776993047bc84f1ff1784445a1e9dd22465789326196
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
fdf8f81e08 pinned now2026-11-15 03:38 UTC4 files · 670 MB

Use it

$ fw get timm/gemma4_vit_167m_enc.gemma4_e4b_it
# manifest sha256 bb17855e2eea… · 670 MB · 4 files
$ fw verify ./gemma4_vit_167m_enc.gemma4_e4b_it timm/gemma4_vit_167m_enc.gemma4_e4b_it
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/timm/gemma4_vit_167m_enc.gemma4_e4b_it.json --dir ./gemma4_vit_167m_enc.gemma4_e4b_it $ python3 fw.py verify ./gemma4_vit_167m_enc.gemma4_e4b_it ./timm__gemma4_vit_167m_enc.gemma4_e4b_it.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download timm/gemma4_vit_167m_enc.gemma4_e4b_it --revision fdf8f81e084f0dffb850345e9a9a9fbb1ee5cd27 --local-dir ./gemma4_vit_167m_enc.gemma4_e4b_it

License

Name
Apache License 2.0
Id
Apache-2.0
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
README.md
Text sha256
a7aeb6024125fcbd09fa4ab12b955e632c8154c9d99f739ca444d4c127601f22
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: timm <huggingface.co/timm>Newsgroups: alt.freeweights.gemmaSubject: gemma4_vit_167m_enc.gemma4_e4b_itDate: 2026-11-15Commit: fdf8f81Signed: 2DC28CC7B26A283B ✓
Upstream
timm/gemma4_vit_167m_enc.gemma4_e4b_it
Pinned commit
fdf8f81e084f0dffb850345e9a9a9fbb1ee5cd27
Manifest
gemma4_vit_167m_enc.gemma4_e4b_it.json · .minisig
Manifest sha256
bb17855e2eeadd8f68c7bf0789b7e5b2330447909e5a03a9c68b2e461910f7ae
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 03:38 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/timm/gemma4_vit_167m_enc.gemma4_e4b_it.json $ curl -O https://freeweights.allternit.com/manifests/timm/gemma4_vit_167m_enc.gemma4_e4b_it.json.minisig $ minisign -Vm gemma4_vit_167m_enc.gemma4_e4b_it.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

No related models in this catalog.Nothing here lists this model as its parent, and it names no parent.
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download timm/gemma4_vit_167m_enc.gemma4_e4b_it
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. gemma4_vit_167m_enc.gemma4_e4b_it.json. Provenance. Takedown history: none.
From: laion <huggingface.co/laion>Subject: Alexandria-Gemma-4-12B-it-Ornith9-Summaries-LoRA-r128
From: laion <huggingface.co/laion>Subject: Alexandria-Gemma-4-12B-it-Ornith9-Summaries-LoRA-r64
From: laion <huggingface.co/laion>Subject: Alexandria-Gemma-4-12B-it-Qwen27-Knowledge-Units-LoRA-r128
From: laion <huggingface.co/laion>Subject: Alexandria-Gemma-4-12B-it-Qwen27-Summaries-LoRA-r128
From: laion <huggingface.co/laion>Subject: Alexandria-Gemma-4-12B-it-Qwen27-Summaries-LoRA-r64
From: laion <huggingface.co/laion>Subject: Alexandria-Gemma-4-E4B-it-Qwen27-Knowledge-Units-LoRA-r128