Spaces:
Sleeping
Sleeping
Commit
·
e8b7738
1
Parent(s):
bb74f26
Add application file
Browse files- app.py +20 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("jdmartinev/intel_image_classification_fastai","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(share=True)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
fastai
|