หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Calling APIs or SDKs Locally

Updated on 2024-10-18 GMT+08:00

Image Recognition Software Development Kit (Image SDK) encapsulates the RESTful APIs provided by Image Recognition to simplify application development. You can add dependencies or download SDKs to call APIs to use Image Recognition.

This section uses Image Tagging as an example to describe how to use the Image Python SDK for local development. You can use the SDK by calling API functions.

Prerequisites

Procedure

  1. Install the Python environment and obtain the SDK.
    1. Download Python of a proper version from Python's official website and install it. Python 3.3 or later is recommended. This section uses Python 3.7 as an example.
    2. Download the latest version of PyCharm from PyCharm's official website.
    3. Start the PyCharm development tool and choose File > Settings > Project Interpreter to configure the Python environment.
    4. Select the Python installation path. See Figure 1. After selecting the target Python, click Apply at the bottom of the page to complete the configuration.
      Figure 1 Configuring the python environment using PyCharm

  2. Create a project in PyCharm and click Terminal in the lower left corner. Run the following commands to install the SDK (the SDK supports Python 3 or later):
    Install the SDK using pip commands:
    # Install the core library.
    pip install huaweicloudsdkcore
    
    # Install the image service library.
    pip install huaweicloudsdkimage
    
    To install the Python SDK using PyCharm, perform the following steps:
    1. Start PyCharm and choose File > Settings...
    2. Click Python Interpreter and then +.
    3. Click +, search for huaweicloudsdkcore and huaweicloudsdkimage, and click Install Package in the lower left corner to install the packages.

    On PyCharm, choose File > Settings > Project > Python Interpreter. Click + in the upper right corner, search for huaweicloudsdkcore and huaweicloudsdkimage respectively, and click Install Package in the lower left corner to install them.

    Figure 2 Installing the Python SDK for Image Recognition using PyCharm
  3. Copy the SDK sample code of Image Tagging to PyCharm.
    # coding: utf-8
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkimage.v2.region.image_region import ImageRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkimage.v2 import *
    if __name__ == "__main__":
       //Enter your AK/SK.
        ak = "<YOUR AK>"
        sk = "<YOUR SK>"
        credentials = BasicCredentials(ak, sk) \
        client = ImageClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(ImageRegion.value_of("ap-southeast-1")) \
            .build()
    try:
            request = RunImageTaggingRequest()
            request.body = ImageTaggingReq(
              
                url="https://support.huaweicloud.com/intl/zh-cn/productdesc-image/zh-cn_image_0241182299.png" 
            ) 
            response = client.run_image_tagging(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
  4. Obtain the AK and SK and replace <YOUR AK> and <YOUR SK> in the sample code with the AK and SK, respectively.

    Log in to the Access Keys page. Create an access key or use an existing access key. The AK and SK are contained in the credentials.csv file.

  5. Run the sample code to obtain the recognition result. You can interpret the review result based on the response parameter description. For details, see the image tag recognition result.
    Figure 3 Example

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback