2 Task 2: Use Tencent Cloud GPU to conduct cat and dog recognition practice

Use the free GPU provided by Tendong Cloud to practice cat and dog recognition.
Although the routines provided are based on tensorflow, you can also use pytorch code.
One advantage of using this platform is that it is convenient, with various environments, etc.; there are also some common data sets.

1 Create project

1. Enter the Trend Cloud user workbench and select the space automatically generated by the system when registering in the current space (there is no free computing power in other spaces);
image.png
2. Fill in the project name and project description, as shown in Figure 2:
image.png
3. Add Image: Select the official image containing the TensorFlow2.X framework, as shown in Figure 3;
image.png
4. Add binding data set: Select the public data set, DogsVsCats.
image.png
5. There is no need to fill in the rest. Click Create in the lower right corner. The system will pop up a prompt to upload the code. Click Don't upload yet. The project is created successfully.

2 Initialize the development environment

1. Download code:
Feishu Document Link: Download step 1 of Chapter 3:
https://nuly9zxzf1.feishu.cn/docx/HOmzdmST9oc43gxjTF0c7PAAnnb

2. Initialize the development environment:
Figure 4: Click the run code in the upper right corner to enter the initialization development environment page;
Figure 5: Fill in the initial configuration of the development environment;
image.png

image.png

image.png

image.png

3 Debugging code

After the development environment is created, you can debug the code in the development environment.
1. Click the JupyterLab tool on the right side of the development environment instance page.
2. Enter the /gemini/ directory by default. Click the code folder in the directory tree on the right to enter the /gemini/code/ directory.
image.png

image.png

3. Click the terminal button on the top webpage to enter the terminal interface.
image.png

4. Run the following code in the web terminal
:

python $GEMINI_RUN/DogsVsCats.py --num_epochs 5 --data_dir $GEMINI_DATA_IN1/DogsVsCats/ --train_dir $GEMINI_DATA_OUT

The system returns a series of information until it returns test accuracy information, as shown below, indicating that the model test is over and its ability to identify cats and dogs is
0.500000, which means it has almost no identification ability.

5. Click JupyterLab, switch back to the JupyterLab tool, and analyze the model code under the /gemini/code/ path.
After investigation, it was found that the data set was not disrupted in the code for training, resulting in the model not being successfully trained. This is because the model is in a batch. It can only
see the cat category and the dog category, but cannot see the information of the other category, so it has no recognition ability.

6. Modify the model code and save it.
a. Double-click DogsVsCats.py under the /gemini/code/ path to start editing the file.
b. Delete the comment symbol # on line 44 of the file.
c, save

7. Click the web terminal button to enter the terminal interface and execute the command in 4 above again to test the recognition ability.
The test results returned by the system are as follows. It is obvious that it can identify cats and dogs 85% of the time.
image.png

4 Submit offline tasks

When you have completed this tuning, you can refer to the following steps to save the code and submit the training task using the current version of the code.
1. Click Submit training task in the upper right corner of the debugging page.
2. Select the image and code version in the single box.
a. Select the code version: click New Code Version and fill in the code version name in the right box.
b. Select image: Choose to use the current working image directly.

image.png
image.png

3. Click OK to enter the task submission page. Refer to the following instructions to configure basic information of the task.
a. Configuration instructions, keep the rest as default.
i. Task model: stand-alone task;
ii. GPU selection: B1.2 xlarge [2Gpu configuration required]
iii. Start command :
Execute the DogsVsCats.py script in the code to start training. The data required for training is GEMINIDATAIN 1/D ogs V The data in the s C ats directory, the training results are saved in the GEMINI_DATA_IN1/DogsVsCats directory, the training results are saved inGEMINIDATAIN 1/ Do g s V s C a t s data in the directory, and the training results are saved in the GEMINI_DATA_OUT directory. The startup command to perform this task is as follows:

python $GEMINI_RUN/DogsVsCats.py --num_epochs 5 --data_dir $GEMINI_DATA_IN1/DogsVsCats/ --train_dir $GEMINI_DATA_OUT

image.png

4. After completing the configuration information, click OK.
Return to the training task page and check the status of the task in the training task list. The task will be trained in about 5 minutes.
·If the task status is displayed as successful, it means that the training task has ended successfully.
·If the task status is failed, you can hover the mouse over the word failed to view the reason for the failure.

image.png

5 Result set storage and download

After the model has been trained on large-scale data, it will have the ability to identify cats and dogs relatively accurately. At this time, the model can be downloaded and deployed to the application.
Trend Cloud Platform provides the function of result set storage and download. The output you set in the code will be stored in the result set. You can export model files in a result set
as models.

1. Select results in the left navigation bar and enter the task results page by default.
image.png

2. Click the export model button in the upper right corner to enter the export model page

image.png
image.png

3. Click Create to generate the model.
The generated model will be saved in the platform, and you can set its visibility to public and share it with other members to use or further improve the model.

おすすめ

転載: blog.csdn.net/Alexa_/article/details/134274977