CoolFace
Apppublic

PM30/test3

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py26 linesDownload Raw Back to root
1import streamlit as st
2from fastai.vision.all import *
3from PIL import Image
4
5# Definiere die Custom-Funktion VOR dem Laden
6def is_cat(x): return x[0].isupper()
7
8# Lade das Modell mit Streamlit Caching
9@st.cache_resource
10def load_model():
11    return load_learner("model.pkl")
12
13learn = load_model()
14
15st.title("Katzen- vs. Hunde-Klassifikation 🐢🐱")
16
17uploaded_file = st.file_uploader("Lade ein Bild hoch", type=["jpg", "png", "jpeg"])
18if uploaded_file is not None:
19    img = PILImage.create(uploaded_file)
20    st.image(img.to_thumb(192,192), caption="Dein Bild", use_column_width=False)
21
22    pred, idx, probs = learn.predict(img)
23    st.markdown(f"**Vorhersage:** {pred}")
24    st.markdown(f"**Wahrscheinlichkeiten:**")
25    st.write({learn.dls.vocab[i]: float(p) for i, p in enumerate(probs)})
26