Skip to content
Advertisement

How do I get the face_recognition encoding from many images in a directory and store them in a CSV File?

This is the code I have and it works for single images:

Loading images and apply the encoding

JavaScript

Face encodings are stored in the first array, after column_stack we have to resize

JavaScript

Convert array to pandas dataframe and write to csv

JavaScript

How do I loop over the images in ‘Folder’ and extract the encoding into a csv file? I have to do this with many images and cannot do it manually. I tried several approaches, but none a working for me. Cv2 can be used instead of load_image_file?

Advertisement

Answer

Try this

Note: I am assuming you dont need to specify folder path before file name in your command. This code will show you how to iterate over the directory to list files and process them

JavaScript

You can then convert to pandas and export to csv. Let me know how it goes

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement