akdeniz27 commited on
Commit
d84f151
1 Parent(s): 889b6ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -53,10 +53,17 @@ elif input_method == "Write or Paste New Text":
53
  st.subheader("Text to Run")
54
  input_text = st.text_area('Write or Paste Text Below', value="", height=128, max_chars=None, key=2)
55
 
 
56
  def setModel(model_checkpoint, aggregation):
57
  model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)
58
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
59
  return pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy=aggregation)
 
 
 
 
 
 
60
 
61
  Run_Button = st.button("Run", key=None)
62
  if Run_Button == True:
@@ -76,11 +83,6 @@ if Run_Button == True:
76
  st.subheader("Recognized Entities")
77
  st.dataframe(df_final)
78
 
79
- def get_html(html: str):
80
- WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem">{}</div>"""
81
- html = html.replace("\n", " ")
82
- return WRAPPER.format(html)
83
-
84
  st.subheader("Spacy Style Display")
85
 
86
  spacy_display = {}
 
53
  st.subheader("Text to Run")
54
  input_text = st.text_area('Write or Paste Text Below', value="", height=128, max_chars=None, key=2)
55
 
56
+ @st.cache
57
  def setModel(model_checkpoint, aggregation):
58
  model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)
59
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
60
  return pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy=aggregation)
61
+
62
+ @st.cache
63
+ def get_html(html: str):
64
+ WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem">{}</div>"""
65
+ html = html.replace("\n", " ")
66
+ return WRAPPER.format(html)
67
 
68
  Run_Button = st.button("Run", key=None)
69
  if Run_Button == True:
 
83
  st.subheader("Recognized Entities")
84
  st.dataframe(df_final)
85
 
 
 
 
 
 
86
  st.subheader("Spacy Style Display")
87
 
88
  spacy_display = {}