Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -50,9 +50,16 @@ def compare_tokenizers(tokenizer_name, text):
|
|
50 |
decoded_text = tokenizer.decode(encoded_output)
|
51 |
tokens_arabic = [token.encode('utf-8').decode('utf-8') for token in tokens]
|
52 |
|
53 |
-
# Prepare the results to be displayed
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
# Define the Gradio interface components with a dropdown for model selection
|
58 |
inputs_component = [
|
@@ -60,11 +67,7 @@ inputs_component = [
|
|
60 |
gr.Textbox(lines=2, placeholder="اكتب النص هنا...", label="Input Text")
|
61 |
]
|
62 |
|
63 |
-
outputs_component = gr.
|
64 |
-
headers=["Tokenizer", "Tokens", "Encoded", "Decoded"],
|
65 |
-
label="Results",
|
66 |
-
type="pandas"
|
67 |
-
)
|
68 |
|
69 |
# Setting up the interface
|
70 |
iface = Interface(
|
|
|
50 |
decoded_text = tokenizer.decode(encoded_output)
|
51 |
tokens_arabic = [token.encode('utf-8').decode('utf-8') for token in tokens]
|
52 |
|
53 |
+
# Prepare the results to be displayed in HTML format
|
54 |
+
results_html = f"""
|
55 |
+
<div>
|
56 |
+
<h3>Tokenizer: {tokenizer_name}</h3>
|
57 |
+
<p><strong>Tokens:</strong> {tokens_arabic}</p>
|
58 |
+
<p><strong>Encoded:</strong> {encoded_output}</p>
|
59 |
+
<p><strong>Decoded:</strong> {decoded_text}</p>
|
60 |
+
</div>
|
61 |
+
"""
|
62 |
+
return results_html
|
63 |
|
64 |
# Define the Gradio interface components with a dropdown for model selection
|
65 |
inputs_component = [
|
|
|
67 |
gr.Textbox(lines=2, placeholder="اكتب النص هنا...", label="Input Text")
|
68 |
]
|
69 |
|
70 |
+
outputs_component = gr.HTML(label="Results")
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# Setting up the interface
|
73 |
iface = Interface(
|