Hwilner's picture
Update app.py
64eca7c verified
raw
history blame
763 Bytes
import torch
import gradio as gr
from transformers import pipeline
# Use the mT5 model for multilingual summarization, including Hebrew
text_summary = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum", torch_dtype=torch.bfloat16)
def summary(input):
# Increase max_length and set max_new_tokens to avoid input length issues
output = text_summary(input, max_length=512, min_length=30, do_sample=False)
return output[0]['summary_text']
gr.close_all()
demo = gr.Interface(
fn=summary,
inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
outputs=[gr.Textbox(label="Summarized text", lines=4)],
title="Hebrew Text Summarizer",
description="This application will summarize Hebrew text."
)
demo.launch()