Spaces:
Sleeping
Sleeping
Fix HF Spaces configuration: README frontmatter, Dockerfile Python version, and model loading from Hub
Browse files- Dockerfile +2 -2
- README.md +15 -3
- app.py +10 -1
- requirements.txt +1 -0
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
# Gunakan image Python 3.
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set working directory awal
|
| 5 |
WORKDIR /code
|
|
|
|
| 1 |
+
# Gunakan image Python 3.10
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set working directory awal
|
| 5 |
WORKDIR /code
|
README.md
CHANGED
|
@@ -1,10 +1,22 @@
|
|
| 1 |
-
|
| 2 |
title: Batik Classifier
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
title: Batik Classifier
|
| 3 |
+
emoji: 🎨
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# 🎨 Batik Classifier
|
| 11 |
+
|
| 12 |
+
Klasifikasi Motif Batik Indonesia menggunakan Model VGG16 Deep Learning.
|
| 13 |
+
|
| 14 |
+
## Features
|
| 15 |
+
|
| 16 |
+
- Upload gambar batik untuk mengetahui motif dan asalnya
|
| 17 |
+
- Mendukung 111 motif batik dari berbagai daerah di Indonesia
|
| 18 |
+
- Top-5 prediction dengan confidence score
|
| 19 |
+
|
| 20 |
+
## Model
|
| 21 |
+
|
| 22 |
+
Model: [RimsJ/Batik-Classifier](https://huggingface.co/RimsJ/Batik-Classifier)
|
app.py
CHANGED
|
@@ -10,6 +10,8 @@ from PIL import Image
|
|
| 10 |
import json
|
| 11 |
import numpy as np
|
| 12 |
from typing import Tuple, Dict
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Global variables
|
| 15 |
model = None
|
|
@@ -37,8 +39,15 @@ def load_model():
|
|
| 37 |
model.classifier[3] = nn.Linear(4096, num_classes)
|
| 38 |
model.classifier = nn.Sequential(*list(model.classifier.children())[:4])
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Load trained weights
|
| 41 |
-
checkpoint = torch.load(
|
| 42 |
|
| 43 |
# Extract state_dict
|
| 44 |
if isinstance(checkpoint, dict) and 'model_state_dict' in checkpoint:
|
|
|
|
| 10 |
import json
|
| 11 |
import numpy as np
|
| 12 |
from typing import Tuple, Dict
|
| 13 |
+
from huggingface_hub import hf_hub_download
|
| 14 |
+
import os
|
| 15 |
|
| 16 |
# Global variables
|
| 17 |
model = None
|
|
|
|
| 39 |
model.classifier[3] = nn.Linear(4096, num_classes)
|
| 40 |
model.classifier = nn.Sequential(*list(model.classifier.children())[:4])
|
| 41 |
|
| 42 |
+
# Download model from Hugging Face Hub
|
| 43 |
+
print("📥 Downloading model from Hugging Face Hub...")
|
| 44 |
+
model_path = hf_hub_download(
|
| 45 |
+
repo_id="RimsJ/Batik-Classifier",
|
| 46 |
+
filename="vgg16_batik_best.pth"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
# Load trained weights
|
| 50 |
+
checkpoint = torch.load(model_path, map_location=device)
|
| 51 |
|
| 52 |
# Extract state_dict
|
| 53 |
if isinstance(checkpoint, dict) and 'model_state_dict' in checkpoint:
|
requirements.txt
CHANGED
|
@@ -7,3 +7,4 @@ torch==2.6.0
|
|
| 7 |
torchvision==0.21.0
|
| 8 |
Pillow==11.1.0
|
| 9 |
numpy==2.2.2
|
|
|
|
|
|
| 7 |
torchvision==0.21.0
|
| 8 |
Pillow==11.1.0
|
| 9 |
numpy==2.2.2
|
| 10 |
+
huggingface_hub
|