D0rs4n commited on
Commit
aefa871
1 Parent(s): f1cfe27

Update app.py add model

Browse files
Files changed (2) hide show
  1. app.py +15 -3
  2. model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,19 @@
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
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ def label_func(fname: str) -> str:
5
+ return fname.split("_")[0]
6
 
7
+ learner = load_learner("model.pkl")
8
+
9
+ categories = ("daytime", "nighttime", "sunrise")
10
+
11
+ def classify_image(img):
12
+ _, _, probs = learner.predict(img)
13
+ return dict(zip(categories, map(float, probs)))
14
+
15
+ image = gr.inputs.Image(shape=(192,192))
16
+ label = gr.outputs.Label()
17
+
18
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label)
19
  iface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c51d1092d9a2f7e07c0bb48663a9cb5c5ac1183c9cfd44c738ee22c9fb7e3718
3
+ size 46994987