未验证 提交 260dcb50 编写于 作者: L littletomatodonkey 提交者: GitHub

add pre-label function (#341)

add pre-label function
上级 ed631e0c
......@@ -53,8 +53,8 @@ PaddleClas is a toolset for image classification tasks prepared for the industry
- [Model training and finetuning](./docs/en/tutorials/getting_started_en.md)
- [Model evaluation](./docs/en/tutorials/getting_started_en.md)
- Model prediction/inference
- [Prediction based on training engine](./docs/en/extension/paddle_inference_en.md)
- [Python inference](./docs/en/extension/paddle_inference_en.md)
- [Prediction based on training engine](./docs/en/tutorials/getting_started_en.md)
- [Python inference](./docs/en/tutorials/getting_started_en.md)
- [C++ inference](./deploy/cpp_infer/readme_en.md)
- [Serving deployment](./docs/en/extension/paddle_serving_en.md)
- [Mobile](./deploy/lite/readme_en.md)
......
......@@ -56,8 +56,8 @@
- [模型训练与微调](./docs/zh_CN/tutorials/getting_started.md)
- [模型评估](./docs/zh_CN/tutorials/getting_started.md)
- 模型预测
- [基于训练引擎预测推理](./docs/zh_CN/extension/paddle_inference.md)
- [基于Python预测引擎预测推理](./docs/zh_CN/extension/paddle_inference.md)
- [基于训练引擎预测推理](./docs/zh_CN/tutorials/getting_started.md)
- [基于Python预测引擎预测推理](./docs/zh_CN/tutorials/getting_started.md)
- [基于C++预测引擎预测推理](./deploy/cpp_infer/readme.md)
- [服务化部署](./docs/zh_CN/extension/paddle_serving.md)
- [端侧部署](./deploy/lite/readme.md)
......
# Prediction Framework
## Introduction
Models for Paddle are stored in many different forms, which can be roughly divided into two categories:
1. persistable model(the models saved by fluid.save_persistables)
The weights are saved in checkpoint, which can be loaded to retrain, one scattered weight file saved by persistable stands for one persistable variable in the model, there is no structure information in these variable, so the weights should be used with the model structure.
```
resnet50-vd-persistable/
├── bn2a_branch1_mean
├── bn2a_branch1_offset
├── bn2a_branch1_scale
├── bn2a_branch1_variance
├── bn2a_branch2a_mean
├── bn2a_branch2a_offset
├── bn2a_branch2a_scale
├── ...
└── res5c_branch2c_weights
```
2. inference model(the models saved by fluid.io.save_inference_model)
The model saved by this function cam be used for inference directly, compared with the ones saved by persistable, the model structure will be additionally saved in the model, with the weights, the model with trained weights can be reconstruction. as shown in the following figure, the structure information is saved in `model`
```
resnet50-vd-persistable/
├── bn2a_branch1_mean
├── bn2a_branch1_offset
├── bn2a_branch1_scale
├── bn2a_branch1_variance
├── bn2a_branch2a_mean
├── bn2a_branch2a_offset
├── bn2a_branch2a_scale
├── ...
├── res5c_branch2c_weights
└── model
```
For convenience, all weight files will be saved into a `params` file when saving the inference model on Paddle, as shown below:
```
resnet50-vd
├── model
└── params
```
Both the training engine and the prediction engine in Paddle support the model's e inference, but the back propagation is not performed during the inference, so it can be customized optimization (such as layer fusion, kernel selection, etc.) to achieve low latency and high throughput during inference. The training engine can support either the persistable model or the inference model, and the prediction engine only supports the inference model, so three different inferences are derived:
1. prediction engine + inference model
2. training engine + inference model
3. training engine + inference model
Regardless of the inference method, it basically includes the following main steps:
+ Engine Build
+ Make Data to Be Predicted
+ Perform Predictions
+ Result Analysis
There are two main differences in different inference methods: building the engine and executing the forecast. The following sections will be introduced in detail
## Model Transformation
During training, we usually save some checkpoints (persistable models). These are just model weight files and cannot be directly loaded by the prediction engine to predict, so we usually find suitable checkpoints after the training and convert them to inference model. There are two main steps: 1. Build a training engine, 2. Save the inference model, as shown below.
```python
import fluid
from ppcls.modeling.architectures.resnet_vd import ResNet50_vd
place = fluid.CPUPlace()
exe = fluid.Executor(place)
startup_prog = fluid.Program()
infer_prog = fluid.Program()
with fluid.program_guard(infer_prog, startup_prog):
with fluid.unique_name.guard():
image = create_input()
image = fluid.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
out = ResNet50_vd.net(input=input, class_dim=1000)
infer_prog = infer_prog.clone(for_test=True)
fluid.load(program=infer_prog, model_path=the path of persistable model, executor=exe)
fluid.io.save_inference_model(
dirname='./output/',
feeded_var_names=[image.name],
main_program=infer_prog,
target_vars=out,
executor=exe,
model_filename='model',
params_filename='params')
```
A complete example is provided in the `tools/export_model.py`, just execute the following command to complete the conversion:
```python
python tools/export_model.py \
--m=the name of model \
--p=the path of persistable model\
--o=the saved path of model and params
```
## Prediction engine + inference model
The complete example is provided in the `tools/infer/predict.py`,just execute the following command to complete the prediction:
```
python ./tools/infer/predict.py \
-i=./test.jpeg \
-m=./resnet50-vd/model \
-p=./resnet50-vd/params \
--use_gpu=1 \
--use_tensorrt=True
```
Parameter Description:
+ `image_file`(shortening i):the path of images which are needed to predict,such as `./test.jpeg`.
+ `model_file`(shortening m):the path of weights folder,such as `./resnet50-vd/model`.
+ `params_file`(shortening p):the path of weights file,such as `./resnet50-vd/params`.
+ `batch_size`(shortening b):batch size,such as `1`.
+ `ir_optim` whether to use `IR` optimization, default: True.
+ `use_tensorrt`: whether to use TensorRT prediction engine, default:True.
+ `gpu_mem`: Initial allocation of GPU memory, the unit is M.
+ `use_gpu`: whether to use GPU, default: True.
+ `enable_benchmark`:whether to use benchmark, default: False.
+ `model_name`:the name of model.
NOTE:
when using benchmark, we use tersorrt by default to make predictions on Paddle.
Building prediction engine:
```python
from paddle.fluid.core import AnalysisConfig
from paddle.fluid.core import create_paddle_predictor
config = AnalysisConfig(the path of model file, the path of params file)
config.enable_use_gpu(8000, 0)
config.disable_glog_info()
config.switch_ir_optim(True)
config.enable_tensorrt_engine(
precision_mode=AnalysisConfig.Precision.Float32,
max_batch_size=1)
# no zero copy方式需要去除fetch feed op
config.switch_use_feed_fetch_ops(False)
predictor = create_paddle_predictor(config)
```
Prediction Execution:
```python
import numpy as np
input_names = predictor.get_input_names()
input_tensor = predictor.get_input_tensor(input_names[0])
input = np.random.randn(1, 3, 224, 224).astype("float32")
input_tensor.reshape([1, 3, 224, 224])
input_tensor.copy_from_cpu(input)
predictor.zero_copy_run()
```
More parameters information can be refered in [Paddle Python prediction API](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/python_infer_cn.html). If you need to predict in the environment of business, we recommand you to use [Paddel C++ prediction API](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/native_infer.html),a rich pre-compiled prediction library is provided in the offical website[Paddle C++ prediction library](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html)
By default, Paddle's wheel package does not include the TensorRT prediction engine. If you need to use TensorRT for prediction optimization, you need to compile the corresponding wheel package yourself. For the compilation method, please refer to Paddle's compilation guide. [Paddle compilation](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/compile/fromsource.html)
## Training engine + persistable model prediction
A complete example is provided in the `tools/infer/infer.py`, just execute the following command to complete the prediction:
```python
python tools/infer/infer.py \
--i=the path of images which are needed to predict \
--m=the name of model \
--p=the path of persistable model \
--use_gpu=True
```
Parameter Description:
+ `image_file`(shortening i):the path of images which are needed to predict,such as `./test.jpeg`
+ `model_file`(shortening m):the path of weights folder,such as `./resnet50-vd/model`
+ `params_file`(shortening p):the path of weights file,such as `./resnet50-vd/params`
+ `use_gpu` : whether to use GPU, default: True.
Training Engine Construction:
Since the persistable model does not contain the structural information of the model, it is necessary to construct the network structure first, and then load the weights to build the training engine。
```python
import fluid
from ppcls.modeling.architectures.resnet_vd import ResNet50_vd
place = fluid.CPUPlace()
exe = fluid.Executor(place)
startup_prog = fluid.Program()
infer_prog = fluid.Program()
with fluid.program_guard(infer_prog, startup_prog):
with fluid.unique_name.guard():
image = create_input()
image = fluid.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
out = ResNet50_vd.net(input=input, class_dim=1000)
infer_prog = infer_prog.clone(for_test=True)
fluid.load(program=infer_prog, model_path=the path of persistable model, executor=exe)
```
Perform inference:
```python
outputs = exe.run(infer_prog,
feed={image.name: data},
fetch_list=[out.name],
return_numpy=False)
```
For the above parameter descriptions, please refer to the official website [fluid.Executor](https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/executor_cn/Executor_cn.html)
## Training engine + inference model prediction
A complete example is provided in `tools/infer/py_infer.py`, just execute the following command to complete the prediction:
```python
python tools/infer/py_infer.py \
--i=the path of images \
--d=the path of saved model \
--m=the path of saved model file \
--p=the path of saved weight file \
--use_gpu=True
```
+ `image_file`(shortening i):the path of images which are needed to predict,如 `./test.jpeg`
+ `model_file`(shortening m):the path of model file,如 `./resnet50_vd/model`
+ `params_file`(shortening p):the path of weights file,如 `./resnet50_vd/params`
+ `model_dir`(shortening d):the folder of model,如`./resent50_vd`
+ `use_gpu`:whether to use GPU, default: True
Training engine build
Since inference model contains the structure of model, we do not need to construct the model before, load the model file and weights file directly to bulid training engine.
```python
import fluid
place = fluid.CPUPlace()
exe = fluid.Executor(place)
[program, feed_names, fetch_lists] = fluid.io.load_inference_model(
the path of saved model,
exe,
model_filename=the path of model file,
params_filename=the path of weights file)
compiled_program = fluid.compiler.CompiledProgram(program)
```
> `load_inference_model` Not only supports scattered weight file collection, but also supports a single weight file。
Perform inference:
```python
outputs = exe.run(compiled_program,
feed={feed_names[0]: data},
fetch_list=fetch_lists,
return_numpy=False)
```
For the above parameter descriptions, please refer to the official website [fluid.Executor](https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/executor_cn/Executor_cn.html)
# 分类预测框架
## 一、简介
Paddle 的模型保存有多种不同的形式,大体可分为两类:
1. persistable 模型(fluid.save_persistabels保存的模型)
一般做为模型的 checkpoint,可以加载后重新训练。persistable 模型保存的是零散的权重文件,每个文件代表模型中的一个 Variable,这些零散的文件不包含结构信息,需要结合模型的结构一起使用。
```
resnet50-vd-persistable/
├── bn2a_branch1_mean
├── bn2a_branch1_offset
├── bn2a_branch1_scale
├── bn2a_branch1_variance
├── bn2a_branch2a_mean
├── bn2a_branch2a_offset
├── bn2a_branch2a_scale
├── ...
└── res5c_branch2c_weights
```
2. inference 模型(fluid.io.save_inference_model保存的模型)
一般是模型训练完成后保存的固化模型,用于预测部署。与 persistable 模型相比,inference 模型会额外保存模型的结构信息,用于配合权重文件构成完整的模型。如下所示,`model` 中保存的即为模型的结构信息。
```
resnet50-vd-persistable/
├── bn2a_branch1_mean
├── bn2a_branch1_offset
├── bn2a_branch1_scale
├── bn2a_branch1_variance
├── bn2a_branch2a_mean
├── bn2a_branch2a_offset
├── bn2a_branch2a_scale
├── ...
├── res5c_branch2c_weights
└── model
```
为了方便起见,paddle 在保存 inference 模型的时候也可以将所有的权重文件保存成一个`params`文件,如下所示:
```
resnet50-vd
├── model
└── params
```
在 Paddle 中训练引擎和预测引擎都支持模型的预测推理,只不过预测引擎不需要进行反向操作,因此可以进行定制型的优化(如层融合,kernel 选择等),达到低时延、高吞吐的目的。训练引擎既可以支持 persistable 模型,也可以支持 inference 模型,而预测引擎只支持 inference 模型,因此也就衍生出了三种不同的预测方式:
1. 预测引擎 + inference 模型
2. 训练引擎 + persistable 模型
3. 训练引擎 + inference 模型
不管是何种预测方式,基本都包含以下几个主要的步骤:
+ 构建引擎
+ 构建待预测数据
+ 执行预测
+ 预测结果解析
不同预测方式,主要有两方面不同:构建引擎和执行预测,以下的几个部分我们会具体介绍。
## 二、模型转换
在任务的训练阶段,通常我们会保存一些 checkpoint(persistable 模型),这些只是模型权重文件,不能直接被预测引擎直接加载预测,所以我们通常会在训练完之后,找到合适的 checkpoint 并将其转换为 inference 模型。主要分为两个步骤:1. 构建训练引擎,2. 保存 inference 模型,如下所示:
```python
import fluid
from ppcls.modeling.architectures.resnet_vd import ResNet50_vd
place = fluid.CPUPlace()
exe = fluid.Executor(place)
startup_prog = fluid.Program()
infer_prog = fluid.Program()
with fluid.program_guard(infer_prog, startup_prog):
with fluid.unique_name.guard():
image = create_input()
image = fluid.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
out = ResNet50_vd.net(input=input, class_dim=1000)
infer_prog = infer_prog.clone(for_test=True)
fluid.load(program=infer_prog, model_path=persistable 模型路径, executor=exe)
fluid.io.save_inference_model(
dirname='./output/',
feeded_var_names=[image.name],
main_program=infer_prog,
target_vars=out,
executor=exe,
model_filename='model',
params_filename='params')
```
在模型库的 `tools/export_model.py` 中提供了完整的示例,只需执行下述命令即可完成转换:
```python
python tools/export_model.py \
--m=模型名称 \
--p=persistable 模型路径 \
--o=model和params保存路径
```
## 三、预测引擎 + inference 模型预测
在模型库的 `tools/infer/predict.py` 中提供了完整的示例,只需执行下述命令即可完成预测:
```
python ./tools/infer/predict.py \
-i=./test.jpeg \
-m=./resnet50-vd/model \
-p=./resnet50-vd/params \
--use_gpu=1 \
--use_tensorrt=True
```
参数说明:
+ `image_file`(简写 i):待预测的图片文件路径,如 `./test.jpeg`
+ `model_file`(简写 m):模型文件路径,如 `./resnet50-vd/model`
+ `params_file`(简写 p):权重文件路径,如 `./resnet50-vd/params`
+ `batch_size`(简写 b):批大小,如 `1`
+ `ir_optim`:是否使用 `IR` 优化,默认值:True
+ `use_tensorrt`:是否使用 TesorRT 预测引擎,默认值:True
+ `gpu_mem`: 初始分配GPU显存,以M单位
+ `use_gpu`:是否使用 GPU 预测,默认值:True
+ `enable_benchmark`:是否启用benchmark,默认值:False
+ `model_name`:模型名字
注意:
当启用benchmark时,默认开启tersorrt进行预测
构建预测引擎:
```python
from paddle.fluid.core import AnalysisConfig
from paddle.fluid.core import create_paddle_predictor
config = AnalysisConfig(model文件路径, params文件路径)
config.enable_use_gpu(8000, 0)
config.disable_glog_info()
config.switch_ir_optim(True)
config.enable_tensorrt_engine(
precision_mode=AnalysisConfig.Precision.Float32,
max_batch_size=1)
# no zero copy方式需要去除fetch feed op
config.switch_use_feed_fetch_ops(False)
predictor = create_paddle_predictor(config)
```
执行预测:
```python
import numpy as np
input_names = predictor.get_input_names()
input_tensor = predictor.get_input_tensor(input_names[0])
input = np.random.randn(1, 3, 224, 224).astype("float32")
input_tensor.reshape([1, 3, 224, 224])
input_tensor.copy_from_cpu(input)
predictor.zero_copy_run()
```
更多预测参数说明可以参考官网 [Paddle Python 预测 API](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/python_infer_cn.html)。如果需要在业务的生产环境部署,也推荐使用 [Paddel C++ 预测 API](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/native_infer.html),官网提供了丰富的预编译预测库 [Paddle C++ 预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html)
默认情况下,Paddle 的 wheel 包中是不包含 TensorRT 预测引擎的,如果需要使用 TensorRT 进行预测优化,需要自己编译对应的 wheel 包,编译方式可以参考 Paddle 的编译指南 [Paddle 编译](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/compile/fromsource.html)
## 四、训练引擎 + persistable 模型预测
在模型库的 `tools/infer/infer.py` 中提供了完整的示例,只需执行下述命令即可完成预测:
```python
python tools/infer/infer.py \
--i=待预测的图片文件路径 \
--m=模型名称 \
--p=persistable 模型路径 \
--use_gpu=True \
--load_static_weights=False
```
参数说明:
+ `image_file`(简写 i):待预测的图片文件路径,如 `./test.jpeg`
+ `model`(简写 m):模型名称,如 `ResNet50_vd`
+ `pretrained_model`(简写 p):权重文件路径,如 `./pretrained/ResNet50_vd_pretrained/`
+ `use_gpu` : 是否开启GPU训练,默认值:`True`
+ `load_static_weights` : 是否加载静态图训练得到的预训练模型,默认值:`False`
训练引擎构建:
由于 persistable 模型不包含模型的结构信息,因此需要先构建出网络结构,然后 load 权重来构建训练引擎。
```python
import fluid
from ppcls.modeling.architectures.resnet_vd import ResNet50_vd
place = fluid.CPUPlace()
exe = fluid.Executor(place)
startup_prog = fluid.Program()
infer_prog = fluid.Program()
with fluid.program_guard(infer_prog, startup_prog):
with fluid.unique_name.guard():
image = create_input()
image = fluid.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
out = ResNet50_vd.net(input=input, class_dim=1000)
infer_prog = infer_prog.clone(for_test=True)
fluid.load(program=infer_prog, model_path=persistable 模型路径, executor=exe)
```
执行预测:
```python
outputs = exe.run(infer_prog,
feed={image.name: data},
fetch_list=[out.name],
return_numpy=False)
```
上述执行预测时候的参数说明可以参考官网 [fluid.Executor](https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/executor_cn/Executor_cn.html)
## 五、训练引擎 + inference 模型预测
在模型库的 `tools/infer/py_infer.py` 中提供了完整的示例,只需执行下述命令即可完成预测:
```python
python tools/infer/py_infer.py \
--i=图片路径 \
--d=模型的存储路径 \
--m=保存的模型文件 \
--p=保存的参数文件 \
--use_gpu=True
```
+ `image_file`(简写 i):待预测的图片文件路径,如 `./test.jpeg`
+ `model_file`(简写 m):模型文件路径,如 `./resnet50_vd/model`
+ `params_file`(简写 p):权重文件路径,如 `./resnet50_vd/params`
+ `model_dir`(简写d):模型路径,如`./resent50_vd`
+ `use_gpu`:是否开启GPU,默认值:True
训练引擎构建:
由于 inference 模型已包含模型的结构信息,因此不再需要提前构建模型结构,直接 load 模型结构和权重文件来构建训练引擎。
```python
import fluid
place = fluid.CPUPlace()
exe = fluid.Executor(place)
[program, feed_names, fetch_lists] = fluid.io.load_inference_model(
模型的存储路径,
exe,
model_filename=保存的模型文件,
params_filename=保存的参数文件)
compiled_program = fluid.compiler.CompiledProgram(program)
```
> `load_inference_model` 既支持零散的权重文件集合,也支持融合后的单个权重文件。
执行预测:
```python
outputs = exe.run(compiled_program,
feed={feed_names[0]: data},
fetch_list=fetch_lists,
return_numpy=False)
```
上述执行预测时候的参数说明可以参考官网 [fluid.Executor](https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/executor_cn/Executor_cn.html)
......@@ -165,6 +165,7 @@ python -m paddle.distributed.launch \
[30分钟玩转PaddleClas教程](./quick_start.md)中包含大量模型微调的示例,可以参考该章节在特定的数据集上进行模型微调。
<a name="model_resume"></a>
### 2.3 模型恢复训练
如果训练任务因为其他原因被终止,也可以加载断点权重文件继续训练。
......@@ -200,6 +201,7 @@ python -m paddle.distributed.launch \
参数说明详见[1.4 模型评估](#1.4)
<a name="model_infer"></a>
## 3. 使用预训练模型进行模型预测
模型训练完成之后,可以加载训练得到的预训练模型,进行模型预测。在模型库的 `tools/infer/infer.py` 中提供了完整的示例,只需执行下述命令即可完成模型预测:
......@@ -219,8 +221,11 @@ python tools/infer/infer.py \
+ `pretrained_model`(简写 p):权重文件路径,如 `./pretrained/ResNet50_vd_pretrained/`
+ `use_gpu` : 是否开启GPU训练,默认值:`True`
+ `load_static_weights` : 是否加载静态图训练得到的预训练模型,默认值:`False`
+ `pre_label_image` : 是否对图像数据进行预标注,默认值:`False`
+ `pre_label_out_idr` : 预标注图像数据的输出文件夹,当`pre_label_image=True`时,会在该文件夹下面生成很多个子文件夹,每个文件夹名称为类别id,其中存储模型预测属于该类别的所有图像。
<a name="model_inference"></a>
## 4. 使用inference模型模型推理
通过导出inference模型,PaddlePaddle支持使用预测引擎进行预测推理。接下来介绍如何用预测引擎进行推理:
......
......@@ -15,6 +15,7 @@
import numpy as np
import argparse
import utils
import shutil
import os
import sys
__dir__ = os.path.dirname(os.path.abspath(__file__))
......@@ -38,7 +39,19 @@ def parse_args():
parser.add_argument("-m", "--model", type=str)
parser.add_argument("-p", "--pretrained_model", type=str)
parser.add_argument("--use_gpu", type=str2bool, default=True)
parser.add_argument("--load_static_weights", type=str2bool, default=False)
parser.add_argument(
"--load_static_weights",
type=str2bool,
default=False,
help='Whether to load the pretrained weights saved in static mode')
# parameters for pre-label the images
parser.add_argument(
"--pre_label_image",
type=str2bool,
default=False,
help="Whether to pre-label the images using the loaded weights")
parser.add_argument("--pre_label_out_idr", type=str, default=None)
return parser.parse_args()
......@@ -63,7 +76,6 @@ def preprocess(fname, ops):
data = open(fname, 'rb').read()
for op in ops:
data = op(data)
return data
......@@ -91,6 +103,13 @@ def get_image_list(img_file):
return imgs_lists
def save_prelabel_results(class_id, input_filepath, output_idr):
output_dir = os.path.join(output_idr, str(class_id))
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
shutil.copy(input_filepath, output_dir)
def main():
args = parse_args()
operators = create_operators()
......@@ -117,14 +136,22 @@ def main():
else:
outputs = F.softmax(outputs)
outputs = outputs.numpy()
probs = postprocess(outputs)
top1_class_id = 0
rank = 1
print("Current image file: {}".format(filename))
for idx, prob in probs:
print("\ttop{:d}, class id: {:d}, probability: {:.4f}".format(
rank, idx, prob))
if rank == 1:
top1_class_id = idx
rank += 1
if args.pre_label_image:
save_prelabel_results(top1_class_id, filename,
args.pre_label_out_idr)
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册