ihatetommy commited on
Commit
6fc378d
·
1 Parent(s): b34f2cd

added model and example image; updated code

Browse files
app.py CHANGED
@@ -1,7 +1,15 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ learn = load_learner("comics_classifier.pkl")
 
5
 
6
+ def classify_image(img):
7
+ publication, _, probs = learn.predict(img)
8
+ return dict(zip(("DC", "Marvel"), map(float, probs)))
9
+
10
+ image = gr.inputs.Image(shape=(192, 192))
11
+ label = gr.outputs.Label()
12
+ examples = ["./ex_img/John_Constantine_0010.jpg", "./ex_img/ambush_bug2.jpg", "./ex_img/blade.jpg"]
13
+
14
+ intf = gr.Interface(fn=classify_image, inputs=image,outputs=label, examples=examples)
15
+ intf.launch(inline=False)
comics_classifier1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e93d3a537950a5763f19e5f0435223d294e961252ac5b13c2d39c3f3d10e31e
3
+ size 46979413
ex_img/John_Constantine_0010.jpg ADDED
ex_img/ambush_bug2.jpg ADDED
ex_img/blade.jpg ADDED