Image Classification
Transformers
Safetensors
English
custom_vit_nano
vit
nano
patch16
img224
custom_code
Instructions to use kd13/vit-nano-patch16-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kd13/vit-nano-patch16-224 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="kd13/vit-nano-patch16-224", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoModelForImageClassification model = AutoModelForImageClassification.from_pretrained("kd13/vit-nano-patch16-224", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update configuration_vit.py
Browse files- configuration_vit.py +32 -1
configuration_vit.py
CHANGED
|
@@ -1 +1,32 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig
|
| 2 |
+
|
| 3 |
+
class CustomViTNanoV2Config(PretrainedConfig):
|
| 4 |
+
model_type = "custom_vit_nano"
|
| 5 |
+
|
| 6 |
+
def __init__(
|
| 7 |
+
self,
|
| 8 |
+
image_size=224,
|
| 9 |
+
patch_size=16,
|
| 10 |
+
in_chans=3,
|
| 11 |
+
num_classes=1000,
|
| 12 |
+
embed_dim=224,
|
| 13 |
+
depth=6,
|
| 14 |
+
num_heads=4,
|
| 15 |
+
mlp_hidden_dim=608,
|
| 16 |
+
stem_channels=(32, 64, 128),
|
| 17 |
+
dropout=0.0,
|
| 18 |
+
**kwargs,
|
| 19 |
+
):
|
| 20 |
+
super().__init__(**kwargs)
|
| 21 |
+
self.image_size = image_size
|
| 22 |
+
self.patch_size = patch_size
|
| 23 |
+
self.in_chans = in_chans
|
| 24 |
+
self.num_classes = num_classes
|
| 25 |
+
self.embed_dim = embed_dim
|
| 26 |
+
self.depth = depth
|
| 27 |
+
self.num_heads = num_heads
|
| 28 |
+
self.mlp_hidden_dim = mlp_hidden_dim
|
| 29 |
+
self.stem_channels = stem_channels
|
| 30 |
+
self.dropout = dropout
|
| 31 |
+
|
| 32 |
+
CustomViTNanoV2Config.register_for_auto_class()
|