shitijnigam commited on
Commit
582d58c
1 Parent(s): ded6d79

update app

Browse files
Files changed (4) hide show
  1. app.py +42 -8
  2. dunno.jpeg +0 -0
  3. fastai_course.code-workspace +11 -0
  4. munchkin.jpeg +0 -0
app.py CHANGED
@@ -1,12 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!! (welcome to testing)"
5
 
6
- iface = gr.Interface(
7
- fn = greet,
8
- inputs = "text",
9
- outputs = "text"
10
- )
11
 
12
- iface.launch(share = True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
+
3
+ # def greet(name):
4
+ # return "Hello " + name + "!! (welcome to testing)"
5
+
6
+ # iface = gr.Interface(
7
+ # fn = greet,
8
+ # inputs = "text",
9
+ # outputs = "text"
10
+ # )
11
+
12
+ # iface.launch(share = True)
13
+
14
+ from fastai.vision.all import *
15
  import gradio as gr
16
 
17
+ def is_cat(x):
18
+ return x[0].isupper()
19
 
20
+ #|export
21
+ dog_path = 'aku.jpeg'
22
+ cat_path = 'munchkin.jpeg'
23
+ dunno_path = 'dunno.jpeg'
 
24
 
25
+ model_path = 'model.pkl'
26
+ learn = load_learner(model_path)
27
+
28
+ #|export
29
+ categories = ('Dog', 'Cat')
30
+
31
+ def classify_image(image):
32
+ predict, index, probabilities = learn.predict(image)
33
+ output = dict(zip(categories, map(float, probabilities)))
34
+ return output
35
+
36
+ image = gr.Image() # image = gr.inputs.Image(shape = (192, 192))
37
+ label = gr.Label() # label = gr.Label()
38
+ examples = [dog_path, cat_path, dunno_path] # examples = ['aku.jpeg', 'munchkin.jpeg', 'dunno.jpeg']
39
+
40
+ interface = gr.Interface(
41
+ fn = classify_image,
42
+ inputs = image,
43
+ outputs = label,
44
+ examples = examples
45
+ )
46
+ interface.launch(inline = False, share = True)
dunno.jpeg ADDED
fastai_course.code-workspace ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "../fastai_course"
5
+ },
6
+ {
7
+ "path": "."
8
+ }
9
+ ],
10
+ "settings": {}
11
+ }
munchkin.jpeg ADDED