Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- image-classification
|
| 6 |
+
- efficientnet
|
| 7 |
+
- vm-ai
|
| 8 |
+
- activity-recognition
|
| 9 |
+
datasets:
|
| 10 |
+
- maxf-coder/task_image_classifier
|
| 11 |
+
metrics:
|
| 12 |
+
- accuracy
|
| 13 |
+
- f1
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# VM.AI — Image Classifier
|
| 17 |
+
|
| 18 |
+
EfficientNet-B4 trained on 14 activity categories for the image-to-prompt pipeline.
|
| 19 |
+
|
| 20 |
+
## Performance
|
| 21 |
+
|
| 22 |
+
| Metric | Value |
|
| 23 |
+
|--------|-------|
|
| 24 |
+
| Test samples | {test_samples} |
|
| 25 |
+
| Top-1 accuracy | {top1} |
|
| 26 |
+
| Top-3 accuracy | {top3} |
|
| 27 |
+
| Macro F1 | {macro_f1} |
|
| 28 |
+
| Weighted F1 | {weighted_f1} |
|
| 29 |
+
|
| 30 |
+
## Per-Class Metrics
|
| 31 |
+
|
| 32 |
+
| Class | Precision | Recall | F1 | Support |
|
| 33 |
+
|-------|-----------|--------|------|---------|
|
| 34 |
+
{class_rows}
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import torch
|
| 39 |
+
import timm
|
| 40 |
+
from PIL import Image
|
| 41 |
+
from torchvision import transforms
|
| 42 |
+
|
| 43 |
+
model = timm.create_model("efficientnet_b4", pretrained=False, num_classes=14)
|
| 44 |
+
model.load_state_dict(torch.load("efficientnet_b4_classifier.pth", map_location="cpu"))
|
| 45 |
+
model.eval()
|
| 46 |
+
|
| 47 |
+
transform = transforms.Compose([
|
| 48 |
+
transforms.Resize((380, 380)),
|
| 49 |
+
transforms.ToTensor(),
|
| 50 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
|
| 51 |
+
])
|
| 52 |
+
|
| 53 |
+
img = Image.open("photo.jpg").convert("RGB")
|
| 54 |
+
tensor = transform(img).unsqueeze(0)
|
| 55 |
+
with torch.no_grad():
|
| 56 |
+
logits = model(tensor)
|
| 57 |
+
pred = logits.argmax(1).item()
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## Training
|
| 61 |
+
|
| 62 |
+
Two-phase training: 5 frozen epochs (head only) + 20 unfrozen epochs (last 2 blocks).
|
| 63 |
+
Optimizer: AdamW with cosine annealing. Mixed precision (AMP).
|
| 64 |
+
See [train_classifier.py](https://github.com/Infiteri/VM.AI) for details.
|
| 65 |
+
|
| 66 |
+
## Charts
|
| 67 |
+
|
| 68 |
+

|
| 69 |
+

|
| 70 |
+

|