Huawei cloud server uses ModelArts to run MindSpore framework Yolov5

Huawei cloud server uses Modlearts to run MindSpore framework Yolov5

Environmental preparation

  • Cloud platform login, used to purchase servers https://uconsole.xckpjs.com/
  • I am using Ascend 910 here
  • Click ModelArts to open the control page, ModelArts

ModelArts is a one-stop development platform for AI developers, providing massive data preprocessing and semi-automatic labeling, large-scale distributed training, automatic model generation, and on-demand deployment of end-edge-cloud models to help users quickly create and deploy Model, manage full-cycle AI workflow.

"One-stop" means that all aspects of AI development, including data processing, algorithm development, model training, and model deployment, can be completed on ModelArts. From a technical point of view, the bottom layer of ModelArts supports various heterogeneous computing resources, and developers can choose to use them flexibly according to their needs without caring about the underlying technology. At the same time, ModelArts supports mainstream open source AI development frameworks such as Tensorflow, PyTorch, and MindSpore, and also supports developers to use self-developed algorithm frameworks to match your usage habits.

The idea of ​​ModelArts is to make AI development easier and more convenient.

Provides a convenient and easy-to-use process for AI developers with different experiences. For example, for business developers, you don’t need to pay attention to models or codes, and can use the automatic learning process to quickly build AI applications; for AI beginners, you don’t need to pay attention to model development, and use preset algorithms to build AI applications; for AI engineers, you can provide a variety of Development environment, multiple operating processes and modes, convenient for developers to code and expand, and quickly build models and applications.
insert image description here

  • Click the Object Storage Console, this is the only tool for transferring files with the server.
    insert image description here
    Select the required version to download the client and
    insert image description here
    create a new bucket after logging in. The bucket is a container for storing code and data. For the convenience of management, it is recommended that each project has a bucket. ModelArts controllers are synchronous
    insert image description here

Code download and upload

Yolov5 link of MindSpore framework https://www.hiascend.cn/zh/software/modelzoo/models/detail/C/9af06eedaa1b9577d6221a939a31747d

Click to download the model script, which is the code file
and then copy the file modelartin the folder train_start.pyto the code folder on the upper layer, which is the startup file for ModelArts training

Now we upload the code to the bucket, open the previously downloaded OBS Browser+ client, create a new bucket, the name can be customized, and then create four new folders, namely

  1. code, used to store running code
  2. dataset, used to store data sets
  3. log, used to store log files
  4. output, used to store the output file
    insert image description here
    and then upload the yolov5 code downloaded in the previous step to the code folder, and put the dataset into the dataset folder. The dataset I use here is coco2014

ModelArts creation algorithm

Open the ModelArts console, click Algorithm Management, and then click Create Algorithm to create our own algorithm
insert image description here

The name can be customized, the AI ​​engine is selected MindSpore, the code directory is selected in the code folder in the bucket, and the startup file is selected codein the folder just copiedtrain_start.py

insert image description here

Add code path parameters to input data data_url
Add code path parameters to output data Add hyperparameters train_url
, max_epochthe default value is 1

insert image description here
Click Submit in the lower right corner to create the algorithm successfully

ModelArts training data

Click the training job in ModelArts, and then click Create training job
insert image description here

Select the algorithm created in the previous step

insert image description here

Select the dataset path in the OBS bucket for training input and select the folder
in the OBS bucket for training outputoutput

insert image description here

Hyperparameter max_epochis to choose how many times to iterate and input according to your own needs

insert image description here

For the resource pool below, select the server you purchased, and select the log folder in the OBS bucket for the job date and path

insert image description here
Click Submit in the lower right corner to start training. Depending on the number of iterations and the size of the data set, the training time varies. The
training may report an error NameError: name 'args' is not defined

NameError: name 'args' is not defined

insert image description here
My solution is to open the error file train_start.pyand find that args is indeed not defined in it, just add a definition.

After running successfully, you can click to enter the training task to view parameters such as loss value,
insert image description here
or you can enter the log folder in the OBS bucket to view log files

If you have any questions, welcome to comment, if you find it helpful, please like and collect it!

Guess you like

Origin blog.csdn.net/Man_1man/article/details/126599758