Spaces:
Runtime error
Runtime error
Jose Garzon
commited on
Commit
·
c39b596
1
Parent(s):
8896971
Model loaded
Browse files- app.py +17 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.learner import load_learner
|
3 |
+
from fastai.vision.core import PILImage
|
4 |
+
|
5 |
+
|
6 |
+
from huggingface_hub import hf_hub_download
|
7 |
+
|
8 |
+
|
9 |
+
learner = load_learner(hf_hub_download("JmGarzonv/intel_image_classification_fastai","model.pkl","model.pkl"))
|
10 |
+
|
11 |
+
def classify_image(image):
|
12 |
+
img = PILImage.create(image)
|
13 |
+
pred_class, pred_idx, outputs = learner.predict(img)
|
14 |
+
return(f"Predicted class: {pred_class}")
|
15 |
+
|
16 |
+
demo = gr.Interface(classify_image, gr.Image(shape=(224, 224)), "text")
|
17 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
fastai
|