CoolFace
Apppublic

ipvikas/ImageProcessing

sourceHugging Faceupdated 1y agoView on Hugging Face
3likes
Deepface_analyze.py34 linesDownload Raw Back to root
1import gradio as gr2import pathlib3from deepface import DeepFace4 5#db_path='https://huggingface.co/spaces/ipvikas/ImageProcessing/blob/main/MyPhotos'6 7#db_path='https://huggingface.co/spaces/ipvikas/ImageProcessing/commit/c65e002550d4c148da1bb94c114373b2272f4d88#d2h-994579/'8db_path= [[path.as_posix()] for path in sorted(pathlib.Path('Image_DATA').rglob('*.j*g'))]9 10#from datasets import load_dataset11#db_path= load_dataset("imagefolder", data_files=db_path)12 13 14import pandas as pd15def get_deepface(image):16    df = DeepFace.find(img_path=image, db_path=db_path)17    d = DeepFace.analyze(img_path=image)18    #new_list = zip(d.keys(), d.values()) 19    #new_list = list(new_list)20    return d21 22description = "Deepface is a lightweight face recognition and facial attribute analysis (age, gender, emotion and race) framework for python. It is a hybrid face recognition framework wrapping state-of-the-art models: VGG-Face, Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace and Dlib."23 24facial_attribute_demo = gr.Interface(25    fn=get_deepface,26    inputs="image",27    outputs=['text'],28    title="face recognition and facial attribute analysis",29    description=description,30    enable_queue=True,31    examples=[["10Jan_1.jpeg"]],32    cache_examples=False)33 34#facial_attribute_demo.launch()