Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -122,6 +122,13 @@ def format_bpe_display(bpe):
|
|
122 |
# 使用HTML标签来设置字体大小、颜色,加粗,并居中
|
123 |
return f"<div style='text-align:center; font-size:20px;'><strong>Current BPE: <span style='color:red;'>{bpe}</span></strong></div>"
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
# Gradio界面
|
126 |
with gr.Blocks(title="BPE Visualization Demo") as demo:
|
127 |
gr.Markdown("## BPE Visualization Demo - TokenFD基座模型能力可视化")
|
@@ -202,13 +209,10 @@ with gr.Blocks(title="BPE Visualization Demo") as demo:
|
|
202 |
# )
|
203 |
|
204 |
index_slider.change(
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
inputs=index_slider,
|
210 |
-
outputs=[heatmap, bpe_display]
|
211 |
-
)
|
212 |
|
213 |
if __name__ == "__main__":
|
214 |
demo.launch()
|
|
|
122 |
# 使用HTML标签来设置字体大小、颜色,加粗,并居中
|
123 |
return f"<div style='text-align:center; font-size:20px;'><strong>Current BPE: <span style='color:red;'>{bpe}</span></strong></div>"
|
124 |
|
125 |
+
def update_slider_index(x):
|
126 |
+
print(f"x: {x}, current_vis length: {len(current_vis)}, current_bpe length: {len(current_bpe)}")
|
127 |
+
if 0 <= x < len(current_vis) and 0 <= x < len(current_bpe):
|
128 |
+
return current_vis[x], format_bpe_display(current_bpe[x])
|
129 |
+
else:
|
130 |
+
return None, "索引超出范围"
|
131 |
+
|
132 |
# Gradio界面
|
133 |
with gr.Blocks(title="BPE Visualization Demo") as demo:
|
134 |
gr.Markdown("## BPE Visualization Demo - TokenFD基座模型能力可视化")
|
|
|
209 |
# )
|
210 |
|
211 |
index_slider.change(
|
212 |
+
update_slider_index,
|
213 |
+
inputs=index_slider,
|
214 |
+
outputs=[heatmap, bpe_display]
|
215 |
+
)
|
|
|
|
|
|
|
216 |
|
217 |
if __name__ == "__main__":
|
218 |
demo.launch()
|