|
import gradio as gr |
|
import torch |
|
|
|
|
|
|
|
|
|
|
|
model = torch.hub.load('./', 'custom', 'best.pt',force_reload=True, source='local',trust_repo=True) |
|
|
|
def predict(input_image): |
|
""" |
|
Predict model output |
|
""" |
|
|
|
output = model(input_image) |
|
|
|
|
|
price = str(output) |
|
|
|
|
|
return [output, price] |
|
|
|
with gr.Blocks() as demo: |
|
|
|
gr.Markdown( |
|
""" |
|
<h1 align="center">AI Cafeteria Price Evaluator</h1> |
|
""") |
|
|
|
|
|
gr.Interface( |
|
fn=predict, |
|
inputs=gr.Image(type="pil"), |
|
outputs=[gr.Image(type="pil", label="Image Prediction"), |
|
gr.Textbox(type="text", label="Price Prediction")] |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|