Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ def analyze_sentence(index, vis_type):
|
|
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 |
else:
|
29 |
print(vis_type)
|
@@ -43,7 +43,7 @@ with demo:
|
|
43 |
sentence_dropdown = gr.Dropdown(label="Sentence",
|
44 |
choices=[x.split('</s> ')[1] for x in dataset['text']],
|
45 |
value=0, min_width=500, type='index')
|
46 |
-
vis_dropdown = gr.Dropdown(label="Visualization", choices=
|
47 |
min_width=150, value=VisType.ALL, type='value')
|
48 |
btn = gr.Button("Run", min_width=30)
|
49 |
output = gr.Plot(label="Plot", container=True)
|
|
|
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.value:
|
27 |
plot_data = attn_maps.sum(0)
|
28 |
else:
|
29 |
print(vis_type)
|
|
|
43 |
sentence_dropdown = gr.Dropdown(label="Sentence",
|
44 |
choices=[x.split('</s> ')[1] for x in dataset['text']],
|
45 |
value=0, min_width=500, type='index')
|
46 |
+
vis_dropdown = gr.Dropdown(label="Visualization", choices=[x.value for x in VisType],
|
47 |
min_width=150, value=VisType.ALL, type='value')
|
48 |
btn = gr.Button("Run", min_width=30)
|
49 |
output = gr.Plot(label="Plot", container=True)
|