token-counter / app.py
kiranr's picture
Update app.py
a0047d0
raw
history blame
357 Bytes
from transformers import AutoTokenizer
import gradio as gr
tokenizer = AutoTokenizer.from_pretrained("kiranr/gpt2-tokenizer")
def tokenize(input_text):
tokens = tokenizer(input_text)["input_ids"]
return f"Number of tokens: {len(tokens)}"
demo = gr.Interface(
fn=tokenize,
inputs=gr.Textbox(lines=7),
outputs="text",
)
demo.launch()