Thomas Husken commited on
Commit
c80ed6f
1 Parent(s): 2b4baa0
Files changed (6) hide show
  1. .gitignore +1 -0
  2. app.py +20 -0
  3. children.jpg +0 -0
  4. requirements.txt +1 -0
  5. romance.jpg +0 -0
  6. science-fiction.jpg +0 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea/
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner('bookjudge.pkl')
5
+ labels = learn.dls.vocab
6
+
7
+ def predict(img):
8
+ img = PILImage.create(img)
9
+ pred,pred_idx,probs = learn.predict(img)
10
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
11
+
12
+
13
+ title = "Judge a book by its cover? Why of course!"
14
+ description = "Who says you can't judge a book by its cover? "
15
+ examples = ["children.jpg", "romance.jpg", "science-fiction.jpg"]
16
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
17
+ interpretation='default'
18
+ enable_queue=True
19
+
20
+ gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article, interpretation=interpretation,enable_queue=enable_queue, examples=examples).launch()
children.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai
romance.jpg ADDED
science-fiction.jpg ADDED