Neural Art

Posted by Jeremy Kun

Neural Art

Neural Art is a bitcoin-payable endpoint that uses deep learning to render images in the style of famous art. Here is an example styling Dorian Nakamoto as a mosiac.

Content image:

style transfer example

Style image:

style transfer example

Output image:

style transfer example

API usage

There are three API endpoints:

  • /quote: POST that accepts the same data as /buy, and returns the price of that call.
  • /buy: POST that accepts data and returns a token for redeeming the output.
  • /redeem: GET that accepts the token and, if the comptuation is finished, returns an imgur link to the output. If the computation is still going, it returns a 'keep waiting' message.

Quote call:

21 buy 21dotco/neural_art/neuralart/quote --data '{"style":"", "content":""}'

Quote output (in satoshis):

    "price": 212500

Purchase command:

21 buy 21dotco/neural_art/neuralart/buy --data '{"style":"", "content":""}' --maxprice 250000

Purchase output:

    "token": "w8nj8"

This returns a token which you can use to redeem your image when the computation finishes. For typical parameter choices this takes 10-30 minutes.

Redeem call:

21 buy ""

Redeem output (when finished):

    "message": "Thanks!",
    "status": "finished",
    "url": ""

Parameter details

The buy parameters are:

  • style: a url to a jpg file that will be the style image.
  • content: a url to a jpg file that will be the content image.
  • width: the width of the output image, between 100 and 700 pixels. Defaults to 500.
  • iterations: the number of iterations, between 1 and 2000 iterations. This is the main complexity tuner, with 1000 iterations taking ~15 minutes. Defaults to 1000, though you can get good results with as few as 200.
  • style-scale: A parameter between 0.0 and 2.0 controlling the emphasis on the style. Defaults to 1.0
  • starting-image: Either "image" or "random" determining where to start the optimization. Using "random" starts with a white noise image, using "image" starts with the content image.

How to send your Bitcoin to the Blockchain

Just as a reminder, you can send bitcoin mined or earned in your balance to the blockchain at any time by running 21 flush . A transaction will be created within 10 minutes, and you can view the transaction id with 21 log. Once the transaction has been confirmed, you can check the balance in your bitcoin wallet from the command line with wallet balance, and you can send bitcoin from your wallet to another address with wallet sendto $BITCOIN_ADDRESS --satoshis $SATOSHI_AMOUNT --use-unconfirmed. The --satoshis flag allows you to specify the amount in satoshis; without it the sendto amount is in BTC, but this behavior is deprecated and will be removed soon. The --use-unconfirmed flag ensures that you can send even if you have unconfirmed transactions in your wallet.

Ready to sell your endpoint? Go to

Ready to try out your bitcoin-payable server in the wild? Or simply want to browse and purchase from other bitcoin-enabled servers? Head over to the 21 Developer Community at to join the bitcoin machine-payable marketplace hosted on the 21 peer-to-peer network.