Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ from tensorflow.keras.models import load_model
|
|
| 17 |
import classifier_data_lib
|
| 18 |
import tokenization
|
| 19 |
import joblib
|
|
|
|
| 20 |
|
| 21 |
print("NumPy Version:", np.__version__)
|
| 22 |
print("TensorFlow Version:", tf.__version__)
|
|
@@ -74,12 +75,17 @@ def preprocess_new_data(texts):
|
|
| 74 |
dataset = dataset.prefetch(tf.data.experimental.AUTOTUNE)
|
| 75 |
|
| 76 |
return dataset
|
| 77 |
-
def launch(
|
| 78 |
# Load the label encoder
|
| 79 |
label_encoder = joblib.load('label_encoder.joblib')
|
| 80 |
|
| 81 |
# Preprocess the new data
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
new_data_dataset = preprocess_new_data(sample_example)
|
| 84 |
|
| 85 |
# Assuming you have a model already loaded (add model loading code if needed)
|
|
|
|
| 17 |
import classifier_data_lib
|
| 18 |
import tokenization
|
| 19 |
import joblib
|
| 20 |
+
from deep_translator import GoogleTranslator
|
| 21 |
|
| 22 |
print("NumPy Version:", np.__version__)
|
| 23 |
print("TensorFlow Version:", tf.__version__)
|
|
|
|
| 75 |
dataset = dataset.prefetch(tf.data.experimental.AUTOTUNE)
|
| 76 |
|
| 77 |
return dataset
|
| 78 |
+
def launch(text_input):
|
| 79 |
# Load the label encoder
|
| 80 |
label_encoder = joblib.load('label_encoder.joblib')
|
| 81 |
|
| 82 |
# Preprocess the new data
|
| 83 |
+
try:
|
| 84 |
+
text_input = GoogleTranslator(source = 'auto',target = 'en').translate(text_input)
|
| 85 |
+
except:
|
| 86 |
+
text_input = text_input
|
| 87 |
+
|
| 88 |
+
sample_example = [text_input]
|
| 89 |
new_data_dataset = preprocess_new_data(sample_example)
|
| 90 |
|
| 91 |
# Assuming you have a model already loaded (add model loading code if needed)
|