Hello! I present to you a simple Python project that I've been working on for some time. This is a recommendation system for e621 that works by analyzing tags from your favorites and comparing them with the latest posts.
https://github.com/DestroyingFilms/e6-Recommendation-System
The algorithm itself is not that complex, but the whole application is a GUI app, which tries to automate the whole process. As I've described in my repository, it works by following these steps:
1. Request profile (username, API key)
2. Read and use settings (blacklist, default post rating, etc.)
3. Download favorited & latest posts
4. Compare and give grades to all the latest posts with favorite ones
After that, the recommendations are complete with preview images being displayed on the main window for the top results.
I will briefly write about each of those steps, as more in-depth information can be found in the GitHub repository that I've provided above.
1. Request profile
The application will ask for your e621 username and API key. The API key is optional, as long as you have your favorites NOT hidden, but if you do, then you have to provide it to the app.
The username is kept in the local config.json file, created in the root directory of the application. However, the API key is hidden, only kept in the encrypted form in the OS itself by using keyring backend.
2. Read and use settings
There is an option menu in the GUI, which has configuration that you can modify, such as a blacklist (tags that will not be recommended to you), minimum score threshold (a min score that the post must have to be recommended), default post rating (a rating that the post must have to be recommended), and much more. Those options are saved to config.json.
Content that is commonly considered objectionable is blacklisted by default, some of which are ALWAYS blacklisted. Additionally, the default post rating is set to "Safe", which will only use "Safe" recent posts for recommendations.
3. Download favorited & latest posts
As the application uses the API service of e621, which has some limits, it is best to download the needed data for favorite posts and latest ones to a local folder. So that it can be used later without needing to send the same request to the API twice or even more. The only data which is needed from those posts is an ID and a list of tags (with a url for a preview image and a file extension of the original post additionally being used for latest posts).
4. Compare and give grades
And finally the recommendation system itself, which uses a simple cosine similarity function to find the best match for each post. What might be important to point out is how the app saves the results, as the top 30 recommendations will have preview images downloaded locally and encoded in base64 to keep in the results.json file. This is once again done to not overflow the API service with useless requests every time the preview image needs to be loaded.
This is pretty much it. As I wrote in the repository, this is a hobby project made in my free time, so there is probably some bugs that I've overlooked and haven't fixed yet. But I am open to criticism and would be glad to hear feedback. I don't guarantee that I will regularly fix issues and bugs. But, I will try my best to fix whatever would be possible once I have enough time for it.
Hope you will still enjoy this simple tool. And have a nice day!