Spaces:
Sleeping
Sleeping
NikiTricky
commited on
Commit
·
7bf3aad
1
Parent(s):
447ad7c
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,15 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!"
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import from_pretrained_keras
|
3 |
|
4 |
+
model = from_pretrained_keras("NikiTricky/resnet50-food101")
|
|
|
5 |
|
6 |
+
def classify_image(inp):
|
7 |
+
inp = inp.reshape((-1, 224, 224, 3))
|
8 |
+
inp /= 255.0
|
9 |
+
prediction = model.predict(inp)
|
10 |
+
confidences = {model.config['id2label'][str(i)]: float(prediction[i]) for i in range(101)}
|
11 |
+
return confidences
|
12 |
|
13 |
+
gr.Interface(fn=classify_image,
|
14 |
+
inputs=gr.Image(shape=(224, 224)),
|
15 |
+
outputs=gr.Label(num_top_classes=3)).launch()
|