Hetan07 commited on
Commit
77282d2
·
1 Parent(s): 4c545af

modified app.py to include the model

Browse files
Files changed (1) hide show
  1. app.py +56 -5
app.py CHANGED
@@ -1,7 +1,58 @@
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
+ # ---
2
+ # jupyter:
3
+ # jupytext:
4
+ # text_representation:
5
+ # extension: .py
6
+ # format_name: light
7
+ # format_version: '1.5'
8
+ # jupytext_version: 1.15.1
9
+ # kernelspec:
10
+ # display_name: Python 3 (ipykernel)
11
+ # language: python
12
+ # name: python3
13
+ # ---
14
+
15
+ # !conda install conda=23.7.3 -y
16
+
17
+ # !nbdev_migrate
18
+
19
+ #|export
20
+ # !pip install gradio
21
+
22
+ #|export
23
+ from fastai.vision.all import *
24
+ import gradio as gd
25
+
26
+ im = PILImage.create('car.jpg')
27
+ im.thumbnail((192,192))
28
+ im
29
+
30
+ #|export
31
+ learn = load_learner('export.pkl')
32
+
33
+ # %time learn.predict(im)
34
+
35
+ # +
36
+ #|export
37
+ categories = ('car','motorbike')
38
+
39
+ def classify_images(img):
40
+ pred,idx,probs = learn.predict(img)
41
+ return dict(zip(categories,map(float,probs)))
42
+
43
+
44
+ # -
45
+
46
+ classify_images(im)
47
+
48
+ # +
49
+ #|export
50
+ image = gd.inputs.Image(shape=(192,192))
51
+ label = gd.outputs.Label()
52
+ examples = ['car.jpg','bike.jpg']
53
+
54
+ intf = gd.Interface(fn = classify_images,inputs = image, outputs = label, examples = examples)
55
+ intf.launch(inline=False)
56
+
57
 
 
 
58