File size: 993 Bytes
4e1f2a7
687de9e
50379ba
 
 
 
 
 
8722a33
d0336c8
50379ba
d0336c8
50379ba
8722a33
b0fa9b5
d0336c8
 
b0fa9b5
8722a33
50379ba
b0fa9b5
d0336c8
 
 
 
b0fa9b5
687de9e
d0336c8
 
50379ba
b0fa9b5
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
#I used the https://www.marqo.ai/blog/how-to-create-a-hugging-face-space to help make this code.
#Logan Lin, Period 3, Artificial Intelligence, 
import gradio as gr
from transformers import AutoModel, AutoProcessor
import torch
import requests
from PIL import Image
from io import BytesIO
from transformers import pipeline
import torch

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

def summarize_text(input_text):

    if not input_text.strip():
        return {"Error": "Please input some text"}

    summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)

    return summary[0]['summary_text']
demo = gr.Interface(
    fn=summarize_text, 
    inputs=gr.Textbox(label="Enter Text to Summarize", lines=5),
    outputs=gr.Label(label="Summary"), 
    title="Text Summarization",
    description="This app uses the facebook/bart-large-cnn for summarizing input and the code is made my Logan Lin.",
    allow_flagging="never"
)

demo.launch()