File size: 2,370 Bytes
4a8e930
 
42fa7ec
ec42e29
42fa7ec
14e27af
 
4a8e930
 
 
efdf1b4
14e27af
c02063c
ec42e29
 
c02063c
14e27af
ec42e29
 
 
14e27af
ec42e29
14e27af
c02063c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14e27af
42fa7ec
6d19733
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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")