Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
from seefood_classifier_import import get_seefood_classifier
|
|
|
|
|
3 |
|
4 |
classifier = get_seefood_classifier()
|
5 |
|
6 |
def classify(image):
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
iface = gr.Interface(fn=classify, inputs="image", outputs="label")
|
11 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from seefood_classifier_import import get_seefood_classifier
|
3 |
+
import PIL.Image
|
4 |
+
import numpy as np
|
5 |
|
6 |
classifier = get_seefood_classifier()
|
7 |
|
8 |
def classify(image):
|
9 |
+
im = PIL.Image.fromarray(np.array(image, dtype=np.uint8))
|
10 |
+
preds = classifier.predict_image(im)
|
11 |
+
results = {pred['label']: pred['score'] for pred in preds}
|
12 |
+
return results
|
13 |
|
14 |
iface = gr.Interface(fn=classify, inputs="image", outputs="label")
|
15 |
iface.launch()
|