bowphs commited on
Commit
54234b7
1 Parent(s): 8d8650b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -46
app.py CHANGED
@@ -20,7 +20,6 @@ from models import (
20
  LabelRobertaForTokenClassification,
21
  )
22
 
23
-
24
  DEFAULT_TEXT = "τίω δέ μιν ἐν καρὸς αἴσῃ."
25
  BUTTON_CSS = "float: right; --tw-border-opacity: 1; border-color: rgb(229 231 235 / var(--tw-border-opacity)); --tw-gradient-from: rgb(243 244 246 / 0.7); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(243 244 246 / 0)); --tw-gradient-to: rgb(229 231 235 / 0.8); --tw-text-opacity: 1; color: rgb(55 65 81 / var(--tw-text-opacity)); border-width: 1px; --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); background-image: linear-gradient(to bottom right, var(--tw-gradient-stops)); display: inline-flex; flex: 1 1 0%; align-items: center; justify-content: center; --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -webkit-appearance: button; border-radius: 0.5rem; padding-top: 0.5rem; padding-bottom: 0.5rem; padding-left: 1rem; padding-right: 1rem; font-size: 1rem; line-height: 1.5rem; font-weight: 600;"
26
  DEFAULT_COLOR = "white"
@@ -34,6 +33,7 @@ MODEL_PATHS = {
34
  MODEL_MAX_LENGTH = 512
35
 
36
  AUTH_TOKEN = os.environ.get("TOKEN") or True
 
37
  # PoS
38
  pos_tokenizer = AutoTokenizer.from_pretrained(
39
  MODEL_PATHS["POS"], model_max_length=MODEL_MAX_LENGTH, use_auth_token=AUTH_TOKEN, revision="8bd84df2bcaee089307fd604c80139a34ac71f12",
@@ -207,31 +207,26 @@ def parse(
207
 
208
  return svg, download_link
209
 
210
-
211
  def setup_parser_ui():
212
- demo = gr.Blocks(css="scrollbar.css")
213
- with demo:
214
- with gr.Box():
 
 
 
 
 
 
215
  with gr.Row():
216
- with gr.Column():
217
- gr.Markdown("# Athena's Lens")
218
- gr.Markdown(
219
- "### From Ἀlkaios to Ὠrigen: A Modern Lens on Timeless Texts"
220
  )
221
- with gr.Box():
222
- with gr.Column():
223
- gr.Markdown(" ## Enter some text")
224
- with gr.Row():
225
- with gr.Column(scale=0.5):
226
- text_input = gr.Textbox(
227
- value=DEFAULT_TEXT, interactive=True, label="Input Text"
228
- )
229
- with gr.Row():
230
- with gr.Column(scale=0.25):
231
- button = gr.Button("Update", variant="primary").style(
232
- full_width=False
233
- )
234
- with gr.Box():
235
  with gr.Column():
236
  with gr.Row():
237
  with gr.Column():
@@ -247,6 +242,7 @@ def setup_parser_ui():
247
  bg = gr.Textbox(label="Background Color", value=DEFAULT_COLOR)
248
  with gr.Column():
249
  text = gr.Textbox(label="Text Color", value="black")
 
250
  with gr.Row():
251
  dep_output = gr.HTML(
252
  value=parse(
@@ -261,29 +257,26 @@ def setup_parser_ui():
261
  )[0]
262
  )
263
  with gr.Row():
264
- with gr.Column(scale=0.25):
265
- dep_button = gr.Button(
266
- "Update Parser", variant="primary"
267
- ).style(full_width=False)
268
  with gr.Column():
269
  dep_download_button = gr.HTML(
270
  value=download_svg(dep_output.value)
271
  )
272
-
273
- with gr.Box():
274
- with gr.Column():
275
- with gr.Row():
276
- with gr.Column():
277
- gr.Markdown("## Contact")
278
- gr.Markdown(
279
- "If you have any questions, suggestions, comments, or problems, feel free to [reach out](mailto:[email protected])."
280
- )
281
- gr.Markdown("## Citation")
282
- gr.Markdown(
283
- "This space uses models from [this](https://aclanthology.org/2023.acl-long.846.pdf) paper."
284
- )
285
- gr.Markdown(
286
- """```bibtex
287
  @incollection{riemenschneider-frank-2023-exploring,
288
  title = "Exploring Large Language Models for Classical Philology",
289
  author = "Riemenschneider, Frederick and Frank, Anette",
@@ -297,9 +290,8 @@ def setup_parser_ui():
297
  pages = "15181--15199",
298
  }
299
  ```
300
- """
301
- )
302
-
303
  button.click(
304
  execute_parse,
305
  inputs=[
@@ -329,8 +321,8 @@ def setup_parser_ui():
329
  ],
330
  outputs=[dep_output, dep_download_button],
331
  )
 
332
 
333
- demo.launch()
334
 
335
 
336
  def main():
 
20
  LabelRobertaForTokenClassification,
21
  )
22
 
 
23
  DEFAULT_TEXT = "τίω δέ μιν ἐν καρὸς αἴσῃ."
24
  BUTTON_CSS = "float: right; --tw-border-opacity: 1; border-color: rgb(229 231 235 / var(--tw-border-opacity)); --tw-gradient-from: rgb(243 244 246 / 0.7); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(243 244 246 / 0)); --tw-gradient-to: rgb(229 231 235 / 0.8); --tw-text-opacity: 1; color: rgb(55 65 81 / var(--tw-text-opacity)); border-width: 1px; --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); background-image: linear-gradient(to bottom right, var(--tw-gradient-stops)); display: inline-flex; flex: 1 1 0%; align-items: center; justify-content: center; --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -webkit-appearance: button; border-radius: 0.5rem; padding-top: 0.5rem; padding-bottom: 0.5rem; padding-left: 1rem; padding-right: 1rem; font-size: 1rem; line-height: 1.5rem; font-weight: 600;"
25
  DEFAULT_COLOR = "white"
 
33
  MODEL_MAX_LENGTH = 512
34
 
35
  AUTH_TOKEN = os.environ.get("TOKEN") or True
36
+
37
  # PoS
38
  pos_tokenizer = AutoTokenizer.from_pretrained(
39
  MODEL_PATHS["POS"], model_max_length=MODEL_MAX_LENGTH, use_auth_token=AUTH_TOKEN, revision="8bd84df2bcaee089307fd604c80139a34ac71f12",
 
207
 
208
  return svg, download_link
209
 
 
210
  def setup_parser_ui():
211
+ theme = gr.themes.Monochrome()
212
+ with gr.Blocks(theme=theme) as demo:
213
+ with gr.Group():
214
+ gr.Markdown("# Athena's Lens")
215
+ gr.Markdown(
216
+ "### From Ἀlkaios to Ὠrigen: A Modern Lens on Timeless Texts"
217
+ )
218
+ with gr.Group():
219
+ gr.Markdown("## Enter some text")
220
  with gr.Row():
221
+ with gr.Column(scale=0.5):
222
+ text_input = gr.Textbox(
223
+ value=DEFAULT_TEXT, interactive=True, label="Input Text"
 
224
  )
225
+ with gr.Row():
226
+ with gr.Column(scale=0.25):
227
+ button = gr.Button("Update", variant="primary")
228
+
229
+ with gr.Group():
 
 
 
 
 
 
 
 
 
230
  with gr.Column():
231
  with gr.Row():
232
  with gr.Column():
 
242
  bg = gr.Textbox(label="Background Color", value=DEFAULT_COLOR)
243
  with gr.Column():
244
  text = gr.Textbox(label="Text Color", value="black")
245
+ with gr.Group():
246
  with gr.Row():
247
  dep_output = gr.HTML(
248
  value=parse(
 
257
  )[0]
258
  )
259
  with gr.Row():
260
+ with gr.Column():
261
+ dep_button = gr.Button("Update Parser", variant="primary")
 
 
262
  with gr.Column():
263
  dep_download_button = gr.HTML(
264
  value=download_svg(dep_output.value)
265
  )
266
+ with gr.Group():
267
+ with gr.Column():
268
+ with gr.Row():
269
+ with gr.Column():
270
+ gr.Markdown("## Contact")
271
+ gr.Markdown(
272
+ "If you have any questions, suggestions, comments, or problems, feel free to [reach out](mailto:riemenschneider@cl.uni-heidelberg.de)."
273
+ )
274
+ gr.Markdown("## Citation")
275
+ gr.Markdown(
276
+ "This space uses models from [this](https://aclanthology.org/2023.acl-long.846.pdf) paper."
277
+ )
278
+ gr.Markdown(
279
+ """```bibtex
 
280
  @incollection{riemenschneider-frank-2023-exploring,
281
  title = "Exploring Large Language Models for Classical Philology",
282
  author = "Riemenschneider, Frederick and Frank, Anette",
 
290
  pages = "15181--15199",
291
  }
292
  ```
293
+ """
294
+ )
 
295
  button.click(
296
  execute_parse,
297
  inputs=[
 
321
  ],
322
  outputs=[dep_output, dep_download_button],
323
  )
324
+ return demo
325
 
 
326
 
327
 
328
  def main():