Views
No views yet
timm/swin_small_patch4_window7_224.ms_in1k for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.SwinImageClassify / SwinModel).1import os
2
3os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
4
5from PIL import Image
6from zeromodels.models.swin import SwinImageClassify, SwinModel, SwinImageProcessor
7
8model = SwinImageClassify.from_weights("zeromodels/swin_small_patch4_window7_224_ms_in1k")
9processor = SwinImageProcessor.from_weights("zeromodels/swin_small_patch4_window7_224_ms_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 = SwinModel.from_weights("zeromodels/swin_small_patch4_window7_224_ms_in1k", as_backbone=True)
18features = backbone(pixels, training=False)from_weights("zeromodels/<variant>"):KERAS_BACKEND before importing Keras / zeromodels.SwinImageClassify returns class logits; SwinModel returns features (as_backbone=True for multi-scale stages).SwinImageClassify.from_weights("hf:timm/swin_small_patch4_window7_224.ms_in1k").license (usually matches the upstream checkpoint).