Spaces:
Build error
Build error
| 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" | |
| 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) |