| | import gradio as gr |
| | import os |
| | os.environ["GRADIO_ANALYTICS_ENABLED"] = "False" |
| | os.environ["HF_HUB_DISABLE_TELEMETRY"] = "1" |
| | os.environ["SPACES_DISABLE_RELOAD"] = "1" |
| |
|
| | from utils.presets import EMOTION_PRESETS |
| | from utils.drama import apply_drama |
| | from utils.color_model import infer_color, apply_cinematic_blend, 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) |
| |
|
| | |
| | model_output = infer_color(cinematic) |
| |
|
| | |
| | blended = apply_cinematic_blend(model_output, drama) |
| |
|
| | |
| | color_block = render_color(blended) |
| |
|
| | scatter_fig = generate_scatter(raw, cinematic, emotion, drama) |
| |
|
| | return ( |
| | preset["text"], |
| | raw, |
| | cinematic, |
| | blended, |
| | 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, |
| | show_error=True, |
| | debug=False |
| | ) |
| |
|
| |
|