Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -122,8 +122,10 @@ 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 |
-
|
126 |
-
|
|
|
|
|
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:
|
@@ -207,12 +209,10 @@ with gr.Blocks(title="BPE Visualization Demo") as demo:
|
|
207 |
# inputs=index_slider,
|
208 |
# outputs=[heatmap, bpe_display]
|
209 |
# )
|
210 |
-
|
211 |
-
bpe = gr.State(value=current_bpe) # 初始化状态
|
212 |
-
|
213 |
index_slider.change(
|
214 |
update_slider_index,
|
215 |
-
inputs=
|
216 |
outputs=[heatmap, bpe_display]
|
217 |
)
|
218 |
|
|
|
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 |
+
@spaces.GPU
|
126 |
+
def update_slider_index(x):
|
127 |
+
global current_vis, current_bpe, current_index
|
128 |
+
print(f"x: {x}, current_vis length: {len(current_vis)}, current_bpe length: {len(current_bpe)}")
|
129 |
if 0 <= x < len(current_vis) and 0 <= x < len(current_bpe):
|
130 |
return current_vis[x], format_bpe_display(current_bpe[x])
|
131 |
else:
|
|
|
209 |
# inputs=index_slider,
|
210 |
# outputs=[heatmap, bpe_display]
|
211 |
# )
|
212 |
+
|
|
|
|
|
213 |
index_slider.change(
|
214 |
update_slider_index,
|
215 |
+
inputs=index_slider,
|
216 |
outputs=[heatmap, bpe_display]
|
217 |
)
|
218 |
|