Spaces:
Sleeping
Sleeping
Initial setup: Create text summarization app using BART model and Gradio interface
Browse files- app.py +18 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 5 |
+
|
| 6 |
+
def summarize_text(text):
|
| 7 |
+
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
| 8 |
+
return summary[0]["summary_text"]
|
| 9 |
+
|
| 10 |
+
interface = gr.Interface(
|
| 11 |
+
fn=summarize_text,
|
| 12 |
+
inputs=gr.Textbox(lines=15, placeholder="Colle ton texte ici..."),
|
| 13 |
+
outputs="text",
|
| 14 |
+
title="Résumé Automatique",
|
| 15 |
+
description="Entrez un texte long et obtenez un résumé concis !"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|