Spaces:
Runtime error
Runtime error
File size: 941 Bytes
945bbd0 3250e90 72fde3b 9ce0e46 3250e90 72fde3b 3250e90 9ce0e46 3250e90 72fde3b 3250e90 72fde3b 945bbd0 3250e90 945bbd0 3250e90 1b33daa |
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 32 33 34 |
import gradio as gr
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
# Load the model and tokenizer
model_name = 'IMISLab/GreekT5-umt5-small-greeksum'
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Set up the summarizer pipeline
summarizer = pipeline(
'summarization',
device = 'cpu',
model = model,
tokenizer = tokenizer,
max_new_tokens = 128,
truncation = True
)
# Define the summarization function
def generate_summary(text):
output = summarizer('summarize: ' + text)
return output[0]['summary_text']
# Create Gradio interface
iface = gr.Interface(
fn=generate_summary, # The function that Gradio will use
inputs=gr.Textbox(label="Input Text", lines=5, placeholder="Enter the text to summarize..."),
outputs=gr.Textbox(label="Summary"),
live=True
)
# Launch the Gradio interface
iface.launch()
|