File size: 1,248 Bytes
adc690b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch as t
import gradio as gr
from transformers import pipeline


# model_path = ("../Model/models--zaib32--autotrain-finetuned_distillbart-3664997842/snapshots/a44da4a43958852b7010ccc60a65dc3bb69b403e")
pipe = pipeline("summarization", model="zaib32/autotrain-finetuned_distillbart-3664997842",
                torch_dtype=t.bfloat16)

# text='''Elon Reeve Musk (born June 28, 1971) is a businessman and investor. He is the founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect, and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.; founder of the Boring Company and xAI; co-founder of Neuralink and OpenAI; and president of the Musk Foundation.'''
# print(pipe(text))


def summary(text):
    output = pipe(text)
    return output[0]['summary_text']


gr.close_all()

# demo = gr.Interface(fn=summary, inputs="text", outputs="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="@GenAILearning Project 1: Text Summarizer",
                    description="This application will summarize text")
demo.launch()