File size: 1,299 Bytes
661526f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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() |