arabicPhilo / appOLD.py
methodya's picture
Rename app.py to appOLD.py
84280c2 verified
raw
history blame
890 Bytes
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()