diff --git a/README_cn.md b/README_cn.md index 5c76207c34af514e90b89f348c6fb616b4938c6e..135ebe2206d59a7a9e18d1b9c74139559d48b7a9 100644 --- a/README_cn.md +++ b/README_cn.md @@ -58,6 +58,7 @@ - [车辆识别](./docs/zh_CN/application/vehicle_fine_grained_classfication.md) - [车辆ReID](./docs/zh_CN/application/vehicle_reid.md) - [logo识别](./docs/zh_CN/application/logo_recognition.md) + - [动漫人物识别](./docs/zh_CN/application/cartoon_character_recognition.md) - [向量检索](./deploy/vector_search/README.md) - 模型训练/评估 - [图像分类任务](./docs/zh_CN/tutorials/getting_started.md) diff --git a/docs/en/extension/VisualDL_en.md b/docs/en/extension/VisualDL_en.md index 28650b29d396ad7272eb31e2e47f3b187e4288e9..cdd99581a0e3d19752f66361e15f9b696e57024a 100644 --- a/docs/en/extension/VisualDL_en.md +++ b/docs/en/extension/VisualDL_en.md @@ -10,7 +10,7 @@ Now PaddleClas support use VisualDL to visualize the changes of learning rate, l You only need to set the `vdl_dir` field in train config: ```yaml -# confit.txt +# config.yaml vdl_dir: "./vdl.log" ``` @@ -19,7 +19,7 @@ vdl_dir: "./vdl.log" Then normal start training: ```shell -python3 tools/train.py -c config.txt +python3 tools/train.py -c config.yaml ``` ### Start VisualDL diff --git a/docs/en/tutorials/getting_started_en.md b/docs/en/tutorials/getting_started_en.md index e3658448ca50f008a4127c8a3d6fdfb835acfa08..19142b0145d3d4c43a152120f9645838f2a93b04 100644 --- a/docs/en/tutorials/getting_started_en.md +++ b/docs/en/tutorials/getting_started_en.md @@ -246,7 +246,7 @@ Among them, the `--model` parameter is used to specify the model name, `--pretra **Note**: 1. If `--output_path=./inference`, then three files will be generated in the folder `inference`, they are `inference.pdiparams`, `inference.pdmodel` and `inference.pdiparams.info`. -2. You can specify the `shape` of the model input image by setting the parameter `--img_size`, the default is `224`, which means the shape of input image is `224*224`. +2. You can specify the `shape` of the model input image by setting the parameter `--img_size`, the default is `224`, which means the shape of input image is `224*224`. If you want to use `Transformer series models`, such as `DeiT_***_384`, `ViT_***_384`, you need to set `--img_size=384`. The above command will generate the model structure file (`inference.pdmodel`) and the model weight file (`inference.pdiparams`), and then the inference engine can be used for inference: diff --git a/docs/zh_CN/extension/VisualDL.md b/docs/zh_CN/extension/VisualDL.md index ea21c5b29e328d23de301b0955cdeb2c4d294852..d360c5b152957f53c2fdf5f334a2fe6d8762f85c 100644 --- a/docs/zh_CN/extension/VisualDL.md +++ b/docs/zh_CN/extension/VisualDL.md @@ -10,7 +10,7 @@ VisualDL是飞桨可视化分析工具,以丰富的图表呈现训练参数变 在PaddleClas中使用VisualDL,只需在训练配置文件(config文件)添加如下字段: ```yaml -# confit.txt +# config.yaml vdl_dir: "./vdl.log" ``` `vdl_dir` 用于指定VisualDL用于保存log信息的目录。 @@ -18,7 +18,7 @@ vdl_dir: "./vdl.log" 然后正常启动训练即可: ```shell -python3 tools/train.py -c config.txt +python3 tools/train.py -c config.yaml ``` ### 启动VisualDL diff --git a/docs/zh_CN/tutorials/getting_started.md b/docs/zh_CN/tutorials/getting_started.md index 7356e2c1ae33b59419b99046e9ff645742b0de7e..fc90c4b7ee4ae0721cffcd1c334e2c9649db7fba 100644 --- a/docs/zh_CN/tutorials/getting_started.md +++ b/docs/zh_CN/tutorials/getting_started.md @@ -232,6 +232,10 @@ python3 tools/export_model.py \ 其中,`Global.pretrained_model`用于指定模型文件路径,该路径仍无需包含模型文件后缀名(如[1.3 模型恢复训练](#1.3))。 +**注意**: +1. `--output_path`表示输出的inference模型文件夹路径,若`--output_path=./inference`,则会在`inference`文件夹下生成`inference.pdiparams`、`inference.pdmodel`和`inference.pdiparams.info`文件。 +2. 可以通过设置参数`--img_size`指定模型输入图像的`shape`,默认为`224`,表示图像尺寸为`224*224`,请根据实际情况修改;如果使用`Transformer`系列模型,如`DeiT_***_384`, `ViT_***_384`等,请注意模型的输入数据尺寸,需要设置参数`img_size=384`。 + 上述命令将生成模型结构文件(`inference.pdmodel`)和模型权重文件(`inference.pdiparams`),然后可以使用预测引擎进行推理: @@ -249,7 +253,7 @@ python3 python/predict_cls.py \ -o Global.infer_imgs=../dataset/flowers102/jpg/image_00001.jpg \ -o Global.inference_model_dir=../inference/ \ -o PostProcess.class_id_map_file=None - + 其中: + `Global.infer_imgs`:待预测的图片文件路径。 @@ -259,4 +263,6 @@ python3 python/predict_cls.py \ + `Global.enable_mkldnn`:是否启用`MKL-DNN`加速,默认为`False`。注意`enable_mkldnn`与`use_gpu`同时为`True`时,将忽略`enable_mkldnn`,而使用GPU运行。 + `Global.use_fp16`:是否启用`FP16`,默认为`False`。 +**注意**: 如果使用`Transformer`系列模型,如`DeiT_***_384`, `ViT_***_384`等,请注意模型的输入数据尺寸,需要设置参数`resize_short=384`, `resize=384`。 + * 如果你希望提升评测模型速度,使用gpu评测时,建议开启TensorRT加速预测,使用cpu评测时,建议开启MKL-DNN加速预测。 diff --git a/paddleclas.py b/paddleclas.py index d8fcf9368473f11b5379a80a7d20bc4290677c0f..9d4cdaea6dbe6035b091c5aa0ec7b95d94c3d6dd 100644 --- a/paddleclas.py +++ b/paddleclas.py @@ -160,10 +160,15 @@ class ModelNameError(Exception): def print_info(): table = PrettyTable(['Series', 'Name']) + try: + sz = os.get_terminal_size() + width = sz.columns - 30 if sz.columns > 50 else 10 + except OSError: + width = 100 for series in model_series: - names = textwrap.fill(" ".join(model_series[series]), width=100) + names = textwrap.fill(" ".join(model_series[series]), width=width) table.add_row([series, names]) - print('Inference models that Paddle provides are listed as follows:') + print('Inference models that PaddleClas provides are listed as follows:') print(table) diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..cdefb80509af7f6d93d6e775a4c48cfe29a95f1e --- /dev/null +++ b/tools/__init__.py @@ -0,0 +1,15 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from . import infer \ No newline at end of file diff --git a/tools/infer/__init__.py b/tools/infer/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..8d3600de80b53eb0787a0ff95fe9ad1eb888cf9f --- /dev/null +++ b/tools/infer/__init__.py @@ -0,0 +1,16 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .predict import Predictor +from .utils import parse_args, create_paddle_predictor, preprocess, postprocess, get_image_list, get_image_list_from_label_file, calc_topk_acc, save_prelabel_results, b64_to_np, np_to_b64 \ No newline at end of file