Spaces:
Sleeping
Sleeping
try
Browse files
app.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
import numpy as np
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
[0.393, 0.769, 0.189],
|
7 |
-
[0.349, 0.686, 0.168],
|
8 |
-
[0.272, 0.534, 0.131]
|
9 |
-
])
|
10 |
-
sepia_img = input_img.dot(sepia_filter.T)
|
11 |
-
sepia_img /= sepia_img.max()
|
12 |
-
return sepia_img
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
learn = load_learner('export.pkl')
|
5 |
+
labels = learn.dls.vocab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
def classify_image(img):
|
8 |
+
img = PILImage.create(img)
|
9 |
+
pred, idx, probs = learn.predict(img)
|
10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
11 |
+
|
12 |
+
|
13 |
+
examples = ['grizzly.jpg']
|
14 |
+
enable_queue=True
|
15 |
+
|
16 |
+
gr.Interface(fn=classify_image,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(),enable_queue=enable_queue).launch()
|