A2RL_online should be used instead of A2RL, A2RL_online supports urls as input and is much faster than A2RL.


[Project] [Paper] [Online Demo] [API] [Related Work: GP-GAN (for Image Blending)]

sourcestep 1step 2step 3step 4step 5output

A2-RL (aka. Aesthetics Aware Reinforcement Learning) is the author's implementation of the RL-based automatic image cropping algorithm described in:

A2-RL: Aesthetics Aware Reinforcement Learning for Automatic Image Cropping   
Debang Li, Huikai Wu, Junge Zhang, Kaiqi Huang

Given a source image, our algorithm could take actions step by step to find almost the best cropping window on source image.



For client users, the input is a list of bytearray reading from image files.

input = bytearray(open('xxx.jpg', 'rb').read())
result = algo.pipe([input]).result

For web (javascript) users, the input is a dict with 'xxximagexxx' as the keys and base64 string of the images as the values.

<input id="file-input" type="file" name="name" style="display: none;"/>
document.getElementById('file-input').onchange = function (evt) {
        var tgt = evt.target || window.event.srcElement;
        files = tgt.files;
        // FileReader support
        if (FileReader && files && files.length) {
            var reader = new FileReader();
            reader.onload = function () {
                           .pipe({'super_image_a': reader.result})
                           .then(function(output) {
        } else {
            // Not supported


output.result = [[xmin, ymin, xmax, ymax], [xmin, ymin, xmax, ymax], ..., [xmin, ymin, xmax, ymax]]



Writing good docs:

Communicate Value

A good introduction should make it clear why someone might use your API.

Show and Tell

Give examples of using your API and explain those examples.

Easy to Skim

Ensure your docs are structured such that familiar users can quickly jump to the content they want.


Revisit your docs after making breaking changes or adding new features to keep them up-to-date.