Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import func as fu | |
| def clear_all(image1, image2, output_image, output_json): | |
| return None, None, None, None | |
| with gr.Blocks() as demo: | |
| gr.Markdown("Choose or upload a dog image and press cpmpare!! the system will retutn the 2 detected faces with the recognition result") | |
| with gr.Row(): | |
| with gr.Column(): | |
| image1_input = gr.Image(type="pil", label="Image 1") | |
| examples_image1 = gr.Examples(examples=["./images/dob1.jpg", "./images/p1.jpg", "./images/dob3.jpg", "./images/d1.jpg"], inputs=image1_input) | |
| with gr.Column(): | |
| image2_input = gr.Image(type="pil", label="Image 2") | |
| examples_image2 = gr.Examples(examples=["./images/dob2.jpg", "./images/p2.jpg", "./images/dob4.jpg", "./images/d2.jpg"], inputs=image2_input) | |
| threshold_input = gr.Slider(minimum=0.0, maximum=1.0, value=0.55, step=0.05, label="Threshold") | |
| # detect_input = gr.Radio(["Yes", "No"], label="Detect dog face", info="Detect dog face on compare!"), | |
| compare_button = gr.Button("Compare") | |
| clear_button = gr.Button("Clear") | |
| output_image = gr.Image(type="pil", label="Stacked Image", interactive=False) | |
| output_json = gr.JSON(label="Result") | |
| compare_button.click( | |
| fn=fu.compare_faces, | |
| inputs=[image1_input, image2_input, threshold_input], | |
| outputs=[output_image, output_json] | |
| ) | |
| clear_button.click( | |
| fn=clear_all, | |
| inputs=[image1_input, image2_input, output_image, output_json], | |
| outputs=[image1_input, image2_input,output_image, output_json] | |
| ) | |
| demo.launch() |