imgcache: a caching server for image classification
imgcache
is an OpenResty application which caches and rate limits requests to any facial analysis API. See conf/config.lua
for configuration options. While imgcache currently depends on Redis, with trivial modifications you could use the shared dictionary as the only backing store. As a consequence, the shared dictionary would lose all cached results whenever the nginx server is restarted.
Why
Sometimes moderators have a life. This can be a problem if you don’t. If you browse reddit, or other image-sharing sites, at odd hours you know that undesirable content can slip through while the moderators sleep. The default configuration of imgcache hides images that either the Microsoft Computer Vision API or the Amazon Rekognition API consider adult content. The problem is that Microsoft and Amazon limit API requests unless you want to spend a lot of money. And I don’t care enough to spend a lot of money. So imgcache queues classification requests, limits the rate, distributes requests to available workers and stores all the classification information for each image. I have since written an improved version in C# that runs in Azure (as a service or as functions). It uses their NoSQL storage to persist classification results. Finally, the Chrome extension now uses local storage to cache results in the browser. I find that the accuracy rate of these services is very good, although they often err on the safe side.