当前位置:网站首页>Cann training camp learns the animation stylization and AOE ATC tuning of the second season of 2022 model series
Cann training camp learns the animation stylization and AOE ATC tuning of the second season of 2022 model series
2022-07-24 16:52:00 【irrationality】
1、unzip -O GBK *.zip
This command can unpack Chinese compressed packages ( Especially by windows System to linux On the system )
2、 Migration scripts
After running through
cd ..
git clone https://gitee.com/ascend/tensorflow.git
cd tensorflow/convert_tf2npu # Access kit
pip3 install pandas
pip3 install xlrd==1.2.0
pip3 install openpyxl
pip3 install tkintertable
pip3 install google_pasta
python3 main.py -i ~/competition/LeNet
job configure as follows 

Note that these two paths cannot be the bucket root
Run code
Report errors :ImportError: cannot import name ‘tutorials’ from ‘tensorflow_core.examples’
there MNIST Data sets are used tensorflow Library to download . It needs to be changed Train.py Medium import The way .
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
meanwhile data Modify accordingly
mnist = input_data.read_data_sets(“/home/ma-user/modelarts/user-job-dir/code/MNIST_data/”, one_hot=True)

3、 Replace the model
Download a resnet101 Model 
Upload to model Folder
src/sample_process.cpp Custom code in the file . Amendment No 82 The line is as follows .
stay src/sample_process.cpp Custom code in the file . Amendment No 82 The line is as follows .
Amendment No 95~98 Documents required for behavior , Here's the picture . If it is consistent with the figure below , There is no need to modify .

4、 Animation stylization
Reference resources :https://gitee.com/ascend/samples/tree/master/python/contrib/cartoonGAN_picture
https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/51RC2alpha005/developmenttools/devtool/aoe_16_002.html
cd ~/samples/python/contrib/cartoonGAN_picture
cd model
# To make it easy to download , Here, the original model download and model conversion commands are directly given , You can copy and execute directly . You can also refer to the above table in modelzoo Download and manually convert , For more details .
cd ${
HOME}/samples/python/contrib/cartoonGAN_picture/model
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/cartoonization/cartoonization.pb
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/cartoonization/insert_op.cfg
Use AOE tuning
modify HwHiAiUser The user password of
su -
passwd HwHiAiUser
apt-get install pciutils
cd ${
HOME}/samples/python/contrib/cartoonGAN_picture/model
aoe --model="./cartoonization.pb" --output_type=FP32 --input_shape="train_real_A:1,256,256,3" --input_format=NHWC --output="cartoonizationv2_256" --framework=3 --precision_mode=allow_fp32_to_fp16 --insert_op_conf=insert_op.cfg --job_type=2
atc --model="./cartoonization.pb" --output_type=FP32 --input_shape="train_real_A:1,256,256,3" --input_format=NHWC --output="cartoonizationv2_256" --framework=3 --precision_mode=allow_fp32_to_fp16 --soc_version=Ascend310 --insert_op_conf=insert_op.cfg
cd ~
mkdir AscendProjects
cd AscendProjects
git clone https://gitee.com/ascend/tools.git
export DDK_PATH=/home/HwHiAiUser/Ascend/ascend-toolkit/latest
export NPU_HOST_LIB=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/acllib/lib64/stub
cd $HOME/AscendProjects/tools/msame/
./build.sh g++ $HOME/AscendProjects/tools/msame/out
cd ${
HOME}/samples/python/contrib/cartoonGAN_picture/model
cd ~/AscendProjects/tools/msame/out
./msame --model ${
HOME}/samples/python/contrib/cartoonGAN_picture/model/cartoonizationv2_256.om --output output/ --loop 100

But the tuning lasted about an hour , More than 3000 seconds 




You can see our newly generated om file 
recompile
cd $HOME/samples/python/contrib/cartoonGAN_picture/data
wget https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/cartoonGAN_picture/scenery.jpg
cd ../src
python3.6 cartoonization.py ../data/
In the installation numpy when , There's a problem
FileNotFoundError: [Errno 2] No such file or directory: ‘/usr/local/python3.7.5/bin/pip’
which pip
/home/HwHiAiUser/.local/bin/pip
sudo ln -s /home/HwHiAiUser/.local/bin/pip /usr/local/python3.7.5/bin/pip
such pip Install it on python3.7.5
It's ok now
pip install --upgrade pip
Configure the source first
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Then change it to
[global]
index-url = https://repo.huaweicloud.com/repository/pypi/simple
trusted-host = repo.huaweicloud.com
timeout = 120
pip install numpy
pip install opencv-python
find ../../../ -name "acllite_utils*"
cp ../../../common/acllite/* ./
python3.7.5 cartoonization.py ../data/

Conversion success , Go to out Let's have a look 
You get the generated image .
边栏推荐
- Envi5.3 open GF-1 WFV data
- 代码随想录笔记_链表_707设计链表
- 我们为什么要推出Getaverse?
- Xxx.pro learning in QT
- [leetcode]75. color classification - problem solving (execution time beat 90%, memory consumption beat 78%)
- Mysql增删改查、检索与约束(详细教学)
- Codeworks round 693 (Div. 3) C. long jumps problem solution
- Zhao Ming, CEO of glory: it is difficult for a single manufacturer to achieve full scene product coverage
- 会议OA项目进度(一)
- Amd Ruilong 7000 is expected to be available on September 15, and the 3D cache version will have to wait
猜你喜欢

Implementation of side list menu (side menu) of wechat applet

IP第十三天笔记

Thinkphp3.2.5 cannot jump to external links

Comparison of array and object merging methods assign, merge, defaults, defaultsdeep in lodash

IP day 13 notes

Axi protocol (2): five channels and two transactions of Axi architecture

MySQL basic commands

Problems encountered in upgrading chrome to version 80 - solutions to system login failure

VSCode如何鼠标滚轮放大界面

Envi5.3 open GF-1 WFV data
随机推荐
Jenkins cli command details
QT design robot simulation controller -- key control robot joint rotation
hping3安装使用
PS pull out logo
QT QML virtual keyboard
查数据库实际数据增长情况
IP第十三天笔记
EF miscellaneous
Parental delegation mechanism
快速入门
ShardingSphere数据库读写分离
Problems encountered in upgrading chrome to version 80 - solutions to system login failure
EMQ Yingyun technology was listed on the 2022 "cutting edge 100" list of Chinese entrepreneurs
Summary of experience in using.Net test framework xUnit, mstest, specflow
EF LINQ Miscellany
详解 Apache Hudi Schema Evolution(模式演进)
双亲委派机制
Getting started with arcpy
[leetcode]38. counting - problem solving (execution time beat 91%, memory consumption beat 97%)
Interview question 01.02. determine whether it is character rearrangement