Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| #def greet(name): | |
| # return "Hello " + name + "!!" | |
| #iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| #iface.launch() | |
| 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'])) |