import os import gradio as gr import warnings os.system("python setup.py build develop --user") os.system("pip install packaging==21.3") os.system("pip install git+https://github.com/openai/CLIP.git") warnings.filterwarnings("ignore") from detector import detect if __name__ == "__main__": detect_app = gr.Blocks() with detect_app: gr.Markdown("# Food Detection Demo") gr.Markdown("Please upload an food picture to see the detection results.") gr.Markdown("Note the model runs on CPU for demo, so it may take a while to run the model.") with gr.Row(): with gr.Column(): input_image = gr.Image(source='upload', type="numpy", label="Please upload a food picture.") run_button = gr.Button(value="Detect", variant="primary") with gr.Column(): output_image = gr.Image(label="Detection Results",show_download_button=True,) run_button.click(fn=detect, inputs=[ input_image], outputs=[output_image]) detect_app.launch(share=False, show_api=False, show_error=True)