Update app.py
Browse files
app.py
CHANGED
|
@@ -62,60 +62,74 @@ def analyze_ec(expression):
|
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
-
# ----
|
| 66 |
with gr.Blocks(
|
| 67 |
-
theme=gr.themes.Soft(
|
| 68 |
-
primary_hue="indigo",
|
| 69 |
-
secondary_hue="blue",
|
| 70 |
-
neutral_hue="gray",
|
| 71 |
-
radius_size="md",
|
| 72 |
-
text_size="lg",
|
| 73 |
-
),
|
| 74 |
css="""
|
| 75 |
-
.gradio-container {background: linear-gradient(135deg, #eef2ff, #e0f2fe);}
|
| 76 |
.card {
|
| 77 |
-
background: rgba(255, 255, 255, 0.
|
| 78 |
-
padding:
|
| 79 |
border-radius: 12px;
|
| 80 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.
|
| 81 |
margin-bottom: 12px;
|
| 82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
"""
|
| 84 |
) as demo:
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
)
|
| 94 |
|
| 95 |
with gr.Row():
|
|
|
|
| 96 |
with gr.Column(scale=1):
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
| 104 |
with gr.Column(scale=2):
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
|
| 108 |
with gr.Row():
|
| 109 |
with gr.Column():
|
| 110 |
-
|
| 111 |
-
|
|
|
|
| 112 |
|
| 113 |
with gr.Column():
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
|
| 120 |
btn.click(analyze_ec, inputs=[expression],
|
| 121 |
outputs=[output_text, fig1, fig2, ec_summary])
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
+
# ---- UI(Gradio 3.x 兼容,美化版,不含 gr.Box) ----
|
| 66 |
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
css="""
|
|
|
|
| 68 |
.card {
|
| 69 |
+
background: rgba(255, 255, 255, 0.78);
|
| 70 |
+
padding: 15px;
|
| 71 |
border-radius: 12px;
|
| 72 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.06);
|
| 73 |
margin-bottom: 12px;
|
| 74 |
}
|
| 75 |
+
.title-area {
|
| 76 |
+
text-align:center;
|
| 77 |
+
margin-bottom: 20px;
|
| 78 |
+
}
|
| 79 |
+
.title-area h1 {
|
| 80 |
+
color:#334155;
|
| 81 |
+
margin-bottom:5px;
|
| 82 |
+
}
|
| 83 |
+
.title-area h3 {
|
| 84 |
+
color:#475569;
|
| 85 |
+
font-weight: normal;
|
| 86 |
+
}
|
| 87 |
+
body {
|
| 88 |
+
background: linear-gradient(135deg, #eef2ff, #e0f2fe);
|
| 89 |
+
}
|
| 90 |
"""
|
| 91 |
) as demo:
|
| 92 |
|
| 93 |
+
# 页面标题
|
| 94 |
+
gr.HTML("""
|
| 95 |
+
<div class='title-area'>
|
| 96 |
+
<h1>🧠 Entrenchment & Conventionalization Model</h1>
|
| 97 |
+
<h3>语言固着(E) × 社群常规化(C)的动态可视化平台</h3>
|
| 98 |
+
</div>
|
| 99 |
+
""")
|
|
|
|
| 100 |
|
| 101 |
with gr.Row():
|
| 102 |
+
# 输入区
|
| 103 |
with gr.Column(scale=1):
|
| 104 |
+
gr.HTML("<div class='card'>")
|
| 105 |
+
expression = gr.Textbox(
|
| 106 |
+
label="输入一个表达",
|
| 107 |
+
placeholder="如:kind of / 内卷 / OMG / 摆烂",
|
| 108 |
+
)
|
| 109 |
+
btn = gr.Button("生成 E&C 分析")
|
| 110 |
+
gr.HTML("</div>")
|
| 111 |
+
|
| 112 |
+
# 输出区
|
| 113 |
with gr.Column(scale=2):
|
| 114 |
+
|
| 115 |
+
gr.HTML("<div class='card'>")
|
| 116 |
+
output_text = gr.Markdown("等待输入表达…")
|
| 117 |
+
gr.HTML("</div>")
|
| 118 |
|
| 119 |
with gr.Row():
|
| 120 |
with gr.Column():
|
| 121 |
+
gr.HTML("<div class='card'>")
|
| 122 |
+
fig1 = gr.Plot()
|
| 123 |
+
gr.HTML("</div>")
|
| 124 |
|
| 125 |
with gr.Column():
|
| 126 |
+
gr.HTML("<div class='card'>")
|
| 127 |
+
fig2 = gr.Plot()
|
| 128 |
+
gr.HTML("</div>")
|
| 129 |
|
| 130 |
+
gr.HTML("<div class='card'>")
|
| 131 |
+
ec_summary = gr.Markdown("")
|
| 132 |
+
gr.HTML("</div>")
|
| 133 |
|
| 134 |
btn.click(analyze_ec, inputs=[expression],
|
| 135 |
outputs=[output_text, fig1, fig2, ec_summary])
|