A python program that uses Amazon Rekognition and Amazon Translate (with boto3) to get labels for pictures and recognizes faces.
Explore the docs »
·
Report Bug
·
Request Feature
I used to store my photos at Google Photos. But recently I switched to PhotoPrism. It is under heavy development, but I missed two things at the moment:
- PhotoPrism adds labels to every picture like "sunset" or "tree", but they are only in English.
- PhotoPrism has no face recognition like Google Photos. But when i.e. I add a picture of my kids I want to get it automatically tagged with their names, so I can search for it.
Until PhotoPrism will add the features to the core program, I wrote a little program to add that functionality. It will of course work without PhotoPrism and with every picture library which reads exif date. The information I add to my pictures is stored in the keywords of the exif data.
Tag-my-picture integrates in my workflow:
- Pictures I take are synchronized to a folder in my dropbox.
- A small bash script on my home server watches this folder for changes.
- When a new picture arrives, tag-my-picture is started.
- Afterwards it is moved to PhotoPrism using the WebDav access.
This is my first contribution to the Open Source Community and on GitHub, so probably I did some things wrong or could do better. Please feel free to contact me and give me some advice.
Please take care! You should always keep a copy of your original pictures, because tag-my-picture changes the exif data. If something weird happens, you don't want to lose your pictures.
At the moment, tag-my-pictures is probably only useful to people, who can code in Python. It is not user friendly or working from the shell.
To get a local copy up and running follow these steps.
- You have to setup AWS Rekognition. Please follow the steps in the AWS documentation. Be aware that AWS Rekognition is not for free. You can get a free trial period, but please read the AWS documents carefully. AWS Translate is also not for free.
- You need to install two python libraries:
pip3 install boto3 pip3 install pillow
- Clone the repo
git clone https://github.com/streiman/tag-my-picture.git
- Change the variables in tag-my-pictures.py according to your paths.
You need to create two folders:
- One to store the faces of the people you know and want to recognize. You could for example use the folder /home/me/faces. In this folder you create subfolders for every person, for example
- Peter
- Paul
- Mary
- A folder where faces of unknown persons are copied, like /home/me/_unknown. You can use them to create new persons in your /home/me/faces-folder or you can delete them, if they are not important to you.
And you have to tell tag-my-pictures where the pictures are stored you want to process. If you run tag-my-pictures, all files in this folder will be read, one by one. If it is a picture like jpg, it will be processed.
First AWS Rekognition will be asked for labels for this picutre. The retrieved labels are then translated to German (you could change the language in the code). Because labels are recurring in many pictures, the translation is also saved in a local file. If an English label is found there, it will be used. Otherwise Amazon Translate is asked for the translation. You can also edit this file to get better translations.
If the picture has a label "person" or "human", the picture is afterwards sent to face detection. First all faces on the picture are cropped and saved in temporary files. Then they are queried against all the faces you stored in your /home/me/faces-folder, which is stored as a so called collection at AWS Rekognition and updated at the start of the program. So you can add new people by just creating subfolders and adding pictures, everything else happens in the background.
If a face is recognized, the name of the person (the name of the subfolder where the picture is stored) is saved in the exif keywords.
See the open issues for a list of proposed features (and known issues).
I will try to make tag-my-picture more userfriendly.
I will also try to use different services for
- labelling
- translation
- face recognition
Feel free to make tag-my-picture better and useful for you.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Andreas - @astreim - [email protected]
Project Link: https://github.com/streiman/tag-my-picture