Spaces:
Runtime error
Runtime error
File size: 911 Bytes
ca79b72 1320441 ca79b72 |
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 |
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() |