Back to top

dNeural Computer Vision API

The dNeural API offers image recognition as a service. To get started, the only thing you need is a valid Application API key and the corresponding API secret. Create an account to get them.

Point your browser to dNeural Developer Dashboard to create your first app.

Overview

API clients

We recommend using a client library to access the API. Ready to use libraries are available for Python and PHP. However our REST API could be easily accessed through CURL.

Python client

To install the SDK from the Github sources you have to clone the repository.

git clone https://github.com/dneural/dneural-python.git

Then, you can install the SDK with:

python setup.py install

You can find few examples of using our API on GitHub page.

Accessing API

Overview

The dNeural API works through a REST interface. Requests are performed using standard HTTPS requests (GET or POST) to our API endpoint

https://api.dneural.com/2.0

All requests need to be signed. Your application API key and API signature needs to be passed as query parameteres named api_key and api_sig.

There are 2 different ways you can use the API, depending if you want to analyze a photo that is publicly accessible or a private photo.

To analyze a public photo, you will have to send us the public URL to the photo.

To analyze a private photo, you will have to send us the photo directly, via a POST request.

Please note:

dNeural supports JPG, PNG.

All files should not exceed 10 MB in size.

Authentication examples

PHP Example

Use the following code or use the forevermatt/calc-api-sig package via composer.

<?php
$key = 'YOUR APP API_KEY';       // insert Key Value received from API Developer Portal
$secret = 'YOUR APP API_SECRET'; // insert Key Secret received from API Developer Portal
$api_sig = hash_hmac('sha1', time().$key, $secret);

Python2 Example

import hmac
from hashlib import sha1
from time import time

key = 'YOUR APP API_KEY'      # insert Key Value received from API Developer Portal
secret = 'YOUR APP API_SECRET' # insert Key Secret received from API Developer Portal
curr_time = str(int(time()))
h1 = hmac.new(secret, curr_time+key, sha1)

api_sig = h1.hexdigest()

NodeJS Example

var crypto = require('crypto');

var apiKey = ...; // insert Key Value received from API Developer Portal.
var sharedSecret = ...; // insert Key Secret received from API Developer Portal.

var unixTimestamp = Math.floor(Date.now() / 1000);
var hmac = crypto.createHmac('sha1', sharedSecret);
var signature = hmac.update(unixTimestamp + apiKey).digest('hex');

Dominant Color extractor

Overview

This method returns density values for dominant colors present in images. Colors predicitions are returned in hex format and also mapped to their closest W3C counterparts.

Extract colors from URL
GET/2.0/color?api_key=&api_sig=

Extract dominant colors from image that is acccessible via HTTP

Example URI

GET https://api.dneural.com/2.0/2.0/color?api_key=&api_sig=
Request  Python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
url = "https://dneural.com/wp-content/uploads/2017/05/colors.jpg"
colors = app.color.check(url)

Extract colors from uploaded image
POST/2.0/color?api_key=&api_sig=

Extract dominant colors from image uploaded from your computer.

  • Python example
from dneural import DNeuralApp
app = DNeuralApp()
image_file = "./examples/images/colors.jpg"
colors = app.color.check(image_file)

Example URI

POST https://api.dneural.com/2.0/2.0/color?api_key=&api_sig=

Face detection

Overview

This method returns probability scores that image contains human face and cooridante locations of where face appear with a bounding box. Additionaly three more features are avaialable: Gender - Gender of the face and the confidence level in determination. Smile - Indicates whether or not the face is smiling, and the confidence level in determination. EyeOpen - Indicates wheter or not the eyes on the face are open, and the confidence level in the determination.

Extract face(s) from URL
GET/2.0/face?api_key=&api_sig=

Extract Face region and face features from image that is accessible via HTTP

Example URI

GET https://api.dneural.com/2.0/2.0/face?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
url = "https://dneural.com/wp-content/uploads/2017/05/face.jpg"
faces = app.face.check(url)
Response  200
HideShow
Body
{
  "face": [
    {
      "y1": 269,
      "x2": 527,
      "x1": 324,
      "y2": 472,
      "Features": {
        "Gender": {
          "Confidence": 0.98112,
          "Value": "Male"
        },
        "EyeOpen": {
          "Confidence": 0.33,
          "Value": 0
        },
        "Smile": {
          "Confidence": 0.52024,
          "Value": 1
        }
      }
    }
  ]
}

Extract face(s) from uploaded image
POST/2.0/face?api_key=&api_sig=

Extract face regions and face features from image uploaded from your computer.

Example URI

POST https://api.dneural.com/2.0/2.0/face?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
image_file = "./examples/images/face.jpg"
faces = app.face.check(url)
Response  200
HideShow
Body
{
  "face": [
    {
      "y1": 269,
      "x2": 527,
      "x1": 324,
      "y2": 472,
      "Features": {
        "Gender": {
          "Confidence": 0.98112,
          "Value": "Male"
        },
        "EyeOpen": {
          "Confidence": 0.33,
          "Value": 0
        },
        "Smile": {
          "Confidence": 0.52024,
          "Value": 1
        }
      }
    }
  ]
}

General Image classifier

Overview

This model recognizes over 1000 different types of images. Trained from ImageNet categories.

Classify image from URL
GET/2.0/classify/general?&api_key=&api_sig=

Classify an image that is acccessible via HTTP

Example URI

GET https://api.dneural.com/2.0/2.0/classify/general?&api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
url = "https://dneural.com/wp-content/uploads/2017/05/general.jpg"
data = app.classify.general(url)
Response  200
HideShow
Body
{
  "general": [
    {
      "class": "red fox, Vulpes vulpes",
      "value": 0.85359
    },
    {
      "class": "kit fox, Vulpes macrotis",
      "value": 0.07105
    },
    {
      "class": "grey fox, gray fox, Urocyon cinereoargenteus",
      "value": 0.01446
    },
    {
      "class": "dhole, Cuon alpinus",
      "value": 0.00085
    },
    {
      "class": "red wolf, maned wolf, Canis rufus, Canis niger",
      "value": 0.00068
    }
  ]
}

Classify uploaded image
POST/2.0/classify/general?&api_key=&api_sig=

Classify an image uploaded from your computer.

Example URI

POST https://api.dneural.com/2.0/2.0/classify/general?&api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
image_file = "./examples/general.jpg"
data = app.classify.general(url)
Response  200
HideShow
Body
{
  "general": [
    {
      "class": "red fox, Vulpes vulpes",
      "value": 0.85359
    },
    {
      "class": "kit fox, Vulpes macrotis",
      "value": 0.07105
    },
    {
      "class": "grey fox, gray fox, Urocyon cinereoargenteus",
      "value": 0.01446
    },
    {
      "class": "dhole, Cuon alpinus",
      "value": 0.00085
    },
    {
      "class": "red wolf, maned wolf, Canis rufus, Canis niger",
      "value": 0.00068
    }
  ]
}

Nudity tags

Categories

Every detected content or sexual activity have predefined category id. Nudity model returns information what type of content is visible on image. Here is full list of categories that could be returned by API.

category id name
n00000001 Rear
n00000002 Breasts
n00000003 Penis
n00000004 Female crotch
n00000010 Intercourse
n00000011 Breast
n00000023 Underwear
n00000024 Bra
n00000027 Legs and Stockings
n00000028 Leg and Stocking
n00000030 Male Torso

NSFW detection

The ‘NSFW’ (Not Safe For Work) model return probability scores on the likelihood that as image contains nudity. This model is great for anyone trying to automatically moderate or filter offensive content.

Overview

NSFW score from URL
GET/2.0/nude/nsfw?api_key=&api_sig=

Get NSFW score of image that is accessible via HTTP

Example URI

GET https://api.dneural.com/2.0/2.0/nude/nsfw?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
url = "https://dneural.com/wp-content/uploads/2017/05/nsfw.jpg"
nsfw_obj = app.nudity.nsfw(url)
Response  200
HideShow
Body
{
  "sfw": {
    "value": 0.29875
  },
  "nsfw": {
    "value": 0.70125
  }
}

NSFW score from uploaded image
POST/2.0/nude/nsfw?api_key=&api_sig=

Get NSFW score of image uploaded from your computer.

Example URI

POST https://api.dneural.com/2.0/2.0/nude/nsfw?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
image_file = "./examples/nsfw.jpg"
nsfw_obj = app.nudity.nsfw(image_file)
Response  200
HideShow
Body
{
  "sfw": {
    "value": 0.29875
  },
  "nsfw": {
    "value": 0.70125
  }
}

Nudity ROI

The ‘Nudity ROI’ (Region Of Interests) model returns a bounding box and probability scores on the likelihood that provided location contains nudity. Information about what type of nudity was detected is provided as well. For full list of categories check ‘Nudity tags’ section.

Overview

Nudity ROI from URL
GET/2.0/nude/roi?api_key=&api_sig=

Get nudity ROIs (Region Of Interests) of image that is accessible via HTTP

Example URI

GET https://api.dneural.com/2.0/2.0/nude/roi?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
url = "https://dneural.com/wp-content/uploads/2017/05/nsfw.jpg"
nsfw_obj = app.nudity.roi(url)
Response  200
HideShow
Body
{
  "roi": [
    {
      "category": "n00000004",
      "confidence": 0.99338,
      "x1": 211,
      "name": "Female crotch",
      "y1": 476,
      "x2": 437,
      "y2": 655
    },
    {
      "category": "n00000002",
      "confidence": 0.9864,
      "x1": 158,
      "name": "Breasts",
      "y1": 289,
      "x2": 495,
      "y2": 430
    },
    {
      "category": "n00000011",
      "confidence": 0.98001,
      "x1": 358,
      "name": "Breast",
      "y1": 291,
      "x2": 475,
      "y2": 408
    },
    {
      "category": "n00000011",
      "confidence": 0.97918,
      "x1": 165,
      "name": "Breast",
      "y1": 319,
      "x2": 309,
      "y2": 422
    }
  ]
}

Nudity ROI from uploaded image
POST/2.0/nude/roi?api_key=&api_sig=

Get nudity ROIs (Region Of Interests) of image uploaded from your computer.

Example URI

POST https://api.dneural.com/2.0/2.0/nude/roi?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
image_file = "./examples/nsfw.jpg"
nsfw_obj = app.nudity.roi(image_file)
Response  200
HideShow
Body
{
  "roi": [
    {
      "category": "n00000004",
      "confidence": 0.99338,
      "x1": 211,
      "name": "Female crotch",
      "y1": 476,
      "x2": 437,
      "y2": 655
    },
    {
      "category": "n00000002",
      "confidence": 0.9864,
      "x1": 158,
      "name": "Breasts",
      "y1": 289,
      "x2": 495,
      "y2": 430
    },
    {
      "category": "n00000011",
      "confidence": 0.98001,
      "x1": 358,
      "name": "Breast",
      "y1": 291,
      "x2": 475,
      "y2": 408
    },
    {
      "category": "n00000011",
      "confidence": 0.97918,
      "x1": 165,
      "name": "Breast",
      "y1": 319,
      "x2": 309,
      "y2": 422
    }
  ]
}

Automatic nudity moderation

Overview

Checks image for nudity and moderates its NSFW part. Link to NSFW version of image is provided. Please download result immediately and store it on your own CDN. All links will be unaviable within 24 hours.

Moderate image from URL
GET/2.0/nude/moderate?api_key=&api_sig=

Moderate an image that is accessible via HTTP

Example URI

GET https://api.dneural.com/2.0/2.0/nude/moderate?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
url = "https://dneural.com/wp-content/uploads/2017/05/nsfw.jpg"
moderated_obj = app.nudity.moderate(url)
Response  200
HideShow
Body
{
  "url": "https://storage.dneural.com/moderate/86/a0/86a0f2d54e08a2c4d5e4f636b2d1e93212c493e1c1427b3f76b648619c0c3ae4.jpg",
  "result": true
}

Moderate uploaded image
POST/2.0/nude/moderate?api_key=&api_sig=

Moderate an image uploaded from your computer.

Example URI

POST https://api.dneural.com/2.0/2.0/nude/moderate?api_key=&api_sig=
Request  python
HideShow
Body
from dneural import DNeuralApp
app = DNeuralApp()
image_file = "./examples/nsfw.jpg"
moderated_obj = app.nudity.moderate(image_file)
Response  200
HideShow
Body
{
  "url": "https://storage.dneural.com/moderate/86/a0/86a0f2d54e08a2c4d5e4f636b2d1e93212c493e1c1427b3f76b648619c0c3ae4.jpg",
  "result": true
}
adminDocumentation