pavithra-devi's picture
kind of final app
733c886
raw
history blame
1.3 kB
import gradio as gr
from src.TextSummarizer.pipeline.prediction import PredictionPipeline
def predict(document):
"""
Method will take the document and summarize it.
"""
# predict the summary using my own pre-trained model.
summary = PredictionPipeline().predict(document)
return summary
# Create the frontend.
input_interfaces: list = []
with gr.Blocks(theme=gr.themes.Soft()) as app:
with gr.Row():
gr.Label("Text Summarizer...")
with gr.Row():
gr.Markdown("Type in your document which you wanna summarize...")
with gr.Row():
with gr.Column():
input_text_box = gr.Textbox(
label="Document",
info="Example text",
lines=20,
value="Wikipedia is a free, open content online encyclopedia created through the collaborative effort of a community of users known as Wikipedians. Anyone registered on the site can create an article for publication; registration is not required to edit articles.",
)
with gr.Column():
output_text_box = gr.Label("summary")
input_interfaces.append(input_text_box)
with gr.Row():
predict_but = gr.Button("Predict")
# Add the button actions.
predict_but.click(predict, inputs=input_interfaces, outputs=output_text_box)
app.launch()