Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,17 @@
|
|
1 |
-
from transformers import
|
2 |
import gradio as gr
|
3 |
|
4 |
|
5 |
-
tokenizer =
|
6 |
|
7 |
def tokenize(input_text):
|
8 |
tokens = tokenizer(input_text)["input_ids"]
|
9 |
return f"Number of tokens: {len(tokens)}"
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer
|
2 |
import gradio as gr
|
3 |
|
4 |
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("kiranr/gpt2-tokenizer")
|
6 |
|
7 |
def tokenize(input_text):
|
8 |
tokens = tokenizer(input_text)["input_ids"]
|
9 |
return f"Number of tokens: {len(tokens)}"
|
10 |
|
11 |
+
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=tokenize,
|
14 |
+
inputs=gr.Textbox(lines=7),
|
15 |
+
outputs="text",
|
16 |
+
)
|
17 |
+
demo.launch()
|