File size: 879 Bytes
09e1592
 
 
cb38f8c
09e1592
3ed20ad
 
 
 
 
 
 
 
cb38f8c
09e1592
 
 
3ed20ad
09e1592
 
3ed20ad
09e1592
 
 
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
import gradio as gr
from transformers import pipeline

summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

def summarize_text(text):
    word_count = len(text.split())  # حساب عدد الكلمات
    if word_count < 10:
        return "Error: The text should have at least 10 words."
    elif word_count > 100:
        return "Error: The text should have no more than 100 words."
    
    summary = summarizer(text, min_length=10, max_length=100)
    return summary[0]['summary_text']

interface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(label="Enter Text", lines=10, placeholder="Paste your long text here..."),
    outputs=gr.Textbox(label="Summarized Text"),
    title="Text Summarizer",
    description="This app uses the BART model to summarize your text. The input text must be between 10 and 100 words."
)

interface.launch()