Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import tensorflow as tf
|
|
6 |
from tensorflow import keras
|
7 |
from tensorflow.keras import layers
|
8 |
from tensorflow.keras.layers import TextVectorization
|
|
|
9 |
|
10 |
strip_chars = pickle.load(open('strip_chars.pkl', 'rb'))
|
11 |
|
@@ -141,8 +142,9 @@ train_spa_texts = [pair[1] for pair in train_pairs]
|
|
141 |
eng_vectorization.adapt(train_eng_texts)
|
142 |
spa_vectorization.adapt(train_spa_texts)
|
143 |
|
144 |
-
inputs = gr.inputs.Textbox(lines=1, label="Text in
|
145 |
-
outputs = [gr.outputs.Textbox(label="Translated text in
|
|
|
146 |
|
147 |
def get_translate(input_sentence):
|
148 |
spa_vocab = spa_vectorization.get_vocabulary()
|
@@ -161,6 +163,6 @@ def get_translate(input_sentence):
|
|
161 |
if sampled_token == "[end]":
|
162 |
break
|
163 |
return decoded_sentence.replace("[start]", "").replace("[end]", "")
|
164 |
-
iface=gr.Interface(fn=get_translate,inputs=inputs
|
165 |
|
166 |
iface.launch(debug=True)
|
|
|
6 |
from tensorflow import keras
|
7 |
from tensorflow.keras import layers
|
8 |
from tensorflow.keras.layers import TextVectorization
|
9 |
+
import pickle
|
10 |
|
11 |
strip_chars = pickle.load(open('strip_chars.pkl', 'rb'))
|
12 |
|
|
|
142 |
eng_vectorization.adapt(train_eng_texts)
|
143 |
spa_vectorization.adapt(train_spa_texts)
|
144 |
|
145 |
+
inputs = gr.inputs.Textbox(lines=1, label="Text in English")
|
146 |
+
outputs = [gr.outputs.Textbox(label="Translated text in Spanish")]
|
147 |
+
examples=["How are you"]
|
148 |
|
149 |
def get_translate(input_sentence):
|
150 |
spa_vocab = spa_vectorization.get_vocabulary()
|
|
|
163 |
if sampled_token == "[end]":
|
164 |
break
|
165 |
return decoded_sentence.replace("[start]", "").replace("[end]", "")
|
166 |
+
iface=gr.Interface(fn=get_translate,inputs=inputs, outputs=outputs, title='EnglishToSpanish Translator', examples=examples)
|
167 |
|
168 |
iface.launch(debug=True)
|