API description
API description
This API enables the use of the image review service. The image review service is an intelligent solution provided by Baidu AI Cloud, offering multidimensional image reviews, including pornography detection, violent and terrorism-related content identification, political sensitivity assessment, disgust image recognition, and advertisement detection, among others.
Note: To use this API, you need to enable the image review service on the console. For details, see [Enable Image Review Service](BOS/Console Operation Guide/Image Review Service.md).
Request
-
Request syntax
Plain Text1 POST /<ObjectName>?process HTTP/1.1 2 Host: <BucketName>.bj.bcebos.com 3 Date: <Date> 4 Authorization: <AuthorizationString> 5 Content-Type: application/json; charset=utf-8 6 Content-Length: <ContentLength> 7 { 8 "action" : { 9 "sync" : [{ 10 "url" : "$(img-censor)", 11 "parameters" : "<base64_encode(param)>", 12 } 13 ] 14 } 15 } -
Request parameters
- url: The fixed value is
$(img-censor), which should not be modified. -
parameters: Represents the base64-encoded value of the image review function parameters. These parameters remain formatted as JSON strings.
Basic structure of image review function parameters:
Plain Text1 { 2 "antiporn" : {}, 3 "terror" : {}, 4 "ocr" : { 5 "detect_direction" : "false", 6 "language_type" : "CHN_ENG", 7 "recognize_granularity" : "big" 8 } 9 }May be an arbitrary combination of multiple sub-services as needed, or a single sub-service such as "pornographic content detection", in which case the parameter is written as
Plain Text1{ 2 "antiporn" : {} 3}The list of sub-services supported by the image review service includes:
- ocr: General optical character recognition
- face: Face detection
- antiporn: Pornography recognition
- politician: Politician recognition
- terror: Violent terrorism recognition
- public: Public figure recognition
- disgust: Disgusting image recognition
- watermark: Watermark QR code recognition
- quality: Denotes image quality recognition values corresponding to underlying service parameters. Refer to the input parameters for the Hetu general optical character recognition (OCR) service for more details.
Detailed explanations of request and response parameters for sub-services are provided below.
- url: The fixed value is
-
Request headers
None
Response
-
Response headers
None
-
Response element
Refer to the explanations for response parameters of each sub-service.
Example
1{
2 "antiporn": {},
3 "ocr": {
4 "detect_direction": "false",
5 "language_type": "CHN_ENG",
6 "recognize_granularity": "big"
7 }
8}
After base64 encoding
1eyJhbnRpcG9ybiI6e30sIm9jciI6eyJkZXRlY3RfZGlyZWN0aW9uIjoiZmFsc2UiLCJsYW5ndWFnZV90eXBlIjoiQ0hOX0VORyIsInJlY29nbml6ZV9ncmFudWxhcml0eSI6ImJpZyJ9fQ==
Fill into parameters. The requests sent are as follows:
1POST /<ObjectName>?process HTTP/1.1
2Host: <BucketName>.bj.bcebos.com
3Date: <Date>
4Authorization: <AuthorizationString>
5Content-Type: application/json; charset=utf-8
6Content-Length: <ContentLength>
7{
8 "action" : {
9 "sync" : [{
10 "url" : "$(img-censor)",
11 "parameters" : "eyJhbnRpcG9ybiI6e30sIm9jciI6eyJkZXRlY3RfZGlyZWN0aW9uIjoiZmFsc2UiLCJsYW5ndWFnZV90eXBlIjoiQ0hOX0VORyIsInJlY29nbml6ZV9ncmFudWxhcml0eSI6ImJpZyJ9fQ==",
12 }
13 ]
14 }
15}
-
Successful response example
Plain Text1HTTP/1.1 200 OK 2Date: Thu, 22 Jun 2017 07:30:56 GMT 3Content-Type: application/json; charset=utf-8 4Content-Length: 237 5Connection: keep-alive 6Server: BceBos 7x-bce-debug-id: MTAuNzUuNzguNDA6VGh1LCAyMiBKdW4gMjAxNyAxNTozMDo1NiBDU1Q6MTg1MDY5NDg3OQ== 8x-bce-request-id: 598f7e18-77fb-424a-bc68-95acb0644076 9{ 10 "result" : { 11 "antiporn" : { 12 "result" : [{ 13 "probability" : 0.000071, 14 "class_name": "Pornography" 15 }, { 16 "probability" : 0.000291, 17 "class_name": "Sexy" 18 }, { 19 "probability" : 0.999638, 20 "class_name": "Normal" 21 } 22 ], 23 "log_id" : 1853911322, 24 "result_num" : 3 25 }, 26 "ocr" : { 27 "log_id" : 2471272194, 28 "words_result_num" : 2, 29 "words_result" : [{ 30 "words" : " TSINGTAO" 31 }, { 32 "words": "Qingdao" 33 } 34 ] 35 } 36 }, 37 "log_id" : 149811665151162 38} -
Failed response example
Plain Text1{ 2 "log_id": 149319909347709, 3 "error_code": 216500, 4 "error_msg": "unknown error" 5}Explanation on failed error_code:
Error code Error message Description 216101 not enough param Insufficient parameters 216102 service not support An unsupported underlying service type is entered 216200 empty imge No image URL 216500 unknown error Unknown error 282804 download image error Image download failed 282000 logic internal error Service logic layer error
