提交 28340e25 编写于 作者: J JunYuLiu

Add tools

上级 5deb5345
......@@ -21,7 +21,7 @@
cd tools/link_detection
pip install requests
```
3.`link_check`目录下执行如下命令,在输入需要检测目录的绝对路径后,开始进行检测,完成后会在当前目录下新建`404.txt``exception.txt``slow.txt`三个文件。
3.`link_detection`目录下执行如下命令,在输入需要检测目录的绝对路径后,开始进行检测,完成后会在当前目录下新建`404.txt``exception.txt``slow.txt`三个文件。
```
python link_detection.py
```
......
# 图片检查工具
## 简介
此工具可以检查用户指定目录里所有图片的使用情况,会检查出没有使用的图片,并且将没有使用的图片删除。
## 使用说明
该工具所依赖的操作系统为Windows操作系统,执行环境为Python环境,具体使用步骤如下所示:
1. 打开Git Bash,下载MindSpore Docs仓代码。
```
git clone https://gitee.com/mindspore/docs.git
```
2. 进入`tools/pic_detection`目录。
```
cd tools/pic_detection
```
3.`pic_detection`目录下执行如下命令,在输入需要检测目录的绝对路径后,开始进行检测,最后将没有使用的图片删除。
```
python pic_detection.py
```
> 检测目录的绝对路径全使用英文,并且使用Linux的绝对路径方式,例如:`/d/master/docs`。
import subprocess
import os
def get_images_dierctory(check_path):
'''
get all images directory.
'''
cmd = 'find %s -type d -name images' %check_path
res = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
dir_list = res.stdout.read().decode('utf-8').split('\n')
del dir_list[-1]
return dir_list
def get_all_pic(dir_list):
'''
get all the images in the images directory.
'''
for dir in dir_list:
res = subprocess.Popen('ls %s'%dir, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
pic_list = res.stdout.read().decode('utf-8').split('\n')
del pic_list[-1]
for i in pic_list:
pic_all.add(i)
def get_use_pic(check_path):
'''
get all the useful pictures.
'''
cmd1 = 'find %s -type f -name "*.md"' %check_path
cmd2 = 'find %s -type f -name "*.ipynb"' %check_path
cmd3 = [cmd1, cmd2]
for i in cmd3:
res = subprocess.Popen(i, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
file_list = res.stdout.read().decode('utf-8').split('\n')
del file_list[-1]
for j in file_list:
j = j.split('/', 1)[1].replace('/', ':/', 1)
with open(j, 'r', encoding='utf-8') as f:
data = f.read()
for k in pic_all:
if k in data:
use_pic.add(k)
def get_use_eddx():
'''
get all the useful eddx files.
'''
for i in filter_pic:
if i.endswith('eddx'):
if i.split('.')[0] in ' '.join(use_pic):
use_eddx.add(i)
def get_useless_pic_path(check_path):
'''
get the absolute path of all useless pictures.
'''
for i in useless_pic:
cmd = 'find %s -type f -name %s' %(check_path,i)
res = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
data = res.stdout.read().decode('utf-8').split('\n')
del data[-1]
for j in data:
path.append(j)
def del_useless_pic():
'''
delete all useless pictures.
'''
for i in path:
os.system('rm -rf %s' %i)
if __name__ == '__main__':
check_path = input('请输入您要检测的绝对路径:').strip()
pic_all = set()
use_pic = set()
use_eddx = set()
path = []
dir_list = get_images_dierctory(check_path)
get_all_pic(dir_list)
get_use_pic(check_path)
filter_pic = pic_all.difference(use_pic)
get_use_eddx()
useless_pic = filter_pic.difference(use_eddx)
get_useless_pic_path(check_path)
print('没有用的照片:', path)
del_useless_pic()
print('删除成功')
......@@ -251,9 +251,9 @@ shuffle性能优化建议如下:
for data in ds2.create_dict_iterator():
print(data["data"])
```
```
输出:
输出:
```
before shuffle:
[0 1 2 3 4]
[1 2 3 4 5]
......
......@@ -351,7 +351,7 @@ epoch: 42 step: 5004, loss is 1.6453942
其中,
`*.ckpt`:指保存的模型参数文件。checkpoint文件名称具体含义:*网络名称*-*epoch数*_*step数*.ckpt。
##### GPU
#### GPU
在GPU硬件平台上,MindSpore采用OpenMPI的`mpirun`进行分布式训练,进程创建1个目录,目录名称为`train_parallel`,用来保存日志信息和训练的checkpoint文件。下面以使用8张卡的分布式训练脚本为例,演示如何运行脚本:
```
sh run_distribute_train_gpu.sh [DATASET_PATH] [DEVICE_NUM]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册