Picture Moderation

The picture moderation aims to recognize malicious information in pictures, and give the moderation results and handling suggestions.

1. Introduction

The caller submits pictures for moderation, and specifies the detection type. Then the server returns the calling result synchronously.

Detection types and their labels are listed below:

Detection Type Description Action Primary Label Secondary Label
Porn recognition Recognize porn and sexy contents in pictures porn
normal: normal normal: normal
sexy: sexy female_underwear: female underwear
female_sexy_chest_l12: female sexy chest level 12
female_sexy_chest_l3: female sexy chest level 3
female_sexy_chest_l4: female sexy chest level 4
female_backless: female backless
female_sexy_leg: female sexy leg
female_focus_leg: female focus leg
bathing_suit: bathing suit
male_topless: male topless
male_normal_topless: male normal topless
other_sexy: other sexy
porn: porn sex_product: sex aids
naked_private_part: exposed sensitive parts
extensive_naked: extensive naked
sex_behavior: sex behavior
naked_female_back: naked famale back
naked_hip: naked hip
sex_bulge: sex bulge
focus_female_crotch: focus female crotch
focus_male_crotch: focus male crotch
hand_on_sexy: hand on sexy
lick: lick
kiss: kiss
sm: SM
sperm: sperm
naked_child: naked child
other_dirty: other dirty
tongue_out: tongue out
female_focus_hip: female focus hip
male_underwear: male underwear
porn_pip: porn pip
Terrorism recognition Recognize bloody and terrorism contents in pictures terrorism normal: normal
fire_explosion: fire explosion
gun: gun
knife: knife
crowd: crowd
flag_of_terrorism: flag of terrorism
special_dress: special dress
disgusted: disgusted
with_weapon: with weapon
bloody: bloody
uniform: uniform
nil
Sensitive information recognition Recognize sensitive contents in pictures antispam normal: normal
special_building: special building
rmb: RMB
map_of_China: map of China
cartoons_of_leaders: cartoons of leaders
flags_of_China: flags of China
Tibetan_buddhism: Tibetan buddhism
other_antispam: Other sensitive information
tank: tank
fighter: fighter
cannon: cannon
battleship: battleship
nil
Sensitive figure recognition Recognize domestic and overseas politicians, and public figures in pictures sface normal: normal
sface: sensitive figure involved
nil
Illegal recognition Identify whether the picture contains illegal scene information illegal normal: normal
minor: minor
drug: drug
drive: drive
gamble: gamble
smoke: smoke
id_infomation: id infomation
tattoo: tattoo
nil
AD recognition Identify whether the image contains advertising information ad normal: normal
QR_code: QR code
bar_code: bar code
applet_code: applet code
nil
OCR recognition Identify whether the image contains suspected ad text information ocr normal: ocr
ocr_ad: ocr ad
nil

2. Restrictions

CategoryDescription
Source of pictures1) Picture URL starting with HTTP/HTTPS
2) Base64 coded string of picture binary stream
Picture sizeSingle picture smaller than 10 MB, and single request smaller than 50 MB.
Picture pixelSupport png, jpg, jpeg, and bmp. For more picture formats, please contact the technical support.
Picture formatSupport png, jpg, jpeg, and bmp. For more picture formats, contact customer support.
Timeout limitThe picture download timeout is limited to 10 seconds. Please ensure that the picture storage service is stable and reliable; it is recommended that the user-side interface call timeout control is 20s.
Concurrency restrictionDefault 20qps(Process 20 pictures per second). You can submit up to 5 pictures in each request. For higher qps capabilities, please contact the technical support.
Area restrictionOnly in Chinese mainland. For support in other countries and regions, please contact the technical support.

3. API Description

3.1 Initiate a Request

Send a moderation request using HTTP POST

ItemDescription
Request methodPOST
Request protocol HTTPS
Request domain nameai.jocloud.com
Request path/app/{appid}/v1/image/sync?traceId=uuid-xxxx-xxxx-xxxx-xxxx
Request parameterstraceId is a uuid string, and used for problem positioning during troubleshooting. It is suggested to use different values for each request.
Request headerContent-Type: application/json;charset=UTF-8
token: authentication token; see its generation method in Identity Authentication
Request bodyjson character string, defined as follows
NameTypeRequiredDescription
actionsString arrayYesDetection type. Options include:
- porn: porn recognition
- terrorism: terrorism recognition
- antispam: sensitive information recognition
- sface: sensitive figure recognition
- illegal: illegal scene information recognition
- ad: ad information recognition
- ocr: ocr information recognition
data[]JSON arrayYesSpecify the detection object information list. Each element in the JSON array is a detection object structure (see the request data table below).
At most 5 pictures processed for a single callback.

Table: Request Data

NameTypeRequiredDescription
dataIdStringYesData unique identifier, for example: uuid-xxxx-xxxx-xxxx-xxxx
dataTypeStringYesData type
- URL: URL starting with HTTP/HTTPS
- BASE64: BASE64 encoded string of binary stream
contentStringYesPicture content to be detected
(e.g., enter URL for the dataType field, and enter picture URL for the content field)
contextJSONNoUser-defined context data, automatically provided when a result is returned.

3.2 Response Result

The response content is a json object, as defined below

NameTypeRequiredDescription
codeIntegerYesError code. See the description of error code, Error code in request
messageStringYesError message description
traceIdStringYestraceId content in the pass-through request parameter
requestIdStringYesThe system generates a unique task identifier specific to this detection request
timestampIntegerYesCurrent unix timestamp (s)
data[]JSON arrayNoDetection result data list (for specific structure, see the table of returned data below). Each item in the array represents a processing result of one image, and this field may be empty in case of errors.

Table: Returned Data

NameTypeRequiredDescription
codeIntegerYesError code. See the description of error code, Error code in data and action
messageStringYesError message description
dataIdStringYesMap to dataId in the request
taskIdStringYesA unique task identifier generated for multiple detection types of this detection object
contextJSONNoMap to context in the request
results[]ArrayNoReturn the result data. When the callback succeeds (code==200), the return result contains one or more elements. Each element represents the processing result of one action, and its specific structure is shown in the table "Result" below.

Table: Result

NameTypeRequiredDescription
codeIntegerYesError code. See the description of error code, Error code in data and action
messageStringYesError message description
actionStringYesDetection type, mapping to the detection type (actions) in the call request
labelStringYesDetection result primary label; its value is related to action. For specific values, see above moderation types and corresponding label specification table.
rateFloating-point numberYesProbability of detection result label, with the value ranging between [0.00 – 1.00]. The larger the value, the higher the credibility.
suggestionStringYesOperation recommended, with the value options:
- pass: normal, requiring no operation;
- block: illegal, suggested to give punishment on illegal contents;
- review: suspected; the detection result is uncertain and requires further manual moderation.
extraData[]JSON arrayNoWhen action is terrorism, and antispam, this field does not exist
The array element of sensitive figure recognition (sface) is detected face information.
See details in the table "Sface-ExtraData" and "Porn-ExtraData".

Table: sface-extraData

NameTypeRequiredDescription
labelStringYesDetected face label
rateFloating-point numberYesProbability of detection result label, with the value ranging between [0.00 – 1.00]. The larger the value, the higher the credibility.
nameStringYesDetected name of sensitive figure
xIntegerYesX-coordinate of the upper left corner of the detected face in the picture
yIntegerYesY-coordinate of the upper left corner of the detected face in the picture
wIntegerYesWidth of detected face
hIntegerYesHeight of detected face

Table: porn-extraData

NameTypeRequiredDescription
labelStringYesDetected secondary label
rateFloating-point numberYesProbability of detection result label, with the value ranging between [0.00 – 1.00]. The larger the value, the higher the credibility.

4. Call Sample

The following shows the sample code of calling with python3:

# -*- coding: utf-8 -*-
# ! python3.6

import requests
import uuid
import base64

host = "https://ai.jocloud.com"

appid = 123456789                                 # Your Service id
restful_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'       # Your certificate ID
restful_secret = 'ssssssssssssssssssssssssssssss' # Your certificate key
traceid = str(uuid.uuid4())                       # TraceId for this request
dataid = str(uuid.uuid4())                        # Request data dataId
dataUrl = "http://xxxx"                           # Request data URL

# url
url = host + '/app/%s/v1/image/sync?traceId=%s' % (appid, traceid)

# headers
headers = {
    "content-type": "application/json"
}
auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + auth.decode()

# content
values = {
    'actions': ['porn'],
    'data': [
        {
            'dataType': 'URL',
            'content': dataUrl,
            'dataId': dataid,
            'context': {'uid': 12345}
        }
    ]
}

# request
res = requests.post(url, json=values, headers=headers)
print('code=%s, data=%s\n' % (res.status_code, res.text))

Response content


{
  "code": 200,
  "message": "OK",
  "traceId": "3913f59e-8a93-4864-932f-c3fc1b184ad4",
  "requestId": "907590fc-2d79-4189-ad3d-2c85d99e5b6f",
  "timestamp": 1583932046,
  "data": [
    {
      "code": 200,
      "message": "OK",
      "dataId": "13878ee2-1872-4fcd-87bb-b0619bbc7572",
      "taskId": "8ccddb5d-992c-4f1d-bc38-5e6dbe97a61a",
      "context": {
        "uid": 12345
      },
      "results": [
        {
          "action": "porn",
          "code": 200,
          "label": "normal", // Primary Label
          "message": "OK",
          "rate": 0.9994381666183472,
          "suggestion": "pass",
          "extraData": [
              {
                  "label":"normal", // Secondary Label
                  "rate":0.9994381666183472
              }
          ]
        }
      ]
    }
  ]
}

5. Version Description

VersionTimeDescription
v2.2.02020-08-31Add ad and ocr recognition; Update labels of 'terrorism' and 'antispam' recognition
v2.1.02020-08-24Add illegal recognition
v2.0.02020-08-17Add secondary labels in the porn recognition
V1.0.02020-03-13Initial version

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top
<