grover101 commited on
Commit
5200e36
·
1 Parent(s): 944b43f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #/export
2
+ from fastai.vision.all import*
3
+ import gradio as gr
4
+
5
+ def oldornot(x): return x[0].isupper()
6
+
7
+ #/export
8
+ learn = load_learner('model.pkl')
9
+
10
+ #/export
11
+ categories = ['Old_Car','New_car']
12
+
13
+ def classify_image(img):
14
+ pred,idx,probs = learn.predict(img)
15
+ return dict(zip(categories,map(float,probs)))
16
+
17
+ #/export
18
+ image = gr.inputs.Image(shape=(192,192))
19
+ label = gr.outputs.Label()
20
+ examples = ['new_car_2.jpg','new_car_4.jpg','old_car_7.jpg','old_car_12.jpg']
21
+
22
+ intf = gr.Interface(fn=classify_image,inputs=image,output=label, examples=examples)
23
+ intf.launch(inline=False)