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

gemma4_vit_167m.gemma4_e4b_it

Date: 2026-11-15Commit: 2eceff9Signed: 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.gemma4_e4b_itsafetensorspermissive
FactsParams167MSize670 MBFormatssafetensorsTaskimage feature extractionLicenseApache-2.0From sourcepermissive
$ fw get timm/gemma4_vit_167m.gemma4_e4b_it
# manifest sha256 99c8479ee762… · 670 MB · 4 files
$ fw verify ./gemma4_vit_167m.gemma4_e4b_it timm/gemma4_vit_167m.gemma4_e4b_it
From sourceHosted (signed)timm/gemma4_vit_167m.gemma4_e4b_itLast check: 2026-11-15 03:44 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:44 UTCpassed

Model card

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

Model card for gemma4_vit_167m.gemma4_e4b_it#

A Gemma 4 ViT image feature encoder extracted from Google's Gemma 4 E4B-it multimodal language model. This is the classifier-friendly wrapper exposing an avg-pool + RmsNorm on top of the encoder patch tokens, ready for fine-tuning a linear head. 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#

Image Classification#
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.gemma4_e4b_it', pretrained=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

top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
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.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.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.md5.13 KBd5a2ab750d527ce4b67f28ce6358d14a329883e996290002523866ea33333297
config.json670 Bc60f7c55d9769d35fc98f74b768126a348c731fd0dde8cf08506193eb6f780c7
model.safetensors670 MB653e7fd2e4016eae71981be8dfc0efe288e255694020ab316ecd06fae2ebeb1c
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
2eceff9715 pinned now2026-11-15 03:44 UTC4 files · 670 MB

Use it

$ fw get timm/gemma4_vit_167m.gemma4_e4b_it
# manifest sha256 99c8479ee762… · 670 MB · 4 files
$ fw verify ./gemma4_vit_167m.gemma4_e4b_it timm/gemma4_vit_167m.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.gemma4_e4b_it.json --dir ./gemma4_vit_167m.gemma4_e4b_it $ python3 fw.py verify ./gemma4_vit_167m.gemma4_e4b_it ./timm__gemma4_vit_167m.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.gemma4_e4b_it --revision 2eceff9715a7808c05f3e4175af307606f1b2999 --local-dir ./gemma4_vit_167m.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
d5a2ab750d527ce4b67f28ce6358d14a329883e996290002523866ea33333297
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.gemma4_e4b_itDate: 2026-11-15Commit: 2eceff9Signed: 2DC28CC7B26A283B ✓
Upstream
timm/gemma4_vit_167m.gemma4_e4b_it
Pinned commit
2eceff9715a7808c05f3e4175af307606f1b2999
Manifest
gemma4_vit_167m.gemma4_e4b_it.json · .minisig
Manifest sha256
99c8479ee762ff6edafcd1cf6d3879db875e8c8d3c5f71cba07c5a4be6c98719
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 03:44 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/timm/gemma4_vit_167m.gemma4_e4b_it.json $ curl -O https://freeweights.allternit.com/manifests/timm/gemma4_vit_167m.gemma4_e4b_it.json.minisig $ minisign -Vm gemma4_vit_167m.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.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.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