Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,6 +57,8 @@ examples = [
|
|
57 |
"艢ledzi艂 mnie niebieski potw贸r, ale si臋 nie ba艂em. By艂em spokojny i zrelaksowany.",
|
58 |
]
|
59 |
|
|
|
|
|
60 |
interface_words = gr.Interface(
|
61 |
fn=check_lang,
|
62 |
inputs="text",
|
@@ -66,13 +68,31 @@ interface_words = gr.Interface(
|
|
66 |
examples=["en", "it", "pl"],
|
67 |
cache_examples=True,
|
68 |
)
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
pipe_S = pipeline(
|
78 |
"text-classification",
|
@@ -95,12 +115,16 @@ interface_model_S = gr.Interface(
|
|
95 |
cache_examples=True,
|
96 |
)
|
97 |
|
|
|
|
|
98 |
# interface_model_G = gr.Interface.load(
|
99 |
# "models/DReAMy-lib/t5-base-DreamBank-Generation-Emot-Char",
|
100 |
# examples=examples_g,
|
101 |
# title="SA Generation",
|
102 |
# )
|
103 |
|
|
|
|
|
104 |
interface_model_RE = gr.Interface(
|
105 |
text_to_graph,
|
106 |
inputs=gr.Textbox(label="Text", placeholder="Enter a text here."),
|
@@ -115,13 +139,31 @@ interface_model_RE = gr.Interface(
|
|
115 |
cache_examples=True,
|
116 |
)
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
gr.TabbedInterface(
|
125 |
-
[interface_words, interface_model_S, interface_model_RE],
|
126 |
-
["Main", "SA English", "RE"],
|
127 |
).launch()
|
|
|
57 |
"艢ledzi艂 mnie niebieski potw贸r, ale si臋 nie ba艂em. By艂em spokojny i zrelaksowany.",
|
58 |
]
|
59 |
|
60 |
+
#############################
|
61 |
+
|
62 |
interface_words = gr.Interface(
|
63 |
fn=check_lang,
|
64 |
inputs="text",
|
|
|
68 |
examples=["en", "it", "pl"],
|
69 |
cache_examples=True,
|
70 |
)
|
71 |
+
|
72 |
+
#############################
|
73 |
+
|
74 |
+
pipe_L = pipeline(
|
75 |
+
"text-classification",
|
76 |
+
model="models/DReAMy-lib/xlm-roberta-large-DreamBank-emotion-presence",
|
77 |
+
max_length=300,
|
78 |
+
return_all_scores=True,
|
79 |
+
truncation="do_not_truncate",
|
80 |
+
)
|
81 |
+
def predictL(text):
|
82 |
+
t = pipe_SL(text)
|
83 |
+
t = {list(dct.values())[0] : list(dct.values())[1] for dct in t[0]}
|
84 |
+
return t
|
85 |
+
interface_model_L = gr.Interface(
|
86 |
+
fn=predictL,
|
87 |
+
inputs='text',
|
88 |
+
outputs=gr.Label(),
|
89 |
+
title="SA Large Multilingual",
|
90 |
+
description=description_L,
|
91 |
+
examples=examples,
|
92 |
+
cache_examples=True,
|
93 |
+
)
|
94 |
+
|
95 |
+
#############################
|
96 |
|
97 |
pipe_S = pipeline(
|
98 |
"text-classification",
|
|
|
115 |
cache_examples=True,
|
116 |
)
|
117 |
|
118 |
+
#############################
|
119 |
+
|
120 |
# interface_model_G = gr.Interface.load(
|
121 |
# "models/DReAMy-lib/t5-base-DreamBank-Generation-Emot-Char",
|
122 |
# examples=examples_g,
|
123 |
# title="SA Generation",
|
124 |
# )
|
125 |
|
126 |
+
#############################
|
127 |
+
|
128 |
interface_model_RE = gr.Interface(
|
129 |
text_to_graph,
|
130 |
inputs=gr.Textbox(label="Text", placeholder="Enter a text here."),
|
|
|
139 |
cache_examples=True,
|
140 |
)
|
141 |
|
142 |
+
#############################
|
143 |
+
|
144 |
+
pipe_N = pipeline(
|
145 |
+
""text2text-generation"",
|
146 |
+
model="models/DReAMy-lib/t5-base-DreamBank-Generation-NER-Char",
|
147 |
+
max_length=300,
|
148 |
+
return_all_scores=True,
|
149 |
+
truncation="do_not_truncate",
|
150 |
+
)
|
151 |
+
def predictN(text):
|
152 |
+
t = pipe_N(text)
|
153 |
+
return t
|
154 |
+
interface_model_N = gr.Interface(
|
155 |
+
fn=predictN,
|
156 |
+
inputs='text',
|
157 |
+
outputs='text',
|
158 |
+
title="NER",
|
159 |
+
description=description_L,
|
160 |
+
examples=examples,
|
161 |
+
cache_examples=True,
|
162 |
+
)
|
163 |
+
|
164 |
+
#############################
|
165 |
|
166 |
gr.TabbedInterface(
|
167 |
+
[interface_words, interface_model_N, interface_model_L, interface_model_S, interface_model_RE],
|
168 |
+
["Main", "NER", "SA Multilingual", "SA English", "RE"],
|
169 |
).launch()
|