AIception, paint me like one of your French girls

Here is a nice thought:

What if one of the great painters (Picasso, van Gogh, Monet) was still alive?

Wouldn’t you be really excited to ask him/her to paint you?


Thanks to modern technology you can!

Morgan Starry


AIception has a public endpoint that will help “paint” any image in the “style” of any great painter.


Let’s get started!

We wish to implement it in Python but you can use your favorite programming language.

1. Create the following directory structure:


2. Get  <from the github here>.

3. Download and install Anaconda ( a great package, dependency and environment manager)

4. Create a virtual environment with Python 3.*

conda create -n blog_aiception_artistic python=3.5

5. Activate your new environment

source activate blog_aiception_artistic

6. Install extra packages like the requests HTTP library

pip install requests

7. Do your first API call

from aiception import *
from pprint import pprint

image_url = ",_2006_(cropped).jpg"

# call AIception API
r = face_age(token, image_url)

You get the following JSON response from the server:

{'answer': {'age': 60.5},
 'created_at': 'Fri, 17 Feb 2017 19:16:20 GMT',
 'image_url': ',_2006_(cropped).jpg',
 'state': 'done',
 'this_url': '',
 'type': 'face_age'}

Great! So the age of the man in the picture is 60.5 years old…wait…that’s not what we want… we want to get a painting!

Let’s use the correct endpoint now, artistic_image, and we need an extra parameter for the style of the image.

8. Call the artistic_image endpoint

from aiception import *

image_url = ",_2006_(cropped).jpg"
style_url = ""

# call AIception API (takes around 55 seconds)
r = artistic_image(token, image_url, style_url)

It will take a while (around 55 seconds) so please be patient.

You can’t rush art!

We receive the following JSON response that is a bit more complex than the first one:

   'created_at':'Fri, 17 Feb 2017 18:56:39 GMT',

The JSON contains 3 urls.

Each is the same stylized image at different stages (iterations) in the digital painting process. You cannot control this parameter (yet).


9. We want to be able to automatically download the received images.

We picked the one at iteration 300 because it looks better.

import shutil

# select the image at iteration '300'
image_url = [elem['image_url'] for elem in r['answer']['urls'] if elem['iteration'] == '300'][0]

# download the image
file_name = "my_image.png"
response = requests.get(image_url, stream=True)
with open(file_name, 'wb') as out_file:
    shutil.copyfileobj(response.raw, out_file)



Now it’s your turn!

Use this technology in your next great

  • mobile app
  • facebook app
  •  unity game

People will want their own photos/cats/dogs stylized.

Try the other endpoints:

r = face_age(token, image_url)
r = detect_object(token, image_url)
r = adult_content(token, image_url)
r = faces(token, image_url)

Mix and match the eye to catch…


Publish your own crazy idea that uses AIception API and if we love it we will share it on this blog as well!



Leave a Reply

Your email address will not be published. Required fields are marked *