Views
No views yet
timm/swinv2_large_window12to16_192to256.ms_in22k_ft_in1k for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.SwinV2ImageClassify / SwinV2Model).1import os
2
3os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
4
5from PIL import Image
6from zeromodels.models.swinv2 import SwinV2ImageClassify, SwinV2Model, SwinV2ImageProcessor
7
8model = SwinV2ImageClassify.from_weights("zeromodels/swinv2_large_window12to16_192to256_ms_in22k_ft_in1k")
9processor = SwinV2ImageProcessor.from_weights("zeromodels/swinv2_large_window12to16_192to256_ms_in22k_ft_in1k")
10
11image = Image.open("your_image.jpg").convert("RGB")
12pixels = processor(image) # resize + normalize (normalization lives in the processor)
13logits = model(pixels, training=False)
14print(logits.shape) # (1, num_classes)
15
16# Feature extraction: the backbone without the classifier head
17backbone = SwinV2Model.from_weights("zeromodels/swinv2_large_window12to16_192to256_ms_in22k_ft_in1k", as_backbone=True)
18features = backbone(pixels, training=False)from_weights("zeromodels/<variant>"):KERAS_BACKEND before importing Keras / zeromodels.SwinV2ImageClassify returns class logits; SwinV2Model returns features (as_backbone=True for multi-scale stages).SwinV2ImageClassify.from_weights("hf:timm/swinv2_large_window12to16_192to256.ms_in22k_ft_in1k").license (usually matches the upstream checkpoint).