Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
demo.launch()
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""Copy of app.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1PkLAIGVP2xaP1XiU1KH9Bn4hO34hXe98
|
8 |
+
"""
|
9 |
+
|
10 |
+
#/default_exp app
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
#/export
|
15 |
+
#from fastai.vision.all import *
|
16 |
+
!pip install gradio
|
17 |
import gradio as gr
|
18 |
|
19 |
+
#/export
|
20 |
+
def is_monet(x): return x[0].issupper
|
21 |
+
|
22 |
+
#/export
|
23 |
+
from fastai.vision.all import *
|
24 |
+
|
25 |
+
#/export
|
26 |
+
learn = load_learner('model.pkl')
|
27 |
+
|
28 |
+
#/export
|
29 |
+
categories = ('Manet', 'Monet')
|
30 |
+
def classify_image(img):
|
31 |
+
pred, idx, probs = learn.predict(img)
|
32 |
+
return dict(zip(categories, map(float, probs)))
|
33 |
+
|
34 |
+
# export
|
35 |
+
image = gr.Image() # Image input without shape argument
|
36 |
+
label = gr.Label() # Label output
|
37 |
+
|
38 |
+
# Define some example images (make sure these paths are correct)
|
39 |
+
examples = ['monet2.jpg', 'manet2.jpg', 'manet1.jpeg']
|
40 |
+
|
41 |
+
# Create the Gradio interface
|
42 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
43 |
+
|
44 |
+
# Launch the interface with Inline=False to open in a separate window
|
45 |
+
intf.launch(share=True)
|
46 |
|
|
|
|