Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -39,14 +39,14 @@ def summarize(input):
|
|
39 |
summary_translated = translate(summary_origin,'en','fr')
|
40 |
return summary_origin, summary_translated[0]
|
41 |
|
42 |
-
def reset_input():
|
43 |
-
|
44 |
|
45 |
-
def text_reset():
|
46 |
-
|
47 |
|
48 |
-
def ner_reset():
|
49 |
-
|
50 |
|
51 |
def merge_tokens(tokens):
|
52 |
merged_tokens = []
|
@@ -101,6 +101,9 @@ def create_playground_footer():
|
|
101 |
with playground:
|
102 |
create_playground_header()
|
103 |
with gr.Tabs():
|
|
|
|
|
|
|
104 |
with gr.TabItem("Image"):
|
105 |
with gr.Row():
|
106 |
with gr.Column(scale=4):
|
@@ -124,6 +127,9 @@ with playground:
|
|
124 |
ITT_button.click(launch_image_pipe, inputs=[img], outputs=[generated_textbox])
|
125 |
# generate_audio_button.click(generate_audio, inputs=[generated_textbox], outputs=[audio_output])
|
126 |
|
|
|
|
|
|
|
127 |
with gr.TabItem("Text"):
|
128 |
with gr.Row():
|
129 |
with gr.Column(scale=4):
|
@@ -136,7 +142,7 @@ with playground:
|
|
136 |
|
137 |
with gr.Column(scale=1):
|
138 |
text_pipeline_button = gr.Button(value="Start Process", variant="primary")
|
139 |
-
text_reset_button = gr.Button(value="Clear")
|
140 |
|
141 |
with gr.Row():
|
142 |
with gr.Column():
|
@@ -144,6 +150,7 @@ with playground:
|
|
144 |
with gr.Column():
|
145 |
summary_textoutput = gr.Textbox(lines=3, placeholder="", label="Text Summarization")
|
146 |
translated_textbox = gr.Textbox(lines=3, placeholder="", label="Translated Result")
|
|
|
147 |
|
148 |
with gr.Row():
|
149 |
with gr.Column():
|
@@ -153,8 +160,11 @@ with playground:
|
|
153 |
], inputs=[source_text], outputs=[summary_textoutput, translated_textbox], run_on_click=True, cache_examples=True, fn=summarize)
|
154 |
|
155 |
text_pipeline_button.click(summarize, inputs=[source_text], outputs=[summary_textoutput, translated_textbox])
|
156 |
-
text_reset_button.click(text_reset, outputs=[source_text,summary_textoutput,translated_textbox])
|
157 |
|
|
|
|
|
|
|
158 |
with gr.TabItem("Name Entity"):
|
159 |
with gr.Row():
|
160 |
with gr.Column(scale=4):
|
@@ -166,14 +176,15 @@ with playground:
|
|
166 |
|
167 |
with gr.Column(scale=1):
|
168 |
ner_pipeline_button = gr.Button(value="Start Process", variant="primary")
|
169 |
-
ner_reset_button = gr.Button(value="Clear")
|
170 |
|
171 |
with gr.Row():
|
172 |
with gr.Column():
|
173 |
-
ner_text_input = gr.Textbox(label="Text to find entities", lines=
|
174 |
|
175 |
with gr.Column():
|
176 |
ner_text_output = gr.HighlightedText(label="Text with entities")
|
|
|
177 |
|
178 |
with gr.Row():
|
179 |
with gr.Column():
|
@@ -183,7 +194,7 @@ with playground:
|
|
183 |
], inputs=[ner_text_input], outputs=[ner_text_output], run_on_click=True, cache_examples=True, fn=ner)
|
184 |
|
185 |
ner_pipeline_button.click(ner, inputs=[ner_text_input], outputs=[ner_text_output])
|
186 |
-
ner_reset_button.click(ner_reset, outputs=[ner_text_input, ner_text_output])
|
187 |
|
188 |
create_playground_footer()
|
189 |
|
|
|
39 |
summary_translated = translate(summary_origin,'en','fr')
|
40 |
return summary_origin, summary_translated[0]
|
41 |
|
42 |
+
# def reset_input():
|
43 |
+
# return ""
|
44 |
|
45 |
+
# def text_reset():
|
46 |
+
# return "","",""
|
47 |
|
48 |
+
# def ner_reset():
|
49 |
+
# return "",""
|
50 |
|
51 |
def merge_tokens(tokens):
|
52 |
merged_tokens = []
|
|
|
101 |
with playground:
|
102 |
create_playground_header()
|
103 |
with gr.Tabs():
|
104 |
+
## ================================================================================================================================
|
105 |
+
## Image Captioning
|
106 |
+
## ================================================================================================================================
|
107 |
with gr.TabItem("Image"):
|
108 |
with gr.Row():
|
109 |
with gr.Column(scale=4):
|
|
|
127 |
ITT_button.click(launch_image_pipe, inputs=[img], outputs=[generated_textbox])
|
128 |
# generate_audio_button.click(generate_audio, inputs=[generated_textbox], outputs=[audio_output])
|
129 |
|
130 |
+
## ================================================================================================================================
|
131 |
+
## Text Summarization and Translation
|
132 |
+
## ================================================================================================================================
|
133 |
with gr.TabItem("Text"):
|
134 |
with gr.Row():
|
135 |
with gr.Column(scale=4):
|
|
|
142 |
|
143 |
with gr.Column(scale=1):
|
144 |
text_pipeline_button = gr.Button(value="Start Process", variant="primary")
|
145 |
+
# text_reset_button = gr.Button(value="Clear")
|
146 |
|
147 |
with gr.Row():
|
148 |
with gr.Column():
|
|
|
150 |
with gr.Column():
|
151 |
summary_textoutput = gr.Textbox(lines=3, placeholder="", label="Text Summarization")
|
152 |
translated_textbox = gr.Textbox(lines=3, placeholder="", label="Translated Result")
|
153 |
+
Text_Clear_button = gr.ClearButton(components=[source_text, summary_textoutput, translated_textbox], value="Clear")
|
154 |
|
155 |
with gr.Row():
|
156 |
with gr.Column():
|
|
|
160 |
], inputs=[source_text], outputs=[summary_textoutput, translated_textbox], run_on_click=True, cache_examples=True, fn=summarize)
|
161 |
|
162 |
text_pipeline_button.click(summarize, inputs=[source_text], outputs=[summary_textoutput, translated_textbox])
|
163 |
+
# text_reset_button.click(text_reset, outputs=[source_text,summary_textoutput,translated_textbox])
|
164 |
|
165 |
+
## ================================================================================================================================
|
166 |
+
## Find entities
|
167 |
+
## ================================================================================================================================
|
168 |
with gr.TabItem("Name Entity"):
|
169 |
with gr.Row():
|
170 |
with gr.Column(scale=4):
|
|
|
176 |
|
177 |
with gr.Column(scale=1):
|
178 |
ner_pipeline_button = gr.Button(value="Start Process", variant="primary")
|
179 |
+
# ner_reset_button = gr.Button(value="Clear")
|
180 |
|
181 |
with gr.Row():
|
182 |
with gr.Column():
|
183 |
+
ner_text_input = gr.Textbox(label="Text to find entities", lines=4)
|
184 |
|
185 |
with gr.Column():
|
186 |
ner_text_output = gr.HighlightedText(label="Text with entities")
|
187 |
+
Ner_Clear_button = gr.ClearButton(components=[ner_text_input, ner_text_input], value="Clear")
|
188 |
|
189 |
with gr.Row():
|
190 |
with gr.Column():
|
|
|
194 |
], inputs=[ner_text_input], outputs=[ner_text_output], run_on_click=True, cache_examples=True, fn=ner)
|
195 |
|
196 |
ner_pipeline_button.click(ner, inputs=[ner_text_input], outputs=[ner_text_output])
|
197 |
+
# ner_reset_button.click(ner_reset, outputs=[ner_text_input, ner_text_output])
|
198 |
|
199 |
create_playground_footer()
|
200 |
|