| 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() |
|
|
|
|