clarkchan's picture
1
31ff37c
raw
history blame
506 Bytes
import gradio as gr
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("liam168/c2-roberta-base-finetuned-dianping-chinese")
def greet(name):
result = tokenizer([name],padding=True,truncation=True,return_tensors="pt")
tensor_str = ','.join(map(str, result.input_ids.numpy()))
decode_str = tokenizer.decode(result)
return tensor_str,decode_str
iface = gr.Interface(fn=greet, inputs="text", outputs=["text","text"])
iface.launch(share=True,server_name="0.0.0.0")