import os import pip import gradio as gr from PIL import Image from backend import Infer DEBUG = False infer = Infer(DEBUG) example_image_path = ["assets/example_1.jpg", "assets/example_2.jpg", "assets/example_3.jpg"] with gr.Blocks(analytics_enabled=False, title="DeepNAPSI") as demo: outputs = [] 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(): with gr.Column(): with gr.Row(): image_input = gr.Image() with gr.Row(): image_button = gr.Button("Predict NAPSI") with gr.Row(): with gr.Column(): outputs.append(gr.Image(label="Thumb")) outputs.append(gr.Number(label="DeepNAPSI Thumb", precision=0)) with gr.Column(): outputs.append(gr.Image(label="Index")) outputs.append(gr.Number(label="DeepNAPSI Index", precision=0)) with gr.Column(): outputs.append(gr.Image(label="Middle")) outputs.append(gr.Number(label="DeepNAPSI Middle", precision=0)) with gr.Column(): outputs.append(gr.Image(label="Ring")) outputs.append(gr.Number(label="DeepNAPSI Ring", precision=0)) with gr.Column(): outputs.append(gr.Image(label="Pinky")) outputs.append(gr.Number(label="DeepNAPSI Pinky", precision=0)) outputs.append(gr.Number(label="DeepNAPSI Sum", precision=0)) example_images = gr.Examples(example_image_path, image_input, outputs, fn=infer.predict, cache_examples=True) image_button.click(infer.predict, inputs=image_input, outputs=outputs) demo.launch(share=True, enable_queue=True, favicon_path="assets/favicon-32x32.png")