bright1 commited on
Commit
905f4de
1 Parent(s): 8505c1a

Made a pull request

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -3,7 +3,7 @@ import pandas as pd
3
  import numpy as np
4
  # from scipy.special import softmax
5
  # import os
6
- from utils import run_sentiment_analysis, preprocess
7
  from transformers import AutoTokenizer, AutoConfig,AutoModelForSequenceClassification
8
  import os
9
  import time
@@ -97,8 +97,14 @@ with my_expander:
97
  time.sleep(5)
98
  success_message.empty()
99
  interpret_button = col2.button(label='Interpret',type='secondary', use_container_width=True)
 
 
 
 
 
 
 
100
 
101
 
102
  # st.help()
103
  # create a date input to receive date
104
-
 
3
  import numpy as np
4
  # from scipy.special import softmax
5
  # import os
6
+ from utils import run_sentiment_analysis, preprocess, integrated_gradients
7
  from transformers import AutoTokenizer, AutoConfig,AutoModelForSequenceClassification
8
  import os
9
  import time
 
97
  time.sleep(5)
98
  success_message.empty()
99
  interpret_button = col2.button(label='Interpret',type='secondary', use_container_width=True)
100
+ if interpret_button:
101
+ ig = integrated_gradients(text, model)
102
+
103
+ ig = ig.sum(dim=-1).squeeze().detach().numpy()[0]
104
+ ig = (ig - ig.min()) / (ig.max() - ig.min())
105
+ # Display the Integrated Gradients as a bar chart
106
+ st.bar_chart(ig)
107
 
108
 
109
  # st.help()
110
  # create a date input to receive date