Pablogps commited on
Commit
9a70cb3
1 Parent(s): 289af6c

Create app.py

Browse files

Created first attempt at the main app file

Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("Pablogps/gradio-test-24")
7
+ # learn = load_learner('model.pkl')
8
+ labels = learn.dls.vocab
9
+
10
+
11
+ def predict(img):
12
+ img = PILImage.create(img)
13
+ pred, pred_idx, probs = learn.predict(img)
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+
17
+ title = "Bad castle predictor"
18
+ description = "A bad model that tries to identify the type of castle."
19
+ examples = ['spanish.jpg', 'french.jpg', 'japanese.jpg']
20
+
21
+ gr.Interface(
22
+ fn=predict,
23
+ inputs=gr.Image(),
24
+ outputs=gr.Label(num_top_classes=3),
25
+ title=title,
26
+ description=description,
27
+ examples=examples,
28
+ ).launch()
29
+ iface.launch()