TheUpperCaseGuy commited on
Commit
ddc21f0
·
1 Parent(s): 55de059

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,7 +1,29 @@
 
 
 
 
 
 
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 requests
3
+ from fastdownload import download_url
4
+ from duckduckgo_search import ddg_images
5
+ from fastcore.all import *
6
+ from fastai.vision.all import download_images
7
  import gradio as gr
8
 
9
+ learn = load_learner('resnet18_model.pkl')
10
+
11
+ categories = ('White','Black')
12
+
13
+
14
+
15
+ def classify_image(image):
16
+ is_people,_,probs = learn.predict(PILImage.create(image))
17
+ return dict(zip(categories,map(float,probs)))
18
+
19
+
20
+ image = gr.inputs.Image(shape=(192,192))
21
+ label = gr.outputs.Label()
22
+ examples=['Black people.jpg','white people.jpg']
23
+
24
+ intf =gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
25
+ intf.launch(inline=False)
26
+
27
+
28
+
29