maettubfh commited on
Commit
8baa175
1 Parent(s): 86c6b7a

reformatted with black

Browse files
Files changed (2) hide show
  1. app.py +46 -13
  2. src/nlp_circle_demo/interface.py +5 -7
app.py CHANGED
@@ -5,25 +5,58 @@ from src.nlp_circle_demo.interface import GradioElementWrapper
5
  GradioElementWrapper.interface_from_yaml("resources/qa_interface.yml")
6
 
7
 
 
 
 
 
 
 
8
 
9
- robertaGer = GradioElementWrapper.interface_from_yaml("resources/legal_german_roberta_interface.yml").gradio_element
10
- gbert = GradioElementWrapper.interface_from_yaml("resources/gbert_interface.yml").gradio_element
 
11
 
12
- ner = GradioElementWrapper.interface_from_yaml("resources/ner_interface.yml").gradio_element
13
 
14
-
15
- zeroShot = GradioElementWrapper.interface_from_yaml("resources/zero_shot_interface.yml").gradio_element
 
16
 
17
  legalInterface = gr.TabbedInterface([robertaGer, gbert], ["Roberta Legal", "Bert"])
18
 
19
 
20
- qaInterface = GradioElementWrapper.interface_from_yaml("resources/qa_interface.yml").gradio_element
21
- simplicationInterface = GradioElementWrapper.interface_from_yaml("resources/simplification_interface.yml").gradio_element
22
- gptInterface = GradioElementWrapper.interface_from_yaml("resources/gpt2_interface.yml").gradio_element
23
- summarizationInterface = GradioElementWrapper.interface_from_yaml("resources/summarization_interface.yml").gradio_element
24
-
25
-
26
- demo = gr.TabbedInterface([gptInterface, legalInterface ,qaInterface, summarizationInterface, simplicationInterface, ner, zeroShot], [
27
- "GPT", "Legal", "Question Answering", "Summarization", "Simplification", "Named Entity Recognition", "Zero-Shot-Klassifizierung"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  demo.launch()
 
5
  GradioElementWrapper.interface_from_yaml("resources/qa_interface.yml")
6
 
7
 
8
+ robertaGer = GradioElementWrapper.interface_from_yaml(
9
+ "resources/legal_german_roberta_interface.yml"
10
+ ).gradio_element
11
+ gbert = GradioElementWrapper.interface_from_yaml(
12
+ "resources/gbert_interface.yml"
13
+ ).gradio_element
14
 
15
+ ner = GradioElementWrapper.interface_from_yaml(
16
+ "resources/ner_interface.yml"
17
+ ).gradio_element
18
 
 
19
 
20
+ zeroShot = GradioElementWrapper.interface_from_yaml(
21
+ "resources/zero_shot_interface.yml"
22
+ ).gradio_element
23
 
24
  legalInterface = gr.TabbedInterface([robertaGer, gbert], ["Roberta Legal", "Bert"])
25
 
26
 
27
+ qaInterface = GradioElementWrapper.interface_from_yaml(
28
+ "resources/qa_interface.yml"
29
+ ).gradio_element
30
+ simplicationInterface = GradioElementWrapper.interface_from_yaml(
31
+ "resources/simplification_interface.yml"
32
+ ).gradio_element
33
+ gptInterface = GradioElementWrapper.interface_from_yaml(
34
+ "resources/gpt2_interface.yml"
35
+ ).gradio_element
36
+ summarizationInterface = GradioElementWrapper.interface_from_yaml(
37
+ "resources/summarization_interface.yml"
38
+ ).gradio_element
39
+
40
+
41
+ demo = gr.TabbedInterface(
42
+ [
43
+ gptInterface,
44
+ legalInterface,
45
+ qaInterface,
46
+ summarizationInterface,
47
+ simplicationInterface,
48
+ ner,
49
+ zeroShot,
50
+ ],
51
+ [
52
+ "GPT",
53
+ "Legal",
54
+ "Question Answering",
55
+ "Summarization",
56
+ "Simplification",
57
+ "Named Entity Recognition",
58
+ "Zero-Shot-Klassifizierung",
59
+ ],
60
+ )
61
 
62
  demo.launch()
src/nlp_circle_demo/interface.py CHANGED
@@ -2,8 +2,8 @@ import gradio as gr
2
  import json
3
  import yaml
4
 
5
- class GradioElementWrapper:
6
 
 
7
  def __init__(self, title, gradio_element):
8
  self.title = title
9
  self.gradio_element = gradio_element
@@ -20,17 +20,15 @@ class GradioElementWrapper:
20
  """Creates Gradio-Element containing an interface."""
21
  description = cls._prepend_link_to_description(name, title, description)
22
  element = gr.load(
23
- name,
24
  title=None, # Having the Tab-Name is sufficient.
25
- description=description,
26
- examples=examples
27
  )
28
  return cls(title, element)
29
 
30
  @staticmethod
31
  def _prepend_link_to_description(name, title, description):
32
  without_huggingface = name.removeprefix("huggingface/")
33
- link = f'https://huggingface.co/{without_huggingface}'
34
  return f'<a href="{link}">{title}</a> </br> {description}'
35
-
36
-
 
2
  import json
3
  import yaml
4
 
 
5
 
6
+ class GradioElementWrapper:
7
  def __init__(self, title, gradio_element):
8
  self.title = title
9
  self.gradio_element = gradio_element
 
20
  """Creates Gradio-Element containing an interface."""
21
  description = cls._prepend_link_to_description(name, title, description)
22
  element = gr.load(
23
+ name,
24
  title=None, # Having the Tab-Name is sufficient.
25
+ description=description,
26
+ examples=examples,
27
  )
28
  return cls(title, element)
29
 
30
  @staticmethod
31
  def _prepend_link_to_description(name, title, description):
32
  without_huggingface = name.removeprefix("huggingface/")
33
+ link = f"https://huggingface.co/{without_huggingface}"
34
  return f'<a href="{link}">{title}</a> </br> {description}'