Ener3122 commited on
Commit
76dc46e
·
verified ·
1 Parent(s): f128ed5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ from huggingface_hub import from_pretrained_fastai
4
+
5
+
6
+ learn = from_pretrained_fastai("Ener3122/Seasons_Classifier")
7
+ labels = learn.dls.vocab
8
+
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred, pred_idx, probs = learn.predict(img)
13
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
+
15
+
16
+ title = "Seasons predictor"
17
+ description = "As long as there isn't water, it might guess right"
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Image(),
22
+ outputs=gr.Label(num_top_classes=4),
23
+ title=title,
24
+ description=description,
25
+ examples=examples,
26
+ ).launch()