Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
model_id = "methodya/arabic-summarizer-philosophy" | |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id) | |
tokenizer = AutoTokenizer.from_pretrained(model_id) | |
def summarize(text, max_length=150): | |
inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True) | |
outputs = model.generate(**inputs, max_length=max_length) | |
return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
interface = gr.Interface( | |
fn=summarize, | |
inputs=[ | |
gr.Textbox(lines=8, label="ุงููุต"), | |
gr.Slider(50, 250, value=150, label="ุทูู ุงูู ูุฎุต") | |
], | |
outputs=gr.Textbox(label="ุงูู ูุฎุต"), | |
title="ู ูุฎุต ุงููุตูุต ุงูููุณููุฉ", | |
description="ูู ูุฐุฌ ูุชูุฎูุต ุงููุตูุต ุงูููุณููุฉ ุจุงููุบุฉ ุงูุนุฑุจูุฉ" | |
) | |
interface.launch() |