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...") 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. Jimmy Wales and Larry Sanger co-founded Wikipedia as an offshoot of an earlier encyclopedia project, Nupedia, in January 2001. Originally, Wikipedia was created to provide content for Nupedia. However, as the wiki site became established it soon grew beyond the scope of the earlier project. As of January 2015, the website provided well over five million articles in English and more than that number in all other languages combined. At that same time, Alexa ranked Wikipedia as the seventh-most popular site on the Internet. Wikipedia was the only non-commercial site of the top ten.", ) input_interfaces.append(input_text_box) # Add the button actions. gr.Interface(predict, inputs=input_interfaces, outputs="text") app.launch(share=True)