File size: 1,490 Bytes
1785552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import torch
import transformers
import gradio as gr
from transformers import pipeline

summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn")

text = """Paris is the capital and most populous city of France, with
          an estimated population of 2,175,601 residents as of 2018,
          in an area of more than 105 square kilometres (41 square
          miles). The City of Paris is the centre and seat of
          government of the region and province of Île-de-France, or
          Paris Region, which has an estimated population of
          12,174,880, or about 18 percent of the population of France
          as of 2017."""

summary = summarizer(text, min_length=10, max_length=100)

summary

summary=summary[0]['summary_text']
print(summary)


def summarization(text):
    text = summary
    return text

# Create the Gradio interface
iface = gr.Interface(
        fn=summarization,
        inputs=[
                gr.Textbox(placeholder="Enter text to summarize..."),
                gr.Number(minimum=10, maximum=50, label="Minimum length"),  # First number input
                gr.Slider(minimum=50, maximum=150, step=1, label="Maximum length")  # Slider for the second number
               ],
        outputs=gr.Textbox(label="Summary"),
        title="Bart Summarization Model",
        description="Enter a text or a paragraph to summarize its content: ", 
                     )

# Launch the app
if __name__ == "__main__":
    iface.launch()