Help Center/
Content Moderation/
SDK Reference/
Using the Python SDK/
SDK Calling Example/
Moderation (Image)/
Image Moderation (Asynchronous Batch) (V2)/
Querying a Task
Updated on 2023-07-17 GMT+08:00
Querying a Task
- This section describes how to use the Image Moderation (Asynchronous Batch) SDK for querying a task by AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. Set job_id in RunCheckResultRequest to configure the ID of the moderation task, and then execute the code.
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmoderation.v2.region.moderation_region import ModerationRegion from huaweicloudsdkmoderation.v2 import * from huaweicloudsdkmoderation.v2 import ModerationClient,RunCheckResultRequest if __name__ == "__main__": //Enter your AK/SK. ak = "<YOUR AK>" sk = "<YOUR SK>" credentials = BasicCredentials(ak, sk) client = ModerationClient.new_builder() \ .with_credentials(credentials) \ .with_region(ModerationRegion.value_of("xxx")) \ //Replace xxx with the region where the service is located. .build() try: request = RunCheckResultRequest() request.job_id = "xxx" //Enter your job ID. response = client.run_check_result(request) print(response.status_code) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- If 200 is displayed on the console, the code is successfully executed. The result of querying the Image Moderation (Asynchronous Batch) task is displayed on the console.
200 {'result': {'create_time': '2021-08-04T08:30:41Z', 'items': [{'category_suggestions': { 'porn': 'pass', }, 'detail': { 'porn': [{'confidence': 0.9883, 'label': 'normal'}, {'confidence': 0.0039, 'label': 'porn'}, {'confidence': 0.0078, 'label': 'sexy'}], 'suggestion': 'pass', 'url': 'https://sdk-obs-source-save.obs.cn-north-4.myhuaweicloud.com/terrorism.jpg'}], 'job_id': 'xxx', 'status': 'finish', 'update_time': '2021-08-04T08:30:41Z'}} Process finished with exit code 0
Parent topic: Image Moderation (Asynchronous Batch) (V2)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot