Spaces:
Sleeping
Sleeping
lorenzoscottb
commited on
Commit
•
f02e17d
1
Parent(s):
17baabe
Update app.py
Browse files
app.py
CHANGED
@@ -57,7 +57,7 @@ examples = [
|
|
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,
|
@@ -69,7 +69,31 @@ interface_words = gr.Interface(
|
|
69 |
cache_examples=True,
|
70 |
)
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
pipe_L = pipeline(
|
75 |
"text-classification",
|
@@ -92,7 +116,7 @@ interface_model_L = gr.Interface(
|
|
92 |
cache_examples=True,
|
93 |
)
|
94 |
|
95 |
-
|
96 |
|
97 |
pipe_S = pipeline(
|
98 |
"text-classification",
|
@@ -115,15 +139,7 @@ interface_model_S = gr.Interface(
|
|
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,
|
@@ -139,7 +155,7 @@ interface_model_RE = gr.Interface(
|
|
139 |
cache_examples=True,
|
140 |
)
|
141 |
|
142 |
-
|
143 |
|
144 |
pipe_N = pipeline(
|
145 |
"text2text-generation",
|
@@ -151,6 +167,7 @@ def predictN(text):
|
|
151 |
t = pipe_N(text)
|
152 |
t = t[0]["generated_text"]
|
153 |
return t
|
|
|
154 |
interface_model_N = gr.Interface(
|
155 |
fn=predictN,
|
156 |
inputs='text',
|
@@ -161,9 +178,9 @@ interface_model_N = gr.Interface(
|
|
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()
|
|
|
57 |
"Śledził mnie niebieski potwór, ale się nie bałem. Byłem spokojny i zrelaksowany.",
|
58 |
]
|
59 |
|
60 |
+
############ Language Test ##############
|
61 |
|
62 |
interface_words = gr.Interface(
|
63 |
fn=check_lang,
|
|
|
69 |
cache_examples=True,
|
70 |
)
|
71 |
|
72 |
+
############ Anomimise ##############
|
73 |
+
|
74 |
+
def anon(text):
|
75 |
+
anon_dreams_list = dreamy.anonimise(
|
76 |
+
[text],
|
77 |
+
return_original=False,
|
78 |
+
batch_size=1
|
79 |
+
)
|
80 |
+
|
81 |
+
return anon_dreams_list[0]
|
82 |
+
|
83 |
+
interface_anon = gr.Interface(
|
84 |
+
fn=anon,
|
85 |
+
inputs="text",
|
86 |
+
outputs="text",
|
87 |
+
title="Anonymise",
|
88 |
+
description=description_main,
|
89 |
+
examples=[
|
90 |
+
"I was an exchange student in Slovakia, visiting someone who had been an exchange student here. The start of the dream was when I had just arrived at their house. Her family was very happy to see me, as well as excited to hear about my life in America. They asked me if I could make them a traditional American dessert to have with dinner, and I agreed, but I needed to go to the store to get some strawberries. The former exchange student, Zelka, said she would drive me to the store, so she took me out to her car which was a jeep like the ones in old WWII movies. The ride was very bumpy and when we got to town, I was very surprised to see how many American stores, etc., were there. It was terrible how much American culture had taken over their country. Then we were taken into this shop where a Chinese man was giving acupuncture lessons.",
|
91 |
+
"I was with my friends Mike and Ray. Lego blocks broke apart. Were perhaps in a junkyard.",
|
92 |
+
],
|
93 |
+
cache_examples=True,
|
94 |
+
)
|
95 |
+
|
96 |
+
############ SA classification #################
|
97 |
|
98 |
pipe_L = pipeline(
|
99 |
"text-classification",
|
|
|
116 |
cache_examples=True,
|
117 |
)
|
118 |
|
119 |
+
############ SA classification small ###############
|
120 |
|
121 |
pipe_S = pipeline(
|
122 |
"text-classification",
|
|
|
139 |
cache_examples=True,
|
140 |
)
|
141 |
|
142 |
+
########## RE ##############
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
interface_model_RE = gr.Interface(
|
145 |
text_to_graph,
|
|
|
155 |
cache_examples=True,
|
156 |
)
|
157 |
|
158 |
+
############ NER #################
|
159 |
|
160 |
pipe_N = pipeline(
|
161 |
"text2text-generation",
|
|
|
167 |
t = pipe_N(text)
|
168 |
t = t[0]["generated_text"]
|
169 |
return t
|
170 |
+
|
171 |
interface_model_N = gr.Interface(
|
172 |
fn=predictN,
|
173 |
inputs='text',
|
|
|
178 |
cache_examples=True,
|
179 |
)
|
180 |
|
181 |
+
########### MIx all ################
|
182 |
|
183 |
gr.TabbedInterface(
|
184 |
+
[interface_words, interface_anon, interface_model_N, interface_model_L, interface_model_S, interface_model_RE],
|
185 |
+
["Main", "Anonymise", "NER", "SA Multilingual", "SA English", "RE"],
|
186 |
).launch()
|