File size: 1,099 Bytes
82e8494
b02de22
82e8494
b02de22
 
82e8494
 
2a11855
82e8494
b02de22
82e8494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d9e3f9
82e8494
 
5d9e3f9
82e8494
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)