File size: 969 Bytes
2880c78
 
 
 
 
 
 
 
5d05d6f
2880c78
 
 
 
 
 
 
 
 
 
 
 
 
d3c77ec
 
2880c78
 
 
 
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
import torch
import gradio as gr
from transformers import pipeline 

# Use a pipeline as a high-level helper
from transformers import pipeline


text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)

# text ='''Nigeria has been home to several indigenous material cultures, precolonial states and kingdoms since the second millennium BC'''
# print (text_summary(text))

def summary(input):
    output = text_summary(input)
    return output [0]['summary_text']

gr.close_all()

#demo = gr.Interface(fn=summary, input="text", output="text")

demo = gr.Interface(fn=summary, 
                    inputs =[gr.Textbox(label="Input text to summarize", lines=6)],
                    outputs=[gr.Textbox(label="summarized text", lines=4)], title ="@My GenAI Project 16: Text-summarizer",
                    description ="This application would be used to summarize text")
                                
demo.launch()