NikiTricky commited on
Commit
7bf3aad
·
1 Parent(s): 447ad7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -1,8 +1,15 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
7
 
8
- demo.launch()
 
 
 
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()