Download app.py from lochn/Lucca: direct link, hf CLI and curl.
- Browser
- Download file 827 Bytes
-
https://huggingface.co/spaces/lochn/Lucca/resolve/main/app.py
- Command line
-
hf download hf://spaces/lochn/Lucca/app.py
-
curl -L -o app.py https://huggingface.co/spaces/lochn/Lucca/resolve/main/app.py
827 Bytes
| # -*- coding: utf-8 -*- | |
| """Copy of text summarization.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/12ph83wSwEKGni2qgQjSRJE-EY0KJs-jL | |
| """ | |
| import gradio as gr | |
| # Use a pipeline as a high-level helper | |
| from transformers import pipeline | |
| pipe = pipeline("summarization", model="facebook/bart-large-cnn") | |
| def summarize_text(text): | |
| result = pipe(text, max_length=500, min_length=30, do_sample=False) | |
| # Extract the summary from the result | |
| # summary = result[0]['generated_text'] | |
| return result | |
| iface = gr.Interface( | |
| fn=summarize_text, | |
| inputs = gr.Textbox(lines=4, placeholder="Enter text to summarize..."), | |
| outputs = "text", | |
| title="Text Summarizer", | |
| description="Enter text and get a concise summary.", | |
| ) | |
| iface.launch(share = True) | |