Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from transformers import pipeline
|
2 |
-
import gradio as gr
|
3 |
-
import torch
|
4 |
import time # To simulate processing time for demonstration
|
5 |
|
6 |
# Load the summarization pipelines
|
@@ -111,32 +110,28 @@ button:hover, .btn:hover {
|
|
111 |
|
112 |
# Create the Gradio interface
|
113 |
with gr.Blocks(css=custom_css) as interface:
|
114 |
-
gr.Markdown("<h1 style='text-align: center;'
|
115 |
|
116 |
-
text_input = gr.Textbox(label="Enter Text Here", lines=8, text_align="right"
|
117 |
-
max_length = gr.Slider(minimum=80, maximum=200, value=100, step=1, label="Max Summary Length"
|
118 |
-
min_length = gr.Slider(minimum=5, maximum=50, value=20, step=1, label="Min Summary Length"
|
119 |
|
120 |
-
summarize_button = gr.Button("Summarize"
|
121 |
-
language_button = gr.Button("Switch Language"
|
122 |
-
summary_output = gr.Textbox(label="Summary", lines=6, text_align="right"
|
123 |
|
124 |
summarize_button.click(summarize, inputs=[text_input, max_length, min_length], outputs=summary_output)
|
125 |
-
language_button.click(lambda: (toggle_language(),
|
126 |
|
127 |
# Update interface labels
|
128 |
def update_labels():
|
129 |
labels = update_interface()
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
max_length.label = max_label
|
137 |
-
min_length.label = min_label
|
138 |
-
summarize_button.label = summarize_label
|
139 |
-
summary_output.label = summary_label
|
140 |
|
141 |
if __name__ == "__main__":
|
142 |
interface.launch()
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
|
|
3 |
import time # To simulate processing time for demonstration
|
4 |
|
5 |
# Load the summarization pipelines
|
|
|
110 |
|
111 |
# Create the Gradio interface
|
112 |
with gr.Blocks(css=custom_css) as interface:
|
113 |
+
title = gr.Markdown("<h1 style='text-align: center;'>Text Summarization Tool</h1>")
|
114 |
|
115 |
+
text_input = gr.Textbox(label="Enter Text Here", lines=8, text_align="right")
|
116 |
+
max_length = gr.Slider(minimum=80, maximum=200, value=100, step=1, label="Max Summary Length")
|
117 |
+
min_length = gr.Slider(minimum=5, maximum=50, value=20, step=1, label="Min Summary Length")
|
118 |
|
119 |
+
summarize_button = gr.Button("Summarize")
|
120 |
+
language_button = gr.Button("Switch Language")
|
121 |
+
summary_output = gr.Textbox(label="Summary", lines=6, text_align="right")
|
122 |
|
123 |
summarize_button.click(summarize, inputs=[text_input, max_length, min_length], outputs=summary_output)
|
124 |
+
language_button.click(lambda: (toggle_language(), update_labels()), outputs=[title, text_input, max_length, min_length, summarize_button, summary_output])
|
125 |
|
126 |
# Update interface labels
|
127 |
def update_labels():
|
128 |
labels = update_interface()
|
129 |
+
title.update(value=f"<h1 style='text-align: center;'>{labels['title']}</h1>")
|
130 |
+
text_input.label = labels["textbox_label"]
|
131 |
+
max_length.label = labels["max_length_label"]
|
132 |
+
min_length.label = labels["min_length_label"]
|
133 |
+
summarize_button.label = labels["summarize_button_label"]
|
134 |
+
summary_output.label = labels["summary_label"]
|
|
|
|
|
|
|
|
|
135 |
|
136 |
if __name__ == "__main__":
|
137 |
interface.launch()
|