fix some errors and add resnext50 Chinese README

pull/10292/head
zhaoting 4 years ago
parent 0b8ca49398
commit 5825ff1418

@ -10,7 +10,7 @@
- [Script and Sample Code](#script-and-sample-code)
- [Training Process](#training-process)
- [Evaluation Process](#eval-process)
- [Export MindIR](#export-mindir)
- [Model Export](#model-export)
- [Model Description](#model-description)
- [Performance](#performance)
- [Training Performance](#training-performance)
@ -182,14 +182,14 @@ Inference result will be stored in the example path, you can find result like th
result: {'acc': 0.71976314102564111} ckpt=./ckpt_0/mobilenet-200_625.ckpt
```
## [Export MindIR](#contents)
Change the export mode and export file in `src/config.py`, and run `export.py`.
## [Model Export](#contents)
```shell
python export.py --platform [PLATFORM] --pretrain_ckpt [CKPT_PATH]
python export.py --platform [PLATFORM] --ckpt_file [CKPT_PATH] --file_format [EXPORT_FORMAT]
```
`EXPORT_FORMAT` should be in ["AIR", "ONNX", "MINDIR"]
# [Model description](#contents)
## [Performance](#contents)

@ -17,7 +17,7 @@
- [用法](#用法-1)
- [启动](#启动-1)
- [结果](#结果-1)
- [导出MINDIR](#导出MINDIR)
- [模型导出](#模型导出)
- [模型描述](#模型描述)
- [性能](#性能)
- [训练性能](#训练性能)
@ -188,14 +188,14 @@ epoch time:138331.250, per step time:221.330, avg loss:3.917
result:{'acc':0.71976314102564111} ckpt=./ckpt_0/mobilenet-200_625.ckpt
```
## 导出MINDIR
修改`src/config.py`文件中的`export_mode`和`export_file`, 运行`export.py`。
## 模型导出
```shell
python export.py --platform [PLATFORM] --pretrain_ckpt [CKPT_PATH]
python export.py --platform [PLATFORM] --ckpt_file [CKPT_PATH] --file_format [EXPORT_FORMAT]
```
`EXPORT_FORMAT` 可选 ["AIR", "ONNX", "MINDIR"].
# 模型描述
## 性能

@ -41,9 +41,7 @@ def set_config(args):
"save_checkpoint_path": "./",
"platform": args.platform,
"run_distribute": args.run_distribute,
"activation": "Softmax",
"export_format": "MINDIR",
"export_file": "mobilenetv2"
"activation": "Softmax"
})
config_gpu = ed({
"num_classes": 1000,
@ -65,9 +63,7 @@ def set_config(args):
"save_checkpoint_path": "./",
"platform": args.platform,
"run_distribute": args.run_distribute,
"activation": "Softmax",
"export_format": "MINDIR",
"export_file": "mobilenetv2"
"activation": "Softmax"
})
config_ascend = ed({
"num_classes": 1000,
@ -92,9 +88,7 @@ def set_config(args):
"rank_id": int(os.getenv('RANK_ID', '0')),
"rank_size": int(os.getenv('RANK_SIZE', '1')),
"run_distribute": int(os.getenv('RANK_SIZE', '1')) > 1.,
"activation": "Softmax",
"export_format": "MINDIR",
"export_file": "mobilenetv2"
"activation": "Softmax"
})
config = ed({"CPU": config_cpu,
"GPU": config_gpu,

@ -56,7 +56,7 @@ if __name__ == '__main__':
# init context
context.set_context(mode=context.GRAPH_MODE, device_target=target, save_graphs=False)
if target != "GPU":
if target == "Ascend":
device_id = int(os.getenv('DEVICE_ID'))
context.set_context(device_id=device_id)

@ -12,7 +12,7 @@
- [Script Parameters](#script-parameters)
- [Training Process](#training-process)
- [Evaluation Process](#evaluation-process)
- [Export MindIR](#export-mindir)
- [Model Export](#model-export)
- [Model Description](#model-description)
- [Performance](#performance)
- [Training Performance](#evaluation-performance)
@ -206,14 +206,14 @@ acc=78.16%(TOP1)
acc=93.88%(TOP5)
```
## [Export MindIR](#contents)
## [Model Export](#contents)
Change the export mode and export file in `src/config.py`, and run `export.py`.
```script
python export.py --platform PLATFORM --pretrained CKPT_PATH
```shell
python export.py --device_target [PLATFORM] --ckpt_file [CKPT_PATH] --file_format [EXPORT_FORMAT]
```
`EXPORT_FORMAT` should be in ["AIR", "ONNX", "MINDIR"]
# [Model description](#contents)
## [Performance](#contents)

File diff suppressed because it is too large Load Diff

@ -41,7 +41,5 @@ config = ed({
"is_save_on_master": 1,
"rank": 0,
"group_size": 1,
"export_format": "MINDIR",
"export_file": "resnext50"
"group_size": 1
})

@ -35,13 +35,12 @@ def _rand(a=0., b=1.):
return np.random.rand() * (b - a) + a
def get_imageId_from_fileName(filename):
"""Get imageID from fileName"""
try:
filename = os.path.splitext(filename)[0]
def get_imageId_from_fileName(filename, id_iter):
"""Get imageID from fileName if fileName is int, else return id_iter."""
filename = os.path.splitext(filename)[0]
if filename.isdigit():
return int(filename)
except:
raise NotImplementedError('Filename %s is supposed to be an integer.' % (filename))
return id_iter
def random_sample_crop(image, boxes):
@ -185,6 +184,7 @@ def create_voc_label(is_training):
image_files_dict = {}
image_anno_dict = {}
images = []
id_iter = 0
for anno_file in os.listdir(anno_dir):
print(anno_file)
if not anno_file.endswith('xml'):
@ -192,7 +192,8 @@ def create_voc_label(is_training):
tree = et.parse(os.path.join(anno_dir, anno_file))
root_node = tree.getroot()
file_name = root_node.find('filename').text
img_id = get_imageId_from_fileName(file_name)
img_id = get_imageId_from_fileName(file_name, id_iter)
id_iter += 1
image_path = os.path.join(image_dir, file_name)
print(image_path)
if not os.path.isfile(image_path):

@ -18,6 +18,7 @@ import random
import numpy as np
from PIL import Image
random.seed(1)
IMG_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.tif', '.tiff']
def is_image_file(filename):

@ -82,7 +82,7 @@ class CityScapes:
'bus', 'train', 'motorcycle', 'bicycle', 'unlabeled']
self.color_list = []
for name in self.classes:
self.color_list.append(label2color[name].color)
self.color_list.append(label2color[name])
self.class_num = len(self.classes)
def get_id(self, img_path):

Loading…
Cancel
Save