jcg00v commited on
Commit
fc67519
1 Parent(s): 419454f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -2
app.py CHANGED
@@ -1,7 +1,9 @@
1
  import streamlit as st
2
  from PIL import Image
3
  from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer
4
-
 
 
5
 
6
  def clear_text():
7
  st.session_state.text = st.session_state.widget
@@ -113,6 +115,77 @@ def get_result_text_ca (list_entity, text):
113
  return " ".join(result_words)
114
 
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  if __name__ == "__main__":
117
 
118
  if "text" not in st.session_state:
@@ -153,4 +226,5 @@ if __name__ == "__main__":
153
  result_pipe = pipe_ca(text)
154
  out = get_result_text_ca(result_pipe, text)
155
 
156
- st.markdown(out, unsafe_allow_html=True)
 
 
1
  import streamlit as st
2
  from PIL import Image
3
  from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer
4
+ from htbuilder import HtmlElement, div, ul, li, br, hr, a, p, img, styles, classes, fonts
5
+ from htbuilder.units import percent, px
6
+ from htbuilder.funcs import rgba, rgb
7
 
8
  def clear_text():
9
  st.session_state.text = st.session_state.widget
 
115
  return " ".join(result_words)
116
 
117
 
118
+ def image(src_as_string, **style):
119
+ return img(src=src_as_string, style=styles(**style))
120
+
121
+
122
+ def link(link, text, **style):
123
+ return a(_href=link, _target="_blank", style=styles(**style))(text)
124
+
125
+ def layout(*args):
126
+
127
+ style = """
128
+ <style>
129
+ # MainMenu {visibility: hidden;}
130
+ footer {visibility: hidden;}
131
+ .stApp { bottom: 105px; }
132
+ </style>
133
+ """
134
+
135
+ style_div = styles(
136
+ position="fixed",
137
+ left=0,
138
+ bottom=0,
139
+ margin=px(0, 0, 0, 0),
140
+ width=percent(100),
141
+ color="black",
142
+ text_align="center",
143
+ height="auto",
144
+ opacity=1
145
+ )
146
+
147
+ style_hr = styles(
148
+ display="block",
149
+ margin=px(8, 8, "auto", "auto"),
150
+ border_style="inset",
151
+ border_width=px(2)
152
+ )
153
+
154
+ body = p()
155
+ foot = div(
156
+ style=style_div
157
+ )(
158
+ hr(
159
+ style=style_hr
160
+ ),
161
+ body
162
+ )
163
+
164
+ st.markdown(style, unsafe_allow_html=True)
165
+
166
+ for arg in args:
167
+ if isinstance(arg, str):
168
+ body(arg)
169
+
170
+ elif isinstance(arg, HtmlElement):
171
+ body(arg)
172
+
173
+ st.markdown(str(foot), unsafe_allow_html=True)
174
+
175
+
176
+ def footer():
177
+ myargs = [
178
+ "Made in ",
179
+ image('./vocali_logo.jpg'),
180
+ "with funding ",
181
+ image('./logo_funding.jpg'),
182
+ link("https://vocali.net/"),
183
+ br(),
184
+ "This work was funded by the Spanish Government, the Spanish Ministry of Economy and Digital Transformation through the Digital Transformation through the 'Recovery, Transformation and Resilience Plan' and also funded by the European Union NextGenerationEU/PRTR through the research project 2021/C005/0015007",
185
+ ]
186
+ layout(*myargs)
187
+
188
+
189
  if __name__ == "__main__":
190
 
191
  if "text" not in st.session_state:
 
226
  result_pipe = pipe_ca(text)
227
  out = get_result_text_ca(result_pipe, text)
228
 
229
+ st.markdown(out, unsafe_allow_html=True)
230
+ footer()