File size: 1,477 Bytes
8a4de57
 
b4d0042
 
8a4de57
b4d0042
 
f2826d5
 
 
 
ce22c11
e70ebbc
cc8349d
c29fdb5
 
fecfe7e
78ea6f0
2ce656d
866d4b0
07a225e
ce22c11
07a225e
7d83082
 
 
b4d0042
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

#def greet(name):
#   return "Hello " + name + "!!"

#iface = gr.Interface(fn=greet, inputs="text", outputs="text")
#iface.launch()
#git clone  https://github.com/huggingface/transformers.git
#cd transformers
#pip install
#python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"
#pip install 'transformers[torch]'
#source .env/bin/activate
#pipenv install git+https://github.com/huggingface/transformers
#python -m pip install git+https://github.com/huggingface/transformers
#source ENV/bin/activate
#python -m venv .env
#pip install transformers
#pip install transformers
#pip install -U git+https://github.com/huggingface/transformers.git
#! pip install -U git+https://github.com/huggingface/accelerate.git

from transformers import pipeline

get_completion = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")

def summarize(input):
    output = get_completion(input)
    return output[0]['summary_text']
    
gr.close_all()
demo = gr.Interface(fn=summarize, 
                    inputs=[gr.Textbox(label="Text to summarize", lines=6)],
                    outputs=[gr.Textbox(label="Result", lines=3)],
                    title="Text summarization with distilbart-cnn",
                    description="Summarize any text using the `shleifer/distilbart-cnn-12-6` model under the hood!"
                   )
demo.launch(share=True)
#demo.launch(share=True, server_port=int(os.environ['PORT2']))