dar-tau commited on
Commit
c79dcc0
·
verified ·
1 Parent(s): b941cea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -17,7 +17,7 @@ def analyze_sentence(index):
17
  attn_map_shape = row['attention_maps_shape'][1:]
18
  seq_len = attn_map_shape[1]
19
  attn_maps = np.array(row['attention_maps']).reshape(*attn_map_shape).clip(0, 1)
20
- fig = plt.figure(figsize=(7, 6))
21
  sns.heatmap(attn_maps.sum(0)[1:, 1:])
22
  plt.xticks(np.arange(seq_len - 1) + 0.5, tokenized[1:], rotation=90);
23
  plt.yticks(np.arange(seq_len - 1) + 0.5, tokenized[1:], rotation=0);
@@ -29,9 +29,9 @@ def analyze_sentence(index):
29
  demo = gr.Blocks()
30
  with demo:
31
  with gr.Row():
32
- dropdown = gr.Dropdown(choices=dataset['text'], value=0, min_width=700, type='index')
33
  btn = gr.Button("Run")
34
- output = gr.Plot(label="Plot")
35
  btn.click(analyze_sentence, [dropdown], [output])
36
 
37
 
 
17
  attn_map_shape = row['attention_maps_shape'][1:]
18
  seq_len = attn_map_shape[1]
19
  attn_maps = np.array(row['attention_maps']).reshape(*attn_map_shape).clip(0, 1)
20
+ fig = plt.figure(figsize=(6.5, 6))
21
  sns.heatmap(attn_maps.sum(0)[1:, 1:])
22
  plt.xticks(np.arange(seq_len - 1) + 0.5, tokenized[1:], rotation=90);
23
  plt.yticks(np.arange(seq_len - 1) + 0.5, tokenized[1:], rotation=0);
 
29
  demo = gr.Blocks()
30
  with demo:
31
  with gr.Row():
32
+ dropdown = gr.Dropdown(choices=dataset['text'], value=0, min_width=750, type='index')
33
  btn = gr.Button("Run")
34
+ output = gr.Plot(label="Plot", container=False)
35
  btn.click(analyze_sentence, [dropdown], [output])
36
 
37