Spaces:
Build error
Build error
"""import os | |
os.environ["SM_FRAMEWORK"] = "tf.keras" | |
os.environ['CUDA_VISIBLE_DEVICES'] = '0' | |
os.environ['NUMBAPRO_NVVM']='/share/pkg.7/cuda/11.2/install/nvvm/lib64/libnvvm.so' | |
os.environ['NUMBAPRO_LIBDEVICE']='/share/pkg.7/cuda/11.2/install/nvvm/libdevice/' | |
import segmentation_models as sm | |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'""" | |
import tensorflow as tf | |
import keras | |
import keras_vggface | |
from keras_vggface.vggface import VGGFace | |
import mtcnn | |
import numpy as np | |
import matplotlib as mpl | |
from keras.utils.data_utils import get_file | |
import dlib | |
import keras_vggface.utils | |
import PIL | |
import os.path | |
os.environ['KMP_DUPLICATE_LIB_OK']='True' | |
from deepface import DeepFace | |
import pandas as pd | |
import sys | |
import gradio as gr | |
from PIL import Image | |
models = [ | |
"VGG-Face", | |
"Facenet", | |
"Facenet512", | |
"OpenFace", | |
"DeepFace", | |
"DeepID", | |
"ArcFace", | |
"Dlib", | |
"SFace", | |
] | |
def db_find(path, db="database", model=0, thresh=.25): | |
m = model | |
dfs = DeepFace.find(img_path=path, db_path=db, model_name=models[m], detector_backend="mtcnn", enforce_detection=False) | |
df = dfs[0].copy() | |
df = df.drop(columns=['source_x', 'source_y', 'source_w', 'source_h']) | |
df['id'] = df['identity'].str.strip("atfalmafkoda_unzip/database/person").str.split("/") | |
df['id'] = df['id'].apply(lambda x: x[0]) | |
img_len = df.loc[df["VGG-Face_cosine"] < .3].shape[0] | |
imgs = df.head(img_len)['identity'].tolist() | |
return df.loc[df["VGG-Face_cosine"] < .3], imgs | |
demo = gr.Interface(fn=db_find, inputs="image", outputs=["dataframe", "gallery"]) | |
demo.launch() | |