Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +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="text", outputs="text")
|
11 |
+
iface.launch()
|