File size: 1,511 Bytes
5637ddb
 
 
 
 
 
 
 
 
 
 
 
 
9919c9b
5637ddb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
# import sys
# import tensorflow as tf
# import gradio as gr

# print("Python:", sys.version)
# print("TF:", tf.__version__)

# def hello():
#     return "Gradio + TensorFlow OK"

# gr.Interface(fn=hello, inputs=None, outputs="text").launch()

import os
os.environ["TF_USE_LEGACY_KERAS"] = "1"

import gradio as gr
from common.gradio.common import full_analysis

with gr.Blocks(theme=gr.themes.Soft()) as demo:

    gr.Markdown("# Handwriting → Big Five Personality Prediction")
    gr.Markdown("Upload any image of handwriting → model will try to predict personality trait")

    with gr.Row():
        with gr.Column():
            image_input = gr.Image(
                type="pil",
                label="Upload handwriting image",
                sources=["upload"],
                height=380
            )

        with gr.Column():
            gr.Markdown("### Prediction")
            prediction_output = gr.Markdown(value="Upload image and click Analyze...")

            gr.Markdown("### Personality Description")
            summary_output = gr.Markdown(value="Description will appear here...")

    btn = gr.Button("Analyze", variant="primary")
    btn.click(
        fn=full_analysis,
        inputs=image_input,
        outputs=[prediction_output, summary_output]
    )

    image_input.change(
        fn=full_analysis,
        inputs=image_input,
        outputs=[prediction_output, summary_output]
    )


if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)