Spaces:
Runtime error
Runtime error
from transformers import pipeline | |
model1 = pipeline("text-generation",model="uer/gpt2-chinese-poem") | |
from opencc import OpenCC | |
t2s=OpenCC('t2s').convert | |
s2t=OpenCC('s2t').convert | |
import jiagu | |
import gradio as gr | |
inp1=gr.inputs.Textbox(label="่ซ่ผธๅ ฅไธๆฎต่ฉฉ่ฉ") | |
inp2=gr.inputs.Slider(minimum=50,maximum=250,step=5,default=150, label="็ๆ่ฉฉ่ฉ้ทๅบฆ") | |
op1=gr.outputs.Textbox(label="็ๆ่ฉฉ่ฉ็ตๆ") | |
op2=gr.outputs.Textbox(label="ๆ ๆๅๆ(positive=ๅๆญฃ้ข, negative=ๅ่ฒ ้ข)") | |
def poem_generator(txt,n=100): | |
model_input=t2s(txt) | |
poem=model1(model_input, max_length=n)[0]['generated_text'] | |
poem="".join(poem.split()) | |
sentiment = jiagu.sentiment(model_input) | |
smt=sentiment[0] | |
return s2t(poem),smt | |
iface=gr.Interface(fn=poem_generator, | |
inputs=[inp1,inp2], | |
outputs=[op1,op2], | |
title="็น้ซไธญๆ่ฉฉ่ฉ็ๆWeb APP", | |
description="่ซ่ผธๅ ฅไธๆฎต่ฉฉ่ฉ๏ผๆๆๅนซไฝ ็นผ็บ็ๆ่ฉฉ่ฉ๏ผ้ๆๅนซไฝ ๅๆ้ๆดๆฎต่ฉฉ่ฉๅๆญฃ้ขๆ่ฒ ้ขๅ!") | |
iface.launch() |