Instructions to use spidey1807/vit-small-cifar100-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use spidey1807/vit-small-cifar100-lora with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- image-classification
|
| 5 |
+
- vision-transformer
|
| 6 |
+
- lora
|
| 7 |
+
- peft
|
| 8 |
+
- cifar100
|
| 9 |
+
datasets:
|
| 10 |
+
- cifar100
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# ViT-Small CIFAR-100 (LoRA Fine-tuned)
|
| 14 |
+
|
| 15 |
+
This model is a `vit_small_patch16_224` from [timm](https://github.com/huggingface/pytorch-image-models),
|
| 16 |
+
fine-tuned on **CIFAR-100** using **LoRA (Low-Rank Adaptation)** via the
|
| 17 |
+
[PEFT](https://github.com/huggingface/peft) library.
|
| 18 |
+
|
| 19 |
+
## Training Details
|
| 20 |
+
|
| 21 |
+
- **Base model**: `vit_small_patch16_224` (ImageNet pretrained)
|
| 22 |
+
- **Dataset**: CIFAR-100 (100 classes)
|
| 23 |
+
- **Method**: LoRA injected into attention `qkv` layers
|
| 24 |
+
- **WandB project**: `mlops-assignment5`
|
| 25 |
+
|
| 26 |
+
## Usage
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
import torch
|
| 30 |
+
import timm
|
| 31 |
+
from peft import LoraConfig, get_peft_model
|
| 32 |
+
|
| 33 |
+
model = timm.create_model("vit_small_patch16_224", pretrained=False, num_classes=100)
|
| 34 |
+
lora_config = LoraConfig(r=RANK, lora_alpha=ALPHA, target_modules=["qkv"],
|
| 35 |
+
lora_dropout=0.1, bias="none", modules_to_save=["head"])
|
| 36 |
+
model = get_peft_model(model, lora_config)
|
| 37 |
+
|
| 38 |
+
ckpt = torch.load("pytorch_model.pt", map_location="cpu")
|
| 39 |
+
model.load_state_dict(ckpt["model_state_dict"])
|
| 40 |
+
model.eval()
|
| 41 |
+
```
|