Spaces:
Sleeping
Sleeping
Edward Tan
commited on
Commit
·
dbbc7f7
1
Parent(s):
c61c465
Updating model
Browse files- .ipynb_checkpoints/app-checkpoint.py +23 -0
- app.py +19 -9
.ipynb_checkpoints/app-checkpoint.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
categories = 'grizzly','black','teddy'
|
4 |
+
learn_inf = load_learner('model/trained_image_model.pkl')
|
5 |
+
|
6 |
+
def classify_image(img):
|
7 |
+
pred, idx, probs = learn_inf.predict(img)
|
8 |
+
return dict(zip(categories, map(float, probs)))
|
9 |
+
|
10 |
+
image = gr.Image()
|
11 |
+
label = gr.Label()
|
12 |
+
examples = ["images/grizzly.jpg"]
|
13 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
14 |
+
intf.launch(analytics_enabled=False, inline=False, share=False, auth=("admin", "pass1234"))
|
15 |
+
|
16 |
+
# demo = gr.Interface(
|
17 |
+
# fn=greet,
|
18 |
+
# inputs=["text", "slider"],
|
19 |
+
# outputs=["text"],
|
20 |
+
# analytics_enabled=False
|
21 |
+
# )
|
22 |
+
|
23 |
+
# demo.launch(auth=("admin", "pass1234"), share=True)
|
app.py
CHANGED
@@ -1,13 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
outputs=["text"],
|
10 |
-
analytics_enabled=False
|
11 |
-
)
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
categories = 'grizzly','black','teddy'
|
4 |
+
learn_inf = load_learner('model/trained_image_model.pkl')
|
5 |
|
6 |
+
def classify_image(img):
|
7 |
+
pred, idx, probs = learn_inf.predict(img)
|
8 |
+
return dict(zip(categories, map(float, probs)))
|
|
|
|
|
|
|
9 |
|
10 |
+
image = gr.Image()
|
11 |
+
label = gr.Label()
|
12 |
+
examples = ["images/grizzly.jpg"]
|
13 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
14 |
+
intf.launch(analytics_enabled=False, inline=False, share=False, auth=("admin", "pass1234"))
|
15 |
+
|
16 |
+
# demo = gr.Interface(
|
17 |
+
# fn=greet,
|
18 |
+
# inputs=["text", "slider"],
|
19 |
+
# outputs=["text"],
|
20 |
+
# analytics_enabled=False
|
21 |
+
# )
|
22 |
+
|
23 |
+
# demo.launch(auth=("admin", "pass1234"), share=True)
|