TongkunGuan commited on
Commit
57a48ab
·
verified ·
1 Parent(s): 5d73243

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -195,10 +195,19 @@ with gr.Blocks(title="BPE Visualization Demo") as demo:
195
  outputs=[heatmap, bpe_display, index_slider]
196
  )
197
 
 
 
 
 
 
 
198
  index_slider.change(
199
- lambda x: (current_vis[x], format_bpe_display(current_bpe[x])),
200
- inputs=index_slider,
201
- outputs=[heatmap, bpe_display]
 
 
 
202
  )
203
 
204
  if __name__ == "__main__":
 
195
  outputs=[heatmap, bpe_display, index_slider]
196
  )
197
 
198
+ # index_slider.change(
199
+ # lambda x: (current_vis[x], format_bpe_display(current_bpe[x])) if 0<=x<len(current_vis else (None,"Invaild")
200
+ # inputs=index_slider,
201
+ # outputs=[heatmap, bpe_display]
202
+ # )
203
+
204
  index_slider.change(
205
+ lambda x: (
206
+ print(f"x: {x}, current_vis length: {len(current_vis)}, current_bpe length: {len(current_bpe)}"), # 打印调试信息
207
+ (current_vis[x], format_bpe_display(current_bpe[x])) if 0 <= x < len(current_vis) and 0 <= x < len(current_bpe) else (None, "索引超出范围")
208
+ ),
209
+ inputs=index_slider,
210
+ outputs=[heatmap, bpe_display]
211
  )
212
 
213
  if __name__ == "__main__":