Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,21 +30,37 @@ def decode_tokens(token_ids):
|
|
30 |
# Gradio interface
|
31 |
with gr.Blocks() as app:
|
32 |
gr.Markdown("## Hindi Tokenizer Encoder-Decoder")
|
33 |
-
|
34 |
with gr.Row():
|
35 |
with gr.Column():
|
36 |
gr.Markdown("### Encode Hindi Text to Token IDs")
|
37 |
hindi_text_input = gr.Textbox(label="Enter Hindi Text")
|
38 |
token_ids_output = gr.Textbox(label="Token IDs (Encoded)", interactive=False)
|
39 |
encode_button = gr.Button("Encode")
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
with gr.Column():
|
42 |
gr.Markdown("### Decode Token IDs to Hindi Text")
|
43 |
token_ids_input = gr.Textbox(label="Enter Token IDs (comma-separated or list)")
|
44 |
decoded_text_output = gr.Textbox(label="Decoded Hindi Text", interactive=False)
|
45 |
decode_button = gr.Button("Decode")
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
encode_button.click(encode_text, inputs=hindi_text_input, outputs=token_ids_output)
|
48 |
decode_button.click(decode_tokens, inputs=token_ids_input, outputs=decoded_text_output)
|
49 |
|
50 |
-
app.launch()
|
|
|
30 |
# Gradio interface
|
31 |
with gr.Blocks() as app:
|
32 |
gr.Markdown("## Hindi Tokenizer Encoder-Decoder")
|
33 |
+
|
34 |
with gr.Row():
|
35 |
with gr.Column():
|
36 |
gr.Markdown("### Encode Hindi Text to Token IDs")
|
37 |
hindi_text_input = gr.Textbox(label="Enter Hindi Text")
|
38 |
token_ids_output = gr.Textbox(label="Token IDs (Encoded)", interactive=False)
|
39 |
encode_button = gr.Button("Encode")
|
40 |
+
|
41 |
+
# Example for encoding
|
42 |
+
encode_example = gr.Examples(
|
43 |
+
examples=["मेरा भारत महान", "गणितीय महत्व", "स्वतंत्रता दिवस"],
|
44 |
+
inputs=hindi_text_input,
|
45 |
+
outputs=token_ids_output,
|
46 |
+
fn=encode_text
|
47 |
+
)
|
48 |
+
|
49 |
with gr.Column():
|
50 |
gr.Markdown("### Decode Token IDs to Hindi Text")
|
51 |
token_ids_input = gr.Textbox(label="Enter Token IDs (comma-separated or list)")
|
52 |
decoded_text_output = gr.Textbox(label="Decoded Hindi Text", interactive=False)
|
53 |
decode_button = gr.Button("Decode")
|
54 |
+
|
55 |
+
# Example for decoding
|
56 |
+
decode_example = gr.Examples(
|
57 |
+
examples=["[23, 34, 45, 67]", "[102, 233, 45]", "[19, 78, 56, 112]"],
|
58 |
+
inputs=token_ids_input,
|
59 |
+
outputs=decoded_text_output,
|
60 |
+
fn=decode_tokens
|
61 |
+
)
|
62 |
+
|
63 |
encode_button.click(encode_text, inputs=hindi_text_input, outputs=token_ids_output)
|
64 |
decode_button.click(decode_tokens, inputs=token_ids_input, outputs=decoded_text_output)
|
65 |
|
66 |
+
app.launch()
|