Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ def analyze_sentence(index, vis_type):
|
|
22 |
seq_len = attn_map_shape[1]
|
23 |
attn_maps = np.array(row['attention_maps']).reshape(*attn_map_shape).clip(0, 1)
|
24 |
fig = plt.figure(figsize=(0.5 + 0.5 * len(tokenized), 0.4 * len(tokenized)))
|
25 |
-
|
26 |
if vis_type == VisType.ALL:
|
27 |
plot_data = attn_maps.sum(0)
|
28 |
sns.heatmap(plot_data)
|
@@ -40,7 +40,8 @@ with demo:
|
|
40 |
sentence_dropdown = gr.Dropdown(label="Sentence",
|
41 |
choices=[x.split('</s> ')[1] for x in dataset['text']],
|
42 |
value=0, min_width=500, type='index')
|
43 |
-
vis_dropdown = gr.Dropdown(label="Visualization", choices=list(VisType),
|
|
|
44 |
btn = gr.Button("Run")
|
45 |
output = gr.Plot(label="Plot", container=True)
|
46 |
metrics = gr.Label("Metrics")
|
|
|
22 |
seq_len = attn_map_shape[1]
|
23 |
attn_maps = np.array(row['attention_maps']).reshape(*attn_map_shape).clip(0, 1)
|
24 |
fig = plt.figure(figsize=(0.5 + 0.5 * len(tokenized), 0.4 * len(tokenized)))
|
25 |
+
attn_maps = attn_maps[:, 1:, 1:]
|
26 |
if vis_type == VisType.ALL:
|
27 |
plot_data = attn_maps.sum(0)
|
28 |
sns.heatmap(plot_data)
|
|
|
40 |
sentence_dropdown = gr.Dropdown(label="Sentence",
|
41 |
choices=[x.split('</s> ')[1] for x in dataset['text']],
|
42 |
value=0, min_width=500, type='index')
|
43 |
+
vis_dropdown = gr.Dropdown(label="Visualization", choices=list(VisType),
|
44 |
+
min_width=80, value=0, type='index')
|
45 |
btn = gr.Button("Run")
|
46 |
output = gr.Plot(label="Plot", container=True)
|
47 |
metrics = gr.Label("Metrics")
|