nicolasca commited on
Commit
aabe890
·
1 Parent(s): 113eb6d

Initial push

Browse files
Files changed (5) hide show
  1. app.py +30 -0
  2. images/baroche.jpg +0 -0
  3. images/byzantin.jpg +0 -0
  4. images/modern.jpg +0 -0
  5. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ learn = load_learner('architecture.pkl')
6
+
7
+ labels = learn.dls.vocab
8
+
9
+
10
+ def predict(img):
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+
15
+ title = "Architecture Classifier"
16
+ description = "An architecture classifier trained on DuckDuckGo images.... Created as a demo for Gradio and HuggingFace Spaces."
17
+ article = "<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
18
+ examples = ['images/baroche.jpg', 'images/byzantin.jpg', 'images/modern.jpg']
19
+ interpretation = 'default'
20
+ enable_queue = True
21
+
22
+ gr.Interface(fn=predict,
23
+ inputs=gr.inputs.Image(shape=(512, 512)),
24
+ outputs=gr.outputs.Label(num_top_classes=3),
25
+ title=title,
26
+ description=description,
27
+ article=article,
28
+ examples=examples,
29
+ interpretation=interpretation,
30
+ enable_queue=enable_queue).launch()
images/baroche.jpg ADDED
images/byzantin.jpg ADDED
images/modern.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image