emotion added
Browse files- app_single.py +9 -9
app_single.py
CHANGED
|
@@ -399,7 +399,7 @@ LABEL_FONT = "'Inter', system-ui, sans-serif"
|
|
| 399 |
MONO_FONT = "'JetBrains Mono', 'SFMono-Regular', Consolas, monospace"
|
| 400 |
|
| 401 |
def _stage_open(spotlight_color: str, breathe_speed: float = 4.0) -> str:
|
| 402 |
-
"""Opening <div> + shared <style> for the
|
| 403 |
return f"""<div class="stage" style="--spot:{spotlight_color};">
|
| 404 |
<style>
|
| 405 |
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
|
|
@@ -689,7 +689,7 @@ def cat_html(mood: str, dance: dict) -> str:
|
|
| 689 |
<div class="stage-cue">
|
| 690 |
<span class="dot"></span>
|
| 691 |
<span class="mood-name">{p['label']}</span>
|
| 692 |
-
<span> Β· live
|
| 693 |
</div>
|
| 694 |
|
| 695 |
<button class="music-toggle" id="music_{stage_id}" title="Play the generated tune" aria-label="Toggle music">
|
|
@@ -819,7 +819,7 @@ def placeholder_html():
|
|
| 819 |
<div style="text-align:center; z-index:2; color:#6B7280; font-family:{STAGE_FONT};">
|
| 820 |
<div style="font-size:2.4rem; margin-bottom:14px; opacity:.6;">π±</div>
|
| 821 |
<div style="font-size:1.05rem; font-weight:700; letter-spacing:.01em; color:#111827; margin-bottom:8px;">
|
| 822 |
-
No
|
| 823 |
</div>
|
| 824 |
<div style="font-size:.82rem; color:#6B7280; max-width:280px; margin:0 auto; line-height:1.7; font-family:{LABEL_FONT};">
|
| 825 |
Upload an image β the model reads its mood and the cat performs it,
|
|
@@ -830,7 +830,7 @@ def placeholder_html():
|
|
| 830 |
def loading_html(local: bool = False) -> str:
|
| 831 |
title = "Running locallyβ¦" if local else "Analyzing imageβ¦"
|
| 832 |
caption = ("on-device inference β first run may take a while"
|
| 833 |
-
if local else "choreographing the
|
| 834 |
return _stage_open("#FFD21E", 2.0) + f"""
|
| 835 |
<div style="text-align:center; z-index:2; color:#6B7280; font-family:{STAGE_FONT};">
|
| 836 |
<div class="loading-spinner" style="
|
|
@@ -1061,7 +1061,7 @@ with gr.Blocks(title="An Adventure in Thousand Token Wood Β· MiniCPM-V 4.6", the
|
|
| 1061 |
|
| 1062 |
with gr.Tabs():
|
| 1063 |
# ββ Tab 1: Image pipeline βββββββββββββββββββββββββββββββββββββββββββββ
|
| 1064 |
-
with gr.TabItem("π· Image β
|
| 1065 |
with gr.Row():
|
| 1066 |
with gr.Column(scale=1):
|
| 1067 |
image_input = gr.Image(type="pil", label="Upload image", height=240)
|
|
@@ -1097,7 +1097,7 @@ with gr.Blocks(title="An Adventure in Thousand Token Wood Β· MiniCPM-V 4.6", the
|
|
| 1097 |
)
|
| 1098 |
refresh_local_btn = gr.Button("Refresh status", size="sm")
|
| 1099 |
|
| 1100 |
-
img_btn = gr.Button("Start
|
| 1101 |
gr.Examples(examples=PROMPT_EXAMPLES, inputs=[prompt_input], label="Prompt ideas")
|
| 1102 |
|
| 1103 |
with gr.Column(scale=1):
|
|
@@ -1121,8 +1121,8 @@ with gr.Blocks(title="An Adventure in Thousand Token Wood Β· MiniCPM-V 4.6", the
|
|
| 1121 |
refresh_local_btn.click(fn=local_status_md, outputs=[local_status])
|
| 1122 |
|
| 1123 |
# ββ Tab 2: Text-only (keyword dance, no API) ββββββββββββββββββββββββββ
|
| 1124 |
-
with gr.TabItem("βοΈ Text β
|
| 1125 |
-
gr.Markdown("Type mood words for an instant
|
| 1126 |
with gr.Row():
|
| 1127 |
with gr.Column(scale=1):
|
| 1128 |
txt_input = gr.Textbox(
|
|
@@ -1130,7 +1130,7 @@ with gr.Blocks(title="An Adventure in Thousand Token Wood Β· MiniCPM-V 4.6", the
|
|
| 1130 |
placeholder='"happy party" Β· "sad rain" Β· "energetic dance"',
|
| 1131 |
lines=3,
|
| 1132 |
)
|
| 1133 |
-
txt_btn = gr.Button("Start
|
| 1134 |
gr.Examples(
|
| 1135 |
examples=[["happy celebrate joy"],["sad lonely rain"],
|
| 1136 |
["energetic dance excited"],["calm peaceful"],
|
|
|
|
| 399 |
MONO_FONT = "'JetBrains Mono', 'SFMono-Regular', Consolas, monospace"
|
| 400 |
|
| 401 |
def _stage_open(spotlight_color: str, breathe_speed: float = 4.0) -> str:
|
| 402 |
+
"""Opening <div> + shared <style> for the emotion card, HF light style."""
|
| 403 |
return f"""<div class="stage" style="--spot:{spotlight_color};">
|
| 404 |
<style>
|
| 405 |
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
|
|
|
|
| 689 |
<div class="stage-cue">
|
| 690 |
<span class="dot"></span>
|
| 691 |
<span class="mood-name">{p['label']}</span>
|
| 692 |
+
<span> Β· live emotion</span>
|
| 693 |
</div>
|
| 694 |
|
| 695 |
<button class="music-toggle" id="music_{stage_id}" title="Play the generated tune" aria-label="Toggle music">
|
|
|
|
| 819 |
<div style="text-align:center; z-index:2; color:#6B7280; font-family:{STAGE_FONT};">
|
| 820 |
<div style="font-size:2.4rem; margin-bottom:14px; opacity:.6;">π±</div>
|
| 821 |
<div style="font-size:1.05rem; font-weight:700; letter-spacing:.01em; color:#111827; margin-bottom:8px;">
|
| 822 |
+
No emotion yet
|
| 823 |
</div>
|
| 824 |
<div style="font-size:.82rem; color:#6B7280; max-width:280px; margin:0 auto; line-height:1.7; font-family:{LABEL_FONT};">
|
| 825 |
Upload an image β the model reads its mood and the cat performs it,
|
|
|
|
| 830 |
def loading_html(local: bool = False) -> str:
|
| 831 |
title = "Running locallyβ¦" if local else "Analyzing imageβ¦"
|
| 832 |
caption = ("on-device inference β first run may take a while"
|
| 833 |
+
if local else "choreographing the emotion")
|
| 834 |
return _stage_open("#FFD21E", 2.0) + f"""
|
| 835 |
<div style="text-align:center; z-index:2; color:#6B7280; font-family:{STAGE_FONT};">
|
| 836 |
<div class="loading-spinner" style="
|
|
|
|
| 1061 |
|
| 1062 |
with gr.Tabs():
|
| 1063 |
# ββ Tab 1: Image pipeline βββββββββββββββββββββββββββββββββββββββββββββ
|
| 1064 |
+
with gr.TabItem("π· Image β emotion"):
|
| 1065 |
with gr.Row():
|
| 1066 |
with gr.Column(scale=1):
|
| 1067 |
image_input = gr.Image(type="pil", label="Upload image", height=240)
|
|
|
|
| 1097 |
)
|
| 1098 |
refresh_local_btn = gr.Button("Refresh status", size="sm")
|
| 1099 |
|
| 1100 |
+
img_btn = gr.Button("Start emotion", variant="primary", elem_id="submit-img")
|
| 1101 |
gr.Examples(examples=PROMPT_EXAMPLES, inputs=[prompt_input], label="Prompt ideas")
|
| 1102 |
|
| 1103 |
with gr.Column(scale=1):
|
|
|
|
| 1121 |
refresh_local_btn.click(fn=local_status_md, outputs=[local_status])
|
| 1122 |
|
| 1123 |
# ββ Tab 2: Text-only (keyword dance, no API) ββββββββββββββββββββββββββ
|
| 1124 |
+
with gr.TabItem("βοΈ Text β emotion"):
|
| 1125 |
+
gr.Markdown("Type mood words for an instant emotion β no API key needed.")
|
| 1126 |
with gr.Row():
|
| 1127 |
with gr.Column(scale=1):
|
| 1128 |
txt_input = gr.Textbox(
|
|
|
|
| 1130 |
placeholder='"happy party" Β· "sad rain" Β· "energetic dance"',
|
| 1131 |
lines=3,
|
| 1132 |
)
|
| 1133 |
+
txt_btn = gr.Button("Start emotion", variant="primary", elem_id="submit-txt")
|
| 1134 |
gr.Examples(
|
| 1135 |
examples=[["happy celebrate joy"],["sad lonely rain"],
|
| 1136 |
["energetic dance excited"],["calm peaceful"],
|