jongalon commited on
Commit
05ed7b5
1 Parent(s): 0ee4d85

Add application file

Browse files
Files changed (2) hide show
  1. app.py +20 -0
  2. 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()
18
+
19
+
20
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ fastai