dar-tau commited on
Commit
9ddf875
1 Parent(s): 7e273f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -5,9 +5,12 @@ import seaborn as sns
5
 
6
  dataset = load_dataset('dar-tau/grammar-attention-maps-opt-350m')['train']
7
 
8
- def choose_sentence(name):
9
- return "Hello " + name + "!!"
 
 
10
 
11
 
12
- iface = gr.Interface(fn=choose_sentence, inputs=[gr.Dropdown(choices=dataset['text'])], outputs="text")
 
13
  iface.launch()
 
5
 
6
  dataset = load_dataset('dar-tau/grammar-attention-maps-opt-350m')['train']
7
 
8
+ def analyze_sentence(index):
9
+ row = dataset[index]
10
+ attn_maps = np.array(row['attention_maps']).reshape(*row['attention_maps_shape'])
11
+ return row['text'], sns.heatmap(attn_maps.sum(1).sum(0))
12
 
13
 
14
+ iface = gr.Interface(fn=analyze_sentence, inputs=[gr.Dropdown(choices=dataset['text'], type='index')],
15
+ outputs=[gr.Label(), gr.Plot(label="Plot")])
16
  iface.launch()