ImageProcessing / Deepface_analyze.py
ipvikas's picture
Update Deepface_analyze.py
bca9d85
raw
history blame contribute delete
No virus
1.3 kB
import gradio as gr
import pathlib
from deepface import DeepFace
#db_path='https://huggingface.co/spaces/ipvikas/ImageProcessing/blob/main/MyPhotos'
#db_path='https://huggingface.co/spaces/ipvikas/ImageProcessing/commit/c65e002550d4c148da1bb94c114373b2272f4d88#d2h-994579/'
db_path= [[path.as_posix()] for path in sorted(pathlib.Path('Image_DATA').rglob('*.j*g'))]
#from datasets import load_dataset
#db_path= load_dataset("imagefolder", data_files=db_path)
import pandas as pd
def get_deepface(image):
df = DeepFace.find(img_path=image, db_path=db_path)
d = DeepFace.analyze(img_path=image)
#new_list = zip(d.keys(), d.values())
#new_list = list(new_list)
return d
description = "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."
facial_attribute_demo = gr.Interface(
fn=get_deepface,
inputs="image",
outputs=['text'],
title="face recognition and facial attribute analysis",
description=description,
enable_queue=True,
examples=[["10Jan_1.jpeg"]],
cache_examples=False)
#facial_attribute_demo.launch()