Spaces:
Build error
Build error
File size: 1,509 Bytes
96ecc8c f18b840 f56cfec f18b840 96ecc8c f18b840 |
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 |
import streamlit as st
import joblib
import numpy as np
import tempfile
import cv2
from huggingface_hub import hf_hub_download
from utils.features import extract_feature_vector
st.set_page_config(page_title="ASL Alphabet Classifier", layout="centered")
# =========================
# LOAD MODEL FROM HF HUB
# =========================
MODEL_REPO = "bimo177x/model"
MODEL_FILE = "asl_random_forest_v1.joblib"
@st.cache_resource
def load_model():
model_path = hf_hub_download(
repo_id=MODEL_REPO,
filename=MODEL_FILE
)
return joblib.load(model_path)
model = load_model()
CLASS_NAMES = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
st.title("ASL Alphabet Image Classifier")
st.write("Unggah gambar tangan berpose alfabet ASL. Sistem akan memproses dan mengklasifikasinya.")
uploaded = st.file_uploader("Upload Image", type=["jpg", "jpeg", "png"])
if uploaded:
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as tmp:
tmp.write(uploaded.read())
temp_path = tmp.name
st.image(uploaded, caption="Uploaded Image", width=300)
st.write("🔍 Extracting features...")
features = extract_feature_vector(temp_path)
if features is None:
st.error("Tidak bisa memproses gambar.")
else:
feats = features.reshape(1, -1)
pred = model.predict(feats)[0]
prob = model.predict_proba(feats)[0]
st.success(f"Prediksi: **{CLASS_NAMES[pred]}**")
st.write("Confidence:")
st.bar_chart(prob) |