Update app.py
Browse files
app.py
CHANGED
|
@@ -925,13 +925,13 @@ def apply_preset(name):
|
|
| 925 |
if values is None:
|
| 926 |
return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(open=True)
|
| 927 |
mood, excited, angry = values
|
| 928 |
-
return (gr.update(value=
|
| 929 |
gr.update(value=excited), gr.update(value=angry), gr.update())
|
| 930 |
|
| 931 |
|
| 932 |
-
def
|
| 933 |
-
"""Happy and Sad are
|
| 934 |
-
return gr.update(value=
|
| 935 |
|
| 936 |
|
| 937 |
UTM = "utm_source=huggingface&utm_medium=space&utm_campaign=drama_demo"
|
|
@@ -1712,7 +1712,7 @@ def generate(video, happy, sad, excited, angry, updates, preset_name, profile: g
|
|
| 1712 |
"""UI wrapper around run(): adds the download button and the remaining-generations line."""
|
| 1713 |
last = (None, IDLE)
|
| 1714 |
try:
|
| 1715 |
-
mood =
|
| 1716 |
for result, status in run(video, mood, excited, angry, updates, preset_name, profile):
|
| 1717 |
last = (result, status)
|
| 1718 |
done = result is not None
|
|
@@ -1766,11 +1766,11 @@ with gr.Blocks(title=PAGE_TITLE) as demo:
|
|
| 1766 |
d_mood, d_exc, d_ang = PRESETS[DEFAULT_PRESET]
|
| 1767 |
with gr.Accordion("Adjust expression intensity", open=False, elem_id="dr-adjust") as adjust:
|
| 1768 |
gr.HTML('<div class="dr-hint">Use the presets as a starting point, then adjust the controls. '
|
| 1769 |
-
'Happy and Sad
|
| 1770 |
-
happy = gr.Slider(
|
| 1771 |
-
info="
|
| 1772 |
-
sad = gr.Slider(
|
| 1773 |
-
info="
|
| 1774 |
excited = gr.Slider(0, 1, value=d_exc, step=0.05, label="Excitement",
|
| 1775 |
info="0 = no added excitement · 1 = strongest excitement")
|
| 1776 |
angry = gr.Slider(0, 1, value=d_ang, step=0.05, label="Anger",
|
|
@@ -1857,9 +1857,9 @@ with gr.Blocks(title=PAGE_TITLE) as demo:
|
|
| 1857 |
|
| 1858 |
preset.change(apply_preset, inputs=[preset], outputs=[happy, sad, excited, angry, adjust],
|
| 1859 |
api_visibility="private", show_progress="hidden")
|
| 1860 |
-
happy.input(
|
| 1861 |
show_progress="hidden", trigger_mode="always_last")
|
| 1862 |
-
sad.input(
|
| 1863 |
show_progress="hidden", trigger_mode="always_last")
|
| 1864 |
for slider in (happy, sad, excited, angry):
|
| 1865 |
slider.release(lambda: CUSTOM, outputs=[preset],
|
|
|
|
| 925 |
if values is None:
|
| 926 |
return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(open=True)
|
| 927 |
mood, excited, angry = values
|
| 928 |
+
return (gr.update(value=mood), gr.update(value=-mood),
|
| 929 |
gr.update(value=excited), gr.update(value=angry), gr.update())
|
| 930 |
|
| 931 |
|
| 932 |
+
def mirror(value):
|
| 933 |
+
"""Happy and Sad are one axis seen from both ends: the other slider is always the negative."""
|
| 934 |
+
return gr.update(value=round(-(value or 0), 2))
|
| 935 |
|
| 936 |
|
| 937 |
UTM = "utm_source=huggingface&utm_medium=space&utm_campaign=drama_demo"
|
|
|
|
| 1712 |
"""UI wrapper around run(): adds the download button and the remaining-generations line."""
|
| 1713 |
last = (None, IDLE)
|
| 1714 |
try:
|
| 1715 |
+
mood = happy or 0 # one axis: positive = happy, negative = sad (Sad slider is always -Happy)
|
| 1716 |
for result, status in run(video, mood, excited, angry, updates, preset_name, profile):
|
| 1717 |
last = (result, status)
|
| 1718 |
done = result is not None
|
|
|
|
| 1766 |
d_mood, d_exc, d_ang = PRESETS[DEFAULT_PRESET]
|
| 1767 |
with gr.Accordion("Adjust expression intensity", open=False, elem_id="dr-adjust") as adjust:
|
| 1768 |
gr.HTML('<div class="dr-hint">Use the presets as a starting point, then adjust the controls. '
|
| 1769 |
+
'Happy and Sad move in opposite directions: Sad 0.5 is the same as Happy −0.5.</div>')
|
| 1770 |
+
happy = gr.Slider(-1, 1, value=d_mood, step=0.05, label="Happy",
|
| 1771 |
+
info="+1 = biggest smile · 0 = neutral · −1 = sad")
|
| 1772 |
+
sad = gr.Slider(-1, 1, value=-d_mood, step=0.05, label="Sad",
|
| 1773 |
+
info="+1 = strongest sadness · 0 = neutral · −1 = happy")
|
| 1774 |
excited = gr.Slider(0, 1, value=d_exc, step=0.05, label="Excitement",
|
| 1775 |
info="0 = no added excitement · 1 = strongest excitement")
|
| 1776 |
angry = gr.Slider(0, 1, value=d_ang, step=0.05, label="Anger",
|
|
|
|
| 1857 |
|
| 1858 |
preset.change(apply_preset, inputs=[preset], outputs=[happy, sad, excited, angry, adjust],
|
| 1859 |
api_visibility="private", show_progress="hidden")
|
| 1860 |
+
happy.input(mirror, inputs=[happy], outputs=[sad], api_visibility="private",
|
| 1861 |
show_progress="hidden", trigger_mode="always_last")
|
| 1862 |
+
sad.input(mirror, inputs=[sad], outputs=[happy], api_visibility="private",
|
| 1863 |
show_progress="hidden", trigger_mode="always_last")
|
| 1864 |
for slider in (happy, sad, excited, angry):
|
| 1865 |
slider.release(lambda: CUSTOM, outputs=[preset],
|