Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import load_learner
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Descarga el modelo desde Hugging Face
|
6 |
+
model_path = hf_hub_download(repo_id="Zemog13/gradio-test", filename="export.pkl")
|
7 |
+
learn = load_learner(model_path)
|
8 |
+
|
9 |
+
# Funci贸n para predicci贸n
|
10 |
+
def predict(image):
|
11 |
+
pred, _, probs = learn.predict(image)
|
12 |
+
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
|
13 |
+
|
14 |
+
# Interfaz de Gradio
|
15 |
+
demo = gr.Interface(fn=predict, inputs="image", outputs="label")
|
16 |
+
demo.launch()
|