I would like to use serengil/deepface library to process a bunch of images. However, some of the extensions are not processed by deepface such as CR2 files. Some of the files in the db_path are also videos or misc files. Is there a way to check the extensions before applying DeepFace.find? Or perhaps narrow down it's finding to specific extensions. I would like to keep the folder intact rather than have a folder with pure JPG/PNG images.
def process_image(img):
dfs = DeepFace.find(img_path=os.path.join(source_path, img),
db_path=db_path,
enforce_detection=False,
detector_backend="retinaface",
model_name="ArcFace"
)
if len(dfs) > 0:
print("Match found for file:", img)
with open(os.path.join(matches_path, img.replace(".jpg", ".txt")), "w") as f:
f.write(str(dfs))