import gradio as gr from PIL import Image from backend import Infer DEBUG = True infer = Infer(DEBUG) with gr.Blocks(analytics_enabled=False, title="DeepNAPSI") as demo: with gr.Column(): gr.Markdown("## Welcome to the DeepNAPSI application!") gr.Markdown("Upload an image of the one hand and click **Predict NAPSI** to see the output.\n" \ "> Note: Make sure there are no identifying information present in the image. The prediction can take up to 1 minute.") with gr.Column(): with gr.Row(): image_input = gr.Image() example_images = gr.Examples(["assets/example_1.jpg", "assets/example_2.jpg", "assets/example_3.jpg"], image_input) with gr.Row(): image_button = gr.Button("Predict NAPSI") outputs = [] with gr.Row(): outputs.append(gr.Number(label="DeepNAPSI Sum")) with gr.Column(): outputs.append(gr.Image()) outputs.append(gr.Number(label="DeepNAPSI Thumb")) with gr.Column(): outputs.append(gr.Image()) outputs.append(gr.Number(label="DeepNAPSI Index")) with gr.Column(): outputs.append(gr.Image()) outputs.append(gr.Number(label="DeepNAPSI Middle")) with gr.Column(): outputs.append(gr.Image()) outputs.append(gr.Number(label="DeepNAPSI Ring")) with gr.Column(): outputs.append(gr.Image()) outputs.append(gr.Number(label="DeepNAPSI Pinky")) image_button.click(infer.predict, inputs=image_input, outputs=outputs) demo.launch(share=True)