jdmartinev commited on
Commit
200e978
·
1 Parent(s): 597aa86

Gradio space

Browse files
Files changed (2) hide show
  1. app.py +18 -0
  2. requeriments.txt +2 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.learner import load_learner
3
+ from fastai.vision.core import PILImage
4
+ from huggingface_hub import hf_hub_download
5
+
6
+
7
+ learner = load_learner(hf_hub_download("jdmartinev/intel_image_classification_fastai","model.pkl"))
8
+
9
+ def classify_image(image):
10
+ img = PILImage.create(image)
11
+ pred_class, pred_idx, outputs = learn.predict(img)
12
+ return f"Predicted class: {pred_class}"
13
+
14
+ interface = gr.Interface(fn=classify_image,
15
+ inputs=gr.inputs.Image(type="file", label="Upload an Image"),
16
+ outputs="text")
17
+
18
+ interface.launch()
requeriments.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ gradio