File size: 506 Bytes
5a3ebe3
0bdb91f
33011f2
5a3ebe3
0bdb91f
d3d9869
31ff37c
 
 
 
1
2
3
4
5
6
7
8
9
10
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")