Commit ·
f569fb0
1
Parent(s): 7552538
initial commit
Browse files
CNN4G7.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:baaba075bc20b769d11c86c6a0ba334c6c24b1b6723bf7b4d6e8cbe398270177
|
| 3 |
+
size 53852952
|
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import tensorflow as tf
|
| 4 |
+
|
| 5 |
+
IMG_SIZE = 48
|
| 6 |
+
CLASSES = ['angry', 'disgust', 'fear', 'happy', 'neutral', 'sad', 'surprise']
|
| 7 |
+
|
| 8 |
+
model = tf.keras.models.load_model('CNN4G7.h5')
|
| 9 |
+
|
| 10 |
+
def preprocess_image(image):
|
| 11 |
+
return image.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
|
| 12 |
+
|
| 13 |
+
def predict_face_expression(image):
|
| 14 |
+
image = preprocess_image(image)
|
| 15 |
+
prediction = model.predict(image)
|
| 16 |
+
return {CLASSES[i]: float(prediction[0][i]) for i in range(len(CLASSES))}
|
| 17 |
+
|
| 18 |
+
with gr.Blocks() as app:
|
| 19 |
+
gr.Markdown('Sistema de identificación de emociones basado en procesamiento de imágenes usando técnicas de Machine Learning')
|
| 20 |
+
|
| 21 |
+
with gr.Tab('Image'):
|
| 22 |
+
with gr.Row():
|
| 23 |
+
image_input = gr.Image(shape=(IMG_SIZE, IMG_SIZE), image_mode='L')
|
| 24 |
+
image_button = gr.Button('Submit')
|
| 25 |
+
|
| 26 |
+
image_button.click(predict_face_expression, inputs=image_input, outputs=gr.outputs.Label(num_top_classes=3))
|
| 27 |
+
|
| 28 |
+
app.launch()
|