Instructions to use cominder/iwin-tiny-patch4-window7-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cominder/iwin-tiny-patch4-window7-224 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="cominder/iwin-tiny-patch4-window7-224", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForImageClassification model = AutoModelForImageClassification.from_pretrained("cominder/iwin-tiny-patch4-window7-224", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 2,452 Bytes
d1878b8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # coding=utf-8
# Copyright 2025 Simin Huo and Ning Li. Iwin Transformer.
# SPDX-License-Identifier: MIT
"""Hugging Face configuration for Iwin Transformer."""
from transformers import PretrainedConfig
class IwinConfig(PretrainedConfig):
r"""
Configuration for [`IwinModel`] / [`IwinForImageClassification`].
Matches the Hub checkpoints under `cominder/iwin-*`. The published
`config.json` used `path_norm` for patch-embedding LayerNorm; that alias is
accepted and written back as `patch_norm`.
"""
model_type = "iwin"
attribute_map = {
"num_attention_heads": "num_heads",
"num_hidden_layers": "num_layers",
}
def __init__(
self,
image_size=224,
patch_size=4,
num_channels=3,
embed_dim=96,
depths=None,
num_heads=None,
window_size=7,
mlp_ratio=4.0,
qkv_bias=True,
hidden_dropout_prob=0.0,
attention_probs_dropout_prob=0.0,
drop_path_rate=0.1,
hidden_act="gelu",
use_absolute_embeddings=False,
initializer_range=0.02,
layer_norm_eps=1e-5,
patch_norm=None,
path_norm=None,
encoder_stride=32,
**kwargs,
):
super().__init__(**kwargs)
if depths is None:
depths = [2, 2, 6, 2]
if num_heads is None:
num_heads = [3, 6, 12, 24]
if patch_norm is None:
patch_norm = True if path_norm is None else bool(path_norm)
self.image_size = image_size
self.patch_size = patch_size
self.num_channels = num_channels
self.embed_dim = embed_dim
self.depths = list(depths)
self.num_layers = len(self.depths)
self.num_heads = list(num_heads)
self.window_size = window_size
self.mlp_ratio = mlp_ratio
self.qkv_bias = qkv_bias
self.hidden_dropout_prob = hidden_dropout_prob
self.attention_probs_dropout_prob = attention_probs_dropout_prob
self.drop_path_rate = drop_path_rate
self.hidden_act = hidden_act
self.use_absolute_embeddings = use_absolute_embeddings
self.initializer_range = initializer_range
self.layer_norm_eps = layer_norm_eps
self.patch_norm = bool(patch_norm)
self.path_norm = self.patch_norm
self.encoder_stride = encoder_stride
self.hidden_size = int(embed_dim * 2 ** (len(self.depths) - 1))
|