kiranr commited on
Commit
e2c8253
1 Parent(s): 4ad9386

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,10 +1,11 @@
1
- from sentencepiece import SentencePieceProcessor
2
  import gradio as gr
3
 
4
- sp = SentencePieceProcessor(model_file="tokenizer.model")
 
5
 
6
  def tokenize(input_text):
7
- tokens = sp.EncodeAsIds(input_text)
8
  return f"Number of tokens: {len(tokens)}"
9
 
10
  iface = gr.Interface(fn=tokenize, inputs=gr.inputs.Textbox(lines=7), outputs="text")
 
1
+ from transformers import AutoTokenizer
2
  import gradio as gr
3
 
4
+
5
+ tokenizer = AutoTokenizer.from_pretrained("gpt2")
6
 
7
  def tokenize(input_text):
8
+ tokens = tokenizer(input_text)["input_ids"]
9
  return f"Number of tokens: {len(tokens)}"
10
 
11
  iface = gr.Interface(fn=tokenize, inputs=gr.inputs.Textbox(lines=7), outputs="text")