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
Situation Awareness
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

Model Package Structure

Updated on 2024-12-26 GMT+08:00

When creating a model, make sure that any meta model imported from OBS complies with specifications.

NOTE:

The model package must contain the model directory. The model directory stores the model file, model configuration file, and model inference code file.

  • Model files: The requirements for model files vary according to the model package structure. For details, see Model Package Example.
  • Model configuration file: The model configuration file must be available and its name is consistently to be config.json. There must be only one model configuration file. For details about how to edit a model configuration file, see Specifications for Editing a Model Configuration File.
  • Model inference code file: It is mandatory. The file name is consistently to be customize_service.py. There must be only one model inference code file. For details about how to edit model inference code, see Specifications for Writing a Model Inference Code File.
    • The .py file on which customize_service.py depends can be directly stored in the model directory. Use relative import for the custom package.
    • The other files on which customize_service.py depends can be stored in the model directory. Use absolute paths to access these files. For details, see Obtaining an Absolute Path.

ModelArts provides samples and sample code for multiple engines. You can edit your configuration files and inference code by referring to ModelArts Samples. ModelArts also provides custom script examples of common AI engines. For details, see Examples of Custom Scripts.

If you encounter any problem when importing a meta model, contact Huawei Cloud technical support.

Model Package Example

  • Structure of the TensorFlow-based model package

    When publishing the model, you only need to specify the ocr directory.

    OBS bucket or directory name
    |── ocr
    |   ├── model (Mandatory) Name of a fixed subdirectory, which is used to store model-related files
    |   │   ├── <<Custom Python package>> (Optional) Your Python package, which can be directly referenced in model inference code
    |   │   ├── saved_model.pb (Mandatory) Protocol buffer file, which contains the graph description of the model
    |   │   ├── variables Name of a fixed sub-directory, which contains the weight and deviation rate of the model. It is mandatory for the main file of a *.pb model.
    |   │   │   ├── variables.index Mandatory
    |   │   │   ├── variables.data-00000-of-00001 Mandatory
    |   │   ├──config.json (Mandatory) Model configuration file. The file name is fixed to config.json. Only one model configuration file is allowed.
    |   │   ├──customize_service.py (Mandatory) Model inference code. The file name is fixed to customize_service.py. Only one model inference code file is allowed.
    The files on which customize_service.py depends can be directly stored in the model directory.
  • Structure of the PyTorch-based model package

    When publishing the model, you only need to specify the resnet directory.

    OBS bucket or directory name
    |── resnet
    |   ├── model (Mandatory) Name of a fixed subdirectory, which is used to store model-related files
    |   │  ├── <<Custom Python package>> (Optional) Your Python package, which can be directly referenced in model inference code
    |   │  ├── resnet50.pth (Mandatory) PyTorch model file, which contains variable and weight information and is saved as state_dict
    |   │  ├──config.json (Mandatory) Model configuration file. The file name is fixed to config.json. Only one model configuration file is allowed.
    |   │  ├──customize_service.py (Mandatory) Model inference code. The file name is fixed to customize_service.py. Only one model inference code file is allowed. The files on which customize_service.py depends can be directly stored in the model directory.
  • Structure of a custom model package depends on the AI engine in your custom image. For example, if the AI engine in your custom image is TensorFlow, the model package uses the TensorFlow structure.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback