Spaces:
Runtime error
Runtime error
Commit ·
79e8362
1
Parent(s): 0cc1388
Create analysis_sentiment.py
Browse files- analysis_sentiment.py +17 -0
analysis_sentiment.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
def frase(Frase):
|
| 5 |
+
modelo = tf.keras.models.load_model("model_experiments_spanish/model_nlp_spanish_2")
|
| 6 |
+
#modelo.summary()
|
| 7 |
+
classes = ['alegría', 'amor', 'enojo', 'miedo', 'sorpresa', 'tristeza']
|
| 8 |
+
#sentences = [input("Ingrese frase:")]
|
| 9 |
+
modelo_preds = modelo.predict([Frase])
|
| 10 |
+
#print(modelo_preds)
|
| 11 |
+
print(f"The sentences contains: {classes[tf.argmax(tf.squeeze(modelo_preds))]}")
|
| 12 |
+
clas = classes[tf.argmax(tf.squeeze(modelo_preds))]
|
| 13 |
+
return clas
|
| 14 |
+
interface = gr.Interface(fn=frase,inputs='text',outputs='text')
|
| 15 |
+
interface.launch(inplace=False)
|
| 16 |
+
|
| 17 |
+
|