Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
22 |
# logging.info(f"RAM memory % used: {psutil.virtual_memory()[2]}")
|
23 |
|
24 |
|
25 |
-
|
26 |
def load_model(model_name):
|
27 |
return (
|
28 |
AutoModelForSequenceClassification.from_pretrained(model_name),
|
@@ -104,35 +104,6 @@ def main():
|
|
104 |
else:
|
105 |
st.write('Goodbye')
|
106 |
print ("After test button")
|
107 |
-
if st.button("Interpret Text"):
|
108 |
-
#print_memory_usage()
|
109 |
-
st.text("Output")
|
110 |
-
with st.spinner("Interpreting your text (This may take some time)"):
|
111 |
-
print ("Interpreting text")
|
112 |
-
if explanation_class_choice != "predicted":
|
113 |
-
word_attributions = cls_explainer(
|
114 |
-
text,
|
115 |
-
class_name=explanation_class_choice,
|
116 |
-
embedding_type=emb_type_num,
|
117 |
-
internal_batch_size=2,
|
118 |
-
)
|
119 |
-
else:
|
120 |
-
word_attributions = cls_explainer(
|
121 |
-
text, embedding_type=emb_type_num, internal_batch_size=2
|
122 |
-
)
|
123 |
-
|
124 |
-
if word_attributions:
|
125 |
-
print ("Word Attributions")
|
126 |
-
word_attributions_expander = st.beta_expander(
|
127 |
-
"Click here for raw word attributions"
|
128 |
-
)
|
129 |
-
with word_attributions_expander:
|
130 |
-
st.json(word_attributions)
|
131 |
-
#components.v1.html(
|
132 |
-
# cls_explainer.visualize()._repr_html_(), scrolling=True, height=350
|
133 |
-
#)
|
134 |
-
print ("end of stuff")
|
135 |
-
|
136 |
|
137 |
if __name__ == "__main__":
|
138 |
main()
|
|
|
22 |
# logging.info(f"RAM memory % used: {psutil.virtual_memory()[2]}")
|
23 |
|
24 |
|
25 |
+
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=1)
|
26 |
def load_model(model_name):
|
27 |
return (
|
28 |
AutoModelForSequenceClassification.from_pretrained(model_name),
|
|
|
104 |
else:
|
105 |
st.write('Goodbye')
|
106 |
print ("After test button")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
if __name__ == "__main__":
|
109 |
main()
|