hari31416 commited on
Commit
3c7199b
·
1 Parent(s): 5f6bf72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -80,26 +80,29 @@ def predict_image_class(image):
80
  top_10[label_dict[idx.item()]] = percentage[idx].item()
81
  return top_10
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
- # Define Gradio interface
85
- description = "This is a demo of EfficientNet trained on Food101 dataset.\
86
- Upload an image of food and it will predict the class of the food."
87
- inputs = gr.inputs.Image()
88
- outputs = gr.outputs.Label(num_top_classes=10)
89
- gradio_app = gr.Interface(
90
- fn=predict_image_class,
91
- inputs=inputs,
92
- outputs=outputs,
93
- title="FoodVision",
94
- description=description,
95
- theme="snehilsanyal/scikit-learn",
96
- examples=[
97
- ["examples/pizza.jpg"],
98
- ["examples/samosa.jpg"],
99
- ],
100
- )
101
-
102
- # Run Gradio app
103
- gradio_app.launch(
104
- server_port=7860,
105
- )
 
80
  top_10[label_dict[idx.item()]] = percentage[idx].item()
81
  return top_10
82
 
83
+ def main():
84
+ # Define Gradio interface
85
+ description = "This is a demo of EfficientNet trained on Food101 dataset.\
86
+ Upload an image of food and it will predict the class of the food."
87
+ inputs = gr.Image()
88
+ outputs = gr.Label(num_top_classes=10, label="Prediction")
89
+ gradio_app = gr.Interface(
90
+ fn=predict_image_class,
91
+ inputs=inputs,
92
+ outputs=outputs,
93
+ title="FoodVision",
94
+ description=description,
95
+ theme="snehilsanyal/scikit-learn",
96
+ examples=[
97
+ ["examples/pizza.jpg"],
98
+ ["examples/samosa.jpg"],
99
+ ],
100
+ )
101
+
102
+ gradio_app.queue().launch(server_name="0.0.0.0", server_port=7860)
103
+
104
+
105
+ if __name__ == "__main__":
106
+ # Run Gradio app
107
+ main()
108