Spaces:
Runtime error
Runtime error
import torch | |
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM | |
import gradio as gr | |
# ใใผใฏใใคใถใผใจใขใใซใฎๆบๅ | |
tokenizer = AutoTokenizer.from_pretrained('sonoisa/t5-base-japanese') | |
model = AutoModelForSeq2SeqLM.from_pretrained('models/') | |
def summary(text): | |
# ๆ็ซ ใใใณใฝใซใซๅคๆ | |
input = tokenizer.encode(text, return_tensors='pt', max_length=512, truncation=True) | |
# ๆจ่ซ | |
model.eval() | |
with torch.no_grad(): | |
summary_ids = model.generate(input) | |
return tokenizer.decode(summary_ids[0][1:-1]) | |
descriptions = "T5ใซใใๆ็ซ ่ฆ็ดใๆ็ซ ใๅ ฅๅใใใจใใใฎ่ฆ็ดๆใๅบๅใใพใใ" | |
demo = gr.Interface(fn=summary, inputs=gr.Textbox(lines=5, placeholder="ๆ็ซ ใๅ ฅๅใใฆใใ ใใ"), outputs=gr.Textbox(lines=5),title="Sentence Summary", description=descriptions) | |
demo.launch() |