当前位置:网站首页>CANN训练营学习2022第二季 模型系列 动漫风格化和AOE ATC调优
CANN训练营学习2022第二季 模型系列 动漫风格化和AOE ATC调优
2022-07-24 16:51:00 【irrationality】
1、unzip -O GBK *.zip
这个命令可以解包中文压缩包 (特别是由windows系统传到linux系统上面的)
2、迁移脚本
跑通之后
cd ..
git clone https://gitee.com/ascend/tensorflow.git
cd tensorflow/convert_tf2npu #进入工具包
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 如下

注意这两个路径不能为桶根目录
运行代码
报错:ImportError: cannot import name ‘tutorials’ from ‘tensorflow_core.examples’
这里的MNIST数据集是利用tensorflow的库来下载的。需要改一下Train.py中的import方式。
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
同时data作相应修改
mnist = input_data.read_data_sets(“/home/ma-user/modelarts/user-job-dir/code/MNIST_data/”, one_hot=True)

3、更换模型
下载一个resnet101模型
上传到model文件夹
src/sample_process.cpp 文件中定制代码。修改第82行如下图。
在 src/sample_process.cpp 文件中定制代码。修改第82行如下图。
修改第95~98行为需要的文件,如下图。如果与下图相符,则不用修改。

4、动漫风格化
参考: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
# 为了方便下载,在这里直接给出原始模型下载及模型转换命令,可以直接拷贝执行。也可以参照上表在modelzoo中下载并手工转换,以了解更多细节。
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
使用AOE调优
修改HwHiAiUser的用户密码
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

但是调优大概持续了一个多小时,三千多秒




可以看到我们新生成的om文件
重新编译
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/
在安装numpy时,遇到了一个问题
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
这样pip安装就装在的python3.7.5
现在就可以了
pip install --upgrade pip
先配置源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
然后修改为
[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/

转换成功,去out下看看
就得到了生成的图像。
边栏推荐
- Jupyter uses tips
- EF data migration
- [Nanjing Agricultural University] information sharing of postgraduate entrance examination and re examination
- 709. Convert to lowercase letters
- [redis] -1. two ways of setting up environment based on docker
- Summary of experience in using.Net test framework xUnit, mstest, specflow
- [machine learning basics] - another perspective to explain SVM
- 双亲委派机制
- QT graphical interface beginner project - unmanned aerial vehicle group combat simulation
- 随笔记:同步、异步和微任务、宏任务的打印顺序
猜你喜欢

Xxx.pro learning in QT

MODIS data WGet Download

AXI协议(1):AMBA总线介绍,AXI概念与背景介绍,AXI协议特点与功能

Notebook computer purchase guide (specific brand and model are not recommended)

15. ARM embedded system: how to debug single board with PC

Mcd12q1 data shows multiple classifications in envi

Small end format and big end format (little endian & big endian)

IP day 13 notes

Sword finger offer 48. the longest substring without repeated characters
![[sequential logic circuit] - counter](/img/a5/c92e0404c6a970a62595bc7a3b68cd.gif)
[sequential logic circuit] - counter
随机推荐
The differences of several deletions in SQL
What does Baidu promote "delete and recall" mean?
DBF menu driver: librarydatabaseproject
The industrial information security center takes the lead in building a data circulation platform, and ant group and other manufacturers provide technical support
Analysis of double pointer sliding window method and solution of leetcode related problems
Codeforces round 690 (Div. 3) C. unique number conventional solution
Custom types: Enumeration
JVM class loading subsystem
Cross server, insert, search
EF miscellaneous
Qualcomm reconciled with apple and received at least $4.5 billion in settlement fees! Next goal: Huawei!
Jenkins CLI 命令详解
剑指 Offer 22. 链表中倒数第k个节点
Pull and load more on wechat applet list rendering
Educational codeforces round 100 (rated for Div. 2) B. find the array solution
Qsqldatabase: solution of qmmysql driver not loaded
【南京农业大学】考研初试复试资料分享
ArcGIS create vector
How to effectively avoid memory leakage when customizing the handler?
Causes and solutions of QT signal and slot connection failure