Xanthius's picture
Create app.py
09f1499
raw
history blame
No virus
321 Bytes
from sentencepiece import SentencePieceProcessor
import gradio as gr
sp = SentencePieceProcessor(model_file="tokenizer.model")
def tokenize(input_text):
tokens = sp.EncodeAsIds(input_text)
return f"Number of tokens: {len(tokens)}"
iface = gr.Interface(fn=tokenize, inputs="text", outputs="text")
iface.launch()