Spaces:
Runtime error
Runtime error
Download app.py from vickyG/Facial_Recognition_Test: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/vickyG/Facial_Recognition_Test/resolve/main/app.py
- Command line
-
hf download hf://spaces/vickyG/Facial_Recognition_Test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/vickyG/Facial_Recognition_Test/resolve/main/app.py
1.02 kB
| # import tensorflow | |
| # from keras.models import model_from_json | |
| import gradio as gr | |
| import tensorflow | |
| import pickle | |
| import os | |
| import tensorflow as tf | |
| from tensorflow import keras | |
| #Agregar red neuronal, función q la importe desde la carpeta creada | |
| model = tf.keras.models.load_model('model') | |
| image_size = 250 | |
| def predict_image(img): | |
| img_4d=img.reshape(-1,image_size,image_size,3) | |
| prediction=model.predict(img_4d, verbose=0)[0] | |
| print(prediction) | |
| return {"Victoria": float(prediction[i]) for i in range(1)} | |
| image = gr.inputs.Image(shape=(image_size,image_size)) | |
| label = gr.outputs.Label(num_top_classes=1) | |
| sample_images = [] | |
| base_dir = './examples/' | |
| for file in os.listdir(base_dir): | |
| if file == ".git" or file == ".ipynb_checkpoints": | |
| continue | |
| sample_images.append(base_dir + '/' + file) | |
| iface = gr.Interface(fn=predict_image, | |
| inputs=image, | |
| outputs=label, | |
| title="Self Facial Recognition", | |
| examples=sample_images) | |
| iface.launch() |