Content Moderation
Content Moderation
- What's New
- Product Bulletin
- Service Overview
- Getting Started
- User Guide
- API Reference
-
SDK Reference
- Introduction to Moderation SDK
- Applying for a Service
- Obtaining Authentication Information
- Preparing the Environment
- Using the SDK (Java)
- Using the Python SDK
- Using the .NET SDK
- Using the Go SDK
-
FAQs
- Service Enabling
-
APIs
- How Do I Use Content Moderation APIs?
- What Should I Do When I Fail to Call a Content Moderation API?
- Can I Directly Upload a Word File for Text Moderation?
- What Are the Constraints on Concurrent API Calls?
- What Can I Do if the Request for Calling an API Times Out?
- How Do I Customize a Detection in Text Moderation?
- Can Content Moderation Traverse and Review the Content in an OBS Folder?
- Error Codes
- Monitoring
- Others
- Price Details
- Glossary
- General Reference
On this page
Show all
Help Center/
Content Moderation/
SDK Reference/
Using the Python SDK/
SDK Calling Example/
Moderation (Image)/
Image Moderation (Asynchronous Batch) (V2)/
Submitting a Task
Copied.
Submitting a Task
- This section describes how to use the Image Moderation SDK by AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. You can set urls in TaskSumbitReq to configure the URLs of the images to be reviewed, 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,RunTaskSumbitRequest,TaskSumbitReq 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 = RunTaskSumbitRequest() listTaskSumbitReqCategoriesbody = [ "porn", ] listTaskSumbitReqUrlsbody = [ "https://XXX.jpg" //Replace it with an image URL that can be accessed from the Internet. ] request.body = TaskSumbitReq( categories=listTaskSumbitReqCategoriesbody, urls=listTaskSumbitReqUrlsbody ) response = client.run_task_sumbit(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 submitting the Image Moderation (Asynchronous Batch) task is displayed on the console.
200 {'result': {'job_id': 'xxx'}} 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