Repository for the invertornot.com API that predicts if an image should be inverted for better dark-mode rendering. Some images (e.g., diagrams) can be easily inverted without losing legibility, while others (e.g., photographs) may become distorted or unrecognizable when inverted. This problem is difficult to solve using heuristics or rule-based approaches, as there can be many edge cases and exceptions. Using deep learning is a much better approach as the model is able to recognize the pattern that makes an image invertible or not.
The model is an EfficientNet fine-tuned on a custom dataset. The input is an image, and the output is a float in [0, 1] representing the probability that the image should be inverted (1 = invert, 0 = don't invert).
Endpoint | Method | Input | Output |
---|---|---|---|
/api/file |
POST | List of image files | List of {invert, sha1, error} for each file. |
/api/url |
POST | List of image URLs | List of {invert, sha1, error, url} for each URL. |
/api/sha1 |
POST | List of SHA1 hashes | List of {invert, sha1, error} for each SHA1. |
The API is built using FastAPI, and the model is run using ONNXRuntime for efficient inference.
This idea was taken from gwern