File size: 2,313 Bytes
9191c48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36b4082
 
9191c48
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import gradio as gr

from utils.presets import EMOTION_PRESETS
from utils.drama import apply_drama
from utils.color_model import infer_color, scale_rgb, render_color
from utils.visualization import generate_scatter


def process_emotion(emotion, drama):
    preset = EMOTION_PRESETS[emotion]

    raw = preset["raw"]
    target = preset["target"]

    cinematic = apply_drama(raw, target, drama)

    rgb = infer_color(cinematic)
    scaled = scale_rgb(rgb)
    color_block = render_color(scaled)

    scatter_fig = generate_scatter(raw, cinematic, emotion, drama)

    return (
        preset["text"],
        raw,
        cinematic,
        scaled,
        color_block,
        scatter_fig
    )


with gr.Blocks(title="VIBE-Eyes 👁️") as demo:

    gr.Markdown("# VIBE-Eyes 👁️")
    gr.Markdown("**Emotion becomes cinema.**")

    with gr.Row():

        with gr.Column(scale=1):

            emotion = gr.Radio(
                choices=list(EMOTION_PRESETS.keys()),
                label="Select Emotion",
                value="Anger (Red)"
            )

            drama = gr.Slider(
                minimum=0,
                maximum=1.5,
                value=0,
                step=0.05,
                label="Drama (Cinematic Amplification)"
            )

        with gr.Column(scale=2):

            text_output = gr.Textbox(label="Preset Text")

            with gr.Row():
                raw_output = gr.JSON(label="Raw VAD+CC")
                cine_output = gr.JSON(label="Cinematic VAD+CC")

            rgb_output = gr.JSON(label="RGB + E + I")
            color_display = gr.HTML(label="Rendered Color")

            scatter_output = gr.Plot(label="Valence–Arousal Space")

    emotion.change(
        fn=process_emotion,
        inputs=[emotion, drama],
        outputs=[
            text_output,
            raw_output,
            cine_output,
            rgb_output,
            color_display,
            scatter_output
        ]
    )

    drama.change(
        fn=process_emotion,
        inputs=[emotion, drama],
        outputs=[
            text_output,
            raw_output,
            cine_output,
            rgb_output,
            color_display,
            scatter_output
        ]
    )

demo.launch(server_name="0.0.0.0", server_port=7860, ssr_mode=False)