Skip to content
Style transfer API for PHP: An example HTML webpage for neural style transfer using the Deep Art Effects API.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
screenshots New screenshots Jun 7, 2017
.gitignore Changed demo site url Jun 8, 2017
client.php Initial commit Jun 7, 2017
composer.json Initial commit Jun 7, 2017
composer.lock Initial commit Jun 7, 2017
get_result.php Initial commit Jun 7, 2017
index.php Removed image size parameter Jun 8, 2017
list_styles.php Initial commit Jun 7, 2017
upload.php Removed image size parameter Jun 8, 2017

Deep Art Effects API Example For PHP

Here is an example on how you can use the Deep Art Effects API for PHP to display available styles, upload an image and get the result.

If you want to try out the example, change the values for the api_key, access_key and secret_key in client.php to your key values.

Try out the Online Demo

Screenshot-1 Screenshot-2 Screenshot-3


PHP 5.4.0 and later

Installation & Usage


To install the bindings via Composer, run the command

composer require deeparteffects/sdk-php

Manual Installation

Download the sdk files from Deep Art Effects SDK for PHP and include autoload.php:


Getting Started

First of all create an Deep Art Effects Client instance and insert your API-Key, your Access-Key and your Secret-Key.


require_once(__DIR__ . '/vendor/autoload.php');

$api_key = '--Your API KEY--';
$access_key = '--Your ACCESS KEY--';
$secret_key = '--Your SECRET KEY--';

$api_instance = new \Deeparteffects\Client\Api\DefaultApi();


Get a list of available styles

Next you want get a list of available styles using the stylesGet method. You get the id and a URL to an image representing the style.


try {
    $styles = $api_instance->stylesGet();
    foreach ($styles as $style) {
        $style_id = $style->getId();
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->stylesGet: ', $e->getMessage(), PHP_EOL;


Upload an image

To upload an image set the styleId you want and hand over the image binary data converted to Base64. In PHP you can convert data to Base64 using the base64_encode() function. After uploading the image you get a submissionId to check for the result.


try {
   $image = base64_encode(file_get_contents('/path/to/file'));
   $uploadRequest = new \Deeparteffects\Client\Model\UploadRequest();
   $result = $api_instance->uploadPost($uploadRequest);
   $submissionId = $result->getSubmissionId();
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->uploadPost: ', $e->getMessage(), PHP_EOL;


Check for the result

You can pass the submissionId to the resultGet function in order to receive a status for your submission. If your submission is in finished state, you can use the URL to download your artwork.


try {
    $result = $api_instance->resultGet($submissionId);
    $status = $result->getStatus();
    if($result->getStatus()=="finished") {
        echo $result->getUrl();
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->resultGet: ', $e->getMessage(), PHP_EOL;

You can’t perform that action at this time.