diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b8c959 --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# ---> Eagle +# Ignore list for Eagle, a PCB layout tool + +# Backup files +*.s#? +*.b#? +*.l#? +*.b$? +*.s$? +*.l$? + +# Eagle project file +# It contains a serial number and references to the file structure +# on your computer. +# comment the following line if you want to have your project file included. +eagle.epf + +# Autorouter files +*.pro +*.job + +# CAM files +*.$$$ +*.cmp +*.ly2 +*.l15 +*.sol +*.plc +*.stc +*.sts +*.crc +*.crs + +*.dri +*.drl +*.gpi +*.pls +*.ger +*.xln + +*.drd +*.drd.* + +*.s#* +*.b#* + +*.info + +*.eps + +# file locks introduced since 7.x +*.lck + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..426989f --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Information_Management_System + diff --git a/doc/无人机的路径生成及绘制环境图-软件系统需求构思及描述.docx b/doc/无人机的路径生成及绘制环境图-软件系统需求构思及描述.docx new file mode 100644 index 0000000..2bffe08 Binary files /dev/null and b/doc/无人机的路径生成及绘制环境图-软件系统需求构思及描述.docx differ diff --git a/doc/无人机的路径生成及绘制环境图-软件设计规格说明书.doc b/doc/无人机的路径生成及绘制环境图-软件设计规格说明书.doc new file mode 100644 index 0000000..eaa3e07 Binary files /dev/null and b/doc/无人机的路径生成及绘制环境图-软件设计规格说明书.doc differ diff --git a/doc/无人机的路径生成及绘制环境图-软件需求规格说明书.docx b/doc/无人机的路径生成及绘制环境图-软件需求规格说明书.docx new file mode 100644 index 0000000..7a5f13a Binary files /dev/null and b/doc/无人机的路径生成及绘制环境图-软件需求规格说明书.docx differ diff --git a/model/软件体系结构分层结构.eddx b/model/软件体系结构分层结构.eddx new file mode 100644 index 0000000..0ebce49 Binary files /dev/null and b/model/软件体系结构分层结构.eddx differ diff --git a/src/PaddleClas/MANIFEST.in b/src/PaddleClas/MANIFEST.in new file mode 100644 index 0000000..b0a4f6d --- /dev/null +++ b/src/PaddleClas/MANIFEST.in @@ -0,0 +1,7 @@ +include LICENSE.txt +include README.md +include docs/en/whl_en.md +recursive-include deploy/python predict_cls.py preprocess.py postprocess.py det_preprocess.py +recursive-include deploy/utils get_image_list.py config.py logger.py predictor.py + +recursive-include ppcls/ *.py *.txt \ No newline at end of file diff --git a/src/PaddleClas/__init__.py b/src/PaddleClas/__init__.py new file mode 100644 index 0000000..2128a6c --- /dev/null +++ b/src/PaddleClas/__init__.py @@ -0,0 +1,17 @@ +# 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. + +__all__ = ['PaddleClas'] +from .paddleclas import PaddleClas +from ppcls.arch.backbone import * diff --git a/src/PaddleClas/benchmark/README.md b/src/PaddleClas/benchmark/README.md new file mode 100644 index 0000000..2e892d9 --- /dev/null +++ b/src/PaddleClas/benchmark/README.md @@ -0,0 +1,27 @@ +# benchmark使用说明 + +此目录所有shell脚本是为了测试PaddleClas中不同模型的速度指标,如单卡训练速度指标、多卡训练速度指标等。 + +## 相关脚本说明 + +一共有3个脚本: + +- `prepare_data.sh`: 下载相应的测试数据,并配置好数据路径 +- `run_benchmark.sh`: 执行单独一个训练测试的脚本,具体调用方式,可查看脚本注释 +- `run_all.sh`: 执行所有训练测试的入口脚本 + +## 使用说明 + +**注意**:为了跟PaddleClas中其他的模块的执行目录保持一致,此模块的执行目录为`PaddleClas`的根目录。 + +### 1.准备数据 + +```shell +bash benchmark/prepare_data.sh +``` + +### 2.执行所有模型的测试 + +```shell +bash benchmark/run_all.sh +``` diff --git a/src/PaddleClas/benchmark/prepare_data.sh b/src/PaddleClas/benchmark/prepare_data.sh new file mode 100644 index 0000000..411459c --- /dev/null +++ b/src/PaddleClas/benchmark/prepare_data.sh @@ -0,0 +1,22 @@ +#!/bin/bash +dataset_url=$1 + +package_check_list=(imageio tqdm Cython pycocotools tb_paddle scipy pandas wget h5py sklearn opencv-python visualdl) +for package in ${package_check_list[@]}; do + if python -c "import ${package}" >/dev/null 2>&1; then + echo "${package} have already installed" + else + echo "${package} NOT FOUND" + pip install ${package} + echo "${package} installed" + fi +done + +cd dataset +rm -rf ILSVRC2012 +wget -nc ${dataset_url} +tar xf ILSVRC2012_val.tar +ln -s ILSVRC2012_val ILSVRC2012 +cd ILSVRC2012 +ln -s val_list.txt train_list.txt +cd ../../ diff --git a/src/PaddleClas/benchmark/run_all.sh b/src/PaddleClas/benchmark/run_all.sh new file mode 100644 index 0000000..a6d6884 --- /dev/null +++ b/src/PaddleClas/benchmark/run_all.sh @@ -0,0 +1,31 @@ +# 提供可稳定复现性能的脚本,默认在标准docker环境内py37执行: paddlepaddle/paddle:latest-gpu-cuda10.1-cudnn7 paddle=2.1.2 py=37 +# 执行目录:需说明 +# cd ** +# 1 安装该模型需要的依赖 (如需开启优化策略请注明) +# pip install ... +# 2 拷贝该模型需要数据、预训练模型 +# 3 批量运行(如不方便批量,1,2需放到单个模型中) +log_path=${LOG_PATH_INDEX_DIR:-$(pwd)} # LOG_PATH_INDEX_DIR 后续QA设置参数 +model_mode_list=(MobileNetV1 MobileNetV2 MobileNetV3_large_x1_0 ShuffleNetV2_x1_0 HRNet_W48_C SwinTransformer_tiny_patch4_window7_224 alt_gvt_base) # benchmark 监控模型列表 +#model_mode_list=(MobileNetV1 MobileNetV2 MobileNetV3_large_x1_0 EfficientNetB0 ShuffleNetV2_x1_0 DenseNet121 HRNet_W48_C SwinTransformer_tiny_patch4_window7_224 alt_gvt_base) # 该脚本支持列表 +fp_item_list=(fp32) +#bs_list=(32 64 96 128) +for model_mode in ${model_mode_list[@]}; do + for fp_item in ${fp_item_list[@]}; do + if [ ${model_mode} = MobileNetV3_large_x1_0 ] || [ ${model_mode} = ShuffleNetV2_x1_0 ]; then + bs_list=(256) + else + bs_list=(64) + fi + for bs_item in ${bs_list[@]};do + echo "index is speed, 1gpus, begin, ${model_name}" + run_mode=sp + CUDA_VISIBLE_DEVICES=0 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 1 ${model_mode} | tee ${log_path}/clas_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_1gpus 2>&1 # (5min) + sleep 10 + echo "index is speed, 8gpus, run_mode is multi_process, begin, ${model_name}" + run_mode=mp + CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 1 ${model_mode}| tee ${log_path}/clas_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_8gpus8p 2>&1 + sleep 10 + done + done +done diff --git a/src/PaddleClas/benchmark/run_benchmark.sh b/src/PaddleClas/benchmark/run_benchmark.sh new file mode 100644 index 0000000..8cee6fc --- /dev/null +++ b/src/PaddleClas/benchmark/run_benchmark.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +set -xe +# 运行示例:CUDA_VISIBLE_DEVICES=0 bash run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 500 ${model_mode} +# 参数说明 +function _set_params(){ + run_mode=${1:-"sp"} # 单卡sp|多卡mp + batch_size=${2:-"64"} + fp_item=${3:-"fp32"} # fp32|fp16 + epochs=${4:-"2"} # 可选,如果需要修改代码提前中断 + model_item=${5:-"model_item"} + run_log_path=${TRAIN_LOG_DIR:-$(pwd)} # TRAIN_LOG_DIR 后续QA设置该参数 + + index=1 + mission_name="图像分类" # 模型所属任务名称,具体可参考scripts/config.ini (必填) + direction_id=0 # 任务所属方向,0:CV,1:NLP,2:Rec。 (必填) + skip_steps=8 # 解析日志,有些模型前几个step耗时长,需要跳过 (必填) + keyword="ips:" # 解析日志,筛选出数据所在行的关键字 (必填) + keyword_loss="loss:" #选填 + model_mode=-1 # 解析日志,具体参考scripts/analysis.py. (必填) + ips_unit="images/s" + base_batch_size=$batch_size +# 以下不用修改 + device=${CUDA_VISIBLE_DEVICES//,/ } + arr=(${device}) + num_gpu_devices=${#arr[*]} + log_file=${run_log_path}/clas_${model_item}_${run_mode}_bs${batch_size}_${fp_item}_${num_gpu_devices} + model_name=${model_item}_bs${batch_size}_${fp_item} # model_item 用于yml匹配,model_name用于入库 +} +function _train(){ + echo "Train on ${num_gpu_devices} GPUs" + echo "current CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES, gpus=$num_gpu_devices, batch_size=$batch_size" + + if [ ${fp_item} = "fp32" ];then + model_config=`find ppcls/configs/ImageNet -name ${model_item}.yaml` + else + model_config=`find ppcls/configs/ImageNet -name ${model_item}_fp16.yaml` + fi + + train_cmd="-c ${model_config} -o DataLoader.Train.sampler.batch_size=${batch_size} -o Global.epochs=${epochs} -o Global.eval_during_train=False -o Global.print_batch_step=2" + case ${run_mode} in + sp) train_cmd="python -u tools/train.py ${train_cmd}" ;; + mp) + train_cmd="python -m paddle.distributed.launch --log_dir=./mylog --gpus=$CUDA_VISIBLE_DEVICES tools/train.py ${train_cmd}" + log_parse_file="mylog/workerlog.0" ;; + *) echo "choose run_mode(sp or mp)"; exit 1; + esac + rm -rf mylog +# 以下不用修改 + timeout 5m ${train_cmd} > ${log_file} 2>&1 + if [ $? -ne 0 ];then + echo -e "${model_name}, FAIL" + export job_fail_flag=1 + else + echo -e "${model_name}, SUCCESS" + export job_fail_flag=0 + fi + kill -9 `ps -ef|grep 'python'|awk '{print $2}'` + + if [ $run_mode = "mp" -a -d mylog ]; then + rm ${log_file} + cp mylog/workerlog.0 ${log_file} + fi +} + +source ${BENCHMARK_ROOT}/scripts/run_model.sh # 在该脚本中会对符合benchmark规范的log使用analysis.py 脚本进行性能数据解析;该脚本在连调时可从benchmark repo中下载https://github.com/PaddlePaddle/benchmark/blob/master/scripts/run_model.sh;如果不联调只想要产出训练log可以注掉本行,提交时需打开 +_set_params $@ +_run +#_train diff --git a/src/PaddleClas/dataset/.gitkeep b/src/PaddleClas/dataset/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/.idea/.gitignore b/src/PaddleClas/deploy/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/src/PaddleClas/deploy/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/src/PaddleClas/deploy/.idea/deploy.iml b/src/PaddleClas/deploy/.idea/deploy.iml new file mode 100644 index 0000000..8a05c6e --- /dev/null +++ b/src/PaddleClas/deploy/.idea/deploy.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/.idea/inspectionProfiles/profiles_settings.xml b/src/PaddleClas/deploy/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/src/PaddleClas/deploy/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/.idea/misc.xml b/src/PaddleClas/deploy/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/src/PaddleClas/deploy/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/.idea/modules.xml b/src/PaddleClas/deploy/.idea/modules.xml new file mode 100644 index 0000000..1071ae1 --- /dev/null +++ b/src/PaddleClas/deploy/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/.scannerwork/.sonar_lock b/src/PaddleClas/deploy/.scannerwork/.sonar_lock new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/.scannerwork/report-task.txt b/src/PaddleClas/deploy/.scannerwork/report-task.txt new file mode 100644 index 0000000..d55dfb8 --- /dev/null +++ b/src/PaddleClas/deploy/.scannerwork/report-task.txt @@ -0,0 +1,6 @@ +projectKey=deploy +serverUrl=http://localhost:9000 +serverVersion=8.1.0.31237 +dashboardUrl=http://localhost:9000/dashboard?id=deploy +ceTaskId=AYA_xvBwrgFtfprwzYuQ +ceTaskUrl=http://localhost:9000/api/ce/task?id=AYA_xvBwrgFtfprwzYuQ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_1.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_1.jpg new file mode 100644 index 0000000..ec10770 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_1.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_10.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_10.jpg new file mode 100644 index 0000000..5fca3bf Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_10.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_100.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_100.jpg new file mode 100644 index 0000000..3588191 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_100.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_11.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_11.jpg new file mode 100644 index 0000000..14f07c9 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_11.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_12.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_12.jpg new file mode 100644 index 0000000..702051a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_12.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_13.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_13.jpg new file mode 100644 index 0000000..01126ea Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_13.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_14.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_14.jpg new file mode 100644 index 0000000..3f8bc89 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_14.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_15.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_15.jpg new file mode 100644 index 0000000..d2431a6 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_15.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_16.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_16.jpg new file mode 100644 index 0000000..d466de8 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_16.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_17.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_17.jpg new file mode 100644 index 0000000..d73830e Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_17.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_18.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_18.jpg new file mode 100644 index 0000000..2330c27 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_18.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_19.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_19.jpg new file mode 100644 index 0000000..76ef557 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_19.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_2.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_2.jpg new file mode 100644 index 0000000..f541386 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_2.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_20.GIF b/src/PaddleClas/deploy/Trees/gallery/0/Image_20.GIF new file mode 100644 index 0000000..c7d40c7 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_20.GIF differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_2001.png b/src/PaddleClas/deploy/Trees/gallery/0/Image_2001.png new file mode 100644 index 0000000..3b4d6ce Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_2001.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_21.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_21.jpg new file mode 100644 index 0000000..6ba0ae5 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_21.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_22.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_22.jpg new file mode 100644 index 0000000..11481a0 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_22.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_23.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_23.jpg new file mode 100644 index 0000000..8df03b9 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_23.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_24.GIF b/src/PaddleClas/deploy/Trees/gallery/0/Image_24.GIF new file mode 100644 index 0000000..6775510 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_24.GIF differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_25.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_25.jpg new file mode 100644 index 0000000..4e6f77a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_25.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_26.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_26.jpg new file mode 100644 index 0000000..8a65677 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_26.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_27.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_27.jpg new file mode 100644 index 0000000..9d458aa Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_27.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_28.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_28.jpg new file mode 100644 index 0000000..1abba95 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_28.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_29.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_29.jpg new file mode 100644 index 0000000..6d94ca7 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_29.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_3.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_3.jpg new file mode 100644 index 0000000..dda97fe Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_3.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_30.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_30.jpg new file mode 100644 index 0000000..884e61d Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_30.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_31.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_31.jpg new file mode 100644 index 0000000..09768ea Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_31.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_32.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_32.jpg new file mode 100644 index 0000000..8963b22 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_32.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_33.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_33.jpg new file mode 100644 index 0000000..76a983b Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_33.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_34.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_34.JPG new file mode 100644 index 0000000..232a661 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_34.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_35.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_35.jpg new file mode 100644 index 0000000..d208c15 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_35.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_36.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_36.jpg new file mode 100644 index 0000000..02d8547 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_36.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_37.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_37.jpg new file mode 100644 index 0000000..9003b1c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_37.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_38.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_38.jpg new file mode 100644 index 0000000..c842b91 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_38.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_39.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_39.jpg new file mode 100644 index 0000000..6ca2d5c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_39.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_4.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_4.jpg new file mode 100644 index 0000000..b9b3795 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_4.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_40.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_40.jpg new file mode 100644 index 0000000..517349e Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_40.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_41.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_41.JPG new file mode 100644 index 0000000..2b15a9a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_41.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_42.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_42.JPG new file mode 100644 index 0000000..c334734 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_42.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_43.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_43.jpg new file mode 100644 index 0000000..bd855bb Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_43.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_44.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_44.jpg new file mode 100644 index 0000000..c0786db Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_44.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_45.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_45.jpg new file mode 100644 index 0000000..e99329c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_45.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_46.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_46.jpg new file mode 100644 index 0000000..8d8e08a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_46.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_47.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_47.jpg new file mode 100644 index 0000000..bb4b665 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_47.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_48.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_48.jpg new file mode 100644 index 0000000..47ea88f Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_48.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_49.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_49.jpg new file mode 100644 index 0000000..0d7298c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_49.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_5.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_5.jpg new file mode 100644 index 0000000..6ccbc9c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_5.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_50.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_50.JPG new file mode 100644 index 0000000..3833fdd Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_50.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_51.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_51.jpg new file mode 100644 index 0000000..9bb379a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_51.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_52.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_52.jpg new file mode 100644 index 0000000..e217583 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_52.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_53.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_53.jpg new file mode 100644 index 0000000..ea90113 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_53.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_54.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_54.jpg new file mode 100644 index 0000000..fe4aadc Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_54.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_55.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_55.jpg new file mode 100644 index 0000000..38dbf05 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_55.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_56.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_56.jpg new file mode 100644 index 0000000..9d150e1 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_56.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_57.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_57.jpg new file mode 100644 index 0000000..2adbf1d Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_57.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_58.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_58.jpg new file mode 100644 index 0000000..14e9595 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_58.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_59.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_59.jpg new file mode 100644 index 0000000..3165ab9 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_59.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_6.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_6.jpg new file mode 100644 index 0000000..90d8f5b Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_6.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_60.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_60.jpg new file mode 100644 index 0000000..b5bed40 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_60.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_61.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_61.jpg new file mode 100644 index 0000000..49a0acb Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_61.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_62.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_62.jpg new file mode 100644 index 0000000..ae3689c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_62.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_63.GIF b/src/PaddleClas/deploy/Trees/gallery/0/Image_63.GIF new file mode 100644 index 0000000..ed1d98a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_63.GIF differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_64.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_64.jpg new file mode 100644 index 0000000..94116a9 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_64.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_65.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_65.JPG new file mode 100644 index 0000000..b1ae445 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_65.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_66.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_66.jpg new file mode 100644 index 0000000..690995d Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_66.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_67.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_67.JPG new file mode 100644 index 0000000..d845f5d Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_67.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_68.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_68.jpg new file mode 100644 index 0000000..6bf3f87 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_68.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_69.png b/src/PaddleClas/deploy/Trees/gallery/0/Image_69.png new file mode 100644 index 0000000..662fee0 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_69.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_7.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_7.jpg new file mode 100644 index 0000000..3588191 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_7.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_70.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_70.jpg new file mode 100644 index 0000000..193e3c5 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_70.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_71.GIF b/src/PaddleClas/deploy/Trees/gallery/0/Image_71.GIF new file mode 100644 index 0000000..6ca874d Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_71.GIF differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_72.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_72.jpg new file mode 100644 index 0000000..cc895ed Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_72.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_73.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_73.jpg new file mode 100644 index 0000000..d2178d0 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_73.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_74.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_74.jpg new file mode 100644 index 0000000..9bc526c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_74.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_75.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_75.jpg new file mode 100644 index 0000000..0822d97 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_75.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_76.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_76.jpg new file mode 100644 index 0000000..d21e900 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_76.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_77.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_77.jpg new file mode 100644 index 0000000..050abd8 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_77.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_78.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_78.jpg new file mode 100644 index 0000000..213b099 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_78.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_79.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_79.jpg new file mode 100644 index 0000000..012ba5d Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_79.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_8.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_8.JPG new file mode 100644 index 0000000..cecf8f8 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_8.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_80.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_80.jpg new file mode 100644 index 0000000..a516319 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_80.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_81.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_81.jpg new file mode 100644 index 0000000..b2fd51c Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_81.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_82.GIF b/src/PaddleClas/deploy/Trees/gallery/0/Image_82.GIF new file mode 100644 index 0000000..63c3cc5 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_82.GIF differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_83.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_83.jpg new file mode 100644 index 0000000..4f6dcd2 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_83.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_84.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_84.jpg new file mode 100644 index 0000000..6d8e7c3 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_84.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_85.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_85.jpg new file mode 100644 index 0000000..b359e03 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_85.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_86.JPG b/src/PaddleClas/deploy/Trees/gallery/0/Image_86.JPG new file mode 100644 index 0000000..274de00 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_86.JPG differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_87.png b/src/PaddleClas/deploy/Trees/gallery/0/Image_87.png new file mode 100644 index 0000000..bf39fe1 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_87.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_88.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_88.jpg new file mode 100644 index 0000000..3a668a4 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_88.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_89.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_89.jpg new file mode 100644 index 0000000..89b8391 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_89.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_9.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_9.jpg new file mode 100644 index 0000000..f2a96ff Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_9.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_90.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_90.jpg new file mode 100644 index 0000000..ea45e0f Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_90.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_91.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_91.jpg new file mode 100644 index 0000000..cb28403 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_91.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_92.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_92.jpg new file mode 100644 index 0000000..427143f Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_92.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_93.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_93.jpg new file mode 100644 index 0000000..4d411b4 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_93.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_94.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_94.jpg new file mode 100644 index 0000000..ec10770 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_94.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_95.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_95.jpg new file mode 100644 index 0000000..f541386 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_95.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_96.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_96.jpg new file mode 100644 index 0000000..dda97fe Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_96.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_97.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_97.jpg new file mode 100644 index 0000000..b9b3795 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_97.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_98.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_98.jpg new file mode 100644 index 0000000..ef34d0e Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_98.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/0/Image_99.jpg b/src/PaddleClas/deploy/Trees/gallery/0/Image_99.jpg new file mode 100644 index 0000000..90d8f5b Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/0/Image_99.jpg differ diff --git a/src/PaddleClas/deploy/Trees/gallery/1/Image_2007.png b/src/PaddleClas/deploy/Trees/gallery/1/Image_2007.png new file mode 100644 index 0000000..b2dcb5f Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/1/Image_2007.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/Image_2002.png b/src/PaddleClas/deploy/Trees/gallery/Image_2002.png new file mode 100644 index 0000000..369b4b7 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/Image_2002.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/Image_2003.png b/src/PaddleClas/deploy/Trees/gallery/Image_2003.png new file mode 100644 index 0000000..7b70f9e Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/Image_2003.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/Image_2004.png b/src/PaddleClas/deploy/Trees/gallery/Image_2004.png new file mode 100644 index 0000000..2720a67 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/Image_2004.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/Image_2005.png b/src/PaddleClas/deploy/Trees/gallery/Image_2005.png new file mode 100644 index 0000000..e92a210 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/Image_2005.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/Image_2006.png b/src/PaddleClas/deploy/Trees/gallery/Image_2006.png new file mode 100644 index 0000000..bf944c4 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/gallery/Image_2006.png differ diff --git a/src/PaddleClas/deploy/Trees/gallery/tree_list.txt b/src/PaddleClas/deploy/Trees/gallery/tree_list.txt new file mode 100644 index 0000000..abb056f --- /dev/null +++ b/src/PaddleClas/deploy/Trees/gallery/tree_list.txt @@ -0,0 +1,2261 @@ +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +0/Image_2001.png tree +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees +1/Image_2007.png trees diff --git a/src/PaddleClas/deploy/Trees/gallery/tree_list_1.txt b/src/PaddleClas/deploy/Trees/gallery/tree_list_1.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/Trees/gallery/tree_list_all.txt b/src/PaddleClas/deploy/Trees/gallery/tree_list_all.txt new file mode 100644 index 0000000..4e87ed7 --- /dev/null +++ b/src/PaddleClas/deploy/Trees/gallery/tree_list_all.txt @@ -0,0 +1,95 @@ +0/Image_1.jpg tree +0/Image_10.jpg tree +0/Image_100.jpg tree +0/Image_11.jpg tree +0/Image_12.jpg tree +0/Image_13.jpg tree +0/Image_14.jpg tree +0/Image_15.jpg tree +0/Image_16.jpg tree +0/Image_17.jpg tree +0/Image_18.jpg tree +0/Image_19.jpg tree +0/Image_2.jpg tree +0/Image_21.jpg tree +0/Image_22.jpg tree +0/Image_23.jpg tree +0/Image_25.jpg tree +0/Image_26.jpg tree +0/Image_27.jpg tree +0/Image_28.jpg tree +0/Image_29.jpg tree +0/Image_3.jpg tree +0/Image_30.jpg tree +0/Image_31.jpg tree +0/Image_32.jpg tree +0/Image_33.jpg tree +0/Image_34.JPG tree +0/Image_35.jpg tree +0/Image_36.jpg tree +0/Image_37.jpg tree +0/Image_38.jpg tree +0/Image_39.jpg tree +0/Image_4.jpg tree +0/Image_40.jpg tree +0/Image_41.JPG tree +0/Image_42.JPG tree +0/Image_43.jpg tree +0/Image_44.jpg tree +0/Image_45.jpg tree +0/Image_46.jpg tree +0/Image_47.jpg tree +0/Image_48.jpg tree +0/Image_49.jpg tree +0/Image_5.jpg tree +0/Image_50.JPG tree +0/Image_51.jpg tree +0/Image_52.jpg tree +0/Image_53.jpg tree +0/Image_54.jpg tree +0/Image_55.jpg tree +0/Image_56.jpg tree +0/Image_57.jpg tree +0/Image_58.jpg tree +0/Image_59.jpg tree +0/Image_6.jpg tree +0/Image_60.jpg tree +0/Image_61.jpg tree +0/Image_62.jpg tree +0/Image_64.jpg tree +0/Image_65.JPG tree +0/Image_66.jpg tree +0/Image_67.JPG tree +0/Image_68.jpg tree +0/Image_69.png tree +0/Image_7.jpg tree +0/Image_70.jpg tree +0/Image_72.jpg tree +0/Image_73.jpg tree +0/Image_74.jpg tree +0/Image_75.jpg tree +0/Image_76.jpg tree +0/Image_77.jpg tree +0/Image_78.jpg tree +0/Image_79.jpg tree +0/Image_8.JPG tree +0/Image_80.jpg tree +0/Image_81.jpg tree +0/Image_83.jpg tree +0/Image_84.jpg tree +0/Image_85.jpg tree +0/Image_86.JPG tree +0/Image_87.png tree +0/Image_88.jpg tree +0/Image_89.jpg tree +0/Image_9.jpg tree +0/Image_90.jpg tree +0/Image_91.jpg tree +0/Image_92.jpg tree +0/Image_93.jpg tree +0/Image_94.jpg tree +0/Image_95.jpg tree +0/Image_96.jpg tree +0/Image_97.jpg tree +0/Image_98.jpg tree +0/Image_99.jpg tree diff --git a/src/PaddleClas/deploy/Trees/index/id_map.pkl b/src/PaddleClas/deploy/Trees/index/id_map.pkl new file mode 100644 index 0000000..3e774b1 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/index/id_map.pkl differ diff --git a/src/PaddleClas/deploy/Trees/index/vector.index b/src/PaddleClas/deploy/Trees/index/vector.index new file mode 100644 index 0000000..fd1b257 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/index/vector.index differ diff --git a/src/PaddleClas/deploy/Trees/test_images/157333-1868444027.jpg b/src/PaddleClas/deploy/Trees/test_images/157333-1868444027.jpg new file mode 100644 index 0000000..631bdda Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/157333-1868444027.jpg differ diff --git a/src/PaddleClas/deploy/Trees/test_images/202103160813194077.jpg b/src/PaddleClas/deploy/Trees/test_images/202103160813194077.jpg new file mode 100644 index 0000000..6f9cb09 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/202103160813194077.jpg differ diff --git a/src/PaddleClas/deploy/Trees/test_images/202103160813194078.jpg b/src/PaddleClas/deploy/Trees/test_images/202103160813194078.jpg new file mode 100644 index 0000000..95c4b3a Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/202103160813194078.jpg differ diff --git a/src/PaddleClas/deploy/Trees/test_images/90.jpeg b/src/PaddleClas/deploy/Trees/test_images/90.jpeg new file mode 100644 index 0000000..f13b396 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/90.jpeg differ diff --git a/src/PaddleClas/deploy/Trees/test_images/Image_4.png b/src/PaddleClas/deploy/Trees/test_images/Image_4.png new file mode 100644 index 0000000..aa938ce Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/Image_4.png differ diff --git a/src/PaddleClas/deploy/Trees/test_images/Image_5.png b/src/PaddleClas/deploy/Trees/test_images/Image_5.png new file mode 100644 index 0000000..694bc24 Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/Image_5.png differ diff --git a/src/PaddleClas/deploy/Trees/test_images/Image_6.jpg b/src/PaddleClas/deploy/Trees/test_images/Image_6.jpg new file mode 100644 index 0000000..90d8f5b Binary files /dev/null and b/src/PaddleClas/deploy/Trees/test_images/Image_6.jpg differ diff --git a/src/PaddleClas/deploy/__init__.py b/src/PaddleClas/deploy/__init__.py new file mode 100644 index 0000000..eb018c3 --- /dev/null +++ b/src/PaddleClas/deploy/__init__.py @@ -0,0 +1 @@ +from . import utils diff --git a/src/PaddleClas/deploy/configs/ShuffleNetV2_x0_25.yaml b/src/PaddleClas/deploy/configs/ShuffleNetV2_x0_25.yaml new file mode 100644 index 0000000..1246366 --- /dev/null +++ b/src/PaddleClas/deploy/configs/ShuffleNetV2_x0_25.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: cpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 20 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x0_25 + class_num: 102 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.0125 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ./dataset/flowers102/flowers102_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/deploy/configs/build_general.yaml b/src/PaddleClas/deploy/configs/build_general.yaml new file mode 100644 index 0000000..a632c99 --- /dev/null +++ b/src/PaddleClas/deploy/configs/build_general.yaml @@ -0,0 +1,36 @@ +Global: + rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_v1.0_infer" + batch_size: 32 + use_gpu: False + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + image_root: "./flowers102/gallery/" + index_dir: "./flowers102/index" + data_file: "./flowers102/gallery/train_label.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 diff --git a/src/PaddleClas/deploy/configs/inference_cartoon.yaml b/src/PaddleClas/deploy/configs/inference_cartoon.yaml new file mode 100644 index 0000000..7d93d98 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_cartoon.yaml @@ -0,0 +1,65 @@ +Global: + infer_imgs: "./recognition_demo_data_v1.1/test_cartoon" + det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/" + rec_inference_model_dir: "./models/cartoon_rec_ResNet50_iCartoon_v1.0_infer/" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + index_dir: "./recognition_demo_data_v1.1/gallery_cartoon/index/" + image_root: "./recognition_demo_data_v1.1/gallery_cartoon/" + data_file: "./recognition_demo_data_v1.1/gallery_cartoon/data_file.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 2048 + batch_size: 32 + return_k: 5 + score_thres: 0.5 \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_cls.yaml b/src/PaddleClas/deploy/configs/inference_cls.yaml new file mode 100644 index 0000000..fc0f0fe --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_cls.yaml @@ -0,0 +1,35 @@ +Global: + infer_imgs: "./images/ILSVRC2012_val_00000010.jpeg" + inference_model_dir: "./models" + batch_size: 1 + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +PreProcess: + transform_ops: + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + channel_num: 3 + - ToCHWImage: + +PostProcess: + main_indicator: Topk + Topk: + topk: 5 + class_id_map_file: "../ppcls/utils/imagenet1k_label_list.txt" + SavePreLabel: + save_dir: ./pre_label/ \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_cls_ch4.yaml b/src/PaddleClas/deploy/configs/inference_cls_ch4.yaml new file mode 100644 index 0000000..9b740ed --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_cls_ch4.yaml @@ -0,0 +1,35 @@ +Global: + infer_imgs: "./images/ILSVRC2012_val_00000010.jpeg" + inference_model_dir: "./models" + batch_size: 1 + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +PreProcess: + transform_ops: + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + channel_num: 4 + - ToCHWImage: + +PostProcess: + main_indicator: Topk + Topk: + topk: 5 + class_id_map_file: "../ppcls/utils/imagenet1k_label_list.txt" + SavePreLabel: + save_dir: ./pre_label/ \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_cls_multilabel.yaml b/src/PaddleClas/deploy/configs/inference_cls_multilabel.yaml new file mode 100644 index 0000000..78912d0 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_cls_multilabel.yaml @@ -0,0 +1,35 @@ +Global: + infer_imgs: "./images/0517_2715693311.jpg" + inference_model_dir: "../inference/" + batch_size: 1 + use_gpu: True + enable_mkldnn: False + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +PreProcess: + transform_ops: + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + channel_num: 3 + - ToCHWImage: + +PostProcess: + main_indicator: MultiLabelTopk + MultiLabelTopk: + topk: 5 + class_id_map_file: None + SavePreLabel: + save_dir: ./pre_label/ \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_det.yaml b/src/PaddleClas/deploy/configs/inference_det.yaml new file mode 100644 index 0000000..c809a02 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_det.yaml @@ -0,0 +1,34 @@ +Global: + infer_imgs: "./images/wangzai.jpg" + det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer" + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 1 + labe_list: + - foreground + + # inference engine config + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_drink.yaml b/src/PaddleClas/deploy/configs/inference_drink.yaml new file mode 100644 index 0000000..d044965 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_drink.yaml @@ -0,0 +1,63 @@ +Global: + infer_imgs: "./drink_dataset_v1.0/test_images/hongniu_1.jpg" + det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer" + rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_v1.0_infer" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + use_gpu: True + enable_mkldnn: False + cpu_num_threads: 10 + enable_benchmark: False + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + image_root: "./drink_dataset_v1.0/gallery" + index_dir: "./drink_dataset_v1.0/index" + data_file: "./drink_dataset_v1.0/gallery/drink_label.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: " " + dist_type: "IP" + embedding_size: 512 + batch_size: 32 + return_k: 5 + score_thres: 0.4 \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_general.yaml b/src/PaddleClas/deploy/configs/inference_general.yaml new file mode 100644 index 0000000..df5ab58 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_general.yaml @@ -0,0 +1,63 @@ +Global: + infer_imgs: "./drink_dataset_v1.0/test_images/1101.jpeg" + det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer" + rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_v1.0_infer" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + image_root: "./Trees/gallery/" + index_dir: "./Trees/index" + data_file: "./Trees/gallery/tree_list.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 + batch_size: 32 + return_k: 5 + score_thres: 0.5 \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_general_binary.yaml b/src/PaddleClas/deploy/configs/inference_general_binary.yaml new file mode 100644 index 0000000..d76dae8 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_general_binary.yaml @@ -0,0 +1,65 @@ +Global: + infer_imgs: "./drink_dataset_v1.0/test_images/001.jpeg" + det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer" + rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_binary_v1.0_infer" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: + main_indicator: Binarize + Binarize: + method: "sign" + +# indexing engine config +IndexProcess: + index_method: "Flat" # supported: HNSW32, Flat + image_root: "./drink_dataset_v1.0/gallery/" + index_dir: "./drink_dataset_v1.0/index_bin" + data_file: "./drink_dataset_v1.0/gallery/drink_label.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "hamming" + embedding_size: 512 + batch_size: 32 + return_k: 5 + hamming_radius: 100 diff --git a/src/PaddleClas/deploy/configs/inference_logo.yaml b/src/PaddleClas/deploy/configs/inference_logo.yaml new file mode 100644 index 0000000..f78ca25 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_logo.yaml @@ -0,0 +1,63 @@ +Global: + infer_imgs: "./recognition_demo_data_v1.1/test_logo" + det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/" + rec_inference_model_dir: "./models/logo_rec_ResNet50_Logo3K_v1.0_infer/" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + index_dir: "./recognition_demo_data_v1.1/gallery_logo/index/" + image_root: "./recognition_demo_data_v1.1/gallery_logo/" + data_file: "./recognition_demo_data_v1.1/gallery_logo/data_file.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 + batch_size: 32 + return_k: 5 + score_thres: 0.5 \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_product.yaml b/src/PaddleClas/deploy/configs/inference_product.yaml new file mode 100644 index 0000000..e7b494c --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_product.yaml @@ -0,0 +1,64 @@ +Global: + infer_imgs: "./recognition_demo_data_v1.1/test_product/daoxiangcunjinzhubing_6.jpg" + det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer" + rec_inference_model_dir: "./models/product_ResNet50_vd_aliproduct_v1.0_infer" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + # inference engine config + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + index_dir: "./recognition_demo_data_v1.1/gallery_product/index" + image_root: "./recognition_demo_data_v1.1/gallery_product/" + data_file: "./recognition_demo_data_v1.1/gallery_product/data_file.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 + batch_size: 32 + return_k: 5 + score_thres: 0.5 \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_rec.yaml b/src/PaddleClas/deploy/configs/inference_rec.yaml new file mode 100644 index 0000000..e183ef0 --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_rec.yaml @@ -0,0 +1,28 @@ +Global: + infer_imgs: "./images/wangzai.jpg" + rec_inference_model_dir: "./models/product_ResNet50_vd_aliproduct_v1.0_infer" + batch_size: 1 + use_gpu: False + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +RecPreProcess: + transform_ops: + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null \ No newline at end of file diff --git a/src/PaddleClas/deploy/configs/inference_vehicle.yaml b/src/PaddleClas/deploy/configs/inference_vehicle.yaml new file mode 100644 index 0000000..d99f42a --- /dev/null +++ b/src/PaddleClas/deploy/configs/inference_vehicle.yaml @@ -0,0 +1,63 @@ +Global: + infer_imgs: "./recognition_demo_data_v1.1/test_vehicle/" + det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/" + rec_inference_model_dir: "./models/vehicle_cls_ResNet50_CompCars_v1.0_infer/" + rec_nms_thresold: 0.05 + + batch_size: 1 + image_shape: [3, 640, 640] + threshold: 0.2 + max_det_results: 5 + labe_list: + - foreground + + use_gpu: True + enable_mkldnn: True + cpu_num_threads: 10 + enable_benchmark: True + use_fp16: False + ir_optim: True + use_tensorrt: False + gpu_mem: 8000 + enable_profile: False + +DetPreProcess: + transform_ops: + - DetResize: + interp: 2 + keep_ratio: false + target_size: [640, 640] + - DetNormalizeImage: + is_scale: true + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + - DetPermute: {} + +DetPostProcess: {} + +RecPreProcess: + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +RecPostProcess: null + +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + index_dir: "./recognition_demo_data_v1.1/gallery_vehicle/index/" + image_root: "./recognition_demo_data_v1.1/gallery_vehicle/" + data_file: "./recognition_demo_data_v1.1/gallery_vehicle/data_file.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 + batch_size: 32 + return_k: 5 + score_thres: 0.5 \ No newline at end of file diff --git a/src/PaddleClas/deploy/cpp/CMakeLists.txt b/src/PaddleClas/deploy/cpp/CMakeLists.txt new file mode 100644 index 0000000..74c1c72 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/CMakeLists.txt @@ -0,0 +1,225 @@ +project(clas_system CXX C) +cmake_minimum_required(VERSION 3.14) + +option(WITH_MKL "Compile demo with MKL/OpenBlas support, default use MKL." ON) +option(WITH_GPU "Compile demo with GPU/CPU, default use CPU." OFF) +option(WITH_STATIC_LIB "Compile demo with static/shared library, default use static." ON) +option(WITH_TENSORRT "Compile demo with TensorRT." OFF) + +SET(PADDLE_LIB "" CACHE PATH "Location of libraries") +SET(OPENCV_DIR "" CACHE PATH "Location of libraries") +SET(CUDA_LIB "" CACHE PATH "Location of libraries") +SET(CUDNN_LIB "" CACHE PATH "Location of libraries") +SET(TENSORRT_DIR "" CACHE PATH "Compile demo with TensorRT") + +set(DEMO_NAME "clas_system") + +include(external-cmake/yaml-cpp.cmake) +include_directories("${CMAKE_SOURCE_DIR}/") +include_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/src/ext-yaml-cpp/include") +link_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/lib") + +macro(safe_set_static_flag) + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) +endmacro() + +if (WITH_MKL) + ADD_DEFINITIONS(-DUSE_MKL) +endif() + +if(NOT DEFINED PADDLE_LIB) + message(FATAL_ERROR "please set PADDLE_LIB with -DPADDLE_LIB=/path/paddle/lib") +endif() + +if(NOT DEFINED OPENCV_DIR) + message(FATAL_ERROR "please set OPENCV_DIR with -DOPENCV_DIR=/path/opencv") +endif() + + +if (WIN32) + include_directories("${PADDLE_LIB}/paddle/fluid/inference") + include_directories("${PADDLE_LIB}/paddle/include") + link_directories("${PADDLE_LIB}/paddle/fluid/inference") + find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH) + +else () + find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH) + include_directories("${PADDLE_LIB}/paddle/include") + link_directories("${PADDLE_LIB}/paddle/lib") +endif () +include_directories(${OpenCV_INCLUDE_DIRS}) + +if (WIN32) + add_definitions("/DGOOGLE_GLOG_DLL_DECL=") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /bigobj /MTd") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /bigobj /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj /MTd") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj /MT") + if (WITH_STATIC_LIB) + safe_set_static_flag() + add_definitions(-DSTATIC_LIB) + endif() +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -std=c++11") + set(CMAKE_STATIC_LIBRARY_PREFIX "") +endif() +message("flags" ${CMAKE_CXX_FLAGS}) + + +if (WITH_GPU) + if (NOT DEFINED CUDA_LIB OR ${CUDA_LIB} STREQUAL "") + message(FATAL_ERROR "please set CUDA_LIB with -DCUDA_LIB=/path/cuda-8.0/lib64") + endif() + if (NOT WIN32) + if (NOT DEFINED CUDNN_LIB) + message(FATAL_ERROR "please set CUDNN_LIB with -DCUDNN_LIB=/path/cudnn_v7.4/cuda/lib64") + endif() + endif(NOT WIN32) +endif() + +include_directories("${PADDLE_LIB}/third_party/install/protobuf/include") +include_directories("${PADDLE_LIB}/third_party/install/glog/include") +include_directories("${PADDLE_LIB}/third_party/install/gflags/include") +include_directories("${PADDLE_LIB}/third_party/install/xxhash/include") +include_directories("${PADDLE_LIB}/third_party/install/zlib/include") +include_directories("${PADDLE_LIB}/third_party/boost") +include_directories("${PADDLE_LIB}/third_party/eigen3") + +include_directories("${CMAKE_SOURCE_DIR}/") + +if (NOT WIN32) + if (WITH_TENSORRT AND WITH_GPU) + include_directories("${TENSORRT_DIR}/include") + link_directories("${TENSORRT_DIR}/lib") + endif() +endif(NOT WIN32) + +link_directories("${PADDLE_LIB}/third_party/install/zlib/lib") + +link_directories("${PADDLE_LIB}/third_party/install/protobuf/lib") +link_directories("${PADDLE_LIB}/third_party/install/glog/lib") +link_directories("${PADDLE_LIB}/third_party/install/gflags/lib") +link_directories("${PADDLE_LIB}/third_party/install/xxhash/lib") +link_directories("${PADDLE_LIB}/paddle/lib") + + +if(WITH_MKL) + include_directories("${PADDLE_LIB}/third_party/install/mklml/include") + if (WIN32) + set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.lib + ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.lib) + else () + set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} + ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX}) + execute_process(COMMAND cp -r ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} /usr/lib) + endif () + set(MKLDNN_PATH "${PADDLE_LIB}/third_party/install/mkldnn") + if(EXISTS ${MKLDNN_PATH}) + include_directories("${MKLDNN_PATH}/include") + if (WIN32) + set(MKLDNN_LIB ${MKLDNN_PATH}/lib/mkldnn.lib) + else () + set(MKLDNN_LIB ${MKLDNN_PATH}/lib/libmkldnn.so.0) + endif () + endif() +else() + if (WIN32) + set(MATH_LIB ${PADDLE_LIB}/third_party/install/openblas/lib/openblas${CMAKE_STATIC_LIBRARY_SUFFIX}) + else () + set(MATH_LIB ${PADDLE_LIB}/third_party/install/openblas/lib/libopenblas${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif () +endif() + +# Note: libpaddle_inference_api.so/a must put before libpaddle_fluid.so/a +if(WITH_STATIC_LIB) + if(WIN32) + set(DEPS + ${PADDLE_LIB}/paddle/lib/paddle_inference${CMAKE_STATIC_LIBRARY_SUFFIX}) + else() + set(DEPS + ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() +else() + if(WIN32) + set(DEPS + ${PADDLE_LIB}/paddle/lib/paddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX}) + else() + set(DEPS + ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() +endif(WITH_STATIC_LIB) + +if (NOT WIN32) + set(DEPS ${DEPS} + ${MATH_LIB} ${MKLDNN_LIB} + glog gflags protobuf z xxhash yaml-cpp + ) + if(EXISTS "${PADDLE_LIB}/third_party/install/snappystream/lib") + set(DEPS ${DEPS} snappystream) + endif() + if (EXISTS "${PADDLE_LIB}/third_party/install/snappy/lib") + set(DEPS ${DEPS} snappy) + endif() +else() + set(DEPS ${DEPS} + ${MATH_LIB} ${MKLDNN_LIB} + glog gflags_static libprotobuf xxhash libyaml-cppmt) + set(DEPS ${DEPS} libcmt shlwapi) + if (EXISTS "${PADDLE_LIB}/third_party/install/snappy/lib") + set(DEPS ${DEPS} snappy) + endif() + if(EXISTS "${PADDLE_LIB}/third_party/install/snappystream/lib") + set(DEPS ${DEPS} snappystream) + endif() +endif(NOT WIN32) + + +if(WITH_GPU) + if(NOT WIN32) + if (WITH_TENSORRT) + set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer_plugin${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + set(DEPS ${DEPS} ${CUDA_LIB}/libcudart${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(DEPS ${DEPS} ${CUDNN_LIB}/libcudnn${CMAKE_SHARED_LIBRARY_SUFFIX}) + else() + set(DEPS ${DEPS} ${CUDA_LIB}/cudart${CMAKE_STATIC_LIBRARY_SUFFIX} ) + set(DEPS ${DEPS} ${CUDA_LIB}/cublas${CMAKE_STATIC_LIBRARY_SUFFIX} ) + set(DEPS ${DEPS} ${CUDNN_LIB}/cudnn${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() +endif() + + +if (NOT WIN32) + set(EXTERNAL_LIB "-ldl -lrt -lgomp -lz -lm -lpthread") + set(DEPS ${DEPS} ${EXTERNAL_LIB}) +endif() + +set(DEPS ${DEPS} ${OpenCV_LIBS}) + +include(FetchContent) +include(external-cmake/auto-log.cmake) +include_directories(${FETCHCONTENT_BASE_DIR}/extern_autolog-src) + +AUX_SOURCE_DIRECTORY(./src SRCS) +add_executable(${DEMO_NAME} ${SRCS}) +ADD_DEPENDENCIES(${DEMO_NAME} ext-yaml-cpp) + +target_link_libraries(${DEMO_NAME} ${DEPS}) + +if (WIN32 AND WITH_MKL) + add_custom_command(TARGET ${DEMO_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.dll ./mklml.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.dll ./libiomp5md.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mkldnn/lib/mkldnn.dll ./mkldnn.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.dll ./release/mklml.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.dll ./release/libiomp5md.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mkldnn/lib/mkldnn.dll ./release/mkldnn.dll + ) +endif() diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/ILSVRC2012_val_00000666.JPEG b/src/PaddleClas/deploy/cpp/docs/imgs/ILSVRC2012_val_00000666.JPEG new file mode 100644 index 0000000..ebb5625 Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/ILSVRC2012_val_00000666.JPEG differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/cpp_infer_result.png b/src/PaddleClas/deploy/cpp/docs/imgs/cpp_infer_result.png new file mode 100644 index 0000000..6a1adfe Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/cpp_infer_result.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step1.png b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step1.png new file mode 100644 index 0000000..58fdf2f Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step1.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step2.png b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step2.png new file mode 100644 index 0000000..f1b5fd0 Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step2.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step3.png b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step3.png new file mode 100644 index 0000000..cb1b2ae Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step3.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step4.png b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step4.png new file mode 100644 index 0000000..5fc0408 Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step4.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step5.png b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step5.png new file mode 100644 index 0000000..fbb2e4c Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step5.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step6.png b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step6.png new file mode 100644 index 0000000..86a8039 Binary files /dev/null and b/src/PaddleClas/deploy/cpp/docs/imgs/vs2019_step6.png differ diff --git a/src/PaddleClas/deploy/cpp/docs/windows_vs2019_build.md b/src/PaddleClas/deploy/cpp/docs/windows_vs2019_build.md new file mode 100644 index 0000000..6e2b370 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/docs/windows_vs2019_build.md @@ -0,0 +1,119 @@ +# Visual Studio 2019 Community CMake 编译指南 + +PaddleClas在Windows 平台下基于`Visual Studio 2019 Community` 进行了测试。微软从`Visual Studio 2017`开始即支持直接管理`CMake`跨平台编译项目,但是直到`2019`才提供了稳定和完全的支持,所以如果你想使用CMake管理项目编译构建,我们推荐使用`Visual Studio 2019`。如果您希望通过生成`sln解决方案`的方式进行编译,可以参考该文档:[https://zhuanlan.zhihu.com/p/145446681](https://zhuanlan.zhihu.com/p/145446681)。 + + +## 前置条件 +* Visual Studio 2019 +* CUDA 9.0 / CUDA 10.0,cudnn 7.6+ (仅在使用GPU版本的预测库时需要) +* CMake 3.0+ + +请确保系统已经正确安装并配置好上述基本软件,其中: + * 在安装`Visual Studio 2019`时,`工作负载`需要勾选`使用C++的桌面开发`; + * CUDA需要正确安装并设置系统环境变量; + * CMake需要正确安装并将路径添加到系统环境变量中。 + +以下测试基于`Visual Studio 2019 Community`版本。 + +**下面所有示例以工作目录为 `D:\projects`演示**。 + +### Step1: 下载PaddlePaddle C++ 预测库 paddle_inference_install_dir + +PaddlePaddle C++ 预测库针对不同的`CPU`和`CUDA`版本提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/windows_cpp_inference.html)。 + +解压后`D:\projects\paddle_inference_install_dir`目录包含内容为: + +``` +paddle_inference_install_dir +├── paddle # paddle核心库和头文件 +| +├── third_party # 第三方依赖库和头文件 +| +└── version.txt # 版本和编译信息 +``` + +然后需要将`Paddle预测库`的路径`D:\projects\paddle_inference_install_dir\paddle\lib`添加到系统环境变量`Path`中。 + +### Step2: 安装配置OpenCV + +1. 在OpenCV官网下载适用于Windows平台的3.4.6版本, [下载地址](https://sourceforge.net/projects/opencvlibrary/files/3.4.6/opencv-3.4.6-vc14_vc15.exe/download) +2. 运行下载的可执行文件,将OpenCV解压至指定目录,如`D:\projects\opencv` +3. 配置环境变量,如下流程所示 + - 此电脑(我的电脑)-> 属性 -> 高级系统设置 -> 环境变量 + - 在系统变量中找到Path(如没有,自行创建),并双击编辑 + - 新建,将OpenCV路径填入并保存,如 `D:\projects\opencv\build\x64\vc14\bin` + +### Step3: 使用Visual Studio 2019直接编译CMake + +1. 打开Visual Studio 2019 Community,点击 `继续但无需代码` + +![step2](./imgs/vs2019_step1.png) + +2. 点击: `文件`->`打开`->`CMake` + +![step2.1](./imgs/vs2019_step2.png) + +选择项目代码所在路径,并打开`CMakeList.txt`: + +![step2.2](./imgs/vs2019_step3.png) + +3. 点击:`项目`->`cpp_inference_demo的CMake设置` + +![step3](./imgs/vs2019_step4.png) + +4. 请设置以下参数的值 + + +| 名称 | 值 | 保存到 JSON | +| ----------------------------- | ------------------ | ----------- | +| CMAKE_BACKWARDS_COMPATIBILITY | 3.17 | [√] | +| CMAKE_BUILD_TYPE | RelWithDebInfo | [√] | +| CUDA_LIB | CUDA的库路径 | [√] | +| CUDNN_LIB | CUDNN的库路径 | [√] | +| OpenCV_DIR | OpenCV的安装路径 | [√] | +| PADDLE_LIB | Paddle预测库的路径 | [√] | +| WITH_GPU | [√] | [√] | +| WITH_MKL | [√] | [√] | +| WITH_STATIC_LIB | [√] | [√] | + +**注意**: + +1. `CMAKE_BACKWARDS_COMPATIBILITY` 的值请根据自己 `cmake` 版本设置,`cmake` 版本可以通过命令:`cmake --version` 查询; +2. `CUDA_LIB` 、 `CUDNN_LIB` 的值仅需在使用**GPU版本**预测库时指定,其中CUDA库版本尽量对齐,**使用9.0、10.0版本,不使用9.2、10.1等版本CUDA库**; +3. 在设置 `CUDA_LIB`、`CUDNN_LIB`、`OPENCV_DIR`、`PADDLE_LIB` 时,点击 `浏览`,分别设置相应的路径; + * `CUDA_LIB`和`CUDNN_LIB`:该路径取决于CUDA与CUDNN的安装位置。 + * `OpenCV_DIR`:该路径下需要有`.cmake`文件,一般为`opencv/build/`; + * `PADDLE_LIB`:该路径下需要有`CMakeCache.txt`文件,一般为`paddle_inference_install_dir/`。 +4. 在使用 `CPU` 版预测库时,请不要勾选 `WITH_GPU` - `保存到 JSON`。 + +![step4](./imgs/vs2019_step5.png) + +**设置完成后**, 点击上图中 `保存并生成CMake缓存以加载变量` 。 + +5. 点击`生成`->`全部生成` + +![step6](./imgs/vs2019_step6.png) + + +### Step4: 预测及可视化 + +在完成上述操作后,`Visual Studio 2019` 编译产出的可执行文件 `clas_system.exe` 在 `out\build\x64-Release`目录下,打开`cmd`,并切换到该目录: + +``` +cd D:\projects\PaddleClas\deploy\cpp_infer\out\build\x64-Release +``` +可执行文件`clas_system.exe`即为编译产出的的预测程序,其使用方法如下: + +```shell +.\clas_system.exe D:\projects\PaddleClas\deploy\cpp_infer\tools\config.txt .\docs\ILSVRC2012_val_00008306.JPEG +``` + +上述命令中,第一个参数(`D:\projects\PaddleClas\deploy\cpp_infer\tools\config.txt`)为配置文件路径,第二个参数(`.\docs\ILSVRC2012_val_00008306.JPEG`)为需要预测的图片路径。 + +注意,需要在配置文件中正确设置预测参数,包括所用模型文件的路径(`cls_model_path`和`cls_params_path`)。 + + +### 注意 +* 在Windows下的终端中执行文件exe时,可能会发生乱码的现象,此时需要在终端中输入`CHCP 65001`,将终端的编码方式由GBK编码(默认)改为UTF-8编码,更加具体的解释可以参考这篇博客:[https://blog.csdn.net/qq_35038153/article/details/78430359](https://blog.csdn.net/qq_35038153/article/details/78430359)。 +* 如果需要使用CPU预测,PaddlePaddle在Windows上仅支持avx的CPU预测,目前不支持noavx的CPU预测。 +* 在使用生成的`clas_system.exe`进行预测时,如提示`由于找不到paddle_fluid.dll,无法继续执行代码。重新安装程序可能会解决此问题`,请检查是否将Paddle预测库路径添加到系统环境变量,详见[Step1: 下载PaddlePaddle C++ 预测库 paddle_inference_install_dir](#step1-下载paddlepaddle-c-预测库-paddle_inference_install_dir) diff --git a/src/PaddleClas/deploy/cpp/external-cmake/auto-log.cmake b/src/PaddleClas/deploy/cpp/external-cmake/auto-log.cmake new file mode 100644 index 0000000..9be9c2f --- /dev/null +++ b/src/PaddleClas/deploy/cpp/external-cmake/auto-log.cmake @@ -0,0 +1,12 @@ +find_package(Git REQUIRED) +include(FetchContent) + +set(FETCHCONTENT_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party") + +FetchContent_Declare( + extern_Autolog + PREFIX autolog + GIT_REPOSITORY https://github.com/LDOUBLEV/AutoLog.git + GIT_TAG main +) +FetchContent_MakeAvailable(extern_Autolog) diff --git a/src/PaddleClas/deploy/cpp/external-cmake/yaml-cpp.cmake b/src/PaddleClas/deploy/cpp/external-cmake/yaml-cpp.cmake new file mode 100644 index 0000000..7bc7f34 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/external-cmake/yaml-cpp.cmake @@ -0,0 +1,30 @@ + +find_package(Git REQUIRED) + +include(ExternalProject) + +message("${CMAKE_BUILD_TYPE}") + +ExternalProject_Add( + ext-yaml-cpp + URL https://bj.bcebos.com/paddlex/deploy/deps/yaml-cpp.zip + URL_MD5 9542d6de397d1fbd649ed468cb5850e6 + CMAKE_ARGS + -DYAML_CPP_BUILD_TESTS=OFF + -DYAML_CPP_BUILD_TOOLS=OFF + -DYAML_CPP_INSTALL=OFF + -DYAML_CPP_BUILD_CONTRIB=OFF + -DMSVC_SHARED_RT=OFF + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} + -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/ext/yaml-cpp/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/ext/yaml-cpp/lib + PREFIX "${CMAKE_BINARY_DIR}/ext/yaml-cpp" + # Disable install step + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_BUILD 1 +) diff --git a/src/PaddleClas/deploy/cpp/include/cls.h b/src/PaddleClas/deploy/cpp/include/cls.h new file mode 100644 index 0000000..8456d10 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/include/cls.h @@ -0,0 +1,90 @@ +// 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. + +#pragma once + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include "paddle_inference_api.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "include/cls_config.h" +#include + +using namespace paddle_infer; + +namespace PaddleClas { + + class Classifier { + public: + explicit Classifier(const ClsConfig &config) { + this->use_gpu_ = config.use_gpu; + this->gpu_id_ = config.gpu_id; + this->gpu_mem_ = config.gpu_mem; + this->cpu_math_library_num_threads_ = config.cpu_threads; + this->use_fp16_ = config.use_fp16; + this->use_mkldnn_ = config.use_mkldnn; + this->use_tensorrt_ = config.use_tensorrt; + this->mean_ = config.mean; + this->std_ = config.std; + this->resize_short_size_ = config.resize_short_size; + this->scale_ = config.scale; + this->crop_size_ = config.crop_size; + this->ir_optim_ = config.ir_optim; + LoadModel(config.cls_model_path, config.cls_params_path); + } + + // Load Paddle inference model + void LoadModel(const std::string &model_path, const std::string ¶ms_path); + + // Run predictor + void Run(cv::Mat &img, std::vector &out_data, std::vector &idx, + std::vector ×); + + private: + std::shared_ptr predictor_; + + bool use_gpu_ = false; + int gpu_id_ = 0; + int gpu_mem_ = 4000; + int cpu_math_library_num_threads_ = 4; + bool use_mkldnn_ = false; + bool use_tensorrt_ = false; + bool use_fp16_ = false; + bool ir_optim_ = true; + + std::vector mean_ = {0.485f, 0.456f, 0.406f}; + std::vector std_ = {0.229f, 0.224f, 0.225f}; + float scale_ = 0.00392157; + + int resize_short_size_ = 256; + int crop_size_ = 224; + + // pre-process + ResizeImg resize_op_; + Normalize normalize_op_; + Permute permute_op_; + CenterCropImg crop_op_; + }; + +} // namespace PaddleClas diff --git a/src/PaddleClas/deploy/cpp/include/cls_config.h b/src/PaddleClas/deploy/cpp/include/cls_config.h new file mode 100644 index 0000000..225e728 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/include/cls_config.h @@ -0,0 +1,133 @@ +// Copyright (c) 2021 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. + +#pragma once + +#ifdef WIN32 +#define OS_PATH_SEP "\\" +#else +#define OS_PATH_SEP "/" +#endif + +#include "include/utility.h" +#include "yaml-cpp/yaml.h" +#include +#include +#include +#include +#include +#include + +namespace PaddleClas { + + class ClsConfig { + public: + explicit ClsConfig(const std::string &path) { + ReadYamlConfig(path); + this->infer_imgs = + this->config_file["Global"]["infer_imgs"].as(); + this->batch_size = this->config_file["Global"]["batch_size"].as(); + this->use_gpu = this->config_file["Global"]["use_gpu"].as(); + if (this->config_file["Global"]["gpu_id"].IsDefined()) + this->gpu_id = this->config_file["Global"]["gpu_id"].as(); + else + this->gpu_id = 0; + this->gpu_mem = this->config_file["Global"]["gpu_mem"].as(); + this->cpu_threads = + this->config_file["Global"]["cpu_num_threads"].as(); + this->use_mkldnn = this->config_file["Global"]["enable_mkldnn"].as(); + this->use_tensorrt = this->config_file["Global"]["use_tensorrt"].as(); + this->use_fp16 = this->config_file["Global"]["use_fp16"].as(); + this->enable_benchmark = + this->config_file["Global"]["enable_benchmark"].as(); + this->ir_optim = this->config_file["Global"]["ir_optim"].as(); + this->enable_profile = + this->config_file["Global"]["enable_profile"].as(); + this->cls_model_path = + this->config_file["Global"]["inference_model_dir"].as() + + OS_PATH_SEP + "inference.pdmodel"; + this->cls_params_path = + this->config_file["Global"]["inference_model_dir"].as() + + OS_PATH_SEP + "inference.pdiparams"; + this->resize_short_size = + this->config_file["PreProcess"]["transform_ops"][0]["ResizeImage"] + ["resize_short"] + .as(); + this->crop_size = + this->config_file["PreProcess"]["transform_ops"][1]["CropImage"]["size"] + .as(); + this->scale = this->config_file["PreProcess"]["transform_ops"][2] + ["NormalizeImage"]["scale"] + .as(); + this->mean = this->config_file["PreProcess"]["transform_ops"][2] + ["NormalizeImage"]["mean"] + .as < std::vector < float >> (); + this->std = this->config_file["PreProcess"]["transform_ops"][2] + ["NormalizeImage"]["std"] + .as < std::vector < float >> (); + if (this->config_file["Global"]["benchmark"].IsDefined()) + this->benchmark = this->config_file["Global"]["benchmark"].as(); + else + this->benchmark = false; + + if (this->config_file["PostProcess"]["Topk"]["topk"].IsDefined()) + this->topk = this->config_file["PostProcess"]["Topk"]["topk"].as(); + if (this->config_file["PostProcess"]["Topk"]["class_id_map_file"] + .IsDefined()) + this->class_id_map_path = + this->config_file["PostProcess"]["Topk"]["class_id_map_file"] + .as(); + if (this->config_file["PostProcess"]["SavePreLabel"]["save_dir"] + .IsDefined()) + this->label_save_dir = + this->config_file["PostProcess"]["SavePreLabel"]["save_dir"] + .as(); + ReadLabelMap(); + } + + YAML::Node config_file; + bool use_gpu = false; + int gpu_id = 0; + int gpu_mem = 4000; + int cpu_threads = 1; + bool use_mkldnn = false; + bool use_tensorrt = false; + bool use_fp16 = false; + bool benchmark = false; + int batch_size = 1; + bool enable_benchmark = false; + bool ir_optim = true; + bool enable_profile = false; + + std::string cls_model_path; + std::string cls_params_path; + std::string infer_imgs; + + int resize_short_size = 256; + int crop_size = 224; + float scale = 0.00392157; + std::vector mean = {0.485, 0.456, 0.406}; + std::vector std = {0.229, 0.224, 0.225}; + int topk = 5; + std::string class_id_map_path; + std::map id_map; + std::string label_save_dir; + + void PrintConfigInfo(); + + void ReadLabelMap(); + + void ReadYamlConfig(const std::string &path); + }; +} // namespace PaddleClas diff --git a/src/PaddleClas/deploy/cpp/include/preprocess_op.h b/src/PaddleClas/deploy/cpp/include/preprocess_op.h new file mode 100644 index 0000000..48c04e4 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/include/preprocess_op.h @@ -0,0 +1,56 @@ +// 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. + +#pragma once + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; + +namespace PaddleClas { + + class Normalize { + public: + virtual void Run(cv::Mat *im, const std::vector &mean, + const std::vector &std, float &scale); + }; + +// RGB -> CHW + class Permute { + public: + virtual void Run(const cv::Mat *im, float *data); + }; + + class CenterCropImg { + public: + virtual void Run(cv::Mat &im, const int crop_size = 224); + }; + + class ResizeImg { + public: + virtual void Run(const cv::Mat &img, cv::Mat &resize_img, int max_size_len); + }; + +} // namespace PaddleClas diff --git a/src/PaddleClas/deploy/cpp/include/utility.h b/src/PaddleClas/deploy/cpp/include/utility.h new file mode 100644 index 0000000..73b594e --- /dev/null +++ b/src/PaddleClas/deploy/cpp/include/utility.h @@ -0,0 +1,46 @@ +// 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. + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" + +namespace PaddleClas { + + class Utility { + public: + static std::vector ReadDict(const std::string &path); + + // template + // inline static size_t argmax(ForwardIterator first, ForwardIterator last) + // { + // return std::distance(first, std::max_element(first, last)); + // } + }; + +} // namespace PaddleClas \ No newline at end of file diff --git a/src/PaddleClas/deploy/cpp/readme.md b/src/PaddleClas/deploy/cpp/readme.md new file mode 100644 index 0000000..ec40f23 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/readme.md @@ -0,0 +1,229 @@ +# 服务器端C++预测 + +本教程将介绍在服务器端部署PaddleClas模型的详细步骤。 + + +## 1. 准备环境 + +### 运行准备 +- Linux环境,推荐使用docker。 +- Windows环境,目前支持基于`Visual Studio 2019 Community`进行编译;此外,如果您希望通过生成`sln解决方案`的方式进行编译,可以参考该文档:[https://zhuanlan.zhihu.com/p/145446681](https://zhuanlan.zhihu.com/p/145446681) + +* 该文档主要介绍基于Linux环境下的PaddleClas C++预测流程,如果需要在Windows环境下使用预测库进行C++预测,具体编译方法请参考[Windows下编译教程](./docs/windows_vs2019_build.md)。 + +### 1.1 编译opencv库 + +* 首先需要从opencv官网上下载在Linux环境下源码编译的包,以3.4.7版本为例,下载及解压缩命令如下: + +``` +wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz +tar -xvf 3.4.7.tar.gz +``` + +最终可以在当前目录下看到`opencv-3.4.7/`的文件夹。 + +* 编译opencv,首先设置opencv源码路径(`root_path`)以及安装路径(`install_path`),`root_path`为下载的opencv源码路径,`install_path`为opencv的安装路径。在本例中,源码路径即为当前目录下的`opencv-3.4.7/`。 + +```shell +cd ./opencv-3.4.7 +export root_path=$PWD +export install_path=${root_path}/opencv3 +``` + +* 然后在opencv源码路径下,按照下面的方式进行编译。 + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + +make -j +make install +``` + +* `make install`完成之后,会在该文件夹下生成opencv头文件和库文件,用于后面的PaddleClas代码编译。 + +以opencv3.4.7版本为例,最终在安装路径下的文件结构如下所示。**注意**:不同的opencv版本,下述的文件结构可能不同。 + +``` +opencv3/ +|-- bin +|-- include +|-- lib64 +|-- share +``` + +### 1.2 下载或者编译Paddle预测库 + +* 有2种方式获取Paddle预测库,下面进行详细介绍。 + +#### 1.2.1 预测库源码编译 +* 如果希望获取最新预测库特性,可以从Paddle github上克隆最新代码,源码编译预测库。 +* 可以参考[Paddle预测库官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16)的说明,从github上获取Paddle代码,然后进行编译,生成最新的预测库。使用git获取代码方法如下。 + +```shell +git clone https://github.com/PaddlePaddle/Paddle.git +``` + +* 进入Paddle目录后,使用如下方法编译。 + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DWITH_CONTRIB=OFF \ + -DWITH_MKL=ON \ + -DWITH_MKLDNN=ON \ + -DWITH_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_INFERENCE_API_TEST=OFF \ + -DON_INFER=ON \ + -DWITH_PYTHON=ON +make -j +make inference_lib_dist +``` + +更多编译参数选项可以参考Paddle C++预测库官网:[https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16)。 + + +* 编译完成之后,可以在`build/paddle_inference_install_dir/`文件下看到生成了以下文件及文件夹。 + +``` +build/paddle_inference_install_dir/ +|-- CMakeCache.txt +|-- paddle +|-- third_party +|-- version.txt +``` + +其中`paddle`就是之后进行C++预测时所需的Paddle库,`version.txt`中包含当前预测库的版本信息。 + +#### 1.2.2 直接下载安装 + +* [Paddle预测库官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id1)上提供了不同cuda版本的Linux预测库,可以在官网查看并选择合适的预测库版本,注意必须选择`develop`版本。 + + 以`2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2`的`develop`版本为例,使用下述命令下载并解压: + + +```shell +wget https://paddle-inference-lib.bj.bcebos.com/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddle_inference.tgz +tar -xvf paddle_inference.tgz +``` + + +最终会在当前的文件夹中生成`paddle_inference/`的子文件夹。 + + +## 2 开始运行 + +### 2.1 将模型导出为inference model + +* 可以参考[模型导出](../../tools/export_model.py),导出`inference model`,用于模型预测。得到预测模型后,假设模型文件放在`inference`目录下,则目录结构如下。 + +``` +inference/ +|--inference.pdmodel +|--inference.pdiparams +``` +**注意**:上述文件中,`inference.pdmodel`文件存储了模型结构信息,`inference.pdiparams`文件存储了模型参数信息。模型目录可以随意设置,但是模型名字不能修改。 + +### 2.2 编译PaddleClas C++预测demo + +* 编译命令如下,其中Paddle C++预测库、opencv等其他依赖库的地址需要换成自己机器上的实际地址。 + + +```shell +sh tools/build.sh +``` + +具体地,`tools/build.sh`中内容如下。 + +```shell +OPENCV_DIR=your_opencv_dir +LIB_DIR=your_paddle_inference_dir +CUDA_LIB_DIR=your_cuda_lib_dir +CUDNN_LIB_DIR=your_cudnn_lib_dir +TENSORRT_DIR=your_tensorrt_lib_dir + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DDEMO_NAME=clas_system \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DTENSORRT_DIR=${TENSORRT_DIR} \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + +make -j +cd .. +``` + +上述命令中, + +* `OPENCV_DIR`为opencv编译安装的地址(本例中为`opencv-3.4.7/opencv3`文件夹的路径); + +* `LIB_DIR`为下载的Paddle预测库(`paddle_inference`文件夹),或编译生成的Paddle预测库(`build/paddle_inference_install_dir`文件夹)的路径; + +* `CUDA_LIB_DIR`为cuda库文件地址,在docker中为`/usr/local/cuda/lib64`; + +* `CUDNN_LIB_DIR`为cudnn库文件地址,在docker中为`/usr/lib/x86_64-linux-gnu/`。 + +* `TENSORRT_DIR`是tensorrt库文件地址,在dokcer中为`/usr/local/TensorRT6-cuda10.0-cudnn7/`,TensorRT需要结合GPU使用。 + +在执行上述命令,编译完成之后,会在当前路径下生成`build`文件夹,其中生成一个名为`clas_system`的可执行文件。 + + +### 2.3 运行demo +#### 2.3.1 设置配置文件 + +```shell +cp ../configs/inference_cls.yaml tools/ +``` + +根据[python预测推理](../../docs/zh_CN/inference_deployment/python_deploy.md)的`图像分类推理`部分修改好`tools`目录下`inference_cls.yaml`文件。`yaml`文件的参数说明详见[python预测推理](../../docs/zh_CN/inference_deployment/python_deploy.md)。 + +请根据实际存放文件,修改好`Global.infer_imgs`、`Global.inference_model_dir`、`PostProcess.Topk.topk`、`PostProcess.Topk.class_id_map_file`等参数。 + +#### 2.3.2 执行 + +```shell +./build/clas_system -c tools/inference_cls.yaml +# or +./build/clas_system -config tools/inference_cls.yaml +``` + +最终屏幕上会输出结果,如下图所示。 + +
+ +
+ + +其中`class id`表示置信度最高的类别对应的id,score表示图片属于该类别的概率。 diff --git a/src/PaddleClas/deploy/cpp/readme_en.md b/src/PaddleClas/deploy/cpp/readme_en.md new file mode 100644 index 0000000..fe5abe2 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/readme_en.md @@ -0,0 +1,240 @@ +# Server-side C++ inference + + +In this tutorial, we will introduce the detailed steps of deploying PaddleClas models on the server side. + + +## 1. Prepare the environment + +### Environment + +- Linux, docker is recommended. +- Windows, compilation based on `Visual Studio 2019 Community` is supported. In addition, you can refer to [How to use PaddleDetection to make a complete project](https://zhuanlan.zhihu.com/p/145446681) to compile by generating the `sln solution`. +- This document mainly introduces the compilation and inference of PaddleClas C++ in Linux environment. +- If you need to use the Inference Library in Windows environment, please refer to [The compilation tutorial in Windows](./docs/windows_vs2019_build.md) for detailed information. + + +### 1.1 Compile opencv + +* First of all, you need to download the source code compiled package in the Linux environment from the opencv official website. Taking opencv3.4.7 as an example, the download and uncompress command are as follows. + +``` +wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz +tar -xf 3.4.7.tar.gz +``` + +Finally, you can see the folder of `opencv-3.4.7/` in the current directory. + +* Compile opencv, the opencv source path (`root_path`) and installation path (`install_path`) should be set by yourself. Among them, `root_path` is the downloaded opencv source code path, and `install_path` is the installation path of opencv. In this case, the opencv source is `./opencv-3.4.7`. + +```shell +cd ./opencv-3.4.7 +export root_path=$PWD +export install_path=${root_path}/opencv3 +``` + +* After entering the opencv source code path, you can compile it in the following way. + + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + +make -j +make install +``` + +* After `make install` is completed, the opencv header file and library file will be generated in this folder for later PaddleClas source code compilation. + +Take opencv3.4.7 for example, the final file structure under the opencv installation path is as follows. **NOTICE**:The following file structure may be different for different Versions of Opencv. + +``` +opencv3/ +|-- bin +|-- include +|-- lib64 +|-- share +``` + +### 1.2 Compile or download the Paddle Inference Library + +* There are 2 ways to obtain the Paddle Inference Library, described in detail below. + + +#### 1.2.1 Compile from the source code +* If you want to get the latest Paddle Inference Library features, you can download the latest code from Paddle GitHub repository and compile the inference library from the source code. +* You can refer to [Paddle Inference Library](https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code) to get the Paddle source code from github, and then compile To generate the latest inference library. The method of using git to access the code is as follows. + + +```shell +git clone https://github.com/PaddlePaddle/Paddle.git +``` + +* After entering the Paddle directory, the compilation method is as follows. + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DWITH_CONTRIB=OFF \ + -DWITH_MKL=ON \ + -DWITH_MKLDNN=ON \ + -DWITH_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_INFERENCE_API_TEST=OFF \ + -DON_INFER=ON \ + -DWITH_PYTHON=ON +make -j +make inference_lib_dist +``` + +For more compilation parameter options, please refer to the official website of the Paddle C++ inference library:[https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code](https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code). + + +* After the compilation process, you can see the following files in the folder of `build/paddle_inference_install_dir/`. + +``` +build/paddle_inference_install_dir/ +|-- CMakeCache.txt +|-- paddle +|-- third_party +|-- version.txt +``` + +Among them, `paddle` is the Paddle library required for C++ prediction later, and `version.txt` contains the version information of the current inference library. + + + +#### 1.2.2 Direct download and installation + +* Different cuda versions of the Linux inference library (based on GCC 4.8.2) are provided on the +[Paddle Inference Library official website](https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html). You can view and select the appropriate version of the inference library on the official website. + +* Please select the `develop` version. + +* After downloading, use the following method to uncompress. + +``` +tar -xf paddle_inference.tgz +``` + +Finally you can see the following files in the folder of `paddle_inference/`. + + +## 2. Compile and run the demo + +### 2.1 Export the inference model + +* You can refer to [Model inference](../../tools/export_model.py),export the inference model. After the model is exported, assuming it is placed in the `inference` directory, the directory structure is as follows. + +``` +inference/ +|--cls_infer.pdmodel +|--cls_infer.pdiparams +``` + +**NOTICE**: Among them, `cls_infer.pdmodel` file stores the model structure information and the `cls_infer.pdiparams` file stores the model parameter information.The paths of the two files need to correspond to the parameters of `cls_model_path` and `cls_params_path` in the configuration file `tools/config.txt`. + +### 2.2 Compile PaddleClas C++ inference demo + + +* The compilation commands are as follows. The addresses of Paddle C++ inference library, opencv and other Dependencies need to be replaced with the actual addresses on your own machines. + +```shell +sh tools/build.sh +``` + +Specifically, the content in `tools/build.sh` is as follows. + +```shell +OPENCV_DIR=your_opencv_dir +LIB_DIR=your_paddle_inference_dir +CUDA_LIB_DIR=your_cuda_lib_dir +CUDNN_LIB_DIR=your_cudnn_lib_dir +TENSORRT_DIR=your_tensorrt_lib_dir + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DDEMO_NAME=clas_system \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DTENSORRT_DIR=${TENSORRT_DIR} \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + +make -j +``` + +In the above parameters of command: + +* `OPENCV_DIR` is the opencv installation path; + +* `LIB_DIR` is the download (`paddle_inference` folder) or the generated Paddle Inference Library path (`build/paddle_inference_install_dir` folder); + +* `CUDA_LIB_DIR` is the cuda library file path, in docker; it is `/usr/local/cuda/lib64`; + +* `CUDNN_LIB_DIR` is the cudnn library file path, in docker it is `/usr/lib/x86_64-linux-gnu/`. + +* `TENSORRT_DIR` is the tensorrt library file path,in dokcer it is `/usr/local/TensorRT6-cuda10.0-cudnn7/`,TensorRT is just enabled for GPU. + +After the compilation is completed, an executable file named `clas_system` will be generated in the `build` folder. + + +### Run the demo +* First, please modify the `tools/config.txt` and `tools/run.sh`. + +* Some key words in `tools/config.txt` is as follows. + * use_gpu: Whether to use GPU. + * gpu_id: GPU id. + * gpu_mem:GPU memory. + * cpu_math_library_num_threads:Number of thread for math library acceleration. + * use_mkldnn:Whether to use mkldnn. + * use_tensorrt: Whether to use tensorRT. + * use_fp16:Whether to use Float16 (half precision), it is just enabled when use_tensorrt is set as 1. + * cls_model_path: Model path of inference model. + * cls_params_path: Params path of inference model. + * resize_short_size:Short side length of the image after resize. + * crop_size:Image size after center crop. + + +* Then execute the following command to complete the classification of an image. + +```shell +sh tools/run.sh +``` + +* The detection results will be shown on the screen, which is as follows. + +
+ +
+ +* In the above results,`class id` represents the id corresponding to the category with the highest confidence, and `score` represents the probability that the image belongs to that category. diff --git a/src/PaddleClas/deploy/cpp/src/cls.cpp b/src/PaddleClas/deploy/cpp/src/cls.cpp new file mode 100644 index 0000000..63d8c5f --- /dev/null +++ b/src/PaddleClas/deploy/cpp/src/cls.cpp @@ -0,0 +1,116 @@ +// 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. + +#include +#include +#include + +namespace PaddleClas { + + void Classifier::LoadModel(const std::string &model_path, + const std::string ¶ms_path) { + paddle_infer::Config config; + config.SetModel(model_path, params_path); + + if (this->use_gpu_) { + config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); + if (this->use_tensorrt_) { + config.EnableTensorRtEngine( + 1 << 20, 1, 3, + this->use_fp16_ ? paddle_infer::Config::Precision::kHalf + : paddle_infer::Config::Precision::kFloat32, + false, false); + } + } else { + config.DisableGpu(); + if (this->use_mkldnn_) { + config.EnableMKLDNN(); + // cache 10 different shapes for mkldnn to avoid memory leak + config.SetMkldnnCacheCapacity(10); + } + config.SetCpuMathLibraryNumThreads(this->cpu_math_library_num_threads_); + } + + config.SwitchUseFeedFetchOps(false); + // true for multiple input + config.SwitchSpecifyInputNames(true); + + config.SwitchIrOptim(this->ir_optim_); + + config.EnableMemoryOptim(); + config.DisableGlogInfo(); + + this->predictor_ = CreatePredictor(config); + } + + void Classifier::Run(cv::Mat &img, std::vector &out_data, + std::vector &idx, std::vector ×) { + cv::Mat srcimg; + cv::Mat resize_img; + img.copyTo(srcimg); + + auto preprocess_start = std::chrono::system_clock::now(); + this->resize_op_.Run(img, resize_img, this->resize_short_size_); + + this->crop_op_.Run(resize_img, this->crop_size_); + + this->normalize_op_.Run(&resize_img, this->mean_, this->std_, this->scale_); + std::vector input(1 * 3 * resize_img.rows * resize_img.cols, 0.0f); + this->permute_op_.Run(&resize_img, input.data()); + + auto input_names = this->predictor_->GetInputNames(); + auto input_t = this->predictor_->GetInputHandle(input_names[0]); + input_t->Reshape({1, 3, resize_img.rows, resize_img.cols}); + auto preprocess_end = std::chrono::system_clock::now(); + + auto infer_start = std::chrono::system_clock::now(); + input_t->CopyFromCpu(input.data()); + this->predictor_->Run(); + + auto output_names = this->predictor_->GetOutputNames(); + auto output_t = this->predictor_->GetOutputHandle(output_names[0]); + std::vector output_shape = output_t->shape(); + int out_num = std::accumulate(output_shape.begin(), output_shape.end(), 1, + std::multiplies()); + + out_data.resize(out_num); + idx.resize(out_num); + output_t->CopyToCpu(out_data.data()); + auto infer_end = std::chrono::system_clock::now(); + + auto postprocess_start = std::chrono::system_clock::now(); + // int maxPosition = + // max_element(out_data.begin(), out_data.end()) - out_data.begin(); + iota(idx.begin(), idx.end(), 0); + stable_sort(idx.begin(), idx.end(), [&out_data](int i1, int i2) { + return out_data[i1] > out_data[i2]; + }); + auto postprocess_end = std::chrono::system_clock::now(); + + std::chrono::duration preprocess_diff = + preprocess_end - preprocess_start; + times[0] = double(preprocess_diff.count() * 1000); + std::chrono::duration inference_diff = infer_end - infer_start; + double inference_cost_time = double(inference_diff.count() * 1000); + times[1] = inference_cost_time; + std::chrono::duration postprocess_diff = + postprocess_end - postprocess_start; + times[2] = double(postprocess_diff.count() * 1000); + + /* std::cout << "result: " << std::endl; */ + /* std::cout << "\tclass id: " << maxPosition << std::endl; */ + /* std::cout << std::fixed << std::setprecision(10) */ + /* << "\tscore: " << double(out_data[maxPosition]) << std::endl; */ + } +} // namespace PaddleClas diff --git a/src/PaddleClas/deploy/cpp/src/cls_config.cpp b/src/PaddleClas/deploy/cpp/src/cls_config.cpp new file mode 100644 index 0000000..ec3a44f --- /dev/null +++ b/src/PaddleClas/deploy/cpp/src/cls_config.cpp @@ -0,0 +1,52 @@ +// 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. + +#include +#include + +namespace PaddleClas { + + void ClsConfig::PrintConfigInfo() { + std::cout << "=======Paddle Class inference config======" << std::endl; + std::cout << this->config_file << std::endl; + std::cout << "=======End of Paddle Class inference config======" << std::endl; + } + + void ClsConfig::ReadYamlConfig(const std::string &path) { + + try { + this->config_file = YAML::LoadFile(path); + } catch (YAML::BadFile &e) { + std::cout << "Something wrong in yaml file, please check yaml file" + << std::endl; + exit(1); + } + } + + void ClsConfig::ReadLabelMap() { + if (this->class_id_map_path.empty()) { + std::cout << "The Class Label file dose not input" << std::endl; + return; + } + std::ifstream in(this->class_id_map_path); + std::string line; + if (in) { + while (getline(in, line)) { + int split_flag = line.find_first_of(" "); + this->id_map[std::stoi(line.substr(0, split_flag))] = + line.substr(split_flag + 1, line.size()); + } + } + } +}; // namespace PaddleClas diff --git a/src/PaddleClas/deploy/cpp/src/main.cpp b/src/PaddleClas/deploy/cpp/src/main.cpp new file mode 100644 index 0000000..120c4a4 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/src/main.cpp @@ -0,0 +1,137 @@ +// Copyright (c) 2021 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. + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; +using namespace cv; +using namespace PaddleClas; + +DEFINE_string(config, +"", "Path of yaml file"); +DEFINE_string(c, +"", "Path of yaml file"); + +int main(int argc, char **argv) { + google::ParseCommandLineFlags(&argc, &argv, true); + std::string yaml_path = ""; + if (FLAGS_config == "" && FLAGS_c == "") { + std::cerr << "[ERROR] usage: " << std::endl + << argv[0] << " -c $yaml_path" << std::endl + << "or:" << std::endl + << argv[0] << " -config $yaml_path" << std::endl; + exit(1); + } else if (FLAGS_config != "") { + yaml_path = FLAGS_config; + } else { + yaml_path = FLAGS_c; + } + ClsConfig config(yaml_path); + config.PrintConfigInfo(); + + std::string path(config.infer_imgs); + + std::vector img_files_list; + if (cv::utils::fs::isDirectory(path)) { + std::vector filenames; + cv::glob(path, filenames); + for (auto f : filenames) { + img_files_list.push_back(f); + } + } else { + img_files_list.push_back(path); + } + + std::cout << "img_file_list length: " << img_files_list.size() << std::endl; + + Classifier classifier(config); + + std::vector cls_times = {0, 0, 0}; + std::vector cls_times_total = {0, 0, 0}; + double infer_time; + std::vector out_data; + std::vector result_index; + int warmup_iter = 5; + bool label_output_equal_flag = true; + for (int idx = 0; idx < img_files_list.size(); ++idx) { + std::string img_path = img_files_list[idx]; + cv::Mat srcimg = cv::imread(img_path, cv::IMREAD_COLOR); + if (!srcimg.data) { + std::cerr << "[ERROR] image read failed! image path: " << img_path + << "\n"; + exit(-1); + } + + cv::cvtColor(srcimg, srcimg, cv::COLOR_BGR2RGB); + classifier.Run(srcimg, out_data, result_index, cls_times); + if (label_output_equal_flag and out_data.size() != config.id_map.size()) { + std::cout << "Warning: the label size is not equal to output size!" + << std::endl; + label_output_equal_flag = false; + } + + int max_len = std::min(config.topk, int(out_data.size())); + std::cout << "Current image path: " << img_path << std::endl; + infer_time = cls_times[0] + cls_times[1] + cls_times[2]; + std::cout << "Current total inferen time cost: " << infer_time << " ms." + << std::endl; + for (int i = 0; i < max_len; ++i) { + printf("\tTop%d: class_id: %d, score: %.4f, ", i + 1, result_index[i], + out_data[result_index[i]]); + if (label_output_equal_flag) + printf("label: %s\n", config.id_map[result_index[i]].c_str()); + } + if (idx >= warmup_iter) { + for (int i = 0; i < cls_times.size(); ++i) + cls_times_total[i] += cls_times[i]; + } + } + if (img_files_list.size() > warmup_iter) { + + infer_time = cls_times_total[0] + cls_times_total[1] + cls_times_total[2]; + std::cout << "average time cost in all: " + << infer_time / (img_files_list.size() - warmup_iter) << " ms." + << std::endl; + } + + std::string presion = "fp32"; + if (config.use_fp16) + presion = "fp16"; + if (config.benchmark) { + AutoLogger autolog("Classification", config.use_gpu, config.use_tensorrt, + config.use_mkldnn, config.cpu_threads, 1, + "1, 3, 224, 224", presion, cls_times_total, + img_files_list.size()); + autolog.report(); + } + return 0; +} diff --git a/src/PaddleClas/deploy/cpp/src/preprocess_op.cpp b/src/PaddleClas/deploy/cpp/src/preprocess_op.cpp new file mode 100644 index 0000000..7e86308 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/src/preprocess_op.cpp @@ -0,0 +1,88 @@ +// 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. + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include "paddle_api.h" +#include "paddle_inference_api.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace PaddleClas { + + void Permute::Run(const cv::Mat *im, float *data) { + int rh = im->rows; + int rw = im->cols; + int rc = im->channels(); + for (int i = 0; i < rc; ++i) { + cv::extractChannel(*im, cv::Mat(rh, rw, CV_32FC1, data + i * rh * rw), i); + } + } + + void Normalize::Run(cv::Mat *im, const std::vector &mean, + const std::vector &std, float &scale) { + if (scale) { + (*im).convertTo(*im, CV_32FC3, scale); + } + for (int h = 0; h < im->rows; h++) { + for (int w = 0; w < im->cols; w++) { + im->at(h, w)[0] = + (im->at(h, w)[0] - mean[0]) / std[0]; + im->at(h, w)[1] = + (im->at(h, w)[1] - mean[1]) / std[1]; + im->at(h, w)[2] = + (im->at(h, w)[2] - mean[2]) / std[2]; + } + } + } + + void CenterCropImg::Run(cv::Mat &img, const int crop_size) { + int resize_w = img.cols; + int resize_h = img.rows; + int w_start = int((resize_w - crop_size) / 2); + int h_start = int((resize_h - crop_size) / 2); + cv::Rect rect(w_start, h_start, crop_size, crop_size); + img = img(rect); + } + + void ResizeImg::Run(const cv::Mat &img, cv::Mat &resize_img, + int resize_short_size) { + int w = img.cols; + int h = img.rows; + + float ratio = 1.f; + if (h < w) { + ratio = float(resize_short_size) / float(h); + } else { + ratio = float(resize_short_size) / float(w); + } + + int resize_h = round(float(h) * ratio); + int resize_w = round(float(w) * ratio); + + cv::resize(img, resize_img, cv::Size(resize_w, resize_h)); + } + +} // namespace PaddleClas diff --git a/src/PaddleClas/deploy/cpp/src/utility.cpp b/src/PaddleClas/deploy/cpp/src/utility.cpp new file mode 100644 index 0000000..dbb4549 --- /dev/null +++ b/src/PaddleClas/deploy/cpp/src/utility.cpp @@ -0,0 +1,39 @@ +// 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. + +#include +#include +#include + +#include + +namespace PaddleClas { + + std::vector Utility::ReadDict(const std::string &path) { + std::ifstream in(path); + std::string line; + std::vector m_vec; + if (in) { + while (getline(in, line)) { + m_vec.push_back(line); + } + } else { + std::cout << "no such label file: " << path << ", exit the program..." + << std::endl; + exit(1); + } + return m_vec; + } + +} // namespace PaddleClas \ No newline at end of file diff --git a/src/PaddleClas/deploy/cpp/tools/build.sh b/src/PaddleClas/deploy/cpp/tools/build.sh new file mode 100644 index 0000000..72447ec --- /dev/null +++ b/src/PaddleClas/deploy/cpp/tools/build.sh @@ -0,0 +1,21 @@ +OPENCV_DIR=/work/project/project/test/opencv-3.4.7/opencv3 +LIB_DIR=/work/project/project/test/paddle_inference/ +CUDA_LIB_DIR=/usr/local/cuda/lib64 +CUDNN_LIB_DIR=/usr/lib/x86_64-linux-gnu/ + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DUSE_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + +make -j +cd .. diff --git a/src/PaddleClas/deploy/cpp_shitu/CMakeLists.txt b/src/PaddleClas/deploy/cpp_shitu/CMakeLists.txt new file mode 100644 index 0000000..f412654 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/CMakeLists.txt @@ -0,0 +1,249 @@ +project(pp_shitu CXX C) +cmake_minimum_required(VERSION 3.14) + +option(WITH_MKL "Compile demo with MKL/OpenBlas support, default use MKL." ON) +option(WITH_GPU "Compile demo with GPU/CPU, default use CPU." OFF) +option(WITH_STATIC_LIB "Compile demo with static/shared library, default use static." ON) +option(WITH_TENSORRT "Compile demo with TensorRT." OFF) +option(FAISS_WITH_MKL "Faiss Compile demo with MKL." OFF) + +SET(PADDLE_LIB "" CACHE PATH "Location of libraries") +SET(OPENCV_DIR "" CACHE PATH "Location of libraries") +SET(CUDA_LIB "" CACHE PATH "Location of libraries") +SET(CUDNN_LIB "" CACHE PATH "Location of libraries") +SET(TENSORRT_DIR "" CACHE PATH "Compile demo with TensorRT") +SET(FAISS_DIR "" CACHE PATH "Location of libraries") + +set(DEMO_NAME "pp_shitu") + +if (FAISS_WITH_MKL) + SET(BLAS_NAME "mklml_intel") +else() + SET(BLAS_NAME "openblas") +endif() + +include(external-cmake/yaml-cpp.cmake) +include_directories("${CMAKE_SOURCE_DIR}/") +include_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/src/ext-yaml-cpp/include") +link_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/lib") + +macro(safe_set_static_flag) + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) +endmacro() + + +if (WITH_MKL) + ADD_DEFINITIONS(-DUSE_MKL) +endif() + +if(NOT DEFINED FAISS_DIR) + message(FATAL_ERROR "please set FAISS_DIR with -DFAISS_DIR=/path/faiss") +endif() + +if(NOT DEFINED PADDLE_LIB) + message(FATAL_ERROR "please set PADDLE_LIB with -DPADDLE_LIB=/path/paddle/lib") +endif() + +if(NOT DEFINED OPENCV_DIR) + message(FATAL_ERROR "please set OPENCV_DIR with -DOPENCV_DIR=/path/opencv") +endif() + +if (WIN32) + include_directories("${FAISS_DIR}/include") + link_directories("${FAISS_DIR}/lib") + find_package(faiss REQUIRED PATHS ${FAISS_DIR}/share/faiss/ NO_DEFAULT_PATH) +else() + find_package(faiss REQUIRED PATHS ${FAISS_DIR}/share/faiss NO_DEFAULT_PATH) + include_directories("${FAISS_DIR}/include") + link_directories("${FAISS_DIR}/lib") +endif() + +if (WIN32) + include_directories("${PADDLE_LIB}/paddle/fluid/inference") + include_directories("${PADDLE_LIB}/paddle/include") + link_directories("${PADDLE_LIB}/paddle/fluid/inference") + find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH) + +else () + find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH) + include_directories("${PADDLE_LIB}/paddle/include") + link_directories("${PADDLE_LIB}/paddle/lib") +endif () +include_directories(${OpenCV_INCLUDE_DIRS}) + +if (WIN32) + add_definitions("/DGOOGLE_GLOG_DLL_DECL=") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /bigobj /MTd") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /bigobj /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj /MTd") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj /MT") + if (WITH_STATIC_LIB) + safe_set_static_flag() + add_definitions(-DSTATIC_LIB) + endif() +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -std=c++11") + set(CMAKE_STATIC_LIBRARY_PREFIX "") +endif() +message("flags" ${CMAKE_CXX_FLAGS}) + + +if (WITH_GPU) + if (NOT DEFINED CUDA_LIB OR ${CUDA_LIB} STREQUAL "") + message(FATAL_ERROR "please set CUDA_LIB with -DCUDA_LIB=/path/cuda-8.0/lib64") + endif() + if (NOT WIN32) + if (NOT DEFINED CUDNN_LIB) + message(FATAL_ERROR "please set CUDNN_LIB with -DCUDNN_LIB=/path/cudnn_v7.4/cuda/lib64") + endif() + endif(NOT WIN32) +endif() + +include_directories("${PADDLE_LIB}/third_party/install/protobuf/include") +include_directories("${PADDLE_LIB}/third_party/install/glog/include") +include_directories("${PADDLE_LIB}/third_party/install/gflags/include") +include_directories("${PADDLE_LIB}/third_party/install/xxhash/include") +include_directories("${PADDLE_LIB}/third_party/install/zlib/include") +include_directories("${PADDLE_LIB}/third_party/boost") +include_directories("${PADDLE_LIB}/third_party/eigen3") + +include_directories("${CMAKE_SOURCE_DIR}/") + +if (NOT WIN32) + if (WITH_TENSORRT AND WITH_GPU) + include_directories("${TENSORRT_DIR}/include") + link_directories("${TENSORRT_DIR}/lib") + endif() +endif(NOT WIN32) + +link_directories("${PADDLE_LIB}/third_party/install/zlib/lib") + +link_directories("${PADDLE_LIB}/third_party/install/protobuf/lib") +link_directories("${PADDLE_LIB}/third_party/install/glog/lib") +link_directories("${PADDLE_LIB}/third_party/install/gflags/lib") +link_directories("${PADDLE_LIB}/third_party/install/xxhash/lib") +link_directories("${PADDLE_LIB}/paddle/lib") + + +if(WITH_MKL) + include_directories("${PADDLE_LIB}/third_party/install/mklml/include") + if (WIN32) + set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.lib + ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.lib) + else () + set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} + ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX}) + execute_process(COMMAND cp -r ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} /usr/lib) + endif () + set(MKLDNN_PATH "${PADDLE_LIB}/third_party/install/mkldnn") + if(EXISTS ${MKLDNN_PATH}) + include_directories("${MKLDNN_PATH}/include") + if (WIN32) + set(MKLDNN_LIB ${MKLDNN_PATH}/lib/mkldnn.lib) + else () + set(MKLDNN_LIB ${MKLDNN_PATH}/lib/libmkldnn.so.0) + endif () + endif() +else() + if (WIN32) + set(MATH_LIB ${PADDLE_LIB}/third_party/install/openblas/lib/openblas${CMAKE_STATIC_LIBRARY_SUFFIX}) + else () + set(MATH_LIB ${PADDLE_LIB}/third_party/install/openblas/lib/libopenblas${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif () +endif() + +# Note: libpaddle_inference_api.so/a must put before libpaddle_fluid.so/a +if(WITH_STATIC_LIB) + if(WIN32) + set(DEPS + ${PADDLE_LIB}/paddle/lib/paddle_inference${CMAKE_STATIC_LIBRARY_SUFFIX}) + else() + set(DEPS + ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() +else() + if(WIN32) + set(DEPS + ${PADDLE_LIB}/paddle/lib/paddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX}) + else() + set(DEPS + ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() +endif(WITH_STATIC_LIB) + +if (NOT WIN32) + set(DEPS ${DEPS} + ${MATH_LIB} ${MKLDNN_LIB} + glog gflags protobuf z xxhash yaml-cpp + ) + if(EXISTS "${PADDLE_LIB}/third_party/install/snappystream/lib") + set(DEPS ${DEPS} snappystream) + endif() + if (EXISTS "${PADDLE_LIB}/third_party/install/snappy/lib") + set(DEPS ${DEPS} snappy) + endif() +else() + set(DEPS ${DEPS} + ${MATH_LIB} ${MKLDNN_LIB} + glog gflags_static libprotobuf xxhash libyaml-cppmt) + set(DEPS ${DEPS} libcmt shlwapi) + if (EXISTS "${PADDLE_LIB}/third_party/install/snappy/lib") + set(DEPS ${DEPS} snappy) + endif() + if(EXISTS "${PADDLE_LIB}/third_party/install/snappystream/lib") + set(DEPS ${DEPS} snappystream) + endif() +endif(NOT WIN32) + + +if(WITH_GPU) + if(NOT WIN32) + if (WITH_TENSORRT) + set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer_plugin${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + set(DEPS ${DEPS} ${CUDA_LIB}/libcudart${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(DEPS ${DEPS} ${CUDNN_LIB}/libcudnn${CMAKE_SHARED_LIBRARY_SUFFIX}) + else() + set(DEPS ${DEPS} ${CUDA_LIB}/cudart${CMAKE_STATIC_LIBRARY_SUFFIX} ) + set(DEPS ${DEPS} ${CUDA_LIB}/cublas${CMAKE_STATIC_LIBRARY_SUFFIX} ) + set(DEPS ${DEPS} ${CUDNN_LIB}/cudnn${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() +endif() + + +if (NOT WIN32) + set(EXTERNAL_LIB "-ldl -lrt -lgomp -lz -lm -lpthread") + set(DEPS ${DEPS} ${EXTERNAL_LIB}) +endif() + +set(DEPS ${DEPS} ${OpenCV_LIBS}) + +include(FetchContent) +include(external-cmake/auto-log.cmake) +include_directories(${FETCHCONTENT_BASE_DIR}/extern_autolog-src) + + +AUX_SOURCE_DIRECTORY(./src SRCS) +add_executable(${DEMO_NAME} ${SRCS}) +ADD_DEPENDENCIES(${DEMO_NAME} ext-yaml-cpp) +target_link_libraries(${DEMO_NAME} ${DEPS}) +target_link_libraries(${DEMO_NAME} ${FAISS_DIR}/lib/libfaiss${CMAKE_STATIC_LIBRARY_SUFFIX}) +target_link_libraries(${DEMO_NAME} ${BLAS_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) + +if (WIN32 AND WITH_MKL) + add_custom_command(TARGET ${DEMO_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.dll ./mklml.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.dll ./libiomp5md.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mkldnn/lib/mkldnn.dll ./mkldnn.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.dll ./release/mklml.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.dll ./release/libiomp5md.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mkldnn/lib/mkldnn.dll ./release/mkldnn.dll + ) +endif() diff --git a/src/PaddleClas/deploy/cpp_shitu/external-cmake/auto-log.cmake b/src/PaddleClas/deploy/cpp_shitu/external-cmake/auto-log.cmake new file mode 100644 index 0000000..9be9c2f --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/external-cmake/auto-log.cmake @@ -0,0 +1,12 @@ +find_package(Git REQUIRED) +include(FetchContent) + +set(FETCHCONTENT_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party") + +FetchContent_Declare( + extern_Autolog + PREFIX autolog + GIT_REPOSITORY https://github.com/LDOUBLEV/AutoLog.git + GIT_TAG main +) +FetchContent_MakeAvailable(extern_Autolog) diff --git a/src/PaddleClas/deploy/cpp_shitu/external-cmake/yaml-cpp.cmake b/src/PaddleClas/deploy/cpp_shitu/external-cmake/yaml-cpp.cmake new file mode 100644 index 0000000..7bc7f34 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/external-cmake/yaml-cpp.cmake @@ -0,0 +1,30 @@ + +find_package(Git REQUIRED) + +include(ExternalProject) + +message("${CMAKE_BUILD_TYPE}") + +ExternalProject_Add( + ext-yaml-cpp + URL https://bj.bcebos.com/paddlex/deploy/deps/yaml-cpp.zip + URL_MD5 9542d6de397d1fbd649ed468cb5850e6 + CMAKE_ARGS + -DYAML_CPP_BUILD_TESTS=OFF + -DYAML_CPP_BUILD_TOOLS=OFF + -DYAML_CPP_INSTALL=OFF + -DYAML_CPP_BUILD_CONTRIB=OFF + -DMSVC_SHARED_RT=OFF + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} + -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/ext/yaml-cpp/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/ext/yaml-cpp/lib + PREFIX "${CMAKE_BINARY_DIR}/ext/yaml-cpp" + # Disable install step + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_BUILD 1 +) diff --git a/src/PaddleClas/deploy/cpp_shitu/include/feature_extracter.h b/src/PaddleClas/deploy/cpp_shitu/include/feature_extracter.h new file mode 100644 index 0000000..e83caee --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/feature_extracter.h @@ -0,0 +1,110 @@ +// 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. + +#pragma once + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include "paddle_inference_api.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +using namespace paddle_infer; + +namespace Feature { + + class FeatureExtracter { + public: + explicit FeatureExtracter(const YAML::Node &config_file) { + this->use_gpu_ = config_file["Global"]["use_gpu"].as(); + if (config_file["Global"]["gpu_id"].IsDefined()) + this->gpu_id_ = config_file["Global"]["gpu_id"].as(); + else + this->gpu_id_ = 0; + this->gpu_mem_ = config_file["Global"]["gpu_mem"].as(); + this->cpu_math_library_num_threads_ = + config_file["Global"]["cpu_num_threads"].as(); + this->use_mkldnn_ = config_file["Global"]["enable_mkldnn"].as(); + this->use_tensorrt_ = config_file["Global"]["use_tensorrt"].as(); + this->use_fp16_ = config_file["Global"]["use_fp16"].as(); + + this->cls_model_path_ = + config_file["Global"]["rec_inference_model_dir"].as() + + OS_PATH_SEP + "inference.pdmodel"; + this->cls_params_path_ = + config_file["Global"]["rec_inference_model_dir"].as() + + OS_PATH_SEP + "inference.pdiparams"; + this->resize_size_ = + config_file["RecPreProcess"]["transform_ops"][0]["ResizeImage"]["size"] + .as(); + this->scale_ = config_file["RecPreProcess"]["transform_ops"][1]["NormalizeImage"]["scale"].as(); + this->mean_ = config_file["RecPreProcess"]["transform_ops"][1] + ["NormalizeImage"]["mean"] + .as < std::vector < float >> (); + this->std_ = config_file["RecPreProcess"]["transform_ops"][1] + ["NormalizeImage"]["std"] + .as < std::vector < float >> (); + if (config_file["Global"]["rec_feature_normlize"].IsDefined()) + this->feature_norm = + config_file["Global"]["rec_feature_normlize"].as(); + + LoadModel(cls_model_path_, cls_params_path_); + } + + // Load Paddle inference model + void LoadModel(const std::string &model_path, const std::string ¶ms_path); + + // Run predictor + void Run(cv::Mat &img, std::vector &out_data, + std::vector ×); + + void FeatureNorm(std::vector &feature); + + std::shared_ptr predictor_; + + private: + bool use_gpu_ = false; + int gpu_id_ = 0; + int gpu_mem_ = 4000; + int cpu_math_library_num_threads_ = 4; + bool use_mkldnn_ = false; + bool use_tensorrt_ = false; + bool feature_norm = true; + bool use_fp16_ = false; + std::vector mean_ = {0.485f, 0.456f, 0.406f}; + std::vector std_ = {0.229f, 0.224f, 0.225f}; + float scale_ = 0.00392157; + int resize_size_ = 224; + int resize_short_ = 224; + std::string cls_model_path_; + std::string cls_params_path_; + + // pre-process + ResizeImg resize_op_; + Normalize normalize_op_; + Permute permute_op_; + }; + +} // namespace Feature diff --git a/src/PaddleClas/deploy/cpp_shitu/include/nms.h b/src/PaddleClas/deploy/cpp_shitu/include/nms.h new file mode 100644 index 0000000..0295624 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/nms.h @@ -0,0 +1,85 @@ +// Copyright (c) 2021 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. + +// This code is adpated from opencv(https://github.com/opencv/opencv) + +#include +#include + +template +static inline bool SortScorePairDescend(const std::pair &pair1, + const std::pair &pair2) { + return pair1.first > pair2.first; +} + +float RectOverlap(const Detection::ObjectResult &a, + const Detection::ObjectResult &b) { + float Aa = (a.rect[2] - a.rect[0] + 1) * (a.rect[3] - a.rect[1] + 1); + float Ab = (b.rect[2] - b.rect[0] + 1) * (b.rect[3] - b.rect[1] + 1); + + int iou_w = max(min(a.rect[2], b.rect[2]) - max(a.rect[0], b.rect[0]) + 1, 0); + int iou_h = max(min(a.rect[3], b.rect[3]) - max(a.rect[1], b.rect[1]) + 1, 0); + float Aab = iou_w * iou_h; + return Aab / (Aa + Ab - Aab); +} + +// Get max scores with corresponding indices. +// scores: a set of scores. +// threshold: only consider scores higher than the threshold. +// top_k: if -1, keep all; otherwise, keep at most top_k. +// score_index_vec: store the sorted (score, index) pair. +inline void +GetMaxScoreIndex(const std::vector &det_result, + const float threshold, + std::vector > &score_index_vec) { + // Generate index score pairs. + for (size_t i = 0; i < det_result.size(); ++i) { + if (det_result[i].confidence > threshold) { + score_index_vec.push_back(std::make_pair(det_result[i].confidence, i)); + } + } + + // Sort the score pair according to the scores in descending order + std::stable_sort(score_index_vec.begin(), score_index_vec.end(), + SortScorePairDescend); + + // // Keep top_k scores if needed. + // if (top_k > 0 && top_k < (int)score_index_vec.size()) + // { + // score_index_vec.resize(top_k); + // } +} + +void NMSBoxes(const std::vector det_result, + const float score_threshold, const float nms_threshold, + std::vector &indices) { + int a = 1; + // Get top_k scores (with corresponding indices). + std::vector > score_index_vec; + GetMaxScoreIndex(det_result, score_threshold, score_index_vec); + + // Do nms + indices.clear(); + for (size_t i = 0; i < score_index_vec.size(); ++i) { + const int idx = score_index_vec[i].second; + bool keep = true; + for (int k = 0; k < (int) indices.size() && keep; ++k) { + const int kept_idx = indices[k]; + float overlap = RectOverlap(det_result[idx], det_result[kept_idx]); + keep = overlap <= nms_threshold; + } + if (keep) + indices.push_back(idx); + } +} diff --git a/src/PaddleClas/deploy/cpp_shitu/include/object_detector.h b/src/PaddleClas/deploy/cpp_shitu/include/object_detector.h new file mode 100644 index 0000000..5bfc562 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/object_detector.h @@ -0,0 +1,138 @@ +// 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. + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "paddle_inference_api.h" // NOLINT + +#include "include/preprocess_op_det.h" +#include "include/yaml_config.h" + +using namespace paddle_infer; + +namespace Detection { +// Object Detection Result + struct ObjectResult { + // Rectangle coordinates of detected object: left, right, top, down + std::vector rect; + // Class id of detected object + int class_id; + // Confidence of detected object + float confidence; + }; + +// Generate visualization colormap for each class + std::vector GenerateColorMap(int num_class); + +// Visualiztion Detection Result + cv::Mat VisualizeResult(const cv::Mat &img, + const std::vector &results, + const std::vector &lables, + const std::vector &colormap, const bool is_rbox); + + class ObjectDetector { + public: + explicit ObjectDetector(const YAML::Node &config_file) { + this->use_gpu_ = config_file["Global"]["use_gpu"].as(); + if (config_file["Global"]["gpu_id"].IsDefined()) + this->gpu_id_ = config_file["Global"]["gpu_id"].as(); + this->gpu_mem_ = config_file["Global"]["gpu_mem"].as(); + this->cpu_math_library_num_threads_ = + config_file["Global"]["cpu_num_threads"].as(); + this->use_mkldnn_ = config_file["Global"]["enable_mkldnn"].as(); + this->use_tensorrt_ = config_file["Global"]["use_tensorrt"].as(); + this->use_fp16_ = config_file["Global"]["use_fp16"].as(); + this->model_dir_ = + config_file["Global"]["det_inference_model_dir"].as(); + this->threshold_ = config_file["Global"]["threshold"].as(); + this->max_det_results_ = config_file["Global"]["max_det_results"].as(); + this->image_shape_ = + config_file["Global"]["image_shape"].as < std::vector < int >> (); + this->label_list_ = + config_file["Global"]["labe_list"].as < std::vector < std::string >> (); + this->ir_optim_ = config_file["Global"]["ir_optim"].as(); + this->batch_size_ = config_file["Global"]["batch_size"].as(); + + preprocessor_.Init(config_file["DetPreProcess"]["transform_ops"]); + LoadModel(model_dir_, batch_size_, run_mode); + } + + // Load Paddle inference model + void LoadModel(const std::string &model_dir, const int batch_size = 1, + const std::string &run_mode = "fluid"); + + // Run predictor + void Predict(const std::vector imgs, const int warmup = 0, + const int repeats = 1, + std::vector *result = nullptr, + std::vector *bbox_num = nullptr, + std::vector *times = nullptr); + + const std::vector &GetLabelList() const { + return this->label_list_; + } + + const float &GetThreshold() const { return this->threshold_; } + + private: + bool use_gpu_ = true; + int gpu_id_ = 0; + int gpu_mem_ = 800; + int cpu_math_library_num_threads_ = 6; + std::string run_mode = "fluid"; + bool use_mkldnn_ = false; + bool use_tensorrt_ = false; + bool batch_size_ = 1; + bool use_fp16_ = false; + std::string model_dir_; + float threshold_ = 0.5; + float max_det_results_ = 5; + std::vector image_shape_ = {3, 640, 640}; + std::vector label_list_; + bool ir_optim_ = true; + bool det_permute_ = true; + bool det_postprocess_ = true; + int min_subgraph_size_ = 30; + bool use_dynamic_shape_ = false; + int trt_min_shape_ = 1; + int trt_max_shape_ = 1280; + int trt_opt_shape_ = 640; + bool trt_calib_mode_ = false; + + // Preprocess image and copy data to input buffer + void Preprocess(const cv::Mat &image_mat); + + // Postprocess result + void Postprocess(const std::vector mats, + std::vector *result, std::vector bbox_num, + bool is_rbox); + + std::shared_ptr predictor_; + Preprocessor preprocessor_; + ImageBlob inputs_; + std::vector output_data_; + std::vector out_bbox_num_data_; + }; + +} // namespace Detection diff --git a/src/PaddleClas/deploy/cpp_shitu/include/preprocess_op.h b/src/PaddleClas/deploy/cpp_shitu/include/preprocess_op.h new file mode 100644 index 0000000..db4c6b2 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/preprocess_op.h @@ -0,0 +1,57 @@ +// 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. + +#pragma once + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; + +namespace Feature { + + class Normalize { + public: + virtual void Run(cv::Mat *im, const std::vector &mean, + const std::vector &std, float scale); + }; + +// RGB -> CHW + class Permute { + public: + virtual void Run(const cv::Mat *im, float *data); + }; + + class CenterCropImg { + public: + virtual void Run(cv::Mat &im, const int crop_size = 224); + }; + + class ResizeImg { + public: + virtual void Run(const cv::Mat &img, cv::Mat &resize_img, int max_size_len, + int size = 0); + }; + +} // namespace Feature diff --git a/src/PaddleClas/deploy/cpp_shitu/include/preprocess_op_det.h b/src/PaddleClas/deploy/cpp_shitu/include/preprocess_op_det.h new file mode 100644 index 0000000..cd66340 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/preprocess_op_det.h @@ -0,0 +1,158 @@ +// 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. + +#pragma once + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace Detection { + +// Object for storing all preprocessed data + class ImageBlob { + public: + // image width and height + std::vector im_shape_; + // Buffer for image data after preprocessing + std::vector im_data_; + // in net data shape(after pad) + std::vector in_net_shape_; + // Evaluation image width and height + // std::vector eval_im_size_f_; + // Scale factor for image size to origin image size + std::vector scale_factor_; + }; + +// Abstraction of preprocessing opration class + class PreprocessOp { + public: + virtual void Init(const YAML::Node &item) = 0; + + virtual void Run(cv::Mat *im, ImageBlob *data) = 0; + }; + + class InitInfo : public PreprocessOp { + public: + virtual void Init(const YAML::Node &item) {} + + virtual void Run(cv::Mat *im, ImageBlob *data); + }; + + class NormalizeImage : public PreprocessOp { + public: + virtual void Init(const YAML::Node &item) { + mean_ = item["mean"].as < std::vector < float >> (); + scale_ = item["std"].as < std::vector < float >> (); + is_scale_ = item["is_scale"].as(); + } + + virtual void Run(cv::Mat *im, ImageBlob *data); + + private: + // CHW or HWC + std::vector mean_; + std::vector scale_; + bool is_scale_; + }; + + class Permute : public PreprocessOp { + public: + virtual void Init(const YAML::Node &item) {} + + virtual void Run(cv::Mat *im, ImageBlob *data); + }; + + class Resize : public PreprocessOp { + public: + virtual void Init(const YAML::Node &item) { + interp_ = item["interp"].as(); + // max_size_ = item["target_size"].as(); + keep_ratio_ = item["keep_ratio"].as(); + target_size_ = item["target_size"].as < std::vector < int >> (); + } + + // Compute best resize scale for x-dimension, y-dimension + std::pair GenerateScale(const cv::Mat &im); + + virtual void Run(cv::Mat *im, ImageBlob *data); + + private: + int interp_ = 2; + bool keep_ratio_; + std::vector target_size_; + std::vector in_net_shape_; + }; + +// Models with FPN need input shape % stride == 0 + class PadStride : public PreprocessOp { + public: + virtual void Init(const YAML::Node &item) { + stride_ = item["stride"].as(); + } + + virtual void Run(cv::Mat *im, ImageBlob *data); + + private: + int stride_; + }; + + class Preprocessor { + public: + void Init(const YAML::Node &config_node) { + // initialize image info at first + ops_["InitInfo"] = std::make_shared(); + for (int i = 0; i < config_node.size(); ++i) { + if (config_node[i]["DetResize"].IsDefined()) { + ops_["Resize"] = std::make_shared(); + ops_["Resize"]->Init(config_node[i]["DetResize"]); + } + + if (config_node[i]["DetNormalizeImage"].IsDefined()) { + ops_["NormalizeImage"] = std::make_shared(); + ops_["NormalizeImage"]->Init(config_node[i]["DetNormalizeImage"]); + } + + if (config_node[i]["DetPermute"].IsDefined()) { + ops_["Permute"] = std::make_shared(); + ops_["Permute"]->Init(config_node[i]["DetPermute"]); + } + + if (config_node[i]["DetPadStrid"].IsDefined()) { + ops_["PadStride"] = std::make_shared(); + ops_["PadStride"]->Init(config_node[i]["DetPadStrid"]); + } + } + } + + void Run(cv::Mat *im, ImageBlob *data); + + public: + static const std::vector RUN_ORDER; + + private: + std::unordered_map > ops_; + }; + +} // namespace Detection diff --git a/src/PaddleClas/deploy/cpp_shitu/include/vector_search.h b/src/PaddleClas/deploy/cpp_shitu/include/vector_search.h new file mode 100644 index 0000000..4b354f7 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/vector_search.h @@ -0,0 +1,70 @@ +// 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. + +#pragma once +#ifdef WIN32 +#define OS_PATH_SEP "\\" +#else +#define OS_PATH_SEP "/" +#endif + +#include "yaml-cpp/yaml.h" +#include +#include +#include +#include + +struct SearchResult { + std::vector I; + std::vector D; + int return_k; +}; + +class VectorSearch { +public: + explicit VectorSearch(const YAML::Node &config_file) { + // IndexProcess + this->index_dir = + config_file["IndexProcess"]["index_dir"].as(); + this->return_k = config_file["IndexProcess"]["return_k"].as(); + this->score_thres = config_file["IndexProcess"]["score_thres"].as(); + this->max_query_number = + config_file["Global"]["max_det_results"].as() + 1; + LoadIdMap(); + LoadIndexFile(); + this->I.resize(this->return_k * this->max_query_number); + this->D.resize(this->return_k * this->max_query_number); + }; + + void LoadIdMap(); + + void LoadIndexFile(); + + const SearchResult &Search(float *feature, int query_number); + + const std::string &GetLabel(faiss::Index::idx_t ind); + + const float &GetThreshold() { return this->score_thres; } + +private: + std::string index_dir; + int return_k = 5; + float score_thres = 0.5; + std::map id_map; + faiss::Index *index; + int max_query_number = 6; + std::vector D; + std::vector I; + SearchResult sr; +}; diff --git a/src/PaddleClas/deploy/cpp_shitu/include/yaml_config.h b/src/PaddleClas/deploy/cpp_shitu/include/yaml_config.h new file mode 100644 index 0000000..78243e2 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/include/yaml_config.h @@ -0,0 +1,58 @@ +// 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. + +#pragma once + +#ifdef WIN32 +#define OS_PATH_SEP "\\" +#else +#define OS_PATH_SEP "/" +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include "yaml-cpp/yaml.h" + + +class YamlConfig { +public: + explicit YamlConfig(const std::string &path) { + config_file = ReadYamlConfig(path); + } + + static std::vector ReadDict(const std::string &path); + + static std::map ReadIndexId(const std::string &path); + + static YAML::Node ReadYamlConfig(const std::string &path); + + void PrintConfigInfo(); + + YAML::Node config_file; +}; diff --git a/src/PaddleClas/deploy/cpp_shitu/readme.md b/src/PaddleClas/deploy/cpp_shitu/readme.md new file mode 100644 index 0000000..97315ec --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/readme.md @@ -0,0 +1,340 @@ +# 服务器端C++预测 + +本教程将介绍在服务器端部署PP-ShiTU的详细步骤。 + +## 目录 + +- [1.准备环境](#1) + - [1.1 升级cmake](#1.1) + - [1.2 编译opencv库](#1.2) + - [1.3 下载或者编译Paddle预测库](#1.3) + - [1.3.1 预测库源码编译](#1.3.1) + - [1.3.2 直接下载安装](#1.3.2) + - [1.4 安装faiss库](#1.4) +- [2.代码编译](#2) +- [3.运行demo](#3) +- [4.使用自己模型](#4) + + + +## 1. 准备环境 + +### 运行准备 +- Linux环境,推荐使用ubuntu docker。 + + + +### 1.1 升级cmake + +由于依赖库编译需要较高版本的cmake,因此,第一步首先将cmake升级。 + +- 下载最新版本cmake + +```shell +# 当前版本最新为3.22.0,根据实际情况自行下载,建议最新版本 +wget https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0.tar.gz +tar xf cmake-3.22.0.tar.gz +``` + +最终可以在当前目录下看到`cmake-3.22.0/`的文件夹。 + +- 编译cmake,首先设置came源码路径(`root_path`)以及安装路径(`install_path`),`root_path`为下载的came源码路径,`install_path`为came的安装路径。在本例中,源码路径即为当前目录下的`cmake-3.22.0/`。 + +```shell +cd ./cmake-3.22.0 +export root_path=$PWD +export install_path=${root_path}/cmake +``` + +- 然后在cmake源码路径下,按照下面的方式进行编译 + +```shell +./bootstrap --prefix=${install_path} +make -j +make install +``` + +- 设置环境变量 + +```shell +export PATH=${install_path}/bin:$PATH +#检查是否正常使用 +cmake --version +``` + +此时,cmake就可以使用了 + + + +### 1.2 编译opencv库 + +* 首先需要从opencv官网上下载在Linux环境下源码编译的包,以3.4.7版本为例,下载及解压缩命令如下: + +``` +wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz +tar -xvf 3.4.7.tar.gz +``` + +最终可以在当前目录下看到`opencv-3.4.7/`的文件夹。 + +* 编译opencv,首先设置opencv源码路径(`root_path`)以及安装路径(`install_path`),`root_path`为下载的opencv源码路径,`install_path`为opencv的安装路径。在本例中,源码路径即为当前目录下的`opencv-3.4.7/`。 + +```shell +cd ./opencv-3.4.7 +export root_path=$PWD +export install_path=${root_path}/opencv3 +``` + +* 然后在opencv源码路径下,按照下面的方式进行编译。 + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + +make -j +make install +``` + +* `make install`完成之后,会在该文件夹下生成opencv头文件和库文件,用于后面的PaddleClas代码编译。 + +以opencv3.4.7版本为例,最终在安装路径下的文件结构如下所示。**注意**:不同的opencv版本,下述的文件结构可能不同。 + +``` +opencv3/ +|-- bin +|-- include +|-- lib64 +|-- share +``` + + + +### 1.3 下载或者编译Paddle预测库 + +* 有2种方式获取Paddle预测库,下面进行详细介绍。 + + + +#### 1.3.1 预测库源码编译 + +* 如果希望获取最新预测库特性,可以从Paddle github上克隆最新代码,源码编译预测库。 +* 可以参考[Paddle预测库官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16)的说明,从github上获取Paddle代码,然后进行编译,生成最新的预测库。使用git获取代码方法如下。 + +```shell +git clone https://github.com/PaddlePaddle/Paddle.git +``` + +* 进入Paddle目录后,使用如下方法编译。 + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DWITH_CONTRIB=OFF \ + -DWITH_MKL=ON \ + -DWITH_MKLDNN=ON \ + -DWITH_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_INFERENCE_API_TEST=OFF \ + -DON_INFER=ON \ + -DWITH_PYTHON=ON +make -j +make inference_lib_dist +``` + +更多编译参数选项可以参考[Paddle C++预测库官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16)。 + + +* 编译完成之后,可以在`build/paddle_inference_install_dir/`文件下看到生成了以下文件及文件夹。 + +``` +build/paddle_inference_install_dir/ +|-- CMakeCache.txt +|-- paddle +|-- third_party +|-- version.txt +``` + +其中`paddle`就是之后进行C++预测时所需的Paddle库,`version.txt`中包含当前预测库的版本信息。 + + + +#### 1.3.2 直接下载安装 + +* [Paddle预测库官网](https://paddle-inference.readthedocs.io/en/latest/user_guides/download_lib.html)上提供了不同cuda版本的Linux预测库,可以在官网查看并选择合适的预测库版本,注意必须选择`develop`版本。 + + 以`https://paddle-inference-lib.bj.bcebos.com/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddle_inference.tgz`的`develop`版本为例,使用下述命令下载并解压: + + +```shell +wget https://paddle-inference-lib.bj.bcebos.com/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddle_inference.tgz + +tar -xvf paddle_inference.tgz +``` + + +最终会在当前的文件夹中生成`paddle_inference/`的子文件夹。 + + + +### 1.4 安装faiss库 + +```shell + # 下载 faiss + git clone https://github.com/facebookresearch/faiss.git + cd faiss + export faiss_install_path=$PWD/faiss_install + cmake -B build . -DFAISS_ENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=${faiss_install_path} + make -C build -j faiss + make -C build install +``` + +在安装`faiss`前,请安装`openblas`,`ubuntu`系统中安装命令如下: + +```shell +apt-get install libopenblas-dev +``` + +注意本教程以安装faiss cpu版本为例,安装时请参考[faiss](https://github.com/facebookresearch/faiss)官网文档,根据需求自行安装。 + + + +## 2. 代码编译 + +编译命令如下,其中Paddle C++预测库、opencv等其他依赖库的地址需要换成自己机器上的实际地址。同时,编译过程中需要下载编译`yaml-cpp`等C++库,请保持联网环境。 + + +```shell +sh tools/build.sh +``` + +具体地,`tools/build.sh`中内容如下,请根据具体路径修改。 + +```shell +OPENCV_DIR=${opencv_install_dir} +LIB_DIR=${paddle_inference_dir} +CUDA_LIB_DIR=/usr/local/cuda/lib64 +CUDNN_LIB_DIR=/usr/lib/x86_64-linux-gnu/ +FAISS_DIR=${faiss_install_dir} +FAISS_WITH_MKL=OFF + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DUSE_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DFAISS_DIR=${FAISS_DIR} \ + -DFAISS_WITH_MKL=${FAISS_WITH_MKL} + +make -j +cd .. +``` + +上述命令中, + +* `OPENCV_DIR`为opencv编译安装的地址(本例中为`opencv-3.4.7/opencv3`文件夹的路径); +* `LIB_DIR`为下载的Paddle预测库(`paddle_inference`文件夹),或编译生成的Paddle预测库(`build/paddle_inference_install_dir`文件夹)的路径; +* `CUDA_LIB_DIR`为cuda库文件地址,在docker中为`/usr/local/cuda/lib64`; +* `CUDNN_LIB_DIR`为cudnn库文件地址,在docker中为`/usr/lib/x86_64-linux-gnu/`。 +* `TENSORRT_DIR`是tensorrt库文件地址,在dokcer中为`/usr/local/TensorRT6-cuda10.0-cudnn7/`,TensorRT需要结合GPU使用。 +* `FAISS_DIR`是faiss的安装地址 +* `FAISS_WITH_MKL`是指在编译faiss的过程中,是否使用了mkldnn,本文档中编译faiss,没有使用,而使用了openblas,故设置为`OFF`,若使用了mkldnn,则为`ON`. + + +在执行上述命令,编译完成之后,会在当前路径下生成`build`文件夹,其中生成一个名为`pp_shitu`的可执行文件。 + + + +## 3. 运行demo + +- 请参考[识别快速开始文档](../../docs/zh_CN/quick_start/quick_start_recognition.md),下载好相应的 轻量级通用主体检测模型、轻量级通用识别模型及瓶装饮料测试数据并解压。 + + ```shell + mkdir models + cd models + wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar + tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar + wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar + tar -xf general_PPLCNet_x2_5_lite_v1.0_infer.tar + cd .. + + mkdir data + cd data + wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar + tar -xf drink_dataset_v1.0.tar + cd .. + ``` + +- 将相应的yaml文件拷到当前文件夹下 + + ```shell + cp ../configs/inference_drink.yaml . + ``` + +- 将`inference_drink.yaml`中的相对路径,改成基于本目录的路径或者绝对路径。涉及到的参数有 + + - Global.infer_imgs :此参数可以是具体的图像地址,也可以是图像集所在的目录 + - Global.det_inference_model_dir : 检测模型存储目录 + - Global.rec_inference_model_dir : 识别模型存储目录 + - IndexProcess.index_dir : 检索库的存储目录,在示例中,检索库在下载的demo数据中。 + +- 字典转换 + + 由于python的检索库的字典,使用`pickle`进行的序列化存储,导致C++不方便读取,因此进行转换 + + ```shell + python tools/transform_id_map.py -c inference_drink.yaml + ``` + + 转换成功后,在`IndexProcess.index_dir`目录下生成`id_map.txt`,方便c++ 读取。 + +- 执行程序 + + ```shell + ./build/pp_shitu -c inference_drink.yaml + # or + ./build/pp_shitu -config inference_drink.yaml + ``` + + 若对图像集进行检索,则可能得到,如下结果。注意,此结果只做展示,具体以实际运行结果为准。 + + 同时,需注意的是,由于opencv 版本问题,会导致图像在预处理的过程中,resize产生细微差别,导致python 和c++结果,轻微不同,如bbox相差几个像素,检索结果小数点后3位diff等。但不会改变最终检索label。 + + ![](../../docs/images/quick_start/shitu_c++_result.png) + + + +## 4. 使用自己模型 + +使用自己训练的模型,可以参考[模型导出](../../docs/zh_CN/inference_deployment/export_model.md),导出`inference model`,用于模型预测。 + +同时注意修改`yaml`文件中具体参数。 diff --git a/src/PaddleClas/deploy/cpp_shitu/readme_en.md b/src/PaddleClas/deploy/cpp_shitu/readme_en.md new file mode 100644 index 0000000..76867c7 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/readme_en.md @@ -0,0 +1,336 @@ +# C++ Inference on Server + +This tutorial details the steps to deploy PP-ShiTU on the server side. + +## Catalogue + +- [1.Prepare the Environment](#1) + - [1.1 Update cmake](#1.1) + - [1.2 Compile opencv Library](#1.2) + - [1.3 Download or Compile Paddle Inference Library](#1.3) + - [1.3.1 Compile the Source of Inference Library](#1.3.1) + - [1.3.2 Direct Download and Installation](#1.3.2) + - [1.4 Install faiss Library](#1.4) +- [2.Code Compilation](#2) +- [3.Run the demo](#3) +- [4.Use Your Own Model](#4) + + + +## 1. Prepare the Environment + +### Environment Preparation + +- Linux environment, ubuntu docker recommended. + + + +### 1.1 Update cmake + +The first step is to upgrade `cmake` considering the requirements of the dependency library compilation. + +- Download the latest version of cmake + +``` +# The latest version is 3.22.0, please download the appropriate one, the latest recommended. +wget https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0.tar.gz +tar xf cmake-3.22.0.tar.gz +``` + +You can find `cmake-3.22.0/` folder in the current directory. + +- To compile cmake, first set the source path of `cmake` (`root_path`) and installation path (`install_path`). In this example, the source path is `cmake-3.22.0/` in the current directory. + +```shell +cd ./cmake-3.22.0 +export root_path=$PWD +export install_path=${root_path}/cmake +``` + +- Then compile under the source path as follows: + +```shell +./bootstrap --prefix=${install_path} +make -j +make install +``` + +- Set environment variables + +```shell +export PATH=${install_path}/bin:$PATH +#Check its well functioning +cmake --version +``` + +cmake is now ready for use. + + + +### 1.2 Compile opencv Library + +- First, download the package for source compilation in Linux environment from the official website of opencv. Taking version 3.4.7 as an example, follow the command below to download and unzip it: + +```shell +wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz +tar -xvf 3.4.7.tar.gz +``` + +You can find`opencv-3.4.7/`folder in the current directory. + +- To compile opencv, first set the source path of opencv(`root_path`) and installation path (`install_path`). In this example, the source path is`opencv-3.4.7/`in the current directory. + +``` +cd ./opencv-3.4.7 +export root_path=$PWD +export install_path=${root_path}/opencv3 +``` + +- Then compile under the source path as follows: + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + +make -j +make install +``` + +- After `make install` is done, opencv header and library files will be generated in this folder for later compilation of PaddleClas code. + +For opencv version 3.4.7, the final file structure under the installation path is shown below. **Note**: The following file structure may vary for different opencv versions. + +``` +opencv3/ +|-- bin +|-- include +|-- lib64 +|-- share +``` + + + +### 1.3 Download or Compile Paddle Inference Library + +- Here we detail 2 ways to obtain Paddle inference library. + + + +#### 1.3.1 Compile the Source of Inference Library + +- To obtain the latest features of the inference library, you can clone the latest code from Paddle github and compile the source code of the library. +- Please refer to the website of [Paddle Inference Library](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_ and_install_lib_cn.html#id16) to get Paddle code from github and then compile it to generate the latest inference library. The method to obtain the code using git is as follows. + +```shell +git clone https://github.com/PaddlePaddle/Paddle.git +``` + +- Adopt the following method to compile after entering Paddle directory. + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DWITH_CONTRIB=OFF \ + -DWITH_MKL=ON \ + -DWITH_MKLDNN=ON \ + -DWITH_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_INFERENCE_API_TEST=OFF \ + -DON_INFER=ON \ + -DWITH_PYTHON=ON +make -j +make inference_lib_dist +``` + +See the official website of [Paddle C++ Inference Library](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16) for more compilation parameters. + +- The following files and folders can be found generated under `build/paddle_inference_install_dir/` after compilation. + +``` +build/paddle_inference_install_dir/ +|-- CMakeCache.txt +|-- paddle +|-- third_party +|-- version.txt +``` + + `paddle` is the Paddle library needed for later C++ inference, and `version.txt` contains the version information of the current inference library. + + + +#### 1.3.2 Direct Download and Installation + +- The Linux inference library of different cuda versions are available on the official website of [Paddle Inference Library ](https://paddle-inference.readthedocs.io/en/latest/user_guides/download_lib.html), where you can choose the appropriate version. Note that you must select the `develop` version. + + For the `develop` version of `https://paddle-inference-lib.bj.bcebos.com/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddle_inference.tgz`, use the following command to download and unzip it: + +```shell +wget https://paddle-inference-lib.bj.bcebos.com/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddle_inference.tgz + +tar -xvf paddle_inference.tgz +``` + +The subfolder `paddle_inference/` will finally be created in the current folder. + + + +### 1.4 Install faiss Library + +```shell + # Download faiss + git clone https://github.com/facebookresearch/faiss.git + cd faiss + export faiss_install_path=$PWD/faiss_install + cmake -B build . -DFAISS_ENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=${faiss_install_path} + make -C build -j faiss + make -C build install +``` + +Please install `openblas` before `faiss`, the installation command in `ubuntu` system is as follows: + +``` +apt-get install libopenblas-dev +``` + +Note that this tutorial installs the cpu version of faiss as an example, please install it as your need by referring to the official documents of [faiss](https://github.com/facebookresearch/faiss). + + + +## 2. Code Compilation + +The command is as follows, where the address of Paddle C++ inference library, opencv and other dependency libraries need to be replaced with the actual address on your own machine. Also, you need to download and compile `yaml-cpp` and other C++ libraries during the compilation, so please keep the network unblocked. + +```shell +sh tools/build.sh +``` + +Specifically, the contents of `tools/build.sh` are as follows, please modify according to the specific path. + +```shell +OPENCV_DIR=${opencv_install_dir} +LIB_DIR=${paddle_inference_dir} +CUDA_LIB_DIR=/usr/local/cuda/lib64 +CUDNN_LIB_DIR=/usr/lib/x86_64-linux-gnu/ +FAISS_DIR=${faiss_install_dir} +FAISS_WITH_MKL=OFF + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DUSE_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DFAISS_DIR=${FAISS_DIR} \ + -DFAISS_WITH_MKL=${FAISS_WITH_MKL} + +make -j +cd .. +``` + +In the above commands: + +- `OPENCV_DIR` is the address of the opencv compilation and installation (in this case, the path of the `opencv-3.4.7/opencv3` folder). +- `LIB_DIR` is the path of the downloaded Paddle inference library (`paddle_inference` folder), or the generated Paddle inference library after compilation (`build/paddle_inference_install_dir` folder). +- `CUDA_LIB_DIR` is path of the cuda library file, which in docker is `/usr/local/cuda/lib64`. +- `CUDNN_LIB_DIR` is the path of the cudnn library file, which in docker is `/usr/lib/x86_64-linux-gnu/` . +- `TENSORRT_DIR` is the path of the tensorrt library file, which in docker is `/usr/local/TensorRT6-cuda10.0-cudnn7/`. TensorRT needs to be used in combination with GPU. +- `FAISS_DIR` is the installation path of faiss. +- `FAISS_WITH_MKL` means whether mkldnn is used during the compilation of faiss. The compilation in this document employs openbals instead of mkldnn, so it is set to `OFF`, otherwise it is `ON`. + +A `build` folder will be created in the current path after the compilation, which generates an executable file named `pp_shitu`. + + + +## 3. Run the demo + +- Please refer to the [Quick Start of Recognition](../../docs/en/quick_start/quick_start_recognition_en.md), download the corresponding Lightweight Generic Mainbody Detection Model, Lightweight Generic Recognition Model, and the beverage test data and unzip them. + + ```shell + mkdir models + cd models + wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar + tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar + wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar + tar -xf general_PPLCNet_x2_5_lite_v1.0_infer.tar + cd .. + + mkdir data + cd data + wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar + tar -xf drink_dataset_v1.0.tar + cd .. + ``` + +- Copy the corresponding yaml file to the current folder + + ``` + cp ../configs/inference_drink.yaml . + ``` + +- Change the relative path in `inference_drink.yaml` to a path based on this directory or an absolute path. The parameters involved are: + + - Global.infer_imgs: This parameter can be a specific image path or the directory where the image set is located + - Global.det_inference_model_dir: The directory where detection models are saved. + - Global.rec_inference_model_dir: The directory where recognition models are saved. + - IndexProcess.index_dir: The storage directory of the retrieval library, in the exmple, the retrieval library is in the downloaded demo data. + +- Transform the ID-Label Map Dictionary + + The id-label map dictionary in python is serialized using `pickle`, which make it hard to read for C++, so the transformation is needed: + + ``` + python tools/transform_id_map.py -c inference_drink.yaml + ``` + + `id_map.txt` is generated in `IndexProcess.index_dir` directory for convenience of C++ reading. + +- Execute the program + + ```shell + ./build/pp_shitu -c inference_drink.yaml + # or + ./build/pp_shitu -config inference_drink.yaml + ``` + + The following results can be obtained after searching the image set. + + At the same time, it should be noticed that a slight difference may occur during the pre-processing of the image due to the version of opencv, resulting in a minor discrepancy in python and c++ results, such as a few pixels for bbox, 3 decimal places for retrieval results, etc. But it has no impact on the final search label. + + [![img](../../docs/images/quick_start/shitu_c++_result.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/quick_start/shitu_c++_result.png) + + + +## 4. Use Your Own Model + +You can also use your self-trained models. Please refer to [model export](../../docs/en/inference_deployment/export_model_en.md) to export ` inference model` for model inference. + +Mind modifying the specific parameters in the `yaml` file. diff --git a/src/PaddleClas/deploy/cpp_shitu/src/feature_extracter.cpp b/src/PaddleClas/deploy/cpp_shitu/src/feature_extracter.cpp new file mode 100644 index 0000000..37c7590 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/feature_extracter.cpp @@ -0,0 +1,119 @@ +// 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. + +#include +#include +#include + +namespace Feature { + + void FeatureExtracter::LoadModel(const std::string &model_path, + const std::string ¶ms_path) { + paddle_infer::Config config; + config.SetModel(model_path, params_path); + + if (this->use_gpu_) { + config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); + if (this->use_tensorrt_) { + config.EnableTensorRtEngine( + 1 << 20, 1, 3, + this->use_fp16_ ? paddle_infer::Config::Precision::kHalf + : paddle_infer::Config::Precision::kFloat32, + false, false); + } + } else { + config.DisableGpu(); + if (this->use_mkldnn_) { + config.EnableMKLDNN(); + // cache 10 different shapes for mkldnn to avoid memory leak + config.SetMkldnnCacheCapacity(10); + } + config.SetCpuMathLibraryNumThreads(this->cpu_math_library_num_threads_); + } + + config.SwitchUseFeedFetchOps(false); + // true for multiple input + config.SwitchSpecifyInputNames(true); + + config.SwitchIrOptim(true); + + config.EnableMemoryOptim(); + config.DisableGlogInfo(); + + this->predictor_ = CreatePredictor(config); + } + + void FeatureExtracter::Run(cv::Mat &img, std::vector &out_data, + std::vector ×) { + cv::Mat resize_img; + std::vector time; + + auto preprocess_start = std::chrono::steady_clock::now(); + this->resize_op_.Run(img, resize_img, this->resize_short_, + this->resize_size_); + + this->normalize_op_.Run(&resize_img, this->mean_, this->std_, this->scale_); + std::vector input(1 * 3 * resize_img.rows * resize_img.cols, 0.0f); + this->permute_op_.Run(&resize_img, input.data()); + + auto input_names = this->predictor_->GetInputNames(); + auto input_t = this->predictor_->GetInputHandle(input_names[0]); + input_t->Reshape({1, 3, resize_img.rows, resize_img.cols}); + auto preprocess_end = std::chrono::steady_clock::now(); + + auto infer_start = std::chrono::steady_clock::now(); + input_t->CopyFromCpu(input.data()); + this->predictor_->Run(); + + auto output_names = this->predictor_->GetOutputNames(); + auto output_t = this->predictor_->GetOutputHandle(output_names[0]); + std::vector output_shape = output_t->shape(); + int out_num = std::accumulate(output_shape.begin(), output_shape.end(), 1, + std::multiplies()); + + out_data.resize(out_num); + output_t->CopyToCpu(out_data.data()); + auto infer_end = std::chrono::steady_clock::now(); + + auto postprocess_start = std::chrono::steady_clock::now(); + if (this->feature_norm) + FeatureNorm(out_data); + auto postprocess_end = std::chrono::steady_clock::now(); + + std::chrono::duration preprocess_diff = + preprocess_end - preprocess_start; + time.push_back(double(preprocess_diff.count()) * 1000); + std::chrono::duration inference_diff = infer_end - infer_start; + double inference_cost_time = double(inference_diff.count() * 1000); + time.push_back(inference_cost_time); + // std::chrono::duration postprocess_diff = + // postprocess_end - postprocess_start; + time.push_back(0); + + // std::cout << "result: " << std::endl; + // std::cout << "\tclass id: " << maxPosition << std::endl; + // std::cout << std::fixed << std::setprecision(10) + // << "\tscore: " << double(out_data[maxPosition]) << std::endl; + times[0] += time[0]; + times[1] += time[1]; + times[2] += time[2]; + } + + void FeatureExtracter::FeatureNorm(std::vector &featuer) { + float featuer_sqrt = std::sqrt(std::inner_product( + featuer.begin(), featuer.end(), featuer.begin(), 0.0f)); + for (int i = 0; i < featuer.size(); ++i) + featuer[i] /= featuer_sqrt; + } +} // namespace Feature diff --git a/src/PaddleClas/deploy/cpp_shitu/src/main.cpp b/src/PaddleClas/deploy/cpp_shitu/src/main.cpp new file mode 100644 index 0000000..be37d3a --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/main.cpp @@ -0,0 +1,342 @@ +// Copyright (c) 2021 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. + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace cv; + +DEFINE_string(config, +"", "Path of yaml file"); +DEFINE_string(c, +"", "Path of yaml file"); + +void DetPredictImage(const std::vector &batch_imgs, + const std::vector &all_img_paths, + const int batch_size, Detection::ObjectDetector *det, + std::vector &im_result, + std::vector &im_bbox_num, std::vector &det_t, + const bool visual_det = false, + const bool run_benchmark = false, + const std::string &output_dir = "output") { + int steps = ceil(float(all_img_paths.size()) / batch_size); + // printf("total images = %d, batch_size = %d, total steps = %d\n", + // all_img_paths.size(), batch_size, steps); + for (int idx = 0; idx < steps; idx++) { + int left_image_cnt = all_img_paths.size() - idx * batch_size; + if (left_image_cnt > batch_size) { + left_image_cnt = batch_size; + } + // for (int bs = 0; bs < left_image_cnt; bs++) { + // std::string image_file_path = all_img_paths.at(idx * batch_size+bs); + // cv::Mat im = cv::imread(image_file_path, 1); + // batch_imgs.insert(batch_imgs.end(), im); + // } + + // Store all detected result + std::vector result; + std::vector bbox_num; + std::vector det_times; + bool is_rbox = false; + if (run_benchmark) { + det->Predict(batch_imgs, 10, 10, &result, &bbox_num, &det_times); + } else { + det->Predict(batch_imgs, 0, 1, &result, &bbox_num, &det_times); + // get labels and colormap + auto labels = det->GetLabelList(); + auto colormap = Detection::GenerateColorMap(labels.size()); + + int item_start_idx = 0; + for (int i = 0; i < left_image_cnt; i++) { + cv::Mat im = batch_imgs[i]; + int detect_num = 0; + + for (int j = 0; j < bbox_num[i]; j++) { + Detection::ObjectResult item = result[item_start_idx + j]; + if (item.confidence < det->GetThreshold() || item.class_id == -1) { + continue; + } + detect_num += 1; + im_result.push_back(item); + if (visual_det) { + if (item.rect.size() > 6) { + is_rbox = true; + printf( + "class=%d confidence=%.4f rect=[%d %d %d %d %d %d %d %d]\n", + item.class_id, item.confidence, item.rect[0], item.rect[1], + item.rect[2], item.rect[3], item.rect[4], item.rect[5], + item.rect[6], item.rect[7]); + } else { + printf("class=%d confidence=%.4f rect=[%d %d %d %d]\n", + item.class_id, item.confidence, item.rect[0], item.rect[1], + item.rect[2], item.rect[3]); + } + } + } + im_bbox_num.push_back(detect_num); + item_start_idx = item_start_idx + bbox_num[i]; + + // Visualization result + if (visual_det) { + std::cout << all_img_paths.at(idx * batch_size + i) + << " The number of detected box: " << detect_num + << std::endl; + cv::Mat vis_img = Detection::VisualizeResult(im, im_result, labels, + colormap, is_rbox); + std::vector compression_params; + compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); + compression_params.push_back(95); + std::string output_path(output_dir); + if (output_dir.rfind(OS_PATH_SEP) != output_dir.size() - 1) { + output_path += OS_PATH_SEP; + } + std::string image_file_path = all_img_paths.at(idx * batch_size + i); + output_path += + image_file_path.substr(image_file_path.find_last_of('/') + 1); + cv::imwrite(output_path, vis_img, compression_params); + printf("Visualized output saved as %s\n", output_path.c_str()); + } + } + } + det_t[0] += det_times[0]; + det_t[1] += det_times[1]; + det_t[2] += det_times[2]; + } +} + +void PrintResult(std::string &img_path, + std::vector &det_result, + std::vector &indeices, VectorSearch &vector_search, + SearchResult &search_result) { + printf("%s:\n", img_path.c_str()); + for (int i = 0; i < indeices.size(); ++i) { + int t = indeices[i]; + printf("\tresult%d: bbox[%d, %d, %d, %d], score: %f, label: %s\n", i, + det_result[t].rect[0], det_result[t].rect[1], det_result[t].rect[2], + det_result[t].rect[3], det_result[t].confidence, + vector_search.GetLabel(search_result.I[search_result.return_k * t]) + .c_str()); + } +} + +int main(int argc, char **argv) { + google::ParseCommandLineFlags(&argc, &argv, true); + std::string yaml_path = ""; + if (FLAGS_config == "" && FLAGS_c == "") { + std::cerr << "[ERROR] usage: " << std::endl + << argv[0] << " -c $yaml_path" << std::endl + << "or:" << std::endl + << argv[0] << " -config $yaml_path" << std::endl; + exit(1); + } else if (FLAGS_config != "") { + yaml_path = FLAGS_config; + } else { + yaml_path = FLAGS_c; + } + + YamlConfig config(yaml_path); + config.PrintConfigInfo(); + + // initialize detector, rec_Model, vector_search + Feature::FeatureExtracter feature_extracter(config.config_file); + Detection::ObjectDetector detector(config.config_file); + VectorSearch searcher(config.config_file); + + // config + const int batch_size = config.config_file["Global"]["batch_size"].as(); + bool visual_det = false; + if (config.config_file["Global"]["visual_det"].IsDefined()) { + visual_det = config.config_file["Global"]["visual_det"].as(); + } + bool benchmark = false; + if (config.config_file["Global"]["benchmark"].IsDefined()) { + benchmark = config.config_file["Global"]["benchmark"].as(); + } + int max_det_results = 5; + if (config.config_file["Global"]["max_det_results"].IsDefined()) { + max_det_results = config.config_file["Global"]["max_det_results"].as(); + } + float rec_nms_thresold = 0.05; + if (config.config_file["Global"]["rec_nms_thresold"].IsDefined()) { + rec_nms_thresold = + config.config_file["Global"]["rec_nms_thresold"].as(); + } + + // load image_file_path + std::string path = + config.config_file["Global"]["infer_imgs"].as(); + std::vector img_files_list; + if (cv::utils::fs::isDirectory(path)) { + std::vector filenames; + cv::glob(path, filenames); + for (auto f : filenames) { + img_files_list.push_back(f); + } + } else { + img_files_list.push_back(path); + } + std::cout << "img_file_list length: " << img_files_list.size() << std::endl; + // for time log + std::vector cls_times = {0, 0, 0}; + std::vector det_times = {0, 0, 0}; + std::vector search_times = {0, 0, 0}; + int instance_num = 0; + // for read images + std::vector batch_imgs; + std::vector img_paths; + // for detection + std::vector det_result; + std::vector det_bbox_num; + // for vector search + std::vector features; + std::vector feature; + // for nms + std::vector indeices; + + int warmup_iter = img_files_list.size() > 5 ? 5 : img_files_list.size(); + if (benchmark) { + img_files_list.insert(img_files_list.begin(), img_files_list.begin(), + img_files_list.begin() + warmup_iter); + } + + for (int idx = 0; idx < img_files_list.size(); ++idx) { + std::string img_path = img_files_list[idx]; + cv::Mat srcimg = cv::imread(img_path, cv::IMREAD_COLOR); + if (!srcimg.data) { + std::cerr << "[ERROR] image read failed! image path: " << img_path + << "\n"; + exit(-1); + } + cv::cvtColor(srcimg, srcimg, cv::COLOR_BGR2RGB); + + batch_imgs.push_back(srcimg); + img_paths.push_back(img_path); + + // step1: get all detection results + DetPredictImage(batch_imgs, img_paths, batch_size, &detector, det_result, + det_bbox_num, det_times, visual_det, false); + + // select max_det_results bbox + if (det_result.size() > max_det_results) { + det_result.resize(max_det_results); + } + instance_num += det_result.size(); + + // step2: add the whole image for recognition to improve recall + Detection::ObjectResult result_whole_img = { + {0, 0, srcimg.cols - 1, srcimg.rows - 1}, 0, 1.0}; + det_result.push_back(result_whole_img); + det_bbox_num[0] = det_result.size() + 1; + + // step3: extract feature for all boxes in an inmage + SearchResult search_result; + for (int j = 0; j < det_result.size(); ++j) { + int w = det_result[j].rect[2] - det_result[j].rect[0]; + int h = det_result[j].rect[3] - det_result[j].rect[1]; + cv::Rect rect(det_result[j].rect[0], det_result[j].rect[1], w, h); + cv::Mat crop_img = srcimg(rect); + feature_extracter.Run(crop_img, feature, cls_times); + features.insert(features.end(), feature.begin(), feature.end()); + } + + // step4: get search result + auto search_start = std::chrono::steady_clock::now(); + search_result = searcher.Search(features.data(), det_result.size()); + auto search_end = std::chrono::steady_clock::now(); + + // nms for search result + for (int i = 0; i < det_result.size(); ++i) { + det_result[i].confidence = search_result.D[search_result.return_k * i]; + } + NMSBoxes(det_result, searcher.GetThreshold(), rec_nms_thresold, indeices); + auto nms_end = std::chrono::steady_clock::now(); + std::chrono::duration search_diff = search_end - search_start; + search_times[1] += double(search_diff.count() * 1000); + + std::chrono::duration nms_diff = nms_end - search_end; + search_times[2] += double(nms_diff.count() * 1000); + + // print result + if (not benchmark or (benchmark and idx >= warmup_iter)) + PrintResult(img_path, det_result, indeices, searcher, search_result); + + // for postprocess + batch_imgs.clear(); + img_paths.clear(); + det_bbox_num.clear(); + det_result.clear(); + feature.clear(); + features.clear(); + indeices.clear(); + if (benchmark and warmup_iter == idx + 1) { + det_times = {0, 0, 0}; + cls_times = {0, 0, 0}; + search_times = {0, 0, 0}; + instance_num = 0; + } + } + + if (benchmark) { + std::string presion = "fp32"; + if (config.config_file["Global"]["use_fp16"].IsDefined() and + config.config_file["Global"]["use_fp16"].as()) + presion = "fp16"; + bool use_gpu = config.config_file["Global"]["use_gpu"].as(); + bool use_tensorrt = config.config_file["Global"]["use_tensorrt"].as(); + bool enable_mkldnn = + config.config_file["Global"]["enable_mkldnn"].as(); + int cpu_num_threads = + config.config_file["Global"]["cpu_num_threads"].as(); + int batch_size = config.config_file["Global"]["batch_size"].as(); + std::vector shape = + config.config_file["Global"]["image_shape"].as < std::vector < int >> (); + std::string det_shape = std::to_string(shape[0]); + for (int i = 1; i < shape.size(); ++i) + det_shape = det_shape + ", " + std::to_string(shape[i]); + + AutoLogger autolog_det("Det", use_gpu, use_tensorrt, enable_mkldnn, + cpu_num_threads, batch_size, det_shape, presion, + det_times, img_files_list.size() - warmup_iter); + autolog_det.report(); + AutoLogger autolog_rec("Rec", use_gpu, use_tensorrt, enable_mkldnn, + cpu_num_threads, batch_size, "3, 224, 224", presion, + cls_times, instance_num); + autolog_rec.report(); + AutoLogger autolog_search("Search", false, use_tensorrt, enable_mkldnn, + cpu_num_threads, batch_size, "dynamic", presion, + search_times, instance_num); + autolog_search.report(); + } + return 0; +} diff --git a/src/PaddleClas/deploy/cpp_shitu/src/object_detector.cpp b/src/PaddleClas/deploy/cpp_shitu/src/object_detector.cpp new file mode 100644 index 0000000..03b02b9 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/object_detector.cpp @@ -0,0 +1,365 @@ +// 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. +#include +// for setprecision +#include "include/object_detector.h" +#include +#include + +using namespace paddle_infer; + +namespace Detection { + +// Load Model and create model predictor + void ObjectDetector::LoadModel(const std::string &model_dir, + const int batch_size, + const std::string &run_mode) { + paddle_infer::Config config; + std::string prog_file = model_dir + OS_PATH_SEP + "inference.pdmodel"; + std::string params_file = model_dir + OS_PATH_SEP + "inference.pdiparams"; + config.SetModel(prog_file, params_file); + if (this->use_gpu_) { + config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); + config.SwitchIrOptim(this->ir_optim_); + // // use tensorrt + // if (run_mode != "fluid") { + // auto precision = paddle_infer::Config::Precision::kFloat32; + // if (run_mode == "trt_fp32") { + // precision = paddle_infer::Config::Precision::kFloat32; + // } + // else if (run_mode == "trt_fp16") { + // precision = paddle_infer::Config::Precision::kHalf; + // } + // else if (run_mode == "trt_int8") { + // precision = paddle_infer::Config::Precision::kInt8; + // } else { + // printf("run_mode should be 'fluid', 'trt_fp32', 'trt_fp16' or + // 'trt_int8'"); + // } + // set tensorrt + + if (this->use_tensorrt_) { + config.EnableTensorRtEngine( + 1 << 30, batch_size, this->min_subgraph_size_, + this->use_fp16_ ? paddle_infer::Config::Precision::kHalf + : paddle_infer::Config::Precision::kFloat32, + false, this->trt_calib_mode_); + // set use dynamic shape + if (this->use_dynamic_shape_) { + // set DynamicShsape for image tensor + const std::vector min_input_shape = {1, 3, this->trt_min_shape_, + this->trt_min_shape_}; + const std::vector max_input_shape = {1, 3, this->trt_max_shape_, + this->trt_max_shape_}; + const std::vector opt_input_shape = {1, 3, this->trt_opt_shape_, + this->trt_opt_shape_}; + const std::map > map_min_input_shape = { + {"image", min_input_shape}}; + const std::map > map_max_input_shape = { + {"image", max_input_shape}}; + const std::map > map_opt_input_shape = { + {"image", opt_input_shape}}; + + config.SetTRTDynamicShapeInfo(map_min_input_shape, map_max_input_shape, + map_opt_input_shape); + std::cout << "TensorRT dynamic shape enabled" << std::endl; + } + } + + // } else if (this->device_ == "XPU"){ + // config.EnableXpu(10*1024*1024); + } else { + config.DisableGpu(); + if (this->use_mkldnn_) { + config.EnableMKLDNN(); + // cache 10 different shapes for mkldnn to avoid memory leak + config.SetMkldnnCacheCapacity(10); + } + config.SetCpuMathLibraryNumThreads(this->cpu_math_library_num_threads_); + } + config.SwitchUseFeedFetchOps(false); + config.SwitchIrOptim(this->ir_optim_); + config.DisableGlogInfo(); + // Memory optimization + config.EnableMemoryOptim(); + predictor_ = std::move(CreatePredictor(config)); + } + +// Visualiztion MaskDetector results + cv::Mat VisualizeResult(const cv::Mat &img, + const std::vector &results, + const std::vector &lables, + const std::vector &colormap, + const bool is_rbox = false) { + cv::Mat vis_img = img.clone(); + for (int i = 0; i < results.size(); ++i) { + // Configure color and text size + std::ostringstream oss; + oss << std::setiosflags(std::ios::fixed) << std::setprecision(4); + oss << lables[results[i].class_id] << " "; + oss << results[i].confidence; + std::string text = oss.str(); + int c1 = colormap[3 * results[i].class_id + 0]; + int c2 = colormap[3 * results[i].class_id + 1]; + int c3 = colormap[3 * results[i].class_id + 2]; + cv::Scalar roi_color = cv::Scalar(c1, c2, c3); + int font_face = cv::FONT_HERSHEY_COMPLEX_SMALL; + double font_scale = 0.5f; + float thickness = 0.5; + cv::Size text_size = + cv::getTextSize(text, font_face, font_scale, thickness, nullptr); + cv::Point origin; + + if (is_rbox) { + // Draw object, text, and background + for (int k = 0; k < 4; k++) { + cv::Point pt1 = cv::Point(results[i].rect[(k * 2) % 8], + results[i].rect[(k * 2 + 1) % 8]); + cv::Point pt2 = cv::Point(results[i].rect[(k * 2 + 2) % 8], + results[i].rect[(k * 2 + 3) % 8]); + cv::line(vis_img, pt1, pt2, roi_color, 2); + } + } else { + int w = results[i].rect[2] - results[i].rect[0]; + int h = results[i].rect[3] - results[i].rect[1]; + cv::Rect roi = cv::Rect(results[i].rect[0], results[i].rect[1], w, h); + // Draw roi object, text, and background + cv::rectangle(vis_img, roi, roi_color, 2); + } + + origin.x = results[i].rect[0]; + origin.y = results[i].rect[1]; + + // Configure text background + cv::Rect text_back = + cv::Rect(results[i].rect[0], results[i].rect[1] - text_size.height, + text_size.width, text_size.height); + // Draw text, and background + cv::rectangle(vis_img, text_back, roi_color, -1); + cv::putText(vis_img, text, origin, font_face, font_scale, + cv::Scalar(255, 255, 255), thickness); + } + return vis_img; + } + + void ObjectDetector::Preprocess(const cv::Mat &ori_im) { + // Clone the image : keep the original mat for postprocess + cv::Mat im = ori_im.clone(); + cv::cvtColor(im, im, cv::COLOR_BGR2RGB); + preprocessor_.Run(&im, &inputs_); + } + + void ObjectDetector::Postprocess(const std::vector mats, + std::vector *result, + std::vector bbox_num, + bool is_rbox = false) { + result->clear(); + int start_idx = 0; + for (int im_id = 0; im_id < mats.size(); im_id++) { + cv::Mat raw_mat = mats[im_id]; + int rh = 1; + int rw = 1; + // if (config_.arch_ == "Face") { + // rh = raw_mat.rows; + // rw = raw_mat.cols; + // } + for (int j = start_idx; j < start_idx + bbox_num[im_id]; j++) { + if (is_rbox) { + // Class id + int class_id = static_cast(round(output_data_[0 + j * 10])); + // Confidence score + float score = output_data_[1 + j * 10]; + int x1 = (output_data_[2 + j * 10] * rw); + int y1 = (output_data_[3 + j * 10] * rh); + int x2 = (output_data_[4 + j * 10] * rw); + int y2 = (output_data_[5 + j * 10] * rh); + int x3 = (output_data_[6 + j * 10] * rw); + int y3 = (output_data_[7 + j * 10] * rh); + int x4 = (output_data_[8 + j * 10] * rw); + int y4 = (output_data_[9 + j * 10] * rh); + + ObjectResult result_item; + result_item.rect = {x1, y1, x2, y2, x3, y3, x4, y4}; + result_item.class_id = class_id; + result_item.confidence = score; + result->push_back(result_item); + } else { + // Class id + int class_id = static_cast(round(output_data_[0 + j * 6])); + // Confidence score + float score = output_data_[1 + j * 6]; + int xmin = (output_data_[2 + j * 6] * rw); + int ymin = (output_data_[3 + j * 6] * rh); + int xmax = (output_data_[4 + j * 6] * rw); + int ymax = (output_data_[5 + j * 6] * rh); + int wd = xmax - xmin; + int hd = ymax - ymin; + + ObjectResult result_item; + result_item.rect = {xmin, ymin, xmax, ymax}; + result_item.class_id = class_id; + result_item.confidence = score; + result->push_back(result_item); + } + } + start_idx += bbox_num[im_id]; + } + } + + void ObjectDetector::Predict(const std::vector imgs, const int warmup, + const int repeats, + std::vector *result, + std::vector *bbox_num, + std::vector *times) { + auto preprocess_start = std::chrono::steady_clock::now(); + int batch_size = imgs.size(); + + // in_data_batch + std::vector in_data_all; + std::vector im_shape_all(batch_size * 2); + std::vector scale_factor_all(batch_size * 2); + + // Preprocess image + for (int bs_idx = 0; bs_idx < batch_size; bs_idx++) { + cv::Mat im = imgs.at(bs_idx); + Preprocess(im); + im_shape_all[bs_idx * 2] = inputs_.im_shape_[0]; + im_shape_all[bs_idx * 2 + 1] = inputs_.im_shape_[1]; + + scale_factor_all[bs_idx * 2] = inputs_.scale_factor_[0]; + scale_factor_all[bs_idx * 2 + 1] = inputs_.scale_factor_[1]; + + // TODO: reduce cost time + in_data_all.insert(in_data_all.end(), inputs_.im_data_.begin(), + inputs_.im_data_.end()); + } + + // Prepare input tensor + auto input_names = predictor_->GetInputNames(); + for (const auto &tensor_name : input_names) { + auto in_tensor = predictor_->GetInputHandle(tensor_name); + if (tensor_name == "image") { + int rh = inputs_.in_net_shape_[0]; + int rw = inputs_.in_net_shape_[1]; + in_tensor->Reshape({batch_size, 3, rh, rw}); + in_tensor->CopyFromCpu(in_data_all.data()); + } else if (tensor_name == "im_shape") { + in_tensor->Reshape({batch_size, 2}); + in_tensor->CopyFromCpu(im_shape_all.data()); + } else if (tensor_name == "scale_factor") { + in_tensor->Reshape({batch_size, 2}); + in_tensor->CopyFromCpu(scale_factor_all.data()); + } + } + + auto preprocess_end = std::chrono::steady_clock::now(); + // Run predictor + // warmup + for (int i = 0; i < warmup; i++) { + predictor_->Run(); + // Get output tensor + auto output_names = predictor_->GetOutputNames(); + auto out_tensor = predictor_->GetOutputHandle(output_names[0]); + std::vector output_shape = out_tensor->shape(); + auto out_bbox_num = predictor_->GetOutputHandle(output_names[1]); + std::vector out_bbox_num_shape = out_bbox_num->shape(); + // Calculate output length + int output_size = 1; + for (int j = 0; j < output_shape.size(); ++j) { + output_size *= output_shape[j]; + } + + if (output_size < 6) { + std::cerr << "[WARNING] No object detected." << std::endl; + } + output_data_.resize(output_size); + out_tensor->CopyToCpu(output_data_.data()); + + int out_bbox_num_size = 1; + for (int j = 0; j < out_bbox_num_shape.size(); ++j) { + out_bbox_num_size *= out_bbox_num_shape[j]; + } + out_bbox_num_data_.resize(out_bbox_num_size); + out_bbox_num->CopyToCpu(out_bbox_num_data_.data()); + } + + bool is_rbox = false; + auto inference_start = std::chrono::steady_clock::now(); + for (int i = 0; i < repeats; i++) { + predictor_->Run(); + // Get output tensor + auto output_names = predictor_->GetOutputNames(); + auto out_tensor = predictor_->GetOutputHandle(output_names[0]); + std::vector output_shape = out_tensor->shape(); + auto out_bbox_num = predictor_->GetOutputHandle(output_names[1]); + std::vector out_bbox_num_shape = out_bbox_num->shape(); + // Calculate output length + int output_size = 1; + for (int j = 0; j < output_shape.size(); ++j) { + output_size *= output_shape[j]; + } + is_rbox = output_shape[output_shape.size() - 1] % 10 == 0; + + if (output_size < 6) { + std::cerr << "[WARNING] No object detected." << std::endl; + } + output_data_.resize(output_size); + out_tensor->CopyToCpu(output_data_.data()); + + int out_bbox_num_size = 1; + for (int j = 0; j < out_bbox_num_shape.size(); ++j) { + out_bbox_num_size *= out_bbox_num_shape[j]; + } + out_bbox_num_data_.resize(out_bbox_num_size); + out_bbox_num->CopyToCpu(out_bbox_num_data_.data()); + } + auto inference_end = std::chrono::steady_clock::now(); + auto postprocess_start = std::chrono::steady_clock::now(); + // Postprocessing result + result->clear(); + Postprocess(imgs, result, out_bbox_num_data_, is_rbox); + bbox_num->clear(); + for (int k = 0; k < out_bbox_num_data_.size(); k++) { + int tmp = out_bbox_num_data_[k]; + bbox_num->push_back(tmp); + } + auto postprocess_end = std::chrono::steady_clock::now(); + + std::chrono::duration preprocess_diff = + preprocess_end - preprocess_start; + times->push_back(double(preprocess_diff.count() * 1000)); + std::chrono::duration inference_diff = inference_end - inference_start; + times->push_back(double(inference_diff.count() / repeats * 1000)); + std::chrono::duration postprocess_diff = + postprocess_end - postprocess_start; + times->push_back(double(postprocess_diff.count() * 1000)); + } + + std::vector GenerateColorMap(int num_class) { + auto colormap = std::vector(3 * num_class, 0); + for (int i = 0; i < num_class; ++i) { + int j = 0; + int lab = i; + while (lab) { + colormap[i * 3] |= (((lab >> 0) & 1) << (7 - j)); + colormap[i * 3 + 1] |= (((lab >> 1) & 1) << (7 - j)); + colormap[i * 3 + 2] |= (((lab >> 2) & 1) << (7 - j)); + ++j; + lab >>= 3; + } + } + return colormap; + } + +} // namespace Detection diff --git a/src/PaddleClas/deploy/cpp_shitu/src/preprocess_op.cpp b/src/PaddleClas/deploy/cpp_shitu/src/preprocess_op.cpp new file mode 100644 index 0000000..6bf1ec9 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/preprocess_op.cpp @@ -0,0 +1,91 @@ +// 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. + +#include "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" +#include "paddle_api.h" +#include "paddle_inference_api.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace Feature { + + void Permute::Run(const cv::Mat *im, float *data) { + int rh = im->rows; + int rw = im->cols; + int rc = im->channels(); + for (int i = 0; i < rc; ++i) { + cv::extractChannel(*im, cv::Mat(rh, rw, CV_32FC1, data + i * rh * rw), i); + } + } + + void Normalize::Run(cv::Mat *im, const std::vector &mean, + const std::vector &std, float scale) { + (*im).convertTo(*im, CV_32FC3, scale); + for (int h = 0; h < im->rows; h++) { + for (int w = 0; w < im->cols; w++) { + im->at(h, w)[0] = + (im->at(h, w)[0] - mean[0]) / std[0]; + im->at(h, w)[1] = + (im->at(h, w)[1] - mean[1]) / std[1]; + im->at(h, w)[2] = + (im->at(h, w)[2] - mean[2]) / std[2]; + } + } + } + + void CenterCropImg::Run(cv::Mat &img, const int crop_size) { + int resize_w = img.cols; + int resize_h = img.rows; + int w_start = int((resize_w - crop_size) / 2); + int h_start = int((resize_h - crop_size) / 2); + cv::Rect rect(w_start, h_start, crop_size, crop_size); + img = img(rect); + } + + void ResizeImg::Run(const cv::Mat &img, cv::Mat &resize_img, + int resize_short_size, int size) { + int resize_h = 0; + int resize_w = 0; + if (size > 0) { + resize_h = size; + resize_w = size; + } else { + int w = img.cols; + int h = img.rows; + + float ratio = 1.f; + if (h < w) { + ratio = float(resize_short_size) / float(h); + } else { + ratio = float(resize_short_size) / float(w); + } + resize_h = round(float(h) * ratio); + resize_w = round(float(w) * ratio); + } + cv::resize(img, resize_img, cv::Size(resize_w, resize_h)); + } + +} // namespace Feature diff --git a/src/PaddleClas/deploy/cpp_shitu/src/preprocess_op_det.cpp b/src/PaddleClas/deploy/cpp_shitu/src/preprocess_op_det.cpp new file mode 100644 index 0000000..e32b03a --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/preprocess_op_det.cpp @@ -0,0 +1,130 @@ +// 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. + +#include +#include + +#include "include/preprocess_op_det.h" + +namespace Detection { + + void InitInfo::Run(cv::Mat *im, ImageBlob *data) { + data->im_shape_ = {static_cast(im->rows), + static_cast(im->cols)}; + data->scale_factor_ = {1., 1.}; + data->in_net_shape_ = {static_cast(im->rows), + static_cast(im->cols)}; + } + + void NormalizeImage::Run(cv::Mat *im, ImageBlob *data) { + double e = 1.0; + if (is_scale_) { + e /= 255.0; + } + (*im).convertTo(*im, CV_32FC3, e); + for (int h = 0; h < im->rows; h++) { + for (int w = 0; w < im->cols; w++) { + im->at(h, w)[0] = + (im->at(h, w)[0] - mean_[0]) / scale_[0]; + im->at(h, w)[1] = + (im->at(h, w)[1] - mean_[1]) / scale_[1]; + im->at(h, w)[2] = + (im->at(h, w)[2] - mean_[2]) / scale_[2]; + } + } + } + + void Permute::Run(cv::Mat *im, ImageBlob *data) { + int rh = im->rows; + int rw = im->cols; + int rc = im->channels(); + (data->im_data_).resize(rc * rh * rw); + float *base = (data->im_data_).data(); + for (int i = 0; i < rc; ++i) { + cv::extractChannel(*im, cv::Mat(rh, rw, CV_32FC1, base + i * rh * rw), i); + } + } + + void Resize::Run(cv::Mat *im, ImageBlob *data) { + auto resize_scale = GenerateScale(*im); + data->im_shape_ = {static_cast(im->cols * resize_scale.first), + static_cast(im->rows * resize_scale.second)}; + data->in_net_shape_ = {static_cast(im->cols * resize_scale.first), + static_cast(im->rows * resize_scale.second)}; + cv::resize(*im, *im, cv::Size(), resize_scale.first, resize_scale.second, + interp_); + data->im_shape_ = { + static_cast(im->rows), static_cast(im->cols), + }; + data->scale_factor_ = { + resize_scale.second, resize_scale.first, + }; + } + + std::pair Resize::GenerateScale(const cv::Mat &im) { + std::pair resize_scale; + int origin_w = im.cols; + int origin_h = im.rows; + + if (keep_ratio_) { + int im_size_max = std::max(origin_w, origin_h); + int im_size_min = std::min(origin_w, origin_h); + int target_size_max = + *std::max_element(target_size_.begin(), target_size_.end()); + int target_size_min = + *std::min_element(target_size_.begin(), target_size_.end()); + double scale_min = + static_cast(target_size_min) / static_cast(im_size_min); + double scale_max = + static_cast(target_size_max) / static_cast(im_size_max); + double scale_ratio = std::min(scale_min, scale_max); + resize_scale = {scale_ratio, scale_ratio}; + } else { + resize_scale.first = + static_cast(target_size_[1]) / static_cast(origin_w); + resize_scale.second = + static_cast(target_size_[0]) / static_cast(origin_h); + } + return resize_scale; + } + + void PadStride::Run(cv::Mat *im, ImageBlob *data) { + if (stride_ <= 0) { + return; + } + int rc = im->channels(); + int rh = im->rows; + int rw = im->cols; + int nh = (rh / stride_) * stride_ + (rh % stride_ != 0) * stride_; + int nw = (rw / stride_) * stride_ + (rw % stride_ != 0) * stride_; + cv::copyMakeBorder(*im, *im, 0, nh - rh, 0, nw - rw, cv::BORDER_CONSTANT, + cv::Scalar(0)); + data->in_net_shape_ = { + static_cast(im->rows), static_cast(im->cols), + }; + } + +// Preprocessor op running order + const std::vector Preprocessor::RUN_ORDER = { + "InitInfo", "Resize", "NormalizeImage", "PadStride", "Permute"}; + + void Preprocessor::Run(cv::Mat *im, ImageBlob *data) { + for (const auto &name : RUN_ORDER) { + if (ops_.find(name) != ops_.end()) { + ops_[name]->Run(im, data); + } + } + } + +} // namespace Detection diff --git a/src/PaddleClas/deploy/cpp_shitu/src/vector_search.cpp b/src/PaddleClas/deploy/cpp_shitu/src/vector_search.cpp new file mode 100644 index 0000000..85c487a --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/vector_search.cpp @@ -0,0 +1,62 @@ +// 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. +#include "include/vector_search.h" +#include +#include +#include +#include +#include +#include + +void VectorSearch::LoadIndexFile() { + std::string file_path = this->index_dir + OS_PATH_SEP + "vector.index"; + const char *fname = file_path.c_str(); + this->index = faiss::read_index(fname, 0); +} + +void VectorSearch::LoadIdMap() { + std::string file_path = this->index_dir + OS_PATH_SEP + "id_map.txt"; + std::ifstream in(file_path); + std::string line; + std::vector m_vec; + if (in) { + while (getline(in, line)) { + std::regex ws_re("\\s+"); + std::vector v( + std::sregex_token_iterator(line.begin(), line.end(), ws_re, -1), + std::sregex_token_iterator()); + if (v.size() != 2) { + std::cout << "The number of element for each line in : " << file_path + << "must be 2, exit the program..." << std::endl; + exit(1); + } else + this->id_map.insert(std::pair( + std::stol(v[0], nullptr, 10), v[1])); + } + } +} + +const SearchResult &VectorSearch::Search(float *feature, int query_number) { + this->D.resize(this->return_k * query_number); + this->I.resize(this->return_k * query_number); + this->index->search(query_number, feature, return_k, D.data(), I.data()); + this->sr.return_k = this->return_k; + this->sr.D = this->D; + this->sr.I = this->I; + return this->sr; +} + +const std::string &VectorSearch::GetLabel(faiss::Index::idx_t ind) { + return this->id_map.at(ind); +} diff --git a/src/PaddleClas/deploy/cpp_shitu/src/yaml_config.cpp b/src/PaddleClas/deploy/cpp_shitu/src/yaml_config.cpp new file mode 100644 index 0000000..b20fcde --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/src/yaml_config.cpp @@ -0,0 +1,78 @@ +// 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. + +#include +#include +#include + +#include + + +std::vector YamlConfig::ReadDict(const std::string &path) { + std::ifstream in(path); + std::string line; + std::vector m_vec; + if (in) { + while (getline(in, line)) { + m_vec.push_back(line); + } + } else { + std::cout << "no such label file: " << path << ", exit the program..." + << std::endl; + exit(1); + } + return m_vec; +} + +std::map YamlConfig::ReadIndexId(const std::string &path) { + std::ifstream in(path); + std::string line; + std::map m_vec; + if (in) { + while (getline(in, line)) { + std::regex ws_re("\\s+"); + std::vector v( + std::sregex_token_iterator(line.begin(), line.end(), ws_re, -1), + std::sregex_token_iterator()); + if (v.size() != 3) { + std::cout << "The number of element for each line in : " << path + << "must be 3, exit the program..." << std::endl; + exit(1); + } else + m_vec.insert(std::pair(stoi(v[0]), v[2])); + } + } + return m_vec; +} + +YAML::Node YamlConfig::ReadYamlConfig(const std::string &path) { + YAML::Node config; + try { + config = YAML::LoadFile(path); + } catch (YAML::BadFile &e) { + std::cout << "Something wrong in yaml file, please check yaml file" + << std::endl; + exit(1); + } + return config; +} + +void YamlConfig::PrintConfigInfo() { + std::cout << this->config_file << std::endl; + // for (YAML::const_iterator + // it=config_file.begin();it!=config_file.end();++it) + // { + // std::cout << it->as() << "\n"; + // } +} diff --git a/src/PaddleClas/deploy/cpp_shitu/tools/build.sh b/src/PaddleClas/deploy/cpp_shitu/tools/build.sh new file mode 100644 index 0000000..a9e2f92 --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/tools/build.sh @@ -0,0 +1,25 @@ +OPENCV_DIR=${opencv_install_dir} +LIB_DIR=${paddle_inference_dir} +CUDA_LIB_DIR=/usr/local/cuda/lib64 +CUDNN_LIB_DIR=/usr/lib/x86_64-linux-gnu/ +FAISS_DIR=${faiss_install_dir} +FAISS_WITH_MKL=OFF + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DUSE_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DFAISS_DIR=${FAISS_DIR} \ + -DFAISS_WITH_MKL=${FAISS_WITH_MKL} + +make -j +cd .. diff --git a/src/PaddleClas/deploy/cpp_shitu/tools/transform_id_map.py b/src/PaddleClas/deploy/cpp_shitu/tools/transform_id_map.py new file mode 100644 index 0000000..3ad6b6f --- /dev/null +++ b/src/PaddleClas/deploy/cpp_shitu/tools/transform_id_map.py @@ -0,0 +1,39 @@ +import argparse +import os +import pickle + +import yaml + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('-c', '--config', type=str, required=True) + args = parser.parse_args() + return args + + +def main(): + args = parse_args() + with open(args.config) as fd: + config = yaml.load(fd.read(), yaml.FullLoader) + index_dir = "" + try: + index_dir = config["IndexProcess"]["index_dir"] + except Exception as e: + print("The IndexProcess.index_dir in config_file dose not exist") + exit(1) + id_map_path = os.path.join(index_dir, "id_map.pkl") + assert os.path.exists( + id_map_path), "The id_map file dose not exist: {}".format(id_map_path) + + with open(id_map_path, "rb") as fd: + ids = pickle.load(fd) + with open(os.path.join(index_dir, "id_map.txt"), "w") as fd: + for k, v in ids.items(): + v = v.split("\t")[1] + fd.write(str(k) + " " + v + "\n") + print('Transform id_map sucess') + + +if __name__ == "__main__": + main() diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0.tar b/src/PaddleClas/deploy/drink_dataset_v1.0.tar new file mode 100644 index 0000000..76161a9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0.tar differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/0.jpg new file mode 100644 index 0000000..26879a8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/1.jpg new file mode 100644 index 0000000..71cadc9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/2.jpg new file mode 100644 index 0000000..72fc402 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/3.jpg new file mode 100644 index 0000000..434afbf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/0/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/0.jpg new file mode 100644 index 0000000..83c9d5a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/1.jpg new file mode 100644 index 0000000..0770655 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/2.jpg new file mode 100644 index 0000000..e340b37 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/3.jpg new file mode 100644 index 0000000..225daa1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/4.jpg new file mode 100644 index 0000000..865174b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/1/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/0.jpg new file mode 100644 index 0000000..03beade Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/1.jpg new file mode 100644 index 0000000..c3e76bd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/2.jpg new file mode 100644 index 0000000..b79fde0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/3.jpg new file mode 100644 index 0000000..4842864 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/4.jpg new file mode 100644 index 0000000..67d9119 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/5.jpg new file mode 100644 index 0000000..c87e332 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/10/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/0.jpg new file mode 100644 index 0000000..1fa8b64 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/1.jpg new file mode 100644 index 0000000..b5ffc34 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/2.jpg new file mode 100644 index 0000000..ae45e35 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/3.jpg new file mode 100644 index 0000000..696ebfa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/4.jpg new file mode 100644 index 0000000..10e7de5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/5.jpg new file mode 100644 index 0000000..5edd698 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/100/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/0.jpg new file mode 100644 index 0000000..6ccaa33 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/1.jpg new file mode 100644 index 0000000..bffbadf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/2.jpg new file mode 100644 index 0000000..7a7cdef Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/3.jpg new file mode 100644 index 0000000..2d33651 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/4.jpg new file mode 100644 index 0000000..e028462 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/5.jpg new file mode 100644 index 0000000..e9e7a8b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/6.jpg new file mode 100644 index 0000000..d841be6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/7.jpg new file mode 100644 index 0000000..aded1d0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/101/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/0.jpg new file mode 100644 index 0000000..163fd23 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/1.jpg new file mode 100644 index 0000000..bc01ae6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/2.jpg new file mode 100644 index 0000000..f79341e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/3.jpg new file mode 100644 index 0000000..275fb56 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/4.jpg new file mode 100644 index 0000000..288283b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/102/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/0.jpg new file mode 100644 index 0000000..dab0557 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/1.jpg new file mode 100644 index 0000000..e69caab Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/2.jpg new file mode 100644 index 0000000..3402c78 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/3.jpg new file mode 100644 index 0000000..58d751b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/4.jpg new file mode 100644 index 0000000..4fc7da2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/5.jpg new file mode 100644 index 0000000..7ba118e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/6.jpg new file mode 100644 index 0000000..4cc8fa9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/7.jpg new file mode 100644 index 0000000..a2891fe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/103/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/0.jpg new file mode 100644 index 0000000..d2fd440 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/1.jpg new file mode 100644 index 0000000..e837a28 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/2.jpg new file mode 100644 index 0000000..a6a2cf8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/3.jpg new file mode 100644 index 0000000..05b01aa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/4.jpg new file mode 100644 index 0000000..ab281ca Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/5.jpg new file mode 100644 index 0000000..406df3d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/6.jpg new file mode 100644 index 0000000..0034728 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/104/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/0.jpg new file mode 100644 index 0000000..4257a1e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/1.jpg new file mode 100644 index 0000000..997daad Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/2.jpg new file mode 100644 index 0000000..61e4b2e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/3.jpg new file mode 100644 index 0000000..1b50ce6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/4.jpg new file mode 100644 index 0000000..d23a113 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/5.jpg new file mode 100644 index 0000000..2abb54a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/6.jpg new file mode 100644 index 0000000..6c04001 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/105/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/0.jpg new file mode 100644 index 0000000..860e666 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/1.jpg new file mode 100644 index 0000000..5b22b58 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/2.jpg new file mode 100644 index 0000000..8608236 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/3.jpg new file mode 100644 index 0000000..3307200 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/4.jpg new file mode 100644 index 0000000..a4bcd51 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/106/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/0.jpg new file mode 100644 index 0000000..0ac2757 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/1.jpg new file mode 100644 index 0000000..4a41f15 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/2.jpg new file mode 100644 index 0000000..7164130 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/3.jpg new file mode 100644 index 0000000..502cb55 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/4.jpg new file mode 100644 index 0000000..61f490c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/5.jpg new file mode 100644 index 0000000..58cb5c0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/107/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/0.jpg new file mode 100644 index 0000000..bbd00a6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/1.jpg new file mode 100644 index 0000000..7872d3b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/2.jpg new file mode 100644 index 0000000..269fef6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/3.jpg new file mode 100644 index 0000000..b029295 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/4.jpg new file mode 100644 index 0000000..1437133 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/108/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/0.jpg new file mode 100644 index 0000000..838a2e1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/1.jpg new file mode 100644 index 0000000..079b42e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/2.jpg new file mode 100644 index 0000000..9e8de16 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/3.jpg new file mode 100644 index 0000000..aefbe4d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/4.jpg new file mode 100644 index 0000000..2aa63c2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/5.jpg new file mode 100644 index 0000000..23ff9eb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/6.jpg new file mode 100644 index 0000000..69a97d7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/7.jpg new file mode 100644 index 0000000..c1d78c4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/109/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/0.jpg new file mode 100644 index 0000000..6791a07 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/1.jpg new file mode 100644 index 0000000..05f9bc4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/2.jpg new file mode 100644 index 0000000..78855e1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/3.jpg new file mode 100644 index 0000000..fb06fc8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/4.jpg new file mode 100644 index 0000000..8445180 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/5.jpg new file mode 100644 index 0000000..f37c2d2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/11/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/0.jpg new file mode 100644 index 0000000..051fbde Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/1.jpg new file mode 100644 index 0000000..d23e380 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/2.jpg new file mode 100644 index 0000000..b1fd349 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/3.jpg new file mode 100644 index 0000000..905a924 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/4.jpg new file mode 100644 index 0000000..9858a8f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/5.jpg new file mode 100644 index 0000000..9519af7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/6.jpg new file mode 100644 index 0000000..1d66e93 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/7.jpg new file mode 100644 index 0000000..b519e29 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/110/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._8.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._8.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._8.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._9.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._9.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/._9.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/0.jpg new file mode 100644 index 0000000..751dfa3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/1.jpg new file mode 100644 index 0000000..fbecdc2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/2.jpg new file mode 100644 index 0000000..9e0f507 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/3.jpg new file mode 100644 index 0000000..0c4c05b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/4.jpg new file mode 100644 index 0000000..8cce843 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/5.jpg new file mode 100644 index 0000000..2aa09ad Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/6.jpg new file mode 100644 index 0000000..31c5af9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/7.jpg new file mode 100644 index 0000000..fac3c65 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/8.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/8.jpg new file mode 100644 index 0000000..0f72e3f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/8.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/9.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/9.jpg new file mode 100644 index 0000000..c51f36a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/111/9.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/0.jpg new file mode 100644 index 0000000..128a542 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/1.jpg new file mode 100644 index 0000000..1d18010 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/2.jpg new file mode 100644 index 0000000..a97d89b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/3.jpg new file mode 100644 index 0000000..fb52eb5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/4.jpg new file mode 100644 index 0000000..9d31ecc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/5.jpg new file mode 100644 index 0000000..a4d4b73 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/6.jpg new file mode 100644 index 0000000..2ff80b8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/112/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/0.jpg new file mode 100644 index 0000000..7a96212 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/1.jpg new file mode 100644 index 0000000..b7ccc97 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/2.jpg new file mode 100644 index 0000000..d6dc81e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/3.jpg new file mode 100644 index 0000000..133080a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/4.jpg new file mode 100644 index 0000000..173b2e2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/5.jpg new file mode 100644 index 0000000..1772060 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/113/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/0.jpg new file mode 100644 index 0000000..a0b5e24 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/1.jpg new file mode 100644 index 0000000..47ba147 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/2.jpg new file mode 100644 index 0000000..8236bf9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/3.jpg new file mode 100644 index 0000000..76befd5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/4.jpg new file mode 100644 index 0000000..99880c7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/5.jpg new file mode 100644 index 0000000..dd150ae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/6.jpg new file mode 100644 index 0000000..a0a2e0b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/114/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/0.jpg new file mode 100644 index 0000000..3e88207 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/1.jpg new file mode 100644 index 0000000..9f35817 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/2.jpg new file mode 100644 index 0000000..1390b7e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/3.jpg new file mode 100644 index 0000000..c429a9a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/4.jpg new file mode 100644 index 0000000..dd0f071 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/5.jpg new file mode 100644 index 0000000..a975efc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/6.jpg new file mode 100644 index 0000000..3e037b0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/7.jpg new file mode 100644 index 0000000..a1e2cd6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/115/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/0.jpg new file mode 100644 index 0000000..4e0d3e6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/1.jpg new file mode 100644 index 0000000..5bf5b60 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/2.jpg new file mode 100644 index 0000000..cb98036 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/3.jpg new file mode 100644 index 0000000..7d7e205 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/4.jpg new file mode 100644 index 0000000..7c884b9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/5.jpg new file mode 100644 index 0000000..0833ccc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/116/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/0.jpg new file mode 100644 index 0000000..80e9dca Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/1.jpg new file mode 100644 index 0000000..96f583a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/2.jpg new file mode 100644 index 0000000..fb98ba7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/3.jpg new file mode 100644 index 0000000..3991cde Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/117/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/0.jpg new file mode 100644 index 0000000..d7fce6a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/1.jpg new file mode 100644 index 0000000..a966d19 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/2.jpg new file mode 100644 index 0000000..6fb0404 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/3.jpg new file mode 100644 index 0000000..d2d4787 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/118/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/0.jpg new file mode 100644 index 0000000..41e6960 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/1.jpg new file mode 100644 index 0000000..ddc6d26 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/2.jpg new file mode 100644 index 0000000..1478a1e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/3.jpg new file mode 100644 index 0000000..2419d69 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/4.jpg new file mode 100644 index 0000000..15ca0d9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/119/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/0.jpg new file mode 100644 index 0000000..f429296 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/1.jpg new file mode 100644 index 0000000..f78b4f6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/2.jpg new file mode 100644 index 0000000..2eee949 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/12/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._2.jpg new file mode 100644 index 0000000..89bca33 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._3.jpg new file mode 100644 index 0000000..407e266 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/0.jpg new file mode 100644 index 0000000..c5a8bdf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/1.jpg new file mode 100644 index 0000000..36aa5f1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/2.jpg new file mode 100644 index 0000000..d86db69 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/3.jpg new file mode 100644 index 0000000..4df8a2b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/120/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/0.jpg new file mode 100644 index 0000000..3886ba2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/1.jpg new file mode 100644 index 0000000..a04d600 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/2.jpg new file mode 100644 index 0000000..2fe0579 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/3.jpg new file mode 100644 index 0000000..2836989 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/121/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/0.jpg new file mode 100644 index 0000000..e50acf6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/1.jpg new file mode 100644 index 0000000..1ba14e7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/2.jpg new file mode 100644 index 0000000..5abc55b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/122/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/0.jpg new file mode 100644 index 0000000..8486d8c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/1.jpg new file mode 100644 index 0000000..b7f7bd6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/2.jpg new file mode 100644 index 0000000..e93d612 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/3.jpg new file mode 100644 index 0000000..cc6a6b4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/4.jpg new file mode 100644 index 0000000..7eed06c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/5.jpg new file mode 100644 index 0000000..84e7235 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/123/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/0.jpg new file mode 100644 index 0000000..13732bb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/1.jpg new file mode 100644 index 0000000..8766b4a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/2.jpg new file mode 100644 index 0000000..894cc8d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/3.jpg new file mode 100644 index 0000000..11b27d2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/4.jpg new file mode 100644 index 0000000..800ea28 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/5.jpg new file mode 100644 index 0000000..113d629 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/124/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/0.jpg new file mode 100644 index 0000000..e8f9189 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/1.jpg new file mode 100644 index 0000000..ba8797c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/2.jpg new file mode 100644 index 0000000..8e2f5d8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/3.jpg new file mode 100644 index 0000000..947cfc5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/4.jpg new file mode 100644 index 0000000..8d03257 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/125/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/0.jpg new file mode 100644 index 0000000..5b8cdf0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/1.jpg new file mode 100644 index 0000000..54d0146 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/2.jpg new file mode 100644 index 0000000..ec371f1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/3.jpg new file mode 100644 index 0000000..4437d69 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/4.jpg new file mode 100644 index 0000000..bb7f94e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/126/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/0.jpg new file mode 100644 index 0000000..34d261c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/1.jpg new file mode 100644 index 0000000..4ab974c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/2.jpg new file mode 100644 index 0000000..87386c9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/3.jpg new file mode 100644 index 0000000..07b101d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/127/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/0.jpg new file mode 100644 index 0000000..ba010a7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/1.jpg new file mode 100644 index 0000000..e7014bb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/2.jpg new file mode 100644 index 0000000..e9b9925 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/3.jpg new file mode 100644 index 0000000..a997389 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/128/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/0.jpg new file mode 100644 index 0000000..ee6951f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/1.jpg new file mode 100644 index 0000000..1b0e520 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/2.jpg new file mode 100644 index 0000000..640f699 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/3.jpg new file mode 100644 index 0000000..078c63c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/4.jpg new file mode 100644 index 0000000..cad45b6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/5.jpg new file mode 100644 index 0000000..74d8d0d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/129/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/0.jpg new file mode 100644 index 0000000..1e772f1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/1.jpg new file mode 100644 index 0000000..8b068e2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/2.jpg new file mode 100644 index 0000000..afbdf23 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/3.jpg new file mode 100644 index 0000000..667f06f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/4.jpg new file mode 100644 index 0000000..89591d5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/13/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/0.jpg new file mode 100644 index 0000000..eb995f8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/1.jpg new file mode 100644 index 0000000..1960f03 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/2.jpg new file mode 100644 index 0000000..1506f11 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/3.jpg new file mode 100644 index 0000000..b12bfcc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/130/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._6.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._7.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/0.jpg new file mode 100644 index 0000000..b7bc58a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/1.jpg new file mode 100644 index 0000000..4ba2240 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/2.jpg new file mode 100644 index 0000000..91929bb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/3.jpg new file mode 100644 index 0000000..6d52c67 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/4.jpg new file mode 100644 index 0000000..76be426 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/5.jpg new file mode 100644 index 0000000..1e3d489 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/6.jpg new file mode 100644 index 0000000..b548502 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/7.jpg new file mode 100644 index 0000000..fd01076 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/131/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/0.jpg new file mode 100644 index 0000000..ba16a61 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/1.jpg new file mode 100644 index 0000000..c08a676 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/2.jpg new file mode 100644 index 0000000..d7f52e8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/3.jpg new file mode 100644 index 0000000..7fa14fe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/4.jpg new file mode 100644 index 0000000..4f6ce71 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/132/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/0.jpg new file mode 100644 index 0000000..554c704 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/1.jpg new file mode 100644 index 0000000..3be1bbf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/2.jpg new file mode 100644 index 0000000..9c369b3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/3.jpg new file mode 100644 index 0000000..22a9634 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/4.jpg new file mode 100644 index 0000000..9040336 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/5.jpg new file mode 100644 index 0000000..ba92349 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/133/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/0.jpg new file mode 100644 index 0000000..81756fd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/1.jpg new file mode 100644 index 0000000..66c5d48 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/2.jpg new file mode 100644 index 0000000..ed9cccf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/3.jpg new file mode 100644 index 0000000..7ea4631 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/134/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._6.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/0.jpg new file mode 100644 index 0000000..ab1fc9f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/1.jpg new file mode 100644 index 0000000..f372516 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/2.jpg new file mode 100644 index 0000000..8441459 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/3.jpg new file mode 100644 index 0000000..3b6a178 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/4.jpg new file mode 100644 index 0000000..dadff3e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/5.jpg new file mode 100644 index 0000000..69db067 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/6.jpg new file mode 100644 index 0000000..a5ed75e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/135/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/0.jpg new file mode 100644 index 0000000..10a76ab Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/1.jpg new file mode 100644 index 0000000..4e66974 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/2.jpg new file mode 100644 index 0000000..23c6d25 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/3.jpg new file mode 100644 index 0000000..f477e0e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/4.jpg new file mode 100644 index 0000000..c5f82ff Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/5.jpg new file mode 100644 index 0000000..3b64005 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/136/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/0.jpg new file mode 100644 index 0000000..f441ea2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/1.jpg new file mode 100644 index 0000000..734abe1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/2.jpg new file mode 100644 index 0000000..ef661b3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/3.jpg new file mode 100644 index 0000000..84b1a20 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/4.jpg new file mode 100644 index 0000000..44eb3fe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/5.jpg new file mode 100644 index 0000000..74a2e1f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/137/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._6.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/0.jpg new file mode 100644 index 0000000..6db8d63 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/1.jpg new file mode 100644 index 0000000..bc00a06 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/2.jpg new file mode 100644 index 0000000..3685c93 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/3.jpg new file mode 100644 index 0000000..838baae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/4.jpg new file mode 100644 index 0000000..a676eb4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/5.jpg new file mode 100644 index 0000000..6c59069 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/6.jpg new file mode 100644 index 0000000..9983670 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/138/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/0.jpg new file mode 100644 index 0000000..852aa16 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/1.jpg new file mode 100644 index 0000000..02a88ea Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/2.jpg new file mode 100644 index 0000000..9dd2bde Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/3.jpg new file mode 100644 index 0000000..a215780 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/4.jpg new file mode 100644 index 0000000..a151d53 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/5.jpg new file mode 100644 index 0000000..25ac09c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/139/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/0.jpg new file mode 100644 index 0000000..b4ca2df Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/1.jpg new file mode 100644 index 0000000..35c690b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/2.jpg new file mode 100644 index 0000000..5f199e1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/3.jpg new file mode 100644 index 0000000..9252dc1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/4.jpg new file mode 100644 index 0000000..61ad823 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/5.jpg new file mode 100644 index 0000000..531290f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/14/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/0.jpg new file mode 100644 index 0000000..6f9e2c4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/1.jpg new file mode 100644 index 0000000..6901cc4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/2.jpg new file mode 100644 index 0000000..3b8d4fb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/3.jpg new file mode 100644 index 0000000..53eff81 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/4.jpg new file mode 100644 index 0000000..6ed25d7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/5.jpg new file mode 100644 index 0000000..f79dc9f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/140/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/0.jpg new file mode 100644 index 0000000..2269a9b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/1.jpg new file mode 100644 index 0000000..c26daff Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/2.jpg new file mode 100644 index 0000000..efb65eb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/3.jpg new file mode 100644 index 0000000..de394d2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/141/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/0.jpg new file mode 100644 index 0000000..5f83c11 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/1.jpg new file mode 100644 index 0000000..5b52f1a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/2.jpg new file mode 100644 index 0000000..a36ce68 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/3.jpg new file mode 100644 index 0000000..f52fb72 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/4.jpg new file mode 100644 index 0000000..a5ef8d4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/142/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/0.jpg new file mode 100644 index 0000000..7df0791 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/1.jpg new file mode 100644 index 0000000..7316d50 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/2.jpg new file mode 100644 index 0000000..8711f76 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/3.jpg new file mode 100644 index 0000000..9b87508 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/4.jpg new file mode 100644 index 0000000..1b36959 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/5.jpg new file mode 100644 index 0000000..b46c7c7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/143/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/0.jpg new file mode 100644 index 0000000..320667c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/1.jpg new file mode 100644 index 0000000..5d5f747 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/2.jpg new file mode 100644 index 0000000..0a5751a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/3.jpg new file mode 100644 index 0000000..542d5dd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/4.jpg new file mode 100644 index 0000000..85452bd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/5.jpg new file mode 100644 index 0000000..89ebff4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/144/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/0.jpg new file mode 100644 index 0000000..b385e31 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/1.jpg new file mode 100644 index 0000000..0485ced Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/2.jpg new file mode 100644 index 0000000..453a14c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/3.jpg new file mode 100644 index 0000000..398cdcb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/4.jpg new file mode 100644 index 0000000..b6ffe26 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/5.jpg new file mode 100644 index 0000000..711cbd3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/145/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/0.jpg new file mode 100644 index 0000000..fdbad98 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/1.jpg new file mode 100644 index 0000000..4482aaa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/2.jpg new file mode 100644 index 0000000..4e52779 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/3.jpg new file mode 100644 index 0000000..6ce13cd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/146/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/0.jpg new file mode 100644 index 0000000..3b1451a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/1.jpg new file mode 100644 index 0000000..666e287 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/2.jpg new file mode 100644 index 0000000..1299b4d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/3.jpg new file mode 100644 index 0000000..7ae4820 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/4.jpg new file mode 100644 index 0000000..8ccf48f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/5.jpg new file mode 100644 index 0000000..ea297fc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/147/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/0.jpg new file mode 100644 index 0000000..aa5e59f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/1.jpg new file mode 100644 index 0000000..fa00eae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/2.jpg new file mode 100644 index 0000000..6fbffc1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/3.jpg new file mode 100644 index 0000000..11871b3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/148/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/0.jpg new file mode 100644 index 0000000..27fecb1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/1.jpg new file mode 100644 index 0000000..c25c5fc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/2.jpg new file mode 100644 index 0000000..299491e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/3.jpg new file mode 100644 index 0000000..81172e4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/149/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/0.jpg new file mode 100644 index 0000000..16ea3a4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/1.jpg new file mode 100644 index 0000000..7e23f6f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/2.jpg new file mode 100644 index 0000000..6269795 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/3.jpg new file mode 100644 index 0000000..d9c020b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/4.jpg new file mode 100644 index 0000000..d3c8685 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/15/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/0.jpg new file mode 100644 index 0000000..90a140b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/1.jpg new file mode 100644 index 0000000..ba09761 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/2.jpg new file mode 100644 index 0000000..eeecc02 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/3.jpg new file mode 100644 index 0000000..44f0cca Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/4.jpg new file mode 100644 index 0000000..3a25160 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/150/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/0.jpg new file mode 100644 index 0000000..ff7d921 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/1.jpg new file mode 100644 index 0000000..29f7c11 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/2.jpg new file mode 100644 index 0000000..dedb2aa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/3.jpg new file mode 100644 index 0000000..a767125 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/151/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/0.jpg new file mode 100644 index 0000000..5496afc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/1.jpg new file mode 100644 index 0000000..2df891c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/2.jpg new file mode 100644 index 0000000..14db8a1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/3.jpg new file mode 100644 index 0000000..398d134 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/4.jpg new file mode 100644 index 0000000..4b6fda6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/5.jpg new file mode 100644 index 0000000..52dcd86 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/152/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/0.jpg new file mode 100644 index 0000000..e171ee4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/1.jpg new file mode 100644 index 0000000..f38ad50 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/2.jpg new file mode 100644 index 0000000..4bf07a0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/3.jpg new file mode 100644 index 0000000..f5147f8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/4.jpg new file mode 100644 index 0000000..97a4087 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/5.jpg new file mode 100644 index 0000000..a1a1fa9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/153/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/0.jpg new file mode 100644 index 0000000..39d763e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/1.jpg new file mode 100644 index 0000000..c522622 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/2.jpg new file mode 100644 index 0000000..1084ed7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/3.jpg new file mode 100644 index 0000000..ae4df25 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/154/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/0.jpg new file mode 100644 index 0000000..1c2ac65 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/1.jpg new file mode 100644 index 0000000..09fef39 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/2.jpg new file mode 100644 index 0000000..eab0d32 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/3.jpg new file mode 100644 index 0000000..fc39ef4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/4.jpg new file mode 100644 index 0000000..a8f03d9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/155/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/0.jpg new file mode 100644 index 0000000..0afc989 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/1.jpg new file mode 100644 index 0000000..5945790 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/2.jpg new file mode 100644 index 0000000..c32e812 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/3.jpg new file mode 100644 index 0000000..dadae13 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/156/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/0.jpg new file mode 100644 index 0000000..d3ed61d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/1.jpg new file mode 100644 index 0000000..91af5ec Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/2.jpg new file mode 100644 index 0000000..75d7294 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/3.jpg new file mode 100644 index 0000000..b50b08e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/4.jpg new file mode 100644 index 0000000..ed4dbea Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/5.jpg new file mode 100644 index 0000000..ea73027 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/157/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/0.jpg new file mode 100644 index 0000000..d2e21b5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/1.jpg new file mode 100644 index 0000000..aff483a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/2.jpg new file mode 100644 index 0000000..e776f84 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/3.jpg new file mode 100644 index 0000000..2ea7960 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/4.jpg new file mode 100644 index 0000000..d6289ae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/5.jpg new file mode 100644 index 0000000..d6e2a18 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/158/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/0.jpg new file mode 100644 index 0000000..0a508a2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/1.jpg new file mode 100644 index 0000000..6a49cda Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/2.jpg new file mode 100644 index 0000000..7ae08f0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/3.jpg new file mode 100644 index 0000000..f3b4ec5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/159/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/0.jpg new file mode 100644 index 0000000..9d9fd8f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/1.jpg new file mode 100644 index 0000000..886d01e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/2.jpg new file mode 100644 index 0000000..d8b1617 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/3.jpg new file mode 100644 index 0000000..04574e6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/16/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/0.jpg new file mode 100644 index 0000000..d00b9b3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/1.jpg new file mode 100644 index 0000000..adb078e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/2.jpg new file mode 100644 index 0000000..1097c8a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/3.jpg new file mode 100644 index 0000000..2ebeeea Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/4.jpg new file mode 100644 index 0000000..2b7bf49 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/5.jpg new file mode 100644 index 0000000..7e279b2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/160/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/0.jpg new file mode 100644 index 0000000..94feb98 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/1.jpg new file mode 100644 index 0000000..fc21802 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/2.jpg new file mode 100644 index 0000000..5e9bdbb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/3.jpg new file mode 100644 index 0000000..428e8f2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/161/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/0.jpg new file mode 100644 index 0000000..3914dd0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/1.jpg new file mode 100644 index 0000000..c77794f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/2.jpg new file mode 100644 index 0000000..a8a7eed Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/3.jpg new file mode 100644 index 0000000..2376470 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/162/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/0.jpg new file mode 100644 index 0000000..1ba471c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/1.jpg new file mode 100644 index 0000000..37470fe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/2.jpg new file mode 100644 index 0000000..7edd305 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/3.jpg new file mode 100644 index 0000000..6e54a2d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/163/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._10.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._10.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._10.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._6.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._7.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._8.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._8.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._8.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._9.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._9.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/._9.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/0.jpg new file mode 100644 index 0000000..a3eda27 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/1.jpg new file mode 100644 index 0000000..391acda Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/10.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/10.jpg new file mode 100644 index 0000000..941e6ff Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/10.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/2.jpg new file mode 100644 index 0000000..d282659 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/3.jpg new file mode 100644 index 0000000..369ac56 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/4.jpg new file mode 100644 index 0000000..b4dfdef Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/5.jpg new file mode 100644 index 0000000..5c71ec2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/6.jpg new file mode 100644 index 0000000..e0aac20 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/7.jpg new file mode 100644 index 0000000..b5f1970 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/8.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/8.jpg new file mode 100644 index 0000000..5ca91b4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/8.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/9.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/9.jpg new file mode 100644 index 0000000..bb8bcda Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/164/9.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/0.jpg new file mode 100644 index 0000000..7fab9bd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/1.jpg new file mode 100644 index 0000000..8bcce2b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/2.jpg new file mode 100644 index 0000000..409e160 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/3.jpg new file mode 100644 index 0000000..ea18a11 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/165/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/0.jpg new file mode 100644 index 0000000..5fbf631 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/1.jpg new file mode 100644 index 0000000..0c9cf7b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/2.jpg new file mode 100644 index 0000000..c148c7f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/3.jpg new file mode 100644 index 0000000..f6eacb3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/4.jpg new file mode 100644 index 0000000..34bc12d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/5.jpg new file mode 100644 index 0000000..32b45a5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/166/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/0.jpg new file mode 100644 index 0000000..6bfaa51 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/1.jpg new file mode 100644 index 0000000..7937936 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/2.jpg new file mode 100644 index 0000000..1df7883 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/3.jpg new file mode 100644 index 0000000..86f06c0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/167/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/0.jpg new file mode 100644 index 0000000..fd0a0f3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/1.jpg new file mode 100644 index 0000000..c081bf8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/2.jpg new file mode 100644 index 0000000..69001b5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/3.jpg new file mode 100644 index 0000000..0a16d77 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/4.jpg new file mode 100644 index 0000000..2fe3336 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/5.jpg new file mode 100644 index 0000000..0149297 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/168/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/0.jpg new file mode 100644 index 0000000..e48d117 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/1.jpg new file mode 100644 index 0000000..19482d7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/2.jpg new file mode 100644 index 0000000..9a17945 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/3.jpg new file mode 100644 index 0000000..3301f67 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/4.jpg new file mode 100644 index 0000000..6c9af7b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/5.jpg new file mode 100644 index 0000000..c16565f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/169/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._6.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/0.jpg new file mode 100644 index 0000000..39caa02 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/1.jpg new file mode 100644 index 0000000..de04674 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/2.jpg new file mode 100644 index 0000000..daff4b0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/3.jpg new file mode 100644 index 0000000..9150b05 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/4.jpg new file mode 100644 index 0000000..234a8e0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/5.jpg new file mode 100644 index 0000000..871ce96 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/6.jpg new file mode 100644 index 0000000..7e0dac8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/17/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/0.jpg new file mode 100644 index 0000000..3832b73 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/1.jpg new file mode 100644 index 0000000..eaad32e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/2.jpg new file mode 100644 index 0000000..5be4a15 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/3.jpg new file mode 100644 index 0000000..2ac5373 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/4.jpg new file mode 100644 index 0000000..288b835 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/170/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._6.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/0.jpg new file mode 100644 index 0000000..5743d1d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/1.jpg new file mode 100644 index 0000000..5b795d4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/2.jpg new file mode 100644 index 0000000..09ce834 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/3.jpg new file mode 100644 index 0000000..ba9f23a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/4.jpg new file mode 100644 index 0000000..2136cdd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/5.jpg new file mode 100644 index 0000000..b6698bf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/6.jpg new file mode 100644 index 0000000..14c1613 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/171/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/0.jpg new file mode 100644 index 0000000..e5eee7a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/1.jpg new file mode 100644 index 0000000..b4019e9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/2.jpg new file mode 100644 index 0000000..9f46449 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/3.jpg new file mode 100644 index 0000000..415b852 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/4.jpg new file mode 100644 index 0000000..68517ba Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/172/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._5.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._6.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._7.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/0.jpg new file mode 100644 index 0000000..de69f8f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/1.jpg new file mode 100644 index 0000000..f49d565 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/2.jpg new file mode 100644 index 0000000..d091b18 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/3.jpg new file mode 100644 index 0000000..5092539 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/4.jpg new file mode 100644 index 0000000..d95bf12 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/5.jpg new file mode 100644 index 0000000..14cbb3f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/6.jpg new file mode 100644 index 0000000..bc855d7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/7.jpg new file mode 100644 index 0000000..bd894f9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/173/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._0.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._1.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._2.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._3.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._4.jpg new file mode 100644 index 0000000..e25cff7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/0.jpg new file mode 100644 index 0000000..9b8e703 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/1.jpg new file mode 100644 index 0000000..b5721e1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/2.jpg new file mode 100644 index 0000000..88779d7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/3.jpg new file mode 100644 index 0000000..8990a2b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/4.jpg new file mode 100644 index 0000000..bfc1a12 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/174/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/0.jpg new file mode 100644 index 0000000..86691e4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/1.jpg new file mode 100644 index 0000000..c61c2d1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/2.jpg new file mode 100644 index 0000000..3eedbc6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/3.jpg new file mode 100644 index 0000000..d3dd420 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/175/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/0.jpg new file mode 100644 index 0000000..7a60d61 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/1.jpg new file mode 100644 index 0000000..38ab78b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/2.jpg new file mode 100644 index 0000000..ebe6418 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/176/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/0.jpg new file mode 100644 index 0000000..ecc46f8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/1.jpg new file mode 100644 index 0000000..6090e63 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/2.jpg new file mode 100644 index 0000000..bf4c6e3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/3.jpg new file mode 100644 index 0000000..b91236c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/4.jpg new file mode 100644 index 0000000..ad25b18 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/177/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/0.jpg new file mode 100644 index 0000000..4cf6e02 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/1.jpg new file mode 100644 index 0000000..c56af0a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/2.jpg new file mode 100644 index 0000000..95093fe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/3.jpg new file mode 100644 index 0000000..d6c885b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/4.jpg new file mode 100644 index 0000000..fa0442f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/5.jpg new file mode 100644 index 0000000..349427b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/178/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/0.jpg new file mode 100644 index 0000000..e9a1768 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/1.jpg new file mode 100644 index 0000000..58f913d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/2.jpg new file mode 100644 index 0000000..482158b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/3.jpg new file mode 100644 index 0000000..2603196 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/179/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/0.jpg new file mode 100644 index 0000000..c5bc0f2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/1.jpg new file mode 100644 index 0000000..f16d46f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/2.jpg new file mode 100644 index 0000000..906a84d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/3.jpg new file mode 100644 index 0000000..78b0685 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/4.jpg new file mode 100644 index 0000000..f685e2e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/18/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/0.jpg new file mode 100644 index 0000000..b46cf93 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/1.jpg new file mode 100644 index 0000000..24108ed Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/2.jpg new file mode 100644 index 0000000..bb7b9f4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/3.jpg new file mode 100644 index 0000000..cbf8c98 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/4.jpg new file mode 100644 index 0000000..b69692a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/5.jpg new file mode 100644 index 0000000..9f03018 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/180/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/0.jpg new file mode 100644 index 0000000..57e5ffa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/1.jpg new file mode 100644 index 0000000..fe4adc9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/2.jpg new file mode 100644 index 0000000..a830c8e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/3.jpg new file mode 100644 index 0000000..388f51e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/4.jpg new file mode 100644 index 0000000..d260a64 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/181/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/0.jpg new file mode 100644 index 0000000..4a6d249 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/1.jpg new file mode 100644 index 0000000..742b7bc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/2.jpg new file mode 100644 index 0000000..1c4f0c8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/3.jpg new file mode 100644 index 0000000..a0a1473 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/4.jpg new file mode 100644 index 0000000..844d706 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/5.jpg new file mode 100644 index 0000000..7d1b685 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/182/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/0.jpg new file mode 100644 index 0000000..dff90f6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/1.jpg new file mode 100644 index 0000000..e25d425 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/2.jpg new file mode 100644 index 0000000..cec2c1d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/3.jpg new file mode 100644 index 0000000..60c0617 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/4.jpg new file mode 100644 index 0000000..a5f6821 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/183/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/0.jpg new file mode 100644 index 0000000..14ab2f7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/1.jpg new file mode 100644 index 0000000..da14a62 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/2.jpg new file mode 100644 index 0000000..8103277 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/3.jpg new file mode 100644 index 0000000..3f0de3d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/4.jpg new file mode 100644 index 0000000..089c46b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/184/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/0.jpg new file mode 100644 index 0000000..be5d01a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/1.jpg new file mode 100644 index 0000000..d821eba Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/2.jpg new file mode 100644 index 0000000..4dcbafb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/3.jpg new file mode 100644 index 0000000..d55dc7d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/4.jpg new file mode 100644 index 0000000..042e508 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/5.jpg new file mode 100644 index 0000000..ce81387 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/185/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/0.jpg new file mode 100644 index 0000000..7ac6f7f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/1.jpg new file mode 100644 index 0000000..35c045f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/186/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/0.jpg new file mode 100644 index 0000000..c10da68 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/1.jpg new file mode 100644 index 0000000..065f4f6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/2.jpg new file mode 100644 index 0000000..1674f4b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/3.jpg new file mode 100644 index 0000000..901f573 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/4.jpg new file mode 100644 index 0000000..7fc14b5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/5.jpg new file mode 100644 index 0000000..3a38ea1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/187/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/0.jpg new file mode 100644 index 0000000..15a2f51 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/1.jpg new file mode 100644 index 0000000..f82063a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/2.jpg new file mode 100644 index 0000000..312dcbe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/3.jpg new file mode 100644 index 0000000..ec7a436 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/4.jpg new file mode 100644 index 0000000..d2f4a7f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/188/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/0.jpg new file mode 100644 index 0000000..a46d863 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/1.jpg new file mode 100644 index 0000000..a8045ce Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/189/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/0.jpg new file mode 100644 index 0000000..1e4c73c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/1.jpg new file mode 100644 index 0000000..37a5899 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/2.jpg new file mode 100644 index 0000000..84b2fb4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/3.jpg new file mode 100644 index 0000000..419eb1e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/4.jpg new file mode 100644 index 0000000..9dbf9da Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/19/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/0.jpg new file mode 100644 index 0000000..750d5ce Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/1.jpg new file mode 100644 index 0000000..b006611 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/2.jpg new file mode 100644 index 0000000..a595f32 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/3.jpg new file mode 100644 index 0000000..442811b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/190/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/0.jpg new file mode 100644 index 0000000..78cc51b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/1.jpg new file mode 100644 index 0000000..c21ace5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/2.jpg new file mode 100644 index 0000000..2a583ba Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/3.jpg new file mode 100644 index 0000000..f39343c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/191/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/0.jpg new file mode 100644 index 0000000..d8e9c9b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/1.jpg new file mode 100644 index 0000000..29fc116 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/2.jpg new file mode 100644 index 0000000..94347b2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/3.jpg new file mode 100644 index 0000000..1ffcfe4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/4.jpg new file mode 100644 index 0000000..5c7528b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/192/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/0.jpg new file mode 100644 index 0000000..d8204e9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/1.jpg new file mode 100644 index 0000000..42985a3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/2.jpg new file mode 100644 index 0000000..ef47c2b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/3.jpg new file mode 100644 index 0000000..05be584 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/4.jpg new file mode 100644 index 0000000..62e9d88 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/5.jpg new file mode 100644 index 0000000..31d0f82 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/193/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/0.jpg new file mode 100644 index 0000000..2a038d8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/1.jpg new file mode 100644 index 0000000..ecd8f1b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/2.jpg new file mode 100644 index 0000000..acc14a3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/3.jpg new file mode 100644 index 0000000..ad361a2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/194/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/0.jpg new file mode 100644 index 0000000..1ce575f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/1.jpg new file mode 100644 index 0000000..1ec6c0b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/195/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/0.jpg new file mode 100644 index 0000000..c8a13ed Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/1.jpg new file mode 100644 index 0000000..b45a60e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/2.jpg new file mode 100644 index 0000000..68ba5a0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/3.jpg new file mode 100644 index 0000000..7683578 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/196/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/0.jpg new file mode 100644 index 0000000..241e27f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/1.jpg new file mode 100644 index 0000000..fa52384 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/2.jpg new file mode 100644 index 0000000..3f6382e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/3.jpg new file mode 100644 index 0000000..10eb442 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/4.jpg new file mode 100644 index 0000000..8777ba4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/5.jpg new file mode 100644 index 0000000..fd613eb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/197/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._6.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/0.jpg new file mode 100644 index 0000000..2967afb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/1.jpg new file mode 100644 index 0000000..0a980f6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/2.jpg new file mode 100644 index 0000000..56063bf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/3.jpg new file mode 100644 index 0000000..b662570 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/4.jpg new file mode 100644 index 0000000..4f2be77 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/5.jpg new file mode 100644 index 0000000..39e0543 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/6.jpg new file mode 100644 index 0000000..479aa16 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/198/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/0.jpg new file mode 100644 index 0000000..b91d472 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/1.jpg new file mode 100644 index 0000000..24f6dc4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/2.jpg new file mode 100644 index 0000000..e050fc7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/3.jpg new file mode 100644 index 0000000..2b6b9b2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/199/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._6.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/0.jpg new file mode 100644 index 0000000..e74bc38 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/1.jpg new file mode 100644 index 0000000..0777094 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/2.jpg new file mode 100644 index 0000000..0c95440 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/3.jpg new file mode 100644 index 0000000..e3846ad Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/4.jpg new file mode 100644 index 0000000..ba699de Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/5.jpg new file mode 100644 index 0000000..207ca81 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/6.jpg new file mode 100644 index 0000000..b49c410 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/2/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/0.jpg new file mode 100644 index 0000000..6c73c3c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/1.jpg new file mode 100644 index 0000000..c92bd96 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/2.jpg new file mode 100644 index 0000000..3d40d13 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/3.jpg new file mode 100644 index 0000000..dca87b1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/4.jpg new file mode 100644 index 0000000..09f2a6b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/20/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/0.jpg new file mode 100644 index 0000000..b32e639 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/1.jpg new file mode 100644 index 0000000..090eba3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/2.jpg new file mode 100644 index 0000000..dfe7691 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/3.jpg new file mode 100644 index 0000000..1184c3f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/200/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._6.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/0.jpg new file mode 100644 index 0000000..579f7b3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/1.jpg new file mode 100644 index 0000000..d33f3c1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/2.jpg new file mode 100644 index 0000000..2ab1459 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/3.jpg new file mode 100644 index 0000000..0a55b73 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/4.jpg new file mode 100644 index 0000000..0b81782 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/5.jpg new file mode 100644 index 0000000..1fb98b6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/6.jpg new file mode 100644 index 0000000..927ef0f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/201/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._6.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/0.jpg new file mode 100644 index 0000000..d77b82d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/1.jpg new file mode 100644 index 0000000..0d6d3d1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/2.jpg new file mode 100644 index 0000000..8b20c97 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/3.jpg new file mode 100644 index 0000000..83cb75d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/4.jpg new file mode 100644 index 0000000..32eb535 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/5.jpg new file mode 100644 index 0000000..d91719a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/6.jpg new file mode 100644 index 0000000..fa80dd2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/202/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/0.jpg new file mode 100644 index 0000000..5599e55 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/1.jpg new file mode 100644 index 0000000..6852700 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/2.jpg new file mode 100644 index 0000000..d70d8d8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/203/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/0.jpg new file mode 100644 index 0000000..5b17cef Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/1.jpg new file mode 100644 index 0000000..78193f4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/2.jpg new file mode 100644 index 0000000..78193f4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/3.jpg new file mode 100644 index 0000000..5b17cef Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/4.jpg new file mode 100644 index 0000000..f5668fa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/5.jpg new file mode 100644 index 0000000..f063f07 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/204/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/0.jpg new file mode 100644 index 0000000..d3ebb5d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/1.jpg new file mode 100644 index 0000000..9535bd9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/2.jpg new file mode 100644 index 0000000..f5e4699 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/3.jpg new file mode 100644 index 0000000..2dcd55b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/4.jpg new file mode 100644 index 0000000..a57cef2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/5.jpg new file mode 100644 index 0000000..c4dfb8b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/205/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/0.jpg new file mode 100644 index 0000000..8a15a14 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/1.jpg new file mode 100644 index 0000000..f341e02 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/206/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._6.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/0.jpg new file mode 100644 index 0000000..90c2888 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/1.jpg new file mode 100644 index 0000000..272c02a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/2.jpg new file mode 100644 index 0000000..e31fb38 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/3.jpg new file mode 100644 index 0000000..f8601a7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/4.jpg new file mode 100644 index 0000000..10b4624 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/5.jpg new file mode 100644 index 0000000..7fe8db8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/6.jpg new file mode 100644 index 0000000..9076c97 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/207/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/0.jpg new file mode 100644 index 0000000..a6f9d08 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/1.jpg new file mode 100644 index 0000000..cb16ac5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/2.jpg new file mode 100644 index 0000000..218b1b5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/3.jpg new file mode 100644 index 0000000..ad95cab Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/4.jpg new file mode 100644 index 0000000..0d9c976 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/5.jpg new file mode 100644 index 0000000..804130a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/208/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._5.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/0.jpg new file mode 100644 index 0000000..b6d1f4b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/1.jpg new file mode 100644 index 0000000..ad81e18 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/2.jpg new file mode 100644 index 0000000..1850b2a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/3.jpg new file mode 100644 index 0000000..af880ee Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/4.jpg new file mode 100644 index 0000000..b2ac1ba Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/5.jpg new file mode 100644 index 0000000..4b1a28d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/209/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/0.jpg new file mode 100644 index 0000000..63b9992 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/1.jpg new file mode 100644 index 0000000..6347a10 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/2.jpg new file mode 100644 index 0000000..92636ab Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/3.jpg new file mode 100644 index 0000000..bc6ee00 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/4.jpg new file mode 100644 index 0000000..f174ca0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/21/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/210/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/210/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/210/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/210/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/210/0.jpg new file mode 100644 index 0000000..8382daf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/210/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._4.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/0.jpg new file mode 100644 index 0000000..80eb7c1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/1.jpg new file mode 100644 index 0000000..456d57c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/2.jpg new file mode 100644 index 0000000..a9b5564 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/3.jpg new file mode 100644 index 0000000..0c372cc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/4.jpg new file mode 100644 index 0000000..27fb936 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/211/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._0.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._1.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._2.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._3.jpg new file mode 100644 index 0000000..51feebe Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/0.jpg new file mode 100644 index 0000000..3291b43 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/1.jpg new file mode 100644 index 0000000..6a871e7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/2.jpg new file mode 100644 index 0000000..309231e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/3.jpg new file mode 100644 index 0000000..0065cae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/212/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/0.jpg new file mode 100644 index 0000000..f1322e2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/1.jpg new file mode 100644 index 0000000..7a1aee7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/2.jpg new file mode 100644 index 0000000..ab112a1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/3.jpg new file mode 100644 index 0000000..cb156be Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/22/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/0.jpg new file mode 100644 index 0000000..d4e27c2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/1.jpg new file mode 100644 index 0000000..86167ed Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/2.jpg new file mode 100644 index 0000000..2ce9d5c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/3.jpg new file mode 100644 index 0000000..5bce182 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/4.jpg new file mode 100644 index 0000000..eb5fc49 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/23/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/0.jpg new file mode 100644 index 0000000..7bd8ada Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/1.jpg new file mode 100644 index 0000000..7a79198 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/2.jpg new file mode 100644 index 0000000..b1e699d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/3.jpg new file mode 100644 index 0000000..c78ad08 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/24/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/0.jpg new file mode 100644 index 0000000..e1d714f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/1.jpg new file mode 100644 index 0000000..99d5803 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/2.jpg new file mode 100644 index 0000000..f45d3cf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/3.jpg new file mode 100644 index 0000000..fe25a7b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/4.jpg new file mode 100644 index 0000000..e7c5e4a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/25/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/0.jpg new file mode 100644 index 0000000..e902555 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/1.jpg new file mode 100644 index 0000000..1ce635e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/2.jpg new file mode 100644 index 0000000..7a309e9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/3.jpg new file mode 100644 index 0000000..0e507c7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/4.jpg new file mode 100644 index 0000000..d6876eb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/26/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/0.jpg new file mode 100644 index 0000000..a879f42 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/1.jpg new file mode 100644 index 0000000..6ee14ec Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/2.jpg new file mode 100644 index 0000000..a1317e7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/3.jpg new file mode 100644 index 0000000..7757dbd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/4.jpg new file mode 100644 index 0000000..7704ccb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/27/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/0.jpg new file mode 100644 index 0000000..091b71a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/1.jpg new file mode 100644 index 0000000..36a6368 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/2.jpg new file mode 100644 index 0000000..bcc6961 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/3.jpg new file mode 100644 index 0000000..edeb020 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/4.jpg new file mode 100644 index 0000000..1b8de8d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/28/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/0.jpg new file mode 100644 index 0000000..0abd3cf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/1.jpg new file mode 100644 index 0000000..75ce58f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/2.jpg new file mode 100644 index 0000000..13358b5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/3.jpg new file mode 100644 index 0000000..ac1d527 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/29/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/0.jpg new file mode 100644 index 0000000..2dc366d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/1.jpg new file mode 100644 index 0000000..67f26c5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/2.jpg new file mode 100644 index 0000000..6daea23 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/3.jpg new file mode 100644 index 0000000..77b0dbf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/3/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/0.jpg new file mode 100644 index 0000000..ab9644b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/1.jpg new file mode 100644 index 0000000..409a398 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/2.jpg new file mode 100644 index 0000000..d461991 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/3.jpg new file mode 100644 index 0000000..a627d29 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/4.jpg new file mode 100644 index 0000000..0e2a416 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/5.jpg new file mode 100644 index 0000000..c794078 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/30/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/0.jpg new file mode 100644 index 0000000..acff7e6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/1.jpg new file mode 100644 index 0000000..fd9c5fa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/2.jpg new file mode 100644 index 0000000..52a329f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/3.jpg new file mode 100644 index 0000000..248a864 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/31/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/0.jpg new file mode 100644 index 0000000..6944149 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/1.jpg new file mode 100644 index 0000000..d87e293 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/2.jpg new file mode 100644 index 0000000..d10bcb7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/3.jpg new file mode 100644 index 0000000..4f135dd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/32/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/0.jpg new file mode 100644 index 0000000..720fb4b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/1.jpg new file mode 100644 index 0000000..ae0ae36 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/2.jpg new file mode 100644 index 0000000..82cfd8e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/3.jpg new file mode 100644 index 0000000..812b70c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/4.jpg new file mode 100644 index 0000000..940be9a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/5.jpg new file mode 100644 index 0000000..cf86bc5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/33/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/0.jpg new file mode 100644 index 0000000..f001632 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/1.jpg new file mode 100644 index 0000000..5d61834 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/2.jpg new file mode 100644 index 0000000..0b39598 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/3.jpg new file mode 100644 index 0000000..94712a6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/4.jpg new file mode 100644 index 0000000..50f14bd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/5.jpg new file mode 100644 index 0000000..07b4fdd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/34/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/0.jpg new file mode 100644 index 0000000..c77d82e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/1.jpg new file mode 100644 index 0000000..4fba505 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/2.jpg new file mode 100644 index 0000000..a2cff1d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/3.jpg new file mode 100644 index 0000000..90191cc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/4.jpg new file mode 100644 index 0000000..cead1f2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/35/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/0.jpg new file mode 100644 index 0000000..6d7c92b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/1.jpg new file mode 100644 index 0000000..33ed8b3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/2.jpg new file mode 100644 index 0000000..6ca6e32 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/3.jpg new file mode 100644 index 0000000..e401f4f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/4.jpg new file mode 100644 index 0000000..44b1f21 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/5.jpg new file mode 100644 index 0000000..f22befc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/36/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/0.jpg new file mode 100644 index 0000000..ee290f2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/1.jpg new file mode 100644 index 0000000..fbe1c3d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/2.jpg new file mode 100644 index 0000000..038c533 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/3.jpg new file mode 100644 index 0000000..db206a3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/4.jpg new file mode 100644 index 0000000..2bc10ff Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/37/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/0.jpg new file mode 100644 index 0000000..65cb573 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/1.jpg new file mode 100644 index 0000000..5019c87 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/2.jpg new file mode 100644 index 0000000..fbce06f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/3.jpg new file mode 100644 index 0000000..3a1844a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/4.jpg new file mode 100644 index 0000000..7314850 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/38/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/0.jpg new file mode 100644 index 0000000..b20af2e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/1.jpg new file mode 100644 index 0000000..3e062bf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/2.jpg new file mode 100644 index 0000000..50fe71f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/3.jpg new file mode 100644 index 0000000..3c4249f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/39/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._6.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/0.jpg new file mode 100644 index 0000000..e46ce0f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/1.jpg new file mode 100644 index 0000000..2c55b2c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/2.jpg new file mode 100644 index 0000000..0e4903b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/3.jpg new file mode 100644 index 0000000..345aa5f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/4.jpg new file mode 100644 index 0000000..e5ec0b8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/5.jpg new file mode 100644 index 0000000..d683ec5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/6.jpg new file mode 100644 index 0000000..249bf6a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/4/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/0.jpg new file mode 100644 index 0000000..eee4e50 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/1.jpg new file mode 100644 index 0000000..cab5c27 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/2.jpg new file mode 100644 index 0000000..ed08497 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/3.jpg new file mode 100644 index 0000000..36fb8d6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/41/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._5.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/0.jpg new file mode 100644 index 0000000..eb60535 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/1.jpg new file mode 100644 index 0000000..e2dd715 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/2.jpg new file mode 100644 index 0000000..586c8b2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/3.jpg new file mode 100644 index 0000000..9bb573c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/4.jpg new file mode 100644 index 0000000..632873d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/5.jpg new file mode 100644 index 0000000..b58fc6c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/42/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._5.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/0.jpg new file mode 100644 index 0000000..0dfc3d9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/1.jpg new file mode 100644 index 0000000..97fbf62 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/2.jpg new file mode 100644 index 0000000..bc6b928 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/3.jpg new file mode 100644 index 0000000..17458d2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/4.jpg new file mode 100644 index 0000000..438fcab Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/5.jpg new file mode 100644 index 0000000..7f73104 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/43/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/0.jpg new file mode 100644 index 0000000..179e55f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/1.jpg new file mode 100644 index 0000000..64d0a4c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/2.jpg new file mode 100644 index 0000000..16c3bf5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/44/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/0.jpg new file mode 100644 index 0000000..d93ad74 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/1.jpg new file mode 100644 index 0000000..094fcc7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/2.jpg new file mode 100644 index 0000000..da68740 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/3.jpg new file mode 100644 index 0000000..57a9f0e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/4.jpg new file mode 100644 index 0000000..8933eee Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/45/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/0.jpg new file mode 100644 index 0000000..d93ad74 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/1.jpg new file mode 100644 index 0000000..094fcc7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/2.jpg new file mode 100644 index 0000000..da68740 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/3.jpg new file mode 100644 index 0000000..57a9f0e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/4.jpg new file mode 100644 index 0000000..8933eee Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/46/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._5.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._6.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._7.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/0.jpg new file mode 100644 index 0000000..296362e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/1.jpg new file mode 100644 index 0000000..44e00ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/2.jpg new file mode 100644 index 0000000..edf7acc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/3.jpg new file mode 100644 index 0000000..920ed02 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/4.jpg new file mode 100644 index 0000000..65717e2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/5.jpg new file mode 100644 index 0000000..d1d149d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/6.jpg new file mode 100644 index 0000000..f05e831 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/7.jpg new file mode 100644 index 0000000..51d9aa3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/47/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/0.jpg new file mode 100644 index 0000000..bb7f9ce Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/1.jpg new file mode 100644 index 0000000..d37496a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/2.jpg new file mode 100644 index 0000000..9765f75 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/48/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/0.jpg new file mode 100644 index 0000000..c26e7c9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/1.jpg new file mode 100644 index 0000000..5e9bd04 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/2.jpg new file mode 100644 index 0000000..6947bee Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/49/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/0.jpg new file mode 100644 index 0000000..a668dc3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/1.jpg new file mode 100644 index 0000000..9d5654d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/2.jpg new file mode 100644 index 0000000..5aae98a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/3.jpg new file mode 100644 index 0000000..08b11fc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/4.jpg new file mode 100644 index 0000000..3e5beec Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/5/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/0.jpg new file mode 100644 index 0000000..753684d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/1.jpg new file mode 100644 index 0000000..bc19e28 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/2.jpg new file mode 100644 index 0000000..c359807 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/3.jpg new file mode 100644 index 0000000..f2f1c58 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/4.jpg new file mode 100644 index 0000000..7b5a8f5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/50/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/0.jpg new file mode 100644 index 0000000..3dbfb09 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/1.jpg new file mode 100644 index 0000000..ae70b0e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/2.jpg new file mode 100644 index 0000000..800e75b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/3.jpg new file mode 100644 index 0000000..eea86f0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/51/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/0.jpg new file mode 100644 index 0000000..e24904d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/1.jpg new file mode 100644 index 0000000..20c13d5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/2.jpg new file mode 100644 index 0000000..e45fef3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/52/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/0.jpg new file mode 100644 index 0000000..fa93de1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/1.jpg new file mode 100644 index 0000000..8fabba4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/2.jpg new file mode 100644 index 0000000..b070dae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/53/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/0.jpg new file mode 100644 index 0000000..03ae221 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/1.jpg new file mode 100644 index 0000000..396de7e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/2.jpg new file mode 100644 index 0000000..3af4d94 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/3.jpg new file mode 100644 index 0000000..93cb5e3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/4.jpg new file mode 100644 index 0000000..014ad6b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/54/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._5.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/0.jpg new file mode 100644 index 0000000..0251065 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/1.jpg new file mode 100644 index 0000000..bc71f78 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/2.jpg new file mode 100644 index 0000000..c844b51 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/3.jpg new file mode 100644 index 0000000..c62a8bf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/4.jpg new file mode 100644 index 0000000..ed00604 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/5.jpg new file mode 100644 index 0000000..3e71e14 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/55/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/0.jpg new file mode 100644 index 0000000..680ceef Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/1.jpg new file mode 100644 index 0000000..5b0138e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/2.jpg new file mode 100644 index 0000000..4a5452b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/56/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/0.jpg new file mode 100644 index 0000000..d271d26 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/1.jpg new file mode 100644 index 0000000..02356a0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/2.jpg new file mode 100644 index 0000000..fa715dc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/3.jpg new file mode 100644 index 0000000..32daae5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/4.jpg new file mode 100644 index 0000000..60555d4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/57/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/0.jpg new file mode 100644 index 0000000..86397a0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/1.jpg new file mode 100644 index 0000000..1f90197 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/2.jpg new file mode 100644 index 0000000..26717be Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/58/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/0.jpg new file mode 100644 index 0000000..82cb25a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/1.jpg new file mode 100644 index 0000000..94c6772 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/2.jpg new file mode 100644 index 0000000..fc694cb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/3.jpg new file mode 100644 index 0000000..307dd2f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/4.jpg new file mode 100644 index 0000000..2319351 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/59/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/0.jpg new file mode 100644 index 0000000..c2e2d53 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/1.jpg new file mode 100644 index 0000000..af5c2d7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/2.jpg new file mode 100644 index 0000000..b531894 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/3.jpg new file mode 100644 index 0000000..a32f02e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/4.jpg new file mode 100644 index 0000000..a10027b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/6/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/0.jpg new file mode 100644 index 0000000..e5a76fa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/1.jpg new file mode 100644 index 0000000..e47a692 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/2.jpg new file mode 100644 index 0000000..11a2486 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/3.jpg new file mode 100644 index 0000000..6513dad Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/4.jpg new file mode 100644 index 0000000..36df83b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/60/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/0.jpg new file mode 100644 index 0000000..1fa9d40 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/1.jpg new file mode 100644 index 0000000..55d9fb9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/2.jpg new file mode 100644 index 0000000..8d9b57f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/61/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/0.jpg new file mode 100644 index 0000000..251dad5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/1.jpg new file mode 100644 index 0000000..ca36090 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/2.jpg new file mode 100644 index 0000000..aaea11e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/62/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/0.jpg new file mode 100644 index 0000000..ea904a1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/1.jpg new file mode 100644 index 0000000..9b5d5af Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/2.jpg new file mode 100644 index 0000000..8c15ab0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/3.jpg new file mode 100644 index 0000000..77b837e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/4.jpg new file mode 100644 index 0000000..7a6046e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/63/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/0.jpg new file mode 100644 index 0000000..c1e15c0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/1.jpg new file mode 100644 index 0000000..0fa8329 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/64/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/0.jpg new file mode 100644 index 0000000..5ae0b4c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/1.jpg new file mode 100644 index 0000000..0e7002d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/2.jpg new file mode 100644 index 0000000..5057b1c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/3.jpg new file mode 100644 index 0000000..5a5f9cc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/4.jpg new file mode 100644 index 0000000..16f71d4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/65/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/0.jpg new file mode 100644 index 0000000..4fff846 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/1.jpg new file mode 100644 index 0000000..be0b2be Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/2.jpg new file mode 100644 index 0000000..fac0087 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/66/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/0.jpg new file mode 100644 index 0000000..9d6cce2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/1.jpg new file mode 100644 index 0000000..52c2b87 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/2.jpg new file mode 100644 index 0000000..d89286a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/67/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/0.jpg new file mode 100644 index 0000000..0e6bc9c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/1.jpg new file mode 100644 index 0000000..25cfa61 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/2.jpg new file mode 100644 index 0000000..7296038 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/68/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._5.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/0.jpg new file mode 100644 index 0000000..b14716f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/1.jpg new file mode 100644 index 0000000..0bc18ca Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/2.jpg new file mode 100644 index 0000000..de331f6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/3.jpg new file mode 100644 index 0000000..cc59b8a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/4.jpg new file mode 100644 index 0000000..7031cc7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/5.jpg new file mode 100644 index 0000000..9ba3125 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/69/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._5.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._6.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/0.jpg new file mode 100644 index 0000000..60ddc8b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/1.jpg new file mode 100644 index 0000000..10c7f7f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/2.jpg new file mode 100644 index 0000000..eca8578 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/3.jpg new file mode 100644 index 0000000..7d96755 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/4.jpg new file mode 100644 index 0000000..5df3a63 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/5.jpg new file mode 100644 index 0000000..275851d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/6.jpg new file mode 100644 index 0000000..71cafc3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/7/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/70/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/70/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/70/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/70/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/70/0.jpg new file mode 100644 index 0000000..5a00349 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/70/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/0.jpg new file mode 100644 index 0000000..33fcc2c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/1.jpg new file mode 100644 index 0000000..911fa07 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/2.jpg new file mode 100644 index 0000000..e670ea4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/71/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/0.jpg new file mode 100644 index 0000000..fb76fb1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/1.jpg new file mode 100644 index 0000000..b472f69 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/2.jpg new file mode 100644 index 0000000..ba314a2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/3.jpg new file mode 100644 index 0000000..e6bbc09 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/4.jpg new file mode 100644 index 0000000..0652a85 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/72/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/0.jpg new file mode 100644 index 0000000..9da67a7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/1.jpg new file mode 100644 index 0000000..505ae5c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/2.jpg new file mode 100644 index 0000000..a9108cc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/3.jpg new file mode 100644 index 0000000..36be4cf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/73/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/0.jpg new file mode 100644 index 0000000..f88f748 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/1.jpg new file mode 100644 index 0000000..0d9aba3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/2.jpg new file mode 100644 index 0000000..168f05e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/74/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/0.jpg new file mode 100644 index 0000000..f14aba5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/1.jpg new file mode 100644 index 0000000..0f849a1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/2.jpg new file mode 100644 index 0000000..f0a2b61 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/3.jpg new file mode 100644 index 0000000..bdd7289 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/75/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/0.jpg new file mode 100644 index 0000000..1920e56 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/1.jpg new file mode 100644 index 0000000..58848a4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/2.jpg new file mode 100644 index 0000000..27a3f30 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/76/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/0.jpg new file mode 100644 index 0000000..1844b76 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/1.jpg new file mode 100644 index 0000000..ad716a5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/2.jpg new file mode 100644 index 0000000..6e82bf2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/3.jpg new file mode 100644 index 0000000..f9ef483 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/4.jpg new file mode 100644 index 0000000..9d949ed Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/77/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/78/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/78/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/78/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/78/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/78/0.jpg new file mode 100644 index 0000000..346d8a0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/78/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/0.jpg new file mode 100644 index 0000000..2deb3e2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/1.jpg new file mode 100644 index 0000000..447374a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/2.jpg new file mode 100644 index 0000000..732902a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/79/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/0.jpg new file mode 100644 index 0000000..c1fdd58 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/1.jpg new file mode 100644 index 0000000..1150c7b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/2.jpg new file mode 100644 index 0000000..485c735 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/3.jpg new file mode 100644 index 0000000..8ff45c7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/4.jpg new file mode 100644 index 0000000..60d71d4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/8/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._0.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._1.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._2.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._3.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._4.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._5.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._6.jpg new file mode 100644 index 0000000..d02ed95 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/0.jpg new file mode 100644 index 0000000..22b3e16 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/1.jpg new file mode 100644 index 0000000..f2d3d36 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/2.jpg new file mode 100644 index 0000000..6199566 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/3.jpg new file mode 100644 index 0000000..b181846 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/4.jpg new file mode 100644 index 0000000..b94a0a8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/5.jpg new file mode 100644 index 0000000..3cdf56c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/6.jpg new file mode 100644 index 0000000..bea49fa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/80/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/0.jpg new file mode 100644 index 0000000..121b302 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/1.jpg new file mode 100644 index 0000000..8a8fb94 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/2.jpg new file mode 100644 index 0000000..500c7a7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/3.jpg new file mode 100644 index 0000000..b5f6491 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/81/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/0.jpg new file mode 100644 index 0000000..dd8d0f0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/1.jpg new file mode 100644 index 0000000..8d8194d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/2.jpg new file mode 100644 index 0000000..de06f0c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/3.jpg new file mode 100644 index 0000000..909b383 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/4.jpg new file mode 100644 index 0000000..3342d98 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/82/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/0.jpg new file mode 100644 index 0000000..20c963f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/1.jpg new file mode 100644 index 0000000..7f4777d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/2.jpg new file mode 100644 index 0000000..e6258e1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/3.jpg new file mode 100644 index 0000000..b4daa23 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/4.jpg new file mode 100644 index 0000000..55e43f7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/5.jpg new file mode 100644 index 0000000..10933d4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/83/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/0.jpg new file mode 100644 index 0000000..25c0fa0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/1.jpg new file mode 100644 index 0000000..c7052e7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/2.jpg new file mode 100644 index 0000000..586191f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/3.jpg new file mode 100644 index 0000000..d22ddce Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/4.jpg new file mode 100644 index 0000000..0597433 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/5.jpg new file mode 100644 index 0000000..30023cf Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/6.jpg new file mode 100644 index 0000000..6454cfd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/84/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/0.jpg new file mode 100644 index 0000000..c0e6247 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/1.jpg new file mode 100644 index 0000000..d330375 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/2.jpg new file mode 100644 index 0000000..656debb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/3.jpg new file mode 100644 index 0000000..1aa4b4e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/4.jpg new file mode 100644 index 0000000..4815d7e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/85/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/0.jpg new file mode 100644 index 0000000..0318700 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/1.jpg new file mode 100644 index 0000000..83738b7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/2.jpg new file mode 100644 index 0000000..05d106c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/3.jpg new file mode 100644 index 0000000..13fdf67 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/4.jpg new file mode 100644 index 0000000..59a26a3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/5.jpg new file mode 100644 index 0000000..8188670 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/86/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/0.jpg new file mode 100644 index 0000000..3d6c55c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/1.jpg new file mode 100644 index 0000000..084f39f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/2.jpg new file mode 100644 index 0000000..887dfa5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/3.jpg new file mode 100644 index 0000000..d4412cd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/87/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._6.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._7.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/._7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/0.jpg new file mode 100644 index 0000000..5fac611 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/1.jpg new file mode 100644 index 0000000..16bf91e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/2.jpg new file mode 100644 index 0000000..c43db1d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/3.jpg new file mode 100644 index 0000000..965ebd3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/4.jpg new file mode 100644 index 0000000..1fda380 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/5.jpg new file mode 100644 index 0000000..a1d4510 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/6.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/6.jpg new file mode 100644 index 0000000..1b325d0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/6.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/7.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/7.jpg new file mode 100644 index 0000000..9544dbb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/88/7.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/0.jpg new file mode 100644 index 0000000..6c8ea26 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/1.jpg new file mode 100644 index 0000000..26db41e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/2.jpg new file mode 100644 index 0000000..8815a1d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/3.jpg new file mode 100644 index 0000000..af75a37 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/89/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._0.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._1.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._2.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._3.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._4.jpg new file mode 100644 index 0000000..de93bb2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/0.jpg new file mode 100644 index 0000000..eac59ff Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/1.jpg new file mode 100644 index 0000000..8d73ab7 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/2.jpg new file mode 100644 index 0000000..86c297d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/3.jpg new file mode 100644 index 0000000..f5ea2ae Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/4.jpg new file mode 100644 index 0000000..8dfb796 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/9/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/0.jpg new file mode 100644 index 0000000..7d110e8 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/1.jpg new file mode 100644 index 0000000..d808dee Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/2.jpg new file mode 100644 index 0000000..abdd38d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/3.jpg new file mode 100644 index 0000000..29b6d7c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/4.jpg new file mode 100644 index 0000000..e837e55 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/90/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/0.jpg new file mode 100644 index 0000000..ddb8a38 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/1.jpg new file mode 100644 index 0000000..3a109d5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/2.jpg new file mode 100644 index 0000000..c9ed3b9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/3.jpg new file mode 100644 index 0000000..38edd61 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/4.jpg new file mode 100644 index 0000000..b38dffc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/91/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/0.jpg new file mode 100644 index 0000000..066fa57 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/1.jpg new file mode 100644 index 0000000..f4cedf0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/2.jpg new file mode 100644 index 0000000..d2d5845 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/3.jpg new file mode 100644 index 0000000..7ae7602 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/4.jpg new file mode 100644 index 0000000..869fb75 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/92/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._5.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/._5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/0.jpg new file mode 100644 index 0000000..87d8d67 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/1.jpg new file mode 100644 index 0000000..c3f80de Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/2.jpg new file mode 100644 index 0000000..9f97ddd Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/3.jpg new file mode 100644 index 0000000..021ffd3 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/4.jpg new file mode 100644 index 0000000..a927486 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/5.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/5.jpg new file mode 100644 index 0000000..a3de476 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/93/5.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/0.jpg new file mode 100644 index 0000000..db00bd9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/1.jpg new file mode 100644 index 0000000..f44a59b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/2.jpg new file mode 100644 index 0000000..2718711 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/3.jpg new file mode 100644 index 0000000..a49ece0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/4.jpg new file mode 100644 index 0000000..8e6e11a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/94/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/0.jpg new file mode 100644 index 0000000..bdb0b7f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/1.jpg new file mode 100644 index 0000000..761f6cb Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/2.jpg new file mode 100644 index 0000000..544aaef Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/3.jpg new file mode 100644 index 0000000..e7414f0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/4.jpg new file mode 100644 index 0000000..0e84b0f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/95/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/0.jpg new file mode 100644 index 0000000..078d94a Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/1.jpg new file mode 100644 index 0000000..6e54ac4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/2.jpg new file mode 100644 index 0000000..a889dda Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/3.jpg new file mode 100644 index 0000000..bc3a753 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/4.jpg new file mode 100644 index 0000000..90d2dbc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/96/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/0.jpg new file mode 100644 index 0000000..1035a61 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/1.jpg new file mode 100644 index 0000000..39e4d86 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/2.jpg new file mode 100644 index 0000000..4e81ba0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/3.jpg new file mode 100644 index 0000000..342f2c9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/4.jpg new file mode 100644 index 0000000..17a781f Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/97/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/0.jpg new file mode 100644 index 0000000..cf3e78b Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/1.jpg new file mode 100644 index 0000000..4b03265 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/2.jpg new file mode 100644 index 0000000..53fd3cc Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/3.jpg new file mode 100644 index 0000000..4af3ab1 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/4.jpg new file mode 100644 index 0000000..69d9514 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/98/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._0.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._1.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._2.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._3.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._4.jpg new file mode 100644 index 0000000..8ba66ac Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/._4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/0.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/0.jpg new file mode 100644 index 0000000..84a8a26 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/0.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/1.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/1.jpg new file mode 100644 index 0000000..f0fe284 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/1.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/2.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/2.jpg new file mode 100644 index 0000000..fafb213 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/2.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/3.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/3.jpg new file mode 100644 index 0000000..70f2b53 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/3.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/4.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/4.jpg new file mode 100644 index 0000000..b02b9a5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/99/4.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/drink_label.txt b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/drink_label.txt new file mode 100644 index 0000000..f7e5fca --- /dev/null +++ b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/drink_label.txt @@ -0,0 +1,987 @@ +0/0.jpg 脉动 +0/1.jpg 脉动 +0/2.jpg 脉动 +0/3.jpg 脉动 +1/0.jpg 红牛 +1/1.jpg 红牛 +1/2.jpg 红牛 +1/3.jpg 红牛 +1/4.jpg 红牛 +2/0.jpg 战马 +2/1.jpg 战马 +2/2.jpg 战马 +2/3.jpg 战马 +2/4.jpg 战马 +2/5.jpg 战马 +2/6.jpg 战马 +3/0.jpg 尖叫 +3/1.jpg 尖叫 +3/2.jpg 尖叫 +3/3.jpg 尖叫 +4/0.jpg 启力 +4/1.jpg 启力 +4/2.jpg 启力 +4/3.jpg 启力 +4/4.jpg 启力 +4/5.jpg 启力 +4/6.jpg 启力 +5/0.jpg 乐虎氨基酸维生素功能饮料 +5/1.jpg 乐虎氨基酸维生素功能饮料 +5/2.jpg 乐虎氨基酸维生素功能饮料 +5/3.jpg 乐虎氨基酸维生素功能饮料 +5/4.jpg 乐虎氨基酸维生素功能饮料 +6/0.jpg 日加满氨基酸功能饮料 +6/1.jpg 日加满氨基酸功能饮料 +6/2.jpg 日加满氨基酸功能饮料 +6/3.jpg 日加满氨基酸功能饮料 +6/4.jpg 日加满氨基酸功能饮料 +7/0.jpg 力克 +7/1.jpg 力克 +7/2.jpg 力克 +7/3.jpg 力克 +7/4.jpg 力克 +7/5.jpg 力克 +7/6.jpg 力克 +8/0.jpg 芙丝饮用天然水 +8/1.jpg 芙丝饮用天然水 +8/2.jpg 芙丝饮用天然水 +8/3.jpg 芙丝饮用天然水 +8/4.jpg 芙丝饮用天然水 +9/0.jpg 康师傅矿物质水 +9/1.jpg 康师傅矿物质水 +9/2.jpg 康师傅矿物质水 +9/3.jpg 康师傅矿物质水 +9/4.jpg 康师傅矿物质水 +10/0.jpg 依云天然矿泉水 +10/1.jpg 依云天然矿泉水 +10/2.jpg 依云天然矿泉水 +10/3.jpg 依云天然矿泉水 +10/4.jpg 依云天然矿泉水 +10/5.jpg 依云天然矿泉水 +11/0.jpg 魔爪能量饮料 +11/1.jpg 魔爪能量饮料 +11/2.jpg 魔爪能量饮料 +11/3.jpg 魔爪能量饮料 +11/4.jpg 魔爪能量饮料 +11/5.jpg 魔爪能量饮料 +12/0.jpg 汇多滋淡盐水 +12/1.jpg 汇多滋淡盐水 +12/2.jpg 汇多滋淡盐水 +13/0.jpg 普娜天然泉水 +13/1.jpg 普娜天然泉水 +13/2.jpg 普娜天然泉水 +13/3.jpg 普娜天然泉水 +13/4.jpg 普娜天然泉水 +14/0.jpg 乐虎功能饮料 +14/1.jpg 乐虎功能饮料 +14/2.jpg 乐虎功能饮料 +14/3.jpg 乐虎功能饮料 +14/4.jpg 乐虎功能饮料 +14/5.jpg 乐虎功能饮料 +15/0.jpg 宝矿力水特 +15/1.jpg 宝矿力水特 +15/2.jpg 宝矿力水特 +15/3.jpg 宝矿力水特 +15/4.jpg 宝矿力水特 +16/0.jpg 阿尔卑斯-天然苏打水 +16/1.jpg 阿尔卑斯-天然苏打水 +16/2.jpg 阿尔卑斯-天然苏打水 +16/3.jpg 阿尔卑斯-天然苏打水 +17/0.jpg 农夫山泉-饮用天然水 +17/1.jpg 农夫山泉-饮用天然水 +17/2.jpg 农夫山泉-饮用天然水 +17/3.jpg 农夫山泉-饮用天然水 +17/4.jpg 农夫山泉-饮用天然水 +17/5.jpg 农夫山泉-饮用天然水 +17/6.jpg 农夫山泉-饮用天然水 +18/0.jpg 碱LOVE +18/1.jpg 碱LOVE +18/2.jpg 碱LOVE +18/3.jpg 碱LOVE +18/4.jpg 碱LOVE +19/0.jpg 农夫山泉-天然矿泉水 +19/1.jpg 农夫山泉-天然矿泉水 +19/2.jpg 农夫山泉-天然矿泉水 +19/3.jpg 农夫山泉-天然矿泉水 +19/4.jpg 农夫山泉-天然矿泉水 +20/0.jpg 农夫山泉-泡茶水 +20/1.jpg 农夫山泉-泡茶水 +20/2.jpg 农夫山泉-泡茶水 +20/3.jpg 农夫山泉-泡茶水 +20/4.jpg 农夫山泉-泡茶水 +21/0.jpg 等渗尖叫 +21/1.jpg 等渗尖叫 +21/2.jpg 等渗尖叫 +21/3.jpg 等渗尖叫 +21/4.jpg 等渗尖叫 +22/0.jpg 恒大冰泉 +22/1.jpg 恒大冰泉 +22/2.jpg 恒大冰泉 +22/3.jpg 恒大冰泉 +23/0.jpg 优珍能量 +23/1.jpg 优珍能量 +23/2.jpg 优珍能量 +23/3.jpg 优珍能量 +23/4.jpg 优珍能量 +24/0.jpg 东鹏特饮 +24/1.jpg 东鹏特饮 +24/2.jpg 东鹏特饮 +24/3.jpg 东鹏特饮 +25/0.jpg 纯水乐 +25/1.jpg 纯水乐 +25/2.jpg 纯水乐 +25/3.jpg 纯水乐 +25/4.jpg 纯水乐 +26/0.jpg 白山水 +26/1.jpg 白山水 +26/2.jpg 白山水 +26/3.jpg 白山水 +26/4.jpg 白山水 +27/0.jpg 水动乐 +27/1.jpg 水动乐 +27/2.jpg 水动乐 +27/3.jpg 水动乐 +27/4.jpg 水动乐 +28/0.jpg F6能量饮品 +28/1.jpg F6能量饮品 +28/2.jpg F6能量饮品 +28/3.jpg F6能量饮品 +28/4.jpg F6能量饮品 +29/0.jpg 动益加 +29/1.jpg 动益加 +29/2.jpg 动益加 +29/3.jpg 动益加 +30/0.jpg 凉白开 +30/1.jpg 凉白开 +30/2.jpg 凉白开 +30/3.jpg 凉白开 +30/4.jpg 凉白开 +30/5.jpg 凉白开 +31/0.jpg 佳得乐 +31/1.jpg 佳得乐 +31/2.jpg 佳得乐 +31/3.jpg 佳得乐 +32/0.jpg 三得利 +32/1.jpg 三得利 +32/2.jpg 三得利 +32/3.jpg 三得利 +33/0.jpg 统一-爱夸天然矿泉水 +33/1.jpg 统一-爱夸天然矿泉水 +33/2.jpg 统一-爱夸天然矿泉水 +33/3.jpg 统一-爱夸天然矿泉水 +33/4.jpg 统一-爱夸天然矿泉水 +33/5.jpg 统一-爱夸天然矿泉水 +34/0.jpg 景田-饮用纯净水 +34/1.jpg 景田-饮用纯净水 +34/2.jpg 景田-饮用纯净水 +34/3.jpg 景田-饮用纯净水 +34/4.jpg 景田-饮用纯净水 +34/5.jpg 景田-饮用纯净水 +35/0.jpg 怡宝-魔力氨基酸 +35/1.jpg 怡宝-魔力氨基酸 +35/2.jpg 怡宝-魔力氨基酸 +35/3.jpg 怡宝-魔力氨基酸 +35/4.jpg 怡宝-魔力氨基酸 +36/0.jpg 红牛-强化型 +36/1.jpg 红牛-强化型 +36/2.jpg 红牛-强化型 +36/3.jpg 红牛-强化型 +36/4.jpg 红牛-强化型 +36/5.jpg 红牛-强化型 +37/0.jpg 景田-百岁山 +37/1.jpg 景田-百岁山 +37/2.jpg 景田-百岁山 +37/3.jpg 景田-百岁山 +37/4.jpg 景田-百岁山 +38/0.jpg 雀巢 +38/1.jpg 雀巢 +38/2.jpg 雀巢 +38/3.jpg 雀巢 +38/4.jpg 雀巢 +39/0.jpg 5小时能量饮料 +39/1.jpg 5小时能量饮料 +39/2.jpg 5小时能量饮料 +39/3.jpg 5小时能量饮料 +41/0.jpg 农夫山泉_纯果蔬汁 +41/1.jpg 农夫山泉_纯果蔬汁 +41/2.jpg 农夫山泉_纯果蔬汁 +41/3.jpg 农夫山泉_纯果蔬汁 +42/0.jpg GINNAI/神内_低聚糖代餐果汁 +42/1.jpg GINNAI/神内_低聚糖代餐果汁 +42/2.jpg GINNAI/神内_低聚糖代餐果汁 +42/3.jpg GINNAI/神内_低聚糖代餐果汁 +42/4.jpg GINNAI/神内_低聚糖代餐果汁 +42/5.jpg GINNAI/神内_低聚糖代餐果汁 +43/0.jpg 贝奇野菜_果汁每日C +43/1.jpg 贝奇野菜_果汁每日C +43/2.jpg 贝奇野菜_果汁每日C +43/3.jpg 贝奇野菜_果汁每日C +43/4.jpg 贝奇野菜_果汁每日C +43/5.jpg 贝奇野菜_果汁每日C +44/0.jpg HeyJuice_西柚饮料果蔬 +44/1.jpg HeyJuice_西柚饮料果蔬 +44/2.jpg HeyJuice_西柚饮料果蔬 +45/0.jpg 沛时Perse_纯蔬果汁 +45/1.jpg 沛时Perse_纯蔬果汁 +45/2.jpg 沛时Perse_纯蔬果汁 +45/3.jpg 沛时Perse_纯蔬果汁 +45/4.jpg 沛时Perse_纯蔬果汁 +46/0.jpg 沛时Perse纯蔬果汁 +46/1.jpg 沛时Perse纯蔬果汁 +46/2.jpg 沛时Perse纯蔬果汁 +46/3.jpg 沛时Perse纯蔬果汁 +46/4.jpg 沛时Perse纯蔬果汁 +47/0.jpg 味全_每日C +47/1.jpg 味全_每日C +47/2.jpg 味全_每日C +47/3.jpg 味全_每日C +47/4.jpg 味全_每日C +47/5.jpg 味全_每日C +47/6.jpg 味全_每日C +47/7.jpg 味全_每日C +48/0.jpg 苏醒汇_纯蔬果汁 +48/1.jpg 苏醒汇_纯蔬果汁 +48/2.jpg 苏醒汇_纯蔬果汁 +49/0.jpg 臻富_番茄汁 +49/1.jpg 臻富_番茄汁 +49/2.jpg 臻富_番茄汁 +50/0.jpg 多乐诗_轻断食果蔬汁 +50/1.jpg 多乐诗_轻断食果蔬汁 +50/2.jpg 多乐诗_轻断食果蔬汁 +50/3.jpg 多乐诗_轻断食果蔬汁 +50/4.jpg 多乐诗_轻断食果蔬汁 +51/0.jpg IF/如果_椰子水饮料 +51/1.jpg IF/如果_椰子水饮料 +51/2.jpg IF/如果_椰子水饮料 +51/3.jpg IF/如果_椰子水饮料 +52/0.jpg 伊藤园_果蔬汁 +52/1.jpg 伊藤园_果蔬汁 +52/2.jpg 伊藤园_果蔬汁 +53/0.jpg 艾璞乐_苦瓜汁 +53/1.jpg 艾璞乐_苦瓜汁 +53/2.jpg 艾璞乐_苦瓜汁 +54/0.jpg 屯河_番茄汁 +54/1.jpg 屯河_番茄汁 +54/2.jpg 屯河_番茄汁 +54/3.jpg 屯河_番茄汁 +54/4.jpg 屯河_番茄汁 +55/0.jpg 屯河_杏汁 +55/1.jpg 屯河_杏汁 +55/2.jpg 屯河_杏汁 +55/3.jpg 屯河_杏汁 +55/4.jpg 屯河_杏汁 +55/5.jpg 屯河_杏汁 +56/0.jpg Sunsweet_西梅汁 +56/1.jpg Sunsweet_西梅汁 +56/2.jpg Sunsweet_西梅汁 +57/0.jpg 农夫果园_混合果蔬汁 +57/1.jpg 农夫果园_混合果蔬汁 +57/2.jpg 农夫果园_混合果蔬汁 +57/3.jpg 农夫果园_混合果蔬汁 +57/4.jpg 农夫果园_混合果蔬汁 +58/0.jpg 佳果源_果蔬汁 +58/1.jpg 佳果源_果蔬汁 +58/2.jpg 佳果源_果蔬汁 +59/0.jpg SUNQUICK/新的_浓缩果汁 +59/1.jpg SUNQUICK/新的_浓缩果汁 +59/2.jpg SUNQUICK/新的_浓缩果汁 +59/3.jpg SUNQUICK/新的_浓缩果汁 +59/4.jpg SUNQUICK/新的_浓缩果汁 +60/0.jpg 维果清_蔬菜汁 +60/1.jpg 维果清_蔬菜汁 +60/2.jpg 维果清_蔬菜汁 +60/3.jpg 维果清_蔬菜汁 +60/4.jpg 维果清_蔬菜汁 +61/0.jpg 宝桑园_果蔬汁 +61/1.jpg 宝桑园_果蔬汁 +61/2.jpg 宝桑园_果蔬汁 +62/0.jpg 千纤_莲藕汁 +62/1.jpg 千纤_莲藕汁 +62/2.jpg 千纤_莲藕汁 +63/0.jpg 玉百味_蔗糖玉米汁 +63/1.jpg 玉百味_蔗糖玉米汁 +63/2.jpg 玉百味_蔗糖玉米汁 +63/3.jpg 玉百味_蔗糖玉米汁 +63/4.jpg 玉百味_蔗糖玉米汁 +64/0.jpg 纯粒源_玉米汁饮料 +64/1.jpg 纯粒源_玉米汁饮料 +65/0.jpg 福兰农庄_纯果汁 +65/1.jpg 福兰农庄_纯果汁 +65/2.jpg 福兰农庄_纯果汁 +65/3.jpg 福兰农庄_纯果汁 +65/4.jpg 福兰农庄_纯果汁 +66/0.jpg 乐源_果蔬汁 +66/1.jpg 乐源_果蔬汁 +66/2.jpg 乐源_果蔬汁 +67/0.jpg 统一_番茄汁 +67/1.jpg 统一_番茄汁 +67/2.jpg 统一_番茄汁 +68/0.jpg 小麦欧耶_0脂肪果蔬汁 +68/1.jpg 小麦欧耶_0脂肪果蔬汁 +68/2.jpg 小麦欧耶_0脂肪果蔬汁 +69/0.jpg VITA_果蔬汁 +69/1.jpg VITA_果蔬汁 +69/2.jpg VITA_果蔬汁 +69/3.jpg VITA_果蔬汁 +69/4.jpg VITA_果蔬汁 +69/5.jpg VITA_果蔬汁 +70/0.jpg 倍优能_黑莓原浆果汁 +71/0.jpg 四季乐活_胡萝卜沙棘汁 +71/1.jpg 四季乐活_胡萝卜沙棘汁 +71/2.jpg 四季乐活_胡萝卜沙棘汁 +72/0.jpg 佐餐时间_不老莓原汁 +72/1.jpg 佐餐时间_不老莓原汁 +72/2.jpg 佐餐时间_不老莓原汁 +72/3.jpg 佐餐时间_不老莓原汁 +72/4.jpg 佐餐时间_不老莓原汁 +73/0.jpg 佐餐时间_山楂汁 +73/1.jpg 佐餐时间_山楂汁 +73/2.jpg 佐餐时间_山楂汁 +73/3.jpg 佐餐时间_山楂汁 +74/0.jpg 阳光味道_桑葚汁 +74/1.jpg 阳光味道_桑葚汁 +74/2.jpg 阳光味道_桑葚汁 +75/0.jpg 乐天_葡萄汁 +75/1.jpg 乐天_葡萄汁 +75/2.jpg 乐天_葡萄汁 +75/3.jpg 乐天_葡萄汁 +76/0.jpg 乐天_芒果汁 +76/1.jpg 乐天_芒果汁 +76/2.jpg 乐天_芒果汁 +77/0.jpg 树丫_桔梗梨汁 +77/1.jpg 树丫_桔梗梨汁 +77/2.jpg 树丫_桔梗梨汁 +77/3.jpg 树丫_桔梗梨汁 +77/4.jpg 树丫_桔梗梨汁 +78/0.jpg 成有王记_冰杨梅汁 +79/0.jpg 蓝宝氏_野生蓝莓果肉饮料 +79/1.jpg 蓝宝氏_野生蓝莓果肉饮料 +79/2.jpg 蓝宝氏_野生蓝莓果肉饮料 +80/0.jpg 蓝宝氏_沙棘果肉饮料 +80/1.jpg 蓝宝氏_沙棘果肉饮料 +80/2.jpg 蓝宝氏_沙棘果肉饮料 +80/3.jpg 蓝宝氏_沙棘果肉饮料 +80/4.jpg 蓝宝氏_沙棘果肉饮料 +80/5.jpg 蓝宝氏_沙棘果肉饮料 +80/6.jpg 蓝宝氏_沙棘果肉饮料 +81/0.jpg 雪菲力盐汽水 +81/1.jpg 雪菲力盐汽水 +81/2.jpg 雪菲力盐汽水 +81/3.jpg 雪菲力盐汽水 +82/0.jpg 雪碧 +82/1.jpg 雪碧 +82/2.jpg 雪碧 +82/3.jpg 雪碧 +82/4.jpg 雪碧 +83/0.jpg 芬达 +83/1.jpg 芬达 +83/2.jpg 芬达 +83/3.jpg 芬达 +83/4.jpg 芬达 +83/5.jpg 芬达 +84/0.jpg 美年达 +84/1.jpg 美年达 +84/2.jpg 美年达 +84/3.jpg 美年达 +84/4.jpg 美年达 +84/5.jpg 美年达 +84/6.jpg 美年达 +85/0.jpg 秋林大白梨 +85/1.jpg 秋林大白梨 +85/2.jpg 秋林大白梨 +85/3.jpg 秋林大白梨 +85/4.jpg 秋林大白梨 +86/0.jpg 百事可乐 +86/1.jpg 百事可乐 +86/2.jpg 百事可乐 +86/3.jpg 百事可乐 +86/4.jpg 百事可乐 +86/5.jpg 百事可乐 +87/0.jpg 珍珍菠萝啤 +87/1.jpg 珍珍菠萝啤 +87/2.jpg 珍珍菠萝啤 +87/3.jpg 珍珍菠萝啤 +88/0.jpg 珍珍荔枝味汽水 +88/1.jpg 珍珍荔枝味汽水 +88/2.jpg 珍珍荔枝味汽水 +88/3.jpg 珍珍荔枝味汽水 +88/4.jpg 珍珍荔枝味汽水 +88/5.jpg 珍珍荔枝味汽水 +88/6.jpg 珍珍荔枝味汽水 +88/7.jpg 珍珍荔枝味汽水 +89/0.jpg 珍啵乐果味汽水 +89/1.jpg 珍啵乐果味汽水 +89/2.jpg 珍啵乐果味汽水 +89/3.jpg 珍啵乐果味汽水 +90/0.jpg 汉斯香橙果味饮料 +90/1.jpg 汉斯香橙果味饮料 +90/2.jpg 汉斯香橙果味饮料 +90/3.jpg 汉斯香橙果味饮料 +90/4.jpg 汉斯香橙果味饮料 +91/0.jpg 汉斯菠萝啤 +91/1.jpg 汉斯菠萝啤 +91/2.jpg 汉斯菠萝啤 +91/3.jpg 汉斯菠萝啤 +91/4.jpg 汉斯菠萝啤 +92/0.jpg 汉口二厂 +92/1.jpg 汉口二厂 +92/2.jpg 汉口二厂 +92/3.jpg 汉口二厂 +92/4.jpg 汉口二厂 +93/0.jpg 果子熟了苏打气泡水 +93/1.jpg 果子熟了苏打气泡水 +93/2.jpg 果子熟了苏打气泡水 +93/3.jpg 果子熟了苏打气泡水 +93/4.jpg 果子熟了苏打气泡水 +93/5.jpg 果子熟了苏打气泡水 +94/0.jpg 怡泉 +94/1.jpg 怡泉 +94/2.jpg 怡泉 +94/3.jpg 怡泉 +94/4.jpg 怡泉 +95/0.jpg 延中盐汽水 +95/1.jpg 延中盐汽水 +95/2.jpg 延中盐汽水 +95/3.jpg 延中盐汽水 +95/4.jpg 延中盐汽水 +96/0.jpg 延中乌梅味汽水 +96/1.jpg 延中乌梅味汽水 +96/2.jpg 延中乌梅味汽水 +96/3.jpg 延中乌梅味汽水 +96/4.jpg 延中乌梅味汽水 +97/0.jpg 巴黎水 +97/1.jpg 巴黎水 +97/2.jpg 巴黎水 +97/3.jpg 巴黎水 +97/4.jpg 巴黎水 +98/0.jpg 崂山可乐 +98/1.jpg 崂山可乐 +98/2.jpg 崂山可乐 +98/3.jpg 崂山可乐 +98/4.jpg 崂山可乐 +99/0.jpg 山海关桔汁汽水 +99/1.jpg 山海关桔汁汽水 +99/2.jpg 山海关桔汁汽水 +99/3.jpg 山海关桔汁汽水 +99/4.jpg 山海关桔汁汽水 +100/0.jpg 屈臣氏汤力苏打汽水 +100/1.jpg 屈臣氏汤力苏打汽水 +100/2.jpg 屈臣氏汤力苏打汽水 +100/3.jpg 屈臣氏汤力苏打汽水 +100/4.jpg 屈臣氏汤力苏打汽水 +100/5.jpg 屈臣氏汤力苏打汽水 +101/0.jpg 宾得宝 +101/1.jpg 宾得宝 +101/2.jpg 宾得宝 +101/3.jpg 宾得宝 +101/4.jpg 宾得宝 +101/5.jpg 宾得宝 +101/6.jpg 宾得宝 +101/7.jpg 宾得宝 +102/0.jpg 宏宝莱 +102/1.jpg 宏宝莱 +102/2.jpg 宏宝莱 +102/3.jpg 宏宝莱 +102/4.jpg 宏宝莱 +103/0.jpg 大窑嘉宾 +103/1.jpg 大窑嘉宾 +103/2.jpg 大窑嘉宾 +103/3.jpg 大窑嘉宾 +103/4.jpg 大窑嘉宾 +103/5.jpg 大窑嘉宾 +103/6.jpg 大窑嘉宾 +103/7.jpg 大窑嘉宾 +104/0.jpg 大洋玛盐汽水 +104/1.jpg 大洋玛盐汽水 +104/2.jpg 大洋玛盐汽水 +104/3.jpg 大洋玛盐汽水 +104/4.jpg 大洋玛盐汽水 +104/5.jpg 大洋玛盐汽水 +104/6.jpg 大洋玛盐汽水 +105/0.jpg 圣碧涛 +105/1.jpg 圣碧涛 +105/2.jpg 圣碧涛 +105/3.jpg 圣碧涛 +105/4.jpg 圣碧涛 +105/5.jpg 圣碧涛 +105/6.jpg 圣碧涛 +106/0.jpg 圣培露 +106/1.jpg 圣培露 +106/2.jpg 圣培露 +106/3.jpg 圣培露 +106/4.jpg 圣培露 +107/0.jpg 喜茶无糖气泡水 +107/1.jpg 喜茶无糖气泡水 +107/2.jpg 喜茶无糖气泡水 +107/3.jpg 喜茶无糖气泡水 +107/4.jpg 喜茶无糖气泡水 +107/5.jpg 喜茶无糖气泡水 +108/0.jpg 哈塔弹珠汽水 +108/1.jpg 哈塔弹珠汽水 +108/2.jpg 哈塔弹珠汽水 +108/3.jpg 哈塔弹珠汽水 +108/4.jpg 哈塔弹珠汽水 +109/0.jpg 可口可乐 +109/1.jpg 可口可乐 +109/2.jpg 可口可乐 +109/3.jpg 可口可乐 +109/4.jpg 可口可乐 +109/5.jpg 可口可乐 +109/6.jpg 可口可乐 +109/7.jpg 可口可乐 +110/0.jpg 华洋汽水 +110/1.jpg 华洋汽水 +110/2.jpg 华洋汽水 +110/3.jpg 华洋汽水 +110/4.jpg 华洋汽水 +110/5.jpg 华洋汽水 +110/6.jpg 华洋汽水 +110/7.jpg 华洋汽水 +111/0.jpg 北冰洋 +111/1.jpg 北冰洋 +111/2.jpg 北冰洋 +111/3.jpg 北冰洋 +111/4.jpg 北冰洋 +111/5.jpg 北冰洋 +111/6.jpg 北冰洋 +111/7.jpg 北冰洋 +111/8.jpg 北冰洋 +111/9.jpg 北冰洋 +112/0.jpg 冰峰 +112/1.jpg 冰峰 +112/2.jpg 冰峰 +112/3.jpg 冰峰 +112/4.jpg 冰峰 +112/5.jpg 冰峰 +112/6.jpg 冰峰 +113/0.jpg 农夫山泉苏打气泡水 +113/1.jpg 农夫山泉苏打气泡水 +113/2.jpg 农夫山泉苏打气泡水 +113/3.jpg 农夫山泉苏打气泡水 +113/4.jpg 农夫山泉苏打气泡水 +113/5.jpg 农夫山泉苏打气泡水 +114/0.jpg 元气森林 +114/1.jpg 元气森林 +114/2.jpg 元气森林 +114/3.jpg 元气森林 +114/4.jpg 元气森林 +114/5.jpg 元气森林 +114/6.jpg 元气森林 +115/0.jpg 健力宝 +115/1.jpg 健力宝 +115/2.jpg 健力宝 +115/3.jpg 健力宝 +115/4.jpg 健力宝 +115/5.jpg 健力宝 +115/6.jpg 健力宝 +115/7.jpg 健力宝 +116/0.jpg 亚洲汽水 +116/1.jpg 亚洲汽水 +116/2.jpg 亚洲汽水 +116/3.jpg 亚洲汽水 +116/4.jpg 亚洲汽水 +116/5.jpg 亚洲汽水 +117/0.jpg 乐天妙之吻 +117/1.jpg 乐天妙之吻 +117/2.jpg 乐天妙之吻 +117/3.jpg 乐天妙之吻 +118/0.jpg 三麟大象苏打气泡水 +118/1.jpg 三麟大象苏打气泡水 +118/2.jpg 三麟大象苏打气泡水 +118/3.jpg 三麟大象苏打气泡水 +119/0.jpg 七喜 +119/1.jpg 七喜 +119/2.jpg 七喜 +119/3.jpg 七喜 +119/4.jpg 七喜 +120/0.jpg 统一冰红茶 +120/1.jpg 统一冰红茶 +120/2.jpg 统一冰红茶 +120/3.jpg 统一冰红茶 +121/0.jpg 维他柠檬茶 +121/1.jpg 维他柠檬茶 +121/2.jpg 维他柠檬茶 +121/3.jpg 维他柠檬茶 +122/0.jpg 维他无糖茶 +122/1.jpg 维他无糖茶 +122/2.jpg 维他无糖茶 +123/0.jpg 达利园青梅绿茶 +123/1.jpg 达利园青梅绿茶 +123/2.jpg 达利园青梅绿茶 +123/3.jpg 达利园青梅绿茶 +123/4.jpg 达利园青梅绿茶 +123/5.jpg 达利园青梅绿茶 +124/0.jpg 伊藤园绿茶 +124/1.jpg 伊藤园绿茶 +124/2.jpg 伊藤园绿茶 +124/3.jpg 伊藤园绿茶 +124/4.jpg 伊藤园绿茶 +124/5.jpg 伊藤园绿茶 +125/0.jpg 伊藤园纤维乌龙茶 +125/1.jpg 伊藤园纤维乌龙茶 +125/2.jpg 伊藤园纤维乌龙茶 +125/3.jpg 伊藤园纤维乌龙茶 +125/4.jpg 伊藤园纤维乌龙茶 +126/0.jpg 伊藤园大麦茶 +126/1.jpg 伊藤园大麦茶 +126/2.jpg 伊藤园大麦茶 +126/3.jpg 伊藤园大麦茶 +126/4.jpg 伊藤园大麦茶 +127/0.jpg 伊藤园蜜桃红茶 +127/1.jpg 伊藤园蜜桃红茶 +127/2.jpg 伊藤园蜜桃红茶 +127/3.jpg 伊藤园蜜桃红茶 +128/0.jpg 伊藤园柠檬红茶 +128/1.jpg 伊藤园柠檬红茶 +128/2.jpg 伊藤园柠檬红茶 +128/3.jpg 伊藤园柠檬红茶 +129/0.jpg 伊藤园茉莉白茶 +129/1.jpg 伊藤园茉莉白茶 +129/2.jpg 伊藤园茉莉白茶 +129/3.jpg 伊藤园茉莉白茶 +129/4.jpg 伊藤园茉莉白茶 +129/5.jpg 伊藤园茉莉白茶 +130/0.jpg 伊藤园铁观音 +130/1.jpg 伊藤园铁观音 +130/2.jpg 伊藤园铁观音 +130/3.jpg 伊藤园铁观音 +131/0.jpg 统一绿茶 +131/1.jpg 统一绿茶 +131/2.jpg 统一绿茶 +131/3.jpg 统一绿茶 +131/4.jpg 统一绿茶 +131/5.jpg 统一绿茶 +131/6.jpg 统一绿茶 +131/7.jpg 统一绿茶 +132/0.jpg 伊藤园浓味乌龙茶 +132/1.jpg 伊藤园浓味乌龙茶 +132/2.jpg 伊藤园浓味乌龙茶 +132/3.jpg 伊藤园浓味乌龙茶 +132/4.jpg 伊藤园浓味乌龙茶 +133/0.jpg 伊藤园浓味绿茶 +133/1.jpg 伊藤园浓味绿茶 +133/2.jpg 伊藤园浓味绿茶 +133/3.jpg 伊藤园浓味绿茶 +133/4.jpg 伊藤园浓味绿茶 +133/5.jpg 伊藤园浓味绿茶 +134/0.jpg 统一茶里王 +134/1.jpg 统一茶里王 +134/2.jpg 统一茶里王 +134/3.jpg 统一茶里王 +135/0.jpg 雀巢茶萃 +135/1.jpg 雀巢茶萃 +135/2.jpg 雀巢茶萃 +135/3.jpg 雀巢茶萃 +135/4.jpg 雀巢茶萃 +135/5.jpg 雀巢茶萃 +135/6.jpg 雀巢茶萃 +136/0.jpg 康师傅茉莉蜜茶 +136/1.jpg 康师傅茉莉蜜茶 +136/2.jpg 康师傅茉莉蜜茶 +136/3.jpg 康师傅茉莉蜜茶 +136/4.jpg 康师傅茉莉蜜茶 +136/5.jpg 康师傅茉莉蜜茶 +137/0.jpg 康师傅茉莉清茶 +137/1.jpg 康师傅茉莉清茶 +137/2.jpg 康师傅茉莉清茶 +137/3.jpg 康师傅茉莉清茶 +137/4.jpg 康师傅茉莉清茶 +137/5.jpg 康师傅茉莉清茶 +138/0.jpg 康师傅茉莉花茶 +138/1.jpg 康师傅茉莉花茶 +138/2.jpg 康师傅茉莉花茶 +138/3.jpg 康师傅茉莉花茶 +138/4.jpg 康师傅茉莉花茶 +138/5.jpg 康师傅茉莉花茶 +138/6.jpg 康师傅茉莉花茶 +139/0.jpg 康师傅冷泡绿茶 +139/1.jpg 康师傅冷泡绿茶 +139/2.jpg 康师傅冷泡绿茶 +139/3.jpg 康师傅冷泡绿茶 +139/4.jpg 康师傅冷泡绿茶 +139/5.jpg 康师傅冷泡绿茶 +140/0.jpg 三得利乌龙茶 +140/1.jpg 三得利乌龙茶 +140/2.jpg 三得利乌龙茶 +140/3.jpg 三得利乌龙茶 +140/4.jpg 三得利乌龙茶 +140/5.jpg 三得利乌龙茶 +141/0.jpg 元气森林燃茶 +141/1.jpg 元气森林燃茶 +141/2.jpg 元气森林燃茶 +141/3.jpg 元气森林燃茶 +142/0.jpg 康师傅冰红茶 +142/1.jpg 康师傅冰红茶 +142/2.jpg 康师傅冰红茶 +142/3.jpg 康师傅冰红茶 +142/4.jpg 康师傅冰红茶 +143/0.jpg 三得利果瀑茶 +143/1.jpg 三得利果瀑茶 +143/2.jpg 三得利果瀑茶 +143/3.jpg 三得利果瀑茶 +143/4.jpg 三得利果瀑茶 +143/5.jpg 三得利果瀑茶 +144/0.jpg 喜茶_轻乳茶 +144/1.jpg 喜茶_轻乳茶 +144/2.jpg 喜茶_轻乳茶 +144/3.jpg 喜茶_轻乳茶 +144/4.jpg 喜茶_轻乳茶 +144/5.jpg 喜茶_轻乳茶 +145/0.jpg 麟珑茶室大麦爽茶 +145/1.jpg 麟珑茶室大麦爽茶 +145/2.jpg 麟珑茶室大麦爽茶 +145/3.jpg 麟珑茶室大麦爽茶 +145/4.jpg 麟珑茶室大麦爽茶 +145/5.jpg 麟珑茶室大麦爽茶 +146/0.jpg 麟珑茶室大人茶 +146/1.jpg 麟珑茶室大人茶 +146/2.jpg 麟珑茶室大人茶 +146/3.jpg 麟珑茶室大人茶 +147/0.jpg 麟珑茶室每天绿茶 +147/1.jpg 麟珑茶室每天绿茶 +147/2.jpg 麟珑茶室每天绿茶 +147/3.jpg 麟珑茶室每天绿茶 +147/4.jpg 麟珑茶室每天绿茶 +147/5.jpg 麟珑茶室每天绿茶 +148/0.jpg 麟珑茶室茉莉轻茶 +148/1.jpg 麟珑茶室茉莉轻茶 +148/2.jpg 麟珑茶室茉莉轻茶 +148/3.jpg 麟珑茶室茉莉轻茶 +149/0.jpg 和其正凉茶 +149/1.jpg 和其正凉茶 +149/2.jpg 和其正凉茶 +149/3.jpg 和其正凉茶 +150/0.jpg 王老吉凉茶 +150/1.jpg 王老吉凉茶 +150/2.jpg 王老吉凉茶 +150/3.jpg 王老吉凉茶 +150/4.jpg 王老吉凉茶 +151/0.jpg 加多宝 +151/1.jpg 加多宝 +151/2.jpg 加多宝 +151/3.jpg 加多宝 +152/0.jpg 统一阿萨姆奶茶 +152/1.jpg 统一阿萨姆奶茶 +152/2.jpg 统一阿萨姆奶茶 +152/3.jpg 统一阿萨姆奶茶 +152/4.jpg 统一阿萨姆奶茶 +152/5.jpg 统一阿萨姆奶茶 +153/0.jpg 康师傅绿茶 +153/1.jpg 康师傅绿茶 +153/2.jpg 康师傅绿茶 +153/3.jpg 康师傅绿茶 +153/4.jpg 康师傅绿茶 +153/5.jpg 康师傅绿茶 +154/0.jpg 农夫山泉打奶茶 +154/1.jpg 农夫山泉打奶茶 +154/2.jpg 农夫山泉打奶茶 +154/3.jpg 农夫山泉打奶茶 +155/0.jpg 麒麟午后奶茶 +155/1.jpg 麒麟午后奶茶 +155/2.jpg 麒麟午后奶茶 +155/3.jpg 麒麟午后奶茶 +155/4.jpg 麒麟午后奶茶 +156/0.jpg 康师傅奶茶 +156/1.jpg 康师傅奶茶 +156/2.jpg 康师傅奶茶 +156/3.jpg 康师傅奶茶 +157/0.jpg 可口可乐淳茶舍 +157/1.jpg 可口可乐淳茶舍 +157/2.jpg 可口可乐淳茶舍 +157/3.jpg 可口可乐淳茶舍 +157/4.jpg 可口可乐淳茶舍 +157/5.jpg 可口可乐淳茶舍 +158/0.jpg 元气森林纤茶 +158/1.jpg 元气森林纤茶 +158/2.jpg 元气森林纤茶 +158/3.jpg 元气森林纤茶 +158/4.jpg 元气森林纤茶 +158/5.jpg 元气森林纤茶 +159/0.jpg 雀巢咖啡 +159/1.jpg 雀巢咖啡 +159/2.jpg 雀巢咖啡 +159/3.jpg 雀巢咖啡 +160/0.jpg 雀巢冷萃咖啡 +160/1.jpg 雀巢冷萃咖啡 +160/2.jpg 雀巢冷萃咖啡 +160/3.jpg 雀巢冷萃咖啡 +160/4.jpg 雀巢冷萃咖啡 +160/5.jpg 雀巢冷萃咖啡 +161/0.jpg 星巴克派克市场 +161/1.jpg 星巴克派克市场 +161/2.jpg 星巴克派克市场 +161/3.jpg 星巴克派克市场 +162/0.jpg 星巴克星倍醇咖啡 +162/1.jpg 星巴克星倍醇咖啡 +162/2.jpg 星巴克星倍醇咖啡 +162/3.jpg 星巴克星倍醇咖啡 +163/0.jpg 星巴克星选咖啡 +163/1.jpg 星巴克星选咖啡 +163/2.jpg 星巴克星选咖啡 +163/3.jpg 星巴克星选咖啡 +164/0.jpg 康师傅冰绿茶 +164/1.jpg 康师傅冰绿茶 +164/2.jpg 康师傅冰绿茶 +164/3.jpg 康师傅冰绿茶 +164/4.jpg 康师傅冰绿茶 +164/5.jpg 康师傅冰绿茶 +164/6.jpg 康师傅冰绿茶 +164/7.jpg 康师傅冰绿茶 +164/8.jpg 康师傅冰绿茶 +164/9.jpg 康师傅冰绿茶 +164/10.jpg 康师傅冰绿茶 +165/0.jpg 星巴克星冰乐咖啡 +165/1.jpg 星巴克星冰乐咖啡 +165/2.jpg 星巴克星冰乐咖啡 +165/3.jpg 星巴克星冰乐咖啡 +166/0.jpg costa咖啡 +166/1.jpg costa咖啡 +166/2.jpg costa咖啡 +166/3.jpg costa咖啡 +166/4.jpg costa咖啡 +166/5.jpg costa咖啡 +167/0.jpg 统一雅哈咖啡 +167/1.jpg 统一雅哈咖啡 +167/2.jpg 统一雅哈咖啡 +167/3.jpg 统一雅哈咖啡 +168/0.jpg 麒麟火咖 +168/1.jpg 麒麟火咖 +168/2.jpg 麒麟火咖 +168/3.jpg 麒麟火咖 +168/4.jpg 麒麟火咖 +168/5.jpg 麒麟火咖 +169/0.jpg 农夫山泉炭仌咖啡 +169/1.jpg 农夫山泉炭仌咖啡 +169/2.jpg 农夫山泉炭仌咖啡 +169/3.jpg 农夫山泉炭仌咖啡 +169/4.jpg 农夫山泉炭仌咖啡 +169/5.jpg 农夫山泉炭仌咖啡 +170/0.jpg 味全贝纳颂 +170/1.jpg 味全贝纳颂 +170/2.jpg 味全贝纳颂 +170/3.jpg 味全贝纳颂 +170/4.jpg 味全贝纳颂 +171/0.jpg 康师傅青梅绿茶 +171/1.jpg 康师傅青梅绿茶 +171/2.jpg 康师傅青梅绿茶 +171/3.jpg 康师傅青梅绿茶 +171/4.jpg 康师傅青梅绿茶 +171/5.jpg 康师傅青梅绿茶 +171/6.jpg 康师傅青梅绿茶 +172/0.jpg 东方树叶红茶/玄米茶/绿茶… +172/1.jpg 东方树叶红茶/玄米茶/绿茶… +172/2.jpg 东方树叶红茶/玄米茶/绿茶… +172/3.jpg 东方树叶红茶/玄米茶/绿茶… +172/4.jpg 东方树叶红茶/玄米茶/绿茶… +173/0.jpg 茶π +173/1.jpg 茶π +173/2.jpg 茶π +173/3.jpg 茶π +173/4.jpg 茶π +173/5.jpg 茶π +173/6.jpg 茶π +173/7.jpg 茶π +174/0.jpg 小茗同学 +174/1.jpg 小茗同学 +174/2.jpg 小茗同学 +174/3.jpg 小茗同学 +174/4.jpg 小茗同学 +175/0.jpg 蒙牛_纯甄 +175/1.jpg 蒙牛_纯甄 +175/2.jpg 蒙牛_纯甄 +175/3.jpg 蒙牛_纯甄 +176/0.jpg 蒙牛_未来星 +176/1.jpg 蒙牛_未来星 +176/2.jpg 蒙牛_未来星 +177/0.jpg 蒙牛_真果粒 +177/1.jpg 蒙牛_真果粒 +177/2.jpg 蒙牛_真果粒 +177/3.jpg 蒙牛_真果粒 +177/4.jpg 蒙牛_真果粒 +178/0.jpg 蒙牛_精选牧场 +178/1.jpg 蒙牛_精选牧场 +178/2.jpg 蒙牛_精选牧场 +178/3.jpg 蒙牛_精选牧场 +178/4.jpg 蒙牛_精选牧场 +178/5.jpg 蒙牛_精选牧场 +179/0.jpg 蒙牛_酸酸乳 +179/1.jpg 蒙牛_酸酸乳 +179/2.jpg 蒙牛_酸酸乳 +179/3.jpg 蒙牛_酸酸乳 +180/0.jpg 蒙牛_特仑苏 +180/1.jpg 蒙牛_特仑苏 +180/2.jpg 蒙牛_特仑苏 +180/3.jpg 蒙牛_特仑苏 +180/4.jpg 蒙牛_特仑苏 +180/5.jpg 蒙牛_特仑苏 +181/0.jpg 蒙牛_新养道 +181/1.jpg 蒙牛_新养道 +181/2.jpg 蒙牛_新养道 +181/3.jpg 蒙牛_新养道 +181/4.jpg 蒙牛_新养道 +182/0.jpg 蒙牛_早餐奶 +182/1.jpg 蒙牛_早餐奶 +182/2.jpg 蒙牛_早餐奶 +182/3.jpg 蒙牛_早餐奶 +182/4.jpg 蒙牛_早餐奶 +182/5.jpg 蒙牛_早餐奶 +183/0.jpg 飞鹤_甄爱倍护 +183/1.jpg 飞鹤_甄爱倍护 +183/2.jpg 飞鹤_甄爱倍护 +183/3.jpg 飞鹤_甄爱倍护 +183/4.jpg 飞鹤_甄爱倍护 +184/0.jpg 飞鹤_茁然 +184/1.jpg 飞鹤_茁然 +184/2.jpg 飞鹤_茁然 +184/3.jpg 飞鹤_茁然 +184/4.jpg 飞鹤_茁然 +185/0.jpg 飞鹤_星飞帆 +185/1.jpg 飞鹤_星飞帆 +185/2.jpg 飞鹤_星飞帆 +185/3.jpg 飞鹤_星飞帆 +185/4.jpg 飞鹤_星飞帆 +185/5.jpg 飞鹤_星飞帆 +186/0.jpg 伊利_畅意 +186/1.jpg 伊利_畅意 +187/0.jpg 伊利_舒化 +187/1.jpg 伊利_舒化 +187/2.jpg 伊利_舒化 +187/3.jpg 伊利_舒化 +187/4.jpg 伊利_舒化 +187/5.jpg 伊利_舒化 +188/0.jpg 伊利_金典 +188/1.jpg 伊利_金典 +188/2.jpg 伊利_金典 +188/3.jpg 伊利_金典 +188/4.jpg 伊利_金典 +189/0.jpg 伊利_优酸乳 +189/1.jpg 伊利_优酸乳 +190/0.jpg 伊利_谷粒多 +190/1.jpg 伊利_谷粒多 +190/2.jpg 伊利_谷粒多 +190/3.jpg 伊利_谷粒多 +191/0.jpg 伊利_QQ星 +191/1.jpg 伊利_QQ星 +191/2.jpg 伊利_QQ星 +191/3.jpg 伊利_QQ星 +192/0.jpg 伊利_学生奶 +192/1.jpg 伊利_学生奶 +192/2.jpg 伊利_学生奶 +192/3.jpg 伊利_学生奶 +192/4.jpg 伊利_学生奶 +193/0.jpg 伊利_植选 +193/1.jpg 伊利_植选 +193/2.jpg 伊利_植选 +193/3.jpg 伊利_植选 +193/4.jpg 伊利_植选 +193/5.jpg 伊利_植选 +194/0.jpg 伊利_核桃乳 +194/1.jpg 伊利_核桃乳 +194/2.jpg 伊利_核桃乳 +194/3.jpg 伊利_核桃乳 +195/0.jpg 伊利_安慕希 +195/1.jpg 伊利_安慕希 +196/0.jpg 伊利_味可滋 +196/1.jpg 伊利_味可滋 +196/2.jpg 伊利_味可滋 +196/3.jpg 伊利_味可滋 diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/drink_label_all.txt b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/drink_label_all.txt new file mode 100644 index 0000000..9835f41 --- /dev/null +++ b/src/PaddleClas/deploy/drink_dataset_v1.0/gallery/drink_label_all.txt @@ -0,0 +1,1068 @@ +0/0.jpg 脉动 +0/1.jpg 脉动 +0/2.jpg 脉动 +0/3.jpg 脉动 +1/0.jpg 红牛 +1/1.jpg 红牛 +1/2.jpg 红牛 +1/3.jpg 红牛 +1/4.jpg 红牛 +2/0.jpg 战马 +2/1.jpg 战马 +2/2.jpg 战马 +2/3.jpg 战马 +2/4.jpg 战马 +2/5.jpg 战马 +2/6.jpg 战马 +3/0.jpg 尖叫 +3/1.jpg 尖叫 +3/2.jpg 尖叫 +3/3.jpg 尖叫 +4/0.jpg 启力 +4/1.jpg 启力 +4/2.jpg 启力 +4/3.jpg 启力 +4/4.jpg 启力 +4/5.jpg 启力 +4/6.jpg 启力 +5/0.jpg 乐虎氨基酸维生素功能饮料 +5/1.jpg 乐虎氨基酸维生素功能饮料 +5/2.jpg 乐虎氨基酸维生素功能饮料 +5/3.jpg 乐虎氨基酸维生素功能饮料 +5/4.jpg 乐虎氨基酸维生素功能饮料 +6/0.jpg 日加满氨基酸功能饮料 +6/1.jpg 日加满氨基酸功能饮料 +6/2.jpg 日加满氨基酸功能饮料 +6/3.jpg 日加满氨基酸功能饮料 +6/4.jpg 日加满氨基酸功能饮料 +7/0.jpg 力克 +7/1.jpg 力克 +7/2.jpg 力克 +7/3.jpg 力克 +7/4.jpg 力克 +7/5.jpg 力克 +7/6.jpg 力克 +8/0.jpg 芙丝饮用天然水 +8/1.jpg 芙丝饮用天然水 +8/2.jpg 芙丝饮用天然水 +8/3.jpg 芙丝饮用天然水 +8/4.jpg 芙丝饮用天然水 +9/0.jpg 康师傅矿物质水 +9/1.jpg 康师傅矿物质水 +9/2.jpg 康师傅矿物质水 +9/3.jpg 康师傅矿物质水 +9/4.jpg 康师傅矿物质水 +10/0.jpg 依云天然矿泉水 +10/1.jpg 依云天然矿泉水 +10/2.jpg 依云天然矿泉水 +10/3.jpg 依云天然矿泉水 +10/4.jpg 依云天然矿泉水 +10/5.jpg 依云天然矿泉水 +11/0.jpg 魔爪能量饮料 +11/1.jpg 魔爪能量饮料 +11/2.jpg 魔爪能量饮料 +11/3.jpg 魔爪能量饮料 +11/4.jpg 魔爪能量饮料 +11/5.jpg 魔爪能量饮料 +12/0.jpg 汇多滋淡盐水 +12/1.jpg 汇多滋淡盐水 +12/2.jpg 汇多滋淡盐水 +13/0.jpg 普娜天然泉水 +13/1.jpg 普娜天然泉水 +13/2.jpg 普娜天然泉水 +13/3.jpg 普娜天然泉水 +13/4.jpg 普娜天然泉水 +14/0.jpg 乐虎功能饮料 +14/1.jpg 乐虎功能饮料 +14/2.jpg 乐虎功能饮料 +14/3.jpg 乐虎功能饮料 +14/4.jpg 乐虎功能饮料 +14/5.jpg 乐虎功能饮料 +15/0.jpg 宝矿力水特 +15/1.jpg 宝矿力水特 +15/2.jpg 宝矿力水特 +15/3.jpg 宝矿力水特 +15/4.jpg 宝矿力水特 +16/0.jpg 阿尔卑斯-天然苏打水 +16/1.jpg 阿尔卑斯-天然苏打水 +16/2.jpg 阿尔卑斯-天然苏打水 +16/3.jpg 阿尔卑斯-天然苏打水 +17/0.jpg 农夫山泉-饮用天然水 +17/1.jpg 农夫山泉-饮用天然水 +17/2.jpg 农夫山泉-饮用天然水 +17/3.jpg 农夫山泉-饮用天然水 +17/4.jpg 农夫山泉-饮用天然水 +17/5.jpg 农夫山泉-饮用天然水 +17/6.jpg 农夫山泉-饮用天然水 +18/0.jpg 碱LOVE +18/1.jpg 碱LOVE +18/2.jpg 碱LOVE +18/3.jpg 碱LOVE +18/4.jpg 碱LOVE +19/0.jpg 农夫山泉-天然矿泉水 +19/1.jpg 农夫山泉-天然矿泉水 +19/2.jpg 农夫山泉-天然矿泉水 +19/3.jpg 农夫山泉-天然矿泉水 +19/4.jpg 农夫山泉-天然矿泉水 +20/0.jpg 农夫山泉-泡茶水 +20/1.jpg 农夫山泉-泡茶水 +20/2.jpg 农夫山泉-泡茶水 +20/3.jpg 农夫山泉-泡茶水 +20/4.jpg 农夫山泉-泡茶水 +21/0.jpg 等渗尖叫 +21/1.jpg 等渗尖叫 +21/2.jpg 等渗尖叫 +21/3.jpg 等渗尖叫 +21/4.jpg 等渗尖叫 +22/0.jpg 恒大冰泉 +22/1.jpg 恒大冰泉 +22/2.jpg 恒大冰泉 +22/3.jpg 恒大冰泉 +23/0.jpg 优珍能量 +23/1.jpg 优珍能量 +23/2.jpg 优珍能量 +23/3.jpg 优珍能量 +23/4.jpg 优珍能量 +24/0.jpg 东鹏特饮 +24/1.jpg 东鹏特饮 +24/2.jpg 东鹏特饮 +24/3.jpg 东鹏特饮 +25/0.jpg 纯水乐 +25/1.jpg 纯水乐 +25/2.jpg 纯水乐 +25/3.jpg 纯水乐 +25/4.jpg 纯水乐 +26/0.jpg 白山水 +26/1.jpg 白山水 +26/2.jpg 白山水 +26/3.jpg 白山水 +26/4.jpg 白山水 +27/0.jpg 水动乐 +27/1.jpg 水动乐 +27/2.jpg 水动乐 +27/3.jpg 水动乐 +27/4.jpg 水动乐 +28/0.jpg F6能量饮品 +28/1.jpg F6能量饮品 +28/2.jpg F6能量饮品 +28/3.jpg F6能量饮品 +28/4.jpg F6能量饮品 +29/0.jpg 动益加 +29/1.jpg 动益加 +29/2.jpg 动益加 +29/3.jpg 动益加 +30/0.jpg 凉白开 +30/1.jpg 凉白开 +30/2.jpg 凉白开 +30/3.jpg 凉白开 +30/4.jpg 凉白开 +30/5.jpg 凉白开 +31/0.jpg 佳得乐 +31/1.jpg 佳得乐 +31/2.jpg 佳得乐 +31/3.jpg 佳得乐 +32/0.jpg 三得利 +32/1.jpg 三得利 +32/2.jpg 三得利 +32/3.jpg 三得利 +33/0.jpg 统一-爱夸天然矿泉水 +33/1.jpg 统一-爱夸天然矿泉水 +33/2.jpg 统一-爱夸天然矿泉水 +33/3.jpg 统一-爱夸天然矿泉水 +33/4.jpg 统一-爱夸天然矿泉水 +33/5.jpg 统一-爱夸天然矿泉水 +34/0.jpg 景田-饮用纯净水 +34/1.jpg 景田-饮用纯净水 +34/2.jpg 景田-饮用纯净水 +34/3.jpg 景田-饮用纯净水 +34/4.jpg 景田-饮用纯净水 +34/5.jpg 景田-饮用纯净水 +35/0.jpg 怡宝-魔力氨基酸 +35/1.jpg 怡宝-魔力氨基酸 +35/2.jpg 怡宝-魔力氨基酸 +35/3.jpg 怡宝-魔力氨基酸 +35/4.jpg 怡宝-魔力氨基酸 +36/0.jpg 红牛-强化型 +36/1.jpg 红牛-强化型 +36/2.jpg 红牛-强化型 +36/3.jpg 红牛-强化型 +36/4.jpg 红牛-强化型 +36/5.jpg 红牛-强化型 +37/0.jpg 景田-百岁山 +37/1.jpg 景田-百岁山 +37/2.jpg 景田-百岁山 +37/3.jpg 景田-百岁山 +37/4.jpg 景田-百岁山 +38/0.jpg 雀巢 +38/1.jpg 雀巢 +38/2.jpg 雀巢 +38/3.jpg 雀巢 +38/4.jpg 雀巢 +39/0.jpg 5小时能量饮料 +39/1.jpg 5小时能量饮料 +39/2.jpg 5小时能量饮料 +39/3.jpg 5小时能量饮料 +41/0.jpg 农夫山泉_纯果蔬汁 +41/1.jpg 农夫山泉_纯果蔬汁 +41/2.jpg 农夫山泉_纯果蔬汁 +41/3.jpg 农夫山泉_纯果蔬汁 +42/0.jpg GINNAI/神内_低聚糖代餐果汁 +42/1.jpg GINNAI/神内_低聚糖代餐果汁 +42/2.jpg GINNAI/神内_低聚糖代餐果汁 +42/3.jpg GINNAI/神内_低聚糖代餐果汁 +42/4.jpg GINNAI/神内_低聚糖代餐果汁 +42/5.jpg GINNAI/神内_低聚糖代餐果汁 +43/0.jpg 贝奇野菜_果汁每日C +43/1.jpg 贝奇野菜_果汁每日C +43/2.jpg 贝奇野菜_果汁每日C +43/3.jpg 贝奇野菜_果汁每日C +43/4.jpg 贝奇野菜_果汁每日C +43/5.jpg 贝奇野菜_果汁每日C +44/0.jpg HeyJuice_西柚饮料果蔬 +44/1.jpg HeyJuice_西柚饮料果蔬 +44/2.jpg HeyJuice_西柚饮料果蔬 +45/0.jpg 沛时Perse_纯蔬果汁 +45/1.jpg 沛时Perse_纯蔬果汁 +45/2.jpg 沛时Perse_纯蔬果汁 +45/3.jpg 沛时Perse_纯蔬果汁 +45/4.jpg 沛时Perse_纯蔬果汁 +46/0.jpg 沛时Perse纯蔬果汁 +46/1.jpg 沛时Perse纯蔬果汁 +46/2.jpg 沛时Perse纯蔬果汁 +46/3.jpg 沛时Perse纯蔬果汁 +46/4.jpg 沛时Perse纯蔬果汁 +47/0.jpg 味全_每日C +47/1.jpg 味全_每日C +47/2.jpg 味全_每日C +47/3.jpg 味全_每日C +47/4.jpg 味全_每日C +47/5.jpg 味全_每日C +47/6.jpg 味全_每日C +47/7.jpg 味全_每日C +48/0.jpg 苏醒汇_纯蔬果汁 +48/1.jpg 苏醒汇_纯蔬果汁 +48/2.jpg 苏醒汇_纯蔬果汁 +49/0.jpg 臻富_番茄汁 +49/1.jpg 臻富_番茄汁 +49/2.jpg 臻富_番茄汁 +50/0.jpg 多乐诗_轻断食果蔬汁 +50/1.jpg 多乐诗_轻断食果蔬汁 +50/2.jpg 多乐诗_轻断食果蔬汁 +50/3.jpg 多乐诗_轻断食果蔬汁 +50/4.jpg 多乐诗_轻断食果蔬汁 +51/0.jpg IF/如果_椰子水饮料 +51/1.jpg IF/如果_椰子水饮料 +51/2.jpg IF/如果_椰子水饮料 +51/3.jpg IF/如果_椰子水饮料 +52/0.jpg 伊藤园_果蔬汁 +52/1.jpg 伊藤园_果蔬汁 +52/2.jpg 伊藤园_果蔬汁 +53/0.jpg 艾璞乐_苦瓜汁 +53/1.jpg 艾璞乐_苦瓜汁 +53/2.jpg 艾璞乐_苦瓜汁 +54/0.jpg 屯河_番茄汁 +54/1.jpg 屯河_番茄汁 +54/2.jpg 屯河_番茄汁 +54/3.jpg 屯河_番茄汁 +54/4.jpg 屯河_番茄汁 +55/0.jpg 屯河_杏汁 +55/1.jpg 屯河_杏汁 +55/2.jpg 屯河_杏汁 +55/3.jpg 屯河_杏汁 +55/4.jpg 屯河_杏汁 +55/5.jpg 屯河_杏汁 +56/0.jpg Sunsweet_西梅汁 +56/1.jpg Sunsweet_西梅汁 +56/2.jpg Sunsweet_西梅汁 +57/0.jpg 农夫果园_混合果蔬汁 +57/1.jpg 农夫果园_混合果蔬汁 +57/2.jpg 农夫果园_混合果蔬汁 +57/3.jpg 农夫果园_混合果蔬汁 +57/4.jpg 农夫果园_混合果蔬汁 +58/0.jpg 佳果源_果蔬汁 +58/1.jpg 佳果源_果蔬汁 +58/2.jpg 佳果源_果蔬汁 +59/0.jpg SUNQUICK/新的_浓缩果汁 +59/1.jpg SUNQUICK/新的_浓缩果汁 +59/2.jpg SUNQUICK/新的_浓缩果汁 +59/3.jpg SUNQUICK/新的_浓缩果汁 +59/4.jpg SUNQUICK/新的_浓缩果汁 +60/0.jpg 维果清_蔬菜汁 +60/1.jpg 维果清_蔬菜汁 +60/2.jpg 维果清_蔬菜汁 +60/3.jpg 维果清_蔬菜汁 +60/4.jpg 维果清_蔬菜汁 +61/0.jpg 宝桑园_果蔬汁 +61/1.jpg 宝桑园_果蔬汁 +61/2.jpg 宝桑园_果蔬汁 +62/0.jpg 千纤_莲藕汁 +62/1.jpg 千纤_莲藕汁 +62/2.jpg 千纤_莲藕汁 +63/0.jpg 玉百味_蔗糖玉米汁 +63/1.jpg 玉百味_蔗糖玉米汁 +63/2.jpg 玉百味_蔗糖玉米汁 +63/3.jpg 玉百味_蔗糖玉米汁 +63/4.jpg 玉百味_蔗糖玉米汁 +64/0.jpg 纯粒源_玉米汁饮料 +64/1.jpg 纯粒源_玉米汁饮料 +65/0.jpg 福兰农庄_纯果汁 +65/1.jpg 福兰农庄_纯果汁 +65/2.jpg 福兰农庄_纯果汁 +65/3.jpg 福兰农庄_纯果汁 +65/4.jpg 福兰农庄_纯果汁 +66/0.jpg 乐源_果蔬汁 +66/1.jpg 乐源_果蔬汁 +66/2.jpg 乐源_果蔬汁 +67/0.jpg 统一_番茄汁 +67/1.jpg 统一_番茄汁 +67/2.jpg 统一_番茄汁 +68/0.jpg 小麦欧耶_0脂肪果蔬汁 +68/1.jpg 小麦欧耶_0脂肪果蔬汁 +68/2.jpg 小麦欧耶_0脂肪果蔬汁 +69/0.jpg VITA_果蔬汁 +69/1.jpg VITA_果蔬汁 +69/2.jpg VITA_果蔬汁 +69/3.jpg VITA_果蔬汁 +69/4.jpg VITA_果蔬汁 +69/5.jpg VITA_果蔬汁 +70/0.jpg 倍优能_黑莓原浆果汁 +71/0.jpg 四季乐活_胡萝卜沙棘汁 +71/1.jpg 四季乐活_胡萝卜沙棘汁 +71/2.jpg 四季乐活_胡萝卜沙棘汁 +72/0.jpg 佐餐时间_不老莓原汁 +72/1.jpg 佐餐时间_不老莓原汁 +72/2.jpg 佐餐时间_不老莓原汁 +72/3.jpg 佐餐时间_不老莓原汁 +72/4.jpg 佐餐时间_不老莓原汁 +73/0.jpg 佐餐时间_山楂汁 +73/1.jpg 佐餐时间_山楂汁 +73/2.jpg 佐餐时间_山楂汁 +73/3.jpg 佐餐时间_山楂汁 +74/0.jpg 阳光味道_桑葚汁 +74/1.jpg 阳光味道_桑葚汁 +74/2.jpg 阳光味道_桑葚汁 +75/0.jpg 乐天_葡萄汁 +75/1.jpg 乐天_葡萄汁 +75/2.jpg 乐天_葡萄汁 +75/3.jpg 乐天_葡萄汁 +76/0.jpg 乐天_芒果汁 +76/1.jpg 乐天_芒果汁 +76/2.jpg 乐天_芒果汁 +77/0.jpg 树丫_桔梗梨汁 +77/1.jpg 树丫_桔梗梨汁 +77/2.jpg 树丫_桔梗梨汁 +77/3.jpg 树丫_桔梗梨汁 +77/4.jpg 树丫_桔梗梨汁 +78/0.jpg 成有王记_冰杨梅汁 +79/0.jpg 蓝宝氏_野生蓝莓果肉饮料 +79/1.jpg 蓝宝氏_野生蓝莓果肉饮料 +79/2.jpg 蓝宝氏_野生蓝莓果肉饮料 +80/0.jpg 蓝宝氏_沙棘果肉饮料 +80/1.jpg 蓝宝氏_沙棘果肉饮料 +80/2.jpg 蓝宝氏_沙棘果肉饮料 +80/3.jpg 蓝宝氏_沙棘果肉饮料 +80/4.jpg 蓝宝氏_沙棘果肉饮料 +80/5.jpg 蓝宝氏_沙棘果肉饮料 +80/6.jpg 蓝宝氏_沙棘果肉饮料 +81/0.jpg 雪菲力盐汽水 +81/1.jpg 雪菲力盐汽水 +81/2.jpg 雪菲力盐汽水 +81/3.jpg 雪菲力盐汽水 +82/0.jpg 雪碧 +82/1.jpg 雪碧 +82/2.jpg 雪碧 +82/3.jpg 雪碧 +82/4.jpg 雪碧 +83/0.jpg 芬达 +83/1.jpg 芬达 +83/2.jpg 芬达 +83/3.jpg 芬达 +83/4.jpg 芬达 +83/5.jpg 芬达 +84/0.jpg 美年达 +84/1.jpg 美年达 +84/2.jpg 美年达 +84/3.jpg 美年达 +84/4.jpg 美年达 +84/5.jpg 美年达 +84/6.jpg 美年达 +85/0.jpg 秋林大白梨 +85/1.jpg 秋林大白梨 +85/2.jpg 秋林大白梨 +85/3.jpg 秋林大白梨 +85/4.jpg 秋林大白梨 +86/0.jpg 百事可乐 +86/1.jpg 百事可乐 +86/2.jpg 百事可乐 +86/3.jpg 百事可乐 +86/4.jpg 百事可乐 +86/5.jpg 百事可乐 +87/0.jpg 珍珍菠萝啤 +87/1.jpg 珍珍菠萝啤 +87/2.jpg 珍珍菠萝啤 +87/3.jpg 珍珍菠萝啤 +88/0.jpg 珍珍荔枝味汽水 +88/1.jpg 珍珍荔枝味汽水 +88/2.jpg 珍珍荔枝味汽水 +88/3.jpg 珍珍荔枝味汽水 +88/4.jpg 珍珍荔枝味汽水 +88/5.jpg 珍珍荔枝味汽水 +88/6.jpg 珍珍荔枝味汽水 +88/7.jpg 珍珍荔枝味汽水 +89/0.jpg 珍啵乐果味汽水 +89/1.jpg 珍啵乐果味汽水 +89/2.jpg 珍啵乐果味汽水 +89/3.jpg 珍啵乐果味汽水 +90/0.jpg 汉斯香橙果味饮料 +90/1.jpg 汉斯香橙果味饮料 +90/2.jpg 汉斯香橙果味饮料 +90/3.jpg 汉斯香橙果味饮料 +90/4.jpg 汉斯香橙果味饮料 +91/0.jpg 汉斯菠萝啤 +91/1.jpg 汉斯菠萝啤 +91/2.jpg 汉斯菠萝啤 +91/3.jpg 汉斯菠萝啤 +91/4.jpg 汉斯菠萝啤 +92/0.jpg 汉口二厂 +92/1.jpg 汉口二厂 +92/2.jpg 汉口二厂 +92/3.jpg 汉口二厂 +92/4.jpg 汉口二厂 +93/0.jpg 果子熟了苏打气泡水 +93/1.jpg 果子熟了苏打气泡水 +93/2.jpg 果子熟了苏打气泡水 +93/3.jpg 果子熟了苏打气泡水 +93/4.jpg 果子熟了苏打气泡水 +93/5.jpg 果子熟了苏打气泡水 +94/0.jpg 怡泉 +94/1.jpg 怡泉 +94/2.jpg 怡泉 +94/3.jpg 怡泉 +94/4.jpg 怡泉 +95/0.jpg 延中盐汽水 +95/1.jpg 延中盐汽水 +95/2.jpg 延中盐汽水 +95/3.jpg 延中盐汽水 +95/4.jpg 延中盐汽水 +96/0.jpg 延中乌梅味汽水 +96/1.jpg 延中乌梅味汽水 +96/2.jpg 延中乌梅味汽水 +96/3.jpg 延中乌梅味汽水 +96/4.jpg 延中乌梅味汽水 +97/0.jpg 巴黎水 +97/1.jpg 巴黎水 +97/2.jpg 巴黎水 +97/3.jpg 巴黎水 +97/4.jpg 巴黎水 +98/0.jpg 崂山可乐 +98/1.jpg 崂山可乐 +98/2.jpg 崂山可乐 +98/3.jpg 崂山可乐 +98/4.jpg 崂山可乐 +99/0.jpg 山海关桔汁汽水 +99/1.jpg 山海关桔汁汽水 +99/2.jpg 山海关桔汁汽水 +99/3.jpg 山海关桔汁汽水 +99/4.jpg 山海关桔汁汽水 +100/0.jpg 屈臣氏汤力苏打汽水 +100/1.jpg 屈臣氏汤力苏打汽水 +100/2.jpg 屈臣氏汤力苏打汽水 +100/3.jpg 屈臣氏汤力苏打汽水 +100/4.jpg 屈臣氏汤力苏打汽水 +100/5.jpg 屈臣氏汤力苏打汽水 +101/0.jpg 宾得宝 +101/1.jpg 宾得宝 +101/2.jpg 宾得宝 +101/3.jpg 宾得宝 +101/4.jpg 宾得宝 +101/5.jpg 宾得宝 +101/6.jpg 宾得宝 +101/7.jpg 宾得宝 +102/0.jpg 宏宝莱 +102/1.jpg 宏宝莱 +102/2.jpg 宏宝莱 +102/3.jpg 宏宝莱 +102/4.jpg 宏宝莱 +103/0.jpg 大窑嘉宾 +103/1.jpg 大窑嘉宾 +103/2.jpg 大窑嘉宾 +103/3.jpg 大窑嘉宾 +103/4.jpg 大窑嘉宾 +103/5.jpg 大窑嘉宾 +103/6.jpg 大窑嘉宾 +103/7.jpg 大窑嘉宾 +104/0.jpg 大洋玛盐汽水 +104/1.jpg 大洋玛盐汽水 +104/2.jpg 大洋玛盐汽水 +104/3.jpg 大洋玛盐汽水 +104/4.jpg 大洋玛盐汽水 +104/5.jpg 大洋玛盐汽水 +104/6.jpg 大洋玛盐汽水 +105/0.jpg 圣碧涛 +105/1.jpg 圣碧涛 +105/2.jpg 圣碧涛 +105/3.jpg 圣碧涛 +105/4.jpg 圣碧涛 +105/5.jpg 圣碧涛 +105/6.jpg 圣碧涛 +106/0.jpg 圣培露 +106/1.jpg 圣培露 +106/2.jpg 圣培露 +106/3.jpg 圣培露 +106/4.jpg 圣培露 +107/0.jpg 喜茶无糖气泡水 +107/1.jpg 喜茶无糖气泡水 +107/2.jpg 喜茶无糖气泡水 +107/3.jpg 喜茶无糖气泡水 +107/4.jpg 喜茶无糖气泡水 +107/5.jpg 喜茶无糖气泡水 +108/0.jpg 哈塔弹珠汽水 +108/1.jpg 哈塔弹珠汽水 +108/2.jpg 哈塔弹珠汽水 +108/3.jpg 哈塔弹珠汽水 +108/4.jpg 哈塔弹珠汽水 +109/0.jpg 可口可乐 +109/1.jpg 可口可乐 +109/2.jpg 可口可乐 +109/3.jpg 可口可乐 +109/4.jpg 可口可乐 +109/5.jpg 可口可乐 +109/6.jpg 可口可乐 +109/7.jpg 可口可乐 +110/0.jpg 华洋汽水 +110/1.jpg 华洋汽水 +110/2.jpg 华洋汽水 +110/3.jpg 华洋汽水 +110/4.jpg 华洋汽水 +110/5.jpg 华洋汽水 +110/6.jpg 华洋汽水 +110/7.jpg 华洋汽水 +111/0.jpg 北冰洋 +111/1.jpg 北冰洋 +111/2.jpg 北冰洋 +111/3.jpg 北冰洋 +111/4.jpg 北冰洋 +111/5.jpg 北冰洋 +111/6.jpg 北冰洋 +111/7.jpg 北冰洋 +111/8.jpg 北冰洋 +111/9.jpg 北冰洋 +112/0.jpg 冰峰 +112/1.jpg 冰峰 +112/2.jpg 冰峰 +112/3.jpg 冰峰 +112/4.jpg 冰峰 +112/5.jpg 冰峰 +112/6.jpg 冰峰 +113/0.jpg 农夫山泉苏打气泡水 +113/1.jpg 农夫山泉苏打气泡水 +113/2.jpg 农夫山泉苏打气泡水 +113/3.jpg 农夫山泉苏打气泡水 +113/4.jpg 农夫山泉苏打气泡水 +113/5.jpg 农夫山泉苏打气泡水 +114/0.jpg 元气森林 +114/1.jpg 元气森林 +114/2.jpg 元气森林 +114/3.jpg 元气森林 +114/4.jpg 元气森林 +114/5.jpg 元气森林 +114/6.jpg 元气森林 +115/0.jpg 健力宝 +115/1.jpg 健力宝 +115/2.jpg 健力宝 +115/3.jpg 健力宝 +115/4.jpg 健力宝 +115/5.jpg 健力宝 +115/6.jpg 健力宝 +115/7.jpg 健力宝 +116/0.jpg 亚洲汽水 +116/1.jpg 亚洲汽水 +116/2.jpg 亚洲汽水 +116/3.jpg 亚洲汽水 +116/4.jpg 亚洲汽水 +116/5.jpg 亚洲汽水 +117/0.jpg 乐天妙之吻 +117/1.jpg 乐天妙之吻 +117/2.jpg 乐天妙之吻 +117/3.jpg 乐天妙之吻 +118/0.jpg 三麟大象苏打气泡水 +118/1.jpg 三麟大象苏打气泡水 +118/2.jpg 三麟大象苏打气泡水 +118/3.jpg 三麟大象苏打气泡水 +119/0.jpg 七喜 +119/1.jpg 七喜 +119/2.jpg 七喜 +119/3.jpg 七喜 +119/4.jpg 七喜 +120/0.jpg 统一冰红茶 +120/1.jpg 统一冰红茶 +120/2.jpg 统一冰红茶 +120/3.jpg 统一冰红茶 +121/0.jpg 维他柠檬茶 +121/1.jpg 维他柠檬茶 +121/2.jpg 维他柠檬茶 +121/3.jpg 维他柠檬茶 +122/0.jpg 维他无糖茶 +122/1.jpg 维他无糖茶 +122/2.jpg 维他无糖茶 +123/0.jpg 达利园青梅绿茶 +123/1.jpg 达利园青梅绿茶 +123/2.jpg 达利园青梅绿茶 +123/3.jpg 达利园青梅绿茶 +123/4.jpg 达利园青梅绿茶 +123/5.jpg 达利园青梅绿茶 +124/0.jpg 伊藤园绿茶 +124/1.jpg 伊藤园绿茶 +124/2.jpg 伊藤园绿茶 +124/3.jpg 伊藤园绿茶 +124/4.jpg 伊藤园绿茶 +124/5.jpg 伊藤园绿茶 +125/0.jpg 伊藤园纤维乌龙茶 +125/1.jpg 伊藤园纤维乌龙茶 +125/2.jpg 伊藤园纤维乌龙茶 +125/3.jpg 伊藤园纤维乌龙茶 +125/4.jpg 伊藤园纤维乌龙茶 +126/0.jpg 伊藤园大麦茶 +126/1.jpg 伊藤园大麦茶 +126/2.jpg 伊藤园大麦茶 +126/3.jpg 伊藤园大麦茶 +126/4.jpg 伊藤园大麦茶 +127/0.jpg 伊藤园蜜桃红茶 +127/1.jpg 伊藤园蜜桃红茶 +127/2.jpg 伊藤园蜜桃红茶 +127/3.jpg 伊藤园蜜桃红茶 +128/0.jpg 伊藤园柠檬红茶 +128/1.jpg 伊藤园柠檬红茶 +128/2.jpg 伊藤园柠檬红茶 +128/3.jpg 伊藤园柠檬红茶 +129/0.jpg 伊藤园茉莉白茶 +129/1.jpg 伊藤园茉莉白茶 +129/2.jpg 伊藤园茉莉白茶 +129/3.jpg 伊藤园茉莉白茶 +129/4.jpg 伊藤园茉莉白茶 +129/5.jpg 伊藤园茉莉白茶 +130/0.jpg 伊藤园铁观音 +130/1.jpg 伊藤园铁观音 +130/2.jpg 伊藤园铁观音 +130/3.jpg 伊藤园铁观音 +131/0.jpg 统一绿茶 +131/1.jpg 统一绿茶 +131/2.jpg 统一绿茶 +131/3.jpg 统一绿茶 +131/4.jpg 统一绿茶 +131/5.jpg 统一绿茶 +131/6.jpg 统一绿茶 +131/7.jpg 统一绿茶 +132/0.jpg 伊藤园浓味乌龙茶 +132/1.jpg 伊藤园浓味乌龙茶 +132/2.jpg 伊藤园浓味乌龙茶 +132/3.jpg 伊藤园浓味乌龙茶 +132/4.jpg 伊藤园浓味乌龙茶 +133/0.jpg 伊藤园浓味绿茶 +133/1.jpg 伊藤园浓味绿茶 +133/2.jpg 伊藤园浓味绿茶 +133/3.jpg 伊藤园浓味绿茶 +133/4.jpg 伊藤园浓味绿茶 +133/5.jpg 伊藤园浓味绿茶 +134/0.jpg 统一茶里王 +134/1.jpg 统一茶里王 +134/2.jpg 统一茶里王 +134/3.jpg 统一茶里王 +135/0.jpg 雀巢茶萃 +135/1.jpg 雀巢茶萃 +135/2.jpg 雀巢茶萃 +135/3.jpg 雀巢茶萃 +135/4.jpg 雀巢茶萃 +135/5.jpg 雀巢茶萃 +135/6.jpg 雀巢茶萃 +136/0.jpg 康师傅茉莉蜜茶 +136/1.jpg 康师傅茉莉蜜茶 +136/2.jpg 康师傅茉莉蜜茶 +136/3.jpg 康师傅茉莉蜜茶 +136/4.jpg 康师傅茉莉蜜茶 +136/5.jpg 康师傅茉莉蜜茶 +137/0.jpg 康师傅茉莉清茶 +137/1.jpg 康师傅茉莉清茶 +137/2.jpg 康师傅茉莉清茶 +137/3.jpg 康师傅茉莉清茶 +137/4.jpg 康师傅茉莉清茶 +137/5.jpg 康师傅茉莉清茶 +138/0.jpg 康师傅茉莉花茶 +138/1.jpg 康师傅茉莉花茶 +138/2.jpg 康师傅茉莉花茶 +138/3.jpg 康师傅茉莉花茶 +138/4.jpg 康师傅茉莉花茶 +138/5.jpg 康师傅茉莉花茶 +138/6.jpg 康师傅茉莉花茶 +139/0.jpg 康师傅冷泡绿茶 +139/1.jpg 康师傅冷泡绿茶 +139/2.jpg 康师傅冷泡绿茶 +139/3.jpg 康师傅冷泡绿茶 +139/4.jpg 康师傅冷泡绿茶 +139/5.jpg 康师傅冷泡绿茶 +140/0.jpg 三得利乌龙茶 +140/1.jpg 三得利乌龙茶 +140/2.jpg 三得利乌龙茶 +140/3.jpg 三得利乌龙茶 +140/4.jpg 三得利乌龙茶 +140/5.jpg 三得利乌龙茶 +141/0.jpg 元气森林燃茶 +141/1.jpg 元气森林燃茶 +141/2.jpg 元气森林燃茶 +141/3.jpg 元气森林燃茶 +142/0.jpg 康师傅冰红茶 +142/1.jpg 康师傅冰红茶 +142/2.jpg 康师傅冰红茶 +142/3.jpg 康师傅冰红茶 +142/4.jpg 康师傅冰红茶 +143/0.jpg 三得利果瀑茶 +143/1.jpg 三得利果瀑茶 +143/2.jpg 三得利果瀑茶 +143/3.jpg 三得利果瀑茶 +143/4.jpg 三得利果瀑茶 +143/5.jpg 三得利果瀑茶 +144/0.jpg 喜茶_轻乳茶 +144/1.jpg 喜茶_轻乳茶 +144/2.jpg 喜茶_轻乳茶 +144/3.jpg 喜茶_轻乳茶 +144/4.jpg 喜茶_轻乳茶 +144/5.jpg 喜茶_轻乳茶 +145/0.jpg 麟珑茶室大麦爽茶 +145/1.jpg 麟珑茶室大麦爽茶 +145/2.jpg 麟珑茶室大麦爽茶 +145/3.jpg 麟珑茶室大麦爽茶 +145/4.jpg 麟珑茶室大麦爽茶 +145/5.jpg 麟珑茶室大麦爽茶 +146/0.jpg 麟珑茶室大人茶 +146/1.jpg 麟珑茶室大人茶 +146/2.jpg 麟珑茶室大人茶 +146/3.jpg 麟珑茶室大人茶 +147/0.jpg 麟珑茶室每天绿茶 +147/1.jpg 麟珑茶室每天绿茶 +147/2.jpg 麟珑茶室每天绿茶 +147/3.jpg 麟珑茶室每天绿茶 +147/4.jpg 麟珑茶室每天绿茶 +147/5.jpg 麟珑茶室每天绿茶 +148/0.jpg 麟珑茶室茉莉轻茶 +148/1.jpg 麟珑茶室茉莉轻茶 +148/2.jpg 麟珑茶室茉莉轻茶 +148/3.jpg 麟珑茶室茉莉轻茶 +149/0.jpg 和其正凉茶 +149/1.jpg 和其正凉茶 +149/2.jpg 和其正凉茶 +149/3.jpg 和其正凉茶 +150/0.jpg 王老吉凉茶 +150/1.jpg 王老吉凉茶 +150/2.jpg 王老吉凉茶 +150/3.jpg 王老吉凉茶 +150/4.jpg 王老吉凉茶 +151/0.jpg 加多宝 +151/1.jpg 加多宝 +151/2.jpg 加多宝 +151/3.jpg 加多宝 +152/0.jpg 统一阿萨姆奶茶 +152/1.jpg 统一阿萨姆奶茶 +152/2.jpg 统一阿萨姆奶茶 +152/3.jpg 统一阿萨姆奶茶 +152/4.jpg 统一阿萨姆奶茶 +152/5.jpg 统一阿萨姆奶茶 +153/0.jpg 康师傅绿茶 +153/1.jpg 康师傅绿茶 +153/2.jpg 康师傅绿茶 +153/3.jpg 康师傅绿茶 +153/4.jpg 康师傅绿茶 +153/5.jpg 康师傅绿茶 +154/0.jpg 农夫山泉打奶茶 +154/1.jpg 农夫山泉打奶茶 +154/2.jpg 农夫山泉打奶茶 +154/3.jpg 农夫山泉打奶茶 +155/0.jpg 麒麟午后奶茶 +155/1.jpg 麒麟午后奶茶 +155/2.jpg 麒麟午后奶茶 +155/3.jpg 麒麟午后奶茶 +155/4.jpg 麒麟午后奶茶 +156/0.jpg 康师傅奶茶 +156/1.jpg 康师傅奶茶 +156/2.jpg 康师傅奶茶 +156/3.jpg 康师傅奶茶 +157/0.jpg 可口可乐淳茶舍 +157/1.jpg 可口可乐淳茶舍 +157/2.jpg 可口可乐淳茶舍 +157/3.jpg 可口可乐淳茶舍 +157/4.jpg 可口可乐淳茶舍 +157/5.jpg 可口可乐淳茶舍 +158/0.jpg 元气森林纤茶 +158/1.jpg 元气森林纤茶 +158/2.jpg 元气森林纤茶 +158/3.jpg 元气森林纤茶 +158/4.jpg 元气森林纤茶 +158/5.jpg 元气森林纤茶 +159/0.jpg 雀巢咖啡 +159/1.jpg 雀巢咖啡 +159/2.jpg 雀巢咖啡 +159/3.jpg 雀巢咖啡 +160/0.jpg 雀巢冷萃咖啡 +160/1.jpg 雀巢冷萃咖啡 +160/2.jpg 雀巢冷萃咖啡 +160/3.jpg 雀巢冷萃咖啡 +160/4.jpg 雀巢冷萃咖啡 +160/5.jpg 雀巢冷萃咖啡 +161/0.jpg 星巴克派克市场 +161/1.jpg 星巴克派克市场 +161/2.jpg 星巴克派克市场 +161/3.jpg 星巴克派克市场 +162/0.jpg 星巴克星倍醇咖啡 +162/1.jpg 星巴克星倍醇咖啡 +162/2.jpg 星巴克星倍醇咖啡 +162/3.jpg 星巴克星倍醇咖啡 +163/0.jpg 星巴克星选咖啡 +163/1.jpg 星巴克星选咖啡 +163/2.jpg 星巴克星选咖啡 +163/3.jpg 星巴克星选咖啡 +164/0.jpg 康师傅冰绿茶 +164/1.jpg 康师傅冰绿茶 +164/2.jpg 康师傅冰绿茶 +164/3.jpg 康师傅冰绿茶 +164/4.jpg 康师傅冰绿茶 +164/5.jpg 康师傅冰绿茶 +164/6.jpg 康师傅冰绿茶 +164/7.jpg 康师傅冰绿茶 +164/8.jpg 康师傅冰绿茶 +164/9.jpg 康师傅冰绿茶 +164/10.jpg 康师傅冰绿茶 +165/0.jpg 星巴克星冰乐咖啡 +165/1.jpg 星巴克星冰乐咖啡 +165/2.jpg 星巴克星冰乐咖啡 +165/3.jpg 星巴克星冰乐咖啡 +166/0.jpg costa咖啡 +166/1.jpg costa咖啡 +166/2.jpg costa咖啡 +166/3.jpg costa咖啡 +166/4.jpg costa咖啡 +166/5.jpg costa咖啡 +167/0.jpg 统一雅哈咖啡 +167/1.jpg 统一雅哈咖啡 +167/2.jpg 统一雅哈咖啡 +167/3.jpg 统一雅哈咖啡 +168/0.jpg 麒麟火咖 +168/1.jpg 麒麟火咖 +168/2.jpg 麒麟火咖 +168/3.jpg 麒麟火咖 +168/4.jpg 麒麟火咖 +168/5.jpg 麒麟火咖 +169/0.jpg 农夫山泉炭仌咖啡 +169/1.jpg 农夫山泉炭仌咖啡 +169/2.jpg 农夫山泉炭仌咖啡 +169/3.jpg 农夫山泉炭仌咖啡 +169/4.jpg 农夫山泉炭仌咖啡 +169/5.jpg 农夫山泉炭仌咖啡 +170/0.jpg 味全贝纳颂 +170/1.jpg 味全贝纳颂 +170/2.jpg 味全贝纳颂 +170/3.jpg 味全贝纳颂 +170/4.jpg 味全贝纳颂 +171/0.jpg 康师傅青梅绿茶 +171/1.jpg 康师傅青梅绿茶 +171/2.jpg 康师傅青梅绿茶 +171/3.jpg 康师傅青梅绿茶 +171/4.jpg 康师傅青梅绿茶 +171/5.jpg 康师傅青梅绿茶 +171/6.jpg 康师傅青梅绿茶 +172/0.jpg 东方树叶红茶/玄米茶/绿茶… +172/1.jpg 东方树叶红茶/玄米茶/绿茶… +172/2.jpg 东方树叶红茶/玄米茶/绿茶… +172/3.jpg 东方树叶红茶/玄米茶/绿茶… +172/4.jpg 东方树叶红茶/玄米茶/绿茶… +173/0.jpg 茶π +173/1.jpg 茶π +173/2.jpg 茶π +173/3.jpg 茶π +173/4.jpg 茶π +173/5.jpg 茶π +173/6.jpg 茶π +173/7.jpg 茶π +174/0.jpg 小茗同学 +174/1.jpg 小茗同学 +174/2.jpg 小茗同学 +174/3.jpg 小茗同学 +174/4.jpg 小茗同学 +175/0.jpg 蒙牛_纯甄 +175/1.jpg 蒙牛_纯甄 +175/2.jpg 蒙牛_纯甄 +175/3.jpg 蒙牛_纯甄 +176/0.jpg 蒙牛_未来星 +176/1.jpg 蒙牛_未来星 +176/2.jpg 蒙牛_未来星 +177/0.jpg 蒙牛_真果粒 +177/1.jpg 蒙牛_真果粒 +177/2.jpg 蒙牛_真果粒 +177/3.jpg 蒙牛_真果粒 +177/4.jpg 蒙牛_真果粒 +178/0.jpg 蒙牛_精选牧场 +178/1.jpg 蒙牛_精选牧场 +178/2.jpg 蒙牛_精选牧场 +178/3.jpg 蒙牛_精选牧场 +178/4.jpg 蒙牛_精选牧场 +178/5.jpg 蒙牛_精选牧场 +179/0.jpg 蒙牛_酸酸乳 +179/1.jpg 蒙牛_酸酸乳 +179/2.jpg 蒙牛_酸酸乳 +179/3.jpg 蒙牛_酸酸乳 +180/0.jpg 蒙牛_特仑苏 +180/1.jpg 蒙牛_特仑苏 +180/2.jpg 蒙牛_特仑苏 +180/3.jpg 蒙牛_特仑苏 +180/4.jpg 蒙牛_特仑苏 +180/5.jpg 蒙牛_特仑苏 +181/0.jpg 蒙牛_新养道 +181/1.jpg 蒙牛_新养道 +181/2.jpg 蒙牛_新养道 +181/3.jpg 蒙牛_新养道 +181/4.jpg 蒙牛_新养道 +182/0.jpg 蒙牛_早餐奶 +182/1.jpg 蒙牛_早餐奶 +182/2.jpg 蒙牛_早餐奶 +182/3.jpg 蒙牛_早餐奶 +182/4.jpg 蒙牛_早餐奶 +182/5.jpg 蒙牛_早餐奶 +183/0.jpg 飞鹤_甄爱倍护 +183/1.jpg 飞鹤_甄爱倍护 +183/2.jpg 飞鹤_甄爱倍护 +183/3.jpg 飞鹤_甄爱倍护 +183/4.jpg 飞鹤_甄爱倍护 +184/0.jpg 飞鹤_茁然 +184/1.jpg 飞鹤_茁然 +184/2.jpg 飞鹤_茁然 +184/3.jpg 飞鹤_茁然 +184/4.jpg 飞鹤_茁然 +185/0.jpg 飞鹤_星飞帆 +185/1.jpg 飞鹤_星飞帆 +185/2.jpg 飞鹤_星飞帆 +185/3.jpg 飞鹤_星飞帆 +185/4.jpg 飞鹤_星飞帆 +185/5.jpg 飞鹤_星飞帆 +186/0.jpg 伊利_畅意 +186/1.jpg 伊利_畅意 +187/0.jpg 伊利_舒化 +187/1.jpg 伊利_舒化 +187/2.jpg 伊利_舒化 +187/3.jpg 伊利_舒化 +187/4.jpg 伊利_舒化 +187/5.jpg 伊利_舒化 +188/0.jpg 伊利_金典 +188/1.jpg 伊利_金典 +188/2.jpg 伊利_金典 +188/3.jpg 伊利_金典 +188/4.jpg 伊利_金典 +189/0.jpg 伊利_优酸乳 +189/1.jpg 伊利_优酸乳 +190/0.jpg 伊利_谷粒多 +190/1.jpg 伊利_谷粒多 +190/2.jpg 伊利_谷粒多 +190/3.jpg 伊利_谷粒多 +191/0.jpg 伊利_QQ星 +191/1.jpg 伊利_QQ星 +191/2.jpg 伊利_QQ星 +191/3.jpg 伊利_QQ星 +192/0.jpg 伊利_学生奶 +192/1.jpg 伊利_学生奶 +192/2.jpg 伊利_学生奶 +192/3.jpg 伊利_学生奶 +192/4.jpg 伊利_学生奶 +193/0.jpg 伊利_植选 +193/1.jpg 伊利_植选 +193/2.jpg 伊利_植选 +193/3.jpg 伊利_植选 +193/4.jpg 伊利_植选 +193/5.jpg 伊利_植选 +194/0.jpg 伊利_核桃乳 +194/1.jpg 伊利_核桃乳 +194/2.jpg 伊利_核桃乳 +194/3.jpg 伊利_核桃乳 +195/0.jpg 伊利_安慕希 +195/1.jpg 伊利_安慕希 +196/0.jpg 伊利_味可滋 +196/1.jpg 伊利_味可滋 +196/2.jpg 伊利_味可滋 +196/3.jpg 伊利_味可滋 +197/0.jpg 光明_赏味 +197/1.jpg 光明_赏味 +197/2.jpg 光明_赏味 +197/3.jpg 光明_赏味 +197/4.jpg 光明_赏味 +197/5.jpg 光明_赏味 +198/0.jpg 光明_巧克努力 +198/1.jpg 光明_巧克努力 +198/2.jpg 光明_巧克努力 +198/3.jpg 光明_巧克努力 +198/4.jpg 光明_巧克努力 +198/5.jpg 光明_巧克努力 +198/6.jpg 光明_巧克努力 +199/0.jpg 光明_致优全鲜乳 +199/1.jpg 光明_致优全鲜乳 +199/2.jpg 光明_致优全鲜乳 +199/3.jpg 光明_致优全鲜乳 +200/0.jpg 光明_畅优 +200/1.jpg 光明_畅优 +200/2.jpg 光明_畅优 +200/3.jpg 光明_畅优 +201/0.jpg 光明_巧风 +201/1.jpg 光明_巧风 +201/2.jpg 光明_巧风 +201/3.jpg 光明_巧风 +201/4.jpg 光明_巧风 +201/5.jpg 光明_巧风 +201/6.jpg 光明_巧风 +202/0.jpg 光明_一只椰子 +202/1.jpg 光明_一只椰子 +202/2.jpg 光明_一只椰子 +202/3.jpg 光明_一只椰子 +202/4.jpg 光明_一只椰子 +202/5.jpg 光明_一只椰子 +202/6.jpg 光明_一只椰子 +203/0.jpg 光明_如实 +203/1.jpg 光明_如实 +203/2.jpg 光明_如实 +204/0.jpg 光明_莫斯利安 +204/1.jpg 光明_莫斯利安 +204/2.jpg 光明_莫斯利安 +204/3.jpg 光明_莫斯利安 +204/4.jpg 光明_莫斯利安 +204/5.jpg 光明_莫斯利安 +205/0.jpg 光明_优倍鲜牛奶 +205/1.jpg 光明_优倍鲜牛奶 +205/2.jpg 光明_优倍鲜牛奶 +205/3.jpg 光明_优倍鲜牛奶 +205/4.jpg 光明_优倍鲜牛奶 +205/5.jpg 光明_优倍鲜牛奶 +206/0.jpg 光明_优幼 +206/1.jpg 光明_优幼 +207/0.jpg 光明_植物活力 +207/1.jpg 光明_植物活力 +207/2.jpg 光明_植物活力 +207/3.jpg 光明_植物活力 +207/4.jpg 光明_植物活力 +207/5.jpg 光明_植物活力 +207/6.jpg 光明_植物活力 +208/0.jpg 光明_优加纯牛奶 +208/1.jpg 光明_优加纯牛奶 +208/2.jpg 光明_优加纯牛奶 +208/3.jpg 光明_优加纯牛奶 +208/4.jpg 光明_优加纯牛奶 +208/5.jpg 光明_优加纯牛奶 +209/0.jpg 光明_有机奶 +209/1.jpg 光明_有机奶 +209/2.jpg 光明_有机奶 +209/3.jpg 光明_有机奶 +209/4.jpg 光明_有机奶 +209/5.jpg 光明_有机奶 +210/0.jpg 三元_爱诺星 +211/0.jpg 三元_全家甜 +211/1.jpg 三元_全家甜 +211/2.jpg 三元_全家甜 +211/3.jpg 三元_全家甜 +211/4.jpg 三元_全家甜 +212/0.jpg 三元_爱力优 +212/1.jpg 三元_爱力优 +212/2.jpg 三元_爱力优 +212/3.jpg 三元_爱力优 \ No newline at end of file diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/index/id_map.pkl b/src/PaddleClas/deploy/drink_dataset_v1.0/index/id_map.pkl new file mode 100644 index 0000000..ddf99b2 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/index/id_map.pkl differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/index/vector.index b/src/PaddleClas/deploy/drink_dataset_v1.0/index/vector.index new file mode 100644 index 0000000..af26122 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/index/vector.index differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/001.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/001.jpeg new file mode 100644 index 0000000..2ef10aa Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/001.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/002.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/002.jpeg new file mode 100644 index 0000000..347b82e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/002.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/003.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/003.jpeg new file mode 100644 index 0000000..a2da79c Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/003.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/004.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/004.jpeg new file mode 100644 index 0000000..c4fc6b5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/004.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/005.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/005.jpeg new file mode 100644 index 0000000..97631f5 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/005.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/100.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/100.jpeg new file mode 100644 index 0000000..e5f845e Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/100.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/110.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/110.jpeg new file mode 100644 index 0000000..a2f19e0 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/110.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/1101.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/1101.jpeg new file mode 100644 index 0000000..a23aca4 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/1101.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/112.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/112.jpeg new file mode 100644 index 0000000..e505713 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/112.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/222.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/222.jpeg new file mode 100644 index 0000000..1fe11c9 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/222.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/99.jpg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/99.jpg new file mode 100644 index 0000000..63aa8c6 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/99.jpg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/mosilian.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/mosilian.jpeg new file mode 100644 index 0000000..22c6075 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/mosilian.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/nongfu_spring.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/nongfu_spring.jpeg new file mode 100644 index 0000000..0f4166d Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/nongfu_spring.jpeg differ diff --git a/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/youjia.jpeg b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/youjia.jpeg new file mode 100644 index 0000000..2875a76 Binary files /dev/null and b/src/PaddleClas/deploy/drink_dataset_v1.0/test_images/youjia.jpeg differ diff --git a/src/PaddleClas/deploy/hubserving/ILSVRC2012_val_00006666.JPEG b/src/PaddleClas/deploy/hubserving/ILSVRC2012_val_00006666.JPEG new file mode 100644 index 0000000..f284522 Binary files /dev/null and b/src/PaddleClas/deploy/hubserving/ILSVRC2012_val_00006666.JPEG differ diff --git a/src/PaddleClas/deploy/hubserving/clas/__init__.py b/src/PaddleClas/deploy/hubserving/clas/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/hubserving/clas/config.json b/src/PaddleClas/deploy/hubserving/clas/config.json new file mode 100644 index 0000000..647036f --- /dev/null +++ b/src/PaddleClas/deploy/hubserving/clas/config.json @@ -0,0 +1,16 @@ +{ + "modules_info": { + "clas_system": { + "init_args": { + "version": "1.0.0", + "use_gpu": true, + "enable_mkldnn": false + }, + "predict_args": { + } + } + }, + "port": 8866, + "use_multiprocess": false, + "workers": 2 +} diff --git a/src/PaddleClas/deploy/hubserving/clas/module.py b/src/PaddleClas/deploy/hubserving/clas/module.py new file mode 100644 index 0000000..98ec1d9 --- /dev/null +++ b/src/PaddleClas/deploy/hubserving/clas/module.py @@ -0,0 +1,100 @@ +# Copyright (c) 2021 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. + +import os +import sys +sys.path.insert(0, ".") + +import time + +import numpy as np +import paddle.nn as nn +from paddlehub.module.module import moduleinfo, serving + +from hubserving.clas.params import get_default_confg +from python.predict_cls import ClsPredictor +from utils import config +from utils.encode_decode import b64_to_np + + +@moduleinfo( + name="clas_system", + version="1.0.0", + summary="class system service", + author="paddle-dev", + author_email="paddle-dev@baidu.com", + type="cv/class") +class ClasSystem(nn.Layer): + def __init__(self, use_gpu=None, enable_mkldnn=None): + """ + initialize with the necessary elements + """ + self._config = self._load_config( + use_gpu=use_gpu, enable_mkldnn=enable_mkldnn) + self.cls_predictor = ClsPredictor(self._config) + + def _load_config(self, use_gpu=None, enable_mkldnn=None): + cfg = get_default_confg() + cfg = config.AttrDict(cfg) + config.create_attr_dict(cfg) + if use_gpu is not None: + cfg.Global.use_gpu = use_gpu + if enable_mkldnn is not None: + cfg.Global.enable_mkldnn = enable_mkldnn + cfg.enable_benchmark = False + if cfg.Global.use_gpu: + try: + _places = os.environ["CUDA_VISIBLE_DEVICES"] + int(_places[0]) + print("Use GPU, GPU Memery:{}".format(cfg.Global.gpu_mem)) + print("CUDA_VISIBLE_DEVICES: ", _places) + except: + raise RuntimeError( + "Environment Variable CUDA_VISIBLE_DEVICES is not set correctly. If you wanna use gpu, please set CUDA_VISIBLE_DEVICES via export CUDA_VISIBLE_DEVICES=cuda_device_id." + ) + else: + print("Use CPU") + print("Enable MKL-DNN") if enable_mkldnn else None + return cfg + + def predict(self, inputs): + if not isinstance(inputs, list): + raise Exception( + "The input data is inconsistent with expectations.") + + starttime = time.time() + outputs = self.cls_predictor.predict(inputs) + elapse = time.time() - starttime + return {"prediction": outputs, "elapse": elapse} + + @serving + def serving_method(self, images, revert_params): + """ + Run as a service. + """ + input_data = b64_to_np(images, revert_params) + results = self.predict(inputs=list(input_data)) + return results + + +if __name__ == "__main__": + import cv2 + import paddlehub as hub + + module = hub.Module(name="clas_system") + img_path = "./hubserving/ILSVRC2012_val_00006666.JPEG" + img = cv2.imread(img_path)[:, :, ::-1] + img = cv2.resize(img, (224, 224)).transpose((2, 0, 1)) + res = module.predict([img.astype(np.float32)]) + print("The returned result of {}: {}".format(img_path, res)) diff --git a/src/PaddleClas/deploy/hubserving/clas/params.py b/src/PaddleClas/deploy/hubserving/clas/params.py new file mode 100644 index 0000000..9d9c0dd --- /dev/null +++ b/src/PaddleClas/deploy/hubserving/clas/params.py @@ -0,0 +1,42 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + + +def get_default_confg(): + return { + 'Global': { + "inference_model_dir": "../inference/", + "batch_size": 1, + 'use_gpu': False, + 'use_fp16': False, + 'enable_mkldnn': False, + 'cpu_num_threads': 1, + 'use_tensorrt': False, + 'ir_optim': False, + "gpu_mem": 8000, + 'enable_profile': False, + "enable_benchmark": False + }, + 'PostProcess': { + 'main_indicator': 'Topk', + 'Topk': { + 'topk': 5, + 'class_id_map_file': './utils/imagenet1k_label_list.txt' + } + } + } diff --git a/src/PaddleClas/deploy/hubserving/readme.md b/src/PaddleClas/deploy/hubserving/readme.md new file mode 100644 index 0000000..6b2b2dd --- /dev/null +++ b/src/PaddleClas/deploy/hubserving/readme.md @@ -0,0 +1,188 @@ +[English](readme_en.md) | 简体中文 + +# 基于PaddleHub Serving的服务部署 + +hubserving服务部署配置服务包`clas`下包含3个必选文件,目录如下: +``` +hubserving/clas/ + └─ __init__.py 空文件,必选 + └─ config.json 配置文件,可选,使用配置启动服务时作为参数传入 + └─ module.py 主模块,必选,包含服务的完整逻辑 + └─ params.py 参数文件,必选,包含模型路径、前后处理参数等参数 +``` + +## 快速启动服务 +### 1. 准备环境 +```shell +# 安装paddlehub,请安装2.0版本 +pip3 install paddlehub==2.1.0 --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +### 2. 下载推理模型 +安装服务模块前,需要准备推理模型并放到正确路径,默认模型路径为: +``` +分类推理模型结构文件:PaddleClas/inference/inference.pdmodel +分类推理模型权重文件:PaddleClas/inference/inference.pdiparams +``` + +**注意**: +* 模型文件路径可在`PaddleClas/deploy/hubserving/clas/params.py`中查看和修改: + ```python + "inference_model_dir": "../inference/" + ``` + 需要注意,模型文件(包括.pdmodel与.pdiparams)名称必须为`inference`。 +* 我们也提供了大量基于ImageNet-1k数据集的预训练模型,模型列表及下载地址详见[模型库概览](../../docs/zh_CN/models/models_intro.md),也可以使用自己训练转换好的模型。 + +### 3. 安装服务模块 +针对Linux环境和Windows环境,安装命令如下。 + +* 在Linux环境下,安装示例如下: +```shell +cd PaddleClas/deploy +# 安装服务模块: +hub install hubserving/clas/ +``` + +* 在Windows环境下(文件夹的分隔符为`\`),安装示例如下: + +```shell +cd PaddleClas\deploy +# 安装服务模块: +hub install hubserving\clas\ +``` + +### 4. 启动服务 +#### 方式1. 命令行命令启动(仅支持CPU) +**启动命令:** +```shell +$ hub serving start --modules Module1==Version1 \ + --port XXXX \ + --use_multiprocess \ + --workers \ +``` + +**参数:** +|参数|用途| +|-|-| +|--modules/-m| [**必选**] PaddleHub Serving预安装模型,以多个Module==Version键值对的形式列出
*`当不指定Version时,默认选择最新版本`*| +|--port/-p| [**可选**] 服务端口,默认为8866| +|--use_multiprocess| [**可选**] 是否启用并发方式,默认为单进程方式,推荐多核CPU机器使用此方式
*`Windows操作系统只支持单进程方式`*| +|--workers| [**可选**] 在并发方式下指定的并发任务数,默认为`2*cpu_count-1`,其中`cpu_count`为CPU核数| + +如按默认参数启动服务: ```hub serving start -m clas_system``` + +这样就完成了一个服务化API的部署,使用默认端口号8866。 + +#### 方式2. 配置文件启动(支持CPU、GPU) +**启动命令:** +```hub serving start -c config.json``` + +其中,`config.json`格式如下: +```json +{ + "modules_info": { + "clas_system": { + "init_args": { + "version": "1.0.0", + "use_gpu": true, + "enable_mkldnn": false + }, + "predict_args": { + } + } + }, + "port": 8866, + "use_multiprocess": false, + "workers": 2 +} +``` + +- `init_args`中的可配参数与`module.py`中的`_initialize`函数接口一致。其中, + - 当`use_gpu`为`true`时,表示使用GPU启动服务。 + - 当`enable_mkldnn`为`true`时,表示使用MKL-DNN加速。 +- `predict_args`中的可配参数与`module.py`中的`predict`函数接口一致。 + +**注意:** +- 使用配置文件启动服务时,其他参数会被忽略。 +- 如果使用GPU预测(即,`use_gpu`置为`true`),则需要在启动服务之前,设置CUDA_VISIBLE_DEVICES环境变量,如:```export CUDA_VISIBLE_DEVICES=0```,否则不用设置。 +- **`use_gpu`不可与`use_multiprocess`同时为`true`**。 +- **`use_gpu`与`enable_mkldnn`同时为`true`时,将忽略`enable_mkldnn`,而使用GPU**。 + +如,使用GPU 3号卡启动串联服务: +```shell +cd PaddleClas/deploy +export CUDA_VISIBLE_DEVICES=3 +hub serving start -c hubserving/clas/config.json +``` + +## 发送预测请求 +配置好服务端,可使用以下命令发送预测请求,获取预测结果: + +```shell +cd PaddleClas/deploy +python hubserving/test_hubserving.py server_url image_path +``` + +需要给脚本传递2个必须参数: +- **server_url**:服务地址,格式为 +`http://[ip_address]:[port]/predict/[module_name]` +- **image_path**:测试图像路径,可以是单张图片路径,也可以是图像集合目录路径。 +- **batch_size**:[**可选**] 以`batch_size`大小为单位进行预测,默认为`1`。 +- **resize_short**:[**可选**] 预处理时,按短边调整大小,默认为`256`。 +- **crop_size**:[**可选**] 预处理时,居中裁剪的大小,默认为`224`。 +- **normalize**:[**可选**] 预处理时,是否进行`normalize`,默认为`True`。 +- **to_chw**:[**可选**] 预处理时,是否调整为`CHW`顺序,默认为`True`。 + +**注意**:如果使用`Transformer`系列模型,如`DeiT_***_384`, `ViT_***_384`等,请注意模型的输入数据尺寸,需要指定`--resize_short=384 --crop_size=384`。 + + +访问示例: +```shell +python hubserving/test_hubserving.py --server_url http://127.0.0.1:8866/predict/clas_system --image_file ./hubserving/ILSVRC2012_val_00006666.JPEG --batch_size 8 +``` + +### 返回结果格式说明 +返回结果为列表(list),包含top-k个分类结果,以及对应的得分,还有此图片预测耗时,具体如下: +``` +list: 返回结果 +└─ list: 第一张图片结果 + └─ list: 前k个分类结果,依score递减排序 + └─ list: 前k个分类结果对应的score,依score递减排序 + └─ float: 该图分类耗时,单位秒 +``` + +**说明:** 如果需要增加、删除、修改返回字段,可对相应模块进行修改,完整流程参考下一节自定义修改服务模块。 + +## 自定义修改服务模块 +如果需要修改服务逻辑,你一般需要操作以下步骤: + +- 1、 停止服务 +```hub serving stop --port/-p XXXX``` + +- 2、 到相应的`module.py`和`params.py`等文件中根据实际需求修改代码。`module.py`修改后需要重新安装(`hub install hubserving/clas/`)并部署。在进行部署前,可通过`python hubserving/clas/module.py`测试已安装服务模块。 + +- 3、 卸载旧服务包 +```hub uninstall clas_system``` + +- 4、 安装修改后的新服务包 +```hub install hubserving/clas/``` + +- 5、重新启动服务 +```hub serving start -m clas_system``` + +**注意**: +常用参数可在[params.py](./clas/params.py)中修改: + * 更换模型,需要修改模型文件路径参数: + ```python + "inference_model_dir": + ``` + * 更改后处理时返回的`top-k`结果数量: + ```python + 'topk': + ``` + * 更改后处理时的lable与class id对应映射文件: + ```python + 'class_id_map_file': + ``` + +为了避免不必要的延时以及能够以batch_size进行预测,数据预处理逻辑(包括resize、crop等操作)在客户端完成,因此需要在[test_hubserving.py](./test_hubserving.py#L35-L52)中修改。 diff --git a/src/PaddleClas/deploy/hubserving/readme_en.md b/src/PaddleClas/deploy/hubserving/readme_en.md new file mode 100644 index 0000000..bb0ddbd --- /dev/null +++ b/src/PaddleClas/deploy/hubserving/readme_en.md @@ -0,0 +1,199 @@ +English | [简体中文](readme.md) + +# Service deployment based on PaddleHub Serving + +HubServing service pack contains 3 files, the directory is as follows: +``` +hubserving/clas/ + └─ __init__.py Empty file, required + └─ config.json Configuration file, optional, passed in as a parameter when using configuration to start the service + └─ module.py Main module file, required, contains the complete logic of the service + └─ params.py Parameter file, required, including parameters such as model path, pre- and post-processing parameters +``` + +## Quick start service +### 1. Prepare the environment +```shell +# Install version 2.0 of PaddleHub +pip3 install paddlehub==2.1.0 --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +### 2. Download inference model +Before installing the service module, you need to prepare the inference model and put it in the correct path. The default model path is: + +``` +Model structure file: PaddleClas/inference/inference.pdmodel +Model parameters file: PaddleClas/inference/inference.pdiparams +``` + +* The model file path can be viewed and modified in `PaddleClas/deploy/hubserving/clas/params.py`. + + It should be noted that the prefix of model structure file and model parameters file must be `inference`. + +* More models provided by PaddleClas can be obtained from the [model library](../../docs/en/models/models_intro_en.md). You can also use models trained by yourself. + +### 3. Install Service Module + +* On Linux platform, the examples are as follows. +```shell +cd PaddleClas/deploy +hub install hubserving/clas/ +``` + +* On Windows platform, the examples are as follows. +```shell +cd PaddleClas\deploy +hub install hubserving\clas\ +``` + +### 4. Start service +#### Way 1. Start with command line parameters (CPU only) + +**start command:** +```shell +$ hub serving start --modules Module1==Version1 \ + --port XXXX \ + --use_multiprocess \ + --workers \ +``` +**parameters:** + +|parameters|usage| +|-|-| +|--modules/-m|PaddleHub Serving pre-installed model, listed in the form of multiple Module==Version key-value pairs
*`When Version is not specified, the latest version is selected by default`*| +|--port/-p|Service port, default is 8866| +|--use_multiprocess|Enable concurrent mode, the default is single-process mode, this mode is recommended for multi-core CPU machines
*`Windows operating system only supports single-process mode`*| +|--workers|The number of concurrent tasks specified in concurrent mode, the default is `2*cpu_count-1`, where `cpu_count` is the number of CPU cores| + +For example, start the 2-stage series service: +```shell +hub serving start -m clas_system +``` + +This completes the deployment of a service API, using the default port number 8866. + +#### Way 2. Start with configuration file(CPU、GPU) +**start command:** +```shell +hub serving start --config/-c config.json +``` +Wherein, the format of `config.json` is as follows: +```json +{ + "modules_info": { + "clas_system": { + "init_args": { + "version": "1.0.0", + "use_gpu": true, + "enable_mkldnn": false + }, + "predict_args": { + } + } + }, + "port": 8866, + "use_multiprocess": false, + "workers": 2 +} +``` +- The configurable parameters in `init_args` are consistent with the `_initialize` function interface in `module.py`. Among them, + - when `use_gpu` is `true`, it means that the GPU is used to start the service. + - when `enable_mkldnn` is `true`, it means that use MKL-DNN to accelerate. +- The configurable parameters in `predict_args` are consistent with the `predict` function interface in `module.py`. + +**Note:** +- When using the configuration file to start the service, other parameters will be ignored. +- If you use GPU prediction (that is, `use_gpu` is set to `true`), you need to set the environment variable CUDA_VISIBLE_DEVICES before starting the service, such as: ```export CUDA_VISIBLE_DEVICES=0```, otherwise you do not need to set it. +- **`use_gpu` and `use_multiprocess` cannot be `true` at the same time.** +- **When both `use_gpu` and `enable_mkldnn` are set to `true` at the same time, GPU is used to run and `enable_mkldnn` will be ignored.** + +For example, use GPU card No. 3 to start the 2-stage series service: +```shell +cd PaddleClas/deploy +export CUDA_VISIBLE_DEVICES=3 +hub serving start -c hubserving/clas/config.json +``` + +## Send prediction requests +After the service starts, you can use the following command to send a prediction request to obtain the prediction result: +```shell +cd PaddleClas/deploy +python hubserving/test_hubserving.py server_url image_path +``` + +Two required parameters need to be passed to the script: +- **server_url**: service address,format of which is +`http://[ip_address]:[port]/predict/[module_name]` +- **image_path**: Test image path, can be a single image path or an image directory path +- **batch_size**: [**Optional**] batch_size. Default by `1`. +- **resize_short**: [**Optional**] In preprocessing, resize according to short size. Default by `256`。 +- **crop_size**: [**Optional**] In preprocessing, centor crop size. Default by `224`。 +- **normalize**: [**Optional**] In preprocessing, whether to do `normalize`. Default by `True`。 +- **to_chw**: [**Optional**] In preprocessing, whether to transpose to `CHW`. Default by `True`。 + +**Notice**: +If you want to use `Transformer series models`, such as `DeiT_***_384`, `ViT_***_384`, etc., please pay attention to the input size of model, and need to set `--resize_short=384`, `--crop_size=384`. + +**Eg.** +```shell +python hubserving/test_hubserving.py --server_url http://127.0.0.1:8866/predict/clas_system --image_file ./hubserving/ILSVRC2012_val_00006666.JPEG --batch_size 8 +``` + +### Returned result format +The returned result is a list, including the `top_k`'s classification results, corresponding scores and the time cost of prediction, details as follows. + +``` +list: The returned results +└─ list: The result of first picture + └─ list: The top-k classification results, sorted in descending order of score + └─ list: The scores corresponding to the top-k classification results, sorted in descending order of score + └─ float: The time cost of predicting the picture, unit second +``` + +**Note:** If you need to add, delete or modify the returned fields, you can modify the corresponding module. For the details, refer to the user-defined modification service module in the next section. + +## User defined service module modification +If you need to modify the service logic, the following steps are generally required: + +1. Stop service +```shell +hub serving stop --port/-p XXXX +``` + +2. Modify the code in the corresponding files, like `module.py` and `params.py`, according to the actual needs. You need re-install(hub install hubserving/clas/) and re-deploy after modifing `module.py`. +After modifying and installing and before deploying, you can use `python hubserving/clas/module.py` to test the installed service module. + +For example, if you need to replace the model used by the deployed service, you need to modify model path parameters `cfg.model_file` and `cfg.params_file` in `params.py`. Of course, other related parameters may need to be modified at the same time. Please modify and debug according to the actual situation. + +3. Uninstall old service module +```shell +hub uninstall clas_system +``` + +4. Install modified service module +```shell +hub install hubserving/clas/ +``` + +5. Restart service +```shell +hub serving start -m clas_system +``` + +**Note**: + +Common parameters can be modified in params.py: +* Directory of model files(include model structure file and model parameters file): + ```python + "inference_model_dir": + ``` +* The number of Top-k results returned during post-processing: + ```python + 'topk': + ``` +* Mapping file corresponding to label and class ID during post-processing: + ```python + 'class_id_map_file': + ``` + +In order to avoid unnecessary delay and be able to predict in batch, the preprocessing (include resize, crop and other) is completed in the client, so modify [test_hubserving.py](./test_hubserving.py#L35-L52) if necessary. diff --git a/src/PaddleClas/deploy/hubserving/test_hubserving.py b/src/PaddleClas/deploy/hubserving/test_hubserving.py new file mode 100644 index 0000000..b778a82 --- /dev/null +++ b/src/PaddleClas/deploy/hubserving/test_hubserving.py @@ -0,0 +1,166 @@ +# Copyright (c) 2021 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. + +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +import time +import requests +import json +import base64 +import argparse + +import numpy as np +import cv2 + +from utils import logger +from utils.get_image_list import get_image_list +from utils import config +from utils.encode_decode import np_to_b64 +from python.preprocess import create_operators + + +def get_args(): + def str2bool(v): + return v.lower() in ("true", "t", "1") + + parser = argparse.ArgumentParser() + parser.add_argument("--server_url", type=str) + parser.add_argument("--image_file", type=str) + parser.add_argument("--batch_size", type=int, default=1) + parser.add_argument("--resize_short", type=int, default=256) + parser.add_argument("--crop_size", type=int, default=224) + parser.add_argument("--normalize", type=str2bool, default=True) + parser.add_argument("--to_chw", type=str2bool, default=True) + return parser.parse_args() + + +class PreprocessConfig(object): + def __init__(self, + resize_short=256, + crop_size=224, + normalize=True, + to_chw=True): + self.config = [{ + 'ResizeImage': { + 'resize_short': resize_short + } + }, { + 'CropImage': { + 'size': crop_size + } + }] + if normalize: + self.config.append({ + 'NormalizeImage': { + 'scale': 0.00392157, + 'mean': [0.485, 0.456, 0.406], + 'std': [0.229, 0.224, 0.225], + 'order': '' + } + }) + if to_chw: + self.config.append({'ToCHWImage': None}) + + def __call__(self): + return self.config + + +def main(args): + image_path_list = get_image_list(args.image_file) + headers = {"Content-type": "application/json"} + preprocess_ops = create_operators( + PreprocessConfig(args.resize_short, args.crop_size, args.normalize, + args.to_chw)()) + + cnt = 0 + predict_time = 0 + all_score = 0.0 + start_time = time.time() + + img_data_list = [] + img_name_list = [] + cnt = 0 + for idx, img_path in enumerate(image_path_list): + img = cv2.imread(img_path) + if img is None: + logger.warning( + f"Image file failed to read and has been skipped. The path: {img_path}" + ) + continue + else: + img = img[:, :, ::-1] + for ops in preprocess_ops: + img = ops(img) + img = np.array(img) + img_data_list.append(img) + + img_name = img_path.split('/')[-1] + img_name_list.append(img_name) + cnt += 1 + if cnt % args.batch_size == 0 or (idx + 1) == len(image_path_list): + inputs = np.array(img_data_list) + b64str, revert_shape = np_to_b64(inputs) + data = { + "images": b64str, + "revert_params": { + "shape": revert_shape, + "dtype": str(inputs.dtype) + } + } + try: + r = requests.post( + url=args.server_url, + headers=headers, + data=json.dumps(data)) + r.raise_for_status + if r.json()["status"] != "000": + msg = r.json()["msg"] + raise Exception(msg) + except Exception as e: + logger.error(f"{e}, in file(s): {img_name_list[0]} etc.") + continue + else: + results = r.json()["results"] + preds = results["prediction"] + elapse = results["elapse"] + + cnt += len(preds) + predict_time += elapse + + for number, result_list in enumerate(preds): + all_score += result_list["scores"][0] + pred_str = ", ".join( + [f"{k}: {result_list[k]}" for k in result_list]) + logger.info( + f"File:{img_name_list[number]}, The result(s): {pred_str}" + ) + + finally: + img_data_list = [] + img_name_list = [] + + total_time = time.time() - start_time + logger.info("The average time of prediction cost: {:.3f} s/image".format( + predict_time / cnt)) + logger.info("The average time cost: {:.3f} s/image".format(total_time / + cnt)) + logger.info("The average top-1 score: {:.3f}".format(all_score / cnt)) + + +if __name__ == '__main__': + args = get_args() + main(args) diff --git a/src/PaddleClas/deploy/images/0517_2715693311.jpg b/src/PaddleClas/deploy/images/0517_2715693311.jpg new file mode 100644 index 0000000..bd9d2f6 Binary files /dev/null and b/src/PaddleClas/deploy/images/0517_2715693311.jpg differ diff --git a/src/PaddleClas/deploy/images/ILSVRC2012_val_00000010.jpeg b/src/PaddleClas/deploy/images/ILSVRC2012_val_00000010.jpeg new file mode 100644 index 0000000..6fcafb4 Binary files /dev/null and b/src/PaddleClas/deploy/images/ILSVRC2012_val_00000010.jpeg differ diff --git a/src/PaddleClas/deploy/images/ILSVRC2012_val_00010010.jpeg b/src/PaddleClas/deploy/images/ILSVRC2012_val_00010010.jpeg new file mode 100644 index 0000000..4908ac4 Binary files /dev/null and b/src/PaddleClas/deploy/images/ILSVRC2012_val_00010010.jpeg differ diff --git a/src/PaddleClas/deploy/images/ILSVRC2012_val_00020010.jpeg b/src/PaddleClas/deploy/images/ILSVRC2012_val_00020010.jpeg new file mode 100644 index 0000000..9c6f877 Binary files /dev/null and b/src/PaddleClas/deploy/images/ILSVRC2012_val_00020010.jpeg differ diff --git a/src/PaddleClas/deploy/images/ILSVRC2012_val_00030010.jpeg b/src/PaddleClas/deploy/images/ILSVRC2012_val_00030010.jpeg new file mode 100644 index 0000000..0a073fe Binary files /dev/null and b/src/PaddleClas/deploy/images/ILSVRC2012_val_00030010.jpeg differ diff --git a/src/PaddleClas/deploy/images/anmuxi.jpg b/src/PaddleClas/deploy/images/anmuxi.jpg new file mode 100644 index 0000000..735ea5a Binary files /dev/null and b/src/PaddleClas/deploy/images/anmuxi.jpg differ diff --git a/src/PaddleClas/deploy/images/coco_000000570688.jpg b/src/PaddleClas/deploy/images/coco_000000570688.jpg new file mode 100644 index 0000000..cb304bd Binary files /dev/null and b/src/PaddleClas/deploy/images/coco_000000570688.jpg differ diff --git a/src/PaddleClas/deploy/images/wangzai.jpg b/src/PaddleClas/deploy/images/wangzai.jpg new file mode 100644 index 0000000..fe7aa77 Binary files /dev/null and b/src/PaddleClas/deploy/images/wangzai.jpg differ diff --git a/src/PaddleClas/deploy/lite/Makefile b/src/PaddleClas/deploy/lite/Makefile new file mode 100644 index 0000000..f18864a --- /dev/null +++ b/src/PaddleClas/deploy/lite/Makefile @@ -0,0 +1,68 @@ +ARM_ABI = arm8 +export ARM_ABI + +include ../Makefile.def + +LITE_ROOT=../../../ + +THIRD_PARTY_DIR=${LITE_ROOT}/third_party + +OPENCV_VERSION=opencv4.1.0 + +ifeq (${ARM_ABI}, arm8) + ARM_PATH=arm64-v8a +endif +ifeq (${ARM_ABI}, arm7) + ARM_PATH=armeabi-v7a +endif + +OPENCV_LIBS = ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/libs/libopencv_imgcodecs.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/libs/libopencv_imgproc.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/libs/libopencv_core.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/libtegra_hal.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/liblibjpeg-turbo.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/liblibwebp.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/liblibpng.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/liblibjasper.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/liblibtiff.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/libIlmImf.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/libtbb.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PATH}/3rdparty/libs/libcpufeatures.a + +OPENCV_INCLUDE = -I../../../third_party/${OPENCV_VERSION}/${ARM_PATH}/include + +CXX_INCLUDES = $(INCLUDES) ${OPENCV_INCLUDE} -I$(LITE_ROOT)/cxx/include + +CXX_LIBS = ${OPENCV_LIBS} -L$(LITE_ROOT)/cxx/lib/ -lpaddle_light_api_shared $(SYSTEM_LIBS) + +############################################################### +# How to use one of static libaray: # +# `libpaddle_api_full_bundled.a` # +# `libpaddle_api_light_bundled.a` # +############################################################### +# Note: default use lite's shared library. # +############################################################### +# 1. Comment above line using `libpaddle_light_api_shared.so` +# 2. Undo comment below line using `libpaddle_api_light_bundled.a` + +#CXX_LIBS = $(LITE_ROOT)/cxx/lib/libpaddle_api_light_bundled.a $(SYSTEM_LIBS) + +clas_system: fetch_opencv clas_system.o + $(CC) $(SYSROOT_LINK) $(CXXFLAGS_LINK) clas_system.o -o clas_system $(CXX_LIBS) $(LDFLAGS) + +clas_system.o: image_classfication.cpp + $(CC) $(SYSROOT_COMPLILE) $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o clas_system.o -c image_classfication.cpp + +fetch_opencv: + @ test -d ${THIRD_PARTY_DIR} || mkdir ${THIRD_PARTY_DIR} + @ test -e ${THIRD_PARTY_DIR}/${OPENCV_VERSION}.tar.gz || \ + (echo "fetch opencv libs" && \ + wget -P ${THIRD_PARTY_DIR} https://paddle-inference-dist.bj.bcebos.com/${OPENCV_VERSION}.tar.gz) + @ test -d ${THIRD_PARTY_DIR}/${OPENCV_VERSION} || \ + tar -zxvf ${THIRD_PARTY_DIR}/${OPENCV_VERSION}.tar.gz -C ${THIRD_PARTY_DIR} + + +.PHONY: clean +clean: + rm -f clas_system.o + rm -f clas_system diff --git a/src/PaddleClas/deploy/lite/benchmark/benchmark.sh b/src/PaddleClas/deploy/lite/benchmark/benchmark.sh new file mode 100644 index 0000000..591331e --- /dev/null +++ b/src/PaddleClas/deploy/lite/benchmark/benchmark.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# ref1: https://github.com/PaddlePaddle/Paddle-Lite/blob/58b2d7dd89/lite/api/benchmark.cc +# ref2: https://paddle-inference-dist.bj.bcebos.com/PaddleLite/benchmark_0/benchmark.sh + +set -e + +# Check input +if [ $# -lt 3 ]; +then + echo "Input error" + echo "Usage:" + echo " sh benchmark.sh " + echo " sh benchmark.sh " + exit +fi + +# Set benchmark params +ANDROID_DIR=/data/local/tmp +BENCHMARK_BIN=$1 +MODELS_DIR=$2 +RESULT_FILENAME=$3 + +WARMUP=10 +REPEATS=30 +IS_RUN_MODEL_OPTIMIZE=false +IS_RUN_QUANTIZED_MODEL=false +NUM_THREADS_LIST=(1 2 4) +MODELS_LIST=$(ls $MODELS_DIR) + +# Check input +if [ $# -gt 3 ]; +then + IS_RUN_MODEL_OPTIMIZE=$4 +fi + +# Adb push benchmark_bin, models +adb push $BENCHMARK_BIN $ANDROID_DIR/benchmark_bin +adb shell chmod +x $ANDROID_DIR/benchmark_bin +adb push $MODELS_DIR $ANDROID_DIR + +# Run benchmark +adb shell "echo 'PaddleLite Benchmark' > $ANDROID_DIR/$RESULT_FILENAME" +for threads in ${NUM_THREADS_LIST[@]}; do + adb shell "echo Threads=$threads Warmup=$WARMUP Repeats=$REPEATS >> $ANDROID_DIR/$RESULT_FILENAME" + for model_name in ${MODELS_LIST[@]}; do + echo "Model=$model_name Threads=$threads" + if [ "$IS_RUN_MODEL_OPTIMIZE" = true ]; + then + adb shell "$ANDROID_DIR/benchmark_bin \ + --model_dir=$ANDROID_DIR/${MODELS_DIR}/$model_name \ + --model_filename=model \ + --param_filename=params \ + --warmup=$WARMUP \ + --repeats=$REPEATS \ + --threads=$threads \ + --result_filename=$ANDROID_DIR/$RESULT_FILENAME" + else + adb shell "$ANDROID_DIR/benchmark_bin \ + --optimized_model_path=$ANDROID_DIR/${MODELS_DIR}/$model_name \ + --warmup=$WARMUP \ + --repeats=$REPEATS \ + --threads=$threads \ + --result_filename=$ANDROID_DIR/$RESULT_FILENAME" + fi + done + adb shell "echo >> $ANDROID_DIR/$RESULT_FILENAME" +done + +# Adb pull benchmark result, show result +adb pull $ANDROID_DIR/$RESULT_FILENAME . +echo "\n--------------------------------------" +cat $RESULT_FILENAME +echo "--------------------------------------" diff --git a/src/PaddleClas/deploy/lite/config.txt b/src/PaddleClas/deploy/lite/config.txt new file mode 100644 index 0000000..08cee3d --- /dev/null +++ b/src/PaddleClas/deploy/lite/config.txt @@ -0,0 +1,6 @@ +clas_model_file ./MobileNetV3_large_x1_0.nb +label_path ./imagenet1k_label_list.txt +resize_short_size 256 +crop_size 224 +visualize 0 +enable_benchmark 0 diff --git a/src/PaddleClas/deploy/lite/image_classfication.cpp b/src/PaddleClas/deploy/lite/image_classfication.cpp new file mode 100644 index 0000000..535f3c8 --- /dev/null +++ b/src/PaddleClas/deploy/lite/image_classfication.cpp @@ -0,0 +1,344 @@ +// 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. + +#include "paddle_api.h" // NOLINT +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace paddle::lite_api; // NOLINT +using namespace std; + +struct RESULT { + std::string class_name; + int class_id; + float score; +}; + +std::vector PostProcess(const float *output_data, int output_size, + const std::vector &word_labels, + cv::Mat &output_image) { + const int TOPK = 5; + int max_indices[TOPK]; + double max_scores[TOPK]; + for (int i = 0; i < TOPK; i++) { + max_indices[i] = 0; + max_scores[i] = 0; + } + for (int i = 0; i < output_size; i++) { + float score = output_data[i]; + int index = i; + for (int j = 0; j < TOPK; j++) { + if (score > max_scores[j]) { + index += max_indices[j]; + max_indices[j] = index - max_indices[j]; + index -= max_indices[j]; + score += max_scores[j]; + max_scores[j] = score - max_scores[j]; + score -= max_scores[j]; + } + } + } + + std::vector results(TOPK); + for (int i = 0; i < results.size(); i++) { + results[i].class_name = "Unknown"; + if (max_indices[i] >= 0 && max_indices[i] < word_labels.size()) { + results[i].class_name = word_labels[max_indices[i]]; + } + results[i].score = max_scores[i]; + results[i].class_id = max_indices[i]; + cv::putText(output_image, + "Top" + std::to_string(i + 1) + "." + results[i].class_name + + ":" + std::to_string(results[i].score), + cv::Point2d(5, i * 18 + 20), cv::FONT_HERSHEY_PLAIN, 1, + cv::Scalar(51, 255, 255)); + } + return results; +} + +// fill tensor with mean and scale and trans layout: nhwc -> nchw, neon speed up +void NeonMeanScale(const float *din, float *dout, int size, + const std::vector mean, + const std::vector scale) { + if (mean.size() != 3 || scale.size() != 3) { + std::cerr << "[ERROR] mean or scale size must equal to 3\n"; + exit(1); + } + float32x4_t vmean0 = vdupq_n_f32(mean[0]); + float32x4_t vmean1 = vdupq_n_f32(mean[1]); + float32x4_t vmean2 = vdupq_n_f32(mean[2]); + float32x4_t vscale0 = vdupq_n_f32(scale[0]); + float32x4_t vscale1 = vdupq_n_f32(scale[1]); + float32x4_t vscale2 = vdupq_n_f32(scale[2]); + + float *dout_c0 = dout; + float *dout_c1 = dout + size; + float *dout_c2 = dout + size * 2; + + int i = 0; + for (; i < size - 3; i += 4) { + float32x4x3_t vin3 = vld3q_f32(din); + float32x4_t vsub0 = vsubq_f32(vin3.val[0], vmean0); + float32x4_t vsub1 = vsubq_f32(vin3.val[1], vmean1); + float32x4_t vsub2 = vsubq_f32(vin3.val[2], vmean2); + float32x4_t vs0 = vmulq_f32(vsub0, vscale0); + float32x4_t vs1 = vmulq_f32(vsub1, vscale1); + float32x4_t vs2 = vmulq_f32(vsub2, vscale2); + vst1q_f32(dout_c0, vs0); + vst1q_f32(dout_c1, vs1); + vst1q_f32(dout_c2, vs2); + + din += 12; + dout_c0 += 4; + dout_c1 += 4; + dout_c2 += 4; + } + for (; i < size; i++) { + *(dout_c0++) = (*(din++) - mean[0]) * scale[0]; + *(dout_c1++) = (*(din++) - mean[1]) * scale[1]; + *(dout_c2++) = (*(din++) - mean[2]) * scale[2]; + } +} + +cv::Mat ResizeImage(const cv::Mat &img, const int &resize_short_size) { + int w = img.cols; + int h = img.rows; + + cv::Mat resize_img; + + float ratio = 1.f; + if (h < w) { + ratio = float(resize_short_size) / float(h); + } else { + ratio = float(resize_short_size) / float(w); + } + int resize_h = round(float(h) * ratio); + int resize_w = round(float(w) * ratio); + + cv::resize(img, resize_img, cv::Size(resize_w, resize_h)); + return resize_img; +} + +cv::Mat CenterCropImg(const cv::Mat &img, const int &crop_size) { + int resize_w = img.cols; + int resize_h = img.rows; + int w_start = int((resize_w - crop_size) / 2); + int h_start = int((resize_h - crop_size) / 2); + cv::Rect rect(w_start, h_start, crop_size, crop_size); + cv::Mat crop_img = img(rect); + return crop_img; +} + +std::vector +RunClasModel(std::shared_ptr predictor, const cv::Mat &img, + const std::map &config, + const std::vector &word_labels, double &cost_time) { + // Read img + int resize_short_size = stoi(config.at("resize_short_size")); + int crop_size = stoi(config.at("crop_size")); + int visualize = stoi(config.at("visualize")); + + cv::Mat resize_image = ResizeImage(img, resize_short_size); + + cv::Mat crop_image = CenterCropImg(resize_image, crop_size); + + cv::Mat img_fp; + double e = 1.0 / 255.0; + crop_image.convertTo(img_fp, CV_32FC3, e); + + // Prepare input data from image + std::unique_ptr input_tensor(std::move(predictor->GetInput(0))); + input_tensor->Resize({1, 3, img_fp.rows, img_fp.cols}); + auto *data0 = input_tensor->mutable_data(); + + std::vector mean = {0.485f, 0.456f, 0.406f}; + std::vector scale = {1 / 0.229f, 1 / 0.224f, 1 / 0.225f}; + const float *dimg = reinterpret_cast(img_fp.data); + NeonMeanScale(dimg, data0, img_fp.rows * img_fp.cols, mean, scale); + + auto start = std::chrono::system_clock::now(); + // Run predictor + predictor->Run(); + + // Get output and post process + std::unique_ptr output_tensor( + std::move(predictor->GetOutput(0))); + auto *output_data = output_tensor->data(); + auto end = std::chrono::system_clock::now(); + auto duration = + std::chrono::duration_cast(end - start); + cost_time = double(duration.count()) * + std::chrono::microseconds::period::num / + std::chrono::microseconds::period::den; + + int output_size = 1; + for (auto dim : output_tensor->shape()) { + output_size *= dim; + } + + cv::Mat output_image; + auto results = + PostProcess(output_data, output_size, word_labels, output_image); + + if (visualize) { + std::string output_image_path = "./clas_result.png"; + cv::imwrite(output_image_path, output_image); + std::cout << "save output image into " << output_image_path << std::endl; + } + + return results; +} + +std::shared_ptr LoadModel(std::string model_file) { + MobileConfig config; + config.set_model_from_file(model_file); + + std::shared_ptr predictor = + CreatePaddlePredictor(config); + return predictor; +} + +std::vector split(const std::string &str, + const std::string &delim) { + std::vector res; + if ("" == str) + return res; + char *strs = new char[str.length() + 1]; + std::strcpy(strs, str.c_str()); + + char *d = new char[delim.length() + 1]; + std::strcpy(d, delim.c_str()); + + char *p = std::strtok(strs, d); + while (p) { + string s = p; + res.push_back(s); + p = std::strtok(NULL, d); + } + + return res; +} + +std::vector ReadDict(std::string path) { + std::ifstream in(path); + std::string filename; + std::string line; + std::vector m_vec; + if (in) { + while (getline(in, line)) { + m_vec.push_back(line); + } + } else { + std::cout << "no such file" << std::endl; + } + return m_vec; +} + +std::map LoadConfigTxt(std::string config_path) { + auto config = ReadDict(config_path); + + std::map dict; + for (int i = 0; i < config.size(); i++) { + std::vector res = split(config[i], " "); + dict[res[0]] = res[1]; + } + return dict; +} + +void PrintConfig(const std::map &config) { + std::cout << "=======PaddleClas lite demo config======" << std::endl; + for (auto iter = config.begin(); iter != config.end(); iter++) { + std::cout << iter->first << " : " << iter->second << std::endl; + } + std::cout << "=======End of PaddleClas lite demo config======" << std::endl; +} + +std::vector LoadLabels(const std::string &path) { + std::ifstream file; + std::vector labels; + file.open(path); + while (file) { + std::string line; + std::getline(file, line); + std::string::size_type pos = line.find(" "); + if (pos != std::string::npos) { + line = line.substr(pos); + } + labels.push_back(line); + } + file.clear(); + file.close(); + return labels; +} + +int main(int argc, char **argv) { + if (argc < 3) { + std::cerr << "[ERROR] usage: " << argv[0] << " config_path img_path\n"; + exit(1); + } + + std::string config_path = argv[1]; + std::string img_path = argv[2]; + + // load config + auto config = LoadConfigTxt(config_path); + PrintConfig(config); + + double elapsed_time = 0.0; + int warmup_iter = 10; + + bool enable_benchmark = bool(stoi(config.at("enable_benchmark"))); + int total_cnt = enable_benchmark ? 1000 : 1; + + std::string clas_model_file = config.at("clas_model_file"); + std::string label_path = config.at("label_path"); + + // Load Labels + std::vector word_labels = LoadLabels(label_path); + + auto clas_predictor = LoadModel(clas_model_file); + for (int j = 0; j < total_cnt; ++j) { + cv::Mat srcimg = cv::imread(img_path, cv::IMREAD_COLOR); + cv::cvtColor(srcimg, srcimg, cv::COLOR_BGR2RGB); + + double run_time = 0; + std::vector results = + RunClasModel(clas_predictor, srcimg, config, word_labels, run_time); + + std::cout << "===clas result for image: " << img_path << "===" << std::endl; + for (int i = 0; i < results.size(); i++) { + std::cout << "\t" + << "Top-" << i + 1 << ", class_id: " << results[i].class_id + << ", class_name: " << results[i].class_name + << ", score: " << results[i].score << std::endl; + } + if (j >= warmup_iter) { + elapsed_time += run_time; + std::cout << "Current image path: " << img_path << std::endl; + std::cout << "Current time cost: " << run_time << " s, " + << "average time cost in all: " + << elapsed_time / (j + 1 - warmup_iter) << " s." << std::endl; + } else { + std::cout << "Current time cost: " << run_time << " s." << std::endl; + } + } + + return 0; +} diff --git a/src/PaddleClas/deploy/lite/imgs/lite_demo_result.png b/src/PaddleClas/deploy/lite/imgs/lite_demo_result.png new file mode 100644 index 0000000..b778f15 Binary files /dev/null and b/src/PaddleClas/deploy/lite/imgs/lite_demo_result.png differ diff --git a/src/PaddleClas/deploy/lite/imgs/tabby_cat.jpg b/src/PaddleClas/deploy/lite/imgs/tabby_cat.jpg new file mode 100644 index 0000000..6eb5b71 Binary files /dev/null and b/src/PaddleClas/deploy/lite/imgs/tabby_cat.jpg differ diff --git a/src/PaddleClas/deploy/lite/prepare.sh b/src/PaddleClas/deploy/lite/prepare.sh new file mode 100644 index 0000000..ed1f13a --- /dev/null +++ b/src/PaddleClas/deploy/lite/prepare.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ $# != 1 ] ; then +echo "USAGE: $0 your_inference_lite_lib_path" +exit 1; +fi + +mkdir -p $1/demo/cxx/clas/debug/ +cp ../../ppcls/utils/imagenet1k_label_list.txt $1/demo/cxx/clas/debug/ +cp -r ./* $1/demo/cxx/clas/ +cp ./config.txt $1/demo/cxx/clas/debug/ +cp ./imgs/tabby_cat.jpg $1/demo/cxx/clas/debug/ + +echo "Prepare Done" diff --git a/src/PaddleClas/deploy/lite/readme.md b/src/PaddleClas/deploy/lite/readme.md new file mode 100644 index 0000000..176e62c --- /dev/null +++ b/src/PaddleClas/deploy/lite/readme.md @@ -0,0 +1,265 @@ +# 端侧部署 + +本教程将介绍基于[Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite) 在移动端部署PaddleClas分类模型的详细步骤。 + +Paddle Lite是飞桨轻量化推理引擎,为手机、IOT端提供高效推理能力,并广泛整合跨平台硬件,为端侧部署及应用落地问题提供轻量化的部署方案。如果希望直接测试速度,可以参考[Paddle-Lite移动端benchmark测试教程](../../docs/zh_CN/extension/paddle_mobile_inference.md)。 + + +## 1. 准备环境 + +### 运行准备 +- 电脑(编译Paddle Lite) +- 安卓手机(armv7或armv8) + +### 1.1 准备交叉编译环境 +交叉编译环境用于编译 Paddle Lite 和 PaddleClas 的C++ demo。 +支持多种开发环境,不同开发环境的编译流程请参考对应文档。 + +1. [Docker](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#docker) +2. [Linux](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#linux) +3. [MAC OS](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#mac-os) + +### 1.2 准备预测库 + +预测库有两种获取方式: +1. [建议]直接下载,预测库下载链接如下: + |平台|预测库下载链接| + |-|-| + |Android|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv7.gcc.c++_static.with_extra.with_cv.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv8.gcc.c++_static.with_extra.with_cv.tar.gz)| + |iOS|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv7.with_cv.with_extra.tiny_publish.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv8.with_cv.with_extra.tiny_publish.tar.gz)| + + **注**: + 1. 如果是从 Paddle-Lite [官方文档](https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#android-toolchain-gcc)下载的预测库, + 注意选择`with_extra=ON,with_cv=ON`的下载链接。 + 2. 如果使用量化的模型部署在端侧,建议使用Paddle-Lite develop分支编译预测库。 + +2. 编译Paddle-Lite得到预测库,Paddle-Lite的编译方式如下: +```shell +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +# 如果使用编译方式,建议使用develop分支编译预测库 +git checkout develop +./lite/tools/build_android.sh --arch=armv8 --with_cv=ON --with_extra=ON +``` + +**注意**:编译Paddle-Lite获得预测库时,需要打开`--with_cv=ON --with_extra=ON`两个选项,`--arch`表示`arm`版本,这里指定为armv8,更多编译命令介绍请参考[链接](https://paddle-lite.readthedocs.io/zh/latest/user_guides/Compile/Android.html#id2)。 + +直接下载预测库并解压后,可以得到`inference_lite_lib.android.armv8/`文件夹,通过编译Paddle-Lite得到的预测库位于`Paddle-Lite/build.lite.android.armv8.gcc/inference_lite_lib.android.armv8/`文件夹下。 +预测库的文件目录如下: + +``` +inference_lite_lib.android.armv8/ +|-- cxx C++ 预测库和头文件 +| |-- include C++ 头文件 +| | |-- paddle_api.h +| | |-- paddle_image_preprocess.h +| | |-- paddle_lite_factory_helper.h +| | |-- paddle_place.h +| | |-- paddle_use_kernels.h +| | |-- paddle_use_ops.h +| | `-- paddle_use_passes.h +| `-- lib C++预测库 +| |-- libpaddle_api_light_bundled.a C++静态库 +| `-- libpaddle_light_api_shared.so C++动态库 +|-- java Java预测库 +| |-- jar +| | `-- PaddlePredictor.jar +| |-- so +| | `-- libpaddle_lite_jni.so +| `-- src +|-- demo C++和Java示例代码 +| |-- cxx C++ 预测库demo +| `-- java Java 预测库demo +``` + +## 2 开始运行 + +### 2.1 模型优化 + +Paddle-Lite 提供了多种策略来自动优化原始的模型,其中包括量化、子图融合、混合调度、Kernel优选等方法,使用Paddle-Lite的`opt`工具可以自动对inference模型进行优化,目前支持两种优化方式,优化后的模型更轻量,模型运行速度更快。 + +**注意**:如果已经准备好了 `.nb` 结尾的模型文件,可以跳过此步骤。 + +#### 2.1.1 [建议]pip安装paddlelite并进行转换 + +Python下安装 `paddlelite`,目前最高支持`Python3.7`。 +**注意**:`paddlelite`whl包版本必须和预测库版本对应。 + +```shell +pip install paddlelite==2.8 +``` + +之后使用`paddle_lite_opt`工具可以进行inference模型的转换。`paddle_lite_opt`的部分参数如下 + +|选项|说明| +|-|-| +|--model_dir|待优化的PaddlePaddle模型(非combined形式)的路径| +|--model_file|待优化的PaddlePaddle模型(combined形式)的网络结构文件路径| +|--param_file|待优化的PaddlePaddle模型(combined形式)的权重文件路径| +|--optimize_out_type|输出模型类型,目前支持两种类型:protobuf和naive_buffer,其中naive_buffer是一种更轻量级的序列化/反序列化实现。若您需要在mobile端执行模型预测,请将此选项设置为naive_buffer。默认为protobuf| +|--optimize_out|优化模型的输出路径| +|--valid_targets|指定模型可执行的backend,默认为arm。目前可支持x86、arm、opencl、npu、xpu,可以同时指定多个backend(以空格分隔),Model Optimize Tool将会自动选择最佳方式。如果需要支持华为NPU(Kirin 810/990 Soc搭载的达芬奇架构NPU),应当设置为npu, arm| +|--record_tailoring_info|当使用 根据模型裁剪库文件 功能时,则设置该选项为true,以记录优化后模型含有的kernel和OP信息,默认为false| + +`--model_file`表示inference模型的model文件地址,`--param_file`表示inference模型的param文件地址;`optimize_out`用于指定输出文件的名称(不需要添加`.nb`的后缀)。直接在命令行中运行`paddle_lite_opt`,也可以查看所有参数及其说明。 + + +#### 2.1.2 源码编译Paddle-Lite生成opt工具 + +模型优化需要Paddle-Lite的`opt`可执行文件,可以通过编译Paddle-Lite源码获得,编译步骤如下: +```shell +# 如果准备环境时已经clone了Paddle-Lite,则不用重新clone Paddle-Lite +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +git checkout develop +# 启动编译 +./lite/tools/build.sh build_optimize_tool +``` + +编译完成后,`opt`文件位于`build.opt/lite/api/`下,可通过如下方式查看`opt`的运行选项和使用方式; +```shell +cd build.opt/lite/api/ +./opt +``` + +`opt`的使用方式与参数与上面的`paddle_lite_opt`完全一致。 + + + +#### 2.1.3 转换示例 + +下面以PaddleClas的 `MobileNetV3_large_x1_0` 模型为例,介绍使用`paddle_lite_opt`完成预训练模型到inference模型,再到Paddle-Lite优化模型的转换。 + +```shell +# 进入PaddleClas根目录 +cd PaddleClas_root_path + +# 下载并解压inference模型 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_infer.tar +tar -xf MobileNetV3_large_x1_0_infer.tar + +# 将inference模型转化为Paddle-Lite优化模型 +paddle_lite_opt --model_file=./MobileNetV3_large_x1_0_infer/inference.pdmodel --param_file=./MobileNetV3_large_x1_0_infer/inference.pdiparams --optimize_out=./MobileNetV3_large_x1_0 +``` + +最终在当前文件夹下生成`MobileNetV3_large_x1_0.nb`的文件。 + +**注意**:`--optimize_out` 参数为优化后模型的保存路径,无需加后缀`.nb`;`--model_file` 参数为模型结构信息文件的路径,`--param_file` 参数为模型权重信息文件的路径,请注意文件名。 + + +### 2.2 与手机联调 + +首先需要进行一些准备工作。 +1. 准备一台arm8的安卓手机,如果编译的预测库和opt文件是armv7,则需要arm7的手机,并修改Makefile中`ARM_ABI = arm7`。 +2. 电脑上安装ADB工具,用于调试。 ADB安装方式如下: + + 3.1. MAC电脑安装ADB: + + ```shell + brew cask install android-platform-tools + ``` + 3.2. Linux安装ADB + ```shell + sudo apt update + sudo apt install -y wget adb + ``` + 3.3. Window安装ADB + + win上安装需要去谷歌的安卓平台下载ADB软件包进行安装:[链接](https://developer.android.com/studio) + +4. 手机连接电脑后,开启手机`USB调试`选项,选择`文件传输`模式,在电脑终端中输入: + +```shell +adb devices +``` +如果有device输出,则表示安装成功,如下所示: +``` +List of devices attached +744be294 device +``` + +5. 准备优化后的模型、预测库文件、测试图像和类别映射文件。 + +```shell +cd PaddleClas_root_path +cd deploy/lite/ + +# 运行prepare.sh +# prepare.sh 会将预测库文件、测试图像和使用的字典文件放置在预测库中的demo/cxx/clas文件夹下 +sh prepare.sh /{lite prediction library path}/inference_lite_lib.android.armv8 + +# 进入lite demo的工作目录 +cd /{lite prediction library path}/inference_lite_lib.android.armv8/ +cd demo/cxx/clas/ + +# 将C++预测动态库so文件复制到debug文件夹中 +cp ../../../cxx/lib/libpaddle_light_api_shared.so ./debug/ +``` + +`prepare.sh` 以 `PaddleClas/deploy/lite/imgs/tabby_cat.jpg` 作为测试图像,将测试图像复制到`demo/cxx/clas/debug/` 文件夹下。 +将 `paddle_lite_opt` 工具优化后的模型文件放置到 `/{lite prediction library path}/inference_lite_lib.android.armv8/demo/cxx/clas/debug/` 文件夹下。本例中,使用[2.1.3](#2.1.3)生成的 `MobileNetV3_large_x1_0.nb` 模型文件。 + +执行完成后,clas文件夹下将有如下文件格式: + +``` +demo/cxx/clas/ +|-- debug/ +| |--MobileNetV3_large_x1_0.nb 优化后的分类器模型文件 +| |--tabby_cat.jpg 待测试图像 +| |--imagenet1k_label_list.txt 类别映射文件 +| |--libpaddle_light_api_shared.so C++预测库文件 +| |--config.txt 分类预测超参数配置 +|-- config.txt 分类预测超参数配置 +|-- image_classfication.cpp 图像分类代码文件 +|-- Makefile 编译文件 +``` + +#### 注意: +* 上述文件中,`imagenet1k_label_list.txt` 是ImageNet1k数据集的类别映射文件,如果使用自定义的类别,需要更换该类别映射文件。 + +* `config.txt` 包含了分类器的超参数,如下: + +```shell +clas_model_file ./MobileNetV3_large_x1_0.nb # 模型文件地址 +label_path ./imagenet1k_label_list.txt # 类别映射文本文件 +resize_short_size 256 # resize之后的短边边长 +crop_size 224 # 裁剪后用于预测的边长 +visualize 0 # 是否进行可视化,如果选择的话,会在当前文件夹下生成名为clas_result.png的图像文件。 +``` + +5. 启动调试,上述步骤完成后就可以使用ADB将文件夹 `debug/` push到手机上运行,步骤如下: + +```shell +# 执行编译,得到可执行文件clas_system +make -j + +# 将编译得到的可执行文件移动到debug文件夹中 +mv clas_system ./debug/ + +# 将上述debug文件夹push到手机上 +adb push debug /data/local/tmp/ + +adb shell +cd /data/local/tmp/debug +export LD_LIBRARY_PATH=/data/local/tmp/debug:$LD_LIBRARY_PATH + +# clas_system可执行文件的使用方式为: +# ./clas_system 配置文件路径 测试图像路径 +./clas_system ./config.txt ./tabby_cat.jpg +``` + +如果对代码做了修改,则需要重新编译并push到手机上。 + +运行效果如下: + +
+ +
+ + +## FAQ +Q1:如果想更换模型怎么办,需要重新按照流程走一遍吗? +A1:如果已经走通了上述步骤,更换模型只需要替换 `.nb` 模型文件即可,同时要注意修改下配置文件中的 `.nb` 文件路径以及类别映射文件(如有必要)。 + +Q2:换一个图测试怎么做? +A2:替换 debug 下的测试图像为你想要测试的图像,使用 ADB 再次 push 到手机上即可。 diff --git a/src/PaddleClas/deploy/lite/readme_en.md b/src/PaddleClas/deploy/lite/readme_en.md new file mode 100644 index 0000000..1027c78 --- /dev/null +++ b/src/PaddleClas/deploy/lite/readme_en.md @@ -0,0 +1,257 @@ + +# Tutorial of PaddleClas Mobile Deployment + +This tutorial will introduce how to use [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) to deploy PaddleClas models on mobile phones. + +Paddle-Lite is a lightweight inference engine for PaddlePaddle. It provides efficient inference capabilities for mobile phones and IoTs, and extensively integrates cross-platform hardware to provide lightweight deployment solutions for mobile-side deployment issues. + +If you only want to test speed, please refer to [The tutorial of Paddle-Lite mobile-side benchmark test](../../docs/zh_CN/extension/paddle_mobile_inference.md). + +## 1. Preparation + +- Computer (for compiling Paddle-Lite) +- Mobile phone (arm7 or arm8) + +## 2. Build Paddle-Lite library + +The cross-compilation environment is used to compile the C++ demos of Paddle-Lite and PaddleClas. + +For the detailed compilation directions of different development environments, please refer to the corresponding documents. + +1. [Docker](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#docker) +2. [Linux](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#linux) +3. [macOS](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#mac-os) + +## 3. Download inference library for Android or iOS + +|Platform|Inference Library Download Link| +|-|-| +|Android|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv7.gcc.c++_static.with_extra.with_cv.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv8.gcc.c++_static.with_extra.with_cv.tar.gz)| +|iOS|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv7.with_cv.with_extra.tiny_publish.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv8.with_cv.with_extra.tiny_publish.tar.gz)| + +**NOTE**: + +1. If you download the inference library from [Paddle-Lite official document](https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#android-toolchain-gcc), please choose `with_extra=ON` , `with_cv=ON` . + +2. It is recommended to build inference library using [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) develop branch if you want to deploy the [quantitative](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/deploy/slim/quantization/README_en.md) model to mobile phones. Please refer to the [link](https://paddle-lite.readthedocs.io/zh/latest/user_guides/Compile/Android.html#id2) for more detailed information about compiling. + + +The structure of the inference library is as follows: + +``` +inference_lite_lib.android.armv8/ +|-- cxx C++ inference library and header files +| |-- include C++ header files +| | |-- paddle_api.h +| | |-- paddle_image_preprocess.h +| | |-- paddle_lite_factory_helper.h +| | |-- paddle_place.h +| | |-- paddle_use_kernels.h +| | |-- paddle_use_ops.h +| | `-- paddle_use_passes.h +| `-- lib C++ inference library +| |-- libpaddle_api_light_bundled.a C++ static library +| `-- libpaddle_light_api_shared.so C++ dynamic library +|-- java Java inference library +| |-- jar +| | `-- PaddlePredictor.jar +| |-- so +| | `-- libpaddle_lite_jni.so +| `-- src +|-- demo C++ and java demos +| |-- cxx C++ demos +| `-- java Java demos +``` + + + +## 4. Inference Model Optimization + +Paddle-Lite provides a variety of strategies to automatically optimize the original training model, including quantization, sub-graph fusion, hybrid scheduling, Kernel optimization and so on. In order to make the optimization process more convenient and easy to use, Paddle-Lite provides `opt` tool to automatically complete the optimization steps and output a lightweight, optimal executable model. + +**NOTE**: If you have already got the `.nb` file, you can skip this step. + + + +### 4.1 [RECOMMEND] Use `pip` to install Paddle-Lite and optimize model + +* Use pip to install Paddle-Lite. The following command uses `pip3.7` . + +```shell +pip install paddlelite==2.8 +``` +**Note**:The version of `paddlelite`'s wheel must match that of inference lib. + +* Use `paddle_lite_opt` to optimize inference model, the parameters of `paddle_lite_opt` are as follows: + +| Parameters | Explanation | +| ----------------------- | ------------------------------------------------------------ | +| --model_dir | Path to the PaddlePaddle model (no-combined) file to be optimized. | +| --model_file | Path to the net structure file of PaddlePaddle model (combined) to be optimized. | +| --param_file | Path to the net weight files of PaddlePaddle model (combined) to be optimized. | +| --optimize_out_type | Type of output model, `protobuf` by default. Supports `protobuf` and `naive_buffer` . Compared with `protobuf`, you can use`naive_buffer` to get a more lightweight serialization/deserialization model. If you need to predict on the mobile-side, please set it to `naive_buffer`. | +| --optimize_out | Path to output model, not needed to add `.nb` suffix. | +| --valid_targets | The executable backend of the model, `arm` by default. Supports one or some of `x86` , `arm` , `opencl` , `npu` , `xpu`. If set more than one, please separate the options by space, and the `opt` tool will choose the best way automatically. If need to support Huawei NPU (DaVinci core carried by Kirin 810/990 SoC), please set it to `npu arm` . | +| --record_tailoring_info | Whether to enable `Cut the Library Files According To the Model` , `false` by default. If need to record kernel and OP infos of optimized model, please set it to `true`. | + +In addition, you can run `paddle_lite_opt` to get more detailed information about how to use. + +### 4.2 Compile Paddle-Lite to generate `opt` tool + +Optimizing model requires Paddle-Lite's `opt` executable file, which can be obtained by compiling the Paddle-Lite. The steps are as follows: + +```shell +# get the Paddle-Lite source code, if have gotten , please skip +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +git checkout develop +# compile +./lite/tools/build.sh build_optimize_tool +``` + +After the compilation is complete, the `opt` file is located under `build.opt/lite/api/`. + +`opt` tool is used in the same way as `paddle_lite_opt` , please refer to [4.1](#4.1). + + + +### 4.3 Demo of get the optimized model + +Taking the `MobileNetV3_large_x1_0` model of PaddleClas as an example, we will introduce how to use `paddle_lite_opt` to complete the conversion from the pre-trained model to the inference model, and then to the Paddle-Lite optimized model. + +```shell +# enter PaddleClas root directory +cd PaddleClas_root_path + +# download and uncompress the inference model +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_infer.tar +tar -xf MobileNetV3_large_x1_0_infer.tar + + +# convert inference model to Paddle-Lite optimized model +paddle_lite_opt --model_file=./MobileNetV3_large_x1_0_infer/inference.pdmodel --param_file=./MobileNetV3_large_x1_0_infer/inference.pdiparams --optimize_out=./MobileNetV3_large_x1_0 +``` + +When the above code command is completed, there will be ``MobileNetV3_large_x1_0.nb` in the current directory, which is the converted model file. + +## 5. Run optimized model on Phone + +1. Prepare an Android phone with `arm8`. If the compiled inference library and `opt` file are `armv7`, you need an `arm7` phone and modify `ARM_ABI = arm7` in the Makefile. + +2. Install the ADB tool on the computer. + + * Install ADB for MAC + + Recommend use homebrew to install. + + ```shell + brew cask install android-platform-tools + ``` + * Install ADB for Linux + + ```shell + sudo apt update + sudo apt install -y wget adb + ``` + * Install ADB for windows + If install ADB fo Windows, you need to download from Google's Android platform: [Download Link](https://developer.android.com/studio). + + First, make sure the phone is connected to the computer, turn on the `USB debugging` option of the phone, and select the `file transfer` mode. Verify whether ADB is installed successfully as follows: + + ```shell + $ adb devices + + List of devices attached + 744be294 device + ``` + + If there is `device` output like the above, it means the installation was successful. + +4. Prepare optimized model, inference library files, test image and dictionary file used. + +```shell +cd PaddleClas_root_path +cd deploy/lite/ + +# prepare.sh will put the inference library files, the test image and the dictionary files in demo/cxx/clas +sh prepare.sh /{lite inference library path}/inference_lite_lib.android.armv8 + +# enter the working directory of lite demo +cd /{lite inference library path}/inference_lite_lib.android.armv8/ +cd demo/cxx/clas/ + +# copy the C++ inference dynamic library file (ie. .so) to the debug folder +cp ../../../cxx/lib/libpaddle_light_api_shared.so ./debug/ +``` + +The `prepare.sh` take `PaddleClas/deploy/lite/imgs/tabby_cat.jpg` as the test image, and copy it to the `demo/cxx/clas/debug/` directory. + +You should put the model that optimized by `paddle_lite_opt` under the `demo/cxx/clas/debug/` directory. In this example, use `MobileNetV3_large_x1_0.nb` model file generated in [2.1.3](#4.3). + +The structure of the clas demo is as follows after the above command is completed: + +``` +demo/cxx/clas/ +|-- debug/ +| |--MobileNetV3_large_x1_0.nb class model +| |--tabby_cat.jpg test image +| |--imagenet1k_label_list.txt dictionary file +| |--libpaddle_light_api_shared.so C++ .so file +| |--config.txt config file +|-- config.txt config file +|-- image_classfication.cpp source code +|-- Makefile compile file +``` + +**NOTE**: + +* `Imagenet1k_label_list.txt` is the category mapping file of the `ImageNet1k` dataset. If use a custom category, you need to replace the category mapping file. +* `config.txt` contains the hyperparameters, as follows: + +```shell +clas_model_file ./MobileNetV3_large_x1_0.nb # path of model file +label_path ./imagenet1k_label_list.txt # path of category mapping file +resize_short_size 256 # the short side length after resize +crop_size 224 # side length used for inference after cropping + +visualize 0 # whether to visualize. If you set it to 1, an image file named 'clas_result.png' will be generated in the current directory. +``` + +5. Run Model on Phone + +```shell +# run compile to get the executable file 'clas_system' +make -j + +# move the compiled executable file to the debug folder +mv clas_system ./debug/ + +# push the debug folder to Phone +adb push debug /data/local/tmp/ + +adb shell +cd /data/local/tmp/debug +export LD_LIBRARY_PATH=/data/local/tmp/debug:$LD_LIBRARY_PATH + +# the usage of clas_system is as follows: +# ./clas_system "path of config file" "path of test image" +./clas_system ./config.txt ./tabby_cat.jpg +``` + +**NOTE**: If you make changes to the code, you need to recompile and repush the `debug ` folder to the phone. + +The result is as follows: + +
+ +
+ + + +## FAQ + +Q1:If I want to change the model, do I need to go through the all process again? +A1:If you have completed the above steps, you only need to replace the `.nb` model file after replacing the model. At the same time, you may need to modify the path of `.nb` file in the config file and change the category mapping file to be compatible the model . + +Q2:How to change the test picture? +A2:Replace the test image under debug folder with the image you want to test,and then repush to the Phone again. diff --git a/src/PaddleClas/deploy/lite_shitu/Makefile b/src/PaddleClas/deploy/lite_shitu/Makefile new file mode 100644 index 0000000..64ee6ae --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/Makefile @@ -0,0 +1,90 @@ +ARM_ABI = arm8#[arm7/arm8] +export ARM_ABI + +ifeq ($(ARM_ABI), arm8) + ARM_PLAT=arm64-v8a +else + ARM_PLAT=armeabi-v7a +endif +${info ARM_ABI: ${ARM_ABI}} +${info ARM_PLAT: ${ARM_PLAT}; option[arm7/arm8]} + +include ../Makefile.def + +LITE_ROOT=../../../ +${info LITE_ROOT: $(abspath ${LITE_ROOT})} + +THIRD_PARTY_DIR=third_party +${info THIRD_PARTY_DIR: $(abspath ${THIRD_PARTY_DIR})} + + +OPENCV_VERSION=opencv4.1.0 +OPENCV_LIBS = ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/libs/libopencv_imgcodecs.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/libs/libopencv_imgproc.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/libs/libopencv_core.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libtegra_hal.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibjpeg-turbo.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibwebp.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibpng.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibjasper.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibtiff.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libIlmImf.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libtbb.a \ + ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libcpufeatures.a + + +LITE_LIBS = -L${LITE_ROOT}/cxx/lib/ -lpaddle_light_api_shared +############################################################### +# How to use one of static libaray: # +# `libpaddle_api_full_bundled.a` # +# `libpaddle_api_light_bundled.a` # +############################################################### +# Note: default use lite's shared library. # +############################################################### +# 1. Comment above line using `libpaddle_light_api_shared.so` +# 2. Undo comment below line using `libpaddle_api_light_bundled.a` +# LITE_LIBS = ${LITE_ROOT}/cxx/lib/libpaddle_api_light_bundled.a + +CXX_LIBS = $(LITE_LIBS) ${OPENCV_LIBS} $(SYSTEM_LIBS) + +LOCAL_DIRSRCS=$(wildcard src/*.cc) +LOCAL_SRCS=$(notdir $(LOCAL_DIRSRCS)) +LOCAL_OBJS=$(patsubst %.cpp, %.o, $(patsubst %.cc, %.o, $(LOCAL_SRCS))) + +JSON_OBJS = json_reader.o json_value.o json_writer.o + +pp_shitu: $(LOCAL_OBJS) $(JSON_OBJS) fetch_opencv + $(CC) $(SYSROOT_LINK) $(CXXFLAGS_LINK) $(LOCAL_OBJS) $(JSON_OBJS) -o pp_shitu $(CXX_LIBS) $(LDFLAGS) + +fetch_opencv: + @ test -d ${THIRD_PARTY_DIR} || mkdir ${THIRD_PARTY_DIR} + @ test -e ${THIRD_PARTY_DIR}/${OPENCV_VERSION}.tar.gz || \ + (echo "fetch opencv libs" && \ + wget -P ${THIRD_PARTY_DIR} https://paddle-inference-dist.bj.bcebos.com/${OPENCV_VERSION}.tar.gz) + @ test -d ${THIRD_PARTY_DIR}/${OPENCV_VERSION} || \ + tar -zxf ${THIRD_PARTY_DIR}/${OPENCV_VERSION}.tar.gz -C ${THIRD_PARTY_DIR} + +fetch_json_code: + @ test -d ${THIRD_PARTY_DIR} || mkdir ${THIRD_PARTY_DIR} + @ test -e ${THIRD_PARTY_DIR}/jsoncpp_code.tar.gz || \ + (echo "fetch jsoncpp_code.tar.gz" && \ + wget -P ${THIRD_PARTY_DIR} https://bj.bcebos.com/v1/paddledet/deploy/jsoncpp_code.tar.gz ) + @ test -d ${THIRD_PARTY_DIR}/jsoncpp_code || \ + tar -zxf ${THIRD_PARTY_DIR}/jsoncpp_code.tar.gz -C ${THIRD_PARTY_DIR} + +LOCAL_INCLUDES = -I./ -Iinclude +OPENCV_INCLUDE = -I${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/include +JSON_INCLUDE = -I${THIRD_PARTY_DIR}/jsoncpp_code/include +CXX_INCLUDES = ${LOCAL_INCLUDES} ${INCLUDES} ${OPENCV_INCLUDE} ${JSON_INCLUDE} -I$(LITE_ROOT)/cxx/include + + +$(LOCAL_OBJS): %.o: src/%.cc fetch_opencv fetch_json_code + $(CC) $(SYSROOT_COMPLILE) $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -c $< -o $@ + +$(JSON_OBJS): %.o: ${THIRD_PARTY_DIR}/jsoncpp_code/%.cpp fetch_json_code + $(CC) $(SYSROOT_COMPLILE) $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -c $< -o $@ + +.PHONY: clean fetch_opencv fetch_json_code +clean: + rm -rf $(LOCAL_OBJS) $(JSON_OBJS) + rm -f pp_shitu diff --git a/src/PaddleClas/deploy/lite_shitu/README.md b/src/PaddleClas/deploy/lite_shitu/README.md new file mode 100644 index 0000000..8f5462f --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/README.md @@ -0,0 +1,218 @@ +# PP-ShiTu在Paddle-Lite端侧部署 + +本教程将介绍基于[Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite) 在移动端部署PaddleClas PP-ShiTu模型的详细步骤。 + +Paddle Lite是飞桨轻量化推理引擎,为手机、IOT端提供高效推理能力,并广泛整合跨平台硬件,为端侧部署及应用落地问题提供轻量化的部署方案。 + +## 1. 准备环境 + +### 运行准备 +- 电脑(编译Paddle Lite) +- 安卓手机(armv7或armv8) + +### 1.1 准备交叉编译环境 +交叉编译环境用于编译 Paddle Lite 和 PaddleClas 的PP-ShiTu Lite demo。 +支持多种开发环境,不同开发环境的编译流程请参考对应文档,请确保安装完成Java jdk、Android NDK(R17以上)。 + +1. [Docker](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#docker) +2. [Linux](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#linux) +3. [MAC OS](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html#mac-os) + +```shell +# 配置完成交叉编译环境后,更新环境变量 +# for docker、Linux +source ~/.bashrc +# for Mac OS +source ~/.bash_profile +``` + +### 1.2 准备预测库 + +预测库有两种获取方式: +1. [**建议**]直接下载,预测库下载链接如下: + |平台| 架构 | 预测库下载链接| + |-|-|-| + |Android| arm7 | [inference_lite_lib](https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.android.armv7.clang.c++_static.with_extra.with_cv.tar.gz) | + | Android | arm8 | [inference_lite_lib](https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.android.armv8.clang.c++_static.with_extra.with_cv.tar.gz) | + | Android | arm8(FP16) | [inference_lite_lib](https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.android.armv8_clang_c++_static_with_extra_with_cv_with_fp16.tiny_publish_427e46.zip) | + +**注意**:1. 如果是从 Paddle-Lite [官方文档](https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#android-toolchain-gcc)下载的预测库,注意选择`with_extra=ON,with_cv=ON`的下载链接。2. 目前只提供Android端demo,IOS端demo可以参考[Paddle-Lite IOS demo](https://github.com/PaddlePaddle/Paddle-Lite-Demo/tree/master/PaddleLite-ios-demo) + + +2. 编译Paddle-Lite得到预测库,Paddle-Lite的编译方式如下: +```shell +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +# 如果使用编译方式,建议使用develop分支编译预测库 +git checkout develop +# FP32 +./lite/tools/build_android.sh --arch=armv8 --toolchain=clang --with_cv=ON --with_extra=ON +# FP16 +./lite/tools/build_android.sh --arch=armv8 --toolchain=clang --with_cv=ON --with_extra=ON --with_arm82_fp16=ON +``` + +**注意**:编译Paddle-Lite获得预测库时,需要打开`--with_cv=ON --with_extra=ON`两个选项,`--arch`表示`arm`版本,这里指定为armv8,更多编译命令介绍请参考[链接](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_andriod.html#id2)。 + +直接下载预测库并解压后,可以得到`inference_lite_lib.android.armv8.clang.c++_static.with_extra.with_cv/`文件夹,通过编译Paddle-Lite得到的预测库位于`Paddle-Lite/build.lite.android.armv8.gcc/inference_lite_lib.android.armv8/`文件夹下。 +预测库的文件目录如下: + +``` +inference_lite_lib.android.armv8/ +|-- cxx C++ 预测库和头文件 +| |-- include C++ 头文件 +| | |-- paddle_api.h +| | |-- paddle_image_preprocess.h +| | |-- paddle_lite_factory_helper.h +| | |-- paddle_place.h +| | |-- paddle_use_kernels.h +| | |-- paddle_use_ops.h +| | `-- paddle_use_passes.h +| `-- lib C++预测库 +| |-- libpaddle_api_light_bundled.a C++静态库 +| `-- libpaddle_light_api_shared.so C++动态库 +|-- java Java预测库 +| |-- jar +| | `-- PaddlePredictor.jar +| |-- so +| | `-- libpaddle_lite_jni.so +| `-- src +|-- demo C++和Java示例代码 +| |-- cxx C++ 预测库demo +| `-- java Java 预测库demo +``` + +## 2 开始运行 + +### 2.1 模型准备 + + +#### 2.1.1 模型准备 + +```shell +# 进入lite_ppshitu目录 +cd $PaddleClas/deploy/lite_shitu +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/lite/ppshitu_lite_models_v1.0.tar +tar -xf ppshitu_lite_models_v1.0.tar +rm -f ppshitu_lite_models_v1.0.tar +``` + +#### 2.1.2将yaml文件转换成json文件 + +```shell +# 如果测试单张图像 +python generate_json_config.py --det_model_path ppshitu_lite_models_v1.0/mainbody_PPLCNet_x2_5_640_quant_v1.0_lite.nb --rec_model_path ppshitu_lite_models_v1.0/general_PPLCNet_x2_5_quant_v1.0_lite.nb --rec_label_path ppshitu_lite_models_v1.0/label.txt --img_path images/demo.jpg +# or +# 如果测试多张图像 +python generate_json_config.py --det_model_path ppshitu_lite_models_v1.0/mainbody_PPLCNet_x2_5_640_quant_v1.0_lite.nb --rec_model_path ppshitu_lite_models_v1.0/general_PPLCNet_x2_5_quant_v1.0_lite.nb --rec_label_path ppshitu_lite_models_v1.0/label.txt --img_dir images + +# 执行完成后,会在lit_shitu下生成shitu_config.json配置文件 + +``` + +### 2.2 与手机联调 + +首先需要进行一些准备工作。 +1. 准备一台arm8的安卓手机,如果编译的预测库是armv7,则需要arm7的手机,并修改Makefile中`ARM_ABI=arm7`。 +2. 电脑上安装ADB工具,用于调试。 ADB安装方式如下: + + 2.1. MAC电脑安装ADB: + + ```shell + brew cask install android-platform-tools + ``` + 2.2. Linux安装ADB + ```shell + sudo apt update + sudo apt install -y wget adb + ``` + 2.3. Window安装ADB + + win上安装需要去谷歌的安卓平台下载ADB软件包进行安装:[链接](https://developer.android.com/studio) + +3. 手机连接电脑后,开启手机`USB调试`选项,选择`文件传输`模式,在电脑终端中输入: + +```shell +adb devices +``` +如果有device输出,则表示安装成功,如下所示: +``` +List of devices attached +744be294 device +``` + +4. 编译lite部署代码生成移动端可执行文件 + +```shell +cd $PaddleClas/deploy/lite_shitu +# ${lite prediction library path}下载的Paddle-Lite库路径 +inference_lite_path=${lite prediction library path}/inference_lite_lib.android.armv8.gcc.c++_static.with_extra.with_cv/ +mkdir $inference_lite_path/demo/cxx/ppshitu_lite + +cp -r * $inference_lite_path/demo/cxx/ppshitu_lite +cd $inference_lite_path/demo/cxx/ppshitu_lite + +# 执行编译,等待完成后得到可执行文件main +make ARM_ABI=arm8 +#如果是arm7,则执行 make ARM_ABI = arm7 (或者在Makefile中修改该项) +``` + +5. 准备优化后的模型、预测库文件、测试图像。 + +```shell +mkdir deploy +mv ppshitu_lite_models_v1.0 deploy/ +mv images deploy/ +mv shitu_config.json deploy/ +cp pp_shitu deploy/ + +# 将C++预测动态库so文件复制到deploy文件夹中 +cp ../../../cxx/lib/libpaddle_light_api_shared.so deploy/ +``` + +执行完成后,deploy文件夹下将有如下文件格式: + +```shell +deploy/ +|-- ppshitu_lite_models_v1.0/ +| |--mainbody_PPLCNet_x2_5_640_v1.0_lite.nb 优化后的主体检测模型文件 +| |--general_PPLCNet_x2_5_quant_v1.0_lite.nb 优化后的识别模型文件 +| |--label.txt 识别模型的label文件 +|-- images/ +| |--demo.jpg 图片文件 +| ... 图片文件 +|-- pp_shitu 生成的移动端执行文件 +|-- shitu_config.json 执行时参数配置文件 +|-- libpaddle_light_api_shared.so Paddle-Lite库文件 +``` + +**注意:** +* `shitu_config.json` 包含了目标检测的超参数,请按需进行修改 + +6. 启动调试,上述步骤完成后就可以使用ADB将文件夹 `deploy/` push到手机上运行,步骤如下: + +```shell +# 将上述deploy文件夹push到手机上 +adb push deploy /data/local/tmp/ + +adb shell +cd /data/local/tmp/deploy +export LD_LIBRARY_PATH=/data/local/tmp/deploy:$LD_LIBRARY_PATH + +# 修改权限为可执行 +chmod 777 pp_shitu +# 执行程序 +./pp_shitu shitu_config.json +``` + +如果对代码做了修改,则需要重新编译并push到手机上。 + +运行效果如下: + +![](../../docs/images/ppshitu_lite_demo.png) + +## FAQ +Q1:如果想更换模型怎么办,需要重新按照流程走一遍吗? +A1:如果已经走通了上述步骤,更换模型只需要替换 `.nb` 模型文件即可,同时要注意修改下配置文件中的 `.nb` 文件路径以及类别映射文件(如有必要)。 + +Q2:换一个图测试怎么做? +A2:替换 deploy 下的测试图像为你想要测试的图像,并重新生成json配置文件(或者直接修改图像路径),使用 ADB 再次 push 到手机上即可。 diff --git a/src/PaddleClas/deploy/lite_shitu/generate_json_config.py b/src/PaddleClas/deploy/lite_shitu/generate_json_config.py new file mode 100644 index 0000000..1525cda --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/generate_json_config.py @@ -0,0 +1,138 @@ +import argparse +import json +import os + +import yaml + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--yaml_path', type=str, default='../configs/inference_drink.yaml') + parser.add_argument( + '--img_dir', + type=str, + default=None, + help='The dir path for inference images') + parser.add_argument( + '--img_path', + type=str, + default=None, + help='The dir path for inference images') + parser.add_argument( + '--det_model_path', + type=str, + default='./det.nb', + help="The model path for mainbody detection") + parser.add_argument( + '--rec_model_path', + type=str, + default='./rec.nb', + help="The rec model path") + parser.add_argument( + '--rec_label_path', + type=str, + default='./label.txt', + help='The rec model label') + parser.add_argument( + '--arch', + type=str, + default='PicoDet', + help='The model structure for detection model') + parser.add_argument( + '--fpn-stride', + type=list, + default=[8, 16, 32, 64], + help="The fpn strid for detection model") + parser.add_argument( + '--keep_top_k', + type=int, + default=100, + help='The params for nms(postprocess for detection)') + parser.add_argument( + '--nms-name', + type=str, + default='MultiClassNMS', + help='The nms name for postprocess of detection model') + parser.add_argument( + '--nms_threshold', + type=float, + default=0.5, + help='The nms nms_threshold for detection postprocess') + parser.add_argument( + '--nms_top_k', + type=int, + default=1000, + help='The nms_top_k in postprocess of detection model') + parser.add_argument( + '--score_threshold', + type=float, + default=0.3, + help='The score_threshold for postprocess of detection') + args = parser.parse_args() + return args + + +def main(): + args = parse_args() + config_yaml = yaml.safe_load(open(args.yaml_path)) + config_json = {} + config_json["Global"] = {} + config_json["Global"][ + "infer_imgs"] = args.img_path if args.img_path else config_yaml[ + "Global"]["infer_imgs"] + if args.img_dir is not None: + config_json["Global"]["infer_imgs_dir"] = args.img_dir + config_json["Global"]["infer_imgs"] = None + else: + config_json["Global"][ + "infer_imgs"] = args.img_path if args.img_path else config_yaml[ + "Global"]["infer_imgs"] + config_json["Global"]["batch_size"] = config_yaml["Global"]["batch_size"] + config_json["Global"]["cpu_num_threads"] = min( + config_yaml["Global"]["cpu_num_threads"], 4) + config_json["Global"]["image_shape"] = config_yaml["Global"]["image_shape"] + config_json["Global"]["det_model_path"] = args.det_model_path + config_json["Global"]["rec_model_path"] = args.rec_model_path + config_json["Global"]["rec_label_path"] = args.rec_label_path + config_json["Global"]["label_list"] = config_yaml["Global"]["labe_list"] + config_json["Global"]["rec_nms_thresold"] = config_yaml["Global"][ + "rec_nms_thresold"] + config_json["Global"]["max_det_results"] = config_yaml["Global"][ + "max_det_results"] + config_json["Global"]["det_fpn_stride"] = args.fpn_stride + config_json["Global"]["det_arch"] = args.arch + config_json["Global"]["return_k"] = config_yaml["IndexProcess"]["return_k"] + + # config_json["DetPreProcess"] = config_yaml["DetPreProcess"] + config_json["DetPreProcess"] = {} + config_json["DetPreProcess"]["transform_ops"] = [] + for x in config_yaml["DetPreProcess"]["transform_ops"]: + k = list(x.keys())[0] + y = x[k] + y['type'] = k + config_json["DetPreProcess"]["transform_ops"].append(y) + + config_json["DetPostProcess"] = { + "keep_top_k": args.keep_top_k, + "name": args.nms_name, + "nms_threshold": args.nms_threshold, + "nms_top_k": args.nms_top_k, + "score_threshold": args.score_threshold + } + # config_json["RecPreProcess"] = config_yaml["RecPreProcess"] + config_json["RecPreProcess"] = {} + config_json["RecPreProcess"]["transform_ops"] = [] + for x in config_yaml["RecPreProcess"]["transform_ops"]: + k = list(x.keys())[0] + y = x[k] + if y is not None: + y["type"] = k + config_json["RecPreProcess"]["transform_ops"].append(y) + + with open('shitu_config.json', 'w') as fd: + json.dump(config_json, fd, indent=4) + + +if __name__ == '__main__': + main() diff --git a/src/PaddleClas/deploy/lite_shitu/images/demo.jpg b/src/PaddleClas/deploy/lite_shitu/images/demo.jpg new file mode 100644 index 0000000..075dc31 Binary files /dev/null and b/src/PaddleClas/deploy/lite_shitu/images/demo.jpg differ diff --git a/src/PaddleClas/deploy/lite_shitu/include/config_parser.h b/src/PaddleClas/deploy/lite_shitu/include/config_parser.h new file mode 100644 index 0000000..dca0e5a --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/include/config_parser.h @@ -0,0 +1,92 @@ +// Copyright (c) 2021 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. + +#pragma once +#include +#include +#include +#include +#include + +#include "json/json.h" + +#ifdef _WIN32 +#define OS_PATH_SEP "\\" +#else +#define OS_PATH_SEP "/" +#endif + +namespace PPShiTu { + +void load_jsonf(std::string jsonfile, Json::Value& jsondata); + +// Inference model configuration parser +class ConfigPaser { + public: + ConfigPaser() {} + + ~ConfigPaser() {} + + bool load_config(const Json::Value& config) { + + // Get model arch : YOLO, SSD, RetinaNet, RCNN, Face + if (config["Global"].isMember("det_arch")) { + arch_ = config["Global"]["det_arch"].as(); + } else { + std::cerr << "Please set model arch," + << "support value : YOLO, SSD, RetinaNet, RCNN, Face." + << std::endl; + return false; + } + + // Get Preprocess for preprocessing + if (config.isMember("DetPreProcess")) { + preprocess_info_ = config["DetPreProcess"]["transform_ops"]; + } else { + std::cerr << "Please set Preprocess." << std::endl; + return false; + } + // Get label_list for visualization + if (config["Global"].isMember("label_list")) { + label_list_.clear(); + for (auto item : config["Global"]["label_list"]) { + label_list_.emplace_back(item.as()); + } + } else { + std::cerr << "Please set label_list." << std::endl; + return false; + } + + // Get NMS for postprocess + if (config.isMember("DetPostProcess")) { + nms_info_ = config["DetPostProcess"]; + } + // Get fpn_stride in PicoDet + if (config["Global"].isMember("det_fpn_stride")) { + fpn_stride_.clear(); + for (auto item : config["Global"]["det_fpn_stride"]) { + fpn_stride_.emplace_back(item.as()); + } + } + + return true; + } + std::string arch_; + Json::Value preprocess_info_; + Json::Value nms_info_; + std::vector label_list_; + std::vector fpn_stride_; +}; + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/include/object_detector.h b/src/PaddleClas/deploy/lite_shitu/include/object_detector.h new file mode 100644 index 0000000..779cc89 --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/include/object_detector.h @@ -0,0 +1,102 @@ +// Copyright (c) 2021 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. + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "json/json.h" + +#include "paddle_api.h" // NOLINT + +#include "include/config_parser.h" +#include "include/preprocess_op.h" +#include "include/utils.h" +#include "include/picodet_postprocess.h" + +using namespace paddle::lite_api; // NOLINT + +namespace PPShiTu { + +// Generate visualization colormap for each class +std::vector GenerateColorMap(int num_class); + +// Visualiztion Detection Result +cv::Mat VisualizeResult(const cv::Mat& img, + const std::vector& results, + const std::vector& lables, + const std::vector& colormap, + const bool is_rbox); + +class ObjectDetector { + public: + explicit ObjectDetector(const Json::Value& config, + const std::string& model_dir, + int cpu_threads = 1, + const int batch_size = 1) { + config_.load_config(config); + printf("config created\n"); + preprocessor_.Init(config_.preprocess_info_); + printf("before object detector\n"); + if(config["Global"]["det_model_path"].as().empty()){ + std::cout << "Please set [det_model_path] in config file" << std::endl; + exit(-1); + } + LoadModel(config["Global"]["det_model_path"].as(), cpu_threads); + printf("create object detector\n"); } + + // Load Paddle inference model + void LoadModel(std::string model_file, int num_theads); + + // Run predictor + void Predict(const std::vector& imgs, + const int warmup = 0, + const int repeats = 1, + std::vector* result = nullptr, + std::vector* bbox_num = nullptr, + std::vector* times = nullptr); + + // Get Model Label list + const std::vector& GetLabelList() const { + return config_.label_list_; + } + + private: + // Preprocess image and copy data to input buffer + void Preprocess(const cv::Mat& image_mat); + // Postprocess result + void Postprocess(const std::vector mats, + std::vector* result, + std::vector bbox_num, + bool is_rbox); + + std::shared_ptr predictor_; + Preprocessor preprocessor_; + ImageBlob inputs_; + std::vector output_data_; + std::vector out_bbox_num_data_; + float threshold_; + ConfigPaser config_; + +}; + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/include/picodet_postprocess.h b/src/PaddleClas/deploy/lite_shitu/include/picodet_postprocess.h new file mode 100644 index 0000000..758795b --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/include/picodet_postprocess.h @@ -0,0 +1,38 @@ +// Copyright (c) 2021 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. + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "include/utils.h" + +namespace PPShiTu { + +void PicoDetPostProcess(std::vector* results, + std::vector outs, + std::vector fpn_stride, + std::vector im_shape, + std::vector scale_factor, + float score_threshold = 0.3, + float nms_threshold = 0.5, + int num_class = 80, + int reg_max = 7); + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/include/preprocess_op.h b/src/PaddleClas/deploy/lite_shitu/include/preprocess_op.h new file mode 100644 index 0000000..f7050fa --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/include/preprocess_op.h @@ -0,0 +1,188 @@ +// Copyright (c) 2021 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. + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "json/json.h" + +namespace PPShiTu { + +// Object for storing all preprocessed data +class ImageBlob { + public: + // image width and height + std::vector im_shape_; + // Buffer for image data after preprocessing + std::vector im_data_; + // in net data shape(after pad) + std::vector in_net_shape_; + // Evaluation image width and height + // std::vector eval_im_size_f_; + // Scale factor for image size to origin image size + std::vector scale_factor_; +}; + +// Abstraction of preprocessing opration class +class PreprocessOp { + public: + virtual void Init(const Json::Value& item) = 0; + virtual void Run(cv::Mat* im, ImageBlob* data) = 0; +}; + +class InitInfo : public PreprocessOp { + public: + virtual void Init(const Json::Value& item) {} + virtual void Run(cv::Mat* im, ImageBlob* data); +}; + +class NormalizeImage : public PreprocessOp { + public: + virtual void Init(const Json::Value& item) { + mean_.clear(); + scale_.clear(); + for (auto tmp : item["mean"]) { + mean_.emplace_back(tmp.as()); + } + for (auto tmp : item["std"]) { + scale_.emplace_back(tmp.as()); + } + is_scale_ = item["is_scale"].as(); + } + + virtual void Run(cv::Mat* im, ImageBlob* data); + + private: + // CHW or HWC + std::vector mean_; + std::vector scale_; + bool is_scale_; +}; + +class Permute : public PreprocessOp { + public: + virtual void Init(const Json::Value& item) {} + virtual void Run(cv::Mat* im, ImageBlob* data); +}; + +class Resize : public PreprocessOp { + public: + virtual void Init(const Json::Value& item) { + interp_ = item["interp"].as(); + // max_size_ = item["target_size"].as(); + keep_ratio_ = item["keep_ratio"].as(); + target_size_.clear(); + for (auto tmp : item["target_size"]) { + target_size_.emplace_back(tmp.as()); + } + } + + // Compute best resize scale for x-dimension, y-dimension + std::pair GenerateScale(const cv::Mat& im); + + virtual void Run(cv::Mat* im, ImageBlob* data); + + private: + int interp_; + bool keep_ratio_; + std::vector target_size_; + std::vector in_net_shape_; +}; + +// Models with FPN need input shape % stride == 0 +class PadStride : public PreprocessOp { + public: + virtual void Init(const Json::Value& item) { + stride_ = item["stride"].as(); + } + + virtual void Run(cv::Mat* im, ImageBlob* data); + + private: + int stride_; +}; + +class TopDownEvalAffine : public PreprocessOp { + public: + virtual void Init(const Json::Value& item) { + trainsize_.clear(); + for (auto tmp : item["trainsize"]) { + trainsize_.emplace_back(tmp.as()); + } + } + + virtual void Run(cv::Mat* im, ImageBlob* data); + + private: + int interp_ = 1; + std::vector trainsize_; +}; + +void CropImg(cv::Mat& img, + cv::Mat& crop_img, + std::vector& area, + std::vector& center, + std::vector& scale, + float expandratio = 0.15); + +class Preprocessor { + public: + void Init(const Json::Value& config_node) { + // initialize image info at first + ops_["InitInfo"] = std::make_shared(); + for (const auto& item : config_node) { + auto op_name = item["type"].as(); + + ops_[op_name] = CreateOp(op_name); + ops_[op_name]->Init(item); + } + } + + std::shared_ptr CreateOp(const std::string& name) { + if (name == "DetResize") { + return std::make_shared(); + } else if (name == "DetPermute") { + return std::make_shared(); + } else if (name == "DetNormalizeImage") { + return std::make_shared(); + } else if (name == "DetPadStride") { + // use PadStride instead of PadBatch + return std::make_shared(); + } else if (name == "TopDownEvalAffine") { + return std::make_shared(); + } + std::cerr << "can not find function of OP: " << name + << " and return: nullptr" << std::endl; + return nullptr; + } + + void Run(cv::Mat* im, ImageBlob* data); + + public: + static const std::vector RUN_ORDER; + + private: + std::unordered_map> ops_; +}; + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/include/recognition.h b/src/PaddleClas/deploy/lite_shitu/include/recognition.h new file mode 100644 index 0000000..0c45e94 --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/include/recognition.h @@ -0,0 +1,115 @@ +// Copyright (c) 2022 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. + +#pragma once +#include "paddle_api.h" // NOLINT +#include "json/json.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace paddle::lite_api; // NOLINT +using namespace std; + +namespace PPShiTu { + +struct RESULT { + std::string class_name; + int class_id; + float score; +}; + +class Recognition { + +public: + explicit Recognition(const Json::Value &config_file) { + MobileConfig config; + if (config_file["Global"]["rec_model_path"].as().empty()) { + std::cout << "Please set [rec_model_path] in config file" << std::endl; + exit(-1); + } + config.set_model_from_file( + config_file["Global"]["rec_model_path"].as()); + this->predictor = CreatePaddlePredictor(config); + + if (config_file["Global"]["rec_label_path"].as().empty()) { + std::cout << "Please set [rec_label_path] in config file" << std::endl; + exit(-1); + } + LoadLabel(config_file["Global"]["rec_label_path"].as()); + SetPreProcessParam(config_file["RecPreProcess"]["transform_ops"]); + if (!config_file["Global"].isMember("return_k")){ + this->topk = config_file["Global"]["return_k"].as(); + } + printf("rec model create!\n"); + } + + void LoadLabel(std::string path) { + std::ifstream file; + std::vector label_list; + file.open(path); + while (file) { + std::string line; + std::getline(file, line); + std::string::size_type pos = line.find(" "); + if (pos != std::string::npos) { + line = line.substr(pos); + } + this->label_list.push_back(line); + } + file.clear(); + file.close(); + } + + void SetPreProcessParam(const Json::Value &config_file) { + for (const auto &item : config_file) { + auto op_name = item["type"].as(); + if (op_name == "ResizeImage") { + this->size = item["size"].as(); + } else if (op_name == "NormalizeImage") { + this->mean.clear(); + this->std.clear(); + for (auto tmp : item["mean"]) { + this->mean.emplace_back(tmp.as()); + } + for (auto tmp : item["std"]) { + this->std.emplace_back(1 / tmp.as()); + } + this->scale = item["scale"].as(); + } + } + } + + std::vector RunRecModel(const cv::Mat &img, double &cost_time); + std::vector PostProcess(const float *output_data, int output_size, + cv::Mat &output_image); + cv::Mat ResizeImage(const cv::Mat &img); + void NeonMeanScale(const float *din, float *dout, int size); + +private: + std::shared_ptr predictor; + std::vector label_list; + std::vector mean = {0.485f, 0.456f, 0.406f}; + std::vector std = {1 / 0.229f, 1 / 0.224f, 1 / 0.225f}; + double scale = 0.00392157; + float size = 224; + int topk = 5; +}; +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/include/utils.h b/src/PaddleClas/deploy/lite_shitu/include/utils.h new file mode 100644 index 0000000..18a04cf --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/include/utils.h @@ -0,0 +1,43 @@ +// Copyright (c) 2021 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. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace PPShiTu { + +// Object Detection Result +struct ObjectResult { + // Rectangle coordinates of detected object: left, right, top, down + std::vector rect; + // Class id of detected object + int class_id; + // Confidence of detected object + float confidence; + + // RecModel result + std::vector rec_result; +}; + +void nms(std::vector &input_boxes, float nms_threshold, bool rec_nms=false); + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/src/config_parser.cc b/src/PaddleClas/deploy/lite_shitu/src/config_parser.cc new file mode 100644 index 0000000..d98b2f9 --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/config_parser.cc @@ -0,0 +1,32 @@ +// Copyright (c) 2021 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. + +#include "include/config_parser.h" + +namespace PPShiTu { + +void load_jsonf(std::string jsonfile, Json::Value &jsondata) { + std::ifstream ifs; + ifs.open(jsonfile); + + Json::CharReaderBuilder builder; + builder["collectComments"] = true; + JSONCPP_STRING errs; + if (!parseFromStream(builder, ifs, &jsondata, &errs)) { + std::cout << errs << std::endl; + return; + } +} + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/src/main.cc b/src/PaddleClas/deploy/lite_shitu/src/main.cc new file mode 100644 index 0000000..690162a --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/main.cc @@ -0,0 +1,225 @@ +// Copyright (c) 2021 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. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "include/config_parser.h" +#include "include/object_detector.h" +#include "include/preprocess_op.h" +#include "include/recognition.h" +#include "json/json.h" + +Json::Value RT_Config; + +static std::string DirName(const std::string &filepath) { + auto pos = filepath.rfind(OS_PATH_SEP); + if (pos == std::string::npos) { + return ""; + } + return filepath.substr(0, pos); +} + +static bool PathExists(const std::string &path) { + struct stat buffer; + return (stat(path.c_str(), &buffer) == 0); +} + +static void MkDir(const std::string &path) { + if (PathExists(path)) + return; + int ret = 0; + ret = mkdir(path.c_str(), 0755); + if (ret != 0) { + std::string path_error(path); + path_error += " mkdir failed!"; + throw std::runtime_error(path_error); + } +} + +static void MkDirs(const std::string &path) { + if (path.empty()) + return; + if (PathExists(path)) + return; + + MkDirs(DirName(path)); + MkDir(path); +} + +void DetPredictImage(const std::vector &batch_imgs, + std::vector &im_result, + const int batch_size_det, const int max_det_num, + const bool run_benchmark, PPShiTu::ObjectDetector *det) { + std::vector det_t = {0, 0, 0}; + int steps = ceil(float(batch_imgs.size()) / batch_size_det); + for (int idx = 0; idx < steps; idx++) { + int left_image_cnt = batch_imgs.size() - idx * batch_size_det; + if (left_image_cnt > batch_size_det) { + left_image_cnt = batch_size_det; + } + // Store all detected result + std::vector result; + std::vector bbox_num; + std::vector det_times; + + bool is_rbox = false; + if (run_benchmark) { + det->Predict(batch_imgs, 50, 50, &result, &bbox_num, &det_times); + } else { + det->Predict(batch_imgs, 0, 1, &result, &bbox_num, &det_times); + } + + int item_start_idx = 0; + for (int i = 0; i < left_image_cnt; i++) { + cv::Mat im = batch_imgs[i]; + // std::vector im_result; + int detect_num = 0; + for (int j = 0; j < min(bbox_num[i], max_det_num); j++) { + PPShiTu::ObjectResult item = result[item_start_idx + j]; + if (item.class_id == -1) { + continue; + } + detect_num += 1; + im_result.push_back(item); + } + item_start_idx = item_start_idx + bbox_num[i]; + } + + det_t[0] += det_times[0]; + det_t[1] += det_times[1]; + det_t[2] += det_times[2]; + } +} + +void PrintResult(const std::string &image_path, + std::vector &det_result) { + printf("%s:\n", image_path.c_str()); + for (int i = 0; i < det_result.size(); ++i) { + printf("\tresult%d: bbox[%d, %d, %d, %d], score: %f, label: %s\n", i, + det_result[i].rect[0], det_result[i].rect[1], det_result[i].rect[2], + det_result[i].rect[3], det_result[i].rec_result[0].score, + det_result[i].rec_result[0].class_name.c_str()); + } +} + +int main(int argc, char **argv) { + std::cout << "Usage: " << argv[0] + << " [config_path](option) [image_dir](option)\n"; + if (argc < 2) { + std::cout << "Usage: ./main det_runtime_config.json" << std::endl; + return -1; + } + std::string config_path = argv[1]; + std::string img_dir = ""; + + if (argc >= 3) { + img_dir = argv[2]; + } + // Parsing command-line + PPShiTu::load_jsonf(config_path, RT_Config); + if (RT_Config["Global"]["det_model_path"].as().empty()) { + std::cout << "Please set [det_model_path] in " << config_path << std::endl; + return -1; + } + + if (!RT_Config["Global"]["infer_imgs_dir"].as().empty() && + img_dir.empty()) { + img_dir = RT_Config["Global"]["infer_imgs_dir"].as(); + } + if (RT_Config["Global"]["infer_imgs"].as().empty() && + img_dir.empty()) { + std::cout << "Please set [infer_imgs] in " << config_path + << " Or use command: <" << argv[0] << " [shitu_config]" + << " [image_dir]>" << std::endl; + return -1; + } + // Load model and create a object detector + PPShiTu::ObjectDetector det( + RT_Config, RT_Config["Global"]["det_model_path"].as(), + RT_Config["Global"]["cpu_num_threads"].as(), + RT_Config["Global"]["batch_size"].as()); + // create rec model + PPShiTu::Recognition rec(RT_Config); + // Do inference on input image + + std::vector det_result; + std::vector batch_imgs; + double rec_time; + if (!RT_Config["Global"]["infer_imgs"].as().empty() || + !img_dir.empty()) { + std::vector all_img_paths; + std::vector cv_all_img_paths; + if (!RT_Config["Global"]["infer_imgs"].as().empty()) { + all_img_paths.push_back( + RT_Config["Global"]["infer_imgs"].as()); + if (RT_Config["Global"]["batch_size"].as() > 1) { + std::cout << "batch_size_det should be 1, when set `image_file`." + << std::endl; + return -1; + } + } else { + cv::glob(img_dir, + cv_all_img_paths); + for (const auto &img_path : cv_all_img_paths) { + all_img_paths.push_back(img_path); + } + } + for (int i = 0; i < all_img_paths.size(); ++i) { + std::string img_path = all_img_paths[i]; + cv::Mat srcimg = cv::imread(img_path, cv::IMREAD_COLOR); + if (!srcimg.data) { + std::cerr << "[ERROR] image read failed! image path: " << img_path + << "\n"; + exit(-1); + } + cv::cvtColor(srcimg, srcimg, cv::COLOR_BGR2RGB); + batch_imgs.push_back(srcimg); + DetPredictImage( + batch_imgs, det_result, RT_Config["Global"]["batch_size"].as(), + RT_Config["Global"]["max_det_results"].as(), false, &det); + + // add the whole image for recognition to improve recall + PPShiTu::ObjectResult result_whole_img = { + {0, 0, srcimg.cols, srcimg.rows}, 0, 1.0}; + det_result.push_back(result_whole_img); + + // get rec result + for (int j = 0; j < det_result.size(); ++j) { + int w = det_result[j].rect[2] - det_result[j].rect[0]; + int h = det_result[j].rect[3] - det_result[j].rect[1]; + cv::Rect rect(det_result[j].rect[0], det_result[j].rect[1], w, h); + cv::Mat crop_img = srcimg(rect); + std::vector result = + rec.RunRecModel(crop_img, rec_time); + det_result[j].rec_result.assign(result.begin(), result.end()); + } + // rec nms + PPShiTu::nms(det_result, + RT_Config["Global"]["rec_nms_thresold"].as(), true); + PrintResult(img_path, det_result); + batch_imgs.clear(); + det_result.clear(); + } + } + return 0; +} diff --git a/src/PaddleClas/deploy/lite_shitu/src/object_detector.cc b/src/PaddleClas/deploy/lite_shitu/src/object_detector.cc new file mode 100644 index 0000000..ffea31b --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/object_detector.cc @@ -0,0 +1,329 @@ +// Copyright (c) 2021 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. +#include +// for setprecision +#include +#include +#include "include/object_detector.h" + +namespace PPShiTu { + +// Load Model and create model predictor +void ObjectDetector::LoadModel(std::string model_file, int num_theads) { + MobileConfig config; + config.set_threads(num_theads); + config.set_model_from_file(model_file); + config.set_power_mode(LITE_POWER_HIGH); + + predictor_ = CreatePaddlePredictor(config); +} + +// Visualiztion MaskDetector results +cv::Mat VisualizeResult(const cv::Mat& img, + const std::vector& results, + const std::vector& lables, + const std::vector& colormap, + const bool is_rbox = false) { + cv::Mat vis_img = img.clone(); + for (int i = 0; i < results.size(); ++i) { + // Configure color and text size + std::ostringstream oss; + oss << std::setiosflags(std::ios::fixed) << std::setprecision(4); + oss << lables[results[i].class_id] << " "; + oss << results[i].confidence; + std::string text = oss.str(); + int c1 = colormap[3 * results[i].class_id + 0]; + int c2 = colormap[3 * results[i].class_id + 1]; + int c3 = colormap[3 * results[i].class_id + 2]; + cv::Scalar roi_color = cv::Scalar(c1, c2, c3); + int font_face = cv::FONT_HERSHEY_COMPLEX_SMALL; + double font_scale = 0.5f; + float thickness = 0.5; + cv::Size text_size = + cv::getTextSize(text, font_face, font_scale, thickness, nullptr); + cv::Point origin; + + if (is_rbox) { + // Draw object, text, and background + for (int k = 0; k < 4; k++) { + cv::Point pt1 = cv::Point(results[i].rect[(k * 2) % 8], + results[i].rect[(k * 2 + 1) % 8]); + cv::Point pt2 = cv::Point(results[i].rect[(k * 2 + 2) % 8], + results[i].rect[(k * 2 + 3) % 8]); + cv::line(vis_img, pt1, pt2, roi_color, 2); + } + } else { + int w = results[i].rect[2] - results[i].rect[0]; + int h = results[i].rect[3] - results[i].rect[1]; + cv::Rect roi = cv::Rect(results[i].rect[0], results[i].rect[1], w, h); + // Draw roi object, text, and background + cv::rectangle(vis_img, roi, roi_color, 2); + } + + origin.x = results[i].rect[0]; + origin.y = results[i].rect[1]; + + // Configure text background + cv::Rect text_back = cv::Rect(results[i].rect[0], + results[i].rect[1] - text_size.height, + text_size.width, + text_size.height); + // Draw text, and background + cv::rectangle(vis_img, text_back, roi_color, -1); + cv::putText(vis_img, + text, + origin, + font_face, + font_scale, + cv::Scalar(255, 255, 255), + thickness); + } + return vis_img; +} + +void ObjectDetector::Preprocess(const cv::Mat& ori_im) { + // Clone the image : keep the original mat for postprocess + cv::Mat im = ori_im.clone(); + // cv::cvtColor(im, im, cv::COLOR_BGR2RGB); + preprocessor_.Run(&im, &inputs_); +} + +void ObjectDetector::Postprocess(const std::vector mats, + std::vector* result, + std::vector bbox_num, + bool is_rbox = false) { + result->clear(); + int start_idx = 0; + for (int im_id = 0; im_id < mats.size(); im_id++) { + cv::Mat raw_mat = mats[im_id]; + int rh = 1; + int rw = 1; + if (config_.arch_ == "Face") { + rh = raw_mat.rows; + rw = raw_mat.cols; + } + for (int j = start_idx; j < start_idx + bbox_num[im_id]; j++) { + if (is_rbox) { + // Class id + int class_id = static_cast(round(output_data_[0 + j * 10])); + // Confidence score + float score = output_data_[1 + j * 10]; + int x1 = (output_data_[2 + j * 10] * rw); + int y1 = (output_data_[3 + j * 10] * rh); + int x2 = (output_data_[4 + j * 10] * rw); + int y2 = (output_data_[5 + j * 10] * rh); + int x3 = (output_data_[6 + j * 10] * rw); + int y3 = (output_data_[7 + j * 10] * rh); + int x4 = (output_data_[8 + j * 10] * rw); + int y4 = (output_data_[9 + j * 10] * rh); + + PPShiTu::ObjectResult result_item; + result_item.rect = {x1, y1, x2, y2, x3, y3, x4, y4}; + result_item.class_id = class_id; + result_item.confidence = score; + result->push_back(result_item); + } else { + // Class id + int class_id = static_cast(round(output_data_[0 + j * 6])); + // Confidence score + float score = output_data_[1 + j * 6]; + int xmin = (output_data_[2 + j * 6] * rw); + int ymin = (output_data_[3 + j * 6] * rh); + int xmax = (output_data_[4 + j * 6] * rw); + int ymax = (output_data_[5 + j * 6] * rh); + int wd = xmax - xmin; + int hd = ymax - ymin; + + PPShiTu::ObjectResult result_item; + result_item.rect = {xmin, ymin, xmax, ymax}; + result_item.class_id = class_id; + result_item.confidence = score; + result->push_back(result_item); + } + } + start_idx += bbox_num[im_id]; + } +} + +void ObjectDetector::Predict(const std::vector& imgs, + const int warmup, + const int repeats, + std::vector* result, + std::vector* bbox_num, + std::vector* times) { + auto preprocess_start = std::chrono::steady_clock::now(); + int batch_size = imgs.size(); + + // in_data_batch + std::vector in_data_all; + std::vector im_shape_all(batch_size * 2); + std::vector scale_factor_all(batch_size * 2); + // Preprocess image + for (int bs_idx = 0; bs_idx < batch_size; bs_idx++) { + cv::Mat im = imgs.at(bs_idx); + Preprocess(im); + im_shape_all[bs_idx * 2] = inputs_.im_shape_[0]; + im_shape_all[bs_idx * 2 + 1] = inputs_.im_shape_[1]; + + scale_factor_all[bs_idx * 2] = inputs_.scale_factor_[0]; + scale_factor_all[bs_idx * 2 + 1] = inputs_.scale_factor_[1]; + + // TODO: reduce cost time + in_data_all.insert( + in_data_all.end(), inputs_.im_data_.begin(), inputs_.im_data_.end()); + } + auto preprocess_end = std::chrono::steady_clock::now(); + std::vector output_data_list_; + // Prepare input tensor + + auto input_names = predictor_->GetInputNames(); + for (const auto& tensor_name : input_names) { + auto in_tensor = predictor_->GetInputByName(tensor_name); + if (tensor_name == "image") { + int rh = inputs_.in_net_shape_[0]; + int rw = inputs_.in_net_shape_[1]; + in_tensor->Resize({batch_size, 3, rh, rw}); + auto* inptr = in_tensor->mutable_data(); + std::copy_n(in_data_all.data(), in_data_all.size(), inptr); + } else if (tensor_name == "im_shape") { + in_tensor->Resize({batch_size, 2}); + auto* inptr = in_tensor->mutable_data(); + std::copy_n(im_shape_all.data(), im_shape_all.size(), inptr); + } else if (tensor_name == "scale_factor") { + in_tensor->Resize({batch_size, 2}); + auto* inptr = in_tensor->mutable_data(); + std::copy_n(scale_factor_all.data(), scale_factor_all.size(), inptr); + } + } + + // Run predictor + // warmup + for (int i = 0; i < warmup; i++) { + predictor_->Run(); + // Get output tensor + auto output_names = predictor_->GetOutputNames(); + if (config_.arch_ == "PicoDet") { + for (int j = 0; j < output_names.size(); j++) { + auto output_tensor = predictor_->GetTensor(output_names[j]); + const float* outptr = output_tensor->data(); + std::vector output_shape = output_tensor->shape(); + output_data_list_.push_back(outptr); + } + } else { + auto out_tensor = predictor_->GetTensor(output_names[0]); + auto out_bbox_num = predictor_->GetTensor(output_names[1]); + } + } + + bool is_rbox = false; + auto inference_start = std::chrono::steady_clock::now(); + for (int i = 0; i < repeats; i++) { + predictor_->Run(); + } + auto inference_end = std::chrono::steady_clock::now(); + auto postprocess_start = std::chrono::steady_clock::now(); + // Get output tensor + output_data_list_.clear(); + int num_class = 1; + int reg_max = 7; + auto output_names = predictor_->GetOutputNames(); + // TODO: Unified model output. + if (config_.arch_ == "PicoDet") { + for (int i = 0; i < output_names.size(); i++) { + auto output_tensor = predictor_->GetTensor(output_names[i]); + const float* outptr = output_tensor->data(); + std::vector output_shape = output_tensor->shape(); + if (i == 0) { + num_class = output_shape[2]; + } + if (i == config_.fpn_stride_.size()) { + reg_max = output_shape[2] / 4 - 1; + } + output_data_list_.push_back(outptr); + } + } else { + auto output_tensor = predictor_->GetTensor(output_names[0]); + auto output_shape = output_tensor->shape(); + auto out_bbox_num = predictor_->GetTensor(output_names[1]); + auto out_bbox_num_shape = out_bbox_num->shape(); + // Calculate output length + int output_size = 1; + for (int j = 0; j < output_shape.size(); ++j) { + output_size *= output_shape[j]; + } + is_rbox = output_shape[output_shape.size() - 1] % 10 == 0; + + if (output_size < 6) { + std::cerr << "[WARNING] No object detected." << std::endl; + } + output_data_.resize(output_size); + std::copy_n( + output_tensor->mutable_data(), output_size, output_data_.data()); + + int out_bbox_num_size = 1; + for (int j = 0; j < out_bbox_num_shape.size(); ++j) { + out_bbox_num_size *= out_bbox_num_shape[j]; + } + out_bbox_num_data_.resize(out_bbox_num_size); + std::copy_n(out_bbox_num->mutable_data(), + out_bbox_num_size, + out_bbox_num_data_.data()); + } + // Postprocessing result + + result->clear(); + if (config_.arch_ == "PicoDet") { + PPShiTu::PicoDetPostProcess( + result, output_data_list_, config_.fpn_stride_, + inputs_.im_shape_, inputs_.scale_factor_, + config_.nms_info_["score_threshold"].as(), + config_.nms_info_["nms_threshold"].as(), num_class, reg_max); + bbox_num->push_back(result->size()); + } else { + Postprocess(imgs, result, out_bbox_num_data_, is_rbox); + bbox_num->clear(); + for (int k = 0; k < out_bbox_num_data_.size(); k++) { + int tmp = out_bbox_num_data_[k]; + bbox_num->push_back(tmp); + } + } + auto postprocess_end = std::chrono::steady_clock::now(); + + std::chrono::duration preprocess_diff = + preprocess_end - preprocess_start; + times->push_back(double(preprocess_diff.count() * 1000)); + std::chrono::duration inference_diff = inference_end - inference_start; + times->push_back(double(inference_diff.count() / repeats * 1000)); + std::chrono::duration postprocess_diff = + postprocess_end - postprocess_start; + times->push_back(double(postprocess_diff.count() * 1000)); +} + +std::vector GenerateColorMap(int num_class) { + auto colormap = std::vector(3 * num_class, 0); + for (int i = 0; i < num_class; ++i) { + int j = 0; + int lab = i; + while (lab) { + colormap[i * 3] |= (((lab >> 0) & 1) << (7 - j)); + colormap[i * 3 + 1] |= (((lab >> 1) & 1) << (7 - j)); + colormap[i * 3 + 2] |= (((lab >> 2) & 1) << (7 - j)); + ++j; + lab >>= 3; + } + } + return colormap; +} + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/src/picodet_postprocess.cc b/src/PaddleClas/deploy/lite_shitu/src/picodet_postprocess.cc new file mode 100644 index 0000000..cde914c --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/picodet_postprocess.cc @@ -0,0 +1,129 @@ +// Copyright (c) 2021 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. +// +// The code is based on: +// https://github.com/RangiLyu/nanodet/blob/main/demo_mnn/nanodet_mnn.cpp + +#include "include/picodet_postprocess.h" +#include + +namespace PPShiTu { + +float fast_exp(float x) { + union { + uint32_t i; + float f; + } v{}; + v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f); + return v.f; +} + +template +int activation_function_softmax(const _Tp *src, _Tp *dst, int length) { + const _Tp alpha = *std::max_element(src, src + length); + _Tp denominator{0}; + + for (int i = 0; i < length; ++i) { + dst[i] = fast_exp(src[i] - alpha); + denominator += dst[i]; + } + + for (int i = 0; i < length; ++i) { + dst[i] /= denominator; + } + + return 0; +} + +// PicoDet decode +PPShiTu::ObjectResult +disPred2Bbox(const float *&dfl_det, int label, float score, int x, int y, + int stride, std::vector im_shape, int reg_max) { + float ct_x = (x + 0.5) * stride; + float ct_y = (y + 0.5) * stride; + std::vector dis_pred; + dis_pred.resize(4); + for (int i = 0; i < 4; i++) { + float dis = 0; + float *dis_after_sm = new float[reg_max + 1]; + activation_function_softmax(dfl_det + i * (reg_max + 1), dis_after_sm, + reg_max + 1); + for (int j = 0; j < reg_max + 1; j++) { + dis += j * dis_after_sm[j]; + } + dis *= stride; + dis_pred[i] = dis; + delete[] dis_after_sm; + } + int xmin = (int)(std::max)(ct_x - dis_pred[0], .0f); + int ymin = (int)(std::max)(ct_y - dis_pred[1], .0f); + int xmax = (int)(std::min)(ct_x + dis_pred[2], (float)im_shape[0]); + int ymax = (int)(std::min)(ct_y + dis_pred[3], (float)im_shape[1]); + + PPShiTu::ObjectResult result_item; + result_item.rect = {xmin, ymin, xmax, ymax}; + result_item.class_id = label; + result_item.confidence = score; + + return result_item; +} + +void PicoDetPostProcess(std::vector *results, + std::vector outs, + std::vector fpn_stride, + std::vector im_shape, + std::vector scale_factor, float score_threshold, + float nms_threshold, int num_class, int reg_max) { + std::vector> bbox_results; + bbox_results.resize(num_class); + int in_h = im_shape[0], in_w = im_shape[1]; + for (int i = 0; i < fpn_stride.size(); ++i) { + int feature_h = ceil((float)in_h / fpn_stride[i]); + int feature_w = ceil((float)in_w / fpn_stride[i]); + for (int idx = 0; idx < feature_h * feature_w; idx++) { + const float *scores = outs[i] + (idx * num_class); + + int row = idx / feature_w; + int col = idx % feature_w; + float score = 0; + int cur_label = 0; + for (int label = 0; label < num_class; label++) { + if (scores[label] > score) { + score = scores[label]; + cur_label = label; + } + } + if (score > score_threshold) { + const float *bbox_pred = + outs[i + fpn_stride.size()] + (idx * 4 * (reg_max + 1)); + bbox_results[cur_label].push_back( + disPred2Bbox(bbox_pred, cur_label, score, col, row, fpn_stride[i], + im_shape, reg_max)); + } + } + } + for (int i = 0; i < (int)bbox_results.size(); i++) { + PPShiTu::nms(bbox_results[i], nms_threshold); + + for (auto box : bbox_results[i]) { + box.rect[0] = box.rect[0] / scale_factor[1]; + box.rect[2] = box.rect[2] / scale_factor[1]; + box.rect[1] = box.rect[1] / scale_factor[0]; + box.rect[3] = box.rect[3] / scale_factor[0]; + results->push_back(box); + } + } +} + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/src/preprocess_op.cc b/src/PaddleClas/deploy/lite_shitu/src/preprocess_op.cc new file mode 100644 index 0000000..9c74d6e --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/preprocess_op.cc @@ -0,0 +1,185 @@ +// Copyright (c) 2021 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. + +#include +#include +#include + +#include "include/preprocess_op.h" + +namespace PPShiTu { + +void InitInfo::Run(cv::Mat* im, ImageBlob* data) { + data->im_shape_ = {static_cast(im->rows), + static_cast(im->cols)}; + data->scale_factor_ = {1., 1.}; + data->in_net_shape_ = {static_cast(im->rows), + static_cast(im->cols)}; +} + +void NormalizeImage::Run(cv::Mat* im, ImageBlob* data) { + double e = 1.0; + if (is_scale_) { + e *= 1./255.0; + } + (*im).convertTo(*im, CV_32FC3, e); + for (int h = 0; h < im->rows; h++) { + for (int w = 0; w < im->cols; w++) { + im->at(h, w)[0] = + (im->at(h, w)[0] - mean_[0]) / scale_[0]; + im->at(h, w)[1] = + (im->at(h, w)[1] - mean_[1]) / scale_[1]; + im->at(h, w)[2] = + (im->at(h, w)[2] - mean_[2]) / scale_[2]; + } + } +} + +void Permute::Run(cv::Mat* im, ImageBlob* data) { + (*im).convertTo(*im, CV_32FC3); + int rh = im->rows; + int rw = im->cols; + int rc = im->channels(); + (data->im_data_).resize(rc * rh * rw); + float* base = (data->im_data_).data(); + for (int i = 0; i < rc; ++i) { + cv::extractChannel(*im, cv::Mat(rh, rw, CV_32FC1, base + i * rh * rw), i); + } +} + +void Resize::Run(cv::Mat* im, ImageBlob* data) { + auto resize_scale = GenerateScale(*im); + data->im_shape_ = {static_cast(im->cols * resize_scale.first), + static_cast(im->rows * resize_scale.second)}; + data->in_net_shape_ = {static_cast(im->cols * resize_scale.first), + static_cast(im->rows * resize_scale.second)}; + cv::resize( + *im, *im, cv::Size(), resize_scale.first, resize_scale.second, interp_); + data->im_shape_ = { + static_cast(im->rows), static_cast(im->cols), + }; + data->scale_factor_ = { + resize_scale.second, resize_scale.first, + }; +} + +std::pair Resize::GenerateScale(const cv::Mat& im) { + std::pair resize_scale; + int origin_w = im.cols; + int origin_h = im.rows; + + if (keep_ratio_) { + int im_size_max = std::max(origin_w, origin_h); + int im_size_min = std::min(origin_w, origin_h); + int target_size_max = + *std::max_element(target_size_.begin(), target_size_.end()); + int target_size_min = + *std::min_element(target_size_.begin(), target_size_.end()); + float scale_min = + static_cast(target_size_min) / static_cast(im_size_min); + float scale_max = + static_cast(target_size_max) / static_cast(im_size_max); + float scale_ratio = std::min(scale_min, scale_max); + resize_scale = {scale_ratio, scale_ratio}; + } else { + resize_scale.first = + static_cast(target_size_[1]) / static_cast(origin_w); + resize_scale.second = + static_cast(target_size_[0]) / static_cast(origin_h); + } + return resize_scale; +} + +void PadStride::Run(cv::Mat* im, ImageBlob* data) { + if (stride_ <= 0) { + return; + } + int rc = im->channels(); + int rh = im->rows; + int rw = im->cols; + int nh = (rh / stride_) * stride_ + (rh % stride_ != 0) * stride_; + int nw = (rw / stride_) * stride_ + (rw % stride_ != 0) * stride_; + cv::copyMakeBorder( + *im, *im, 0, nh - rh, 0, nw - rw, cv::BORDER_CONSTANT, cv::Scalar(0)); + data->in_net_shape_ = { + static_cast(im->rows), static_cast(im->cols), + }; +} + +void TopDownEvalAffine::Run(cv::Mat* im, ImageBlob* data) { + cv::resize(*im, *im, cv::Size(trainsize_[0], trainsize_[1]), 0, 0, interp_); + // todo: Simd::ResizeBilinear(); + data->in_net_shape_ = { + static_cast(trainsize_[1]), static_cast(trainsize_[0]), + }; +} + +// Preprocessor op running order +const std::vector Preprocessor::RUN_ORDER = {"InitInfo", + "DetTopDownEvalAffine", + "DetResize", + "DetNormalizeImage", + "DetPadStride", + "DetPermute"}; + +void Preprocessor::Run(cv::Mat* im, ImageBlob* data) { + for (const auto& name : RUN_ORDER) { + if (ops_.find(name) != ops_.end()) { + ops_[name]->Run(im, data); + } + } +} + +void CropImg(cv::Mat& img, + cv::Mat& crop_img, + std::vector& area, + std::vector& center, + std::vector& scale, + float expandratio) { + int crop_x1 = std::max(0, area[0]); + int crop_y1 = std::max(0, area[1]); + int crop_x2 = std::min(img.cols - 1, area[2]); + int crop_y2 = std::min(img.rows - 1, area[3]); + + int center_x = (crop_x1 + crop_x2) / 2.; + int center_y = (crop_y1 + crop_y2) / 2.; + int half_h = (crop_y2 - crop_y1) / 2.; + int half_w = (crop_x2 - crop_x1) / 2.; + + if (half_h * 3 > half_w * 4) { + half_w = static_cast(half_h * 0.75); + } else { + half_h = static_cast(half_w * 4 / 3); + } + + crop_x1 = + std::max(0, center_x - static_cast(half_w * (1 + expandratio))); + crop_y1 = + std::max(0, center_y - static_cast(half_h * (1 + expandratio))); + crop_x2 = std::min(img.cols - 1, + static_cast(center_x + half_w * (1 + expandratio))); + crop_y2 = std::min(img.rows - 1, + static_cast(center_y + half_h * (1 + expandratio))); + crop_img = + img(cv::Range(crop_y1, crop_y2 + 1), cv::Range(crop_x1, crop_x2 + 1)); + + center.clear(); + center.emplace_back((crop_x1 + crop_x2) / 2); + center.emplace_back((crop_y1 + crop_y2) / 2); + scale.clear(); + scale.emplace_back((crop_x2 - crop_x1)); + scale.emplace_back((crop_y2 - crop_y1)); +} + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/lite_shitu/src/recognition.cc b/src/PaddleClas/deploy/lite_shitu/src/recognition.cc new file mode 100644 index 0000000..0e711f3 --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/recognition.cc @@ -0,0 +1,143 @@ +// Copyright (c) 2022 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. + +#include "include/recognition.h" + +namespace PPShiTu { +std::vector Recognition::RunRecModel(const cv::Mat &img, + double &cost_time) { + + // Read img + cv::Mat resize_image = ResizeImage(img); + + cv::Mat img_fp; + resize_image.convertTo(img_fp, CV_32FC3, scale); + + // Prepare input data from image + std::unique_ptr input_tensor(std::move(this->predictor->GetInput(0))); + input_tensor->Resize({1, 3, img_fp.rows, img_fp.cols}); + auto *data0 = input_tensor->mutable_data(); + + const float *dimg = reinterpret_cast(img_fp.data); + NeonMeanScale(dimg, data0, img_fp.rows * img_fp.cols); + + auto start = std::chrono::system_clock::now(); + // Run predictor + this->predictor->Run(); + + // Get output and post process + std::unique_ptr output_tensor( + std::move(this->predictor->GetOutput(1))); + auto *output_data = output_tensor->data(); + auto end = std::chrono::system_clock::now(); + auto duration = + std::chrono::duration_cast(end - start); + cost_time = double(duration.count()) * + std::chrono::microseconds::period::num / + std::chrono::microseconds::period::den; + + int output_size = 1; + for (auto dim : output_tensor->shape()) { + output_size *= dim; + } + + cv::Mat output_image; + auto results = PostProcess(output_data, output_size, output_image); + return results; +} + +void Recognition::NeonMeanScale(const float *din, float *dout, int size) { + + if (this->mean.size() != 3 || this->std.size() != 3) { + std::cerr << "[ERROR] mean or scale size must equal to 3\n"; + exit(1); + } + float32x4_t vmean0 = vdupq_n_f32(mean[0]); + float32x4_t vmean1 = vdupq_n_f32(mean[1]); + float32x4_t vmean2 = vdupq_n_f32(mean[2]); + float32x4_t vscale0 = vdupq_n_f32(std[0]); + float32x4_t vscale1 = vdupq_n_f32(std[1]); + float32x4_t vscale2 = vdupq_n_f32(std[2]); + + float *dout_c0 = dout; + float *dout_c1 = dout + size; + float *dout_c2 = dout + size * 2; + + int i = 0; + for (; i < size - 3; i += 4) { + float32x4x3_t vin3 = vld3q_f32(din); + float32x4_t vsub0 = vsubq_f32(vin3.val[0], vmean0); + float32x4_t vsub1 = vsubq_f32(vin3.val[1], vmean1); + float32x4_t vsub2 = vsubq_f32(vin3.val[2], vmean2); + float32x4_t vs0 = vmulq_f32(vsub0, vscale0); + float32x4_t vs1 = vmulq_f32(vsub1, vscale1); + float32x4_t vs2 = vmulq_f32(vsub2, vscale2); + vst1q_f32(dout_c0, vs0); + vst1q_f32(dout_c1, vs1); + vst1q_f32(dout_c2, vs2); + + din += 12; + dout_c0 += 4; + dout_c1 += 4; + dout_c2 += 4; + } + for (; i < size; i++) { + *(dout_c0++) = (*(din++) - this->mean[0]) * this->std[0]; + *(dout_c1++) = (*(din++) - this->mean[1]) * this->std[1]; + *(dout_c2++) = (*(din++) - this->mean[2]) * this->std[2]; + } +} + +cv::Mat Recognition::ResizeImage(const cv::Mat &img) { + cv::Mat resize_img; + cv::resize(img, resize_img, cv::Size(this->size, this->size)); + return resize_img; +} +std::vector Recognition::PostProcess(const float *output_data, + int output_size, + cv::Mat &output_image) { + + int max_indices[this->topk]; + double max_scores[this->topk]; + for (int i = 0; i < this->topk; i++) { + max_indices[i] = 0; + max_scores[i] = 0; + } + for (int i = 0; i < output_size; i++) { + float score = output_data[i]; + int index = i; + for (int j = 0; j < this->topk; j++) { + if (score > max_scores[j]) { + index += max_indices[j]; + max_indices[j] = index - max_indices[j]; + index -= max_indices[j]; + score += max_scores[j]; + max_scores[j] = score - max_scores[j]; + score -= max_scores[j]; + } + } + } + + std::vector results(this->topk); + for (int i = 0; i < results.size(); i++) { + results[i].class_name = "Unknown"; + if (max_indices[i] >= 0 && max_indices[i] < this->label_list.size()) { + results[i].class_name = this->label_list[max_indices[i]]; + } + results[i].score = max_scores[i]; + results[i].class_id = max_indices[i]; + } + return results; +} +} diff --git a/src/PaddleClas/deploy/lite_shitu/src/utils.cc b/src/PaddleClas/deploy/lite_shitu/src/utils.cc new file mode 100644 index 0000000..3bc4617 --- /dev/null +++ b/src/PaddleClas/deploy/lite_shitu/src/utils.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2021 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. + +#include "include/utils.h" + +namespace PPShiTu { + +void nms(std::vector &input_boxes, float nms_threshold, + bool rec_nms) { + if (!rec_nms) { + std::sort(input_boxes.begin(), input_boxes.end(), + [](ObjectResult a, ObjectResult b) { + return a.confidence > b.confidence; + }); + } else { + std::sort(input_boxes.begin(), input_boxes.end(), + [](ObjectResult a, ObjectResult b) { + return a.rec_result[0].score > b.rec_result[0].score; + }); + } + std::vector vArea(input_boxes.size()); + for (int i = 0; i < int(input_boxes.size()); ++i) { + vArea[i] = (input_boxes.at(i).rect[2] - input_boxes.at(i).rect[0] + 1) * + (input_boxes.at(i).rect[3] - input_boxes.at(i).rect[1] + 1); + } + for (int i = 0; i < int(input_boxes.size()); ++i) { + for (int j = i + 1; j < int(input_boxes.size());) { + float xx1 = (std::max)(input_boxes[i].rect[0], input_boxes[j].rect[0]); + float yy1 = (std::max)(input_boxes[i].rect[1], input_boxes[j].rect[1]); + float xx2 = (std::min)(input_boxes[i].rect[2], input_boxes[j].rect[2]); + float yy2 = (std::min)(input_boxes[i].rect[3], input_boxes[j].rect[3]); + float w = (std::max)(float(0), xx2 - xx1 + 1); + float h = (std::max)(float(0), yy2 - yy1 + 1); + float inter = w * h; + float ovr = inter / (vArea[i] + vArea[j] - inter); + if (ovr >= nms_threshold) { + input_boxes.erase(input_boxes.begin() + j); + vArea.erase(vArea.begin() + j); + } else { + j++; + } + } + } +} + +} // namespace PPShiTu diff --git a/src/PaddleClas/deploy/models/general_PPLCNet_x2_5_lite_v1.0_infer/inference.pdiparams b/src/PaddleClas/deploy/models/general_PPLCNet_x2_5_lite_v1.0_infer/inference.pdiparams new file mode 100644 index 0000000..014e7c2 Binary files /dev/null and b/src/PaddleClas/deploy/models/general_PPLCNet_x2_5_lite_v1.0_infer/inference.pdiparams differ diff --git a/src/PaddleClas/deploy/models/general_PPLCNet_x2_5_lite_v1.0_infer/inference.pdmodel b/src/PaddleClas/deploy/models/general_PPLCNet_x2_5_lite_v1.0_infer/inference.pdmodel new file mode 100644 index 0000000..a444c2d Binary files /dev/null and b/src/PaddleClas/deploy/models/general_PPLCNet_x2_5_lite_v1.0_infer/inference.pdmodel differ diff --git a/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/infer_cfg.yml b/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/infer_cfg.yml new file mode 100644 index 0000000..42f78c0 --- /dev/null +++ b/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/infer_cfg.yml @@ -0,0 +1,28 @@ +mode: fluid +draw_threshold: 0.5 +metric: COCO +use_dynamic_shape: false +arch: PicoDet +min_subgraph_size: 3 +Preprocess: +- interp: 2 + keep_ratio: false + target_size: + - 416 + - 416 + type: Resize +- is_scale: true + mean: + - 0.485 + - 0.456 + - 0.406 + std: + - 0.229 + - 0.224 + - 0.225 + type: NormalizeImage +- type: Permute +- stride: 32 + type: PadStride +label_list: +- foreground diff --git a/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/inference.pdiparams b/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/inference.pdiparams new file mode 100644 index 0000000..9d74bb0 Binary files /dev/null and b/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/inference.pdiparams differ diff --git a/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/inference.pdmodel b/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/inference.pdmodel new file mode 100644 index 0000000..544cbcd Binary files /dev/null and b/src/PaddleClas/deploy/models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/inference.pdmodel differ diff --git a/src/PaddleClas/deploy/output/110.jpeg b/src/PaddleClas/deploy/output/110.jpeg new file mode 100644 index 0000000..b5c60c0 Binary files /dev/null and b/src/PaddleClas/deploy/output/110.jpeg differ diff --git a/src/PaddleClas/deploy/output/1101.jpeg b/src/PaddleClas/deploy/output/1101.jpeg new file mode 100644 index 0000000..12fcd0d Binary files /dev/null and b/src/PaddleClas/deploy/output/1101.jpeg differ diff --git a/src/PaddleClas/deploy/output/157333-1868444027.jpg b/src/PaddleClas/deploy/output/157333-1868444027.jpg new file mode 100644 index 0000000..1988409 Binary files /dev/null and b/src/PaddleClas/deploy/output/157333-1868444027.jpg differ diff --git a/src/PaddleClas/deploy/output/202103160813194077.jpg b/src/PaddleClas/deploy/output/202103160813194077.jpg new file mode 100644 index 0000000..b953d58 Binary files /dev/null and b/src/PaddleClas/deploy/output/202103160813194077.jpg differ diff --git a/src/PaddleClas/deploy/output/202103160813194078.jpg b/src/PaddleClas/deploy/output/202103160813194078.jpg new file mode 100644 index 0000000..8e9314e Binary files /dev/null and b/src/PaddleClas/deploy/output/202103160813194078.jpg differ diff --git a/src/PaddleClas/deploy/output/5645c5659bc39.jpg b/src/PaddleClas/deploy/output/5645c5659bc39.jpg new file mode 100644 index 0000000..efaa287 Binary files /dev/null and b/src/PaddleClas/deploy/output/5645c5659bc39.jpg differ diff --git a/src/PaddleClas/deploy/output/90.jpeg b/src/PaddleClas/deploy/output/90.jpeg new file mode 100644 index 0000000..191cc1c Binary files /dev/null and b/src/PaddleClas/deploy/output/90.jpeg differ diff --git a/src/PaddleClas/deploy/output/DSCF4020.jpg b/src/PaddleClas/deploy/output/DSCF4020.jpg new file mode 100644 index 0000000..8a882f2 Binary files /dev/null and b/src/PaddleClas/deploy/output/DSCF4020.jpg differ diff --git a/src/PaddleClas/deploy/output/Image_25.jpg b/src/PaddleClas/deploy/output/Image_25.jpg new file mode 100644 index 0000000..e057020 Binary files /dev/null and b/src/PaddleClas/deploy/output/Image_25.jpg differ diff --git a/src/PaddleClas/deploy/output/Image_4.png b/src/PaddleClas/deploy/output/Image_4.png new file mode 100644 index 0000000..1eef66e Binary files /dev/null and b/src/PaddleClas/deploy/output/Image_4.png differ diff --git a/src/PaddleClas/deploy/output/Image_5.png b/src/PaddleClas/deploy/output/Image_5.png new file mode 100644 index 0000000..e1a04c9 Binary files /dev/null and b/src/PaddleClas/deploy/output/Image_5.png differ diff --git a/src/PaddleClas/deploy/output/Image_6.jpg b/src/PaddleClas/deploy/output/Image_6.jpg new file mode 100644 index 0000000..0a9daf1 Binary files /dev/null and b/src/PaddleClas/deploy/output/Image_6.jpg differ diff --git a/src/PaddleClas/deploy/output/Image_99.jpg b/src/PaddleClas/deploy/output/Image_99.jpg new file mode 100644 index 0000000..a6ee6cd Binary files /dev/null and b/src/PaddleClas/deploy/output/Image_99.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00017.jpg b/src/PaddleClas/deploy/output/image_00017.jpg new file mode 100644 index 0000000..3f68667 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00017.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00023.jpg b/src/PaddleClas/deploy/output/image_00023.jpg new file mode 100644 index 0000000..02dfac0 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00023.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00038.jpg b/src/PaddleClas/deploy/output/image_00038.jpg new file mode 100644 index 0000000..27d0cb3 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00038.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00055.jpg b/src/PaddleClas/deploy/output/image_00055.jpg new file mode 100644 index 0000000..982ad4a Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00055.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00082.jpg b/src/PaddleClas/deploy/output/image_00082.jpg new file mode 100644 index 0000000..b9851da Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00082.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00083.jpg b/src/PaddleClas/deploy/output/image_00083.jpg new file mode 100644 index 0000000..b664aa6 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00083.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00094.jpg b/src/PaddleClas/deploy/output/image_00094.jpg new file mode 100644 index 0000000..d1f5178 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00094.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00169.jpg b/src/PaddleClas/deploy/output/image_00169.jpg new file mode 100644 index 0000000..4bbcbca Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00169.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00212.jpg b/src/PaddleClas/deploy/output/image_00212.jpg new file mode 100644 index 0000000..a5a12c8 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00212.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00222.jpg b/src/PaddleClas/deploy/output/image_00222.jpg new file mode 100644 index 0000000..513d1d9 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00222.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00255.jpg b/src/PaddleClas/deploy/output/image_00255.jpg new file mode 100644 index 0000000..86a661d Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00255.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00269.jpg b/src/PaddleClas/deploy/output/image_00269.jpg new file mode 100644 index 0000000..7bc7ca5 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00269.jpg differ diff --git a/src/PaddleClas/deploy/output/image_00285.jpg b/src/PaddleClas/deploy/output/image_00285.jpg new file mode 100644 index 0000000..dd04ab2 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_00285.jpg differ diff --git a/src/PaddleClas/deploy/output/image_06734.jpg b/src/PaddleClas/deploy/output/image_06734.jpg new file mode 100644 index 0000000..1f0ba33 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_06734.jpg differ diff --git a/src/PaddleClas/deploy/output/image_06734.png b/src/PaddleClas/deploy/output/image_06734.png new file mode 100644 index 0000000..71e5cc2 Binary files /dev/null and b/src/PaddleClas/deploy/output/image_06734.png differ diff --git a/src/PaddleClas/deploy/output/mosilian.jpeg b/src/PaddleClas/deploy/output/mosilian.jpeg new file mode 100644 index 0000000..df7817d Binary files /dev/null and b/src/PaddleClas/deploy/output/mosilian.jpeg differ diff --git a/src/PaddleClas/deploy/output/nongfu_spring.jpeg b/src/PaddleClas/deploy/output/nongfu_spring.jpeg new file mode 100644 index 0000000..2354e01 Binary files /dev/null and b/src/PaddleClas/deploy/output/nongfu_spring.jpeg differ diff --git a/src/PaddleClas/deploy/output/sy_20110730200033739060.jpg b/src/PaddleClas/deploy/output/sy_20110730200033739060.jpg new file mode 100644 index 0000000..2fb2195 Binary files /dev/null and b/src/PaddleClas/deploy/output/sy_20110730200033739060.jpg differ diff --git a/src/PaddleClas/deploy/output/v2-b9c2666c76372cefc49c292ffa9d5903_r.jpg b/src/PaddleClas/deploy/output/v2-b9c2666c76372cefc49c292ffa9d5903_r.jpg new file mode 100644 index 0000000..49873a5 Binary files /dev/null and b/src/PaddleClas/deploy/output/v2-b9c2666c76372cefc49c292ffa9d5903_r.jpg differ diff --git a/src/PaddleClas/deploy/output/xpic9231.jpg b/src/PaddleClas/deploy/output/xpic9231.jpg new file mode 100644 index 0000000..2a2a2a3 Binary files /dev/null and b/src/PaddleClas/deploy/output/xpic9231.jpg differ diff --git a/src/PaddleClas/deploy/paddle2onnx/readme.md b/src/PaddleClas/deploy/paddle2onnx/readme.md new file mode 100644 index 0000000..d1307ea --- /dev/null +++ b/src/PaddleClas/deploy/paddle2onnx/readme.md @@ -0,0 +1,61 @@ +# paddle2onnx 模型转化与预测 + +本章节介绍 ResNet50_vd 模型如何转化为 ONNX 模型,并基于 ONNX 引擎预测。 + +## 1. 环境准备 + +需要准备 Paddle2ONNX 模型转化环境,和 ONNX 模型预测环境。 + +Paddle2ONNX 支持将 PaddlePaddle 模型格式转化到 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 9~11,部分Paddle算子支持更低的ONNX Opset转换。 +更多细节可参考 [Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX/blob/develop/README_zh.md) + +- 安装 Paddle2ONNX +``` +python3.7 -m pip install paddle2onnx +``` + +- 安装 ONNX 运行时 +``` +python3.7 -m pip install onnxruntime +``` + +## 2. 模型转换 + +- ResNet50_vd inference模型下载 + +``` +cd deploy +mkdir models && cd models +wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar +cd .. +``` + +- 模型转换 + +使用 Paddle2ONNX 将 Paddle 静态图模型转换为 ONNX 模型格式: +``` +paddle2onnx --model_dir=./models/ResNet50_vd_infer/ \ +--model_filename=inference.pdmodel \ +--params_filename=inference.pdiparams \ +--save_file=./models/ResNet50_vd_infer/inference.onnx \ +--opset_version=10 \ +--enable_onnx_checker=True +``` + +执行完毕后,ONNX 模型 `inference.onnx` 会被保存在 `./models/ResNet50_vd_infer/` 路径下 + +## 3. onnx 预测 + +执行如下命令: +``` +python3.7 python/predict_cls.py \ +-c configs/inference_cls.yaml \ +-o Global.use_onnx=True \ +-o Global.use_gpu=False \ +-o Global.inference_model_dir=./models/ResNet50_vd_infer +``` + +结果如下: +``` +ILSVRC2012_val_00000010.jpeg: class id(s): [153, 204, 229, 332, 155], score(s): [0.69, 0.10, 0.02, 0.01, 0.01], label_name(s): ['Maltese dog, Maltese terrier, Maltese', 'Lhasa, Lhasa apso', 'Old English sheepdog, bobtail', 'Angora, Angora rabbit', 'Shih-Tzu'] +``` diff --git a/src/PaddleClas/deploy/paddleserving/__init__.py b/src/PaddleClas/deploy/paddleserving/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/paddleserving/classification_web_service.py b/src/PaddleClas/deploy/paddleserving/classification_web_service.py new file mode 100644 index 0000000..75eb335 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/classification_web_service.py @@ -0,0 +1,74 @@ +# 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. +import sys +from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage +try: + from paddle_serving_server_gpu.web_service import WebService, Op +except ImportError: + from paddle_serving_server.web_service import WebService, Op +import logging +import numpy as np +import base64, cv2 + + +class ImagenetOp(Op): + def init_op(self): + self.seq = Sequential([ + Resize(256), CenterCrop(224), RGB2BGR(), Transpose((2, 0, 1)), + Div(255), Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], + True) + ]) + self.label_dict = {} + label_idx = 0 + with open("imagenet.label") as fin: + for line in fin: + self.label_dict[label_idx] = line.strip() + label_idx += 1 + + def preprocess(self, input_dicts, data_id, log_id): + (_, input_dict), = input_dicts.items() + batch_size = len(input_dict.keys()) + imgs = [] + for key in input_dict.keys(): + data = base64.b64decode(input_dict[key].encode('utf8')) + data = np.fromstring(data, np.uint8) + im = cv2.imdecode(data, cv2.IMREAD_COLOR) + img = self.seq(im) + imgs.append(img[np.newaxis, :].copy()) + input_imgs = np.concatenate(imgs, axis=0) + return {"inputs": input_imgs}, False, None, "" + + def postprocess(self, input_dicts, fetch_dict, data_id, log_id): + score_list = fetch_dict["prediction"] + result = {"label": [], "prob": []} + for score in score_list: + score = score.tolist() + max_score = max(score) + result["label"].append(self.label_dict[score.index(max_score)] + .strip().replace(",", "")) + result["prob"].append(max_score) + result["label"] = str(result["label"]) + result["prob"] = str(result["prob"]) + return result, None, "" + + +class ImageService(WebService): + def get_pipeline_response(self, read_op): + image_op = ImagenetOp(name="imagenet", input_ops=[read_op]) + return image_op + + +uci_service = ImageService(name="imagenet") +uci_service.prepare_pipeline_config("config.yml") +uci_service.run_service() diff --git a/src/PaddleClas/deploy/paddleserving/config.yml b/src/PaddleClas/deploy/paddleserving/config.yml new file mode 100644 index 0000000..d9f464d --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/config.yml @@ -0,0 +1,33 @@ +#worker_num, 最大并发数。当build_dag_each_worker=True时, 框架会创建worker_num个进程,每个进程内构建grpcSever和DAG +##当build_dag_each_worker=False时,框架会设置主线程grpc线程池的max_workers=worker_num +worker_num: 1 + +#http端口, rpc_port和http_port不允许同时为空。当rpc_port可用且http_port为空时,不自动生成http_port +http_port: 18080 +rpc_port: 9993 + +dag: + #op资源类型, True, 为线程模型;False,为进程模型 + is_thread_op: False +op: + imagenet: + #并发数,is_thread_op=True时,为线程并发;否则为进程并发 + concurrency: 1 + + #当op配置没有server_endpoints时,从local_service_conf读取本地服务配置 + local_service_conf: + + #uci模型路径 + model_config: ResNet50_vd_serving + + #计算硬件类型: 空缺时由devices决定(CPU/GPU),0=cpu, 1=gpu, 2=tensorRT, 3=arm cpu, 4=kunlun xpu + device_type: 1 + + #计算硬件ID,当devices为""或不写时为CPU预测;当devices为"0", "0,1,2"时为GPU预测,表示使用的GPU卡 + devices: "0" # "0,1" + + #client类型,包括brpc, grpc和local_predictor.local_predictor不启动Serving服务,进程内预测 + client_type: local_predictor + + #Fetch结果列表,以client_config中fetch_var的alias_name为准 + fetch_list: ["prediction"] diff --git a/src/PaddleClas/deploy/paddleserving/cpu_utilization.py b/src/PaddleClas/deploy/paddleserving/cpu_utilization.py new file mode 100644 index 0000000..984c723 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/cpu_utilization.py @@ -0,0 +1,4 @@ +import psutil +cpu_utilization=psutil.cpu_percent(1,False) +print('CPU_UTILIZATION:', cpu_utilization) + diff --git a/src/PaddleClas/deploy/paddleserving/daisy.jpg b/src/PaddleClas/deploy/paddleserving/daisy.jpg new file mode 100644 index 0000000..7edeca6 Binary files /dev/null and b/src/PaddleClas/deploy/paddleserving/daisy.jpg differ diff --git a/src/PaddleClas/deploy/paddleserving/imagenet.label b/src/PaddleClas/deploy/paddleserving/imagenet.label new file mode 100644 index 0000000..d714673 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/imagenet.label @@ -0,0 +1,1000 @@ +tench, Tinca tinca, +goldfish, Carassius auratus, +great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias, +tiger shark, Galeocerdo cuvieri, +hammerhead, hammerhead shark, +electric ray, crampfish, numbfish, torpedo, +stingray, +cock, +hen, +ostrich, Struthio camelus, +brambling, Fringilla montifringilla, +goldfinch, Carduelis carduelis, +house finch, linnet, Carpodacus mexicanus, +junco, snowbird, +indigo bunting, indigo finch, indigo bird, Passerina cyanea, +robin, American robin, Turdus migratorius, +bulbul, +jay, +magpie, +chickadee, +water ouzel, dipper, +kite, +bald eagle, American eagle, Haliaeetus leucocephalus, +vulture, +great grey owl, great gray owl, Strix nebulosa, +European fire salamander, Salamandra salamandra, +common newt, Triturus vulgaris, +eft, +spotted salamander, Ambystoma maculatum, +axolotl, mud puppy, Ambystoma mexicanum, +bullfrog, Rana catesbeiana, +tree frog, tree-frog, +tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui, +loggerhead, loggerhead turtle, Caretta caretta, +leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea, +mud turtle, +terrapin, +box turtle, box tortoise, +banded gecko, +common iguana, iguana, Iguana iguana, +American chameleon, anole, Anolis carolinensis, +whiptail, whiptail lizard, +agama, +frilled lizard, Chlamydosaurus kingi, +alligator lizard, +Gila monster, Heloderma suspectum, +green lizard, Lacerta viridis, +African chameleon, Chamaeleo chamaeleon, +Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis, +African crocodile, Nile crocodile, Crocodylus niloticus, +American alligator, Alligator mississipiensis, +triceratops, +thunder snake, worm snake, Carphophis amoenus, +ringneck snake, ring-necked snake, ring snake, +hognose snake, puff adder, sand viper, +green snake, grass snake, +king snake, kingsnake, +garter snake, grass snake, +water snake, +vine snake, +night snake, Hypsiglena torquata, +boa constrictor, Constrictor constrictor, +rock python, rock snake, Python sebae, +Indian cobra, Naja naja, +green mamba, +sea snake, +horned viper, cerastes, sand viper, horned asp, Cerastes cornutus, +diamondback, diamondback rattlesnake, Crotalus adamanteus, +sidewinder, horned rattlesnake, Crotalus cerastes, +trilobite, +harvestman, daddy longlegs, Phalangium opilio, +scorpion, +black and gold garden spider, Argiope aurantia, +barn spider, Araneus cavaticus, +garden spider, Aranea diademata, +black widow, Latrodectus mactans, +tarantula, +wolf spider, hunting spider, +tick, +centipede, +black grouse, +ptarmigan, +ruffed grouse, partridge, Bonasa umbellus, +prairie chicken, prairie grouse, prairie fowl, +peacock, +quail, +partridge, +African grey, African gray, Psittacus erithacus, +macaw, +sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita, +lorikeet, +coucal, +bee eater, +hornbill, +hummingbird, +jacamar, +toucan, +drake, +red-breasted merganser, Mergus serrator, +goose, +black swan, Cygnus atratus, +tusker, +echidna, spiny anteater, anteater, +platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus, +wallaby, brush kangaroo, +koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus, +wombat, +jellyfish, +sea anemone, anemone, +brain coral, +flatworm, platyhelminth, +nematode, nematode worm, roundworm, +conch, +snail, +slug, +sea slug, nudibranch, +chiton, coat-of-mail shell, sea cradle, polyplacophore, +chambered nautilus, pearly nautilus, nautilus, +Dungeness crab, Cancer magister, +rock crab, Cancer irroratus, +fiddler crab, +king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica, +American lobster, Northern lobster, Maine lobster, Homarus americanus, +spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish, +crayfish, crawfish, crawdad, crawdaddy, +hermit crab, +isopod, +white stork, Ciconia ciconia, +black stork, Ciconia nigra, +spoonbill, +flamingo, +little blue heron, Egretta caerulea, +American egret, great white heron, Egretta albus, +bittern, +crane, +limpkin, Aramus pictus, +European gallinule, Porphyrio porphyrio, +American coot, marsh hen, mud hen, water hen, Fulica americana, +bustard, +ruddy turnstone, Arenaria interpres, +red-backed sandpiper, dunlin, Erolia alpina, +redshank, Tringa totanus, +dowitcher, +oystercatcher, oyster catcher, +pelican, +king penguin, Aptenodytes patagonica, +albatross, mollymawk, +grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus, +killer whale, killer, orca, grampus, sea wolf, Orcinus orca, +dugong, Dugong dugon, +sea lion, +Chihuahua, +Japanese spaniel, +Maltese dog, Maltese terrier, Maltese, +Pekinese, Pekingese, Peke, +Shih-Tzu, +Blenheim spaniel, +papillon, +toy terrier, +Rhodesian ridgeback, +Afghan hound, Afghan, +basset, basset hound, +beagle, +bloodhound, sleuthhound, +bluetick, +black-and-tan coonhound, +Walker hound, Walker foxhound, +English foxhound, +redbone, +borzoi, Russian wolfhound, +Irish wolfhound, +Italian greyhound, +whippet, +Ibizan hound, Ibizan Podenco, +Norwegian elkhound, elkhound, +otterhound, otter hound, +Saluki, gazelle hound, +Scottish deerhound, deerhound, +Weimaraner, +Staffordshire bullterrier, Staffordshire bull terrier, +American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier, +Bedlington terrier, +Border terrier, +Kerry blue terrier, +Irish terrier, +Norfolk terrier, +Norwich terrier, +Yorkshire terrier, +wire-haired fox terrier, +Lakeland terrier, +Sealyham terrier, Sealyham, +Airedale, Airedale terrier, +cairn, cairn terrier, +Australian terrier, +Dandie Dinmont, Dandie Dinmont terrier, +Boston bull, Boston terrier, +miniature schnauzer, +giant schnauzer, +standard schnauzer, +Scotch terrier, Scottish terrier, Scottie, +Tibetan terrier, chrysanthemum dog, +silky terrier, Sydney silky, +soft-coated wheaten terrier, +West Highland white terrier, +Lhasa, Lhasa apso, +flat-coated retriever, +curly-coated retriever, +golden retriever, +Labrador retriever, +Chesapeake Bay retriever, +German short-haired pointer, +vizsla, Hungarian pointer, +English setter, +Irish setter, red setter, +Gordon setter, +Brittany spaniel, +clumber, clumber spaniel, +English springer, English springer spaniel, +Welsh springer spaniel, +cocker spaniel, English cocker spaniel, cocker, +Sussex spaniel, +Irish water spaniel, +kuvasz, +schipperke, +groenendael, +malinois, +briard, +kelpie, +komondor, +Old English sheepdog, bobtail, +Shetland sheepdog, Shetland sheep dog, Shetland, +collie, +Border collie, +Bouvier des Flandres, Bouviers des Flandres, +Rottweiler, +German shepherd, German shepherd dog, German police dog, alsatian, +Doberman, Doberman pinscher, +miniature pinscher, +Greater Swiss Mountain dog, +Bernese mountain dog, +Appenzeller, +EntleBucher, +boxer, +bull mastiff, +Tibetan mastiff, +French bulldog, +Great Dane, +Saint Bernard, St Bernard, +Eskimo dog, husky, +malamute, malemute, Alaskan malamute, +Siberian husky, +dalmatian, coach dog, carriage dog, +affenpinscher, monkey pinscher, monkey dog, +basenji, +pug, pug-dog, +Leonberg, +Newfoundland, Newfoundland dog, +Great Pyrenees, +Samoyed, Samoyede, +Pomeranian, +chow, chow chow, +keeshond, +Brabancon griffon, +Pembroke, Pembroke Welsh corgi, +Cardigan, Cardigan Welsh corgi, +toy poodle, +miniature poodle, +standard poodle, +Mexican hairless, +timber wolf, grey wolf, gray wolf, Canis lupus, +white wolf, Arctic wolf, Canis lupus tundrarum, +red wolf, maned wolf, Canis rufus, Canis niger, +coyote, prairie wolf, brush wolf, Canis latrans, +dingo, warrigal, warragal, Canis dingo, +dhole, Cuon alpinus, +African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus, +hyena, hyaena, +red fox, Vulpes vulpes, +kit fox, Vulpes macrotis, +Arctic fox, white fox, Alopex lagopus, +grey fox, gray fox, Urocyon cinereoargenteus, +tabby, tabby cat, +tiger cat, +Persian cat, +Siamese cat, Siamese, +Egyptian cat, +cougar, puma, catamount, mountain lion, painter, panther, Felis concolor, +lynx, catamount, +leopard, Panthera pardus, +snow leopard, ounce, Panthera uncia, +jaguar, panther, Panthera onca, Felis onca, +lion, king of beasts, Panthera leo, +tiger, Panthera tigris, +cheetah, chetah, Acinonyx jubatus, +brown bear, bruin, Ursus arctos, +American black bear, black bear, Ursus americanus, Euarctos americanus, +ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus, +sloth bear, Melursus ursinus, Ursus ursinus, +mongoose, +meerkat, mierkat, +tiger beetle, +ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle, +ground beetle, carabid beetle, +long-horned beetle, longicorn, longicorn beetle, +leaf beetle, chrysomelid, +dung beetle, +rhinoceros beetle, +weevil, +fly, +bee, +ant, emmet, pismire, +grasshopper, hopper, +cricket, +walking stick, walkingstick, stick insect, +cockroach, roach, +mantis, mantid, +cicada, cicala, +leafhopper, +lacewing, lacewing fly, +"dragonfly, darning needle, devils darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk", +damselfly, +admiral, +ringlet, ringlet butterfly, +monarch, monarch butterfly, milkweed butterfly, Danaus plexippus, +cabbage butterfly, +sulphur butterfly, sulfur butterfly, +lycaenid, lycaenid butterfly, +starfish, sea star, +sea urchin, +sea cucumber, holothurian, +wood rabbit, cottontail, cottontail rabbit, +hare, +Angora, Angora rabbit, +hamster, +porcupine, hedgehog, +fox squirrel, eastern fox squirrel, Sciurus niger, +marmot, +beaver, +guinea pig, Cavia cobaya, +sorrel, +zebra, +hog, pig, grunter, squealer, Sus scrofa, +wild boar, boar, Sus scrofa, +warthog, +hippopotamus, hippo, river horse, Hippopotamus amphibius, +ox, +water buffalo, water ox, Asiatic buffalo, Bubalus bubalis, +bison, +ram, tup, +bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis, +ibex, Capra ibex, +hartebeest, +impala, Aepyceros melampus, +gazelle, +Arabian camel, dromedary, Camelus dromedarius, +llama, +weasel, +mink, +polecat, fitch, foulmart, foumart, Mustela putorius, +black-footed ferret, ferret, Mustela nigripes, +otter, +skunk, polecat, wood pussy, +badger, +armadillo, +three-toed sloth, ai, Bradypus tridactylus, +orangutan, orang, orangutang, Pongo pygmaeus, +gorilla, Gorilla gorilla, +chimpanzee, chimp, Pan troglodytes, +gibbon, Hylobates lar, +siamang, Hylobates syndactylus, Symphalangus syndactylus, +guenon, guenon monkey, +patas, hussar monkey, Erythrocebus patas, +baboon, +macaque, +langur, +colobus, colobus monkey, +proboscis monkey, Nasalis larvatus, +marmoset, +capuchin, ringtail, Cebus capucinus, +howler monkey, howler, +titi, titi monkey, +spider monkey, Ateles geoffroyi, +squirrel monkey, Saimiri sciureus, +Madagascar cat, ring-tailed lemur, Lemur catta, +indri, indris, Indri indri, Indri brevicaudatus, +Indian elephant, Elephas maximus, +African elephant, Loxodonta africana, +lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens, +giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca, +barracouta, snoek, +eel, +coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch, +rock beauty, Holocanthus tricolor, +anemone fish, +sturgeon, +gar, garfish, garpike, billfish, Lepisosteus osseus, +lionfish, +puffer, pufferfish, blowfish, globefish, +abacus, +abaya, +"academic gown, academic robe, judges robe", +accordion, piano accordion, squeeze box, +acoustic guitar, +aircraft carrier, carrier, flattop, attack aircraft carrier, +airliner, +airship, dirigible, +altar, +ambulance, +amphibian, amphibious vehicle, +analog clock, +apiary, bee house, +apron, +ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin, +assault rifle, assault gun, +backpack, back pack, knapsack, packsack, rucksack, haversack, +bakery, bakeshop, bakehouse, +balance beam, beam, +balloon, +ballpoint, ballpoint pen, ballpen, Biro, +Band Aid, +banjo, +bannister, banister, balustrade, balusters, handrail, +barbell, +barber chair, +barbershop, +barn, +barometer, +barrel, cask, +barrow, garden cart, lawn cart, wheelbarrow, +baseball, +basketball, +bassinet, +bassoon, +bathing cap, swimming cap, +bath towel, +bathtub, bathing tub, bath, tub, +beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon, +beacon, lighthouse, beacon light, pharos, +beaker, +bearskin, busby, shako, +beer bottle, +beer glass, +bell cote, bell cot, +bib, +bicycle-built-for-two, tandem bicycle, tandem, +bikini, two-piece, +binder, ring-binder, +binoculars, field glasses, opera glasses, +birdhouse, +boathouse, +bobsled, bobsleigh, bob, +bolo tie, bolo, bola tie, bola, +bonnet, poke bonnet, +bookcase, +bookshop, bookstore, bookstall, +bottlecap, +bow, +bow tie, bow-tie, bowtie, +brass, memorial tablet, plaque, +brassiere, bra, bandeau, +breakwater, groin, groyne, mole, bulwark, seawall, jetty, +breastplate, aegis, egis, +broom, +bucket, pail, +buckle, +bulletproof vest, +bullet train, bullet, +butcher shop, meat market, +cab, hack, taxi, taxicab, +caldron, cauldron, +candle, taper, wax light, +cannon, +canoe, +can opener, tin opener, +cardigan, +car mirror, +carousel, carrousel, merry-go-round, roundabout, whirligig, +"carpenters kit, tool kit", +carton, +car wheel, +cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM, +cassette, +cassette player, +castle, +catamaran, +CD player, +cello, violoncello, +cellular telephone, cellular phone, cellphone, cell, mobile phone, +chain, +chainlink fence, +chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour, +chain saw, chainsaw, +chest, +chiffonier, commode, +chime, bell, gong, +china cabinet, china closet, +Christmas stocking, +church, church building, +cinema, movie theater, movie theatre, movie house, picture palace, +cleaver, meat cleaver, chopper, +cliff dwelling, +cloak, +clog, geta, patten, sabot, +cocktail shaker, +coffee mug, +coffeepot, +coil, spiral, volute, whorl, helix, +combination lock, +computer keyboard, keypad, +confectionery, confectionary, candy store, +container ship, containership, container vessel, +convertible, +corkscrew, bottle screw, +cornet, horn, trumpet, trump, +cowboy boot, +cowboy hat, ten-gallon hat, +cradle, +crane, +crash helmet, +crate, +crib, cot, +Crock Pot, +croquet ball, +crutch, +cuirass, +dam, dike, dyke, +desk, +desktop computer, +dial telephone, dial phone, +diaper, nappy, napkin, +digital clock, +digital watch, +dining table, board, +dishrag, dishcloth, +dishwasher, dish washer, dishwashing machine, +disk brake, disc brake, +dock, dockage, docking facility, +dogsled, dog sled, dog sleigh, +dome, +doormat, welcome mat, +drilling platform, offshore rig, +drum, membranophone, tympan, +drumstick, +dumbbell, +Dutch oven, +electric fan, blower, +electric guitar, +electric locomotive, +entertainment center, +envelope, +espresso maker, +face powder, +feather boa, boa, +file, file cabinet, filing cabinet, +fireboat, +fire engine, fire truck, +fire screen, fireguard, +flagpole, flagstaff, +flute, transverse flute, +folding chair, +football helmet, +forklift, +fountain, +fountain pen, +four-poster, +freight car, +French horn, horn, +frying pan, frypan, skillet, +fur coat, +garbage truck, dustcart, +gasmask, respirator, gas helmet, +gas pump, gasoline pump, petrol pump, island dispenser, +goblet, +go-kart, +golf ball, +golfcart, golf cart, +gondola, +gong, tam-tam, +gown, +grand piano, grand, +greenhouse, nursery, glasshouse, +grille, radiator grille, +grocery store, grocery, food market, market, +guillotine, +hair slide, +hair spray, +half track, +hammer, +hamper, +hand blower, blow dryer, blow drier, hair dryer, hair drier, +hand-held computer, hand-held microcomputer, +handkerchief, hankie, hanky, hankey, +hard disc, hard disk, fixed disk, +harmonica, mouth organ, harp, mouth harp, +harp, +harvester, reaper, +hatchet, +holster, +home theater, home theatre, +honeycomb, +hook, claw, +hoopskirt, crinoline, +horizontal bar, high bar, +horse cart, horse-cart, +hourglass, +iPod, +iron, smoothing iron, +"jack-o-lantern", +jean, blue jean, denim, +jeep, landrover, +jersey, T-shirt, tee shirt, +jigsaw puzzle, +jinrikisha, ricksha, rickshaw, +joystick, +kimono, +knee pad, +knot, +lab coat, laboratory coat, +ladle, +lampshade, lamp shade, +laptop, laptop computer, +lawn mower, mower, +lens cap, lens cover, +letter opener, paper knife, paperknife, +library, +lifeboat, +lighter, light, igniter, ignitor, +limousine, limo, +liner, ocean liner, +lipstick, lip rouge, +Loafer, +lotion, +loudspeaker, speaker, speaker unit, loudspeaker system, speaker system, +"loupe, jewelers loupe", +lumbermill, sawmill, +magnetic compass, +mailbag, postbag, +mailbox, letter box, +maillot, +maillot, tank suit, +manhole cover, +maraca, +marimba, xylophone, +mask, +matchstick, +maypole, +maze, labyrinth, +measuring cup, +medicine chest, medicine cabinet, +megalith, megalithic structure, +microphone, mike, +microwave, microwave oven, +military uniform, +milk can, +minibus, +miniskirt, mini, +minivan, +missile, +mitten, +mixing bowl, +mobile home, manufactured home, +Model T, +modem, +monastery, +monitor, +moped, +mortar, +mortarboard, +mosque, +mosquito net, +motor scooter, scooter, +mountain bike, all-terrain bike, off-roader, +mountain tent, +mouse, computer mouse, +mousetrap, +moving van, +muzzle, +nail, +neck brace, +necklace, +nipple, +notebook, notebook computer, +obelisk, +oboe, hautboy, hautbois, +ocarina, sweet potato, +odometer, hodometer, mileometer, milometer, +oil filter, +organ, pipe organ, +oscilloscope, scope, cathode-ray oscilloscope, CRO, +overskirt, +oxcart, +oxygen mask, +packet, +paddle, boat paddle, +paddlewheel, paddle wheel, +padlock, +paintbrush, +"pajama, pyjama, pjs, jammies", +palace, +panpipe, pandean pipe, syrinx, +paper towel, +parachute, chute, +parallel bars, bars, +park bench, +parking meter, +passenger car, coach, carriage, +patio, terrace, +pay-phone, pay-station, +pedestal, plinth, footstall, +pencil box, pencil case, +pencil sharpener, +perfume, essence, +Petri dish, +photocopier, +pick, plectrum, plectron, +pickelhaube, +picket fence, paling, +pickup, pickup truck, +pier, +piggy bank, penny bank, +pill bottle, +pillow, +ping-pong ball, +pinwheel, +pirate, pirate ship, +pitcher, ewer, +"plane, carpenters plane, woodworking plane", +planetarium, +plastic bag, +plate rack, +plow, plough, +"plunger, plumbers helper", +Polaroid camera, Polaroid Land camera, +pole, +police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria, +poncho, +pool table, billiard table, snooker table, +pop bottle, soda bottle, +pot, flowerpot, +"potters wheel", +power drill, +prayer rug, prayer mat, +printer, +prison, prison house, +projectile, missile, +projector, +puck, hockey puck, +punching bag, punch bag, punching ball, punchball, +purse, +quill, quill pen, +quilt, comforter, comfort, puff, +racer, race car, racing car, +racket, racquet, +radiator, +radio, wireless, +radio telescope, radio reflector, +rain barrel, +recreational vehicle, RV, R.V., +reel, +reflex camera, +refrigerator, icebox, +remote control, remote, +restaurant, eating house, eating place, eatery, +revolver, six-gun, six-shooter, +rifle, +rocking chair, rocker, +rotisserie, +rubber eraser, rubber, pencil eraser, +rugby ball, +rule, ruler, +running shoe, +safe, +safety pin, +saltshaker, salt shaker, +sandal, +sarong, +sax, saxophone, +scabbard, +scale, weighing machine, +school bus, +schooner, +scoreboard, +screen, CRT screen, +screw, +screwdriver, +seat belt, seatbelt, +sewing machine, +shield, buckler, +shoe shop, shoe-shop, shoe store, +shoji, +shopping basket, +shopping cart, +shovel, +shower cap, +shower curtain, +ski, +ski mask, +sleeping bag, +slide rule, slipstick, +sliding door, +slot, one-armed bandit, +snorkel, +snowmobile, +snowplow, snowplough, +soap dispenser, +soccer ball, +sock, +solar dish, solar collector, solar furnace, +sombrero, +soup bowl, +space bar, +space heater, +space shuttle, +spatula, +speedboat, +"spider web, spiders web", +spindle, +sports car, sport car, +spotlight, spot, +stage, +steam locomotive, +steel arch bridge, +steel drum, +stethoscope, +stole, +stone wall, +stopwatch, stop watch, +stove, +strainer, +streetcar, tram, tramcar, trolley, trolley car, +stretcher, +studio couch, day bed, +stupa, tope, +submarine, pigboat, sub, U-boat, +suit, suit of clothes, +sundial, +sunglass, +sunglasses, dark glasses, shades, +sunscreen, sunblock, sun blocker, +suspension bridge, +swab, swob, mop, +sweatshirt, +swimming trunks, bathing trunks, +swing, +switch, electric switch, electrical switch, +syringe, +table lamp, +tank, army tank, armored combat vehicle, armoured combat vehicle, +tape player, +teapot, +teddy, teddy bear, +television, television system, +tennis ball, +thatch, thatched roof, +theater curtain, theatre curtain, +thimble, +thresher, thrasher, threshing machine, +throne, +tile roof, +toaster, +tobacco shop, tobacconist shop, tobacconist, +toilet seat, +torch, +totem pole, +tow truck, tow car, wrecker, +toyshop, +tractor, +trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi, +tray, +trench coat, +tricycle, trike, velocipede, +trimaran, +tripod, +triumphal arch, +trolleybus, trolley coach, trackless trolley, +trombone, +tub, vat, +turnstile, +typewriter keyboard, +umbrella, +unicycle, monocycle, +upright, upright piano, +vacuum, vacuum cleaner, +vase, +vault, +velvet, +vending machine, +vestment, +viaduct, +violin, fiddle, +volleyball, +waffle iron, +wall clock, +wallet, billfold, notecase, pocketbook, +wardrobe, closet, press, +warplane, military plane, +washbasin, handbasin, washbowl, lavabo, wash-hand basin, +washer, automatic washer, washing machine, +water bottle, +water jug, +water tower, +whiskey jug, +whistle, +wig, +window screen, +window shade, +Windsor tie, +wine bottle, +wing, +wok, +wooden spoon, +wool, woolen, woollen, +worm fence, snake fence, snake-rail fence, Virginia fence, +wreck, +yawl, +yurt, +web site, website, internet site, site, +comic book, +crossword puzzle, crossword, +street sign, +traffic light, traffic signal, stoplight, +book jacket, dust cover, dust jacket, dust wrapper, +menu, +plate, +guacamole, +consomme, +hot pot, hotpot, +trifle, +ice cream, icecream, +ice lolly, lolly, lollipop, popsicle, +French loaf, +bagel, beigel, +pretzel, +cheeseburger, +hotdog, hot dog, red hot, +mashed potato, +head cabbage, +broccoli, +cauliflower, +zucchini, courgette, +spaghetti squash, +acorn squash, +butternut squash, +cucumber, cuke, +artichoke, globe artichoke, +bell pepper, +cardoon, +mushroom, +Granny Smith, +strawberry, +orange, +lemon, +fig, +pineapple, ananas, +banana, +jackfruit, jak, jack, +custard apple, +pomegranate, +hay, +carbonara, +chocolate sauce, chocolate syrup, +dough, +meat loaf, meatloaf, +pizza, pizza pie, +potpie, +burrito, +red wine, +espresso, +cup, +eggnog, +alp, +bubble, +cliff, drop, drop-off, +coral reef, +geyser, +lakeside, lakeshore, +promontory, headland, head, foreland, +sandbar, sand bar, +seashore, coast, seacoast, sea-coast, +valley, vale, +volcano, +ballplayer, baseball player, +groom, bridegroom, +scuba diver, +rapeseed, +daisy, +"yellow ladys slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum", +corn, +acorn, +hip, rose hip, rosehip, +buckeye, horse chestnut, conker, +coral fungus, +agaric, +gyromitra, +stinkhorn, carrion fungus, +earthstar, +hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa, +bolete, +ear, spike, capitulum, +toilet tissue, toilet paper, bathroom tissue diff --git a/src/PaddleClas/deploy/paddleserving/imgs/results.png b/src/PaddleClas/deploy/paddleserving/imgs/results.png new file mode 100644 index 0000000..ad44083 Binary files /dev/null and b/src/PaddleClas/deploy/paddleserving/imgs/results.png differ diff --git a/src/PaddleClas/deploy/paddleserving/imgs/results_shitu.png b/src/PaddleClas/deploy/paddleserving/imgs/results_shitu.png new file mode 100644 index 0000000..5c09949 Binary files /dev/null and b/src/PaddleClas/deploy/paddleserving/imgs/results_shitu.png differ diff --git a/src/PaddleClas/deploy/paddleserving/imgs/start_server.png b/src/PaddleClas/deploy/paddleserving/imgs/start_server.png new file mode 100644 index 0000000..8294e19 Binary files /dev/null and b/src/PaddleClas/deploy/paddleserving/imgs/start_server.png differ diff --git a/src/PaddleClas/deploy/paddleserving/imgs/start_server_shitu.png b/src/PaddleClas/deploy/paddleserving/imgs/start_server_shitu.png new file mode 100644 index 0000000..f2709ec Binary files /dev/null and b/src/PaddleClas/deploy/paddleserving/imgs/start_server_shitu.png differ diff --git a/src/PaddleClas/deploy/paddleserving/pipeline_http_client.py b/src/PaddleClas/deploy/paddleserving/pipeline_http_client.py new file mode 100644 index 0000000..290d647 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/pipeline_http_client.py @@ -0,0 +1,20 @@ +import requests +import json +import base64 +import os + + +def cv2_to_base64(image): + return base64.b64encode(image).decode('utf8') + + +if __name__ == "__main__": + url = "http://127.0.0.1:18080/imagenet/prediction" + with open(os.path.join(".", "daisy.jpg"), 'rb') as file: + image_data1 = file.read() + image = cv2_to_base64(image_data1) + + data = {"key": ["image"], "value": [image]} + for i in range(1): + r = requests.post(url=url, data=json.dumps(data)) + print(r.json()) diff --git a/src/PaddleClas/deploy/paddleserving/pipeline_rpc_client.py b/src/PaddleClas/deploy/paddleserving/pipeline_rpc_client.py new file mode 100644 index 0000000..75bcae0 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/pipeline_rpc_client.py @@ -0,0 +1,33 @@ +# 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. +try: + from paddle_serving_server_gpu.pipeline import PipelineClient +except ImportError: + from paddle_serving_server.pipeline import PipelineClient +import base64 + +client = PipelineClient() +client.connect(['127.0.0.1:9993']) + +def cv2_to_base64(image): + return base64.b64encode(image).decode('utf8') + +if __name__ == "__main__": + with open("daisy.jpg", 'rb') as file: + image_data = file.read() + image = cv2_to_base64(image_data) + + for i in range(1): + ret = client.predict(feed_dict={"image": image}, fetch=["label", "prob"]) + print(ret) diff --git a/src/PaddleClas/deploy/paddleserving/readme.md b/src/PaddleClas/deploy/paddleserving/readme.md new file mode 100644 index 0000000..a2fdec2 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/readme.md @@ -0,0 +1 @@ +../../docs/zh_CN/inference_deployment/paddle_serving_deploy.md \ No newline at end of file diff --git a/src/PaddleClas/deploy/paddleserving/recognition/__init__.py b/src/PaddleClas/deploy/paddleserving/recognition/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/paddleserving/recognition/config.yml b/src/PaddleClas/deploy/paddleserving/recognition/config.yml new file mode 100644 index 0000000..6ecc32e --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/config.yml @@ -0,0 +1,43 @@ +#worker_num, 最大并发数。当build_dag_each_worker=True时, 框架会创建worker_num个进程,每个进程内构建grpcSever和DAG +##当build_dag_each_worker=False时,框架会设置主线程grpc线程池的max_workers=worker_num +worker_num: 1 + +#http端口, rpc_port和http_port不允许同时为空。当rpc_port可用且http_port为空时,不自动生成http_port +http_port: 18081 +rpc_port: 9994 + +dag: + #op资源类型, True, 为线程模型;False,为进程模型 + is_thread_op: False +op: + rec: + #并发数,is_thread_op=True时,为线程并发;否则为进程并发 + concurrency: 1 + + #当op配置没有server_endpoints时,从local_service_conf读取本地服务配置 + local_service_conf: + + #uci模型路径 + model_config: ../../models/general_PPLCNet_x2_5_lite_v1.0_serving + + #计算硬件类型: 空缺时由devices决定(CPU/GPU),0=cpu, 1=gpu, 2=tensorRT, 3=arm cpu, 4=kunlun xpu + device_type: 1 + + #计算硬件ID,当devices为""或不写时为CPU预测;当devices为"0", "0,1,2"时为GPU预测,表示使用的GPU卡 + devices: "0" # "0,1" + + #client类型,包括brpc, grpc和local_predictor.local_predictor不启动Serving服务,进程内预测 + client_type: local_predictor + + #Fetch结果列表,以client_config中fetch_var的alias_name为准 + fetch_list: ["features"] + + det: + concurrency: 1 + local_service_conf: + client_type: local_predictor + device_type: 1 + devices: '0' + fetch_list: + - save_infer_model/scale_0.tmp_1 + model_config: ../../models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/ diff --git a/src/PaddleClas/deploy/paddleserving/recognition/daoxiangcunjinzhubing_6.jpg b/src/PaddleClas/deploy/paddleserving/recognition/daoxiangcunjinzhubing_6.jpg new file mode 100644 index 0000000..fc64a95 Binary files /dev/null and b/src/PaddleClas/deploy/paddleserving/recognition/daoxiangcunjinzhubing_6.jpg differ diff --git a/src/PaddleClas/deploy/paddleserving/recognition/label_list.txt b/src/PaddleClas/deploy/paddleserving/recognition/label_list.txt new file mode 100644 index 0000000..35e26a6 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/label_list.txt @@ -0,0 +1,2 @@ +foreground +background \ No newline at end of file diff --git a/src/PaddleClas/deploy/paddleserving/recognition/pipeline_http_client.py b/src/PaddleClas/deploy/paddleserving/recognition/pipeline_http_client.py new file mode 100644 index 0000000..efc0f3a --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/pipeline_http_client.py @@ -0,0 +1,21 @@ +import requests +import json +import base64 +import os + +imgpath = "../../drink_dataset_v1.0/test_images/001.jpeg" + +def cv2_to_base64(image): + return base64.b64encode(image).decode('utf8') + +if __name__ == "__main__": + url = "http://127.0.0.1:18081/recognition/prediction" + + with open(os.path.join(".", imgpath), 'rb') as file: + image_data1 = file.read() + image = cv2_to_base64(image_data1) + data = {"key": ["image"], "value": [image]} + + for i in range(1): + r = requests.post(url=url, data=json.dumps(data)) + print(r.json()) diff --git a/src/PaddleClas/deploy/paddleserving/recognition/pipeline_rpc_client.py b/src/PaddleClas/deploy/paddleserving/recognition/pipeline_rpc_client.py new file mode 100644 index 0000000..50a1e42 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/pipeline_rpc_client.py @@ -0,0 +1,34 @@ +# 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. +try: + from paddle_serving_server_gpu.pipeline import PipelineClient +except ImportError: + from paddle_serving_server.pipeline import PipelineClient +import base64 + +client = PipelineClient() +client.connect(['127.0.0.1:9994']) +imgpath = "../../drink_dataset_v1.0/test_images/001.jpeg" + +def cv2_to_base64(image): + return base64.b64encode(image).decode('utf8') + +if __name__ == "__main__": + with open(imgpath, 'rb') as file: + image_data = file.read() + image = cv2_to_base64(image_data) + + for i in range(1): + ret = client.predict(feed_dict={"image": image}, fetch=["result"]) + print(ret) diff --git a/src/PaddleClas/deploy/paddleserving/recognition/recognition_web_service.py b/src/PaddleClas/deploy/paddleserving/recognition/recognition_web_service.py new file mode 100644 index 0000000..4a3478b --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/recognition_web_service.py @@ -0,0 +1,209 @@ +# 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 paddle_serving_server.web_service import WebService, Op +import logging +import numpy as np +import sys +import cv2 +from paddle_serving_app.reader import * +import base64 +import os +import faiss +import pickle +import json + + +class DetOp(Op): + def init_op(self): + self.img_preprocess = Sequential([ + BGR2RGB(), Div(255.0), + Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], False), + Resize((640, 640)), Transpose((2, 0, 1)) + ]) + + self.img_postprocess = RCNNPostprocess("label_list.txt", "output") + self.threshold = 0.2 + self.max_det_results = 5 + + def generate_scale(self, im): + """ + Args: + im (np.ndarray): image (np.ndarray) + Returns: + im_scale_x: the resize ratio of X + im_scale_y: the resize ratio of Y + """ + target_size = [640, 640] + origin_shape = im.shape[:2] + resize_h, resize_w = target_size + im_scale_y = resize_h / float(origin_shape[0]) + im_scale_x = resize_w / float(origin_shape[1]) + return im_scale_y, im_scale_x + + def preprocess(self, input_dicts, data_id, log_id): + (_, input_dict), = input_dicts.items() + imgs = [] + raw_imgs = [] + for key in input_dict.keys(): + data = base64.b64decode(input_dict[key].encode('utf8')) + raw_imgs.append(data) + data = np.fromstring(data, np.uint8) + raw_im = cv2.imdecode(data, cv2.IMREAD_COLOR) + + im_scale_y, im_scale_x = self.generate_scale(raw_im) + im = self.img_preprocess(raw_im) + + im_shape = np.array(im.shape[1:]).reshape(-1) + scale_factor = np.array([im_scale_y, im_scale_x]).reshape(-1) + imgs.append({ + "image": im[np.newaxis, :], + "im_shape": im_shape[np.newaxis, :], + "scale_factor": scale_factor[np.newaxis, :], + }) + self.raw_img = raw_imgs + + feed_dict = { + "image": np.concatenate( + [x["image"] for x in imgs], axis=0), + "im_shape": np.concatenate( + [x["im_shape"] for x in imgs], axis=0), + "scale_factor": np.concatenate( + [x["scale_factor"] for x in imgs], axis=0) + } + return feed_dict, False, None, "" + + def postprocess(self, input_dicts, fetch_dict, data_id, log_id): + boxes = self.img_postprocess(fetch_dict, visualize=False) + boxes.sort(key=lambda x: x["score"], reverse=True) + boxes = filter(lambda x: x["score"] >= self.threshold, + boxes[:self.max_det_results]) + boxes = list(boxes) + for i in range(len(boxes)): + boxes[i]["bbox"][2] += boxes[i]["bbox"][0] - 1 + boxes[i]["bbox"][3] += boxes[i]["bbox"][1] - 1 + result = json.dumps(boxes) + res_dict = {"bbox_result": result, "image": self.raw_img} + return res_dict, None, "" + + +class RecOp(Op): + def init_op(self): + self.seq = Sequential([ + BGR2RGB(), Resize((224, 224)), Div(255), + Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], + False), Transpose((2, 0, 1)) + ]) + + index_dir = "../../drink_dataset_v1.0/index" + assert os.path.exists(os.path.join( + index_dir, "vector.index")), "vector.index not found ..." + assert os.path.exists(os.path.join( + index_dir, "id_map.pkl")), "id_map.pkl not found ... " + + self.searcher = faiss.read_index( + os.path.join(index_dir, "vector.index")) + + with open(os.path.join(index_dir, "id_map.pkl"), "rb") as fd: + self.id_map = pickle.load(fd) + + self.rec_nms_thresold = 0.05 + self.rec_score_thres = 0.5 + self.feature_normalize = True + self.return_k = 1 + + def preprocess(self, input_dicts, data_id, log_id): + (_, input_dict), = input_dicts.items() + raw_img = input_dict["image"][0] + data = np.frombuffer(raw_img, np.uint8) + origin_img = cv2.imdecode(data, cv2.IMREAD_COLOR) + dt_boxes = input_dict["bbox_result"] + boxes = json.loads(dt_boxes) + boxes.append({ + "category_id": 0, + "score": 1.0, + "bbox": [0, 0, origin_img.shape[1], origin_img.shape[0]] + }) + self.det_boxes = boxes + + #construct batch images for rec + imgs = [] + for box in boxes: + box = [int(x) for x in box["bbox"]] + im = origin_img[box[1]:box[3], box[0]:box[2]].copy() + img = self.seq(im) + imgs.append(img[np.newaxis, :].copy()) + + input_imgs = np.concatenate(imgs, axis=0) + return {"x": input_imgs}, False, None, "" + + def nms_to_rec_results(self, results, thresh=0.1): + filtered_results = [] + x1 = np.array([r["bbox"][0] for r in results]).astype("float32") + y1 = np.array([r["bbox"][1] for r in results]).astype("float32") + x2 = np.array([r["bbox"][2] for r in results]).astype("float32") + y2 = np.array([r["bbox"][3] for r in results]).astype("float32") + scores = np.array([r["rec_scores"] for r in results]) + + areas = (x2 - x1 + 1) * (y2 - y1 + 1) + order = scores.argsort()[::-1] + while order.size > 0: + i = order[0] + xx1 = np.maximum(x1[i], x1[order[1:]]) + yy1 = np.maximum(y1[i], y1[order[1:]]) + xx2 = np.minimum(x2[i], x2[order[1:]]) + yy2 = np.minimum(y2[i], y2[order[1:]]) + + w = np.maximum(0.0, xx2 - xx1 + 1) + h = np.maximum(0.0, yy2 - yy1 + 1) + inter = w * h + ovr = inter / (areas[i] + areas[order[1:]] - inter) + inds = np.where(ovr <= thresh)[0] + order = order[inds + 1] + filtered_results.append(results[i]) + return filtered_results + + def postprocess(self, input_dicts, fetch_dict, data_id, log_id): + batch_features = fetch_dict["features"] + + if self.feature_normalize: + feas_norm = np.sqrt( + np.sum(np.square(batch_features), axis=1, keepdims=True)) + batch_features = np.divide(batch_features, feas_norm) + + scores, docs = self.searcher.search(batch_features, self.return_k) + + results = [] + for i in range(scores.shape[0]): + pred = {} + if scores[i][0] >= self.rec_score_thres: + pred["bbox"] = [int(x) for x in self.det_boxes[i]["bbox"]] + pred["rec_docs"] = self.id_map[docs[i][0]].split()[1] + pred["rec_scores"] = scores[i][0] + results.append(pred) + + #do nms + results = self.nms_to_rec_results(results, self.rec_nms_thresold) + return {"result": str(results)}, None, "" + + +class RecognitionService(WebService): + def get_pipeline_response(self, read_op): + det_op = DetOp(name="det", input_ops=[read_op]) + rec_op = RecOp(name="rec", input_ops=[det_op]) + return rec_op + + +product_recog_service = RecognitionService(name="recognition") +product_recog_service.prepare_pipeline_config("config.yml") +product_recog_service.run_service() diff --git a/src/PaddleClas/deploy/paddleserving/recognition/run_cpp_serving.sh b/src/PaddleClas/deploy/paddleserving/recognition/run_cpp_serving.sh new file mode 100644 index 0000000..affca99 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/run_cpp_serving.sh @@ -0,0 +1,7 @@ +nohup python3 -m paddle_serving_server.serve \ +--model ../../models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving \ + --port 9293 >>log_mainbody_detection.txt 1&>2 & + +nohup python3 -m paddle_serving_server.serve \ +--model ../../models/general_PPLCNet_x2_5_lite_v1.0_serving \ +--port 9294 >>log_feature_extraction.txt 1&>2 & diff --git a/src/PaddleClas/deploy/paddleserving/recognition/test_cpp_serving_client.py b/src/PaddleClas/deploy/paddleserving/recognition/test_cpp_serving_client.py new file mode 100644 index 0000000..a2bf1ae --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/recognition/test_cpp_serving_client.py @@ -0,0 +1,202 @@ +# 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. + +import sys +import numpy as np + +from paddle_serving_client import Client +from paddle_serving_app.reader import * +import cv2 +import faiss +import os +import pickle + + +class MainbodyDetect(): + """ + pp-shitu mainbody detect. + include preprocess, process, postprocess + return detect results + Attention: Postprocess include num limit and box filter; no nms + """ + + def __init__(self): + self.preprocess = DetectionSequential([ + DetectionFile2Image(), DetectionNormalize( + [0.485, 0.456, 0.406], [0.229, 0.224, 0.225], True), + DetectionResize( + (640, 640), False, interpolation=2), DetectionTranspose( + (2, 0, 1)) + ]) + + self.client = Client() + self.client.load_client_config( + "../../models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_client/serving_client_conf.prototxt" + ) + self.client.connect(['127.0.0.1:9293']) + + self.max_det_result = 5 + self.conf_threshold = 0.2 + + def predict(self, imgpath): + im, im_info = self.preprocess(imgpath) + im_shape = np.array(im.shape[1:]).reshape(-1) + scale_factor = np.array(list(im_info['scale_factor'])).reshape(-1) + + fetch_map = self.client.predict( + feed={ + "image": im, + "im_shape": im_shape, + "scale_factor": scale_factor, + }, + fetch=["save_infer_model/scale_0.tmp_1"], + batch=False) + return self.postprocess(fetch_map, imgpath) + + def postprocess(self, fetch_map, imgpath): + #1. get top max_det_result + det_results = fetch_map["save_infer_model/scale_0.tmp_1"] + if len(det_results) > self.max_det_result: + boxes_reserved = fetch_map[ + "save_infer_model/scale_0.tmp_1"][:self.max_det_result] + else: + boxes_reserved = det_results + + #2. do conf threshold + boxes_list = [] + for i in range(boxes_reserved.shape[0]): + if (boxes_reserved[i, 1]) > self.conf_threshold: + boxes_list.append(boxes_reserved[i, :]) + + #3. add origin image box + origin_img = cv2.imread(imgpath) + boxes_list.append( + np.array([0, 1.0, 0, 0, origin_img.shape[1], origin_img.shape[0]])) + return np.array(boxes_list) + + +class ObjectRecognition(): + """ + pp-shitu object recognion for all objects detected by MainbodyDetect. + include preprocess, process, postprocess + preprocess include preprocess for each image and batching. + Batch process + postprocess include retrieval and nms + """ + + def __init__(self): + self.client = Client() + self.client.load_client_config( + "../../models/general_PPLCNet_x2_5_lite_v1.0_client/serving_client_conf.prototxt" + ) + self.client.connect(["127.0.0.1:9294"]) + + self.seq = Sequential([ + BGR2RGB(), Resize((224, 224)), Div(255), + Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], + False), Transpose((2, 0, 1)) + ]) + + self.searcher, self.id_map = self.init_index() + + self.rec_nms_thresold = 0.05 + self.rec_score_thres = 0.5 + self.feature_normalize = True + self.return_k = 1 + + def init_index(self): + index_dir = "../../drink_dataset_v1.0/index" + assert os.path.exists(os.path.join( + index_dir, "vector.index")), "vector.index not found ..." + assert os.path.exists(os.path.join( + index_dir, "id_map.pkl")), "id_map.pkl not found ... " + + searcher = faiss.read_index(os.path.join(index_dir, "vector.index")) + + with open(os.path.join(index_dir, "id_map.pkl"), "rb") as fd: + id_map = pickle.load(fd) + return searcher, id_map + + def predict(self, det_boxes, imgpath): + #1. preprocess + batch_imgs = [] + origin_img = cv2.imread(imgpath) + for i in range(det_boxes.shape[0]): + box = det_boxes[i] + x1, y1, x2, y2 = [int(x) for x in box[2:]] + cropped_img = origin_img[y1:y2, x1:x2, :].copy() + tmp = self.seq(cropped_img) + batch_imgs.append(tmp) + batch_imgs = np.array(batch_imgs) + + #2. process + fetch_map = self.client.predict( + feed={"x": batch_imgs}, fetch=["features"], batch=True) + batch_features = fetch_map["features"] + + #3. postprocess + if self.feature_normalize: + feas_norm = np.sqrt( + np.sum(np.square(batch_features), axis=1, keepdims=True)) + batch_features = np.divide(batch_features, feas_norm) + scores, docs = self.searcher.search(batch_features, self.return_k) + + results = [] + for i in range(scores.shape[0]): + pred = {} + if scores[i][0] >= self.rec_score_thres: + pred["bbox"] = [int(x) for x in det_boxes[i, 2:]] + pred["rec_docs"] = self.id_map[docs[i][0]].split()[1] + pred["rec_scores"] = scores[i][0] + results.append(pred) + return self.nms_to_rec_results(results) + + def nms_to_rec_results(self, results): + filtered_results = [] + x1 = np.array([r["bbox"][0] for r in results]).astype("float32") + y1 = np.array([r["bbox"][1] for r in results]).astype("float32") + x2 = np.array([r["bbox"][2] for r in results]).astype("float32") + y2 = np.array([r["bbox"][3] for r in results]).astype("float32") + scores = np.array([r["rec_scores"] for r in results]) + + areas = (x2 - x1 + 1) * (y2 - y1 + 1) + order = scores.argsort()[::-1] + while order.size > 0: + i = order[0] + xx1 = np.maximum(x1[i], x1[order[1:]]) + yy1 = np.maximum(y1[i], y1[order[1:]]) + xx2 = np.minimum(x2[i], x2[order[1:]]) + yy2 = np.minimum(y2[i], y2[order[1:]]) + + w = np.maximum(0.0, xx2 - xx1 + 1) + h = np.maximum(0.0, yy2 - yy1 + 1) + inter = w * h + ovr = inter / (areas[i] + areas[order[1:]] - inter) + inds = np.where(ovr <= self.rec_nms_thresold)[0] + order = order[inds + 1] + filtered_results.append(results[i]) + return filtered_results + + +if __name__ == "__main__": + det = MainbodyDetect() + rec = ObjectRecognition() + + #1. get det_results + imgpath = "../../drink_dataset_v1.0/test_images/001.jpeg" + det_results = det.predict(imgpath) + + #2. get rec_results + rec_results = rec.predict(det_results, imgpath) + print(rec_results) diff --git a/src/PaddleClas/deploy/paddleserving/run_cpp_serving.sh b/src/PaddleClas/deploy/paddleserving/run_cpp_serving.sh new file mode 100644 index 0000000..05794b7 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/run_cpp_serving.sh @@ -0,0 +1,2 @@ +#run cls server: +nohup python3 -m paddle_serving_server.serve --model ResNet50_vd_serving --port 9292 & diff --git a/src/PaddleClas/deploy/paddleserving/test_cpp_serving_client.py b/src/PaddleClas/deploy/paddleserving/test_cpp_serving_client.py new file mode 100644 index 0000000..50794b3 --- /dev/null +++ b/src/PaddleClas/deploy/paddleserving/test_cpp_serving_client.py @@ -0,0 +1,52 @@ +# 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. + +import sys +from paddle_serving_client import Client + +#app +from paddle_serving_app.reader import Sequential, URL2Image, Resize +from paddle_serving_app.reader import CenterCrop, RGB2BGR, Transpose, Div, Normalize +import time + +client = Client() +client.load_client_config("./ResNet50_vd_serving/serving_server_conf.prototxt") +client.connect(["127.0.0.1:9292"]) + +label_dict = {} +label_idx = 0 +with open("imagenet.label") as fin: + for line in fin: + label_dict[label_idx] = line.strip() + label_idx += 1 + +#preprocess +seq = Sequential([ + URL2Image(), Resize(256), CenterCrop(224), RGB2BGR(), Transpose((2, 0, 1)), + Div(255), Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], True) +]) + +start = time.time() +image_file = "https://paddle-serving.bj.bcebos.com/imagenet-example/daisy.jpg" +for i in range(1): + img = seq(image_file) + fetch_map = client.predict( + feed={"inputs": img}, fetch=["prediction"], batch=False) + + prob = max(fetch_map["prediction"][0]) + label = label_dict[fetch_map["prediction"][0].tolist().index(prob)].strip( + ).replace(",", "") + print("prediction: {}, probability: {}".format(label, prob)) +end = time.time() +print(end - start) diff --git a/src/PaddleClas/deploy/python/.idea/.gitignore b/src/PaddleClas/deploy/python/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/src/PaddleClas/deploy/python/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/src/PaddleClas/deploy/python/.idea/inspectionProfiles/profiles_settings.xml b/src/PaddleClas/deploy/python/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/src/PaddleClas/deploy/python/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/python/.idea/misc.xml b/src/PaddleClas/deploy/python/.idea/misc.xml new file mode 100644 index 0000000..e2aaded --- /dev/null +++ b/src/PaddleClas/deploy/python/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/python/.idea/modules.xml b/src/PaddleClas/deploy/python/.idea/modules.xml new file mode 100644 index 0000000..614b3c1 --- /dev/null +++ b/src/PaddleClas/deploy/python/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/python/.idea/python.iml b/src/PaddleClas/deploy/python/.idea/python.iml new file mode 100644 index 0000000..db04eee --- /dev/null +++ b/src/PaddleClas/deploy/python/.idea/python.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/PaddleClas/deploy/python/__init__.py b/src/PaddleClas/deploy/python/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/deploy/python/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/deploy/python/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..e55c2a9 Binary files /dev/null and b/src/PaddleClas/deploy/python/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/python/__pycache__/det_preprocess.cpython-39.pyc b/src/PaddleClas/deploy/python/__pycache__/det_preprocess.cpython-39.pyc new file mode 100644 index 0000000..89f6758 Binary files /dev/null and b/src/PaddleClas/deploy/python/__pycache__/det_preprocess.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/python/__pycache__/postprocess.cpython-39.pyc b/src/PaddleClas/deploy/python/__pycache__/postprocess.cpython-39.pyc new file mode 100644 index 0000000..a1bf4f1 Binary files /dev/null and b/src/PaddleClas/deploy/python/__pycache__/postprocess.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/python/__pycache__/predict_det.cpython-39.pyc b/src/PaddleClas/deploy/python/__pycache__/predict_det.cpython-39.pyc new file mode 100644 index 0000000..18ad706 Binary files /dev/null and b/src/PaddleClas/deploy/python/__pycache__/predict_det.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/python/__pycache__/predict_rec.cpython-39.pyc b/src/PaddleClas/deploy/python/__pycache__/predict_rec.cpython-39.pyc new file mode 100644 index 0000000..1bbf0c9 Binary files /dev/null and b/src/PaddleClas/deploy/python/__pycache__/predict_rec.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/python/__pycache__/preprocess.cpython-39.pyc b/src/PaddleClas/deploy/python/__pycache__/preprocess.cpython-39.pyc new file mode 100644 index 0000000..16e5e7a Binary files /dev/null and b/src/PaddleClas/deploy/python/__pycache__/preprocess.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/python/build_gallery.py b/src/PaddleClas/deploy/python/build_gallery.py new file mode 100644 index 0000000..7b69a04 --- /dev/null +++ b/src/PaddleClas/deploy/python/build_gallery.py @@ -0,0 +1,214 @@ +# Copyright (c) 2021 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. +import os +import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +import cv2 +import faiss +import numpy as np +from tqdm import tqdm +import pickle + +from python.predict_rec import RecPredictor + +from utils import logger +from utils import config + + +def split_datafile(data_file, image_root, delimiter="\t"): + ''' + data_file: image path and info, which can be splitted by spacer + image_root: image path root + delimiter: delimiter + ''' + gallery_images = [] + gallery_docs = [] + with open(data_file, 'r', encoding='utf-8') as f: + lines = f.readlines() + for _, ori_line in enumerate(lines): + line = ori_line.strip().split(delimiter) + text_num = len(line) + assert text_num >= 2, f"line({ori_line}) must be splitted into at least 2 parts, but got {text_num}" + image_file = os.path.join(image_root, line[0]) + + gallery_images.append(image_file) + gallery_docs.append(ori_line.strip()) + + return gallery_images, gallery_docs + + +class GalleryBuilder(object): + def __init__(self, config): + + self.config = config + self.rec_predictor = RecPredictor(config) + assert 'IndexProcess' in config.keys(), "Index config not found ... " + self.build(config['IndexProcess']) + + def build(self, config): + ''' + build index from scratch + ''' + operation_method = config.get("index_operation", "new").lower() + + gallery_images, gallery_docs = split_datafile( + config['data_file'], config['image_root'], config['delimiter']) + + # when remove data in index, do not need extract fatures + if operation_method != "remove": + gallery_features = self._extract_features(gallery_images, config) + assert operation_method in [ + "new", "remove", "append" + ], "Only append, remove and new operation are supported" + + # vector.index: faiss index file + # id_map.pkl: use this file to map id to image_doc + if operation_method in ["remove", "append"]: + # if remove or append, vector.index and id_map.pkl must exist + assert os.path.join( + config["index_dir"], "vector.index" + ), "The vector.index dose not exist in {} when 'index_operation' is not None".format( + config["index_dir"]) + assert os.path.join( + config["index_dir"], "id_map.pkl" + ), "The id_map.pkl dose not exist in {} when 'index_operation' is not None".format( + config["index_dir"]) + index = faiss.read_index( + os.path.join(config["index_dir"], "vector.index")) + with open(os.path.join(config["index_dir"], "id_map.pkl"), + 'rb') as fd: + ids = pickle.load(fd) + assert index.ntotal == len(ids.keys( + )), "data number in index is not equal in in id_map" + else: + if not os.path.exists(config["index_dir"]): + os.makedirs(config["index_dir"], exist_ok=True) + index_method = config.get("index_method", "HNSW32") + + # if IVF method, cal ivf number automaticlly + if index_method == "IVF": + index_method = index_method + str( + min(int(len(gallery_images) // 8), 65536)) + ",Flat" + + # for binary index, add B at head of index_method + if config["dist_type"] == "hamming": + index_method = "B" + index_method + + #dist_type + dist_type = faiss.METRIC_INNER_PRODUCT if config[ + "dist_type"] == "IP" else faiss.METRIC_L2 + + #build index + if config["dist_type"] == "hamming": + index = faiss.index_binary_factory(config["embedding_size"], + index_method) + else: + index = faiss.index_factory(config["embedding_size"], + index_method, dist_type) + index = faiss.IndexIDMap2(index) + ids = {} + + if config["index_method"] == "HNSW32": + logger.warning( + "The HNSW32 method dose not support 'remove' operation") + + if operation_method != "remove": + # calculate id for new data + start_id = max(ids.keys()) + 1 if ids else 0 + ids_now = ( + np.arange(0, len(gallery_images)) + start_id).astype(np.int64) + + # only train when new index file + if operation_method == "new": + if config["dist_type"] == "hamming": + index.add(gallery_features) + else: + index.train(gallery_features) + + if not config["dist_type"] == "hamming": + index.add_with_ids(gallery_features, ids_now) + + for i, d in zip(list(ids_now), gallery_docs): + ids[i] = d + else: + if config["index_method"] == "HNSW32": + raise RuntimeError( + "The index_method: HNSW32 dose not support 'remove' operation" + ) + # remove ids in id_map, remove index data in faiss index + remove_ids = list( + filter(lambda k: ids.get(k) in gallery_docs, ids.keys())) + remove_ids = np.asarray(remove_ids) + index.remove_ids(remove_ids) + for k in remove_ids: + del ids[k] + + # store faiss index file and id_map file + if config["dist_type"] == "hamming": + faiss.write_index_binary( + index, os.path.join(config["index_dir"], "vector.index")) + else: + faiss.write_index( + index, os.path.join(config["index_dir"], "vector.index")) + + with open(os.path.join(config["index_dir"], "id_map.pkl"), 'wb') as fd: + pickle.dump(ids, fd) + + def _extract_features(self, gallery_images, config): + # extract gallery features + if config["dist_type"] == "hamming": + gallery_features = np.zeros( + [len(gallery_images), config['embedding_size'] // 8], + dtype=np.uint8) + else: + gallery_features = np.zeros( + [len(gallery_images), config['embedding_size']], + dtype=np.float32) + + #construct batch imgs and do inference + batch_size = config.get("batch_size", 32) + batch_img = [] + for i, image_file in enumerate(tqdm(gallery_images)): + img = cv2.imread(image_file) + if img is None: + logger.error("img empty, please check {}".format(image_file)) + exit() + img = img[:, :, ::-1] + batch_img.append(img) + + if (i + 1) % batch_size == 0: + rec_feat = self.rec_predictor.predict(batch_img) + gallery_features[i - batch_size + 1:i + 1, :] = rec_feat + batch_img = [] + + if len(batch_img) > 0: + rec_feat = self.rec_predictor.predict(batch_img) + gallery_features[-len(batch_img):, :] = rec_feat + batch_img = [] + + return gallery_features + + +def main(config): + GalleryBuilder(config) + return + + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config(args.config, overrides=args.override, show=True) + main(config) diff --git a/src/PaddleClas/deploy/python/det_preprocess.py b/src/PaddleClas/deploy/python/det_preprocess.py new file mode 100644 index 0000000..5f5760e --- /dev/null +++ b/src/PaddleClas/deploy/python/det_preprocess.py @@ -0,0 +1,205 @@ +# 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. + +import cv2 +import numpy as np + + +def decode_image(im_file, im_info): + """read rgb image + Args: + im_file (str|np.ndarray): input can be image path or np.ndarray + im_info (dict): info of image + Returns: + im (np.ndarray): processed image (np.ndarray) + im_info (dict): info of processed image + """ + if isinstance(im_file, str): + with open(im_file, 'rb') as f: + im_read = f.read() + data = np.frombuffer(im_read, dtype='uint8') + im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode + im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB) + else: + im = im_file + im_info['im_shape'] = np.array(im.shape[:2], dtype=np.float32) + im_info['scale_factor'] = np.array([1., 1.], dtype=np.float32) + return im, im_info + + +class DetResize(object): + """resize image by target_size and max_size + Args: + target_size (int): the target size of image + keep_ratio (bool): whether keep_ratio or not, default true + interp (int): method of resize + """ + + def __init__( + self, + target_size, + keep_ratio=True, + interp=cv2.INTER_LINEAR, ): + if isinstance(target_size, int): + target_size = [target_size, target_size] + self.target_size = target_size + self.keep_ratio = keep_ratio + self.interp = interp + + def __call__(self, im, im_info): + """ + Args: + im (np.ndarray): image (np.ndarray) + im_info (dict): info of image + Returns: + im (np.ndarray): processed image (np.ndarray) + im_info (dict): info of processed image + """ + assert len(self.target_size) == 2 + assert self.target_size[0] > 0 and self.target_size[1] > 0 + im_channel = im.shape[2] + im_scale_y, im_scale_x = self.generate_scale(im) + # set image_shape + im_info['input_shape'][1] = int(im_scale_y * im.shape[0]) + im_info['input_shape'][2] = int(im_scale_x * im.shape[1]) + im = cv2.resize( + im, + None, + None, + fx=im_scale_x, + fy=im_scale_y, + interpolation=self.interp) + im_info['im_shape'] = np.array(im.shape[:2]).astype('float32') + im_info['scale_factor'] = np.array( + [im_scale_y, im_scale_x]).astype('float32') + return im, im_info + + def generate_scale(self, im): + """ + Args: + im (np.ndarray): image (np.ndarray) + Returns: + im_scale_x: the resize ratio of X + im_scale_y: the resize ratio of Y + """ + origin_shape = im.shape[:2] + im_c = im.shape[2] + if self.keep_ratio: + im_size_min = np.min(origin_shape) + im_size_max = np.max(origin_shape) + target_size_min = np.min(self.target_size) + target_size_max = np.max(self.target_size) + im_scale = float(target_size_min) / float(im_size_min) + if np.round(im_scale * im_size_max) > target_size_max: + im_scale = float(target_size_max) / float(im_size_max) + im_scale_x = im_scale + im_scale_y = im_scale + else: + resize_h, resize_w = self.target_size + im_scale_y = resize_h / float(origin_shape[0]) + im_scale_x = resize_w / float(origin_shape[1]) + return im_scale_y, im_scale_x + + +class DetNormalizeImage(object): + """normalize image + Args: + mean (list): im - mean + std (list): im / std + is_scale (bool): whether need im / 255 + is_channel_first (bool): if True: image shape is CHW, else: HWC + """ + + def __init__(self, mean, std, is_scale=True): + self.mean = mean + self.std = std + self.is_scale = is_scale + + def __call__(self, im, im_info): + """ + Args: + im (np.ndarray): image (np.ndarray) + im_info (dict): info of image + Returns: + im (np.ndarray): processed image (np.ndarray) + im_info (dict): info of processed image + """ + im = im.astype(np.float32, copy=False) + mean = np.array(self.mean)[np.newaxis, np.newaxis, :] + std = np.array(self.std)[np.newaxis, np.newaxis, :] + + if self.is_scale: + im = im / 255.0 + + im -= mean + im /= std + return im, im_info + + +class DetPermute(object): + """permute image + Args: + to_bgr (bool): whether convert RGB to BGR + channel_first (bool): whether convert HWC to CHW + """ + + def __init__(self, ): + super().__init__() + + def __call__(self, im, im_info): + """ + Args: + im (np.ndarray): image (np.ndarray) + im_info (dict): info of image + Returns: + im (np.ndarray): processed image (np.ndarray) + im_info (dict): info of processed image + """ + im = im.transpose((2, 0, 1)).copy() + return im, im_info + + +class DetPadStride(object): + """ padding image for model with FPN , instead PadBatch(pad_to_stride, pad_gt) in original config + Args: + stride (bool): model with FPN need image shape % stride == 0 + """ + + def __init__(self, stride=0): + self.coarsest_stride = stride + + def __call__(self, im, im_info): + """ + Args: + im (np.ndarray): image (np.ndarray) + im_info (dict): info of image + Returns: + im (np.ndarray): processed image (np.ndarray) + im_info (dict): info of processed image + """ + coarsest_stride = self.coarsest_stride + if coarsest_stride <= 0: + return im, im_info + im_c, im_h, im_w = im.shape + pad_h = int(np.ceil(float(im_h) / coarsest_stride) * coarsest_stride) + pad_w = int(np.ceil(float(im_w) / coarsest_stride) * coarsest_stride) + padding_im = np.zeros((im_c, pad_h, pad_w), dtype=np.float32) + padding_im[:, :im_h, :im_w] = im + return padding_im, im_info + + +def det_preprocess(im, im_info, preprocess_ops): + for operator in preprocess_ops: + im, im_info = operator(im, im_info) + return im, im_info diff --git a/src/PaddleClas/deploy/python/postprocess.py b/src/PaddleClas/deploy/python/postprocess.py new file mode 100644 index 0000000..d26cbaa --- /dev/null +++ b/src/PaddleClas/deploy/python/postprocess.py @@ -0,0 +1,161 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import os +import copy +import shutil +from functools import partial +import importlib +import numpy as np +import paddle +import paddle.nn.functional as F + + +def build_postprocess(config): + if config is None: + return None + + mod = importlib.import_module(__name__) + config = copy.deepcopy(config) + + main_indicator = config.pop( + "main_indicator") if "main_indicator" in config else None + main_indicator = main_indicator if main_indicator else "" + + func_list = [] + for func in config: + func_list.append(getattr(mod, func)(**config[func])) + return PostProcesser(func_list, main_indicator) + + +class PostProcesser(object): + def __init__(self, func_list, main_indicator="Topk"): + self.func_list = func_list + self.main_indicator = main_indicator + + def __call__(self, x, image_file=None): + rtn = None + for func in self.func_list: + tmp = func(x, image_file) + if type(func).__name__ in self.main_indicator: + rtn = tmp + return rtn + + +class Topk(object): + def __init__(self, topk=1, class_id_map_file=None): + assert isinstance(topk, (int, )) + self.class_id_map = self.parse_class_id_map(class_id_map_file) + self.topk = topk + + def parse_class_id_map(self, class_id_map_file): + if class_id_map_file is None: + return None + + if not os.path.exists(class_id_map_file): + print( + "Warning: If want to use your own label_dict, please input legal path!\nOtherwise label_names will be empty!" + ) + return None + + try: + class_id_map = {} + with open(class_id_map_file, "r") as fin: + lines = fin.readlines() + for line in lines: + partition = line.split("\n")[0].partition(" ") + class_id_map[int(partition[0])] = str(partition[-1]) + except Exception as ex: + print(ex) + class_id_map = None + return class_id_map + + def __call__(self, x, file_names=None, multilabel=False): + if file_names is not None: + assert x.shape[0] == len(file_names) + y = [] + for idx, probs in enumerate(x): + index = probs.argsort(axis=0)[-self.topk:][::-1].astype( + "int32") if not multilabel else np.where( + probs >= 0.5)[0].astype("int32") + clas_id_list = [] + score_list = [] + label_name_list = [] + for i in index: + clas_id_list.append(i.item()) + score_list.append(probs[i].item()) + if self.class_id_map is not None: + label_name_list.append(self.class_id_map[i.item()]) + result = { + "class_ids": clas_id_list, + "scores": np.around( + score_list, decimals=5).tolist(), + } + if file_names is not None: + result["file_name"] = file_names[idx] + if label_name_list is not None: + result["label_names"] = label_name_list + y.append(result) + return y + + +class MultiLabelTopk(Topk): + def __init__(self, topk=1, class_id_map_file=None): + super().__init__() + + def __call__(self, x, file_names=None): + return super().__call__(x, file_names, multilabel=True) + + +class SavePreLabel(object): + def __init__(self, save_dir): + if save_dir is None: + raise Exception( + "Please specify save_dir if SavePreLabel specified.") + self.save_dir = partial(os.path.join, save_dir) + + def __call__(self, x, file_names=None): + if file_names is None: + return + assert x.shape[0] == len(file_names) + for idx, probs in enumerate(x): + index = probs.argsort(axis=0)[-1].astype("int32") + self.save(index, file_names[idx]) + + def save(self, id, image_file): + output_dir = self.save_dir(str(id)) + os.makedirs(output_dir, exist_ok=True) + shutil.copy(image_file, output_dir) + + +class Binarize(object): + def __init__(self, method="round"): + self.method = method + self.unit = np.array([[128, 64, 32, 16, 8, 4, 2, 1]]).T + + def __call__(self, x, file_names=None): + if self.method == "round": + x = np.round(x + 1).astype("uint8") - 1 + + if self.method == "sign": + x = ((np.sign(x) + 1) / 2).astype("uint8") + + embedding_size = x.shape[1] + assert embedding_size % 8 == 0, "The Binary index only support vectors with sizes multiple of 8" + + byte = np.zeros([x.shape[0], embedding_size // 8], dtype=np.uint8) + for i in range(embedding_size // 8): + byte[:, i:i + 1] = np.dot(x[:, i * 8:(i + 1) * 8], self.unit) + + return byte diff --git a/src/PaddleClas/deploy/python/predict_cls.py b/src/PaddleClas/deploy/python/predict_cls.py new file mode 100644 index 0000000..574caa3 --- /dev/null +++ b/src/PaddleClas/deploy/python/predict_cls.py @@ -0,0 +1,153 @@ +# 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. +import os +import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +import cv2 +import numpy as np + +from utils import logger +from utils import config +from utils.predictor import Predictor +from utils.get_image_list import get_image_list +from python.preprocess import create_operators +from python.postprocess import build_postprocess + + +class ClsPredictor(Predictor): + def __init__(self, config): + super().__init__(config["Global"]) + + self.preprocess_ops = [] + self.postprocess = None + if "PreProcess" in config: + if "transform_ops" in config["PreProcess"]: + self.preprocess_ops = create_operators(config["PreProcess"][ + "transform_ops"]) + if "PostProcess" in config: + self.postprocess = build_postprocess(config["PostProcess"]) + + # for whole_chain project to test each repo of paddle + self.benchmark = config["Global"].get("benchmark", False) + if self.benchmark: + import auto_log + import os + pid = os.getpid() + size = config["PreProcess"]["transform_ops"][1]["CropImage"][ + "size"] + self.auto_logger = auto_log.AutoLogger( + model_name=config["Global"].get("model_name", "cls"), + model_precision='fp16' + if config["Global"]["use_fp16"] else 'fp32', + batch_size=config["Global"].get("batch_size", 1), + data_shape=[3, size, size], + save_path=config["Global"].get("save_log_path", + "./auto_log.log"), + inference_config=self.config, + pids=pid, + process_name=None, + gpu_ids=None, + time_keys=[ + 'preprocess_time', 'inference_time', 'postprocess_time' + ], + warmup=2) + + def predict(self, images): + use_onnx = self.args.get("use_onnx", False) + if not use_onnx: + input_names = self.predictor.get_input_names() + input_tensor = self.predictor.get_input_handle(input_names[0]) + + output_names = self.predictor.get_output_names() + output_tensor = self.predictor.get_output_handle(output_names[0]) + else: + input_names = self.predictor.get_inputs()[0].name + output_names = self.predictor.get_outputs()[0].name + + if self.benchmark: + self.auto_logger.times.start() + if not isinstance(images, (list, )): + images = [images] + for idx in range(len(images)): + for ops in self.preprocess_ops: + images[idx] = ops(images[idx]) + image = np.array(images) + if self.benchmark: + self.auto_logger.times.stamp() + + if not use_onnx: + input_tensor.copy_from_cpu(image) + self.predictor.run() + batch_output = output_tensor.copy_to_cpu() + else: + batch_output = self.predictor.run( + output_names=[output_names], + input_feed={input_names: image})[0] + + if self.benchmark: + self.auto_logger.times.stamp() + if self.postprocess is not None: + batch_output = self.postprocess(batch_output) + if self.benchmark: + self.auto_logger.times.end(stamp=True) + return batch_output + + +def main(config): + cls_predictor = ClsPredictor(config) + image_list = get_image_list(config["Global"]["infer_imgs"]) + + batch_imgs = [] + batch_names = [] + cnt = 0 + for idx, img_path in enumerate(image_list): + img = cv2.imread(img_path) + if img is None: + logger.warning( + "Image file failed to read and has been skipped. The path: {}". + format(img_path)) + else: + img = img[:, :, ::-1] + batch_imgs.append(img) + img_name = os.path.basename(img_path) + batch_names.append(img_name) + cnt += 1 + + if cnt % config["Global"]["batch_size"] == 0 or (idx + 1 + ) == len(image_list): + if len(batch_imgs) == 0: + continue + batch_results = cls_predictor.predict(batch_imgs) + for number, result_dict in enumerate(batch_results): + filename = batch_names[number] + clas_ids = result_dict["class_ids"] + scores_str = "[{}]".format(", ".join("{:.2f}".format( + r) for r in result_dict["scores"])) + label_names = result_dict["label_names"] + print("{}:\tclass id(s): {}, score(s): {}, label_name(s): {}". + format(filename, clas_ids, scores_str, label_names)) + batch_imgs = [] + batch_names = [] + if cls_predictor.benchmark: + cls_predictor.auto_logger.report() + return + + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config(args.config, overrides=args.override, show=True) + main(config) diff --git a/src/PaddleClas/deploy/python/predict_det.py b/src/PaddleClas/deploy/python/predict_det.py new file mode 100644 index 0000000..e4e0a24 --- /dev/null +++ b/src/PaddleClas/deploy/python/predict_det.py @@ -0,0 +1,157 @@ +# 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. +import os +import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +from utils import logger +from utils import config +from utils.predictor import Predictor +from utils.get_image_list import get_image_list +from det_preprocess import det_preprocess +from preprocess import create_operators + +import os +import argparse +import time +import yaml +import ast +from functools import reduce +import cv2 +import numpy as np +import paddle + + +class DetPredictor(Predictor): + def __init__(self, config): + super().__init__(config["Global"], + config["Global"]["det_inference_model_dir"]) + + self.preprocess_ops = create_operators(config["DetPreProcess"][ + "transform_ops"]) + self.config = config + + def preprocess(self, img): + im_info = { + 'scale_factor': np.array( + [1., 1.], dtype=np.float32), + 'im_shape': np.array( + img.shape[:2], dtype=np.float32), + 'input_shape': self.config["Global"]["image_shape"], + "scale_factor": np.array( + [1., 1.], dtype=np.float32) + } + im, im_info = det_preprocess(img, im_info, self.preprocess_ops) + inputs = self.create_inputs(im, im_info) + return inputs + + def create_inputs(self, im, im_info): + """generate input for different model type + Args: + im (np.ndarray): image (np.ndarray) + im_info (dict): info of image + model_arch (str): model type + Returns: + inputs (dict): input of model + """ + inputs = {} + inputs['image'] = np.array((im, )).astype('float32') + inputs['im_shape'] = np.array( + (im_info['im_shape'], )).astype('float32') + inputs['scale_factor'] = np.array( + (im_info['scale_factor'], )).astype('float32') + + return inputs + + def parse_det_results(self, pred, threshold, label_list): + max_det_results = self.config["Global"]["max_det_results"] + keep_indexes = pred[:, 1].argsort()[::-1][:max_det_results] + results = [] + for idx in keep_indexes: + single_res = pred[idx] + class_id = int(single_res[0]) + score = single_res[1] + bbox = single_res[2:] + if score < threshold: + continue + label_name = label_list[class_id] + results.append({ + "class_id": class_id, + "score": score, + "bbox": bbox, + "label_name": label_name, + }) + return results + + def predict(self, image, threshold=0.5, run_benchmark=False): + ''' + Args: + image (str/np.ndarray): path of image/ np.ndarray read by cv2 + threshold (float): threshold of predicted box' score + Returns: + results (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box, + matix element:[class, score, x_min, y_min, x_max, y_max] + MaskRCNN's results include 'masks': np.ndarray: + shape: [N, im_h, im_w] + ''' + inputs = self.preprocess(image) + np_boxes = None + input_names = self.predictor.get_input_names() + + for i in range(len(input_names)): + input_tensor = self.predictor.get_input_handle(input_names[i]) + input_tensor.copy_from_cpu(inputs[input_names[i]]) + + t1 = time.time() + self.predictor.run() + output_names = self.predictor.get_output_names() + boxes_tensor = self.predictor.get_output_handle(output_names[0]) + np_boxes = boxes_tensor.copy_to_cpu() + t2 = time.time() + + print("Inference: {} ms per batch image".format((t2 - t1) * 1000.0)) + + # do not perform postprocess in benchmark mode + results = [] + if reduce(lambda x, y: x * y, np_boxes.shape) < 6: + print('[WARNNING] No object detected.') + results = np.array([]) + else: + results = np_boxes + + results = self.parse_det_results(results, + self.config["Global"]["threshold"], + self.config["Global"]["labe_list"]) + return results + + +def main(config): + det_predictor = DetPredictor(config) + image_list = get_image_list(config["Global"]["infer_imgs"]) + + assert config["Global"]["batch_size"] == 1 + for idx, image_file in enumerate(image_list): + img = cv2.imread(image_file)[:, :, ::-1] + output = det_predictor.predict(img) + print(output) + + return + + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config(args.config, overrides=args.override, show=True) + main(config) diff --git a/src/PaddleClas/deploy/python/predict_rec.py b/src/PaddleClas/deploy/python/predict_rec.py new file mode 100644 index 0000000..e243358 --- /dev/null +++ b/src/PaddleClas/deploy/python/predict_rec.py @@ -0,0 +1,148 @@ +# 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. +import os +import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +import cv2 +import numpy as np + +from utils import logger +from utils import config +from utils.predictor import Predictor +from utils.get_image_list import get_image_list +from preprocess import create_operators +from postprocess import build_postprocess + + +class RecPredictor(Predictor): + def __init__(self, config): + super().__init__(config["Global"], + config["Global"]["rec_inference_model_dir"]) + self.preprocess_ops = create_operators(config["RecPreProcess"][ + "transform_ops"]) + self.postprocess = build_postprocess(config["RecPostProcess"]) + self.benchmark = config["Global"].get("benchmark", False) + + if self.benchmark: + import auto_log + pid = os.getpid() + self.auto_logger = auto_log.AutoLogger( + model_name=config["Global"].get("model_name", "rec"), + model_precision='fp16' + if config["Global"]["use_fp16"] else 'fp32', + batch_size=config["Global"].get("batch_size", 1), + data_shape=[3, 224, 224], + save_path=config["Global"].get("save_log_path", + "./auto_log.log"), + inference_config=self.config, + pids=pid, + process_name=None, + gpu_ids=None, + time_keys=[ + 'preprocess_time', 'inference_time', 'postprocess_time' + ], + warmup=2) + + def predict(self, images, feature_normalize=True): + use_onnx = self.args.get("use_onnx", False) + if not use_onnx: + input_names = self.predictor.get_input_names() + input_tensor = self.predictor.get_input_handle(input_names[0]) + + output_names = self.predictor.get_output_names() + output_tensor = self.predictor.get_output_handle(output_names[0]) + else: + input_names = self.predictor.get_inputs()[0].name + output_names = self.predictor.get_outputs()[0].name + + if self.benchmark: + self.auto_logger.times.start() + if not isinstance(images, (list, )): + images = [images] + for idx in range(len(images)): + for ops in self.preprocess_ops: + images[idx] = ops(images[idx]) + image = np.array(images) + if self.benchmark: + self.auto_logger.times.stamp() + + if not use_onnx: + input_tensor.copy_from_cpu(image) + self.predictor.run() + batch_output = output_tensor.copy_to_cpu() + else: + batch_output = self.predictor.run( + output_names=[output_names], + input_feed={input_names: image})[0] + + if self.benchmark: + self.auto_logger.times.stamp() + + if feature_normalize: + feas_norm = np.sqrt( + np.sum(np.square(batch_output), axis=1, keepdims=True)) + batch_output = np.divide(batch_output, feas_norm) + + if self.postprocess is not None: + batch_output = self.postprocess(batch_output) + + if self.benchmark: + self.auto_logger.times.end(stamp=True) + return batch_output + + +def main(config): + rec_predictor = RecPredictor(config) + image_list = get_image_list(config["Global"]["infer_imgs"]) + + batch_imgs = [] + batch_names = [] + cnt = 0 + for idx, img_path in enumerate(image_list): + img = cv2.imread(img_path) + if img is None: + logger.warning( + "Image file failed to read and has been skipped. The path: {}". + format(img_path)) + else: + img = img[:, :, ::-1] + batch_imgs.append(img) + img_name = os.path.basename(img_path) + batch_names.append(img_name) + cnt += 1 + + if cnt % config["Global"]["batch_size"] == 0 or (idx + 1 + ) == len(image_list): + if len(batch_imgs) == 0: + continue + + batch_results = rec_predictor.predict(batch_imgs) + for number, result_dict in enumerate(batch_results): + filename = batch_names[number] + print("{}:\t{}".format(filename, result_dict)) + batch_imgs = [] + batch_names = [] + if rec_predictor.benchmark: + rec_predictor.auto_logger.report() + + return + + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config(args.config, overrides=args.override, show=True) + main(config) diff --git a/src/PaddleClas/deploy/python/predict_system.py b/src/PaddleClas/deploy/python/predict_system.py new file mode 100644 index 0000000..e45ee16 --- /dev/null +++ b/src/PaddleClas/deploy/python/predict_system.py @@ -0,0 +1,155 @@ +# Copyright (c) 2021 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. +import os +import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +import copy +import cv2 +import numpy as np +import faiss +import pickle + +from python.predict_rec import RecPredictor +from python.predict_det import DetPredictor + +from utils import logger +from utils import config +from utils.get_image_list import get_image_list +from utils.draw_bbox import draw_bbox_results + + +class SystemPredictor(object): + def __init__(self, config): + + self.config = config + self.rec_predictor = RecPredictor(config) + self.det_predictor = DetPredictor(config) + + assert 'IndexProcess' in config.keys(), "Index config not found ... " + self.return_k = self.config['IndexProcess']['return_k'] + + index_dir = self.config["IndexProcess"]["index_dir"] + assert os.path.exists(os.path.join( + index_dir, "vector.index")), "vector.index not found ..." + assert os.path.exists(os.path.join( + index_dir, "id_map.pkl")), "id_map.pkl not found ... " + + if config['IndexProcess'].get("dist_type") == "hamming": + self.Searcher = faiss.read_index_binary( + os.path.join(index_dir, "vector.index")) + else: + self.Searcher = faiss.read_index( + os.path.join(index_dir, "vector.index")) + + with open(os.path.join(index_dir, "id_map.pkl"), "rb") as fd: + self.id_map = pickle.load(fd) + + def append_self(self, results, shape): + results.append({ + "class_id": 0, + "score": 1.0, + "bbox": + np.array([0, 0, shape[1], shape[0]]), # xmin, ymin, xmax, ymax + "label_name": "foreground", + }) + return results + + def nms_to_rec_results(self, results, thresh=0.1): + filtered_results = [] + x1 = np.array([r["bbox"][0] for r in results]).astype("float32") + y1 = np.array([r["bbox"][1] for r in results]).astype("float32") + x2 = np.array([r["bbox"][2] for r in results]).astype("float32") + y2 = np.array([r["bbox"][3] for r in results]).astype("float32") + scores = np.array([r["rec_scores"] for r in results]) + + areas = (x2 - x1 + 1) * (y2 - y1 + 1) + order = scores.argsort()[::-1] + while order.size > 0: + i = order[0] + xx1 = np.maximum(x1[i], x1[order[1:]]) + yy1 = np.maximum(y1[i], y1[order[1:]]) + xx2 = np.minimum(x2[i], x2[order[1:]]) + yy2 = np.minimum(y2[i], y2[order[1:]]) + + w = np.maximum(0.0, xx2 - xx1 + 1) + h = np.maximum(0.0, yy2 - yy1 + 1) + inter = w * h + ovr = inter / (areas[i] + areas[order[1:]] - inter) + inds = np.where(ovr <= thresh)[0] + order = order[inds + 1] + filtered_results.append(results[i]) + + return filtered_results + + def predict(self, img): + output = [] + # st1: get all detection results + results = self.det_predictor.predict(img) + + # st2: add the whole image for recognition to improve recall + results = self.append_self(results, img.shape) + + # st3: recognition process, use score_thres to ensure accuracy + for result in results: + preds = {} + xmin, ymin, xmax, ymax = result["bbox"].astype("int") + crop_img = img[ymin:ymax, xmin:xmax, :].copy() + rec_results = self.rec_predictor.predict(crop_img) + preds["bbox"] = [xmin, ymin, xmax, ymax] + scores, docs = self.Searcher.search(rec_results, self.return_k) + + # just top-1 result will be returned for the final + if self.config["IndexProcess"]["dist_type"] == "hamming": + if scores[0][0] <= self.config["IndexProcess"][ + "hamming_radius"]: + preds["rec_docs"] = self.id_map[docs[0][0]].split()[1] + preds["rec_scores"] = scores[0][0] + output.append(preds) + else: + if scores[0][0] >= self.config["IndexProcess"]["score_thres"]: + preds["rec_docs"] = self.id_map[docs[0][0]].split()[1] + preds["rec_scores"] = scores[0][0] + output.append(preds) + + # st5: nms to the final results to avoid fetching duplicate results + output = self.nms_to_rec_results( + output, self.config["Global"]["rec_nms_thresold"]) + + return output + + +def main(config): + system_predictor = SystemPredictor(config) + image_list = get_image_list(config["Global"]["infer_imgs"]) + + assert config["Global"]["batch_size"] == 1 + for idx, image_file in enumerate(image_list): + img = cv2.imread(image_file)[:, :, ::-1] + cv2.imshow('IMG', img) + cv2.waitKey() + cv2.destroyAllWindows() + output = system_predictor.predict(img) + draw_bbox_results(img, output, image_file) + print(output) + + return + + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config(args.config, overrides=args.override, show=True) + main(config) diff --git a/src/PaddleClas/deploy/python/preprocess.py b/src/PaddleClas/deploy/python/preprocess.py new file mode 100644 index 0000000..1da32ad --- /dev/null +++ b/src/PaddleClas/deploy/python/preprocess.py @@ -0,0 +1,337 @@ +""" +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from functools import partial +import six +import math +import random +import cv2 +import numpy as np +import importlib +from PIL import Image + +from python.det_preprocess import DetNormalizeImage, DetPadStride, DetPermute, DetResize + + +def create_operators(params): + """ + create operators based on the config + + Args: + params(list): a dict list, used to create some operators + """ + assert isinstance(params, list), ('operator config should be a list') + mod = importlib.import_module(__name__) + ops = [] + for operator in params: + assert isinstance(operator, + dict) and len(operator) == 1, "yaml format error" + op_name = list(operator)[0] + param = {} if operator[op_name] is None else operator[op_name] + op = getattr(mod, op_name)(**param) + ops.append(op) + + return ops + + +class UnifiedResize(object): + def __init__(self, interpolation=None, backend="cv2"): + _cv2_interp_from_str = { + 'nearest': cv2.INTER_NEAREST, + 'bilinear': cv2.INTER_LINEAR, + 'area': cv2.INTER_AREA, + 'bicubic': cv2.INTER_CUBIC, + 'lanczos': cv2.INTER_LANCZOS4 + } + _pil_interp_from_str = { + 'nearest': Image.NEAREST, + 'bilinear': Image.BILINEAR, + 'bicubic': Image.BICUBIC, + 'box': Image.BOX, + 'lanczos': Image.LANCZOS, + 'hamming': Image.HAMMING + } + + def _pil_resize(src, size, resample): + pil_img = Image.fromarray(src) + pil_img = pil_img.resize(size, resample) + return np.asarray(pil_img) + + if backend.lower() == "cv2": + if isinstance(interpolation, str): + interpolation = _cv2_interp_from_str[interpolation.lower()] + # compatible with opencv < version 4.4.0 + elif interpolation is None: + interpolation = cv2.INTER_LINEAR + self.resize_func = partial(cv2.resize, interpolation=interpolation) + elif backend.lower() == "pil": + if isinstance(interpolation, str): + interpolation = _pil_interp_from_str[interpolation.lower()] + self.resize_func = partial(_pil_resize, resample=interpolation) + else: + logger.warning( + f"The backend of Resize only support \"cv2\" or \"PIL\". \"f{backend}\" is unavailable. Use \"cv2\" instead." + ) + self.resize_func = cv2.resize + + def __call__(self, src, size): + return self.resize_func(src, size) + + +class OperatorParamError(ValueError): + """ OperatorParamError + """ + pass + + +class DecodeImage(object): + """ decode image """ + + def __init__(self, to_rgb=True, to_np=False, channel_first=False): + self.to_rgb = to_rgb + self.to_np = to_np # to numpy + self.channel_first = channel_first # only enabled when to_np is True + + def __call__(self, img): + if six.PY2: + assert type(img) is str and len( + img) > 0, "invalid input 'img' in DecodeImage" + else: + assert type(img) is bytes and len( + img) > 0, "invalid input 'img' in DecodeImage" + data = np.frombuffer(img, dtype='uint8') + img = cv2.imdecode(data, 1) + if self.to_rgb: + assert img.shape[2] == 3, 'invalid shape of image[%s]' % ( + img.shape) + img = img[:, :, ::-1] + + if self.channel_first: + img = img.transpose((2, 0, 1)) + + return img + + +class ResizeImage(object): + """ resize image """ + + def __init__(self, + size=None, + resize_short=None, + interpolation=None, + backend="cv2"): + if resize_short is not None and resize_short > 0: + self.resize_short = resize_short + self.w = None + self.h = None + elif size is not None: + self.resize_short = None + self.w = size if type(size) is int else size[0] + self.h = size if type(size) is int else size[1] + else: + raise OperatorParamError("invalid params for ReisizeImage for '\ + 'both 'size' and 'resize_short' are None") + + self._resize_func = UnifiedResize( + interpolation=interpolation, backend=backend) + + def __call__(self, img): + img_h, img_w = img.shape[:2] + if self.resize_short is not None: + percent = float(self.resize_short) / min(img_w, img_h) + w = int(round(img_w * percent)) + h = int(round(img_h * percent)) + else: + w = self.w + h = self.h + return self._resize_func(img, (w, h)) + + +class CropImage(object): + """ crop image """ + + def __init__(self, size): + if type(size) is int: + self.size = (size, size) + else: + self.size = size # (h, w) + + def __call__(self, img): + w, h = self.size + img_h, img_w = img.shape[:2] + + if img_h < h or img_w < w: + raise Exception( + f"The size({h}, {w}) of CropImage must be greater than size({img_h}, {img_w}) of image. Please check image original size and size of ResizeImage if used." + ) + + w_start = (img_w - w) // 2 + h_start = (img_h - h) // 2 + + w_end = w_start + w + h_end = h_start + h + return img[h_start:h_end, w_start:w_end, :] + + +class RandCropImage(object): + """ random crop image """ + + def __init__(self, + size, + scale=None, + ratio=None, + interpolation=None, + backend="cv2"): + if type(size) is int: + self.size = (size, size) # (h, w) + else: + self.size = size + + self.scale = [0.08, 1.0] if scale is None else scale + self.ratio = [3. / 4., 4. / 3.] if ratio is None else ratio + + self._resize_func = UnifiedResize( + interpolation=interpolation, backend=backend) + + def __call__(self, img): + size = self.size + scale = self.scale + ratio = self.ratio + + aspect_ratio = math.sqrt(random.uniform(*ratio)) + w = 1. * aspect_ratio + h = 1. / aspect_ratio + + img_h, img_w = img.shape[:2] + + bound = min((float(img_w) / img_h) / (w**2), + (float(img_h) / img_w) / (h**2)) + scale_max = min(scale[1], bound) + scale_min = min(scale[0], bound) + + target_area = img_w * img_h * random.uniform(scale_min, scale_max) + target_size = math.sqrt(target_area) + w = int(target_size * w) + h = int(target_size * h) + + i = random.randint(0, img_w - w) + j = random.randint(0, img_h - h) + + img = img[j:j + h, i:i + w, :] + + return self._resize_func(img, size) + + +class RandFlipImage(object): + """ random flip image + flip_code: + 1: Flipped Horizontally + 0: Flipped Vertically + -1: Flipped Horizontally & Vertically + """ + + def __init__(self, flip_code=1): + assert flip_code in [-1, 0, 1 + ], "flip_code should be a value in [-1, 0, 1]" + self.flip_code = flip_code + + def __call__(self, img): + if random.randint(0, 1) == 1: + return cv2.flip(img, self.flip_code) + else: + return img + + +class AutoAugment(object): + def __init__(self): + self.policy = ImageNetPolicy() + + def __call__(self, img): + from PIL import Image + img = np.ascontiguousarray(img) + img = Image.fromarray(img) + img = self.policy(img) + img = np.asarray(img) + + +class NormalizeImage(object): + """ normalize image such as substract mean, divide std + """ + + def __init__(self, + scale=None, + mean=None, + std=None, + order='chw', + output_fp16=False, + channel_num=3): + if isinstance(scale, str): + scale = eval(scale) + assert channel_num in [ + 3, 4 + ], "channel number of input image should be set to 3 or 4." + self.channel_num = channel_num + self.output_dtype = 'float16' if output_fp16 else 'float32' + self.scale = np.float32(scale if scale is not None else 1.0 / 255.0) + self.order = order + mean = mean if mean is not None else [0.485, 0.456, 0.406] + std = std if std is not None else [0.229, 0.224, 0.225] + + shape = (3, 1, 1) if self.order == 'chw' else (1, 1, 3) + self.mean = np.array(mean).reshape(shape).astype('float32') + self.std = np.array(std).reshape(shape).astype('float32') + + def __call__(self, img): + from PIL import Image + if isinstance(img, Image.Image): + img = np.array(img) + + assert isinstance(img, + np.ndarray), "invalid input 'img' in NormalizeImage" + + img = (img.astype('float32') * self.scale - self.mean) / self.std + + if self.channel_num == 4: + img_h = img.shape[1] if self.order == 'chw' else img.shape[0] + img_w = img.shape[2] if self.order == 'chw' else img.shape[1] + pad_zeros = np.zeros( + (1, img_h, img_w)) if self.order == 'chw' else np.zeros( + (img_h, img_w, 1)) + img = (np.concatenate( + (img, pad_zeros), axis=0) + if self.order == 'chw' else np.concatenate( + (img, pad_zeros), axis=2)) + return img.astype(self.output_dtype) + + +class ToCHWImage(object): + """ convert hwc image to chw image + """ + + def __init__(self): + pass + + def __call__(self, img): + from PIL import Image + if isinstance(img, Image.Image): + img = np.array(img) + + return img.transpose((2, 0, 1)) diff --git a/src/PaddleClas/deploy/shell/predict.sh b/src/PaddleClas/deploy/shell/predict.sh new file mode 100644 index 0000000..f0f59f4 --- /dev/null +++ b/src/PaddleClas/deploy/shell/predict.sh @@ -0,0 +1,18 @@ +# classification +python3.7 python/predict_cls.py -c configs/inference_cls.yaml + +# multilabel_classification +#python3.7 python/predict_cls.py -c configs/inference_multilabel_cls.yaml + +# feature extractor +# python3.7 python/predict_rec.py -c configs/inference_rec.yaml + +# detection +# python3.7 python/predict_det.py -c configs/inference_rec.yaml + + +# build system +#python3.7 python/build_gallery.py -c configs/build_logo.yaml + +# inference system +# python3.7 python/predict_system.py -c configs/inference_logo.yaml diff --git a/src/PaddleClas/deploy/slim/README.md b/src/PaddleClas/deploy/slim/README.md new file mode 100644 index 0000000..eed8aa3 --- /dev/null +++ b/src/PaddleClas/deploy/slim/README.md @@ -0,0 +1,144 @@ + +## Slim功能介绍 +复杂的模型有利于提高模型的性能,但也导致模型中存在一定冗余。此部分提供精简模型的功能,包括两部分:模型量化(量化训练、离线量化)、模型剪枝。 + +其中模型量化将全精度缩减到定点数减少这种冗余,达到减少模型计算复杂度,提高模型推理性能的目的。 +模型量化可以在基本不损失模型的精度的情况下,将FP32精度的模型参数转换为Int8精度,减小模型参数大小并加速计算,使用量化后的模型在移动端等部署时更具备速度优势。 + +模型剪枝将CNN中不重要的卷积核裁剪掉,减少模型参数量,从而降低模型计算复杂度。 + +本教程将介绍如何使用飞桨模型压缩库PaddleSlim做PaddleClas模型的压缩。 +[PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) 集成了模型剪枝、量化(包括量化训练和离线量化)、蒸馏和神经网络搜索等多种业界常用且领先的模型压缩功能,如果您感兴趣,可以关注并了解。 + +在开始本教程之前,建议先了解[PaddleClas模型的训练方法](../../docs/zh_CN/tutorials/getting_started.md)以及[PaddleSlim](https://paddleslim.readthedocs.io/zh_CN/latest/index.html) + + +## 快速开始 +当训练出一个模型后,如果希望进一步的压缩模型大小并加速预测,可使用量化或者剪枝的方法压缩模型。 + +模型压缩主要包括五个步骤: +1. 安装 PaddleSlim +2. 准备训练好的模型 +3. 模型压缩 +4. 导出量化推理模型 +5. 量化模型预测部署 + +### 1. 安装PaddleSlim + +* 可以通过pip install的方式进行安装。 + +```bash +pip install paddleslim -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +* 如果获取PaddleSlim的最新特性,可以从源码安装。 + +```bash +git clone https://github.com/PaddlePaddle/PaddleSlim.git +cd Paddleslim +python3.7 setup.py install +``` + +### 2. 准备训练好的模型 + +PaddleClas提供了一系列训练好的[模型](../../docs/zh_CN/models/models_intro.md),如果待量化的模型不在列表中,需要按照[常规训练](../../docs/zh_CN/tutorials/getting_started.md)方法得到训练好的模型。 + +### 3. 模型压缩 + +进入PaddleClas根目录 + +```bash +cd PaddleClas +``` + +`slim`训练相关代码已经集成到`ppcls/engine/`下,离线量化代码位于`deploy/slim/quant_post_static.py`。 + +#### 3.1 模型量化 + +量化训练包括离线量化训练和在线量化训练,在线量化训练效果更好,需加载预训练模型,在定义好量化策略后即可对模型进行量化。 + +##### 3.1.1 在线量化训练 + +训练指令如下: + +* CPU/单卡GPU + +以CPU为例,若使用GPU,则将命令中改成`cpu`改成`gpu` + +```bash +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.device=cpu +``` + +其中`yaml`文件解析详见[参考文档](../../docs/zh_CN/tutorials/config_description.md)。为了保证精度,`yaml`文件中已经使用`pretrained model`. + + +* 单机多卡/多机多卡启动 + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +``` + +##### 3.1.2 离线量化 + +**注意**:目前离线量化,必须使用已经训练好的模型,导出的`inference model`进行量化。一般模型导出`inference model`可参考[教程](../../docs/zh_CN/inference.md). + +一般来说,离线量化损失模型精度较多。 + +生成`inference model`后,离线量化运行方式如下 + +```bash +python3.7 deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./deploy/models/class_ResNet50_vd_ImageNet_infer +``` + +`Global.save_inference_dir`是`inference model`存放的目录。 + +执行成功后,在`Global.save_inference_dir`的目录下,生成`quant_post_static_model`文件夹,其中存储生成的离线量化模型,其可以直接进行预测部署,无需再重新导出模型。 + +#### 3.2 模型剪枝 + +训练指令如下: + +- CPU/单卡GPU + +以CPU为例,若使用GPU,则将命令中改成`cpu`改成`gpu` + +```bash +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.device=cpu +``` + +- 单机单卡/单机多卡/多机多卡启动 + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml +``` + +### 4. 导出模型 + +在得到在线量化训练、模型剪枝保存的模型后,可以将其导出为inference model,用于预测部署,以模型剪枝为例: + +```bash +python3.7 tools/export.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml \ + -o Global.pretrained_model=./output/ResNet50_vd/best_model \ + -o Global.save_inference_dir=./inference +``` + + +### 5. 模型部署 + +上述步骤导出的模型可以通过PaddleLite的opt模型转换工具完成模型转换。 +模型部署的可参考 [移动端模型部署](../lite/readme.md) + + +## 训练超参数建议 + +* 量化训练时,建议加载常规训练得到的预训练模型,加速量化训练收敛。 +* 量化训练时,建议初始学习率修改为常规训练的`1/20~1/10`,同时将训练epoch数修改为常规训练的`1/5~1/2`,学习率策略方面,加上Warmup,其他配置信息不建议修改。 diff --git a/src/PaddleClas/deploy/slim/README_en.md b/src/PaddleClas/deploy/slim/README_en.md new file mode 100644 index 0000000..d7a978f --- /dev/null +++ b/src/PaddleClas/deploy/slim/README_en.md @@ -0,0 +1,144 @@ + +## Introduction to Slim + +Generally, a more complex model would achive better performance in the task, but it also leads to some redundancy in the model. This part provides the function of compressing the model, including two parts: model quantization (offline quantization training and online quantization training) and model pruning. +Quantization is a technique that reduces this redundancy by reducing the full precision data to a fixed number, so as to reduce model calculation complexity and improve model inference performance. + +Model pruning cuts off the unimportant convolution kernel in CNN to reduce the amount of model parameters, so as to reduce the computational complexity of the model. + +It is recommended that you could understand following pages before reading this example: +- [The training strategy of PaddleClas models](../../docs/en/tutorials/getting_started_en.md) +- [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) + +## Quick Start + After training a model, if you want to further compress the model size and speed up the prediction, you can use quantization or pruning to compress the model according to the following steps. + +1. Install PaddleSlim +2. Prepare trained model +3. Model compression +4. Export inference model +5. Deploy quantization inference model + + +### 1. Install PaddleSlim + +* Install by pip. + +```bash +pip install paddleslim -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +* Install from source code to get the lastest features. + +```bash +git clone https://github.com/PaddlePaddle/PaddleSlim.git +cd Paddleslim +python setup.py install +``` + + +### 2. Download Pretrain Model +PaddleClas provides a series of trained [models](../../docs/en/models/models_intro_en.md). +If the model to be quantified is not in the list, you need to follow the [Regular Training](../../docs/en/tutorials/getting_started_en.md) method to get the trained model. + +### 3. Model Compression + +Go to the root directory of PaddleClas + +```bash +cd PaddleClase +``` + +The training related codes have been integrated into `ppcls/engine/`. The offline quantization code is located in `deploy/slim/quant_post_static.py` + +#### 3.1 Model Quantization + +Quantization training includes offline quantization and online quantization training. + +##### 3.1.1 Online quantization training + +Online quantization training is more effective. It is necessary to load the pre-trained model. +After the quantization strategy is defined, the model can be quantified. + +The training command is as follow: + +* CPU/Single GPU + +If using GPU, change the `cpu` to `gpu` in the following command. + +```bash +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.device=cpu +``` + +The description of `yaml` file can be found in this [doc](../../docs/en/tutorials/config_en.md). To get better accuracy, the `pretrained model`is used in `yaml`. + + +* Distributed training + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -m train \ + -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +``` + +##### 3.1.2 Offline quantization + +**Attention**: At present, offline quantization must use `inference model` as input, which can be exported by trained model. The process of exporting `inference model` for trained model can refer to this [doc](../../docs/en/inference.md). + +Generally speaking, the offline quantization gets more loss of accuracy than online qutization training. + +After getting `inference model`, we can run following command to get offline quantization model. + +``` +python3.7 deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./deploy/models/class_ResNet50_vd_ImageNet_infer +``` + +`Global.save_inference_dir` is the directory storing the `inference model`. + +If run successfully, the directory `quant_post_static_model` is generated in `Global.save_inference_dir`, which stores the offline quantization model that can be used for deploy directly. + +#### 3.2 Model Pruning + +- CPU/Single GPU + +If using GPU, change the `cpu` to `gpu` in the following command. + +```bash +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.device=cpu +``` + +- Distributed training + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml +``` + + + +### 4. Export inference model + +After getting the compressed model, we can export it as inference model for predictive deployment. Using pruned model as example: + +```bash +python3.7 tools/export.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml \ + -o Global.pretrained_model=./output/ResNet50_vd/best_model + -o Global.save_inference_dir=./inference +``` + +### 5. Deploy +The derived model can be converted through the `opt tool` of PaddleLite. + +For compresed model deployment, please refer to [Mobile terminal model deployment](../lite/readme_en.md) + +## Notes: + +* In quantitative training, it is suggested to load the pre-trained model obtained from conventional training to accelerate the convergence of quantitative training. +* In quantitative training, it is suggested that the initial learning rate should be changed to `1 / 20 ~ 1 / 10` of the conventional training, and the training epoch number should be changed to `1 / 5 ~ 1 / 2` of the conventional training. In terms of learning rate strategy, it's better to train with warmup, other configuration information is not recommended to be changed. diff --git a/src/PaddleClas/deploy/slim/quant_post_static.py b/src/PaddleClas/deploy/slim/quant_post_static.py new file mode 100644 index 0000000..5c84697 --- /dev/null +++ b/src/PaddleClas/deploy/slim/quant_post_static.py @@ -0,0 +1,74 @@ +# Copyright (c) 2021 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 __future__ import absolute_import, division, print_function + +import os +import sys + +import numpy as np +import paddle +import paddleslim +from paddle.jit import to_static +from paddleslim.analysis import dygraph_flops as flops + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../../'))) +from paddleslim.dygraph.quant import QAT + +from ppcls.data import build_dataloader +from ppcls.utils import config as conf +from ppcls.utils.logger import init_logger + + +def main(): + args = conf.parse_args() + config = conf.get_config(args.config, overrides=args.override, show=False) + + assert os.path.exists( + os.path.join(config["Global"]["save_inference_dir"], + 'inference.pdmodel')) and os.path.exists( + os.path.join(config["Global"]["save_inference_dir"], + 'inference.pdiparams')) + config["DataLoader"]["Eval"]["sampler"]["batch_size"] = 1 + config["DataLoader"]["Eval"]["loader"]["num_workers"] = 0 + init_logger() + device = paddle.set_device("cpu") + train_dataloader = build_dataloader(config["DataLoader"], "Eval", device, + False) + + def sample_generator(loader): + def __reader__(): + for indx, data in enumerate(loader): + images = np.array(data[0]) + yield images + + return __reader__ + + paddle.enable_static() + place = paddle.CPUPlace() + exe = paddle.static.Executor(place) + paddleslim.quant.quant_post_static( + executor=exe, + model_dir=config["Global"]["save_inference_dir"], + model_filename='inference.pdmodel', + params_filename='inference.pdiparams', + quantize_model_path=os.path.join( + config["Global"]["save_inference_dir"], "quant_post_static_model"), + sample_generator=sample_generator(train_dataloader), + batch_nums=10) + + +if __name__ == "__main__": + main() diff --git a/src/PaddleClas/deploy/utils/__init__.py b/src/PaddleClas/deploy/utils/__init__.py new file mode 100644 index 0000000..baf14a9 --- /dev/null +++ b/src/PaddleClas/deploy/utils/__init__.py @@ -0,0 +1,5 @@ +from . import logger +from . import config +from . import get_image_list +from . import predictor +from . import encode_decode \ No newline at end of file diff --git a/src/PaddleClas/deploy/utils/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..f58ada7 Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/__pycache__/config.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/config.cpython-39.pyc new file mode 100644 index 0000000..b6b1f27 Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/config.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/__pycache__/draw_bbox.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/draw_bbox.cpython-39.pyc new file mode 100644 index 0000000..cb0d460 Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/draw_bbox.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/__pycache__/encode_decode.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/encode_decode.cpython-39.pyc new file mode 100644 index 0000000..5a166f8 Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/encode_decode.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/__pycache__/get_image_list.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/get_image_list.cpython-39.pyc new file mode 100644 index 0000000..0819645 Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/get_image_list.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/__pycache__/logger.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/logger.cpython-39.pyc new file mode 100644 index 0000000..945660e Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/logger.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/__pycache__/predictor.cpython-39.pyc b/src/PaddleClas/deploy/utils/__pycache__/predictor.cpython-39.pyc new file mode 100644 index 0000000..ba1cd2b Binary files /dev/null and b/src/PaddleClas/deploy/utils/__pycache__/predictor.cpython-39.pyc differ diff --git a/src/PaddleClas/deploy/utils/config.py b/src/PaddleClas/deploy/utils/config.py new file mode 100644 index 0000000..7e7ffb7 --- /dev/null +++ b/src/PaddleClas/deploy/utils/config.py @@ -0,0 +1,197 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import os +import copy +import argparse +import yaml + +from utils import logger + +__all__ = ['get_config'] + + +class AttrDict(dict): + def __getattr__(self, key): + return self[key] + + def __setattr__(self, key, value): + if key in self.__dict__: + self.__dict__[key] = value + else: + self[key] = value + + def __deepcopy__(self, content): + return copy.deepcopy(dict(self)) + + +def create_attr_dict(yaml_config): + from ast import literal_eval + for key, value in yaml_config.items(): + if type(value) is dict: + yaml_config[key] = value = AttrDict(value) + if isinstance(value, str): + try: + value = literal_eval(value) + except BaseException: + pass + if isinstance(value, AttrDict): + create_attr_dict(yaml_config[key]) + else: + yaml_config[key] = value + + +def parse_config(cfg_file): + """Load a config file into AttrDict""" + with open(cfg_file, 'r') as fopen: + yaml_config = AttrDict(yaml.load(fopen, Loader=yaml.SafeLoader)) + create_attr_dict(yaml_config) + return yaml_config + + +def print_dict(d, delimiter=0): + """ + Recursively visualize a dict and + indenting acrrording by the relationship of keys. + """ + placeholder = "-" * 60 + for k, v in sorted(d.items()): + if isinstance(v, dict): + logger.info("{}{} : ".format(delimiter * " ", + logger.coloring(k, "HEADER"))) + print_dict(v, delimiter + 4) + elif isinstance(v, list) and len(v) >= 1 and isinstance(v[0], dict): + logger.info("{}{} : ".format(delimiter * " ", + logger.coloring(str(k), "HEADER"))) + for value in v: + print_dict(value, delimiter + 4) + else: + logger.info("{}{} : {}".format(delimiter * " ", + logger.coloring(k, "HEADER"), + logger.coloring(v, "OKGREEN"))) + if k.isupper(): + logger.info(placeholder) + + +def print_config(config): + """ + visualize configs + Arguments: + config: configs + """ + logger.advertise() + print_dict(config) + + +def override(dl, ks, v): + """ + Recursively replace dict of list + Args: + dl(dict or list): dict or list to be replaced + ks(list): list of keys + v(str): value to be replaced + """ + + def str2num(v): + try: + return eval(v) + except Exception: + return v + + assert isinstance(dl, (list, dict)), ("{} should be a list or a dict") + assert len(ks) > 0, ('lenght of keys should larger than 0') + if isinstance(dl, list): + k = str2num(ks[0]) + if len(ks) == 1: + assert k < len(dl), ('index({}) out of range({})'.format(k, dl)) + dl[k] = str2num(v) + else: + override(dl[k], ks[1:], v) + else: + if len(ks) == 1: + # assert ks[0] in dl, ('{} is not exist in {}'.format(ks[0], dl)) + if not ks[0] in dl: + logger.warning('A new filed ({}) detected!'.format(ks[0])) + dl[ks[0]] = str2num(v) + else: + override(dl[ks[0]], ks[1:], v) + + +def override_config(config, options=None): + """ + Recursively override the config + Args: + config(dict): dict to be replaced + options(list): list of pairs(key0.key1.idx.key2=value) + such as: [ + 'topk=2', + 'VALID.transforms.1.ResizeImage.resize_short=300' + ] + Returns: + config(dict): replaced config + """ + if options is not None: + for opt in options: + assert isinstance(opt, str), ( + "option({}) should be a str".format(opt)) + assert "=" in opt, ( + "option({}) should contain a =" + "to distinguish between key and value".format(opt)) + pair = opt.split('=') + assert len(pair) == 2, ("there can be only a = in the option") + key, value = pair + keys = key.split('.') + override(config, keys, value) + return config + + +def get_config(fname, overrides=None, show=True): + """ + Read config from file + """ + assert os.path.exists(fname), ( + 'config file({}) is not exist'.format(fname)) + config = parse_config(fname) + override_config(config, overrides) + if show: + print_config(config) + # check_config(config) + return config + + +def parser(): + parser = argparse.ArgumentParser("generic-image-rec train script") + parser.add_argument( + '-c', + '--config', + type=str, + default='configs/config.yaml', + help='config file path') + parser.add_argument( + '-o', + '--override', + action='append', + default=[], + help='config options to be overridden') + parser.add_argument( + '-v', + '--verbose', + action='store_true', + help='wheather print the config info') + return parser + + +def parse_args(): + args = parser().parse_args() + return args diff --git a/src/PaddleClas/deploy/utils/draw_bbox.py b/src/PaddleClas/deploy/utils/draw_bbox.py new file mode 100644 index 0000000..b1b6d17 --- /dev/null +++ b/src/PaddleClas/deploy/utils/draw_bbox.py @@ -0,0 +1,62 @@ +# Copyright (c) 2021 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. + +import os +import numpy as np +import cv2 +from PIL import Image, ImageDraw, ImageFont + + +def draw_bbox_results(image, + results, + input_path, + font_path="./utils/simfang.ttf", + save_dir=None): + if isinstance(image, np.ndarray): + image = Image.fromarray(image) + draw = ImageDraw.Draw(image) + font_size = 18 + font = ImageFont.truetype(font_path, font_size, encoding="utf-8") + + color = (0, 102, 255) + + for result in results: + # empty results + if result["rec_docs"] is None: + continue + + xmin, ymin, xmax, ymax = result["bbox"] + text = "{}, {:.2f}".format(result["rec_docs"], result["rec_scores"]) + th = font_size + tw = font.getsize(text)[0] + # tw = int(len(result["rec_docs"]) * font_size) + 60 + start_y = max(0, ymin - th) + + draw.rectangle( + [(xmin + 1, start_y), (xmin + tw + 1, start_y + th)], fill=color) + + draw.text((xmin + 1, start_y), text, fill=(255, 255, 255), font=font) + + draw.rectangle( + [(xmin, ymin), (xmax, ymax)], outline=(255, 0, 0), width=2) + + image_name = os.path.basename(input_path) + if save_dir is None: + save_dir = "output" + os.makedirs(save_dir, exist_ok=True) + output_path = os.path.join(save_dir, image_name) + + image.save(output_path, quality=95) + image.show() + return np.array(image) diff --git a/src/PaddleClas/deploy/utils/encode_decode.py b/src/PaddleClas/deploy/utils/encode_decode.py new file mode 100644 index 0000000..d76a529 --- /dev/null +++ b/src/PaddleClas/deploy/utils/encode_decode.py @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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. + +import base64 + +import numpy as np + + +def np_to_b64(images): + img_str = base64.b64encode(images).decode('utf8') + return img_str, images.shape + + +def b64_to_np(b64str, revert_params): + shape = revert_params["shape"] + dtype = revert_params["dtype"] + dtype = getattr(np, dtype) if isinstance(str, type(dtype)) else dtype + data = base64.b64decode(b64str.encode('utf8')) + data = np.fromstring(data, dtype).reshape(shape) + return data \ No newline at end of file diff --git a/src/PaddleClas/deploy/utils/get_image_list.py b/src/PaddleClas/deploy/utils/get_image_list.py new file mode 100644 index 0000000..6f10935 --- /dev/null +++ b/src/PaddleClas/deploy/utils/get_image_list.py @@ -0,0 +1,49 @@ +# 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. + +import os +import argparse +import base64 +import numpy as np + + +def get_image_list(img_file): + imgs_lists = [] + if img_file is None or not os.path.exists(img_file): + raise Exception("not found any img file in {}".format(img_file)) + + img_end = ['jpg', 'png', 'jpeg', 'JPEG', 'JPG', 'bmp'] + if os.path.isfile(img_file) and img_file.split('.')[-1] in img_end: + imgs_lists.append(img_file) + elif os.path.isdir(img_file): + for single_file in os.listdir(img_file): + if single_file.split('.')[-1] in img_end: + imgs_lists.append(os.path.join(img_file, single_file)) + if len(imgs_lists) == 0: + raise Exception("not found any img file in {}".format(img_file)) + imgs_lists = sorted(imgs_lists) + return imgs_lists + + +def get_image_list_from_label_file(image_path, label_file_path): + imgs_lists = [] + gt_labels = [] + with open(label_file_path, "r") as fin: + lines = fin.readlines() + for line in lines: + image_name, label = line.strip("\n").split() + label = int(label) + imgs_lists.append(os.path.join(image_path, image_name)) + gt_labels.append(int(label)) + return imgs_lists, gt_labels diff --git a/src/PaddleClas/deploy/utils/imagenet1k_label_list.txt b/src/PaddleClas/deploy/utils/imagenet1k_label_list.txt new file mode 100644 index 0000000..376e180 --- /dev/null +++ b/src/PaddleClas/deploy/utils/imagenet1k_label_list.txt @@ -0,0 +1,1000 @@ +0 tench, Tinca tinca +1 goldfish, Carassius auratus +2 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias +3 tiger shark, Galeocerdo cuvieri +4 hammerhead, hammerhead shark +5 electric ray, crampfish, numbfish, torpedo +6 stingray +7 cock +8 hen +9 ostrich, Struthio camelus +10 brambling, Fringilla montifringilla +11 goldfinch, Carduelis carduelis +12 house finch, linnet, Carpodacus mexicanus +13 junco, snowbird +14 indigo bunting, indigo finch, indigo bird, Passerina cyanea +15 robin, American robin, Turdus migratorius +16 bulbul +17 jay +18 magpie +19 chickadee +20 water ouzel, dipper +21 kite +22 bald eagle, American eagle, Haliaeetus leucocephalus +23 vulture +24 great grey owl, great gray owl, Strix nebulosa +25 European fire salamander, Salamandra salamandra +26 common newt, Triturus vulgaris +27 eft +28 spotted salamander, Ambystoma maculatum +29 axolotl, mud puppy, Ambystoma mexicanum +30 bullfrog, Rana catesbeiana +31 tree frog, tree-frog +32 tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui +33 loggerhead, loggerhead turtle, Caretta caretta +34 leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea +35 mud turtle +36 terrapin +37 box turtle, box tortoise +38 banded gecko +39 common iguana, iguana, Iguana iguana +40 American chameleon, anole, Anolis carolinensis +41 whiptail, whiptail lizard +42 agama +43 frilled lizard, Chlamydosaurus kingi +44 alligator lizard +45 Gila monster, Heloderma suspectum +46 green lizard, Lacerta viridis +47 African chameleon, Chamaeleo chamaeleon +48 Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis +49 African crocodile, Nile crocodile, Crocodylus niloticus +50 American alligator, Alligator mississipiensis +51 triceratops +52 thunder snake, worm snake, Carphophis amoenus +53 ringneck snake, ring-necked snake, ring snake +54 hognose snake, puff adder, sand viper +55 green snake, grass snake +56 king snake, kingsnake +57 garter snake, grass snake +58 water snake +59 vine snake +60 night snake, Hypsiglena torquata +61 boa constrictor, Constrictor constrictor +62 rock python, rock snake, Python sebae +63 Indian cobra, Naja naja +64 green mamba +65 sea snake +66 horned viper, cerastes, sand viper, horned asp, Cerastes cornutus +67 diamondback, diamondback rattlesnake, Crotalus adamanteus +68 sidewinder, horned rattlesnake, Crotalus cerastes +69 trilobite +70 harvestman, daddy longlegs, Phalangium opilio +71 scorpion +72 black and gold garden spider, Argiope aurantia +73 barn spider, Araneus cavaticus +74 garden spider, Aranea diademata +75 black widow, Latrodectus mactans +76 tarantula +77 wolf spider, hunting spider +78 tick +79 centipede +80 black grouse +81 ptarmigan +82 ruffed grouse, partridge, Bonasa umbellus +83 prairie chicken, prairie grouse, prairie fowl +84 peacock +85 quail +86 partridge +87 African grey, African gray, Psittacus erithacus +88 macaw +89 sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita +90 lorikeet +91 coucal +92 bee eater +93 hornbill +94 hummingbird +95 jacamar +96 toucan +97 drake +98 red-breasted merganser, Mergus serrator +99 goose +100 black swan, Cygnus atratus +101 tusker +102 echidna, spiny anteater, anteater +103 platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus +104 wallaby, brush kangaroo +105 koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus +106 wombat +107 jellyfish +108 sea anemone, anemone +109 brain coral +110 flatworm, platyhelminth +111 nematode, nematode worm, roundworm +112 conch +113 snail +114 slug +115 sea slug, nudibranch +116 chiton, coat-of-mail shell, sea cradle, polyplacophore +117 chambered nautilus, pearly nautilus, nautilus +118 Dungeness crab, Cancer magister +119 rock crab, Cancer irroratus +120 fiddler crab +121 king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica +122 American lobster, Northern lobster, Maine lobster, Homarus americanus +123 spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish +124 crayfish, crawfish, crawdad, crawdaddy +125 hermit crab +126 isopod +127 white stork, Ciconia ciconia +128 black stork, Ciconia nigra +129 spoonbill +130 flamingo +131 little blue heron, Egretta caerulea +132 American egret, great white heron, Egretta albus +133 bittern +134 crane +135 limpkin, Aramus pictus +136 European gallinule, Porphyrio porphyrio +137 American coot, marsh hen, mud hen, water hen, Fulica americana +138 bustard +139 ruddy turnstone, Arenaria interpres +140 red-backed sandpiper, dunlin, Erolia alpina +141 redshank, Tringa totanus +142 dowitcher +143 oystercatcher, oyster catcher +144 pelican +145 king penguin, Aptenodytes patagonica +146 albatross, mollymawk +147 grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus +148 killer whale, killer, orca, grampus, sea wolf, Orcinus orca +149 dugong, Dugong dugon +150 sea lion +151 Chihuahua +152 Japanese spaniel +153 Maltese dog, Maltese terrier, Maltese +154 Pekinese, Pekingese, Peke +155 Shih-Tzu +156 Blenheim spaniel +157 papillon +158 toy terrier +159 Rhodesian ridgeback +160 Afghan hound, Afghan +161 basset, basset hound +162 beagle +163 bloodhound, sleuthhound +164 bluetick +165 black-and-tan coonhound +166 Walker hound, Walker foxhound +167 English foxhound +168 redbone +169 borzoi, Russian wolfhound +170 Irish wolfhound +171 Italian greyhound +172 whippet +173 Ibizan hound, Ibizan Podenco +174 Norwegian elkhound, elkhound +175 otterhound, otter hound +176 Saluki, gazelle hound +177 Scottish deerhound, deerhound +178 Weimaraner +179 Staffordshire bullterrier, Staffordshire bull terrier +180 American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier +181 Bedlington terrier +182 Border terrier +183 Kerry blue terrier +184 Irish terrier +185 Norfolk terrier +186 Norwich terrier +187 Yorkshire terrier +188 wire-haired fox terrier +189 Lakeland terrier +190 Sealyham terrier, Sealyham +191 Airedale, Airedale terrier +192 cairn, cairn terrier +193 Australian terrier +194 Dandie Dinmont, Dandie Dinmont terrier +195 Boston bull, Boston terrier +196 miniature schnauzer +197 giant schnauzer +198 standard schnauzer +199 Scotch terrier, Scottish terrier, Scottie +200 Tibetan terrier, chrysanthemum dog +201 silky terrier, Sydney silky +202 soft-coated wheaten terrier +203 West Highland white terrier +204 Lhasa, Lhasa apso +205 flat-coated retriever +206 curly-coated retriever +207 golden retriever +208 Labrador retriever +209 Chesapeake Bay retriever +210 German short-haired pointer +211 vizsla, Hungarian pointer +212 English setter +213 Irish setter, red setter +214 Gordon setter +215 Brittany spaniel +216 clumber, clumber spaniel +217 English springer, English springer spaniel +218 Welsh springer spaniel +219 cocker spaniel, English cocker spaniel, cocker +220 Sussex spaniel +221 Irish water spaniel +222 kuvasz +223 schipperke +224 groenendael +225 malinois +226 briard +227 kelpie +228 komondor +229 Old English sheepdog, bobtail +230 Shetland sheepdog, Shetland sheep dog, Shetland +231 collie +232 Border collie +233 Bouvier des Flandres, Bouviers des Flandres +234 Rottweiler +235 German shepherd, German shepherd dog, German police dog, alsatian +236 Doberman, Doberman pinscher +237 miniature pinscher +238 Greater Swiss Mountain dog +239 Bernese mountain dog +240 Appenzeller +241 EntleBucher +242 boxer +243 bull mastiff +244 Tibetan mastiff +245 French bulldog +246 Great Dane +247 Saint Bernard, St Bernard +248 Eskimo dog, husky +249 malamute, malemute, Alaskan malamute +250 Siberian husky +251 dalmatian, coach dog, carriage dog +252 affenpinscher, monkey pinscher, monkey dog +253 basenji +254 pug, pug-dog +255 Leonberg +256 Newfoundland, Newfoundland dog +257 Great Pyrenees +258 Samoyed, Samoyede +259 Pomeranian +260 chow, chow chow +261 keeshond +262 Brabancon griffon +263 Pembroke, Pembroke Welsh corgi +264 Cardigan, Cardigan Welsh corgi +265 toy poodle +266 miniature poodle +267 standard poodle +268 Mexican hairless +269 timber wolf, grey wolf, gray wolf, Canis lupus +270 white wolf, Arctic wolf, Canis lupus tundrarum +271 red wolf, maned wolf, Canis rufus, Canis niger +272 coyote, prairie wolf, brush wolf, Canis latrans +273 dingo, warrigal, warragal, Canis dingo +274 dhole, Cuon alpinus +275 African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus +276 hyena, hyaena +277 red fox, Vulpes vulpes +278 kit fox, Vulpes macrotis +279 Arctic fox, white fox, Alopex lagopus +280 grey fox, gray fox, Urocyon cinereoargenteus +281 tabby, tabby cat +282 tiger cat +283 Persian cat +284 Siamese cat, Siamese +285 Egyptian cat +286 cougar, puma, catamount, mountain lion, painter, panther, Felis concolor +287 lynx, catamount +288 leopard, Panthera pardus +289 snow leopard, ounce, Panthera uncia +290 jaguar, panther, Panthera onca, Felis onca +291 lion, king of beasts, Panthera leo +292 tiger, Panthera tigris +293 cheetah, chetah, Acinonyx jubatus +294 brown bear, bruin, Ursus arctos +295 American black bear, black bear, Ursus americanus, Euarctos americanus +296 ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus +297 sloth bear, Melursus ursinus, Ursus ursinus +298 mongoose +299 meerkat, mierkat +300 tiger beetle +301 ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle +302 ground beetle, carabid beetle +303 long-horned beetle, longicorn, longicorn beetle +304 leaf beetle, chrysomelid +305 dung beetle +306 rhinoceros beetle +307 weevil +308 fly +309 bee +310 ant, emmet, pismire +311 grasshopper, hopper +312 cricket +313 walking stick, walkingstick, stick insect +314 cockroach, roach +315 mantis, mantid +316 cicada, cicala +317 leafhopper +318 lacewing, lacewing fly +319 dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk +320 damselfly +321 admiral +322 ringlet, ringlet butterfly +323 monarch, monarch butterfly, milkweed butterfly, Danaus plexippus +324 cabbage butterfly +325 sulphur butterfly, sulfur butterfly +326 lycaenid, lycaenid butterfly +327 starfish, sea star +328 sea urchin +329 sea cucumber, holothurian +330 wood rabbit, cottontail, cottontail rabbit +331 hare +332 Angora, Angora rabbit +333 hamster +334 porcupine, hedgehog +335 fox squirrel, eastern fox squirrel, Sciurus niger +336 marmot +337 beaver +338 guinea pig, Cavia cobaya +339 sorrel +340 zebra +341 hog, pig, grunter, squealer, Sus scrofa +342 wild boar, boar, Sus scrofa +343 warthog +344 hippopotamus, hippo, river horse, Hippopotamus amphibius +345 ox +346 water buffalo, water ox, Asiatic buffalo, Bubalus bubalis +347 bison +348 ram, tup +349 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis +350 ibex, Capra ibex +351 hartebeest +352 impala, Aepyceros melampus +353 gazelle +354 Arabian camel, dromedary, Camelus dromedarius +355 llama +356 weasel +357 mink +358 polecat, fitch, foulmart, foumart, Mustela putorius +359 black-footed ferret, ferret, Mustela nigripes +360 otter +361 skunk, polecat, wood pussy +362 badger +363 armadillo +364 three-toed sloth, ai, Bradypus tridactylus +365 orangutan, orang, orangutang, Pongo pygmaeus +366 gorilla, Gorilla gorilla +367 chimpanzee, chimp, Pan troglodytes +368 gibbon, Hylobates lar +369 siamang, Hylobates syndactylus, Symphalangus syndactylus +370 guenon, guenon monkey +371 patas, hussar monkey, Erythrocebus patas +372 baboon +373 macaque +374 langur +375 colobus, colobus monkey +376 proboscis monkey, Nasalis larvatus +377 marmoset +378 capuchin, ringtail, Cebus capucinus +379 howler monkey, howler +380 titi, titi monkey +381 spider monkey, Ateles geoffroyi +382 squirrel monkey, Saimiri sciureus +383 Madagascar cat, ring-tailed lemur, Lemur catta +384 indri, indris, Indri indri, Indri brevicaudatus +385 Indian elephant, Elephas maximus +386 African elephant, Loxodonta africana +387 lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens +388 giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca +389 barracouta, snoek +390 eel +391 coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch +392 rock beauty, Holocanthus tricolor +393 anemone fish +394 sturgeon +395 gar, garfish, garpike, billfish, Lepisosteus osseus +396 lionfish +397 puffer, pufferfish, blowfish, globefish +398 abacus +399 abaya +400 academic gown, academic robe, judge's robe +401 accordion, piano accordion, squeeze box +402 acoustic guitar +403 aircraft carrier, carrier, flattop, attack aircraft carrier +404 airliner +405 airship, dirigible +406 altar +407 ambulance +408 amphibian, amphibious vehicle +409 analog clock +410 apiary, bee house +411 apron +412 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin +413 assault rifle, assault gun +414 backpack, back pack, knapsack, packsack, rucksack, haversack +415 bakery, bakeshop, bakehouse +416 balance beam, beam +417 balloon +418 ballpoint, ballpoint pen, ballpen, Biro +419 Band Aid +420 banjo +421 bannister, banister, balustrade, balusters, handrail +422 barbell +423 barber chair +424 barbershop +425 barn +426 barometer +427 barrel, cask +428 barrow, garden cart, lawn cart, wheelbarrow +429 baseball +430 basketball +431 bassinet +432 bassoon +433 bathing cap, swimming cap +434 bath towel +435 bathtub, bathing tub, bath, tub +436 beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon +437 beacon, lighthouse, beacon light, pharos +438 beaker +439 bearskin, busby, shako +440 beer bottle +441 beer glass +442 bell cote, bell cot +443 bib +444 bicycle-built-for-two, tandem bicycle, tandem +445 bikini, two-piece +446 binder, ring-binder +447 binoculars, field glasses, opera glasses +448 birdhouse +449 boathouse +450 bobsled, bobsleigh, bob +451 bolo tie, bolo, bola tie, bola +452 bonnet, poke bonnet +453 bookcase +454 bookshop, bookstore, bookstall +455 bottlecap +456 bow +457 bow tie, bow-tie, bowtie +458 brass, memorial tablet, plaque +459 brassiere, bra, bandeau +460 breakwater, groin, groyne, mole, bulwark, seawall, jetty +461 breastplate, aegis, egis +462 broom +463 bucket, pail +464 buckle +465 bulletproof vest +466 bullet train, bullet +467 butcher shop, meat market +468 cab, hack, taxi, taxicab +469 caldron, cauldron +470 candle, taper, wax light +471 cannon +472 canoe +473 can opener, tin opener +474 cardigan +475 car mirror +476 carousel, carrousel, merry-go-round, roundabout, whirligig +477 carpenter's kit, tool kit +478 carton +479 car wheel +480 cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM +481 cassette +482 cassette player +483 castle +484 catamaran +485 CD player +486 cello, violoncello +487 cellular telephone, cellular phone, cellphone, cell, mobile phone +488 chain +489 chainlink fence +490 chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour +491 chain saw, chainsaw +492 chest +493 chiffonier, commode +494 chime, bell, gong +495 china cabinet, china closet +496 Christmas stocking +497 church, church building +498 cinema, movie theater, movie theatre, movie house, picture palace +499 cleaver, meat cleaver, chopper +500 cliff dwelling +501 cloak +502 clog, geta, patten, sabot +503 cocktail shaker +504 coffee mug +505 coffeepot +506 coil, spiral, volute, whorl, helix +507 combination lock +508 computer keyboard, keypad +509 confectionery, confectionary, candy store +510 container ship, containership, container vessel +511 convertible +512 corkscrew, bottle screw +513 cornet, horn, trumpet, trump +514 cowboy boot +515 cowboy hat, ten-gallon hat +516 cradle +517 crane +518 crash helmet +519 crate +520 crib, cot +521 Crock Pot +522 croquet ball +523 crutch +524 cuirass +525 dam, dike, dyke +526 desk +527 desktop computer +528 dial telephone, dial phone +529 diaper, nappy, napkin +530 digital clock +531 digital watch +532 dining table, board +533 dishrag, dishcloth +534 dishwasher, dish washer, dishwashing machine +535 disk brake, disc brake +536 dock, dockage, docking facility +537 dogsled, dog sled, dog sleigh +538 dome +539 doormat, welcome mat +540 drilling platform, offshore rig +541 drum, membranophone, tympan +542 drumstick +543 dumbbell +544 Dutch oven +545 electric fan, blower +546 electric guitar +547 electric locomotive +548 entertainment center +549 envelope +550 espresso maker +551 face powder +552 feather boa, boa +553 file, file cabinet, filing cabinet +554 fireboat +555 fire engine, fire truck +556 fire screen, fireguard +557 flagpole, flagstaff +558 flute, transverse flute +559 folding chair +560 football helmet +561 forklift +562 fountain +563 fountain pen +564 four-poster +565 freight car +566 French horn, horn +567 frying pan, frypan, skillet +568 fur coat +569 garbage truck, dustcart +570 gasmask, respirator, gas helmet +571 gas pump, gasoline pump, petrol pump, island dispenser +572 goblet +573 go-kart +574 golf ball +575 golfcart, golf cart +576 gondola +577 gong, tam-tam +578 gown +579 grand piano, grand +580 greenhouse, nursery, glasshouse +581 grille, radiator grille +582 grocery store, grocery, food market, market +583 guillotine +584 hair slide +585 hair spray +586 half track +587 hammer +588 hamper +589 hand blower, blow dryer, blow drier, hair dryer, hair drier +590 hand-held computer, hand-held microcomputer +591 handkerchief, hankie, hanky, hankey +592 hard disc, hard disk, fixed disk +593 harmonica, mouth organ, harp, mouth harp +594 harp +595 harvester, reaper +596 hatchet +597 holster +598 home theater, home theatre +599 honeycomb +600 hook, claw +601 hoopskirt, crinoline +602 horizontal bar, high bar +603 horse cart, horse-cart +604 hourglass +605 iPod +606 iron, smoothing iron +607 jack-o'-lantern +608 jean, blue jean, denim +609 jeep, landrover +610 jersey, T-shirt, tee shirt +611 jigsaw puzzle +612 jinrikisha, ricksha, rickshaw +613 joystick +614 kimono +615 knee pad +616 knot +617 lab coat, laboratory coat +618 ladle +619 lampshade, lamp shade +620 laptop, laptop computer +621 lawn mower, mower +622 lens cap, lens cover +623 letter opener, paper knife, paperknife +624 library +625 lifeboat +626 lighter, light, igniter, ignitor +627 limousine, limo +628 liner, ocean liner +629 lipstick, lip rouge +630 Loafer +631 lotion +632 loudspeaker, speaker, speaker unit, loudspeaker system, speaker system +633 loupe, jeweler's loupe +634 lumbermill, sawmill +635 magnetic compass +636 mailbag, postbag +637 mailbox, letter box +638 maillot +639 maillot, tank suit +640 manhole cover +641 maraca +642 marimba, xylophone +643 mask +644 matchstick +645 maypole +646 maze, labyrinth +647 measuring cup +648 medicine chest, medicine cabinet +649 megalith, megalithic structure +650 microphone, mike +651 microwave, microwave oven +652 military uniform +653 milk can +654 minibus +655 miniskirt, mini +656 minivan +657 missile +658 mitten +659 mixing bowl +660 mobile home, manufactured home +661 Model T +662 modem +663 monastery +664 monitor +665 moped +666 mortar +667 mortarboard +668 mosque +669 mosquito net +670 motor scooter, scooter +671 mountain bike, all-terrain bike, off-roader +672 mountain tent +673 mouse, computer mouse +674 mousetrap +675 moving van +676 muzzle +677 nail +678 neck brace +679 necklace +680 nipple +681 notebook, notebook computer +682 obelisk +683 oboe, hautboy, hautbois +684 ocarina, sweet potato +685 odometer, hodometer, mileometer, milometer +686 oil filter +687 organ, pipe organ +688 oscilloscope, scope, cathode-ray oscilloscope, CRO +689 overskirt +690 oxcart +691 oxygen mask +692 packet +693 paddle, boat paddle +694 paddlewheel, paddle wheel +695 padlock +696 paintbrush +697 pajama, pyjama, pj's, jammies +698 palace +699 panpipe, pandean pipe, syrinx +700 paper towel +701 parachute, chute +702 parallel bars, bars +703 park bench +704 parking meter +705 passenger car, coach, carriage +706 patio, terrace +707 pay-phone, pay-station +708 pedestal, plinth, footstall +709 pencil box, pencil case +710 pencil sharpener +711 perfume, essence +712 Petri dish +713 photocopier +714 pick, plectrum, plectron +715 pickelhaube +716 picket fence, paling +717 pickup, pickup truck +718 pier +719 piggy bank, penny bank +720 pill bottle +721 pillow +722 ping-pong ball +723 pinwheel +724 pirate, pirate ship +725 pitcher, ewer +726 plane, carpenter's plane, woodworking plane +727 planetarium +728 plastic bag +729 plate rack +730 plow, plough +731 plunger, plumber's helper +732 Polaroid camera, Polaroid Land camera +733 pole +734 police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria +735 poncho +736 pool table, billiard table, snooker table +737 pop bottle, soda bottle +738 pot, flowerpot +739 potter's wheel +740 power drill +741 prayer rug, prayer mat +742 printer +743 prison, prison house +744 projectile, missile +745 projector +746 puck, hockey puck +747 punching bag, punch bag, punching ball, punchball +748 purse +749 quill, quill pen +750 quilt, comforter, comfort, puff +751 racer, race car, racing car +752 racket, racquet +753 radiator +754 radio, wireless +755 radio telescope, radio reflector +756 rain barrel +757 recreational vehicle, RV, R.V. +758 reel +759 reflex camera +760 refrigerator, icebox +761 remote control, remote +762 restaurant, eating house, eating place, eatery +763 revolver, six-gun, six-shooter +764 rifle +765 rocking chair, rocker +766 rotisserie +767 rubber eraser, rubber, pencil eraser +768 rugby ball +769 rule, ruler +770 running shoe +771 safe +772 safety pin +773 saltshaker, salt shaker +774 sandal +775 sarong +776 sax, saxophone +777 scabbard +778 scale, weighing machine +779 school bus +780 schooner +781 scoreboard +782 screen, CRT screen +783 screw +784 screwdriver +785 seat belt, seatbelt +786 sewing machine +787 shield, buckler +788 shoe shop, shoe-shop, shoe store +789 shoji +790 shopping basket +791 shopping cart +792 shovel +793 shower cap +794 shower curtain +795 ski +796 ski mask +797 sleeping bag +798 slide rule, slipstick +799 sliding door +800 slot, one-armed bandit +801 snorkel +802 snowmobile +803 snowplow, snowplough +804 soap dispenser +805 soccer ball +806 sock +807 solar dish, solar collector, solar furnace +808 sombrero +809 soup bowl +810 space bar +811 space heater +812 space shuttle +813 spatula +814 speedboat +815 spider web, spider's web +816 spindle +817 sports car, sport car +818 spotlight, spot +819 stage +820 steam locomotive +821 steel arch bridge +822 steel drum +823 stethoscope +824 stole +825 stone wall +826 stopwatch, stop watch +827 stove +828 strainer +829 streetcar, tram, tramcar, trolley, trolley car +830 stretcher +831 studio couch, day bed +832 stupa, tope +833 submarine, pigboat, sub, U-boat +834 suit, suit of clothes +835 sundial +836 sunglass +837 sunglasses, dark glasses, shades +838 sunscreen, sunblock, sun blocker +839 suspension bridge +840 swab, swob, mop +841 sweatshirt +842 swimming trunks, bathing trunks +843 swing +844 switch, electric switch, electrical switch +845 syringe +846 table lamp +847 tank, army tank, armored combat vehicle, armoured combat vehicle +848 tape player +849 teapot +850 teddy, teddy bear +851 television, television system +852 tennis ball +853 thatch, thatched roof +854 theater curtain, theatre curtain +855 thimble +856 thresher, thrasher, threshing machine +857 throne +858 tile roof +859 toaster +860 tobacco shop, tobacconist shop, tobacconist +861 toilet seat +862 torch +863 totem pole +864 tow truck, tow car, wrecker +865 toyshop +866 tractor +867 trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi +868 tray +869 trench coat +870 tricycle, trike, velocipede +871 trimaran +872 tripod +873 triumphal arch +874 trolleybus, trolley coach, trackless trolley +875 trombone +876 tub, vat +877 turnstile +878 typewriter keyboard +879 umbrella +880 unicycle, monocycle +881 upright, upright piano +882 vacuum, vacuum cleaner +883 vase +884 vault +885 velvet +886 vending machine +887 vestment +888 viaduct +889 violin, fiddle +890 volleyball +891 waffle iron +892 wall clock +893 wallet, billfold, notecase, pocketbook +894 wardrobe, closet, press +895 warplane, military plane +896 washbasin, handbasin, washbowl, lavabo, wash-hand basin +897 washer, automatic washer, washing machine +898 water bottle +899 water jug +900 water tower +901 whiskey jug +902 whistle +903 wig +904 window screen +905 window shade +906 Windsor tie +907 wine bottle +908 wing +909 wok +910 wooden spoon +911 wool, woolen, woollen +912 worm fence, snake fence, snake-rail fence, Virginia fence +913 wreck +914 yawl +915 yurt +916 web site, website, internet site, site +917 comic book +918 crossword puzzle, crossword +919 street sign +920 traffic light, traffic signal, stoplight +921 book jacket, dust cover, dust jacket, dust wrapper +922 menu +923 plate +924 guacamole +925 consomme +926 hot pot, hotpot +927 trifle +928 ice cream, icecream +929 ice lolly, lolly, lollipop, popsicle +930 French loaf +931 bagel, beigel +932 pretzel +933 cheeseburger +934 hotdog, hot dog, red hot +935 mashed potato +936 head cabbage +937 broccoli +938 cauliflower +939 zucchini, courgette +940 spaghetti squash +941 acorn squash +942 butternut squash +943 cucumber, cuke +944 artichoke, globe artichoke +945 bell pepper +946 cardoon +947 mushroom +948 Granny Smith +949 strawberry +950 orange +951 lemon +952 fig +953 pineapple, ananas +954 banana +955 jackfruit, jak, jack +956 custard apple +957 pomegranate +958 hay +959 carbonara +960 chocolate sauce, chocolate syrup +961 dough +962 meat loaf, meatloaf +963 pizza, pizza pie +964 potpie +965 burrito +966 red wine +967 espresso +968 cup +969 eggnog +970 alp +971 bubble +972 cliff, drop, drop-off +973 coral reef +974 geyser +975 lakeside, lakeshore +976 promontory, headland, head, foreland +977 sandbar, sand bar +978 seashore, coast, seacoast, sea-coast +979 valley, vale +980 volcano +981 ballplayer, baseball player +982 groom, bridegroom +983 scuba diver +984 rapeseed +985 daisy +986 yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum +987 corn +988 acorn +989 hip, rose hip, rosehip +990 buckeye, horse chestnut, conker +991 coral fungus +992 agaric +993 gyromitra +994 stinkhorn, carrion fungus +995 earthstar +996 hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa +997 bolete +998 ear, spike, capitulum +999 toilet tissue, toilet paper, bathroom tissue diff --git a/src/PaddleClas/deploy/utils/logger.py b/src/PaddleClas/deploy/utils/logger.py new file mode 100644 index 0000000..ece8526 --- /dev/null +++ b/src/PaddleClas/deploy/utils/logger.py @@ -0,0 +1,120 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import logging +import os +import datetime + +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s %(levelname)s: %(message)s", + datefmt="%Y-%m-%d %H:%M:%S") + + +def time_zone(sec, fmt): + real_time = datetime.datetime.now() + return real_time.timetuple() + + +logging.Formatter.converter = time_zone +_logger = logging.getLogger(__name__) + +Color = { + 'RED': '\033[31m', + 'HEADER': '\033[35m', # deep purple + 'PURPLE': '\033[95m', # purple + 'OKBLUE': '\033[94m', + 'OKGREEN': '\033[92m', + 'WARNING': '\033[93m', + 'FAIL': '\033[91m', + 'ENDC': '\033[0m' +} + + +def coloring(message, color="OKGREEN"): + assert color in Color.keys() + if os.environ.get('PADDLECLAS_COLORING', False): + return Color[color] + str(message) + Color["ENDC"] + else: + return message + + +def anti_fleet(log): + """ + logs will print multi-times when calling Fleet API. + Only display single log and ignore the others. + """ + + def wrapper(fmt, *args): + if int(os.getenv("PADDLE_TRAINER_ID", 0)) == 0: + log(fmt, *args) + + return wrapper + + +@anti_fleet +def info(fmt, *args): + _logger.info(fmt, *args) + + +@anti_fleet +def warning(fmt, *args): + _logger.warning(coloring(fmt, "RED"), *args) + + +@anti_fleet +def error(fmt, *args): + _logger.error(coloring(fmt, "FAIL"), *args) + + +def scaler(name, value, step, writer): + """ + This function will draw a scalar curve generated by the visualdl. + Usage: Install visualdl: pip3 install visualdl==2.0.0b4 + and then: + visualdl --logdir ./scalar --host 0.0.0.0 --port 8830 + to preview loss corve in real time. + """ + writer.add_scalar(tag=name, step=step, value=value) + + +def advertise(): + """ + Show the advertising message like the following: + + =========================================================== + == PaddleClas is powered by PaddlePaddle ! == + =========================================================== + == == + == For more info please go to the following website. == + == == + == https://github.com/PaddlePaddle/PaddleClas == + =========================================================== + + """ + copyright = "PaddleClas is powered by PaddlePaddle !" + ad = "For more info please go to the following website." + website = "https://github.com/PaddlePaddle/PaddleClas" + AD_LEN = 6 + len(max([copyright, ad, website], key=len)) + + info( + coloring("\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}\n".format( + "=" * (AD_LEN + 4), + "=={}==".format(copyright.center(AD_LEN)), + "=" * (AD_LEN + 4), + "=={}==".format(' ' * AD_LEN), + "=={}==".format(ad.center(AD_LEN)), + "=={}==".format(' ' * AD_LEN), + "=={}==".format(website.center(AD_LEN)), + "=" * (AD_LEN + 4), ), "RED")) diff --git a/src/PaddleClas/deploy/utils/predictor.py b/src/PaddleClas/deploy/utils/predictor.py new file mode 100644 index 0000000..7fd1d6d --- /dev/null +++ b/src/PaddleClas/deploy/utils/predictor.py @@ -0,0 +1,95 @@ +# 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. +import platform +import os +import argparse +import base64 +import shutil +import cv2 +import numpy as np + +from paddle.inference import Config +from paddle.inference import create_predictor + + +class Predictor(object): + def __init__(self, args, inference_model_dir=None): + # HALF precission predict only work when using tensorrt + if args.use_fp16 is True: + assert args.use_tensorrt is True + self.args = args + if self.args.get("use_onnx", False): + self.predictor, self.config = self.create_onnx_predictor( + args, inference_model_dir) + else: + self.predictor, self.config = self.create_paddle_predictor( + args, inference_model_dir) + + def predict(self, image): + raise NotImplementedError + + def create_paddle_predictor(self, args, inference_model_dir=None): + if inference_model_dir is None: + inference_model_dir = args.inference_model_dir + params_file = os.path.join(inference_model_dir, "inference.pdiparams") + model_file = os.path.join(inference_model_dir, "inference.pdmodel") + config = Config(model_file, params_file) + + if args.use_gpu: + config.enable_use_gpu(args.gpu_mem, 0) + else: + config.disable_gpu() + if args.enable_mkldnn: + # there is no set_mkldnn_cache_capatity() on macOS + if platform.system() != "Darwin": + # cache 10 different shapes for mkldnn to avoid memory leak + config.set_mkldnn_cache_capacity(10) + config.enable_mkldnn() + config.set_cpu_math_library_num_threads(args.cpu_num_threads) + + if args.enable_profile: + config.enable_profile() + config.disable_glog_info() + config.switch_ir_optim(args.ir_optim) # default true + if args.use_tensorrt: + config.enable_tensorrt_engine( + precision_mode=Config.Precision.Half + if args.use_fp16 else Config.Precision.Float32, + max_batch_size=args.batch_size, + workspace_size=1 << 30, + min_subgraph_size=30) + + config.enable_memory_optim() + # use zero copy + config.switch_use_feed_fetch_ops(False) + predictor = create_predictor(config) + + return predictor, config + + def create_onnx_predictor(self, args, inference_model_dir=None): + import onnxruntime as ort + if inference_model_dir is None: + inference_model_dir = args.inference_model_dir + model_file = os.path.join(inference_model_dir, "inference.onnx") + config = ort.SessionOptions() + if args.use_gpu: + raise ValueError( + "onnx inference now only supports cpu! please specify use_gpu false." + ) + else: + config.intra_op_num_threads = args.cpu_num_threads + if args.ir_optim: + config.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL + predictor = ort.InferenceSession(model_file, sess_options=config) + return predictor, config diff --git a/src/PaddleClas/deploy/utils/simfang.ttf b/src/PaddleClas/deploy/utils/simfang.ttf new file mode 100644 index 0000000..2b59eae Binary files /dev/null and b/src/PaddleClas/deploy/utils/simfang.ttf differ diff --git a/src/PaddleClas/deploy/vector_search/Makefile b/src/PaddleClas/deploy/vector_search/Makefile new file mode 100644 index 0000000..ec2df59 --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/Makefile @@ -0,0 +1,15 @@ +CXX=g++ + +ifeq ($(OS),Windows_NT) + postfix=dll +else + postfix=so +endif + +all : index + +index : src/config.h src/graph.h src/data.h interface.cc + ${CXX} -shared -fPIC interface.cc -o index.${postfix} -std=c++11 -Ofast -march=native -g -flto -funroll-loops -DOMP -fopenmp + +clean : + rm index.${postfix} \ No newline at end of file diff --git a/src/PaddleClas/deploy/vector_search/README.md b/src/PaddleClas/deploy/vector_search/README.md new file mode 100644 index 0000000..afa1dc2 --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/README.md @@ -0,0 +1,93 @@ +# 向量检索 + +**注意**:由于系统适配性问题,在新版本中,此检索算法将被废弃。新版本中将使用[faiss](https://github.com/facebookresearch/faiss),整体检索的过程保持不变,但建立索引及检索时的yaml文件有所修改。 +## 1. 简介 + +一些垂域识别任务(如车辆、商品等)需要识别的类别数较大,往往采用基于检索的方式,通过查询向量与底库向量进行快速的最近邻搜索,获得匹配的预测类别。向量检索模块提供基础的近似最近邻搜索算法,基于百度自研的Möbius算法,一种基于图的近似最近邻搜索算法,用于最大内积搜索 (MIPS)。 该模块提供python接口,支持numpy和 tensor类型向量,支持L2和Inner Product距离计算。 + +Mobius 算法细节详见论文 ([Möbius Transformation for Fast Inner Product Search on Graph](http://research.baidu.com/Public/uploads/5e189d36b5cf6.PDF), [Code](https://github.com/sunbelbd/mobius)) + + + +## 2. 安装 + +### 2.1 直接使用提供的库文件 + +该文件夹下有已经编译好的`index.so`(gcc8.2.0下编译,用于Linux)以及`index.dll`(gcc10.3.0下编译,用于Windows),可以跳过2.2与2.3节,直接使用。 + +如果因为gcc版本过低或者环境不兼容的问题,导致库文件无法使用,则需要在不同的平台下手动编译库文件。 + +**注意:** +请确保您的 C++ 编译器支持 C++11 标准。 + + +### 2.2 Linux上编译生成库文件 + +运行下面的命令,安装gcc与g++。 + +```shell +sudo apt-get update +sudo apt-get upgrade -y +sudo apt-get install build-essential gcc g++ +``` + +可以通过命令`gcc -v`查看gcc版本。 + +进入该文件夹,直接运行`make`即可,如果希望重新生成`index.so`文件,可以首先使用`make clean`清除已经生成的缓存,再使用`make`生成更新之后的库文件。 + +### 2.3 Windows上编译生成库文件 + +Windows上首先需要安装gcc编译工具,推荐使用[TDM-GCC](https://jmeubank.github.io/tdm-gcc/articles/2020-03/9.2.0-release),进入官网之后,可以选择合适的版本进行下载。推荐下载[tdm64-gcc-10.3.0-2.exe](https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm64-2/tdm64-gcc-10.3.0-2.exe)。 + +下载完成之后,按照默认的安装步骤进行安装即可。这里有3点需要注意: +1. 向量检索模块依赖于openmp,因此在安装到`choose components`步骤的时候,需要勾选上`openmp`的安装选项,否则之后编译的时候会报错`libgomp.spec: No such file or directory`,[参考链接](https://github.com/dmlc/xgboost/issues/1027) +2. 安装过程中会提示是否需要添加到系统的环境变量中,这里建议勾选上,否则之后使用的时候还需要手动添加系统环境变量。 +3. Linux上的编译命令为`make`,Windows上为`mingw32-make`,这里需要区分一下。 + + +安装完成后,可以打开一个命令行终端,通过命令`gcc -v`查看gcc版本。 + +在该文件夹(deploy/vector_search)下,运行命令`mingw32-make`,即可生成`index.dll`库文件。如果希望重新生成`index.dll`文件,可以首先使用`mingw32-make clean`清除已经生成的缓存,再使用`mingw32-make`生成更新之后的库文件。 + +### 2.4 MacOS上编译生成库文件 + +运行下面的命令,安装gcc与g++: + +```shell +brew install gcc +``` +#### 注意: +1. 若提示 `Error: Running Homebrew as root is extremely dangerous and no longer supported...`, 参考该[链接](https://jingyan.baidu.com/article/e52e3615057a2840c60c519c.html)处理 +2. 若提示 `Error: Failure while executing; `tar --extract --no-same-owner --file...`, 参考该[链接](https://blog.csdn.net/Dawn510/article/details/117787358)处理 + +在安装之后编译后的可执行程序会被复制到/usr/local/bin下面,查看这个文件夹下的gcc: +``` +ls /usr/local/bin/gcc* +``` +可以看到本地gcc对应的版本号为gcc-11,编译命令如下: (如果本地gcc版本为gcc-9, 则相应命令修改为`CXX=g++-9 make`) +``` +CXX=g++-11 make +``` + +## 3. 快速使用 + + import numpy as np + from interface import Graph_Index + + # 随机产生样本 + index_vectors = np.random.rand(100000,128).astype(np.float32) + query_vector = np.random.rand(128).astype(np.float32) + index_docs = ["ID_"+str(i) for i in range(100000)] + + # 初始化索引结构 + indexer = Graph_Index(dist_type="IP") #支持"IP"和"L2" + indexer.build(gallery_vectors=index_vectors, gallery_docs=index_docs, pq_size=100, index_path='test') + + # 查询 + scores, docs = indexer.search(query=query_vector, return_k=10, search_budget=100) + print(scores) + print(docs) + + # 保存与加载 + indexer.dump(index_path="test") + indexer.load(index_path="test") diff --git a/src/PaddleClas/deploy/vector_search/README_en.md b/src/PaddleClas/deploy/vector_search/README_en.md new file mode 100644 index 0000000..aecadfd --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/README_en.md @@ -0,0 +1,97 @@ +# Vector search + +**Attention**: Due to the system adaptability problem, this retrieval algorithm will be abandoned in the new version. [faiss](https://github.com/facebookresearch/faiss) will be used in the new version. The use process of the overall retrieval system base will remain unchanged, but the yaml files for build indexes and retrieval will be modified. + +## 1. Introduction + +Some vertical domain recognition tasks (e.g., vehicles, commodities, etc.) require a large number of recognized categories, and often use a retrieval-based approach to obtain matching predicted categories by performing a fast nearest neighbor search with query vectors and underlying library vectors. The vector search module provides the basic approximate nearest neighbor search algorithm based on Baidu's self-developed Möbius algorithm, a graph-based approximate nearest neighbor search algorithm for maximum inner product search (MIPS). This module provides python interface, supports numpy and tensor type vectors, and supports L2 and Inner Product distance calculation. + +Details of the Mobius algorithm can be found in the paper.([Möbius Transformation for Fast Inner Product Search on Graph](http://research.baidu.com/Public/uploads/5e189d36b5cf6.PDF), [Code](https://github.com/sunbelbd/mobius)) + +## 2. Installation + +### 2.1 Use the provided library files directly + +This folder contains the compiled `index.so` (compiled under gcc8.2.0 for Linux) and `index.dll` (compiled under gcc10.3.0 for Windows), which can be used directly, skipping sections 2.2 and 2.3. + +If the library files are not available due to a low gcc version or an incompatible environment, you need to manually compile the library files under a different platform. + +**Note:** Make sure that C++ compiler supports the C++11 standard. + +### 2.2 Compile and generate library files on Linux + +Run the following command to install gcc and g++. + +``` +sudo apt-get update +sudo apt-get upgrade -y +sudo apt-get install build-essential gcc g++ +``` + +Check the gcc version by the command `gcc -v`. + +`make` can be operated directly. If you wish to regenerate the `index.so`, you can first use `make clean` to clear the cache, and then use `make` to generate the updated library file. + +### 2.3 Compile and generate library files on Windows + +You need to install gcc compiler tool first, we recommend using [TDM-GCC](https://jmeubank.github.io/tdm-gcc/articles/2020-03/9.2.0-release), you can choose the right version on the official website. We recommend downloading [tdm64-gcc-10.3.0-2.exe](https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm64-2/tdm64-gcc-10.3.0-2.exe). + +After the downloading, follow the default installation steps to install. There are 3 points to note here: + +1. The vector search module depends on openmp, so you need to check the `openmp` installation option when going on to `choose components` step, otherwise it will report an error `libgomp.spec: No such file or directory`, [reference link](https://github.com/dmlc/xgboost/issues/1027) +2. When being asked whether to add to the system environment variables, it is recommended to check here, otherwise you need to add the system environment variables manually later. +3. The compile command is `make` on Linux and `mingw32-make` on Windows, so you need to distinguish here. + +After installation, you can open a command line terminal and check the gcc version with the command `gcc -v`. + +Run the command `mingw32-make` to generate the `index.dll` library file under the folder (deploy/vector_search). If you want to regenerate the `index.dll` file, you can first use `mingw32-make clean` to clear the cache, and then use `mingw32-make` to generate the updated library file. + +### 2.4 Compile and generate library files on MacOS + +Run the following command to install gcc and g++: + +``` +brew install gcc +``` + +#### Caution: + +1. If prompted with `Error: Running Homebrew as root is extremely dangerous and no longer supported... `, refer to this [link](https://jingyan.baidu.com/article/e52e3615057a2840c60c519c.html) +2. If prompted with `Error: Failure while executing; tar --extract --no-same-owner --file... `, refer to this [link](https://blog.csdn.net/Dawn510/article/details/117787358). + +After installation the compiled executable is copied under /usr/local/bin, look at the gcc in this folder: + +``` +ls /usr/local/bin/gcc* +``` + +The local gcc version is gcc-11, and the compile command is as follows: (If the local gcc version is gcc-9, the corresponding command should be `CXX=g++-9 make`) + +``` +CXX=g++-11 make +``` + +## 3. Quick use + +``` +import numpy as np +from interface import Graph_Index + +# Random sample generation +index_vectors = np.random.rand(100000,128).astype(np.float32) +query_vector = np.random.rand(128).astype(np.float32) +index_docs = ["ID_"+str(i) for i in range(100000)] + +# Initialize index structure +indexer = Graph_Index(dist_type="IP") #support "IP" and "L2" +indexer.build(gallery_vectors=index_vectors, gallery_docs=index_docs, pq_size=100, index_path='test') + +# Query +scores, docs = indexer.search(query=query_vector, return_k=10, search_budget=100) +print(scores) +print(docs) + +# Save and load +indexer.dump(index_path="test") +indexer.load(index_path="test") +``` diff --git a/src/PaddleClas/deploy/vector_search/__init__.py b/src/PaddleClas/deploy/vector_search/__init__.py new file mode 100644 index 0000000..4ee26df --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/__init__.py @@ -0,0 +1 @@ +from .interface import Graph_Index diff --git a/src/PaddleClas/deploy/vector_search/index.dll b/src/PaddleClas/deploy/vector_search/index.dll new file mode 100644 index 0000000..5d54753 Binary files /dev/null and b/src/PaddleClas/deploy/vector_search/index.dll differ diff --git a/src/PaddleClas/deploy/vector_search/index.so b/src/PaddleClas/deploy/vector_search/index.so new file mode 100644 index 0000000..d58d4f7 Binary files /dev/null and b/src/PaddleClas/deploy/vector_search/index.so differ diff --git a/src/PaddleClas/deploy/vector_search/interface.cc b/src/PaddleClas/deploy/vector_search/interface.cc new file mode 100644 index 0000000..4013668 --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/interface.cc @@ -0,0 +1,266 @@ +//MIT License +// +//Copyright (c) 2021 Mobius Authors + +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files (the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions: + +//The above copyright notice and this permission notice shall be included in all +//copies or substantial portions of the Software. + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//SOFTWARE. + +//from https://github.com/sunbelbd/mobius/blob/e2d166547d61d791da8f06747a63b9cd38f02c71/main.cc + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include"src/data.h" +#include"src/graph.h" + +struct IndexContext{ + void* graph; + void* data; +}; + + +int topk = 0; +int display_topk = 1; +int build_idx_offset = 0; +int query_idx_offset = 0; + +void flush_add_buffer( + std::vector>>>& add_buffer, + GraphWrapper* graph){ + #pragma omp parallel for + for(int i = 0;i < add_buffer.size();++i){ + auto& idx = add_buffer[i].first; + auto& point = add_buffer[i].second; + graph->add_vertex_lock(idx,point); + } + add_buffer.clear(); +} + + +extern "C"{ +// for mobius IP index +void build_mobius_index(float* dense_mat,int row,int dim, int pq_size, double mobius_pow , const char* prefix){ + std::unique_ptr data; + std::unique_ptr data_original; + std::unique_ptr graph; + int topk = 0; + int display_topk = 1; + int build_idx_offset = 0; + int query_idx_offset = 0; + + ++row; + data = std::unique_ptr(new Data(row,dim)); + graph = std::unique_ptr(new FixedDegreeGraph<3>(data.get())); + graph->set_construct_pq_size(pq_size); + + std::vector>>> add_buffer; + + ((FixedDegreeGraph<3>*)graph.get())->get_data()->mobius_pow = mobius_pow; + data_original = std::unique_ptr(new Data(row,dim)); + + std::vector> dummy_mobius_point; + for(int i = 0;i < dim;++i) + dummy_mobius_point.push_back(std::make_pair(i,0)); + + //idx += build_idx_offset; + + for(int i = 0;i < row - 1;++i){ + + std::vector> point; + point.reserve(dim); + for(int j = 0;j < dim;++j) + point.push_back(std::make_pair(j,dense_mat[i * dim + j])); + + data_original->add(i,point); + data->add_mobius(i,point); + if(i < 1000){ + graph->add_vertex(i,point); + }else{ + add_buffer.push_back(std::make_pair(i,point)); + } + if(add_buffer.size() >= 1000000) + flush_add_buffer(add_buffer,graph.get()); + } + flush_add_buffer(add_buffer,graph.get()); + graph->add_vertex(row - 1,dummy_mobius_point); + data.swap(data_original); + + std::string str = std::string(prefix); + data->dump(str + ".data"); + graph->dump(str + ".graph"); + +} + +void load_mobius_index_prefix(int row,int dim,IndexContext* index_context,const char* prefix){ + std::string str = std::string(prefix); + + ++row; + Data* data = new Data(row,dim); + GraphWrapper* graph = new FixedDegreeGraph<1>(data); + + //idx += build_idx_offset; + data->load(str + ".data"); + graph->load(str + ".graph"); + + ((FixedDegreeGraph<1>*)graph)->search_start_point = row - 1; + ((FixedDegreeGraph<1>*)graph)->ignore_startpoint = true; + + index_context->graph = graph; + index_context->data = data; +} + +void save_mobius_index_prefix(IndexContext* index_context,const char* prefix){ + std::string str = std::string(prefix); + Data* data = (Data*)(index_context->data); + GraphWrapper* graph = (GraphWrapper*)(index_context->graph); + + data->dump(str + ".data"); + graph->dump(str + ".graph"); +} + +void search_mobius_index(float* dense_vec,int dim,int search_budget,int return_k, IndexContext* index_context,idx_t* ret_id,double* ret_score){ + int topk = 0; + int display_topk = 1; + int build_idx_offset = 0; + int query_idx_offset = 0; + + Data* data = reinterpret_cast(index_context->data); + GraphWrapper* graph = reinterpret_cast(index_context->graph); + + + //auto flag = (data==NULL); + //std::cout<> point; + point.reserve(dim); + for(int j = 0;j < dim;++j) + point.push_back(std::make_pair(j,dense_vec[j])); + std::vector topN; + std::vector score; + graph->search_top_k_with_score(point,search_budget,topN,score); + for(int i = 0;i < topN.size() && i < return_k;++i){ + ret_id[i] = topN[i]; + ret_score[i] = score[i]; + } +} + + +// For L2 index +void build_l2_index(float* dense_mat,int row,int dim, int pq_size, const char* prefix){ + std::unique_ptr data; + std::unique_ptr graph; + int topk = 0; + int display_topk = 1; + int build_idx_offset = 0; + int query_idx_offset = 0; + + data = std::unique_ptr(new Data(row,dim)); + graph = std::unique_ptr(new FixedDegreeGraph<3>(data.get())); + graph->set_construct_pq_size(pq_size); + + std::vector>>> add_buffer; + + for(int i = 0;i < row;++i){ + std::vector> point; + point.reserve(dim); + for(int j = 0;j < dim;++j) + point.push_back(std::make_pair(j,dense_mat[i * dim + j])); + data->add(i,point); + if(i < 1000){ + graph->add_vertex(i,point); + }else{ + add_buffer.push_back(std::make_pair(i,point)); + } + if(add_buffer.size() >= 1000000) + flush_add_buffer(add_buffer,graph.get()); + } + flush_add_buffer(add_buffer,graph.get()); + + std::string str = std::string(prefix); + data->dump(str + ".data"); + graph->dump(str + ".graph"); + +} + +void load_l2_index_prefix(int row,int dim,IndexContext* index_context,const char* prefix){ + std::string str = std::string(prefix); + + Data* data = new Data(row,dim); + GraphWrapper* graph = new FixedDegreeGraph<3>(data); + + //idx += build_idx_offset; + + data->load(str + ".data"); + graph->load(str + ".graph"); + + index_context->graph = graph; + index_context->data = data; +} + +void save_l2_index_prefix(IndexContext* index_context,const char* prefix){ + std::string str = std::string(prefix); + Data* data = (Data*)(index_context->data); + GraphWrapper* graph = (GraphWrapper*)(index_context->graph); + + data->dump(str + ".data"); + graph->dump(str + ".graph"); +} + + + +void search_l2_index(float* dense_vec,int dim,int search_budget,int return_k, IndexContext* index_context,idx_t* ret_id,double* ret_score){ + int topk = 0; + int display_topk = 1; + int build_idx_offset = 0; + int query_idx_offset = 0; + + Data* data = reinterpret_cast(index_context->data); + GraphWrapper* graph = reinterpret_cast(index_context->graph); + + std::vector> point; + point.reserve(dim); + for(int j = 0;j < dim;++j) + point.push_back(std::make_pair(j,dense_vec[j])); + std::vector topN; + std::vector score; + graph->search_top_k_with_score(point,search_budget,topN,score); + for(int i = 0;i < topN.size() && i < return_k;++i){ +// printf("%d: (%zu, %f)\n",i,topN[i],score[i]); + ret_id[i] = topN[i]; + ret_score[i] = score[i]; + } +} + + +void release_context(IndexContext* index_context){ + delete (Data*)(index_context->data); + delete (GraphWrapper*)(index_context->graph); +} + +} // extern "C" + diff --git a/src/PaddleClas/deploy/vector_search/interface.py b/src/PaddleClas/deploy/vector_search/interface.py new file mode 100644 index 0000000..8dcd86f --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/interface.py @@ -0,0 +1,272 @@ +# Copyright (c) 2021 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. + +import ctypes +import paddle +import numpy.ctypeslib as ctl +import numpy as np +import os +import sys +import json +import platform + +from ctypes import * +from numpy.ctypeslib import ndpointer + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +winmode = None +if platform.system() == "Windows": + lib_filename = "index.dll" + if sys.version_info.minor >= 8: + winmode = 0x8 +else: + lib_filename = "index.so" +so_path = os.path.join(__dir__, lib_filename) +try: + if winmode is not None: + lib = ctypes.CDLL(so_path, winmode=winmode) + else: + lib = ctypes.CDLL(so_path) +except Exception as ex: + readme_path = os.path.join(__dir__, "README.md") + print( + f"Error happened when load lib {so_path} with msg {ex},\nplease refer to {readme_path} to rebuild your library." + ) + exit(-1) + + +class IndexContext(Structure): + _fields_ = [("graph", c_void_p), ("data", c_void_p)] + + +# for mobius IP index +build_mobius_index = lib.build_mobius_index +build_mobius_index.restype = None +build_mobius_index.argtypes = [ + ctl.ndpointer( + np.float32, flags='aligned, c_contiguous'), ctypes.c_int, ctypes.c_int, + ctypes.c_int, ctypes.c_double, ctypes.c_char_p +] + +search_mobius_index = lib.search_mobius_index +search_mobius_index.restype = None +search_mobius_index.argtypes = [ + ctl.ndpointer( + np.float32, flags='aligned, c_contiguous'), ctypes.c_int, ctypes.c_int, + ctypes.c_int, POINTER(IndexContext), ctl.ndpointer( + np.uint64, flags='aligned, c_contiguous'), ctl.ndpointer( + np.float64, flags='aligned, c_contiguous') +] + +load_mobius_index_prefix = lib.load_mobius_index_prefix +load_mobius_index_prefix.restype = None +load_mobius_index_prefix.argtypes = [ + ctypes.c_int, ctypes.c_int, POINTER(IndexContext), ctypes.c_char_p +] + +save_mobius_index_prefix = lib.save_mobius_index_prefix +save_mobius_index_prefix.restype = None +save_mobius_index_prefix.argtypes = [POINTER(IndexContext), ctypes.c_char_p] + +# for L2 index +build_l2_index = lib.build_l2_index +build_l2_index.restype = None +build_l2_index.argtypes = [ + ctl.ndpointer( + np.float32, flags='aligned, c_contiguous'), ctypes.c_int, ctypes.c_int, + ctypes.c_int, ctypes.c_char_p +] + +search_l2_index = lib.search_l2_index +search_l2_index.restype = None +search_l2_index.argtypes = [ + ctl.ndpointer( + np.float32, flags='aligned, c_contiguous'), ctypes.c_int, ctypes.c_int, + ctypes.c_int, POINTER(IndexContext), ctl.ndpointer( + np.uint64, flags='aligned, c_contiguous'), ctl.ndpointer( + np.float64, flags='aligned, c_contiguous') +] + +load_l2_index_prefix = lib.load_l2_index_prefix +load_l2_index_prefix.restype = None +load_l2_index_prefix.argtypes = [ + ctypes.c_int, ctypes.c_int, POINTER(IndexContext), ctypes.c_char_p +] + +save_l2_index_prefix = lib.save_l2_index_prefix +save_l2_index_prefix.restype = None +save_l2_index_prefix.argtypes = [POINTER(IndexContext), ctypes.c_char_p] + +release_context = lib.release_context +release_context.restype = None +release_context.argtypes = [POINTER(IndexContext)] + + +class Graph_Index(object): + """ + graph index + """ + + def __init__(self, dist_type="IP"): + self.dim = 0 + self.total_num = 0 + self.dist_type = dist_type + self.mobius_pow = 2.0 + self.index_context = IndexContext(0, 0) + self.gallery_doc_dict = {} + self.with_attr = False + assert dist_type in ["IP", "L2"], "Only support IP and L2 distance ..." + + def build(self, + gallery_vectors, + gallery_docs=[], + pq_size=100, + index_path='graph_index/', + append_index=False): + """ + build index + """ + if paddle.is_tensor(gallery_vectors): + gallery_vectors = gallery_vectors.numpy() + assert gallery_vectors.ndim == 2, "Input vector must be 2D ..." + + self.total_num = gallery_vectors.shape[0] + self.dim = gallery_vectors.shape[1] + + assert (len(gallery_docs) == self.total_num + if len(gallery_docs) > 0 else True) + + print("training index -> num: {}, dim: {}, dist_type: {}".format( + self.total_num, self.dim, self.dist_type)) + + if not os.path.exists(index_path): + os.makedirs(index_path) + + if self.dist_type == "IP": + build_mobius_index( + gallery_vectors, self.total_num, self.dim, pq_size, + self.mobius_pow, + create_string_buffer((index_path + "/index").encode('utf-8'))) + load_mobius_index_prefix( + self.total_num, self.dim, + ctypes.byref(self.index_context), + create_string_buffer((index_path + "/index").encode('utf-8'))) + else: + build_l2_index( + gallery_vectors, self.total_num, self.dim, pq_size, + create_string_buffer((index_path + "/index").encode('utf-8'))) + load_l2_index_prefix( + self.total_num, self.dim, + ctypes.byref(self.index_context), + create_string_buffer((index_path + "/index").encode('utf-8'))) + + self.gallery_doc_dict = {} + if len(gallery_docs) > 0: + self.with_attr = True + for i in range(gallery_vectors.shape[0]): + self.gallery_doc_dict[str(i)] = gallery_docs[i] + + self.gallery_doc_dict["total_num"] = self.total_num + self.gallery_doc_dict["dim"] = self.dim + self.gallery_doc_dict["dist_type"] = self.dist_type + self.gallery_doc_dict["with_attr"] = self.with_attr + + output_path = os.path.join(index_path, "info.json") + if append_index is True and os.path.exists(output_path): + with open(output_path, "r") as fin: + lines = fin.readlines()[0] + ori_gallery_doc_dict = json.loads(lines) + assert ori_gallery_doc_dict["dist_type"] == self.gallery_doc_dict[ + "dist_type"] + assert ori_gallery_doc_dict["dim"] == self.gallery_doc_dict["dim"] + assert ori_gallery_doc_dict["with_attr"] == self.gallery_doc_dict[ + "with_attr"] + offset = ori_gallery_doc_dict["total_num"] + for i in range(0, self.gallery_doc_dict["total_num"]): + ori_gallery_doc_dict[str(i + offset)] = self.gallery_doc_dict[ + str(i)] + + ori_gallery_doc_dict["total_num"] += self.gallery_doc_dict[ + "total_num"] + self.gallery_doc_dict = ori_gallery_doc_dict + with open(output_path, "w") as f: + json.dump(self.gallery_doc_dict, f) + + print("finished creating index ...") + + def search(self, query, return_k=10, search_budget=100): + """ + search + """ + ret_id = np.zeros(return_k, dtype=np.uint64) + ret_score = np.zeros(return_k, dtype=np.float64) + + if paddle.is_tensor(query): + query = query.numpy() + if self.dist_type == "IP": + search_mobius_index(query, self.dim, search_budget, return_k, + ctypes.byref(self.index_context), ret_id, + ret_score) + else: + search_l2_index(query, self.dim, search_budget, return_k, + ctypes.byref(self.index_context), ret_id, + ret_score) + + ret_id = ret_id.tolist() + ret_doc = [] + if self.with_attr: + for i in range(return_k): + ret_doc.append(self.gallery_doc_dict[str(ret_id[i])]) + return ret_score, ret_doc + else: + return ret_score, ret_id + + def dump(self, index_path): + + if not os.path.exists(index_path): + os.makedirs(index_path) + + if self.dist_type == "IP": + save_mobius_index_prefix( + ctypes.byref(self.index_context), + create_string_buffer((index_path + "/index").encode('utf-8'))) + else: + save_l2_index_prefix( + ctypes.byref(self.index_context), + create_string_buffer((index_path + "/index").encode('utf-8'))) + + with open(index_path + "/info.json", "w") as f: + json.dump(self.gallery_doc_dict, f) + + def load(self, index_path): + self.gallery_doc_dict = {} + + with open(index_path + "/info.json", "r") as f: + self.gallery_doc_dict = json.load(f) + + self.total_num = self.gallery_doc_dict["total_num"] + self.dim = self.gallery_doc_dict["dim"] + self.dist_type = self.gallery_doc_dict["dist_type"] + self.with_attr = self.gallery_doc_dict["with_attr"] + + if self.dist_type == "IP": + load_mobius_index_prefix( + self.total_num, self.dim, + ctypes.byref(self.index_context), + create_string_buffer((index_path + "/index").encode('utf-8'))) + else: + load_l2_index_prefix( + self.total_num, self.dim, + ctypes.byref(self.index_context), + create_string_buffer((index_path + "/index").encode('utf-8'))) diff --git a/src/PaddleClas/deploy/vector_search/src/config.h b/src/PaddleClas/deploy/vector_search/src/config.h new file mode 100644 index 0000000..352d684 --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/src/config.h @@ -0,0 +1,43 @@ +//MIT License +// +//Copyright (c) 2021 Mobius Authors + +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files (the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions: + +//The above copyright notice and this permission notice shall be included in all +//copies or substantial portions of the Software. + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//SOFTWARE. + + +//from https://github.com/sunbelbd/mobius/blob/e2d166547d61d791da8f06747a63b9cd38f02c71/config.h + +#pragma once + + +typedef float value_t; +//typedef double dist_t; +typedef float dist_t; +typedef size_t idx_t; +typedef int UINT; + + +#define ACC_BATCH_SIZE 4096 +#define FIXED_DEGREE 31 +#define FIXED_DEGREE_SHIFT 5 + + +//for construction +#define SEARCH_DEGREE 15 +#define CONSTRUCT_SEARCH_BUDGET 150 diff --git a/src/PaddleClas/deploy/vector_search/src/data.h b/src/PaddleClas/deploy/vector_search/src/data.h new file mode 100644 index 0000000..ea65e70 --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/src/data.h @@ -0,0 +1,365 @@ +//MIT License +// +//Copyright (c) 2021 Mobius Authors + +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files (the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions: + +//The above copyright notice and this permission notice shall be included in all +//copies or substantial portions of the Software. + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//SOFTWARE. + +//from https://github.com/sunbelbd/mobius/blob/e2d166547d61d791da8f06747a63b9cd38f02c71/data.h + +#pragma once + +#include +#include +#include + +#include"config.h" + +#define ZERO_EPS 1e-10 + +#define _SCALE_WORLD_DENSE_DATA + +#ifdef _SCALE_WORLD_DENSE_DATA +//dense data +class Data{ +private: + std::unique_ptr data; + size_t num; + size_t curr_num = 0; + int dim; + +public: + value_t mobius_pow = 2; + value_t max_ip_norm = 1; + value_t max_ip_norm2 = 1; + + Data(size_t num, int dim) : num(num),dim(dim){ + data = std::unique_ptr(new value_t[num * dim]); + memset(data.get(),0,sizeof(value_t) * num * dim); + } + + value_t* get(idx_t idx) const{ + return data.get() + idx * dim; + } + + template + dist_t ipwrap_l2_query_distance(idx_t a,T& v) const{ + auto pa = get(a); + dist_t ret = 0; + dist_t normu = 0; + for(int i = 0;i < dim;++i){ + auto diff = (*(pa + i) / max_ip_norm) - v[i]; + ret += diff * diff; + normu += (*(pa + i)) * (*(pa + i)); + } + ret += 1 - normu / max_ip_norm2; + return ret; + } + + template + dist_t ipwrap_l2_build_distance(idx_t a,T& v) const{ + auto pa = get(a); + dist_t ret = 0; + dist_t normu = 0; + dist_t normv = 0; + for(int i = 0;i < dim;++i){ + auto diff = *(pa + i) - v[i]; + ret += diff * diff; + normu += (*(pa + i)) * (*(pa + i)); + normv += v[i] * v[i]; + } + dist_t wrap_termu = sqrt(1 - normu / max_ip_norm2); + dist_t wrap_termv = sqrt(1 - normv / max_ip_norm2); + dist_t diff_wrap = wrap_termu - wrap_termv; + ret = ret / max_ip_norm2 + diff_wrap * diff_wrap; + return ret; + } + + template + dist_t l2_distance(idx_t a,T& v) const{ + auto pa = get(a); + dist_t ret = 0; + for(int i = 0;i < dim;++i){ + auto diff = *(pa + i) - v[i]; + ret += diff * diff; + } + return ret; + } + + template + dist_t negative_inner_prod_distance(idx_t a,T& v) const{ + auto pa = get(a); + dist_t ret = 0; + for(int i = 0;i < dim;++i){ + ret -= (*(pa + i)) * v[i]; + } + return ret; + } + + template + dist_t negative_cosine_distance(idx_t a,T& v) const{ + auto pa = get(a); + dist_t ret = 0; + value_t lena = 0,lenv = 0; + for(int i = 0;i < dim;++i){ + ret += (*(pa + i)) * v[i]; + lena += (*(pa + i)) * (*(pa + i)); + lenv += v[i] * v[i]; + } + int sign = ret < 0 ? 1 : -1; +// return sign * (ret * ret / lena);// / lenv); + return sign * (ret * ret / lena / lenv); + } + + template + dist_t mobius_l2_distance(idx_t a,T& v) const{ + auto pa = get(a); + dist_t ret = 0; + value_t lena = 0,lenv = 0; + for(int i = 0;i < dim;++i){ + lena += (*(pa + i)) * (*(pa + i)); + lenv += v[i] * v[i]; + } + value_t modifier_a = pow(lena,0.5 * mobius_pow); + value_t modifier_v = pow(lenv,0.5 * mobius_pow); + if(fabs(modifier_a) < ZERO_EPS) + modifier_a = 1; + if(fabs(modifier_v) < ZERO_EPS) + modifier_v = 1; + for(int i = 0;i < dim;++i){ + value_t tmp = (*(pa + i)) / modifier_a - v[i] / modifier_v; + ret += tmp * tmp; + } + return ret; + } + + template + dist_t real_nn(T& v) const{ + dist_t minn = 1e100; + for(size_t i = 0;i < curr_num;++i){ + auto res = l2_distance(i,v); + if(res < minn){ + minn = res; + } + } + return minn; + } + + std::vector organize_point_mobius(const std::vector>& v){ + std::vector ret(dim,0); + value_t lena = 0; + for(const auto& p : v){ +// ret[p.first] = p.second; + lena += p.second * p.second; + } + value_t modifier_a = pow(lena,0.5 * mobius_pow); + if(fabs(modifier_a) < ZERO_EPS) + modifier_a = 1; + for(const auto& p : v){ + ret[p.first] = p.second / modifier_a; + } + return std::move(ret); + } + + std::vector organize_point(const std::vector>& v){ + std::vector ret(dim,0); + for(const auto& p : v){ + if(p.first >= dim) + printf("error %d %d\n",p.first,dim); + ret[p.first] = p.second; + } + return std::move(ret); + } + + value_t vec_sum2(const std::vector>& v){ + value_t ret = 0; + for(const auto& p : v){ + if(p.first >= dim) + printf("error %d %d\n",p.first,dim); + ret += p.second * p.second; + } + return std::move(ret); + } + + + void add(idx_t idx, std::vector>& value){ + //printf("adding %zu\n",idx); + //for(auto p : value) + // printf("%zu %d %f\n",idx,p.first,p.second); + curr_num = std::max(curr_num,idx); + auto p = get(idx); + for(const auto& v : value) + *(p + v.first) = v.second; + } + + void add_mobius(idx_t idx, std::vector>& value){ + //printf("adding %zu\n",idx); + //for(auto p : value) + // printf("%zu %d %f\n",idx,p.first,p.second); + curr_num = std::max(curr_num,idx); + auto p = get(idx); + value_t lena = 0; + for(const auto& v : value){ + *(p + v.first) = v.second; + lena += v.second * v.second; + } + value_t modifier_a = pow(lena,0.5 * mobius_pow); + if(fabs(modifier_a) < ZERO_EPS) + modifier_a = 1; + for(const auto& v : value){ + *(p + v.first) = v.second / modifier_a; + } + } + + inline size_t max_vertices(){ + return num; + } + + inline size_t curr_vertices(){ + return curr_num; + } + + void print(){ + for(int i = 0;i < num && i < 10;++i) + printf("%f ",*(data.get() + i)); + printf("\n"); + } + + int get_dim(){ + return dim; + } + + void dump(std::string path = "bfsg.data"){ + FILE* fp = fopen(path.c_str(),"wb"); + fwrite(data.get(),sizeof(value_t) * num * dim,1,fp); + fclose(fp); + } + + void load(std::string path = "bfsg.data"){ + curr_num = num; + FILE* fp = fopen(path.c_str(),"rb"); + auto cnt = fread(data.get(),sizeof(value_t) * num * dim,1,fp); + fclose(fp); + } + +}; +template<> +dist_t Data::ipwrap_l2_build_distance(idx_t a,idx_t& b) const{ + auto pa = get(a); + auto pb = get(b); + dist_t ret = 0; + dist_t normu = 0; + dist_t normv = 0; + for(int i = 0;i < dim;++i){ + auto diff = *(pa + i) - *(pb + i); + ret += diff * diff; + normu += (*(pa + i)) * (*(pa + i)); + normv += (*(pb + i)) * (*(pb + i)); + } + dist_t wrap_termu = sqrt(1 - normu / max_ip_norm2); + dist_t wrap_termv = sqrt(1 - normv / max_ip_norm2); + dist_t diff_wrap = wrap_termu - wrap_termv; + ret = ret / max_ip_norm2 + diff_wrap * diff_wrap; + return ret; +} +template<> +dist_t Data::ipwrap_l2_query_distance(idx_t a,idx_t& b) const{ + auto pa = get(a); + auto pb = get(b); + dist_t ret = 0; + dist_t normu = 0; + for(int i = 0;i < dim;++i){ + auto diff = (*(pa + i) / max_ip_norm) - *(pb + i); + ret += diff * diff; + normu += (*(pa + i)) * (*(pa + i)); + } + ret += 1 - normu / max_ip_norm2; + return ret; +} +template<> +dist_t Data::l2_distance(idx_t a,idx_t& b) const{ + auto pa = get(a), + pb = get(b); + dist_t ret = 0; + for(int i = 0;i < dim;++i){ + auto diff = *(pa + i) - *(pb + i); + ret += diff * diff; + } + return ret; +} + +template<> +dist_t Data::negative_inner_prod_distance(idx_t a,idx_t& b) const{ + auto pa = get(a), + pb = get(b); + dist_t ret = 0; + for(int i = 0;i < dim;++i){ + ret -= (*(pa + i)) * (*(pb + i)); + } + return ret; +} + +template<> +dist_t Data::negative_cosine_distance(idx_t a,idx_t& b) const{ + auto pa = get(a), + pb = get(b); + dist_t ret = 0; + value_t lena = 0,lenv = 0; + for(int i = 0;i < dim;++i){ + ret += (*(pa + i)) * (*(pb + i)); + lena += (*(pa + i)) * (*(pa + i)); + lenv += (*(pb + i)) * (*(pb + i)); + } + int sign = ret < 0 ? 1 : -1; +// return sign * (ret * ret / lena); + return sign * (ret * ret / lena / lenv); +} + +template<> +dist_t Data::mobius_l2_distance(idx_t a,idx_t& b) const{ + auto pa = get(a), + pb = get(b); + dist_t ret = 0; + value_t lena = 0,lenv = 0; + for(int i = 0;i < dim;++i){ + lena += (*(pa + i)) * (*(pa + i)); + lenv += (*(pb + i)) * (*(pb + i)); + } + value_t modifier_a = pow(lena,0.5 * mobius_pow); + value_t modifier_v = pow(lenv,0.5 * mobius_pow); + if(fabs(modifier_a) < ZERO_EPS) + modifier_a = 1; + if(fabs(modifier_v) < ZERO_EPS) + modifier_v = 1; + for(int i = 0;i < dim;++i){ + value_t tmp = (*(pa + i)) / modifier_a - (*(pb + i)) / modifier_v; + ret += tmp * tmp; + } + return ret; +} + +#else +//sparse data +class Data{ +public: + //TODO + +}; +#endif + + diff --git a/src/PaddleClas/deploy/vector_search/src/graph.h b/src/PaddleClas/deploy/vector_search/src/graph.h new file mode 100644 index 0000000..d54353b --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/src/graph.h @@ -0,0 +1,636 @@ +//MIT License +// +//Copyright (c) 2021 Mobius Authors + +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files (the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions: + +//The above copyright notice and this permission notice shall be included in all +//copies or substantial portions of the Software. + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//SOFTWARE. + +//from https://github.com/sunbelbd/mobius/blob/e2d166547d61d791da8f06747a63b9cd38f02c71/graph.h + + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +#include"config.h" +#include"data.h" + +#ifdef OMP +#include +#endif + +typedef unsigned int vl_type; + +class VisitedList { +public: + vl_type curV; + vl_type *mass; + unsigned int numelements; + + VisitedList(int numelements1) { + curV = 1; + numelements = numelements1; + mass = new vl_type[numelements]; + memset(mass, 0, sizeof(vl_type) * numelements); + } + + void reset() { + ++curV; + if (curV == 0) { + curV = 1; + memset(mass, 0, sizeof(vl_type) * numelements); + } + }; + + ~VisitedList() { delete mass; } +}; + +struct GraphMeasures{ + int distance_cnt = 0; +}; + +class GraphWrapper{ +public: + virtual void add_vertex(idx_t vertex_id,std::vector>& point) = 0; + virtual void add_vertex_lock(idx_t vertex_id,std::vector>& point) = 0; + virtual void search_top_k(const std::vector>& query,int k,std::vector& result) = 0; + virtual void search_top_k_with_score(const std::vector>& query,int k,std::vector& result,std::vector& score){} + + virtual void dump(std::string path = "bfsg.graph") = 0; + virtual void load(std::string path = "bfsg.graph") = 0; + virtual ~GraphWrapper(){} + virtual void set_construct_pq_size(int size){}; + GraphMeasures measures; +}; + +template +class FixedDegreeGraph : public GraphWrapper{ +private: + const int degree = SEARCH_DEGREE; + const int flexible_degree = FIXED_DEGREE; + const int vertex_offset_shift = FIXED_DEGREE_SHIFT; + std::vector edges; + std::vector edge_dist; + Data* data; + std::mt19937_64 rand_gen = std::mt19937_64(1234567);//std::random_device{}()); + std::vector edge_mutex;//do not push back on this vector, it will destroy the mutex + + bool debug = false; + VisitedList* p_visited = NULL; + #ifdef OMP + std::vector visited_pool; + #endif + int construct_pq_size = CONSTRUCT_SEARCH_BUDGET; + + + void rank_and_switch_ordered(idx_t v_id,idx_t u_id){ + //We assume the neighbors of v_ids in edges[offset] are sorted + //by the distance to v_id ascendingly when it is full + //NOTICE: before it is full, it is unsorted + auto curr_dist = pair_distance(v_id,u_id); + auto offset = ((size_t)v_id) << vertex_offset_shift; + int degree = edges[offset]; + std::vector neighbor; + neighbor.reserve(degree + 1); + for(int i = 0;i < degree;++i) + neighbor.push_back(edges[offset + i + 1]); + neighbor.push_back(u_id); + neighbor = edge_selection_filter_neighbor(neighbor,v_id,flexible_degree); + edges[offset] = neighbor.size(); + for(int i = 0;i < neighbor.size();++i) + edges[offset + i + 1] = neighbor[i]; + return; + //We assert edges[offset] > 0 here + if(curr_dist >= edge_dist[offset + edges[offset]]){ + return; + } + edges[offset + edges[offset]] = u_id; + edge_dist[offset + edges[offset]] = curr_dist; + for(size_t i = offset + edges[offset] - 1;i > offset;--i){ + if(edge_dist[i] > edge_dist[i + 1]){ + std::swap(edges[i],edges[i + 1]); + std::swap(edge_dist[i],edge_dist[i + 1]); + }else{ + break; + } + } + } + + void rank_and_switch(idx_t v_id,idx_t u_id){ + rank_and_switch_ordered(v_id,u_id); + //TODO: + //Implement an unordered version to compare with + } + + template + dist_t distance(idx_t a,T& b){ + if(dist_type == 0) + return data->l2_distance(a,b); + else if(dist_type == 1) + return data->negative_inner_prod_distance(a,b); + else if(dist_type == 2) + return data->negative_cosine_distance(a,b); + else if(dist_type == 3) + return data->l2_distance(a,b); + else if(dist_type == 4) + return data->ipwrap_l2_build_distance(a,b); + else if(dist_type == 5) + return data->ipwrap_l2_query_distance(a,b); + else{ + // should not happen + fprintf(stderr,"unsupported dist_type %d\n",dist_type); + return 0; + } + } + + void compute_distance_naive(size_t offset,std::vector& dists){ + dists.resize(edges[offset]); + auto degree = edges[offset]; + for(int i = 0;i < degree;++i){ + dists[i] = distance(offset >> vertex_offset_shift,edges[offset + i + 1]); + } + } + + void compute_distance(size_t offset,std::vector& dists){ + compute_distance_naive(offset,dists); + } + + template + dist_t pair_distance_naive(idx_t a,T& b){ + ++measures.distance_cnt; + return distance(a,b); + } + + template + dist_t pair_distance(idx_t a,T& b){ + return pair_distance_naive(a,b); + } + + + void qsort(size_t l,size_t r){ + auto mid = (l + r) >> 1; + int i = l,j = r; + auto k = edge_dist[mid]; + do{ + while(edge_dist[i] < k) ++i; + while(k < edge_dist[j]) --j; + if(i <= j){ + std::swap(edge_dist[i],edge_dist[j]); + std::swap(edges[i],edges[j]); + ++i; + --j; + } + }while(i <= j); + if(i < r)qsort(i,r); + if(l < j)qsort(l,j); + } + + void rank_edges(size_t offset){ + std::vector dists; + compute_distance(offset,dists); + for(int i = 0;i < dists.size();++i) + edge_dist[offset + i + 1] = dists[i]; + qsort(offset + 1,offset + dists.size()); + //TODO: + //use a heap in the edge_dist + } + + void add_edge_lock(idx_t v_id,idx_t u_id){ + edge_mutex[v_id].lock(); + auto offset = ((size_t)v_id) << vertex_offset_shift; + if(edges[offset] < flexible_degree){ + ++edges[offset]; + edges[offset + edges[offset]] = u_id; + }else{ + rank_and_switch(v_id,u_id); + } + edge_mutex[v_id].unlock(); + } + + void add_edge(idx_t v_id,idx_t u_id){ + auto offset = ((size_t)v_id) << vertex_offset_shift; + if(edges[offset] < flexible_degree){ + ++edges[offset]; + edges[offset + edges[offset]] = u_id; + }else{ + rank_and_switch(v_id,u_id); + } + } + +public: + long long total_explore_cnt = 0; + int total_explore_times = 0; + + size_t search_start_point = 0; + bool ignore_startpoint = false; + + FixedDegreeGraph(Data* data) : data(data){ + auto num_vertices = data->max_vertices(); + edges = std::vector(((size_t)num_vertices) << vertex_offset_shift); + edge_dist = std::vector(((size_t)num_vertices) << vertex_offset_shift); + edge_mutex = std::vector(num_vertices); + p_visited = new VisitedList(num_vertices + 5); + #ifdef OMP + int n_threads = 1; + #pragma omp parallel + #pragma omp master + { + n_threads = omp_get_num_threads(); + } + visited_pool.resize(n_threads); + for(int i = 0;i < n_threads;++i) + visited_pool[i] = new VisitedList(num_vertices + 5); + #endif + } + + void set_construct_pq_size(int size){ + construct_pq_size = size; + } + + std::vector edge_selection_filter_neighbor(std::vector& neighbor,idx_t vertex_id,int desired_size){ + std::vector filtered_neighbor; + std::vector dists(neighbor.size()); + for(int i = 0;i < dists.size();++i) + dists[i] = pair_distance(vertex_id,neighbor[i]); + std::vector idx(neighbor.size()); + for(int i = 0;i < idx.size();++i) + idx[i] = i; + std::sort(idx.begin(),idx.end(),[&](int a,int b){return dists[a] < dists[b];}); + for(int i = 0;i < idx.size();++i){ + dist_t cur_dist = dists[idx[i]]; + bool pass = true; + for(auto neighbor_id : filtered_neighbor){ + if(cur_dist > pair_distance(neighbor_id,neighbor[idx[i]])){ + pass = false; + break; + } + } + if(pass){ + filtered_neighbor.push_back(neighbor[idx[i]]); + if(filtered_neighbor.size() >= desired_size) + break; + }else{ + } + } + return std::move(filtered_neighbor); + } + + void add_vertex_lock(idx_t vertex_id,std::vector>& point){ + std::vector neighbor; + search_top_k_lock(point,construct_pq_size,neighbor); + auto offset = ((size_t)vertex_id) << vertex_offset_shift; + int num_neighbors = degree < neighbor.size() ? degree : neighbor.size(); + edge_mutex[vertex_id].lock(); + // TODO: + // it is possible to save this space --- edges[offset] + // by set the last number in the range as + // a large number - current degree + if(neighbor.size() >= degree) + neighbor = edge_selection_filter_neighbor(neighbor,vertex_id,degree); + edges[offset] = neighbor.size(); + + for(int i = 0;i < neighbor.size() && i < degree;++i){ + edges[offset + i + 1] = neighbor[i]; + } + edge_mutex[vertex_id].unlock(); + for(int i = 0;i < neighbor.size() && i < degree;++i){ + add_edge_lock(neighbor[i],vertex_id); + } + } + void add_vertex(idx_t vertex_id,std::vector>& point){ + std::vector neighbor; + search_top_k(point,construct_pq_size,neighbor); + auto offset = ((size_t)vertex_id) << vertex_offset_shift; + int num_neighbors = degree < neighbor.size() ? degree : neighbor.size(); + // TODO: + // it is possible to save this space --- edges[offset] + // by set the last number in the range as + // a large number - current degree + if(neighbor.size() >= degree){ + neighbor = edge_selection_filter_neighbor(neighbor,vertex_id,degree); + } + edges[offset] = neighbor.size(); + + for(int i = 0;i < neighbor.size() && i < degree;++i){ + edges[offset + i + 1] = neighbor[i]; + } + for(int i = 0;i < neighbor.size() && i < degree;++i){ + add_edge(neighbor[i],vertex_id); + } + } + + void astar_multi_start_search_lock(const std::vector>& query,int k,std::vector& result){ + std::priority_queue,std::vector>,std::greater>> q; + const int num_start_point = 1; + + auto converted_query = dist_type == 3 ? data->organize_point_mobius(query) : data->organize_point(query); + #ifdef OMP + int tid = omp_get_thread_num(); + auto& p_visited = visited_pool[tid]; + #endif + + p_visited->reset(); + auto tag = p_visited->curV; + for(int i = 0;i < num_start_point && i < data->curr_vertices();++i){ + auto start = search_start_point;//rand_gen() % data->curr_vertices(); + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + q.push(std::make_pair(pair_distance_naive(start,converted_query),start)); + } + std::priority_queue> topk; + const int max_step = 1000000; + bool found_min_node = false; + dist_t min_dist = 1e100; + int explore_cnt = 0; + for(int iter = 0;iter < max_step && !q.empty();++iter){ + auto now = q.top(); + if(topk.size() == k && topk.top().first < now.first){ + break; + } + ++explore_cnt; + min_dist = std::min(min_dist,now.first); + q.pop(); + if(ignore_startpoint == false || iter != 0) + topk.push(now); + if(topk.size() > k) + topk.pop(); + edge_mutex[now.second].lock(); + auto offset = ((size_t)now.second) << vertex_offset_shift; + auto degree = edges[offset]; + + for(int i = 0;i < degree;++i){ + auto start = edges[offset + i + 1]; + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + auto dist = pair_distance_naive(start,converted_query); + if(topk.empty() || dist < topk.top().first || topk.size() < k) + q.push(std::make_pair(dist,start)); + } + edge_mutex[now.second].unlock(); + } + total_explore_cnt += explore_cnt; + ++total_explore_times; + result.resize(topk.size()); + int i = result.size() - 1; + while(!topk.empty()){ + result[i] = (topk.top().second); + topk.pop(); + --i; + } + } + + void astar_no_heap_search(const std::vector>& query,std::vector& result){ + const int num_start_point = 1; + std::pair q_top = std::make_pair(10000000000,0); + auto converted_query = dist_type == 3 ? data->organize_point_mobius(query) : data->organize_point(query); + p_visited->reset(); + auto tag = p_visited->curV; + for(int i = 0;i < num_start_point && i < data->curr_vertices();++i){ + auto start = search_start_point;//rand_gen() % data->curr_vertices(); + p_visited->mass[start] = tag; + if(ignore_startpoint == false){ + q_top = (std::make_pair(pair_distance_naive(start,converted_query),start)); + }else{ + auto offset = ((size_t)start) << vertex_offset_shift; + auto degree = edges[offset]; + + for(int i = 1;i <= degree;++i){ + p_visited->mass[edges[offset + i]] = tag; + auto dis = pair_distance_naive(edges[offset + i],converted_query); + if(dis < q_top.first) + q_top = (std::make_pair(dis,start)); + } + } + } + const int max_step = 1000000; + bool found_min_node = false; + dist_t min_dist = 1e100; + int explore_cnt = 0; + for(int iter = 0;iter < max_step;++iter){ + ++explore_cnt; + auto offset = ((size_t)q_top.second) << vertex_offset_shift; + auto degree = edges[offset]; + + bool changed = false; + for(int i = 0;i < degree;++i){ + auto start = edges[offset + i + 1]; + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + auto dist = pair_distance_naive(start,converted_query); + if(dist < q_top.first){ + q_top = (std::make_pair(dist,start)); + changed = true; + } + } + if(changed == false) + break; + } + total_explore_cnt += explore_cnt; + ++total_explore_times; + result.resize(1); + result[0] = q_top.second; + } + + void astar_multi_start_search_with_score(const std::vector>& query,int k,std::vector& result,std::vector& score){ + std::priority_queue,std::vector>,std::greater>> q; + const int num_start_point = 1; + + auto converted_query = dist_type == 3 ? data->organize_point_mobius(query) : data->organize_point(query); + p_visited->reset(); + auto tag = p_visited->curV; + for(int i = 0;i < num_start_point && i < data->curr_vertices();++i){ + auto start = search_start_point;//rand_gen() % data->curr_vertices(); + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + q.push(std::make_pair(pair_distance_naive(start,converted_query),start)); + } + std::priority_queue> topk; + const int max_step = 1000000; + bool found_min_node = false; + dist_t min_dist = 1e100; + int explore_cnt = 0; + for(int iter = 0;iter < max_step && !q.empty();++iter){ + auto now = q.top(); + if(topk.size() == k && topk.top().first < now.first){ + break; + } + ++explore_cnt; + min_dist = std::min(min_dist,now.first); + q.pop(); + if(ignore_startpoint == false || iter != 0) + topk.push(now); + if(topk.size() > k) + topk.pop(); + auto offset = ((size_t)now.second) << vertex_offset_shift; + auto degree = edges[offset]; + + for(int i = 0;i < degree;++i){ + auto start = edges[offset + i + 1]; + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + auto dist = pair_distance_naive(start,converted_query); + if(topk.empty() || dist < topk.top().first || topk.size() < k) + q.push(std::make_pair(dist,start)); + } + } + total_explore_cnt += explore_cnt; + ++total_explore_times; + result.resize(topk.size()); + score.resize(topk.size()); + int i = result.size() - 1; + while(!topk.empty()){ + result[i] = (topk.top().second); + score[i] = -(topk.top().first); + topk.pop(); + --i; + } + } + + void astar_multi_start_search(const std::vector>& query,int k,std::vector& result){ + std::priority_queue,std::vector>,std::greater>> q; + const int num_start_point = 1; + + auto converted_query = dist_type == 3 ? data->organize_point_mobius(query) : data->organize_point(query); + p_visited->reset(); + auto tag = p_visited->curV; + for(int i = 0;i < num_start_point && i < data->curr_vertices();++i){ + auto start = search_start_point;//rand_gen() % data->curr_vertices(); + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + q.push(std::make_pair(pair_distance_naive(start,converted_query),start)); + } + std::priority_queue> topk; + const int max_step = 1000000; + bool found_min_node = false; + dist_t min_dist = 1e100; + int explore_cnt = 0; + for(int iter = 0;iter < max_step && !q.empty();++iter){ + auto now = q.top(); + if(topk.size() == k && topk.top().first < now.first){ + break; + } + ++explore_cnt; + min_dist = std::min(min_dist,now.first); + q.pop(); + if(ignore_startpoint == false || iter != 0) + topk.push(now); + if(topk.size() > k) + topk.pop(); + auto offset = ((size_t)now.second) << vertex_offset_shift; + auto degree = edges[offset]; + + for(int i = 0;i < degree;++i){ + auto start = edges[offset + i + 1]; + if(p_visited->mass[start] == tag) + continue; + p_visited->mass[start] = tag; + auto dist = pair_distance_naive(start,converted_query); + if(topk.empty() || dist < topk.top().first || topk.size() < k) + q.push(std::make_pair(dist,start)); + } + } + total_explore_cnt += explore_cnt; + ++total_explore_times; + result.resize(topk.size()); + int i = result.size() - 1; + while(!topk.empty()){ + result[i] = (topk.top().second); + topk.pop(); + --i; + } + } + + void search_top_k(const std::vector>& query,int k,std::vector& result){ + if(k == 1) + astar_no_heap_search(query,result); + else + astar_multi_start_search(query,k,result); + } + + void search_top_k_with_score(const std::vector>& query,int k,std::vector& result,std::vector& score){ + astar_multi_start_search_with_score(query,k,result,score); + } + + void search_top_k_lock(const std::vector>& query,int k,std::vector& result){ + astar_multi_start_search_lock(query,k,result); + } + + void print_stat(){ + auto n = data->max_vertices(); + size_t sum = 0; + std::vector histogram(2 * degree + 1,0); + for(size_t i = 0;i < n;++i){ + sum += edges[i << vertex_offset_shift]; + int tmp = edges[i << vertex_offset_shift]; + if(tmp > 2 * degree + 1) + fprintf(stderr,"[ERROR] node %zu has %d degree\n",i,tmp); + ++histogram[edges[i << vertex_offset_shift]]; + if(tmp != degree) + fprintf(stderr,"[INFO] %zu has degree %d\n",i,tmp); + } + fprintf(stderr,"[INFO] #vertices %zu, avg degree %f\n",n,sum * 1.0 / n); + std::unordered_set visited; + fprintf(stderr,"[INFO] degree histogram:\n"); + for(int i = 0;i <= 2 * degree + 1;++i) + fprintf(stderr,"[INFO] %d:\t%zu\n",i,histogram[i]); + + } + + void print_edges(int x){ + for(size_t i = 0;i < x;++i){ + size_t offset = i << vertex_offset_shift; + int degree = edges[offset]; + fprintf(stderr,"%d (%d): ",i,degree); + for(int j = 1;j <= degree;++j) + fprintf(stderr,"(%zu,%f) ",edges[offset + j],edge_dist[offset + j]); + fprintf(stderr,"\n"); + } + } + + void dump(std::string path = "bfsg.graph"){ + FILE* fp = fopen(path.c_str(),"wb"); + size_t num_vertices = data->max_vertices(); + fwrite(&edges[0],sizeof(edges[0]) * (num_vertices << vertex_offset_shift),1,fp); + fclose(fp); + } + + void load(std::string path = "bfsg.graph"){ + FILE* fp = fopen(path.c_str(),"rb"); + size_t num_vertices = data->max_vertices(); + auto cnt = fread(&edges[0],sizeof(edges[0]) * (num_vertices << vertex_offset_shift),1,fp); + fclose(fp); + } + + Data* get_data(){ + return data; + } + +}; + diff --git a/src/PaddleClas/deploy/vector_search/test.py b/src/PaddleClas/deploy/vector_search/test.py new file mode 100644 index 0000000..06951b4 --- /dev/null +++ b/src/PaddleClas/deploy/vector_search/test.py @@ -0,0 +1,34 @@ +# Copyright (c) 2021 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. + +import numpy as np +from interface import Graph_Index + +# 随机产生样本 +index_vectors = np.random.rand(100000,128).astype(np.float32) +query_vector = np.random.rand(128).astype(np.float32) +index_docs = ["ID_"+str(i) for i in range(100000)] + +# 初始化索引结构 +indexer = Graph_Index(dist_type="IP") #支持"IP"和"L2" +indexer.build(gallery_vectors=index_vectors, gallery_docs=index_docs, pq_size=100, index_path='test') + +# 查询 +scores, docs = indexer.search(query=query_vector, return_k=10, search_budget=100) +print(scores) +print(docs) + +# 保存与加载 +indexer.dump(index_path="test") +indexer.load(index_path="test") diff --git a/src/PaddleClas/docs/Makefile b/src/PaddleClas/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/src/PaddleClas/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/src/PaddleClas/docs/en/Makefile b/src/PaddleClas/docs/en/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/src/PaddleClas/docs/en/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/src/PaddleClas/docs/en/advanced_tutorials/DataAugmentation_en.md b/src/PaddleClas/docs/en/advanced_tutorials/DataAugmentation_en.md new file mode 100644 index 0000000..e6613d9 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/DataAugmentation_en.md @@ -0,0 +1,338 @@ +# Image Augmentation +--- + +Experiments about data augmentation will be introduced in detail in this section. If you want to quickly experience these methods, please refer to [**Quick start PaddleClas in 30 miniutes**](../../tutorials/quick_start_en.md), which based on CIFAR100 dataset. If you want to know the content of related algorithms, please refer to [Data Augmentation Algorithm Introduction](../algorithm_introduction/DataAugmentation_en.md). + + +## Catalogue + +- [1. Configurations](#1) + - [1.1 AutoAugment](#1.1) + - [1.2 RandAugment](#1.2) + - [1.3 TimmAutoAugment](#1.3) + - [1.4 Cutout](#1.4) + - [1.5 RandomErasing](#1.5) + - [1.6 HideAndSeek](#1.6) + - [1.7 GridMask](#1.7) + - [1.8 Mixup](#1.8) + - [1.9 Cutmix](#1.9) + - [1.10 Use Mixup and Cutmix at the same time](#1.10) +- [2. Start training](#2) +- [3. Matters needing attention](#3) +- [4. Experiments](#4) + + + +## Configurations + +Since hyperparameters differ from different augmentation methods. For better understanding, we list 8 augmentation configuration files in `configs/DataAugment` based on ResNet50. Users can train the model with `tools/run.sh`. The following are 3 of them. + + +### 1.1 AutoAugment + +The configuration of the data augmentation method of `AotoAugment` is as follows. `AutoAugment` is converted on the uint8 data format, so its processing should be placed before the normalization operation (`NormalizeImage`). + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + + +### 1.2 RandAugment + +The configuration of the data augmentation method of `RandAugment` is as follows, where the user needs to specify the parameters `num_layers` and `magnitude`, and the default values ​​are `2` and `5` respectively. `RandAugment` is converted on the uint8 data format, so its processing should be placed before the normalization operation (`NormalizeImage`). + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - RandAugment: + num_layers: 2 + magnitude: 5 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + + +### 1.3 TimmAutoAugment + +The configuration of the data augmentation method of `TimmAutoAugment` is as follows, in which the user needs to specify the parameters `config_str`, `interpolation`, and `img_size`. The default values ​​are `rand-m9-mstd0.5-inc1` and `bicubic. `, `224`. `TimmAutoAugment` is converted on the uint8 data format, so its processing should be placed before the normalization operation (`NormalizeImage`). + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + + +### 1.4 Cutout + +The configuration of the data augmentation method of `Cutout` is as follows, where the user needs to specify the parameters `n_holes` and `length`, and the default values are `1` and `112` respectively. Similar to other image cropping data augmentation methods, `Cutout` can operate on data in uint8 format, or on data after normalization (`NormalizeImage`).The demo here is operated after normalization. + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - Cutout: + n_holes: 1 + length: 112 +``` + + +### 1.5 RandomErasing + +The configuration of the image augmentation method of `RandomErasing` is as follows, where the user needs to specify the parameters `EPSILON`, `sl`, `sh`, `r1`, `attempt`, `use_log_aspect`, `mode`, and the default values They are `0.25`, `0.02`, `1.0/3.0`, `0.3`, `10`, `True`, and `pixel`. Similar to other image cropping data augmentation methods, `RandomErasing` can operate on data in uint8 format, or on data after normalization (`NormalizeImage`).The demo here is operated after normalization. + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel +``` + + +### 1.6 HideAndSeek + +The configuration of the image augmentation method of `HideAndSeek` is as follows. Similar to other image cropping data augmentation methods, `HideAndSeek` can operate on data in uint8 format, or on data after normalization (`NormalizeImage`).The demo here is operated after normalization. + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - HideAndSeek: +``` + + +### 1.7 GridMask + +The configuration of the image augmentation method of `GridMask` is as follows, where the user needs to specify the parameters `d1`, `d2`, `rotate`, `ratio`, `mode`, and the default values are `96`, `224 respectively `, `1`, `0.5`, `0`. Similar to other image cropping data augmentation methods, `HideAndSeek` can operate on data in uint8 format, or on data after normalization (`GridMask`).The demo here is operated after normalization. + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - GridMask: + d1: 96 + d2: 224 + rotate: 1 + ratio: 0.5 + mode: 0 +``` + + +### 1.8 Mixup + +The configuration of the data augmentation method of `Mixup` is as follows, where the user needs to specify the parameter `alpha`, and the default value is `0.2`. Similar to other image mixing data augmentation methods, `Mixup` is to perform image mix on the data in each batch after the image is processed, and the mixed images and labels are put into the network for training, +so it operates after image data processing (image transformation, image cropping). + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 +``` + + +### 1.9 Cutmix + +The configuration of the image augmentation method of `Cutmix` is as follows, where the user needs to specify the parameter `alpha`, and the default value is `0.2`. Similar to other image mixing data augmentation methods, `Mixup` is to perform image mix on the data in each batch after the image is processed, and the mixed images and labels are put into the network for training, +so it operates after image data processing (image transformation, image cropping). + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - CutmixOperator: + alpha: 0.2 +``` + + +### 1.10 Use Mixup and Cutmix at the same time + +The configuration for both `Mixup` and `Cutmix` is as follows, in which the user needs to specify an additional parameter `prob`, which controls the probability of different data enhancements, and the default is `0.5`. + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 +``` + + +## 2. Start training + +After you configure the training environment, similar to training other classification tasks, you only need to replace the configuration file in `tools/train.sh` with the configuration file of the corresponding data augmentation method. + + +The contents of `train.sh` are as follows: + +```bash +python3 -m paddle.distributed.launch \ + --selected_gpus="0,1,2,3" \ + --log_dir=ResNet50_Cutout \ + tools/train.py \ + -c ./ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml +``` + +Run `train.sh`: + +```bash +sh tools/train.sh +``` + + +## 3. Matters needing attention + +* In addition, because the label needs to be aliased when the image is aliased, the accuracy of the training data cannot be calculated. The training accuracy rate was not printed during the training process. + +* The training data is more difficult with data augmentation, so the training loss may be larger, the training set accuracy is relatively low, but it has better generalization ability, so the validation set accuracy is relatively higher. + +* After the use of data augmentation, the model may tend to be underfitting. It is recommended to reduce `l2_decay` for better performance on validation set. + +* hyperparameters exist in almost all agmenatation methods. Here we provide hyperparameters for ImageNet1k dataset. User may need to finetune the hyperparameters on specified dataset. More training tricks can be referred to [Tricks](../models_training/train_strategy_en.md). + + +> If this document is helpful to you, welcome to star our project: [https://github.com/PaddlePaddle/PaddleClas](https://github.com/PaddlePaddle/PaddleClas) + + +## 4. Experiments + +Based on PaddleClas, Metrics of different augmentation methods on ImageNet1k dataset are as follows. + + +| Model | Learning strategy | l2 decay | batch size | epoch | Augmentation method | Top1 Acc | Reference | +|-------------|------------------|--------------|------------|-------|----------------|------------|----| +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | Standard transform | 0.7731 | - | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | AutoAugment | 0.7795 | 0.7763 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | mixup | 0.7828 | 0.7790 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | cutmix | 0.7839 | 0.7860 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | cutout | 0.7801 | - | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | gridmask | 0.7785 | 0.7790 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | random-augment | 0.7770 | 0.7760 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | random erasing | 0.7791 | - | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | hide and seek | 0.7743 | 0.7720 | + + +**note**: +* In the experiment here, for better comparison, we fixed the l2 decay to 1e-4. To achieve higher accuracy, we recommend trying to use a smaller l2 decay. Combined with data augmentaton, we found that reducing l2 decay from 1e-4 to 7e-5 can bring at least 0.3~0.5% accuracy improvement. +* We have not yet combined different strategies or verified, whch is our future work. diff --git a/src/PaddleClas/docs/en/advanced_tutorials/code_overview_en.md b/src/PaddleClas/docs/en/advanced_tutorials/code_overview_en.md new file mode 100644 index 0000000..05f4b57 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/code_overview_en.md @@ -0,0 +1,303 @@ +# Code Overview + +## Catalogue + +- [1. Overview of Code and Content](#1) +- [2. Training Module](#2) + - [2.1 Data](#2.1) + - [2.2 Model Structure](#2.2) + - [2.3 Loss Function](#2.3) + - [2.4 Optimizer, Learning Rate Decay, and Weight Decay](#2.4) + - [2.5 Evaluation During Training](#2.5) + - [2.6 Model Saving](#2.6) + - [2.7 Model Pruning and Quantification](#2.7) +- [3. Codes and Methods for Inference and Deployment](#3) + + + +## 1. Overview of Code and Content + +The main code and content structure of PaddleClas are as follows: + +- benchmark: shell scripts to test the speed metrics of different models in PaddleClas, such as single-card training speed metrics, multi-card training speed metrics, etc. +- dataset: datasets and the scripts used to process datasets. The scripts are responsible for processing the dataset into a suitable format for Dataloader. +- deploy: code for deployment, including deployment tools, which support python/cpp inference, Hub Serveing, Paddle Lite, Slim offline quantification and other deployment methods. +- ppcls: code for training and evaluation which is the main body of the PaddleClas framework. It also contains configuration files, and specific code of model training, evaluation, inference, dynamic to static export, etc. +- tools: entry functions and scripts for training, evaluation, inference, and dynamic to static export. +- The requirements.txt file is adopted to install the dependencies for PaddleClas. Use pip for upgrading, installation, and application. +- test_tipc: TIPC tests of PaddleClas models from training to prediction to verify that whether each function works properly. + + + +## 2. Training Module + +Modules of training deep learning model mainly contains data, model structure, loss function, +strategies such as optimizer, learning rate decay, and weight decay strategy, etc., which are explained below. + + + +### 2.1 Data + +For supervised tasks, the training data generally contains the raw data and its annotation. +In a single-label-based image classification task, the raw data refers to the image data, +while the annotation is the class to which the image data belongs. In PaddleClas, a label file, +in the following format, is required for training, +with each row containing one training sample and separated by a separator (space by default), +representing the image path and the class label respectively. + +``` +train/n01440764/n01440764_10026.JPEG 0 +train/n01440764/n01440764_10027.JPEG 0 +``` + +`ppcls/data/dataloader/common_dataset.py` contains the `CommonDataset` class inherited from `paddle.io.Dataset`, +which is a dataset class that can index and fetch a given sample by a key value. +Dataset classes such as `ImageNetDataset`, `LogoDataset`, `CommonDataset`, etc. are all inherited from this class. + +The raw image needs to be preprocessed before training. +The standard data preprocessing during training contains +`DecodeImage`, `RandCropImage`, `RandFlipImage`, `NormalizeImage`, and `ToCHWImage`. +The data preprocessing is mainly in the `transforms` field, which is presented in a list, +and then converts the data in order, as reflected in the configuration file below. + +```yaml +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + +PaddleClas also contains `AutoAugment`, `RandAugment`, and other data augmentation methods, +which can also be configured in the configuration file and thus added to the data preprocessing of the training. +Each data augmentation and process method is implemented as a class for easy migration and reuse. +For more specific implementation of data processing, please refer to the code under `ppcls/data/preprocess/ops/`. + +You can also use methods such as mixup or cutmix to augment the data that make up a batch. +PaddleClas integrates `MixupOperator`, `CutmixOperator`, `FmixOperator`, and other batch-based data augmentation methods, +which can be configured by deploying the mix parameter in the configuration file. +For code implementation, please refer to `ppcls/data/preprocess /batch_ops/batch_operators.py`. + +In image classification, the data post-processing is mainly `argmax` operation, which is not elaborated here. + + + +### 2.2 Model Structure + +The model in the configuration file is structured as follows: + +```yaml +Arch: + name: ResNet50 + class_num: 1000 + pretrained: False + use_ssld: False +``` + +`Arch.name`: the name of the model + +`Arch.pretrained`: whether to add a pre-trained model + +`Arch.use_ssld`: whether to use a pre-trained model based on `SSLD` knowledge distillation. + +All model names are defined in `ppcls/arch/backbone/__init__.py`. + +Correspondingly, the model object is created in `ppcls/arch/__init__.py` with the `build_model` method. + +```python +def build_model(config): + config = copy.deepcopy(config) + model_type = config.pop("name") + mod = importlib.import_module(__name__) + arch = getattr(mod, model_type)(**config) + return arch +``` + + + +### 2.3 Loss Function + +PaddleClas implement `CELoss` , `JSDivLoss`, `TripletLoss`, `CenterLoss` and other loss functions, all defined in `ppcls/loss`. + +In the `ppcls/loss/__init__.py` file, `CombinedLoss` is used to construct and combine loss functions. +The loss functions and calculation methods required in different training strategies are disparate, +and the following factors are considered by PaddleClas in the construction of the loss function. + +1. whether to use label smooth +2. whether to use mixup or cutmix +3. whether to use distillation method for training +4. whether to train metric learning + +User can specify the type and weight of the loss function in the configuration file, +such as adding TripletLossV2 to the training, the configuration file is as follows: + +```yaml +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 +``` + + + +### 2.4 Optimizer, Learning Rate Decay, and Weight Decay + +In image classification tasks, `Momentum` is a commonly used optimizer, +and several optimizer strategies such as `Momentum`, `RMSProp`, `Adam`, and `AdamW` are provided in PaddleClas. + +The weight decay strategy is a common regularization method, mainly adopted to prevent model overfitting. +Two weight decay strategies, `L1Decay` and `L2Decay`, are provided in PaddleClas. + +Learning rate decay is an essential training method for accuracy improvement in image classification tasks. +PaddleClas currently supports `Cosine`, `Piecewise`, `Linear`, and other learning rate decay strategies. + +In the configuration file, the optimizer, weight decay, +and learning rate decay strategies can be configured with the following fields. + +```yaml +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 +``` + +Employ `build_optimizer` in `ppcls/optimizer/__init__.py` to create the optimizer and learning rate objects. + +```python +def build_optimizer(config, epochs, step_each_epoch, parameters): + config = copy.deepcopy(config) + # step1 build lr + lr = build_lr_scheduler(config.pop('lr'), epochs, step_each_epoch) + logger.debug("build lr ({}) success..".format(lr)) + # step2 build regularization + if 'regularizer' in config and config['regularizer'] is not None: + reg_config = config.pop('regularizer') + reg_name = reg_config.pop('name') + 'Decay' + reg = getattr(paddle.regularizer, reg_name)(**reg_config) + else: + reg = None + logger.debug("build regularizer ({}) success..".format(reg)) + # step3 build optimizer + optim_name = config.pop('name') + if 'clip_norm' in config: + clip_norm = config.pop('clip_norm') + grad_clip = paddle.nn.ClipGradByNorm(clip_norm=clip_norm) + else: + grad_clip = None + optim = getattr(optimizer, optim_name)(learning_rate=lr, + weight_decay=reg, + grad_clip=grad_clip, + **config)(parameters=parameters) + logger.debug("build optimizer ({}) success..".format(optim)) + return optim, lr +``` + +Different optimizers and weight decay strategies are implemented as classes, +which can be found in the file `ppcls/optimizer/optimizer.py`. +Different learning rate decay strategies can be found in the file `ppcls/optimizer/learning_rate.py`. + + + +### 2.5 Evaluation During Training + +When training the model, you can set the interval of model saving, +or you can evaluate the validation set every several epochs so that the model with the best accuracy can be saved. +Follow the examples below to configure. + +``` +Global: + save_interval: 1 # epoch interval of model saving + eval_during_train: True # whether evaluate during training + eval_interval: 1 # epoch interval of evaluation +``` + + + +### 2.6 Model Saving + +The model is saved through the `paddle.save()` function of the Paddle framework. +The dynamic graph version of the model is saved in the form of a dictionary to facilitate further training. +The specific implementation is as follows: + +```python +def save_model(program, model_path, epoch_id, prefix='ppcls'): + model_path = os.path.join(model_path, str(epoch_id)) + _mkdir_if_not_exist(model_path) + model_prefix = os.path.join(model_path, prefix) + paddle.static.save(program, model_prefix) + logger.info( + logger.coloring("Already save model in {}".format(model_path), "HEADER")) +``` + +When saving, there are two things to keep in mind: + +1. Only save the model on node 0, otherwise, if all nodes save models to the same path, +a file conflict may occur during multi-card training when multiple nodes write files, +preventing the final saved model from being loaded correctly. +2. Optimizer parameters also need to be saved to facilitate subsequent loading of breakpoints for training. + + + +### 2.7 Model Pruning and Quantification + +If you want to conduct compression training, please configure with the following fields. + +1. Model pruning: + +```yaml +Slim: + prune: + name: fpgm + pruned_ratio: 0.3 +``` + +2. Model quantification: + +```yaml +Slim: + quant: + name: pact +``` +For details of the training method, see [Pruning and Quantification Application](model_prune_quantization_en.md), +and the algorithm is described in [Pruning and Quantification algorithms](model_prune_quantization_en.md). + + + +## 3. Codes and Methods for Inference and Deployment + +- If you wish to quantify the classification model offline, please refer to +[Model Pruning and Quantification Tutorial](model_prune_quantization_en.md) for offline quantification. +- If you wish to use python for server-side deployment, +please refer to [Python Inference Tutorial](../inference_deployment/python_deploy_en.md). +- If you wish to use cpp for server-side deployment, +please refer to [Cpp Inference Tutorial](../inference_deployment/cpp_deploy_en.md). +- If you wish to deploy the classification model as a service, +please refer to the [Hub Serving Inference Deployment Tutorial](../inference_deployment/paddle_hub_serving_deploy_en.md). +- If you wish to use classification models for inference on mobile, +please refer to [PaddleLite Inference Deployment Tutorial](../inference_deployment/paddle_lite_deploy_en.md) +- If you wish to use the whl package for inference of classification models, +please refer to [whl Package Inference](../inference_deployment/whl_deploy_en.md) . diff --git a/src/PaddleClas/docs/en/advanced_tutorials/distillation/distillation_en.md b/src/PaddleClas/docs/en/advanced_tutorials/distillation/distillation_en.md new file mode 100644 index 0000000..f1d39a3 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/distillation/distillation_en.md @@ -0,0 +1,245 @@ + +# Knowledge Distillation + +## Introduction of model compression methods + +In recent years, deep neural networks have been proven to be an extremely effective method to solve problems in the fields of computer vision and natural language processing. The deep learning methods performs better than traditional methods with suitable network structure and training process. + +With enough training data, increasing parameters of the neural network by building a reasonabe network can significantly the model performance. But this increases the model complexity, which takes too much computation cost in real scenarios. + + +Parameter redundancy exists in deep neural networks. There are several methods to compress the model such as pruning ,quantization, knowledge distillation, etc. Knowledge distillation refers to using the teacher model to guide the student model to learn specific tasks, ensuring that the small model has a relatively large effect improvement with the computation cost unchanged, and even obtains similar accuracy with the large model [1]. Combining some of the existing distillation methods [2,3], PaddleClas provides a simple semi-supervised label knowledge distillation solution (SSLD). Top-1 Accuarcy on ImageNet1k dataset has an improvement of more than 3% based on ResNet_vd and MobileNet series, which can be shown as below. + + +![](../../../images/distillation/distillation_perform_s.jpg) + + +## SSLD + +### Introduction + +The following figure shows the framework of SSLD. + +![](../../../images/distillation/ppcls_distillation.png) + +First, we select nearly 4 million images from ImageNet22k dataset, and integrate it with the ImageNet-1k training set to get a new dataset containing 5 million images. Then, we combine the student model and the teacher model into a new network, which outputs the predictions of the student model and the teacher model, respectively. The gradient of the entire network of the teacher model is fixed. Finally, we use JS divergence loss as the loss function for the training process. Here we take MobileNetV3 distillation task as an example, and introduce key points of SSLD. + +* Choice of the teacher model, During knowledge distillation, it may not be an optimal solution if the structure of the teacher model and the student model are too different. Under the same structure, the teacher model with higher accuracy leads to better performance for the student model during distillation. Compared with the 79.12% ResNet50_vd teacher model, using the 82.4% teacher model can bring a 0.4% accuracy improvement on Top-1 accuracy (`75.6%-> 76.0%`). + +* Improvement of loss function. The most commonly used loss function for classification is cross entropy loss. We find that when using soft label for training, KL divergence loss is almost useless to improve model performance compared to cross entropy loss, but The accuracy has a 0.2% improvement using JS divergence loss (`76.0%-> 76.2%`). Loss function in SSLD is JS divergence loss. + +* More iteration number. It is only 120 for the baseline experiment. We can achieve a 0.9% improvement by setting it as 360 (`76.2%-> 77.1%`). + +* There is not need for laleled data in SSLD, which leads to convenient training data expansion. label is not utilized when computing the loss function, therefore the unlabeled data can also be used to train the network. The label-free distillation strategy of this distillation solution has also greatly improved the upper performance limit of student models (`77.1%-> 78.5%`). + +* ImageNet1k finetune. ImageNet1k training set is used for finetuning, which brings a 0.4% accuracy improvement (`78.5%-> 78.9%`). + + +### Data selection + +* An important feature of the SSLD distillation scheme is no need for labeled images, so the dataset size can be arbitrarily expanded. Considering the limitation of computing resources, we here only expand the training set of the distillation task based on the ImageNet22k dataset. For SSLD, we used the `Top-k per class` data sampling scheme [3]. Specific steps are as follows. +     * Deduplication of training set. We first deduplicate the ImageNet22k dataset and the ImageNet1k validation set based on the SIFT feature similarity matching method to prevent the added ImageNet22k training set from containing the ImageNet1k validation set images. Finally we removed 4511 similar images. Similar pictures with partial filtering are shown below. + + ![](../../../images/distillation/22k_1k_val_compare_w_sift.png) + + * Obtain the soft label of the ImageNet22k dataset. For the ImageNet22k dataset after deduplication, we use the `ResNeXt101_32x16d_wsl` model to make predictions to obtain the soft label of each image. +     * Top-k data selection. There contains 1000 categories in ImageNet1k dataset. For each category, we find out images in the category with Top-k highest score, and finally generate a dataset whose image number does not exceed `1000 * k` (For some categories, there may contain less than k images). +     * The selected images are merged with the ImageNet1k training set to form the new dataset used for the final distillation model training, which contains 5 million images in all. + +## Experiments + +The distillation solution that PaddleClas provides is combining common training with finetuning. Given a suitable teacher model, the large dataset(5 million) is used for common training and the ImageNet1k dataset is used for finetuning. + +### Choice of teacher model + +In order to verify the influence of the model size difference between the teacher model and the student model on the distillation results as well as the teacher model accuracy, we conducted several experiments. The training strategy is unified as follows: `cosine_decay_warmup, lr = 1.3, epoch = 120, bs = 2048`, and the student models are all trained from scratch. + + +|Teacher Model | Teacher Top1 | Student Model | Student Top1| +|- |:-: |:-: | :-: | +| ResNeXt101_32x16d_wsl | 84.2% | MobileNetV3_large_x1_0 | 75.78% | +| ResNet50_vd | 79.12% | MobileNetV3_large_x1_0 | 75.60% | +| ResNet50_vd | 82.35% | MobileNetV3_large_x1_0 | 76.00% | + + +It can be shown from the table that: + +> When the teacher model structure is the same, the higher the teacher model accuracy, the better the final student model will be. +> +> The size difference between the teacher model and the student model should not be too large, otherwise it will decrease the accuracy of the distillation results. + +Therefore, during distillation, for the ResNet series student model, we use `ResNeXt101_32x16d_wsl` as the teacher model; for the MobileNet series student model, we use` ResNet50_vd_SSLD` as the teacher model. + + +### Distillation using large-scale dataset + +Training process is carried out on the large-scale dataset with 5 million images. Specifically, the following table shows more details of different models. + +|Student Model | num_epoch | l2_ecay | batch size/gpu cards | base lr | learning rate decay | top1 acc | +| - |:-: |:-: | :-: |:-: |:-: |:-: | +| MobileNetV1 | 360 | 3e-5 | 4096/8 | 1.6 | cosine_decay_warmup | 77.65% | +| MobileNetV2 | 360 | 1e-5 | 3072/8 | 0.54 | cosine_decay_warmup | 76.34% | +| MobileNetV3_large_x1_0 | 360 | 1e-5 | 5760/24 | 3.65625 | cosine_decay_warmup | 78.54% | +| MobileNetV3_small_x1_0 | 360 | 1e-5 | 5760/24 | 3.65625 | cosine_decay_warmup | 70.11% | +| ResNet50_vd | 360 | 7e-5 | 1024/32 | 0.4 | cosine_decay_warmup | 82.07% | +| ResNet101_vd | 360 | 7e-5 | 1024/32 | 0.4 | cosine_decay_warmup | 83.41% | +| Res2Net200_vd_26w_4s | 360 | 4e-5 | 1024/32 | 0.4 | cosine_decay_warmup | 84.82% | + +### finetuning using ImageNet1k + +Finetuning is carried out on ImageNet1k dataset to restore distribution between training set and test set. the following table shows more details of finetuning. + + +|Student Model | num_epoch | l2_ecay | batch size/gpu cards | base lr | learning rate decay | top1 acc | +| - |:-: |:-: | :-: |:-: |:-: |:-: | +| MobileNetV1 | 30 | 3e-5 | 4096/8 | 0.016 | cosine_decay_warmup | 77.89% | +| MobileNetV2 | 30 | 1e-5 | 3072/8 | 0.0054 | cosine_decay_warmup | 76.73% | +| MobileNetV3_large_x1_0 | 30 | 1e-5 | 2048/8 | 0.008 | cosine_decay_warmup | 78.96% | +| MobileNetV3_small_x1_0 | 30 | 1e-5 | 6400/32 | 0.025 | cosine_decay_warmup | 71.28% | +| ResNet50_vd | 60 | 7e-5 | 1024/32 | 0.004 | cosine_decay_warmup | 82.39% | +| ResNet101_vd | 30 | 7e-5 | 1024/32 | 0.004 | cosine_decay_warmup | 83.73% | +| Res2Net200_vd_26w_4s | 360 | 4e-5 | 1024/32 | 0.004 | cosine_decay_warmup | 85.13% | + +### Data agmentation and Fix strategy + +* Based on experiments mentioned above, we add AutoAugment [4] during training process, and reduced l2_decay from 4e-5 t 2e-5. Finally, the Top-1 accuracy on ImageNet1k dataset can reach 82.99%, with 0.6% improvement compared to the standard SSLD distillation strategy. + +* For image classsification tasks, The model accuracy can be further improved when the test scale is 1.15 times that of training[5]. For the 82.99% ResNet50_vd pretrained model, it comes to 83.7% using 320x320 for the evaluation. We use Fix strategy to finetune the model with the training scale set as 320x320. During the process, the pre-preocessing pipeline is same for both training and test. All the weights except the fully connected layer are freezed. Finally the top-1 accuracy comes to **84.0%**. + +### Some phenomena during the experiment + +In the prediction process, the average value and variance of the batch norm are obtained by loading the pretrained model (set its mode as test mode). In the training process, batch norm is obtained by counting the information of the current batch (set its mode as train mode) and calculating the moving average with the historical saved information. In the distillation task, we found that through the train mode, In the distillation task, we found that the real-time change of the bn parameter of the teacher model to guide the student model is better than the student model obtained through the test mode distillation. The following is a set of experimental results. Therefore, in this distillation scheme, we use train mode to get the soft label of the teacher model. + +|Teacher Model | Teacher Top1 | Student Model | Student Top1| +|- |:-: |:-: | :-: | +| ResNet50_vd | 82.35% | MobileNetV3_large_x1_0 | 76.00% | +| ResNet50_vd | 82.35% | MobileNetV3_large_x1_0 | 75.84% | + +## Application of the distillation model + +### Instructions + +* Adjust the learning rate of the middle layer. The middle layer feature map of the model obtained by distillation is more refined. Therefore, when the distillation model is used as the pretrained model in other tasks, if the same learning rate as before is adopted, it is easy to destroy the features. If the learning rate of the overall model training is reduced, it will bring about the problem of slow convergence. Therefore, we use the strategy of adjusting the learning rate of the middle layer. specifically: +    * For ResNet50_vd, we set up a learning rate list. The three conv2d convolution parameters before the resiual block have a uniform learning rate multiple, and the four resiual block conv2d have theirs own learning rate parameters, respectively. 5 values need to be set in the list. By the experiment, we find that when used for transfer learning finetune classification model, the learning rate list with `[0.1,0.1,0.2,0.2,0.3]` performs better in most tasks; while in the object detection tasks, `[0.05, 0.05, 0.05, 0.1, 0.15]` can bring greater accuracy gains. +    * For MoblileNetV3_large_x1_0, because it contains 15 blocks, we set each 3 blocks to share a learning rate, so 5 learning rate values are required. We find that in classification and detection tasks, the learning rate list with `[0.25, 0.25, 0.5, 0.5, 0.75]` performs better in most tasks. +* Appropriate l2 decay. Different l2 decay values are set for different models during training. In order to prevent overfitting, l2 decay is ofen set as large for large models. L2 decay is set as `1e-4` for ResNet50, and `1e-5 ~ 4e-5` for MobileNet series models. L2 decay needs also to be adjusted when applied in other tasks. Taking Faster_RCNN_MobiletNetV3_FPN as an example, we found that only modifying l2 decay can bring up to 0.5% accuracy (mAP) improvement on the COCO2017 dataset. + + +### Transfer learning + +* To verify the effect of the SSLD pretrained model in transfer learning, we carried out experiments on 10 small datasets. Here, in order to ensure the comparability of the experiment, we use the standard preprocessing process trained by the ImageNet1k dataset. For the distillation model, we also add a simple search method for the learning rate of the middle layers of the distillation pretrained model. +* For ResNet50_vd, the baseline pretrained model Top-1 Acc is 79.12%, the other parameters are got by grid search. For distillation pretrained model, we add learning rate of the middle layers into the search space. The following table shows the results. + +| Dataset | Model | Baseline Top1 Acc | Distillation Model Finetune | +|- |:-: |:-: | :-: | +| Oxford102 flowers | ResNete50_vd | 97.18% | 97.41% | +| caltech-101 | ResNete50_vd | 92.57% | 93.21% | +| Oxford-IIIT-Pets | ResNete50_vd | 94.30% | 94.76% | +| DTD | ResNete50_vd | 76.48% | 77.71% | +| fgvc-aircraft-2013b | ResNete50_vd | 88.98% | 90.00% | +| Stanford-Cars | ResNete50_vd | 92.65% | 92.76% | +| SUN397 | ResNete50_vd | 64.02% | 68.36% | +| cifar100 | ResNete50_vd | 86.50% | 87.58% | +| cifar10 | ResNete50_vd | 97.72% | 97.94% | +| Food-101 | ResNete50_vd | 89.58% | 89.99% | + +* It can be seen that on the above 10 datasets, combined with the appropriate middle layer learning rate, the distillation pretrained model can bring an average accuracy improvement of more than 1%. + +### Object detection + + +Based on the two-stage Faster/Cascade RCNN model, we verify the effect of the pretrained model obtained by distillation. + +* ResNet50_vd + +Training scale and test scale are set as 640x640, and some of the ablationstudies are as follows. + + +| Model | train/test scale | pretrain top1 acc | feature map lr | coco mAP | +|- |:-: |:-: | :-: | :-: | +| Faster RCNN R50_vd FPN | 640/640 | 79.12% | [1.0,1.0,1.0,1.0,1.0] | 34.8% | +| Faster RCNN R50_vd FPN | 640/640 | 79.12% | [0.05,0.05,0.1,0.1,0.15] | 34.3% | +| Faster RCNN R50_vd FPN | 640/640 | 82.18% | [0.05,0.05,0.1,0.1,0.15] | 36.3% | + + +It can be seen here that for the baseline pretrained model, excessive adjustment of the middle-layer learning rate actually reduces the performance of the detection model. Based on this distillation model, we also provide a practical server-side detection solution. The detailed configuration and training code are open source, more details can be refer to [PaddleDetection] (https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/rcnn_enhance). + + +## Practice + +This section will introduce the SSLD distillation experiments in detail based on the ImageNet-1K dataset. If you want to experience this method quickly, you can refer to [** Quick start PaddleClas in 30 minutes**] (../../tutorials/quick_start_en.md), whose dataset is set as Flowers102. + + + +### Configuration + + + +#### Distill MobileNetV3_small_x1_0 using MobileNetV3_large_x1_0 + +An example of SSLD distillation is provided here. The configuration file of `MobileNetV3_large_x1_0` distilling `MobileNetV3_small_x1_0` is provided in `ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml`, and the user can directly replace the path of the configuration file in `tools/train.sh` to use it. + +Configuration of distilling `MobileNetV3_large_x1_0` using `MobileNetV3_small_x1_0` is as follows. + +```yaml +Arch: + name: "DistillationModel" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - True + - False + models: + - Teacher: + name: MobileNetV3_large_x1_0 + pretrained: True + use_ssld: True + - Student: + name: MobileNetV3_small_x1_0 + pretrained: False + + infer_model_name: "Student" +``` + +In configuration file, the `freeze_params_list` needs to specify whether the model needs to freeze the parameters, the `models` needs to specify the teacher model and the student model, and the teacher model needs to load the pretrained model. The user can directly change the model here. + +### Begin to train the network + +If everything is ready, users can begin to train the network using the following command. + +```bash + +python -m paddle.distributed.launch \ + --selected_gpus="0,1,2,3" \ + --log_dir=mv3_large_x1_0_distill_mv3_small_x1_0 \ + tools/train.py \ + -c ./ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml +``` + +### Note + +* Before using SSLD, users need to train a teacher model on the target dataset firstly. The teacher model is used to guide the training of the student model. + +* If the student model is not loaded with a pretrained model, the other hyperparameters of the training can refer to the hyperparameters trained by the student model on ImageNet-1k. If the student model is loaded with the pre-trained model, the learning rate can be adjusted to `1/100~1/10` of the standard learning rate. + +* In the process of SSLD distillation, the student model only learns the soft label, which makes the training process more difficult. It is recommended that the value of `l2_decay` can be decreased appropriately to obtain higher accuracy of the validation set. + +* If users are going to add unlabeled training data, just the training list textfile needs to be adjusted for more data. + + + +> If this document is helpful to you, welcome to star our project: [https://github.com/PaddlePaddle/PaddleClas](https://github.com/PaddlePaddle/PaddleClas) + + +## Reference + +[1] Hinton G, Vinyals O, Dean J. Distilling the knowledge in a neural network[J]. arXiv preprint arXiv:1503.02531, 2015. + +[2] Bagherinezhad H, Horton M, Rastegari M, et al. Label refinery: Improving imagenet classification through label progression[J]. arXiv preprint arXiv:1805.02641, 2018. + +[3] Yalniz I Z, Jégou H, Chen K, et al. Billion-scale semi-supervised learning for image classification[J]. arXiv preprint arXiv:1905.00546, 2019. + +[4] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123. + +[5] Touvron H, Vedaldi A, Douze M, et al. Fixing the train-test resolution discrepancy[C]//Advances in Neural Information Processing Systems. 2019: 8250-8260. diff --git a/src/PaddleClas/docs/en/advanced_tutorials/distillation/index.rst b/src/PaddleClas/docs/en/advanced_tutorials/distillation/index.rst new file mode 100644 index 0000000..5548512 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/distillation/index.rst @@ -0,0 +1,7 @@ +distillation +================================ + +.. toctree:: + :maxdepth: 3 + + distillation_en.md diff --git a/src/PaddleClas/docs/en/advanced_tutorials/how_to_contribute_en.md b/src/PaddleClas/docs/en/advanced_tutorials/how_to_contribute_en.md new file mode 100644 index 0000000..4502bda --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/how_to_contribute_en.md @@ -0,0 +1,304 @@ +# How to Contribute to the PaddleClas Community + +------ + +## Catalogue + +- [1. How to Contribute Code](#1) + - [1.1 Branches of PaddleClas](#1.1) + - [1.2 Commit Code to PaddleClas](#1.2) + - [1.2.1 Codes of Fork and Clone](#1.2.1) + - [1.2.2 Connect to the Remote Repository](#1.2.2) + - [1.2.3 Create the Local Branch](#1.2.3) + - [1.2.4 Employ Pre-commit Hook](#1.2.4) + - [1.2.5 Modify and Commit Code](#1.2.5) + - [1.2.6 Keep the Local Repository Updated](#1.2.6) + - [1.2.7 Push to Remote Repository](#1.2.7) + - [1.2.8 Commit Pull Request](#1.2.8) + - [1.2.9 CLA and Unit Test](#1.2.9) + - [1.2.10 Delete Branch](#1.2.10) + - [1.2.11 Conventions](#1.2.11) +- [2. Summary](#2) +- [3. Inferences](#3) + + + +## 1. How to Contribute Code + + + +### 1.1 Branches of PaddleClas + +PaddleClas maintains the following two branches: + +- release/x.x series: Stable release branches, which are tagged with the release version of Paddle in due course. +The latest and the default branch is the release/2.3, which is compatible with Paddle v2.1.0. +The branch of release/x.x series will continue to grow with future iteration, +and the latest release will be maintained by default, while the former one will fix bugs with no other branches covered. +- develop : developing branch, which is adapted to the develop version of Paddle and is mainly used for +developing new functions. A good choice for secondary development. +To ensure that the develop branch can pull out the release/x.x when needed, +only the API that is valid in Paddle's latest release branch can be adopted for its code. +In other words, if a new API has been developed in this branch but not yet in the release, +please do not use it in PaddleClas. Apart from that, features that do not involve the performance optimizations, +parameter adjustments, and policy updates of the API can be developed normally. + +The historical branches of PaddleClas will not be maintained, but will be remained for the existing users. + +- release/static: This branch was used for static graph development and testing, +and is currently compatible with >=1.7 versions of Paddle. +It is still practicable for the special need of adapting an old version of Paddle, +but the code will not be updated except for bug fixing. +- dygraph-dev: This branch will no longer be maintained and accept no new code. +Please transfer to the develop branch as soon as possible. + +PaddleClas welcomes code contributions to the repo, and the basic process is detailed in the next part. + + + +### 1.2 Commit the Code to PaddleClas + + + +#### 1.2.1 Codes of Fork and Clone + +- Skip to the home page of [PaddleClas GitHub](https://github.com/PaddlePaddle/PaddleClas) and click the +Fork button to generate a repository in your own directory, such as `https://github.com/USERNAME/PaddleClas`. + +[](../../images/quick_start/community/001_fork.png) + +- Clone the remote repository to local + +```shell +# Pull the code of the develop branch +git clone https://github.com/USERNAME/PaddleClas.git -b develop +cd PaddleClas +``` + +Obtain the address below + +[](../../images/quick_start/community/002_clone.png) + + + +#### 1.2.2 Connect to the Remote Repository + +First check the current information of the remote repository with `git remote -v`. + +```shell +origin https://github.com/USERNAME/PaddleClas.git (fetch) +origin https://github.com/USERNAME/PaddleClas.git (push) +``` + +The above information only contains the cloned remote repository, +which is the PaddleClas under your username. Then we create a remote host of the original PaddleClas repository named upstream. + +```shell +git remote add upstream https://github.com/PaddlePaddle/PaddleClas.git +``` + +Adopt `git remote -v` to view the current information of the remote repository, +and 2 remote repositories including origin and upstream can be found, as shown below. + +```shell +origin https://github.com/USERNAME/PaddleClas.git (fetch) +origin https://github.com/USERNAME/PaddleClas.git (push) +upstream https://github.com/PaddlePaddle/PaddleClas.git (fetch) +upstream https://github.com/PaddlePaddle/PaddleClas.git (push) +``` + +This is mainly to keep the local repository updated when committing a pull request (PR). + + + +#### 1.2.3 Create the Local Branch + +Run the following command to create a new local branch based on the current one. + +```shell +git checkout -b new_branch +``` + +Or you can create new ones based on remote or upstream branches. + +```shell +# Create the new_branch based on the develope of origin (unser remote repository) +git checkout -b new_branch origin/develop +# Create the new_branch base on the develope of upstream +# If you need to create a new branch from upstream, +# please first employ git fetch upstream to fetch the upstream code +git checkout -b new_branch upstream/develop +``` + +The following output shows that it has switched to the new branch with : + +``` +Branch new_branch set up to track remote branch develop from upstream. +Switched to a new branch 'new_branch' +``` + + + +#### 1.2.4 Employ Pre-commit Hook + +Paddle developers adopt the pre-commit tool to manage Git pre-commit hooks. +It helps us format the source code (C++, Python) and automatically check basic issues before committing +e.g., one EOL per file, no large files added to Git, etc. + +The pre-commit test is part of the unit tests in Travis-CI, +and PRs that do not satisfy the hook cannot be committed to PaddleClas. +Please install it first and run it in the current directory: + +``` +pip install pre-commit +pre-commit install +``` + +- **Note** + +1. Paddle uses clang-format to format C/C++ source code, please make sure `clang-format` has a version of 3.8 or higher. +2. `yapf` installed by `pip install pre-commit` and `conda install -c conda-forge pre-commit` is slightly different, +and the former one is chosen by PaddleClas developers. + + + +#### 1.2.5 Modify and Commit Code + +You can check the changed files via `git status`. Follow the steps below to commit the `README.md` of PaddleClas after modification: + +``` +git add README.md +pre-commit +``` + +Repeat the above steps until the pre-commit format check does not report an error, as shown below. + +[](../../images/quick_start/community/003_precommit_pass.png) + +Run the following command to commit. + +``` +git commit -m "your commit info" +``` + + + +#### 1.2.6 Keep the Local Repository Updated + +Get the latest code for upstream and update the current branch. +The upstream here is from the `Connecting to a remote repository` part in section 1.2. + +``` +git fetch upstream +# If you want to commit to another branch, please pull the code from another branch of upstream, in this case it is develop +git pull upstream develop +``` + + + +#### 1.2.7 Push to Remote Repository + +``` +git push origin new_branch +``` + + + +#### 1.2.8 Commit Pull Request + +Click new pull request and select the local branch and the target branch, +as shown in the following figure. In the description of the PR, fill out what the PR accomplishes. +Next, wait for the review, and if any changes are required, +update the corresponding branch in origin by referring to the above steps. + +[](../../images/quick_start/community/004_create_pr.png) + + + +#### 1.2.9 CLA and Unit Test + +- When you first commit a Pull Request to PaddlePaddle, +you are required to sign a CLA (Contributor License Agreement) to ensure that your code can be merged, +please follow the step below to sign CLA: + +1. Please examine the Check section of your PR, find license/cla, +and click the detail on the right side to enter the CLA website +2. Click `Sign in with GitHub to agree` on the CLA website, +and you will be redirected back to your Pull Request page when you are done. + + + +#### 1.2.10 Delete Branch + +- Delete remote branch + +When the PR is merged into the main repository, you can delete the remote branch from the PR page. + +You can also delete the remote branch using `git push origin :branch name`, e.g. + +``` +git push origin :new_branch +``` + +- Delete local branch + +``` +# Switch to the develop branch, otherwise the current branch cannot be deleted +git checkout develop + +# Delete new_branch +git branch -D new_branch +``` + + + +#### 1.2.11 Conventions + +To help official maintainers focus on the code itself when reviewing it, +please adhere to the following conventions each time you commit code: + +1. Please pass the unit test in Travis-CI first. +Otherwise, the submitted code may have problems and usually receive no official review. +2. Before committing a Pull Request: +Note the number of commits. + +Reason: If only one file is modified but more than a dozen commits are committed with a few changes for each, +this may overwhelm the reviewer for they need to check each and every commit for specific changes, +including the case that the changes between commits overwrite each other. + +Recommendation: Minimize the number of commits each time, and add the last commit with `git commit --amend`. +For multiple commits that have been pushed to a remote repository, please refer to +[squash commits after push](https://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed). + +Please pay attention to the name of each commit: +it should reflect the content of the current commit without being too casual. + +3. If an issue is resolved, please add `fix #issue_number` to the first comment box of the Pull Request, +so that the corresponding issue will be closed automatically when the Pull Request is merged. Please choose the appropriate term with keywords such as close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved, please choose the appropriate term. See details in [Closing issues via commit messages](https://help.github.com/articles/closing-issues-via-commit-messages). + +In addition, please stick to the following convention to respond to reviewers' comments: + +1. Every review comment from the official maintainer is expected to be answered, +which will better enhance the contribution of the open source community. + +- If you agree with the review and finish the corresponding modification, please simply return Done; +- If you disagree with the review, please give your reasons. + +2. If there are plenty of review comments, + +- Please present the revision in general. +- Please reply with `start a review` instead of a direct approach, for it may be overwhelming to receive the email of every reply. + + + +## 2. Summary + +- The open source community relies on the contributions and feedback of developers and users. +We highly appreciate that and look forward to your valuable comments and Pull Requests to PaddleClas in the hope that together we can build a leading practical and comprehensive code repository for image recognition! + + + +## 3. References + +1. [Guide to PaddlePaddle Local Development](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/08_contribution/index_en.html) +2. [Committing PR to Open Source Framework](https://blog.csdn.net/vim_wj/article/details/78300239) diff --git a/src/PaddleClas/docs/en/advanced_tutorials/index.rst b/src/PaddleClas/docs/en/advanced_tutorials/index.rst new file mode 100644 index 0000000..e741733 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/index.rst @@ -0,0 +1,12 @@ +advanced_tutorials +================================ + +.. toctree:: + :maxdepth: 2 + + DataAugmentation_en.md + distillation/index + multilabel/index + model_prune_quantization_en.md + code_overview_en.md + how_to_contribute_en.md diff --git a/src/PaddleClas/docs/en/advanced_tutorials/model_prune_quantization_en.md b/src/PaddleClas/docs/en/advanced_tutorials/model_prune_quantization_en.md new file mode 100644 index 0000000..1946cfa --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/model_prune_quantization_en.md @@ -0,0 +1,180 @@ +# Model Quantization and Pruning + +Complex models are conducive to better model performance, but they may also lead to certain redundancy. This section presents ways to streamline the model, including model quantization (quantization training and offline quantization) and model pruning. + +Model quantization reduces the full precision to a fixed number of points to lower the redundancy and achieve the purpose of simplifying the model computation and improving model inference performance. Model quantization can reduce the size of model parameters by converting its precision from FP32 to Int8 without losing model precision, followed by accelerated computation, creating a quantized model with more speed advantages when deployed on mobile devices. + +Model pruning decreases the number of model parameters by cutting out the unimportant convolutional kernels in the CNN, thus bringing down the computational complexity. + +This tutorial explains how to use PaddleSlim, PaddlePaddle's model compression library, for PaddleClas compression, i.e., pruning and quantization. [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) integrates a variety of common and leading model compression functions such as model pruning, quantization (including quantization training and offline quantization), distillation, and neural network search. If you are interested, please follow us and learn more. + +To start with, you are recommended to learn [PaddleClas Training](../models_training/classification_en.md) and [PaddleSlim](https://paddleslim.readthedocs.io/zh_CN/latest/index.html), see [Model Pruning and Quantization Algorithms](../algorithm_introduction/model_prune_quantization_en.md) for related pruning and quantization methods. + +------ + +## Catalogue + +- [1. Prepare the Environment](#1) + - [1.1 Install PaddleSlim](#1.1) + - [1.2 Prepare the Trained Model](#1.2) +- [2. Quick Start](#2) + - [2.1 Model Quantization](#2.1) + - [2.1.1 Online Quantization Training](#2.1.1) + - [2.1.2 Offline Quantization](#2.1.2) + - [2.2 Model Pruning](#2.2) +- [3. Export the Model](#3) +- [4. Deploy the Model](#4) +- [5. Hyperparameter Training](#5) + + + +## 1. Prepare the Environment + +Once a model has been trained, you can adopt quantization or pruning to further compress the model size and speed up the inference. + +Five steps are included: + +1. Install PaddleSlim +2. Prepare the trained the model +3. Compress the model +4. Export quantized inference model +5. Inference and deployment of the quantized model + + + +### 1.1 Install PaddleSlim + +- You can adopt pip install for installation. + +``` +pip install paddleslim -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +- You can also install it from the source code with the latest features of PaddleSlim. + +``` +git clone https://github.com/PaddlePaddle/PaddleSlim.git +cd Paddleslim +python3.7 setup.py install +``` + + + +### 1.2 Prepare the Trained Model + +PaddleClas offers a list of trained [models](../models/models_intro_en.md). If the model to be quantized is not in the list, you need to follow the [regular training](../models_training/classification_en.md) method to get the trained model. + + + +## 2. Quick Start + +Go to PaddleClas root directory + +```shell +cd PaddleClas +``` + +Related code for `slim` training has been integrated under `ppcls/engine/`, and the offline quantization code can be found in `deploy/slim/quant_post_static.py`. + + + +### 2.1 Model Quantization + +Quantization training includes offline and online training. Online quantitative training, the more effective one, requires loading a pre-trained model, which can be quantized after defining the strategy. + + + +#### 2.1.1 Online Quantization Training + +Try the following command: + +- CPU/Single GPU + +Take CPU for example, if you use GPU, change the `cpu` to `gpu`. + +``` +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.device=cpu +``` + +The parsing of the `yaml` file is described in [reference document](../models_training/config_description_en.md). For accuracy, the `pretrained model` has already been adopted by the `yaml` file. + +- Launch in single-machine multi-card/ multi-machine multi-card mode + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +``` + + + +#### 2.1.2 Offline Quantization + +**Note**: Currently, the `inference model` exported from the trained model is a must for offline quantization. See the [tutorial](../inference_deployment/export_model_en.md) for general export of the `inference model`. + +Normally, offline quantization may lose more accuracy. + +After generating the `inference model`, the offline quantization is run as follows: + +```shell +python3.7 deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./deploy/models/class_ResNet50_vd_ImageNet_infer +``` + +The `inference model` is stored in`Global.save_inference_dir`. + +Successfully executed, the `quant_post_static_model` folder is created in the `Global.save_inference_dir`, where the generated offline quantization models are stored and can be deployed directly without re-exporting the models. + + + +### 2.2 Model Pruning + +Trying the following command: + +- CPU/Single GPU + +Take CPU for example, if you use GPU, change the `cpu` to `gpu`. + +```shell +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.device=cpu +``` + +- Launch in single-machine single-card/ single-machine multi-card/ multi machine multi-card mode + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml +``` + + + +## 3. Export the Model + +Having obtained the saved model after online quantization training and pruning, it can be exported as an inference model for inference deployment. Here we take model pruning as an example: + +``` +python3.7 tools/export.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml \ + -o Global.pretrained_model=./output/ResNet50_vd/best_model \ + -o Global.save_inference_dir=./inference +``` + + + +## 4. Deploy the Model + +The exported model can be deployed directly using inference, please refer to [inference deployment](../inference_deployment/). + +You can also use PaddleLite's opt tool to convert the inference model to a mobile model for its mobile deployment. Please refer to [Mobile Model Deployment](../inference_deployment/paddle_lite_deploy_en.md) for more details. + + + +## 5. Hyperparameter Training + +- For quantization and pruning training, it is recommended to load the pre-trained model obtained from conventional training to accelerate the convergence of quantization training. +- For quantization training, it is recommended to modify the initial learning rate to `1/20~1/10` of the conventional training and the number of training epochs to `1/5~1/2`, while adding Warmup to the learning rate strategy. Please make no other modifications to the configuration information. +- For pruning training, the hyperparameter configuration is recommended to remain the same as the regular training. diff --git a/src/PaddleClas/docs/en/advanced_tutorials/multilabel/index.rst b/src/PaddleClas/docs/en/advanced_tutorials/multilabel/index.rst new file mode 100644 index 0000000..07e0a54 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/multilabel/index.rst @@ -0,0 +1,7 @@ +Multilabel Classification +================================ + +.. toctree:: + :maxdepth: 3 + + multilabel_en.md \ No newline at end of file diff --git a/src/PaddleClas/docs/en/advanced_tutorials/multilabel/multilabel_en.md b/src/PaddleClas/docs/en/advanced_tutorials/multilabel/multilabel_en.md new file mode 100644 index 0000000..46a89f0 --- /dev/null +++ b/src/PaddleClas/docs/en/advanced_tutorials/multilabel/multilabel_en.md @@ -0,0 +1,92 @@ +# Multilabel classification quick start + +Based on the [NUS-WIDE-SCENE](https://lms.comp.nus.edu.sg/wp-content/uploads/2019/research/nuswide/NUS-WIDE.html) dataset which is a subset of NUS-WIDE dataset, you can experience multilabel of PaddleClas, include training, evaluation and prediction. Please refer to [Installation](../../installation/) to install at first. + +## Preparation + +* Enter PaddleClas directory + +``` +cd path_to_PaddleClas +``` + +* Create and enter `dataset/NUS-WIDE-SCENE` directory, download and decompress NUS-WIDE-SCENE dataset + +```shell +mkdir dataset/NUS-WIDE-SCENE +cd dataset/NUS-WIDE-SCENE +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/NUS-SCENE-dataset.tar +tar -xf NUS-SCENE-dataset.tar +``` + +* Return `PaddleClas` root home + +``` +cd ../../ +``` + +## Training + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml +``` + +After training for 10 epochs, the best accuracy over the validation set should be around 0.95. + +## Evaluation + +```bash +python tools/eval.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + +## Prediction + +```bash +python3 tools/infer.py + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + +You will get multiple output such as the following: +``` +[{'class_ids': [6, 13, 17, 23, 26, 30], 'scores': [0.95683, 0.5567, 0.55211, 0.99088, 0.5943, 0.78767], 'file_name': './deploy/images/0517_2715693311.jpg', 'label_names': []}] +``` + +## Prediction based on prediction engine + +### Export model + +```bash +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + +The default path of the inference model is under the current path `./inference` + +### Prediction based on prediction engine + +Enter the deploy directory: + +```bash +cd ./deploy +``` + +Prediction based on prediction engine: + +``` +python3 python/predict_cls.py \ + -c configs/inference_multilabel_cls.yaml +``` + +You will get multiple output such as the following: + +``` +0517_2715693311.jpg: class id(s): [6, 13, 17, 23, 26, 30], score(s): [0.96, 0.56, 0.55, 0.99, 0.59, 0.79], label_name(s): [] +``` diff --git a/src/PaddleClas/docs/en/algorithm_introduction/DataAugmentation_en.md b/src/PaddleClas/docs/en/algorithm_introduction/DataAugmentation_en.md new file mode 100644 index 0000000..9ada02f --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/DataAugmentation_en.md @@ -0,0 +1,264 @@ +# Data Augmentation +------ + +## Catalogue + + - [1. Introduction to data augmentation](#1) + - [2. Common data augmentation methods](#2) + - [2.1 Image Transformation](#2.1) + - [2.1.1 AutoAugment](#2.1.1) + - [2.1.2 RandAugment](#2.1.2) + - [2.1.3 TimmAutoAugment](#2.1.3) + - [2.2 Image Cropping](#2.2) + - [2.2.1 Cutout](#2.2.1) + - [2.2.2 RandomErasing](#2.2.2) + - [2.2.3 HideAndSeek](#2.2.3) + - [2.2.4 GridMask](#2.2.4) + - [2.3 Image mix](#2.3) + - [2.3.1 Mixup](#2.3.1) + - [2.3.2 Cutmix](#2.3.2) + + +## 1. Introduction to data augmentation + +Data augmentation is a commonly used regularization method in image classification task, which is often used in scenarios with insufficient data or large model. In this chapter, we mainly introduce 8 image augmentation methods besides standard augmentation methods. Users can apply these methods in their own tasks for better model performance. Under the same conditions, these augmentation methods' performance on ImageNet1k dataset is shown as follows. + +![](../../images/image_aug/main_image_aug.png) + + + +## 2. Common data augmentation methods + +If without special explanation, all the examples and experiments in this chapter are based on ImageNet1k dataset with the network input image size set as 224. + +The standard data augmentation pipeline in ImageNet classification tasks contains the following steps. + +1. Decode image, abbreviated as `ImageDecode`. +2. Randomly crop the image to size with 224x224, abbreviated as `RandCrop`. +3. Randomly flip the image horizontally, abbreviated as `RandFlip`. +4. Normalize the image pixel values, abbreviated as `Normalize`. +5. Transpose the image from `[224, 224, 3]`(HWC) to `[3, 224, 224]`(CHW), abbreviated as `Transpose`. +6. Group the image data(`[3, 224, 224]`) into a batch(`[N, 3, 224, 224]`), where `N` is the batch size. It is abbreviated as `Batch`. + + +Compared with the above standard image augmentation methods, the researchers have also proposed many improved image augmentation strategies. These strategies are to insert certain operations at different stages of the standard augmentation method, based on the different stages of operation. We divide it into the following three categories. + +1. Transformation. Perform some transformations on the image after `RandCrop`, such as AutoAugment and RandAugment. +2. Cropping. Perform some transformations on the image after `Transpose`, such as CutOut, RandErasing, HideAndSeek and GridMask. +3. Aliasing. Perform some transformations on the image after `Batch`, such as Mixup and Cutmix. + + +Visualization results of some images after augmentation are shown as follows. + +![](../../images/image_aug/image_aug_samples_s_en.jpg) + + +The following table shows more detailed information of the transformations. + + +| Method | Input | Output | Auto-
Augment\[1\] | Rand-
Augment\[2\] | CutOut\[3\] | Rand
Erasing\[4\] | HideAnd-
Seek\[5\] | GridMask\[6\] | Mixup\[7\] | Cutmix\[8\] | +|-------------|---------------------------|---------------------------|------------------|------------------|-------------|------------------|------------------|---------------|------------|------------| +| Image
Decode | Binary | (224, 224, 3)
uint8 | Y | Y | Y | Y | Y | Y | Y | Y | +| RandCrop | (:, :, 3)
uint8 | (224, 224, 3)
uint8 | Y | Y | Y | Y | Y | Y | Y | Y | +| **Process** | (224, 224, 3)
uint8 | (224, 224, 3)
uint8 | Y | Y | \- | \- | \- | \- | \- | \- | +| RandFlip | (224, 224, 3)
uint8 | (224, 224, 3)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| Normalize | (224, 224, 3)
uint8 | (3, 224, 224)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| Transpose | (224, 224, 3)
float32 | (3, 224, 224)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| **Process** | (3, 224, 224)
float32 | (3, 224, 224)
float32 | \- | \- | Y | Y | Y | Y | \- | \- | +| Batch | (3, 224, 224)
float32 | (N, 3, 224, 224)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| **Process** | (N, 3, 224, 224)
float32 | (N, 3, 224, 224)
float32 | \- | \- | \- | \- | \- | \- | Y | Y | + + + +PaddleClas integrates all the above data augmentation strategies. More details including principles and usage of the strategies are introduced in the following chapters. For better visualization, we use the following figure to show the changes after the transformations. And `RandCrop` is replaced with` Resize` for simplification. + +![](../../images/image_aug/test_baseline.jpeg) + + +### 2.1 Image Transformation + +Transformation means performing some transformations on the image after `RandCrop`. It mainly contains AutoAugment and RandAugment. + + +#### 2.1.1 AutoAugment + +Address:[https://arxiv.org/abs/1805.09501v1](https://arxiv.org/abs/1805.09501v1) + +Github repo:[https://github.com/DeepVoltaire/AutoAugment](https://github.com/DeepVoltaire/AutoAugment) + + +Unlike conventional artificially designed image augmentation methods, AutoAugment is an image augmentation solution suitable for a specific data set found by certain search algorithm in the search space of a series of image augmentation sub-strategies. For the ImageNet dataset, the final data augmentation solution contains 25 sub-strategy combinations. Each sub-strategy contains two transformations. For each image, a sub-strategy combination is randomly selected and then determined with a certain probability Perform each transformation in the sub-strategy. + +The images after `AutoAugment` are as follows. + +![](../../images/image_aug/test_autoaugment.jpeg) + + +#### 2.1.2 RandAugment + +Address: [https://arxiv.org/pdf/1909.13719.pdf](https://arxiv.org/pdf/1909.13719.pdf) + +Github repo: [https://github.com/heartInsert/randaugment](https://github.com/heartInsert/randaugment) + + +The search method of `AutoAugment` is relatively violent. Searching for the optimal strategy for this data set directly on the data set requires a lot of computation. In `RandAugment`, the author found that on the one hand, for larger models and larger datasets, the gains generated by the augmentation method searched using `AutoAugment` are smaller. On the other hand, the searched strategy is limited to certain dataset, which has poor generalization performance and not sutable for other datasets. + +In `RandAugment`, the author proposes a random augmentation method. Instead of using a specific probability to determine whether to use a certain sub-strategy, all sub-strategies are selected with the same probability. The experiments in the paper also show that this method performs well even for large models. + +The images after `RandAugment` are as follows. + +![](../../images/image_aug/test_randaugment.jpeg) + + +#### 2.1.3 TimmAutoAugment + +Github open source code address: [https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/auto_augment.py](https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/auto_augment.py) + +`TimmAutoAugment` is an improvement of AutoAugment and RandAugment by open source authors. Facts have proved that it has better performance on many visual tasks. At present, most VisionTransformer models are implemented based on TimmAutoAugment. + + +### 2.2 Image Cropping + +Cropping means performing some transformations on the image after `Transpose`, setting pixels of the cropped area as certain constant. It mainly contains CutOut, RandErasing, HideAndSeek and GridMask. + +Image cropping methods can be operated before or after normalization. The difference is that if we crop the image before normalization and fill the areas with 0, the cropped areas' pixel values will not be 0 after normalization, which will cause grayscale distribution change of the data. + +The above-mentioned cropping transformation ideas are the similar, all to solve the problem of poor generalization ability of the trained model on occlusion images, the difference lies in that their cropping details. + + +#### 2.2.1 Cutout + +Address: [https://arxiv.org/abs/1708.04552](https://arxiv.org/abs/1708.04552) + +Github repo: [https://github.com/uoguelph-mlrg/Cutout](https://github.com/uoguelph-mlrg/Cutout) + + +Cutout is a kind of dropout, but occludes input image rather than feature map. It is more robust to noise than noise. Cutout has two advantages: (1) Using Cutout, we can simulate the situation when the subject is partially occluded. (2) It can promote the model to make full use of more content in the image for classification, and prevent the network from focusing only on the saliency area, thereby causing overfitting. + +The images after `Cutout` are as follows. + +![](../../images/image_aug/test_cutout.jpeg) + + +#### 2.2.2 RandomErasing + +Address: [https://arxiv.org/pdf/1708.04896.pdf](https://arxiv.org/pdf/1708.04896.pdf) + +Github repo: [https://github.com/zhunzhong07/Random-Erasing](https://github.com/zhunzhong07/Random-Erasing) + +RandomErasing is similar to the Cutout. It is also to solve the problem of poor generalization ability of the trained model on images with occlusion. The author also pointed out in the paper that the way of random cropping is complementary to random horizontal flipping. The author also verified the effectiveness of the method on pedestrian re-identification (REID). Unlike `Cutout`, in` `, `RandomErasing` is operateed on the image with a certain probability, size and aspect ratio of the generated mask are also randomly generated according to pre-defined hyperparameters. + +The images after `RandomErasing` are as follows. + +![](../../images/image_aug/test_randomerassing.jpeg) + + +#### 2.2.3 HideAndSeek + +Address: [https://arxiv.org/pdf/1811.02545.pdf](https://arxiv.org/pdf/1811.02545.pdf) + +Github repo: [https://github.com/kkanshul/Hide-and-Seek](https://github.com/kkanshul/Hide-and-Seek) + + +Images are divided into some patches for `HideAndSeek` and masks are generated with certain probability for each patch. The meaning of the masks in different areas is shown in the figure below. + +![](../../images/image_aug/hide-and-seek-visual.png) + +The images after `HideAndSeek` are as follows. + +![](../../images/image_aug/gridmask-0.png) + + +#### 2.2.4 GridMask +Address:[https://arxiv.org/abs/2001.04086](https://arxiv.org/abs/2001.04086) + +Github repo:[https://github.com/akuxcw/GridMask](https://github.com/akuxcw/GridMask) + + +The author points out that the previous method based on image cropping has two problems, as shown in the following figure: + +1. Excessive deletion of the area may cause most or all of the target subject to be deleted, or cause the context information loss, resulting in the images after enhancement becoming noisy data. +2. Reserving too much area has little effect on the object and context. + +![](../../images/image_aug/hide-and-seek-visual.png) + +Therefore, it is the core problem to be solved how to +if you avoid over-deletion or over-retention becomes the core problem to be solved. + +`GridMask` is to generate a mask with the same resolution as the original image and multiply it with the original image. The mask grid and size are adjusted by the hyperparameters. + +In the training process, there are two methods to use: +1. Set a probability p and use the GridMask to augment the image with probability p from the beginning of training. +2. Initially set the augmentation probability to 0, and the probability is increased with number of iterations from 0 to p. + +It shows that the second method is better. + +The images after `GridMask` are as follows. + +![](../../images/image_aug/test_gridmask.jpeg) + + +### 2.3 Image mix + +mix means performing some transformations on the image after `Batch`, which contains Mixup and Cutmix. + +Data augmentation methods introduced before are based on single image while mixing is carried on a certain batch to generate a new batch. + + +#### 2.3.1 Mixup + +Address: [https://arxiv.org/pdf/1710.09412.pdf](https://arxiv.org/pdf/1710.09412.pdf) + +Github repo: [https://github.com/facebookresearch/mixup-cifar10](https://github.com/facebookresearch/mixup-cifar10) + +Mixup is the first solution for image aliasing, it is easy to realize and performs well not only on image classification but also on object detection. Mixup is usually carried out in a batch for simplification, so as `Cutmix`. + +The images after `Mixup` are as follows. + +![](../../images/image_aug/test_mixup.png) + + +#### 2.3.2 Cutmix + +Address: [https://arxiv.org/pdf/1905.04899v2.pdf](https://arxiv.org/pdf/1905.04899v2.pdf) + +Github repo: [https://github.com/clovaai/CutMix-PyTorch](https://github.com/clovaai/CutMix-PyTorch) + +Unlike `Mixup` which directly adds two images, for Cutmix, an `ROI` is cut out from one image and +Cutmix randomly cuts out an `ROI` from one image, and then covered onto the corresponding area in the another image. + +The images after `Cutmix` are as follows. + +![](../../images/image_aug/test_cutmix.png) + +For the practical part of data augmentation, please refer to [Data Augmentation Practice](../advanced_tutorials/DataAugmentation_en.md). + +## Reference + +[1] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123. + +[2] Cubuk E D, Zoph B, Shlens J, et al. Randaugment: Practical automated data augmentation with a reduced search space[J]. arXiv preprint arXiv:1909.13719, 2019. + +[3] DeVries T, Taylor G W. Improved regularization of convolutional neural networks with cutout[J]. arXiv preprint arXiv:1708.04552, 2017. + +[4] Zhong Z, Zheng L, Kang G, et al. Random erasing data augmentation[J]. arXiv preprint arXiv:1708.04896, 2017. + +[5] Singh K K, Lee Y J. Hide-and-seek: Forcing a network to be meticulous for weakly-supervised object and action localization[C]//2017 IEEE international conference on computer vision (ICCV). IEEE, 2017: 3544-3553. + +[6] Chen P. GridMask Data Augmentation[J]. arXiv preprint arXiv:2001.04086, 2020. + +[7] Zhang H, Cisse M, Dauphin Y N, et al. mixup: Beyond empirical risk minimization[J]. arXiv preprint arXiv:1710.09412, 2017. + +[8] Yun S, Han D, Oh S J, et al. Cutmix: Regularization strategy to train strong classifiers with localizable features[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 6023-6032. + +[test_baseline]: ../../../images/image_aug/test_baseline.jpeg +[test_autoaugment]: ../../../images/image_aug/test_autoaugment.jpeg +[test_cutout]: ../../../images/image_aug/test_cutout.jpeg +[test_gridmask]: ../../../images/image_aug/test_gridmask.jpeg +[gridmask-0]: ../../../images/image_aug/gridmask-0.png +[test_hideandseek]: ../../../images/image_aug/test_hideandseek.jpeg +[test_randaugment]: ../../../images/image_aug/test_randaugment.jpeg +[test_randomerassing]: ../../../images/image_aug/test_randomerassing.jpeg +[hide_and_seek_mask_expanation]: ../../../images/image_aug/hide-and-seek-visual.png +[test_mixup]: ../../../images/image_aug/test_mixup.png +[test_cutmix]: ../../../images/image_aug/test_cutmix.png diff --git a/src/PaddleClas/docs/en/algorithm_introduction/ImageNet_models_en.md b/src/PaddleClas/docs/en/algorithm_introduction/ImageNet_models_en.md new file mode 100644 index 0000000..c9d0a72 --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/ImageNet_models_en.md @@ -0,0 +1,599 @@ +# ImageNet Model zoo overview + +## Catalogue + +- [1. Model library overview diagram](#1) +- [2. SSLD pretrained models](#2) + - [2.1 Server-side knowledge distillation model](#2.1) + - [2.2 Mobile-side knowledge distillation model](#2.2) + - [2.3 Intel-CPU-side knowledge distillation model](#2.3) +- [3. PP-LCNet series](#3) +- [4. ResNet series](#4) +- [5. Mobile series](#5) +- [6. SEResNeXt and Res2Net series](#6) +- [7. DPN and DenseNet series](#7) +- [8. HRNet series](#8) +- [9. Inception series](#9) +- [10. EfficientNet ans ResNeXt101_wsl series](#10) +- [11. ResNeSt and RegNet series](#11) +- [12. ViT and DeiT series](#12) +- [13. RepVGG series](#13) +- [14. MixNet series](#14) +- [15. ReXNet series](#15) +- [16. SwinTransformer series](#16) +- [17. LeViT series](#17) +- [18. Twins series](#18) +- [19. HarDNet series](#19) +- [20. DLA series](#20) +- [21. RedNet series](#21) +- [22. TNT series](#22) +- [23. Other models](#23) +- [Reference](#reference) + + + +## 1. Model library overview diagram + +Based on the ImageNet-1k classification dataset, the 37 classification network structures supported by PaddleClas and the corresponding 217 image classification pretrained models are shown below. Training trick, a brief introduction to each series of network structures, and performance evaluation will be shown in the corresponding chapters. The evaluation environment is as follows. + +* Arm CPU evaluation environment is based on Snapdragon 855 (SD855). +* Intel CPU evaluation environment is based on Intel(R) Xeon(R) Gold 6148. +* The GPU evaluation speed is measured by running 2100 times under the FP32+TensorRT configuration (excluding the warmup time of the first 100 times). +* FLOPs and Params are calculated by `paddle.flops()` (PaddlePaddle version is 2.2) + +Curves of accuracy to the inference time of common server-side models are shown as follows. + +![](../../images/models/V100_benchmark/v100.fp32.bs1.main_fps_top1_s.png) + +Curves of accuracy to the inference time of common mobile-side models are shown as follows. + +![](../../images/models/mobile_arm_top1.png) + +Curves of accuracy to the inference time of some VisionTransformer models are shown as follows. + +![](../../images/models/V100_benchmark/v100.fp32.bs1.visiontransformer.png) + + + +## 2. SSLD pretrained models +Accuracy and inference time of the prtrained models based on SSLD distillation are as follows. More detailed information can be refered to [SSLD distillation tutorial](../advanced_tutorials/distillation/distillation_en.md). + + + +### 2.1 Server-side knowledge distillation model + +| Model | Top-1 Acc | Reference
Top-1 Acc | Acc gain | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|---------------------|-----------|-----------|---------------|----------------|-----------|----------|-----------|-----------------------------------|-----------------------------------|-----------------------------------| +| ResNet34_vd_ssld | 0.797 | 0.760 | 0.037 | 2.00 | 3.28 | 5.84 | 3.93 | 21.84 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_ssld_pretrained.pdparams)   | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_vd_ssld_infer.tar)   | +| ResNet50_vd_ssld | 0.830 | 0.792 | 0.039 | 2.60 | 4.86 | 7.63 | 4.35 | 25.63 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_ssld_infer.tar) | +| ResNet101_vd_ssld | 0.837 | 0.802 | 0.035 | 4.43 | 8.25 | 12.60 | 8.08 | 44.67 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_vd_ssld_infer.tar) | +| Res2Net50_vd_26w_4s_ssld | 0.831 | 0.798 | 0.033 | 3.59 | 6.35 | 9.50 | 4.28 | 25.76 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_vd_26w_4s_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_vd_26w_4s_ssld_infer.tar) | +| Res2Net101_vd_
26w_4s_ssld | 0.839 | 0.806 | 0.033 | 6.34 | 11.02 | 16.13 | 8.35 | 45.35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net101_vd_26w_4s_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net101_vd_26w_4s_ssld_infer.tar) | +| Res2Net200_vd_
26w_4s_ssld | 0.851 | 0.812 | 0.049 | 11.45 | 19.77 | 28.81 | 15.77 | 76.44 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net200_vd_26w_4s_ssld_infer.tar) | +| HRNet_W18_C_ssld | 0.812 | 0.769 | 0.043 | 6.66 | 8.94 | 11.95 | 4.32 | 21.35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W18_C_ssld_infer.tar) | +| HRNet_W48_C_ssld | 0.836 | 0.790 | 0.046 | 11.07 | 17.06 | 27.28 | 17.34 | 77.57 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W48_C_ssld_infer.tar) | +| SE_HRNet_W64_C_ssld | 0.848 | - | - | 17.11 | 26.87 | 43.24 | 29.00 | 129.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/SE_HRNet_W64_C_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_HRNet_W64_C_ssld_infer.tar) | + + + +### 2.2 Mobile-side knowledge distillation model + +| Model | Top-1 Acc | Reference
Top-1 Acc | Acc gain | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | FLOPs(M) | Params(M) | Model大小(M) | Pretrained Model Download Address | Inference Model Download Address | +|---------------------|-----------|-----------|---------------|----------------|-----------|----------|-----------|-----------------------------------|-----------------------------------|-----------------------------------|-----------------------------------| +| MobileNetV1_ssld | 0.779 | 0.710 | 0.069 | 30.24 | 17.86 | 10.30 | 578.88 | 4.25 | 16 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_ssld_infer.tar) | +| MobileNetV2_ssld | 0.767 | 0.722 | 0.045 | 20.74 | 12.71 | 8.10 | 327.84 | 3.54 | 14 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_ssld_infer.tar) | +| MobileNetV3_small_x0_35_ssld | 0.556 | 0.530 | 0.026 | 2.23 | 1.66 | 1.43 | 14.56 | 1.67 | 6.9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_35_ssld_infer.tar) | +| MobileNetV3_large_x1_0_ssld | 0.790 | 0.753 | 0.036 | 16.55 | 10.09 | 6.84 | 229.66 | 5.50 | 21 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_ssld_infer.tar) | +| MobileNetV3_small_x1_0_ssld | 0.713 | 0.682 | 0.031 | 5.63 | 3.65 | 2.60 | 63.67 | 2.95 | 12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_0_ssld_infer.tar) | +| GhostNet_x1_3_ssld | 0.794 | 0.757 | 0.037 | 19.16 | 12.25 | 9.40 | 236.89 | 7.38 | 29 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_3_ssld_infer.tar) | + + + +### 2.3 Intel-CPU-side knowledge distillation model + +| Model | Top-1 Acc | Reference
Top-1 Acc | Acc gain | Intel-Xeon-Gold-6148 time(ms)
bs=1 | FLOPs(M) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|---------------------|-----------|-----------|---------------|----------------|----------|-----------|-----------------------------------|-----------------------------------| +| PPLCNet_x0_5_ssld | 0.661 | 0.631 | 0.030 | 2.05 | 47.28 | 1.89 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_5_ssld_infer.tar) | +| PPLCNet_x1_0_ssld | 0.744 | 0.713 | 0.033 | 2.46 | 160.81 | 2.96 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_0_ssld_infer.tar) | +| PPLCNet_x2_5_ssld | 0.808 | 0.766 | 0.042 | 5.39 | 906.49 | 9.04 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x2_5_ssld_infer.tar) | + + +* Note: `Reference Top-1 Acc` means the accuracy of the pre-trained model obtained by PaddleClas based on ImageNet1k dataset training. + + + +## 3. PP-LCNet series [[28](#ref28)] + +The accuracy and speed indicators of the PP-LCNet series models are shown in the following table. For more information about this series of models, please refer to: [PP-LCNet series model documents](../models/PP-LCNet_en.md)。 + +| Model | Top-1 Acc | Top-5 Acc | Intel-Xeon-Gold-6148 time(ms)
bs=1 | FLOPs(M) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|:--:|:--:|:--:|:--:|----|----|----|:--:| +| PPLCNet_x0_25 |0.5186 | 0.7565 | 1.61785 | 18.25 | 1.52 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_25_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_25_infer.tar) | +| PPLCNet_x0_35 |0.5809 | 0.8083 | 2.11344 | 29.46 | 1.65 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_35_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_35_infer.tar) | +| PPLCNet_x0_5 |0.6314 | 0.8466 | 2.72974 | 47.28 | 1.89 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_5_infer.tar) | +| PPLCNet_x0_75 |0.6818 | 0.8830 | 4.51216 | 98.82 | 2.37 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_75_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_75_infer.tar) | +| PPLCNet_x1_0 |0.7132 | 0.9003 | 6.49276 | 160.81 | 2.96 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_0_infer.tar) | +| PPLCNet_x1_5 |0.7371 | 0.9153 | 12.2601 | 341.86 | 4.52 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_5_infer.tar) | +| PPLCNet_x2_0 |0.7518 | 0.9227 | 20.1667 | 590 | 6.54 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x2_0_infer.tar) | +| PPLCNet_x2_5 |0.7660 | 0.9300 | 29.595 | 906 | 9.04 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x2_5_infer.tar) | + + + +## 4. ResNet series [[1](#ref1)] + +The accuracy and speed indicators of ResNet and ResNet_vd series models are shown in the following table. For more information about this series of models, please refer to: [ResNet and ResNet_vd series model documents](../models/ResNet_and_vd_en.md)。 + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|---------------------|-----------|-----------|-----------------------|----------------------|----------|-----------|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------| +| ResNet18 | 0.7098 | 0.8992 | 1.22 | 2.19 | 3.63 | 1.83 | 11.70 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet18_infer.tar) | +| ResNet18_vd | 0.7226 | 0.9080 | 1.26 | 2.28 | 3.89 | 2.07 | 11.72 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet18_vd_infer.tar) | +| ResNet34 | 0.7457 | 0.9214 | 1.97 | 3.25 | 5.70 | 3.68 | 21.81 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_infer.tar) | +| ResNet34_vd | 0.7598 | 0.9298 | 2.00 | 3.28 | 5.84 | 3.93 | 21.84 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_vd_infer.tar) | +| ResNet34_vd_ssld | 0.7972 | 0.9490 | 2.00 | 3.28 | 5.84 | 3.93 | 21.84 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_vd_ssld_infer.tar) | +| ResNet50 | 0.7650 | 0.9300 | 2.54 | 4.79 | 7.40 | 4.11 | 25.61 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_infer.tar) | +| ResNet50_vc | 0.7835 | 0.9403 | 2.57 | 4.83 | 7.52 | 4.35 | 25.63 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vc_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vc_infer.tar) | +| ResNet50_vd | 0.7912 | 0.9444 | 2.60 | 4.86 | 7.63 | 4.35 | 25.63 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar) | +| ResNet101 | 0.7756 | 0.9364 | 4.37 | 8.18 | 12.38 | 7.83 | 44.65 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_infer.tar) | +| ResNet101_vd | 0.8017 | 0.9497 | 4.43 | 8.25 | 12.60 | 8.08 | 44.67 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_vd_infer.tar) | +| ResNet152 | 0.7826 | 0.9396 | 6.05 | 11.41 | 17.33 | 11.56 | 60.34 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet152_infer.tar) | +| ResNet152_vd | 0.8059 | 0.9530 | 6.11 | 11.51 | 17.59 | 11.80 | 60.36 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet152_vd_infer.tar) | +| ResNet200_vd | 0.8093 | 0.9533 | 7.70 | 14.57 | 22.16 | 15.30 | 74.93 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet200_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet200_vd_infer.tar) | +| ResNet50_vd_
ssld | 0.8300 | 0.9640 | 2.60 | 4.86 | 7.63 | 4.35 | 25.63 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_ssld_infer.tar) | +| ResNet101_vd_
ssld | 0.8373 | 0.9669 | 4.43 | 8.25 | 12.60 | 8.08 | 44.67 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_vd_ssld_infer.tar) | + + + +## 5. Mobile series [[3](#ref3)][[4](#ref4)][[5](#ref5)][[6](#ref6)][[23](#ref23)] + +The accuracy and speed indicators of the mobile series models are shown in the following table. For more information about this series, please refer to: [Mobile series model documents](../models/Mobile_en.md)。 + +| Model | Top-1 Acc | Top-5 Acc | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | FLOPs(M) | Params(M) | Model大小(M) | Pretrained Model Download Address | Inference Model Download Address | +|----------------------------------|-----------|-----------|------------------------|----------|-----------|---------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| MobileNetV1_
x0_25 | 0.5143 | 0.7546 | 2.88 | 1.82 | 1.26 | 43.56 | 0.48 | 1.9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_25_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_x0_25_infer.tar) | +| MobileNetV1_
x0_5 | 0.6352 | 0.8473 | 8.74 | 5.26 | 3.09 | 154.57 | 1.34 | 5.2 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_x0_5_infer.tar) | +| MobileNetV1_
x0_75 | 0.6881 | 0.8823 | 17.84 | 10.61 | 6.21 | 333.00 | 2.60 | 10 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_75_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_x0_75_infer.tar) | +| MobileNetV1 | 0.7099 | 0.8968 | 30.24 | 17.86 | 10.30 | 578.88 | 4.25 | 16 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_infer.tar) | +| MobileNetV1_
ssld | 0.7789 | 0.9394 | 30.24 | 17.86 | 10.30 | 578.88 | 4.25 | 16 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_ssld_infer.tar) | +| MobileNetV2_
x0_25 | 0.5321 | 0.7652 | 3.46 | 2.51 | 2.03 | 34.18 | 1.53 | 6.1 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_25_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x0_25_infer.tar) | +| MobileNetV2_
x0_5 | 0.6503 | 0.8572 | 7.69 | 4.92 | 3.57 | 99.48 | 1.98 | 7.8 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x0_5_infer.tar) | +| MobileNetV2_
x0_75 | 0.6983 | 0.8901 | 13.69 | 8.60 | 5.82 | 197.37 | 2.65 | 10 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_75_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x0_75_infer.tar) | +| MobileNetV2 | 0.7215 | 0.9065 | 20.74 | 12.71 | 8.10 | 327.84 | 3.54 | 14 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_infer.tar) | +| MobileNetV2_
x1_5 | 0.7412 | 0.9167 | 40.79 | 24.49 | 15.50 | 702.35 | 6.90 | 26 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x1_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x1_5_infer.tar) | +| MobileNetV2_
x2_0 | 0.7523 | 0.9258 | 67.50 | 40.03 | 25.55 | 1217.25 | 11.33 | 43 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x2_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x2_0_infer.tar) | +| MobileNetV2_
ssld | 0.7674 | 0.9339 | 20.74 | 12.71 | 8.10 | 327.84 | 3.54 | 14 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_ssld_infer.tar) | +| MobileNetV3_
large_x1_25 | 0.7641 | 0.9295 | 24.52 | 14.76 | 9.89 | 362.70 | 7.47 | 29 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_25_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_25_infer.tar) | +| MobileNetV3_
large_x1_0 | 0.7532 | 0.9231 | 16.55 | 10.09 | 6.84 | 229.66 | 5.50 | 21 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_infer.tar) | +| MobileNetV3_
large_x0_75 | 0.7314 | 0.9108 | 11.53 | 7.06 | 4.94 | 151.70 | 3.93 | 16 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_75_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x0_75_infer.tar) | +| MobileNetV3_
large_x0_5 | 0.6924 | 0.8852 | 6.50 | 4.22 | 3.15 | 71.83 | 2.69 | 11 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x0_5_infer.tar) | +| MobileNetV3_
large_x0_35 | 0.6432 | 0.8546 | 4.43 | 3.11 | 2.41 | 40.90 | 2.11 | 8.6 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_35_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x0_35_infer.tar) | +| MobileNetV3_
small_x1_25 | 0.7067 | 0.8951 | 7.88 | 4.91 | 3.45 | 100.07 | 3.64 | 14 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_25_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_25_infer.tar) | +| MobileNetV3_
small_x1_0 | 0.6824 | 0.8806 | 5.63 | 3.65 | 2.60 | 63.67 | 2.95 | 12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_0_infer.tar) | +| MobileNetV3_
small_x0_75 | 0.6602 | 0.8633 | 4.50 | 2.96 | 2.19 | 46.02 | 2.38 | 9.6 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_75_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_75_infer.tar) | +| MobileNetV3_
small_x0_5 | 0.5921 | 0.8152 | 2.89 | 2.04 | 1.62 | 22.60 | 1.91 | 7.8 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_5_infer.tar) | +| MobileNetV3_
small_x0_35 | 0.5303 | 0.7637 | 2.23 | 1.66 | 1.43 | 14.56 | 1.67 | 6.9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_35_infer.tar) | +| MobileNetV3_
small_x0_35_ssld | 0.5555 | 0.7771 | 2.23 | 1.66 | 1.43 | 14.56 | 1.67 | 6.9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_35_ssld_infer.tar) | +| MobileNetV3_
large_x1_0_ssld | 0.7896 | 0.9448 | 16.55 | 10.09 | 6.84 | 229.66 | 5.50 | 21 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_ssld_infer.tar) | +| MobileNetV3_small_
x1_0_ssld | 0.7129 | 0.9010 | 5.63 | 3.65 | 2.60 | 63.67 | 2.95 | 12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_0_ssld_infer.tar) | +| ShuffleNetV2 | 0.6880 | 0.8845 | 9.72 | 5.97 | 4.13 | 148.86 | 2.29 | 9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x1_0_infer.tar) | +| ShuffleNetV2_
x0_25 | 0.4990 | 0.7379 | 1.94 | 1.53 | 1.43 | 18.95 | 0.61 | 2.7 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_25_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x0_25_infer.tar) | +| ShuffleNetV2_
x0_33 | 0.5373 | 0.7705 | 2.23 | 1.70 | 1.79 | 24.04 | 0.65 | 2.8 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_33_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x0_33_infer.tar) | +| ShuffleNetV2_
x0_5 | 0.6032 | 0.8226 | 3.67 | 2.63 | 2.06 | 42.58 | 1.37 | 5.6 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x0_5_infer.tar) | +| ShuffleNetV2_
x1_5 | 0.7163 | 0.9015 | 17.21 | 10.56 | 6.81 | 301.35 | 3.53 | 14 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x1_5_infer.tar) | +| ShuffleNetV2_
x2_0 | 0.7315 | 0.9120 | 31.21 | 18.98 | 11.65 | 571.70 | 7.40 | 28 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x2_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x2_0_infer.tar) | +| ShuffleNetV2_
swish | 0.7003 | 0.8917 | 31.21 | 9.06 | 5.74 | 148.86 | 2.29 | 9.1 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_swish_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_swish_infer.tar) | +| GhostNet_
x0_5 | 0.6688 | 0.8695 | 5.28 | 3.95 | 3.29 | 46.15 | 2.60 | 10 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x0_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x0_5_infer.tar) | +| GhostNet_
x1_0 | 0.7402 | 0.9165 | 12.89 | 8.66 | 6.72 | 148.78 | 5.21 | 20 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_0_infer.tar) | +| GhostNet_
x1_3 | 0.7579 | 0.9254 | 19.16 | 12.25 | 9.40 | 236.89 | 7.38 | 29 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_3_infer.tar) | +| GhostNet_
x1_3_ssld | 0.7938 | 0.9449 | 19.16 | 12.25 | 9.40 | 236.89 | 7.38 | 29 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_3_ssld_infer.tar) | +| ESNet_x0_25 | 0.6248 | 0.8346 |4.12|2.97|2.51| 30.85 | 2.83 | 11 |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_25_pretrained.pdparams) |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x0_25_infer.tar) | +| ESNet_x0_5 | 0.6882 | 0.8804 |6.45|4.42|3.35| 67.31 | 3.25 | 13 |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_5_pretrained.pdparams) |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x0_5_infer.tar) | +| ESNet_x0_75 | 0.7224 | 0.9045 |9.59|6.28|4.52| 123.74 | 3.87 | 15 |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_75_pretrained.pdparams) |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x0_75_infer.tar) | +| ESNet_x1_0 | 0.7392 | 0.9140 |13.67|8.71|5.97| 197.33 | 4.64 | 18 |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x1_0_pretrained.pdparams) |[Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x1_0_infer.tar) | + + + +## 6. SEResNeXt and Res2Net series [[7](#ref7)][[8](#ref8)][[9](#ref9)] + +The accuracy and speed indicators of the SEResNeXt and Res2Net series models are shown in the following table. For more information about the models of this series, please refer to: [SEResNeXt and Res2Net series model documents](../models/SEResNext_and_Res2Net_en.md). + + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|---------------------------|-----------|-----------|-----------------------|----------------------|----------|-----------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| Res2Net50_
26w_4s | 0.7933 | 0.9457 | 3.52 | 6.23 | 9.30 | 4.28 | 25.76 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_26w_4s_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_26w_4s_infer.tar) | +| Res2Net50_vd_
26w_4s | 0.7975 | 0.9491 | 3.59 | 6.35 | 9.50 | 4.52 | 25.78 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_vd_26w_4s_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_vd_26w_4s_infer.tar) | +| Res2Net50_
14w_8s | 0.7946 | 0.9470 | 4.39 | 7.21 | 10.38 | 4.20 | 25.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_14w_8s_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_14w_8s_infer.tar) | +| Res2Net101_vd_
26w_4s | 0.8064 | 0.9522 | 6.34 | 11.02 | 16.13 | 8.35 | 45.35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net101_vd_26w_4s_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net101_vd_26w_4s_infer.tar) | +| Res2Net200_vd_
26w_4s | 0.8121 | 0.9571 | 11.45 | 19.77 | 28.81 | 15.77 | 76.44 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net200_vd_26w_4s_infer.tar) | +| Res2Net200_vd_
26w_4s_ssld | 0.8513 | 0.9742 | 11.45 | 19.77 | 28.81 | 15.77 | 76.44 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net200_vd_26w_4s_ssld_infer.tar) | +| ResNeXt50_
32x4d | 0.7775 | 0.9382 | 5.07 | 8.49 | 12.02 | 4.26 | 25.10 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_32x4d_infer.tar) | +| ResNeXt50_vd_
32x4d | 0.7956 | 0.9462 | 5.29 | 8.68 | 12.33 | 4.50 | 25.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_vd_32x4d_infer.tar) | +| ResNeXt50_
64x4d | 0.7843 | 0.9413 | 9.39 | 13.97 | 20.56 | 8.02 | 45.29 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_64x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_64x4d_infer.tar) | +| ResNeXt50_vd_
64x4d | 0.8012 | 0.9486 | 9.75 | 14.14 | 20.84 | 8.26 | 45.31 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_64x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_vd_64x4d_infer.tar) | +| ResNeXt101_
32x4d | 0.7865 | 0.9419 | 11.34 | 16.78 | 22.80 | 8.01 | 44.32 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x4d_infer.tar) | +| ResNeXt101_vd_
32x4d | 0.8033 | 0.9512 | 11.36 | 17.01 | 23.07 | 8.25 | 44.33 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_vd_32x4d_infer.tar) | +| ResNeXt101_
64x4d | 0.7835 | 0.9452 | 21.57 | 28.08 | 39.49 | 15.52 | 83.66 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_64x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_64x4d_infer.tar) | +| ResNeXt101_vd_
64x4d | 0.8078 | 0.9520 | 21.57 | 28.22 | 39.70 | 15.76 | 83.68 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_64x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_vd_64x4d_infer.tar) | +| ResNeXt152_
32x4d | 0.7898 | 0.9433 | 17.14 | 25.11 | 33.79 | 11.76 | 60.15 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_32x4d_infer.tar) | +| ResNeXt152_vd_
32x4d | 0.8072 | 0.9520 | 16.99 | 25.29 | 33.85 | 12.01 | 60.17 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_vd_32x4d_infer.tar) | +| ResNeXt152_
64x4d | 0.7951 | 0.9471 | 33.07 | 42.05 | 59.13 | 23.03 | 115.27 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_64x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_64x4d_infer.tar) | +| ResNeXt152_vd_
64x4d | 0.8108 | 0.9534 | 33.30 | 42.41 | 59.42 | 23.27 | 115.29 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_64x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_vd_64x4d_infer.tar) | +| SE_ResNet18_vd | 0.7333 | 0.9138 | 1.48 | 2.70 | 4.32 | 2.07 | 11.81 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet18_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNet18_vd_infer.tar) | +| SE_ResNet34_vd | 0.7651 | 0.9320 | 2.42 | 3.69 | 6.29 | 3.93 | 22.00 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet34_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNet34_vd_infer.tar) | +| SE_ResNet50_vd | 0.7952 | 0.9475 | 3.11 | 5.99 | 9.34 | 4.36 | 28.16 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet50_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNet50_vd_infer.tar) | +| SE_ResNeXt50_
32x4d | 0.7844 | 0.9396 | 6.39 | 11.01 | 14.94 | 4.27 | 27.63 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNeXt50_32x4d_infer.tar) | +| SE_ResNeXt50_vd_
32x4d | 0.8024 | 0.9489 | 7.04 | 11.57 | 16.01 | 5.64 | 27.76 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_vd_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNeXt50_vd_32x4d_infer.tar) | +| SE_ResNeXt101_
32x4d | 0.7939 | 0.9443 | 13.31 | 21.85 | 28.77 | 8.03 | 49.09 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt101_32x4d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNeXt101_32x4d_infer.tar) | +| SENet154_vd | 0.8140 | 0.9548 | 34.83 | 51.22 | 69.74 | 24.45 | 122.03 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SENet154_vd_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SENet154_vd_infer.tar) | + + + +## 7. DPN and DenseNet series [[14](#ref14)][[15](#ref15)] + +The accuracy and speed indicators of the DPN and DenseNet series models are shown in the following table. For more information about the models of this series, please refer to: [DPN and DenseNet series model documents](../models/DPN_DenseNet_en.md). + + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|-------------|-----------|-----------|-----------------------|----------------------|----------|-----------|--------------------------------------------------------------------------------------|-------------|-------------| +| DenseNet121 | 0.7566 | 0.9258 | 3.40 | 6.94 | 9.17 | 2.87 | 8.06 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet121_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet121_infer.tar) | +| DenseNet161 | 0.7857 | 0.9414 | 7.06 | 14.37 | 19.55 | 7.79 | 28.90 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet161_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet161_infer.tar) | +| DenseNet169 | 0.7681 | 0.9331 | 5.00 | 10.29 | 12.84 | 3.40 | 14.31 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet169_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet169_infer.tar) | +| DenseNet201 | 0.7763 | 0.9366 | 6.38 | 13.72 | 17.17 | 4.34 | 20.24 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet201_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet201_infer.tar) | +| DenseNet264 | 0.7796 | 0.9385 | 9.34 | 20.95 | 25.41 | 5.82 | 33.74 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet264_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet264_infer.tar) | +| DPN68 | 0.7678 | 0.9343 | 8.18 | 11.40 | 14.82 | 2.35 | 12.68 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN68_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN68_infer.tar) | +| DPN92 | 0.7985 | 0.9480 | 12.48 | 20.04 | 25.10 | 6.54 | 37.79 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN92_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN92_infer.tar) | +| DPN98 | 0.8059 | 0.9510 | 14.70 | 25.55 | 35.12 | 11.728 | 61.74 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN98_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN98_infer.tar) | +| DPN107 | 0.8089 | 0.9532 | 19.46 | 35.62 | 50.22 | 18.38 | 87.13 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN107_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN107_infer.tar) | +| DPN131 | 0.8070 | 0.9514 | 19.64 | 34.60 | 47.42 | 16.09 | 79.48 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN131_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN131_infer.tar) | + + + +## 8. HRNet series [[13](#ref13)] + +The accuracy and speed indicators of the HRNet series models are shown in the following table. For more information about the models of this series, please refer to: [HRNet series model documents](../models/HRNet_en.md). + + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|-------------|-----------|-----------|------------------|------------------|----------|-----------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------| +| HRNet_W18_C | 0.7692 | 0.9339 | 6.66 | 8.94 | 11.95 | 4.32 | 21.35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W18_C_infer.tar) | +| HRNet_W18_C_ssld | 0.81162 | 0.95804 | 6.66 | 8.94 | 11.95 | 4.32 | 21.35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W18_C_ssld_infer.tar) | +| HRNet_W30_C | 0.7804 | 0.9402 | 8.61 | 11.40 | 15.23 | 8.15 | 37.78 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W30_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W30_C_infer.tar) | +| HRNet_W32_C | 0.7828 | 0.9424 | 8.54 | 11.58 | 15.57 | 8.97 | 41.30 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W32_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W32_C_infer.tar) | +| HRNet_W40_C | 0.7877 | 0.9447 | 9.83 | 15.02 | 20.92 | 12.74 | 57.64 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W40_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W40_C_infer.tar) | +| HRNet_W44_C | 0.7900 | 0.9451 | 10.62 | 16.18 | 25.92 | 14.94 | 67.16 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W44_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W44_C_infer.tar) | +| HRNet_W48_C | 0.7895 | 0.9442 | 11.07 | 17.06 | 27.28 | 17.34 | 77.57 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W48_C_infer.tar) | +| HRNet_W48_C_ssld | 0.8363 | 0.9682 | 11.07 | 17.06 | 27.28 | 17.34 | 77.57 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W48_C_ssld_infer.tar) | +| HRNet_W64_C | 0.7930 | 0.9461 | 13.82 | 21.15 | 35.51 | 28.97 | 128.18 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W64_C_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W64_C_infer.tar) | +| SE_HRNet_W64_C_ssld | 0.8475 | 0.9726 | 17.11 | 26.87 | 43.24 | 29.00 | 129.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/SE_HRNet_W64_C_ssld_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_HRNet_W64_C_ssld_infer.tar) | + + + +## 9. Inception series [[10](#ref10)][[11](#ref11)][[12](#ref12)][[26](#ref26)] + +The accuracy and speed indicators of the Inception series models are shown in the following table. For more information about this series of models, please refer to: [Inception series model documents](../models/Inception_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|--------------------|-----------|-----------|-----------------------|----------------------|----------|-----------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| +| GoogLeNet | 0.7070 | 0.8966 | 1.41 | 3.25 | 5.00 | 1.44 | 11.54 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GoogLeNet_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GoogLeNet_infer.tar) | +| Xception41 | 0.7930 | 0.9453 | 3.58 | 8.76 | 16.61 | 8.57 | 23.02 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception41_infer.tar) | +| Xception41_deeplab | 0.7955 | 0.9438 | 3.81 | 9.16 | 17.20 | 9.28 | 27.08 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_deeplab_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception41_deeplab_infer.tar) | +| Xception65 | 0.8100 | 0.9549 | 5.45 | 12.78 | 24.53 | 13.25 | 36.04 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception65_infer.tar) | +| Xception65_deeplab | 0.8032 | 0.9449 | 5.65 | 13.08 | 24.61 | 13.96 | 40.10 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_deeplab_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception65_deeplab_infer.tar) | +| Xception71 | 0.8111 | 0.9545 | 6.19 | 15.34 | 29.21 | 16.21 | 37.86 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception71_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception71_infer.tar) | +| InceptionV3 | 0.7914 | 0.9459 | 4.78 | 8.53 | 12.28 | 5.73 | 23.87 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/InceptionV3_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/InceptionV3_infer.tar) | +| InceptionV4 | 0.8077 | 0.9526 | 8.93 | 15.17 | 21.56 | 12.29 | 42.74 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/InceptionV4_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/InceptionV4_infer.tar) | + + + +## 10. EfficientNet and ResNeXt101_wsl series [[16](#ref16)][[17](#ref17)] + +The accuracy and speed indicators of the EfficientNet and ResNeXt101_wsl series models are shown in the following table. For more information about this series of models, please refer to: [EfficientNet and ResNeXt101_wsl series model documents](../models/EfficientNet_and_ResNeXt101_wsl_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|---------------------------|-----------|-----------|------------------|------------------|----------|-----------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| ResNeXt101_
32x8d_wsl | 0.8255 | 0.9674 | 13.55 | 23.39 | 36.18 | 16.48 | 88.99 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x8d_wsl_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x8d_wsl_infer.tar) | +| ResNeXt101_
32x16d_wsl | 0.8424 | 0.9726 | 21.96 | 38.35 | 63.29 | 36.26 | 194.36 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x16d_wsl_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x16d_wsl_infer.tar) | +| ResNeXt101_
32x32d_wsl | 0.8497 | 0.9759 | 37.28 | 76.50 | 121.56 | 87.28 | 469.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x32d_wsl_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x32d_wsl_infer.tar) | +| ResNeXt101_
32x48d_wsl | 0.8537 | 0.9769 | 55.07 | 124.39 | 205.01 | 153.57 | 829.26 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x48d_wsl_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x48d_wsl_infer.tar) | +| Fix_ResNeXt101_
32x48d_wsl | 0.8626 | 0.9797 | 55.01 | 122.63 | 204.66 | 313.41 | 829.26 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Fix_ResNeXt101_32x48d_wsl_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Fix_ResNeXt101_32x48d_wsl_infer.tar) | +| EfficientNetB0 | 0.7738 | 0.9331 | 1.96 | 3.71 | 5.56 | 0.40 | 5.33 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB0_infer.tar) | +| EfficientNetB1 | 0.7915 | 0.9441 | 2.88 | 5.40 | 7.63 | 0.71 | 7.86 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB1_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB1_infer.tar) | +| EfficientNetB2 | 0.7985 | 0.9474 | 3.26 | 6.20 | 9.17 | 1.02 | 9.18 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB2_infer.tar) | +| EfficientNetB3 | 0.8115 | 0.9541 | 4.52 | 8.85 | 13.54 | 1.88 | 12.324 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB3_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB3_infer.tar) | +| EfficientNetB4 | 0.8285 | 0.9623 | 6.78 | 15.47 | 24.95 | 4.51 | 19.47 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB4_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB4_infer.tar) | +| EfficientNetB5 | 0.8362 | 0.9672 | 10.97 | 27.24 | 45.93 | 10.51 | 30.56 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB5_infer.tar) | +| EfficientNetB6 | 0.8400 | 0.9688 | 17.09 | 43.32 | 76.90 | 19.47 | 43.27 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB6_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB6_infer.tar) | +| EfficientNetB7 | 0.8430 | 0.9689 | 25.91 | 71.23 | 128.20 | 38.45 | 66.66 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB7_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB7_infer.tar) | +| EfficientNetB0_
small | 0.7580 | 0.9258 | 1.24 | 2.59 | 3.92 | 0.40 | 4.69 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_small_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB0_small_infer.tar) | + + + +## 11. ResNeSt and RegNet series [[24](#ref24)][[25](#ref25)] + +The accuracy and speed indicators of the ResNeSt and RegNet series models are shown in the following table. For more information about the models of this series, please refer to: [ResNeSt and RegNet series model documents](../models/ResNeSt_RegNet_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| ResNeSt50_
fast_1s1x64d | 0.8035 | 0.9528 | 2.73 | 5.33 | 8.24 | 4.36 | 26.27 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_fast_1s1x64d_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeSt50_fast_1s1x64d_infer.tar) | +| ResNeSt50 | 0.8083 | 0.9542 | 7.36 | 10.23 | 13.84 | 5.40 | 27.54 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeSt50_infer.tar) | +| RegNetX_4GF | 0.785 | 0.9416 | 6.46 | 8.48 | 11.45 | 4.00 | 22.23 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetX_4GF_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RegNetX_4GF_infer.tar) | + + + +## 12. ViT and DeiT series [[31](#ref31)][[32](#ref32)] + +The accuracy and speed indicators of ViT (Vision Transformer) and DeiT (Data-efficient Image Transformers) series models are shown in the following table. For more information about this series of models, please refer to: [ViT_and_DeiT series model documents](../models/ViT_and_DeiT_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|------------------------|-----------|-----------|------------------|------------------|----------|------------------------|------------------------|------------------------|------------------------| +| ViT_small_
patch16_224 | 0.7769 | 0.9342 | 3.71 | 9.05 | 16.72 | 9.41 | 48.60 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_small_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_small_patch16_224_infer.tar) | +| ViT_base_
patch16_224 | 0.8195 | 0.9617 | 6.12 | 14.84 | 28.51 | 16.85 | 86.42 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_base_patch16_224_infer.tar) | +| ViT_base_
patch16_384 | 0.8414 | 0.9717 | 14.15 | 48.38 | 95.06 | 49.35 | 86.42 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_base_patch16_384_infer.tar) | +| ViT_base_
patch32_384 | 0.8176 | 0.9613 | 4.94 | 13.43 | 24.08 | 12.66 | 88.19 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch32_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_base_patch32_384_infer.tar) | +| ViT_large_
patch16_224 | 0.8323 | 0.9650 | 15.53 | 49.50 | 94.09 | 59.65 | 304.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_large_patch16_224_infer.tar) | +|ViT_large_
patch16_384| 0.8513 | 0.9736 | 39.51 | 152.46 | 304.06 | 174.70 | 304.12 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_large_patch16_384_infer.tar) | +|ViT_large_
patch32_384| 0.8153 | 0.9608 | 11.44 | 36.09 | 70.63 | 44.24 | 306.48 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch32_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_large_patch32_384_infer.tar) | + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|------------------------|-----------|-----------|------------------|------------------|----------|------------------------|------------------------|------------------------|------------------------| +| DeiT_tiny_
patch16_224 | 0.718 | 0.910 | 3.61 | 3.94 | 6.10 | 1.07 | 5.68 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_tiny_patch16_224_infer.tar) | +| DeiT_small_
patch16_224 | 0.796 | 0.949 | 3.61 | 6.24 | 10.49 | 4.24 | 21.97 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_small_patch16_224_infer.tar) | +| DeiT_base_
patch16_224 | 0.817 | 0.957 | 6.13 | 14.87 | 28.50 | 16.85 | 86.42 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_patch16_224_infer.tar) | +| DeiT_base_
patch16_384 | 0.830 | 0.962 | 14.12 | 48.80 | 97.60 | 49.35 | 86.42 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_patch16_384_infer.tar) | +| DeiT_tiny_
distilled_patch16_224 | 0.741 | 0.918 | 3.51 | 4.05 | 6.03 | 1.08 | 5.87 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_distilled_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_tiny_distilled_patch16_224_infer.tar) | +| DeiT_small_
distilled_patch16_224 | 0.809 | 0.953 | 3.70 | 6.20 | 10.53 | 4.26 | 22.36 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_distilled_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_small_distilled_patch16_224_infer.tar) | +| DeiT_base_
distilled_patch16_224 | 0.831 | 0.964 | 6.17 | 14.94 | 28.58 | 16.93 | 87.18 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_distilled_patch16_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_distilled_patch16_224_infer.tar) | +| DeiT_base_
distilled_patch16_384 | 0.851 | 0.973 | 14.12 | 48.76 | 97.09 | 49.43 | 87.18 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_distilled_patch16_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_distilled_patch16_384_infer.tar) | + + + +## 13. RepVGG series [[36](#ref36)] + +The accuracy and speed indicators of RepVGG series models are shown in the following table. For more introduction, please refer to: [RepVGG series model documents](../models/RepVGG_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| RepVGG_A0 | 0.7131 | 0.9016 | | | | 1.36 | 8.31 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_A0_infer.tar) | +| RepVGG_A1 | 0.7380 | 0.9146 | | | | 2.37 | 12.79 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A1_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_A1_infer.tar) | +| RepVGG_A2 | 0.7571 | 0.9264 | | | | 5.12 | 25.50 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_A2_infer.tar) | +| RepVGG_B0 | 0.7450 | 0.9213 | | | | 3.06 | 14.34 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B0_infer.tar) | +| RepVGG_B1 | 0.7773 | 0.9385 | | | | 11.82 | 51.83 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B1_infer.tar) | +| RepVGG_B2 | 0.7813 | 0.9410 | | | | 18.38 | 80.32 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B2_infer.tar) | +| RepVGG_B1g2 | 0.7732 | 0.9359 | | | | 8.82 | 41.36 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1g2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B1g2_infer.tar) | +| RepVGG_B1g4 | 0.7675 | 0.9335 | | | | 7.31 | 36.13 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1g4_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B1g4_infer.tar) | +| RepVGG_B2g4 | 0.7881 | 0.9448 | | | | 11.34 | 55.78 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B2g4_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B2g4_infer.tar) | +| RepVGG_B3g4 | 0.7965 | 0.9485 | | | | 16.07 | 75.63 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B3g4_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B3g4_infer.tar) | + + + +## 14. MixNet series [[29](#ref29)] + +The accuracy and speed indicators of the MixNet series models are shown in the following table. For more introduction, please refer to: [MixNet series model documents](../models/MixNet_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(M) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| -------- | --------- | --------- | ---------------- | ---------------- | ----------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| MixNet_S | 0.7628 | 0.9299 | 2.31 | 3.63 | 5.20 | 252.977 | 4.167 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_S_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MixNet_S_infer.tar) | +| MixNet_M | 0.7767 | 0.9364 | 2.84 | 4.60 | 6.62 | 357.119 | 5.065 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_M_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MixNet_M_infer.tar) | +| MixNet_L | 0.7860 | 0.9437 | 3.16 | 5.55 | 8.03 | 579.017 | 7.384 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_L_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MixNet_L_infer.tar) | + + + +## 15. ReXNet series [[30](#ref30)] + +The accuracy and speed indicators of ReXNet series models are shown in the following table. For more introduction, please refer to: [ReXNet series model documents](../models/ReXNet_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| ReXNet_1_0 | 0.7746 | 0.9370 | 3.08 | 4.15 | 5.49 | 0.415 | 4.84 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_1_0_infer.tar) | +| ReXNet_1_3 | 0.7913 | 0.9464 | 3.54 | 4.87 | 6.54 | 0.68 | 7.61 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_3_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_1_3_infer.tar) | +| ReXNet_1_5 | 0.8006 | 0.9512 | 3.68 | 5.31 | 7.38 | 0.90 | 9.79 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_1_5_infer.tar) | +| ReXNet_2_0 | 0.8122 | 0.9536 | 4.30 | 6.54 | 9.19 | 1.56 | 16.45 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_2_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_2_0_infer.tar) | +| ReXNet_3_0 | 0.8209 | 0.9612 | 5.74 | 9.49 | 13.62 | 3.44 | 34.83 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_3_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_3_0_infer.tar) | + + + +## 16. SwinTransformer series [[27](#ref27)] + +The accuracy and speed indicators of SwinTransformer series models are shown in the following table. For more introduction, please refer to: [SwinTransformer series model documents](../models/SwinTransformer_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| SwinTransformer_tiny_patch4_window7_224 | 0.8069 | 0.9534 | 6.59 | 9.68 | 16.32 | 4.35 | 28.26 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_tiny_patch4_window7_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_tiny_patch4_window7_224_infer.tar) | +| SwinTransformer_small_patch4_window7_224 | 0.8275 | 0.9613 | 12.54 | 17.07 | 28.08 | 8.51 | 49.56 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_small_patch4_window7_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_small_patch4_window7_224_infer.tar) | +| SwinTransformer_base_patch4_window7_224 | 0.8300 | 0.9626 | 13.37 | 23.53 | 39.11 | 15.13 | 87.70 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window7_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window7_224_infer.tar) | +| SwinTransformer_base_patch4_window12_384 | 0.8439 | 0.9693 | 19.52 | 64.56 | 123.30 | 44.45 | 87.70 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window12_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window12_384_infer.tar) | +| SwinTransformer_base_patch4_window7_224[1] | 0.8487 | 0.9746 | 13.53 | 23.46 | 39.13 | 15.13 | 87.70 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window7_224_22kto1k_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window7_224_infer.tar) | +| SwinTransformer_base_patch4_window12_384[1] | 0.8642 | 0.9807 | 19.65 | 64.72 | 123.42 | 44.45 | 87.70 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window12_384_22kto1k_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window12_384_infer.tar) | +| SwinTransformer_large_patch4_window7_224[1] | 0.8596 | 0.9783 | 15.74 | 38.57 | 71.49 | 34.02 | 196.43 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window7_224_22kto1k_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_large_patch4_window7_224_22kto1k_infer.tar) | +| SwinTransformer_large_patch4_window12_384[1] | 0.8719 | 0.9823 | 32.61 | 116.59 | 223.23 | 99.97 | 196.43 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window12_384_22kto1k_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_large_patch4_window12_384_22kto1k_infer.tar) | + +[1]:It is pre-trained based on the ImageNet22k dataset, and then transferred and learned from the ImageNet1k dataset. + + + +## 17. LeViT series [[33](#ref33)] + +The accuracy and speed indicators of LeViT series models are shown in the following table. For more introduction, please refer to: [LeViT series model documents](../models/LeViT_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(M) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| LeViT_128S | 0.7598 | 0.9269 | | | | 281 | 7.42 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128S_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_128S_infer.tar) | +| LeViT_128 | 0.7810 | 0.9371 | | | | 365 | 8.87 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_128_infer.tar) | +| LeViT_192 | 0.7934 | 0.9446 | | | | 597 | 10.61 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_192_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_192_infer.tar) | +| LeViT_256 | 0.8085 | 0.9497 | | | | 1049 | 18.45 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_256_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_256_infer.tar) | +| LeViT_384 | 0.8191 | 0.9551 | | | | 2234 | 38.45 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_384_infer.tar) | + +**Note**: The accuracy difference with Reference is due to the difference in data preprocessing and the use of no distilled head as output. + + + +## 18. Twins series [[34](#ref34)] + +The accuracy and speed indicators of Twins series models are shown in the following table. For more introduction, please refer to: [Twins series model documents](../models/Twins_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| pcpvt_small | 0.8082 | 0.9552 | 7.32 | 10.51 | 15.27 |3.67 | 24.06 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_small_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/pcpvt_small_infer.tar) | +| pcpvt_base | 0.8242 | 0.9619 | 12.20 | 16.22 | 23.16 | 6.44 | 43.83 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_base_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/pcpvt_base_infer.tar) | +| pcpvt_large | 0.8273 | 0.9650 | 16.47 | 22.90 | 32.73 | 9.50 | 60.99 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_large_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/pcpvt_large_infer.tar) | +| alt_gvt_small | 0.8140 | 0.9546 | 6.94 | 9.01 | 12.27 |2.81 | 24.06 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_small_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/alt_gvt_small_infer.tar) | +| alt_gvt_base | 0.8294 | 0.9621 | 9.37 | 15.02 | 24.54 | 8.34 | 56.07 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_base_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/alt_gvt_base_infer.tar) | +| alt_gvt_large | 0.8331 | 0.9642 | 11.76 | 22.08 | 35.12 | 14.81 | 99.27 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_large_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/alt_gvt_large_infer.tar) | + +**Note**: The accuracy difference with Reference is due to the difference in data preprocessing. + + + +## 19. HarDNet series [[37](#ref37)] + +The accuracy and speed indicators of HarDNet series models are shown in the following table. For more introduction, please refer to: [HarDNet series model documents](../models/HarDNet_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| HarDNet39_ds | 0.7133 |0.8998 | 1.40 | 2.30 | 3.33 | 0.44 | 3.51 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet39_ds_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet39_ds_infer.tar) | +| HarDNet68_ds |0.7362 | 0.9152 | 2.26 | 3.34 | 5.06 | 0.79 | 4.20 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_ds_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet68_ds_infer.tar) | +| HarDNet68| 0.7546 | 0.9265 | 3.58 | 8.53 | 11.58 | 4.26 | 17.58 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet68_infer.tar) | +| HarDNet85 | 0.7744 | 0.9355 | 6.24 | 14.85 | 20.57 | 9.09 | 36.69 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet85_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet85_infer.tar) | + + + +## 20. DLA series [[38](#ref38)] + +The accuracy and speed indicators of DLA series models are shown in the following table. For more introduction, please refer to: [DLA series model documents](../models/DLA_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| DLA102 | 0.7893 |0.9452 | 4.95 | 8.08 | 12.40 | 7.19 | 33.34 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA102_infer.tar) | +| DLA102x2 |0.7885 | 0.9445 | 19.58 | 23.97 | 31.37 | 9.34 | 41.42 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA102x2_infer.tar) | +| DLA102x| 0.781 | 0.9400 | 11.12 | 15.60 | 20.37 | 5.89 | 26.40 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA102x_infer.tar) | +| DLA169 | 0.7809 | 0.9409 | 7.70 | 12.25 | 18.90 | 11.59 | 53.50 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA169_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA169_infer.tar) | +| DLA34 | 0.7603 | 0.9298 | 1.83 | 3.37 | 5.98 | 3.07 | 15.76 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA34_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA34_infer.tar) | +| DLA46_c |0.6321 | 0.853 | 1.06 | 2.08 | 3.23 | 0.54 | 1.31 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA46_c_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA46_c_infer.tar) | +| DLA60 | 0.7610 | 0.9292 | 2.78 | 5.36 | 8.29 | 4.26 | 22.08 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA60_infer.tar) | +| DLA60x_c | 0.6645 | 0.8754 | 1.79 | 3.68 | 5.19 | 0.59 | 1.33 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_c_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA60x_c_infer.tar) | +| DLA60x | 0.7753 | 0.9378 | 5.98 | 9.24 | 12.52 | 3.54 | 17.41 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA60x_infer.tar) | + + + +## 21. RedNet series [[39](#ref39)] + +The accuracy and speed indicators of RedNet series models are shown in the following table. For more introduction, please refer to: [RedNet series model documents](../models/RedNet_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RedNet26 | 0.7595 |0.9319 | 4.45 | 15.16 | 29.03 | 1.69 | 9.26 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet26_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet26_infer.tar) | +| RedNet38 |0.7747 | 0.9356 | 6.24 | 21.39 | 41.26 | 2.14 | 12.43 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet38_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet38_infer.tar) | +| RedNet50| 0.7833 | 0.9417 | 8.04 | 27.71 | 53.73 | 2.61 | 15.60 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet50_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet50_infer.tar) | +| RedNet101 | 0.7894 | 0.9436 | 13.07 | 44.12 | 83.28 | 4.59 | 25.76 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet101_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet101_infer.tar) | +| RedNet152 | 0.7917 | 0.9440 | 18.66 | 63.27 | 119.48 | 6.57 | 34.14 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet152_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet152_infer.tar) | + + + +## 22. TNT series [[35](#ref35)] + +The accuracy and speed indicators of TNT series models are shown in the following table. For more introduction, please refer to: [TNT series model documents](../models/TNT_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| TNT_small | 0.8121 |0.9563 | | | 4.83 | 23.68 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/TNT_small_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/TNT_small_infer.tar) | + +**Note**: Both `mean` and `std` in the data preprocessing part of the TNT model `NormalizeImage` are 0.5. + + + +## 23. Other models + +The accuracy and speed indicators of AlexNet [[18](#ref18)], SqueezeNet series [[19](#ref19)], VGG series [[20](#ref20)], DarkNet53 [[21](#ref21)] and other models are shown in the following table. For more information, please refer to: [Other model documents](../models/Others_en.md). + +| Model | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address | +|------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| AlexNet | 0.567 | 0.792 | 0.81 | 1.50 | 2.33 | 0.71 | 61.10 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/AlexNet_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/AlexNet_infer.tar) | +| SqueezeNet1_0 | 0.596 | 0.817 | 0.68 | 1.64 | 2.62 | 0.78 | 1.25 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SqueezeNet1_0_infer.tar) | +| SqueezeNet1_1 | 0.601 | 0.819 | 0.62 | 1.30 | 2.09 | 0.35 | 1.24 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_1_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SqueezeNet1_1_infer.tar) | +| VGG11 | 0.693 | 0.891 | 1.72 | 4.15 | 7.24 | 7.61 | 132.86 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG11_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG11_infer.tar) | +| VGG13 | 0.700 | 0.894 | 2.02 | 5.28 | 9.54 | 11.31 | 133.05 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG13_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG13_infer.tar) | +| VGG16 | 0.720 | 0.907 | 2.48 | 6.79 | 12.33 | 15.470 | 138.35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG16_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG16_infer.tar) | +| VGG19 | 0.726 | 0.909 | 2.93 | 8.28 | 15.21 | 19.63 | 143.66 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG19_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG19_infer.tar) | +| DarkNet53 | 0.780 | 0.941 | 2.79 | 6.42 | 10.89 | 9.31 | 41.65 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DarkNet53_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DarkNet53_infer.tar) | + + + +## Reference + +[1] He K, Zhang X, Ren S, et al. Deep residual learning for image recognition[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2016: 770-778. + +[2] He T, Zhang Z, Zhang H, et al. Bag of tricks for image classification with convolutional neural networks[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2019: 558-567. + +[3] Howard A, Sandler M, Chu G, et al. Searching for mobilenetv3[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 1314-1324. + +[4] Sandler M, Howard A, Zhu M, et al. Mobilenetv2: Inverted residuals and linear bottlenecks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2018: 4510-4520. + +[5] Howard A G, Zhu M, Chen B, et al. Mobilenets: Efficient convolutional neural networks for mobile vision applications[J]. arXiv preprint arXiv:1704.04861, 2017. + +[6] Ma N, Zhang X, Zheng H T, et al. Shufflenet v2: Practical guidelines for efficient cnn architecture design[C]//Proceedings of the European Conference on Computer Vision (ECCV). 2018: 116-131. + +[7] Xie S, Girshick R, Dollár P, et al. Aggregated residual transformations for deep neural networks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 1492-1500. + +[8] Hu J, Shen L, Sun G. Squeeze-and-excitation networks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2018: 7132-7141. + +[9] Gao S, Cheng M M, Zhao K, et al. Res2net: A new multi-scale backbone architecture[J]. IEEE transactions on pattern analysis and machine intelligence, 2019. + +[10] Szegedy C, Liu W, Jia Y, et al. Going deeper with convolutions[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2015: 1-9. + +[11] Szegedy C, Ioffe S, Vanhoucke V, et al. Inception-v4, inception-resnet and the impact of residual connections on learning[C]//Thirty-first AAAI conference on artificial intelligence. 2017. + +[12] Chollet F. Xception: Deep learning with depthwise separable convolutions[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 1251-1258. + +[13] Wang J, Sun K, Cheng T, et al. Deep high-resolution representation learning for visual recognition[J]. arXiv preprint arXiv:1908.07919, 2019. + +[14] Chen Y, Li J, Xiao H, et al. Dual path networks[C]//Advances in neural information processing systems. 2017: 4467-4475. + +[15] Huang G, Liu Z, Van Der Maaten L, et al. Densely connected convolutional networks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 4700-4708. + +[16] Tan M, Le Q V. Efficientnet: Rethinking model scaling for convolutional neural networks[J]. arXiv preprint arXiv:1905.11946, 2019. + +[17] Mahajan D, Girshick R, Ramanathan V, et al. Exploring the limits of weakly supervised pretraining[C]//Proceedings of the European Conference on Computer Vision (ECCV). 2018: 181-196. + +[18] Krizhevsky A, Sutskever I, Hinton G E. Imagenet classification with deep convolutional neural networks[C]//Advances in neural information processing systems. 2012: 1097-1105. + +[19] Iandola F N, Han S, Moskewicz M W, et al. SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and< 0.5 MB model size[J]. arXiv preprint arXiv:1602.07360, 2016. + +[20] Simonyan K, Zisserman A. Very deep convolutional networks for large-scale image recognition[J]. arXiv preprint arXiv:1409.1556, 2014. + +[21] Redmon J, Divvala S, Girshick R, et al. You only look once: Unified, real-time object detection[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2016: 779-788. + +[22] Ding X, Guo Y, Ding G, et al. Acnet: Strengthening the kernel skeletons for powerful cnn via asymmetric convolution blocks[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 1911-1920. + +[23] Han K, Wang Y, Tian Q, et al. GhostNet: More features from cheap operations[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2020: 1580-1589. + +[24] Zhang H, Wu C, Zhang Z, et al. Resnest: Split-attention networks[J]. arXiv preprint arXiv:2004.08955, 2020. + +[25] Radosavovic I, Kosaraju R P, Girshick R, et al. Designing network design spaces[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2020: 10428-10436. + +[26] C.Szegedy, V.Vanhoucke, S.Ioffe, J.Shlens, and Z.Wojna. Rethinking the inception architecture for computer vision. arXiv preprint arXiv:1512.00567, 2015. + +[27] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin and Baining Guo. Swin Transformer: Hierarchical Vision Transformer using Shifted Windows. + +[28]Cheng Cui, Tingquan Gao, Shengyu Wei, Yuning Du, Ruoyu Guo, Shuilong Dong, Bin Lu, Ying Zhou, Xueying Lv, Qiwen Liu, Xiaoguang Hu, Dianhai Yu, Yanjun Ma. PP-LCNet: A Lightweight CPU Convolutional Neural Network. + +[29]Mingxing Tan, Quoc V. Le. MixConv: Mixed Depthwise Convolutional Kernels. + +[30]Dongyoon Han, Sangdoo Yun, Byeongho Heo, YoungJoon Yoo. Rethinking Channel Dimensions for Efficient Model Design. + +[31]Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby. AN IMAGE IS WORTH 16X16 WORDS: +TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE. + +[32]Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, Herve Jegou. Training data-efficient image transformers & distillation through attention. + +[33]Benjamin Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Herve Jegou, Matthijs Douze. LeViT: a Vision Transformer in ConvNet’s Clothing for Faster Inference. + +[34]Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, Chunhua Shen. Twins: Revisiting the Design of Spatial Attention in Vision Transformers. + +[35]Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, Yunhe Wang. Transformer in Transformer. + +[36]Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, Jian Sun. RepVGG: Making VGG-style ConvNets Great Again. + +[37]Ping Chao, Chao-Yang Kao, Yu-Shan Ruan, Chien-Hsiang Huang, Youn-Long Lin. HarDNet: A Low Memory Traffic Network. + +[38]Fisher Yu, Dequan Wang, Evan Shelhamer, Trevor Darrell. Deep Layer Aggregation. + +[39]Duo Lim Jie Hu, Changhu Wang, Xiangtai Li, Qi She, Lei Zhu, Tong Zhang, Qifeng Chen. Involution: Inverting the Inherence of Convolution for Visual Recognition. diff --git a/src/PaddleClas/docs/en/algorithm_introduction/image_classification_en.md b/src/PaddleClas/docs/en/algorithm_introduction/image_classification_en.md new file mode 100644 index 0000000..fa2319c --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/image_classification_en.md @@ -0,0 +1,78 @@ +# Image Classification Task Introduction +## Catalogue + +- [1. Dataset Introduction](#1) + - [1.1 ImageNet-1k](#1.1) + - [1.2 CIFAR-10/CIFAR-100](#1.2) +- [2. Image Classification Process](#2) + - [2.1 Data and its Preprocessing](#2.1) + - [2.2 Prepare the model](#2.2) + - [2.3 Train the model](#2.3) + - [2.4 Evaluate the model](#2.4) +- [3. Main Algorithms Introduction](#3) + +Image Classification is a fundamental task that classifies the image by semantic information and assigns it to a specific label. Image Classification is the foundation of Computer Vision tasks, such as object detection, image segmentation, object tracking, and behavior analysis. Image Classification enjoys comprehensive applications, including face recognition and smart video analysis in the security and protection field, traffic scenario recognition in the traffic field, image retrieval and electronic photo album classification in the internet industry, and image recognition in the medical industry. + +Generally speaking, Image Classification attempts to fully describe the whole image by feature engineering and assigns labels by a classifier. Hence, how to extract the features of images is the essential part. Before we have deep learning, the most adopted classification method is the Bag of Words model. However, Image Classification based on deep learning can learn the hierarchical feature description by supervised and unsupervised learning, replacing the manual image feature selection. Recently, Convolution Neural Network (CNN) in deep learning gives an awesome performance in the image field. It uses pixel information as the input to get all the information to the maximum extent. Additionally, since the model uses convolution to extract features, the classification result is the output. Thus, this end-to-end method performs well and is widespread. + +Image Classification is a basic but important field in computer vision, whose research results have a lasting impact on the development of computer vision and even deep learning. Image classification has many sub-fields, such as multi-label image classification and fine-grained image classification. Here we only brief on the single-label image classification. + + + +## 1. Dataset Introduction + + + +### 1.1 ImageNet-1k + +The ImageNet project is a large-scale visual database for the research of visual object recognition software. More than 14 million images have been annotated manually to point out objects in the picture, and at least 1 million images are provided with borders. ImageNet-1k is a subset of the ImageNet dataset, which contains 1000 categories. The training set contains 1281167 image data, and the validation set contains 50,000 image data. Since 2010, ImageNet began to hold an annual image classification competition, namely, the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) with ImageNet-1k as its specified dataset. To date, ImageNet-1k has become one of the most significant contributors to the development of computer vision, based on which numerous initial models of downstream computer vision tasks are trained. + + + +### 1.2 CIFAR-10/CIFAR-100 + +The CIFAR-10 data set consists of 60,000 color images of 10 categories with an image resolution of 32x32, and each category has 6000 images, including 5000 in the training set and 1000 in the validation set. The 10 different classes represent airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks. The CIFAR-100 dataset is an extension of CIFAR-10 and consists of 60,000 color images of 100 classes with an image resolution of 32x32, and each class has 600 images, including 500 in the training set and 100 in the validation set. Researchers can try different algorithms quickly due to their small scale. These two data sets are also commonly used for testing the quality of models in image classification. + + + +## 2. Image Classification Process + +The prepared training data is correspondingly preprocessed and then passed through the image classification model. The output of the model and the real label are used in a cross-entropy loss function which describes the convergence direction of the model. An image classification model can be obtained by repeatedly traversing all the image data input models, conducting the corresponding gradient descent for the final loss function through some optimizers, returning the gradient information to the model, and updating the weight of the model. + + + +### 2.1 Data and its Preprocessing + +The quality and quantity of data often determine the performance of a model. In the field of image classification, data includes images and labels. In most cases, labeled data is scarce to an extent that hard to saturate the model. In order to enable the model to learn more image features, a lot of image transformation or data augmentation is required before the image enters the model, so as to ensure the diversity of input data, hence better generalization capabilities of the model. PaddleClas provides standard image transformation for training ImageNet-1k and 8 data augmentation methods. For related codes, please refer to [Data Preprocess](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/data/preprocess),and the configuration file to [Data Augmentation Configuration File](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/DataAugment). + + + +### 2.2 Prepare the Model + +After the data is settled, the model often determines the upper limit of the final accuracy. In the field of image classification, classic models emerge in endlessly. PaddleClas provides 36 series, or a total of 164 ImageNet pre-trained models. For specific accuracy, speed and other indicators, please refer to [Backbone Network Introduction](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/en/models). + + + +### 2.3 Train the Model + +After preparing the data and model, you can start training the model and updating the parameters of the model. After many iterations, a trained model can finally be obtained for image classification tasks. The training process of image classification requires a lot of experience and involves the setting of many hyperparameters. PaddleClas provides a series of [training tuning methods](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/en/models/Tricks_en.md), which can help you quickly obtain a high-precision model. + + + +### 2.4 Evaluate the Model + +After a model is trained, the evaluation results of the model on the validation set can determine the performance of the model. The evaluation index is generally Top1-Acc or Top5-Acc, and the higher the index, the better the model performance. + + + +## 3. Main Algorithms Introduction + +- LeNet: Yan LeCun et al. first applied convolutional neural networks to image classification tasks in the 1990s, and creatively proposed LeNet, which achieved great success in handwritten digit recognition tasks. +- AlexNet: Alex Krizhevsky et al. proposed AlexNet in 2012 and applied it to ImageNet, and won the 2012 ImageNet classification competition. Since then, a deep learning boom is created. +- VGG: Simonyan and Zisserman put forward the VGG network structure in 2014. This network structure uses a smaller convolution kernel to stack the entire network, achieving better performance in ImageNet classification and providing new ideas for the subsequent network structure design. +- GoogLeNet: Christian Szegedy et al. presented GoogLeNet in 2014. This network uses a multi-branch structure and a global average pooling layer (GAP). While maintaining the accuracy of the model, the amount of model storage and calculation witnesses a drastic decrease. The network won the 2014 ImageNet classification competition. +- ResNet: Kaiming He et al. delivered ResNet in 2015, which deepened the depth of the network by introducing a residual module, reducing the recognition error rate of ImageNet classification to 3.6%, which exceeded the recognition accuracy of normal human eyes for the first time. +- DenseNet: Huang Gao et al. proposed DenseNet in 2017. The network designed a denser connected block and achieved higher performance with a smaller amount of parameters. +- EfficientNet: Mingxing Tan et al. introduced EfficientNet in 2019. This network balances the width of the network, the depth of the network, and the resolution of the input image. With the same FLOPS and parameters, it reaches the state-of-the-art results. + +For more algorithm introduction, please refer to [Algorithm Introduction](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/en/models). diff --git a/src/PaddleClas/docs/en/algorithm_introduction/index.rst b/src/PaddleClas/docs/en/algorithm_introduction/index.rst new file mode 100644 index 0000000..e0fad79 --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/index.rst @@ -0,0 +1,12 @@ +algorithm_introduction +================================ + +.. toctree:: + :maxdepth: 2 + + image_classification_en.md + metric_learning_en.md + knowledge_distillation_en.md + model_prune_quantization_en.md + ImageNet_models_en.md + DataAugmentation_en.md diff --git a/src/PaddleClas/docs/en/algorithm_introduction/knowledge_distillation_en.md b/src/PaddleClas/docs/en/algorithm_introduction/knowledge_distillation_en.md new file mode 100644 index 0000000..f528569 --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/knowledge_distillation_en.md @@ -0,0 +1,94 @@ +# Knowledge Distillation + +--- +## Content + +* [1. Introduction of model compression methods](#1) +* [2. Application of knowledge distillation](#2) +* [3. Overview of knowledge distillation methods](#3) + * [3.1 Response based distillation](#3.1) + * [3.2 Feature based distillation](#3.2) + * [3.3 Relation based distillation](#3.3) +* [4. Reference](#4) + + + +## 1. Introduction of model compression methods + +In recent years, deep neural networks have been proved to be an extremely effective method for solving problems in the fields of computer vision and natural language processing. A suitable neural network architecture might performs better than traditional algorithms mostly. + +When the amount of data is large enough, increasing the model parameters with a reasonable method can significantly improve the model performance, but this brings about the problem of a sharp increase of the model complexity. It costs more for larger models. + +Parameter redundancy exists in deep neural networks generally. At present, there are several mainstream methods to compress the model and reduce parameters. Such as pruning, quantization, knowledge distillation, etc. Knowledge distillation refers to the use of a teacher model to guide the student model to learn specific tasks to ensure that the small model obtains relatively large performance, and even has comparable performance with the large model [1]. + + +Currently, knowledge distillation methods can be roughly divided into the following three types. + +* Response based distillation: Output of student model is guided by the teacher model for +* Feature based distillation: Inner feature map of student model is guided by the teacher model. +* Relation based distillation: For different samples, the teacher model and the student model are used to calculate the correlation of the feature map between the samples, the final goal is to make sure that correlation matrix of student model and the teacher model are as consistent as possible. + + + + +## 2. Application of knowledge distillation + +Knowledge distillation algorithm is widely used in lightweight tasks. For tasks that need to meet specific accuracy, by using the knowledge distillation method, we can achieve the required accuracy with a smaller model, thereby reducing model deployment cost. + + +What's more, for the same model structure, pre-trained models obtained by knowledge distillation often performs better, and these pre-trained models can also improve performance of the downstream tasks. For example, a pre-trained image classification model with higher accuracy can also help other tasks obtain significant accuracy gains such as target detection, image segmentation, OCR, and video classification. + + + +## 3. Overview of knowledge distillation methods + + + +### 3.1 Response based distillation + + +Knowledge distillation algorithm is firstly proposed by Hinton, which is called KD. In addition to base cross entropy loss, KL divergence loss between output of student model and teacher model is also added into the total training loss. It's noted that a larger teacher model is needed to guide the training process of the student model. + +PaddleClas proposed a simple but useful knowledge distillation algorithm canlled SSLD [6], Labels are not needed for SSLD, so unlabeled data can also be used for training. Accuracy of 15 models has more than 3% improvement using SSLD. + +Teacher model is needed for the above-mentioned distillation method to guide the student model training process. Deep Mutual Learning (DML) is then proposed [7], for which two models with same architecture learn from each other to obtain higher accuracy. Compared with KD and other knowledge distillation algorithms that rely on large teacher models, DML is free of dependence on large teacher models. The distillation training process is simpler. + + + +### 3.2 Feature based distillation + +Heo et al. proposed OverHaul [8], which calculates the feature map distance between the student model and the teacher model, as distillation loss. Here, feature map alignment of the student model and the teacher model is used to ensure that the feature maps' distance can be calculated. + +Feature based distillation can also be integrated with the response based knowledge distillation algorithm in Chapter 3.1, which means both the inner feature map and output of the student model are guided during the training process. For the DML method, this integration process is simpler, because the alignment process is not needed since the two models' architectures are absolutely same. This integration process is used in the PP-OCRv2 system, which ultimately greatly improves the accuracy of the OCR text recognition model. + + + +### 3.3 Relation based distillation + +The papers in chapters `3.1` and `3.2` mainly consider the inner feature map or final output of the student model and the teacher model. These knowledge distillation algorithms only focus on the output for single sample, but do not consider the output relationship between different samples. + +Park et al. proposed RKD [10], a relationship-based knowledge distillation algorithm. In RKD, the relationship between different samples is further considered, and two loss functions are used, which are the second-order distance loss (distance-wise) and the third-order angle loss (angle-wise). For the final distillation loss, KD loss and RKD loss are considered at the same time. The final accuracy is better than the accuracy of the model obtained just using KD loss. + + + +## 4. Reference + +[1] Hinton G, Vinyals O, Dean J. Distilling the knowledge in a neural network[J]. arXiv preprint arXiv:1503.02531, 2015. + +[2] Bagherinezhad H, Horton M, Rastegari M, et al. Label refinery: Improving imagenet classification through label progression[J]. arXiv preprint arXiv:1805.02641, 2018. + +[3] Yalniz I Z, Jégou H, Chen K, et al. Billion-scale semi-supervised learning for image classification[J]. arXiv preprint arXiv:1905.00546, 2019. + +[4] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123. + +[5] Touvron H, Vedaldi A, Douze M, et al. Fixing the train-test resolution discrepancy[C]//Advances in Neural Information Processing Systems. 2019: 8250-8260. + +[6] Cui C, Guo R, Du Y, et al. Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones[J]. arXiv preprint arXiv:2103.05959, 2021. + +[7] Zhang Y, Xiang T, Hospedales T M, et al. Deep mutual learning[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2018: 4320-4328. + +[8] Heo B, Kim J, Yun S, et al. A comprehensive overhaul of feature distillation[C]//Proceedings of the IEEE/CVF International Conference on Computer Vision. 2019: 1921-1930. + +[9] Du Y, Li C, Guo R, et al. PP-OCRv2: Bag of Tricks for Ultra Lightweight OCR System[J]. arXiv preprint arXiv:2109.03144, 2021. + +[10] Park W, Kim D, Lu Y, et al. Relational knowledge distillation[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2019: 3967-3976. diff --git a/src/PaddleClas/docs/en/algorithm_introduction/metric_learning_en.md b/src/PaddleClas/docs/en/algorithm_introduction/metric_learning_en.md new file mode 100644 index 0000000..e8e4096 --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/metric_learning_en.md @@ -0,0 +1,40 @@ +# Metric Learning + +## Catalogue + +- [1.Introduction](#1) +- [2.Applications](#2) +- [3.Algorithms](#3) + - [3.1 Classification based](#3.1) + - [3.2 Pairwise based](#3.2) + + +## 1.Introduction + +Measuring the distance between data is a common practice in machine learning. Generally speaking, Euclidean Distance, Inner Product, or Cosine Similarity are all available to calculate measurable data. However, the same operation can hardly be replicated on unstructured data, such as calculating the compatibility between a video and a piece of music. Despite the difficulty in performing the aforementioned vector operation directly due to varied data formats, priori knowledge tells that ED(laugh_video, laugh_music) < ED(laugh_video, blue_music). And how to effectively characterize this "distance"? This is exactly the focus of Metric Learning. + +Metric learning, known as Distance Metric Learning, is to automatically construct a task-specific metric function based on training data in the form of machine learning. As shown in the figure below, the goal of Metric learning is to learn a transformation function (either linear or nonlinear) L that maps data points from the original vector space to a new one in which similar points are closer together and non-similar points are further apart, making the metric more task-appropriate. And Deep Metric Learning fits the transformation function by adopting a deep neural network. ![example](../../images/ml_illustration.jpg) + + +## 2.Applications + +Metric Learning technologies are widely applied in real life, such as Face Recognition, Person ReID, Image Retrieval, Fine-grained classification, etc. With the growing prevalence of deep learning in industrial practice, Deep Metric Learning (DML) emerges as the current research direction. + +Normally, DML consists of three parts: a feature extraction network for map embedding, a sampling strategy to combine samples in a mini-batch into multiple sub-sets, and a loss function to compute the loss on each sub-set. Please refer to the figure below: ![image](../../images/ml_pipeline.jpg) + + +## 3.Algorithms + +Two learning paradigms are adopted in Metric Learning: + + +### 3.1 Classification based: + +This refers to methods based on classification labels. They learn the effective feature representation by classifying each sample into the correct category and require the participation of the explicit labels of each sample in the Loss calculation during the learning process. Common algorithms include [L2-Softmax](https://arxiv.org/abs/1703.09507), [Large-margin Softmax](https://arxiv.org/abs/1612.02295), [Angular Softmax](https://arxiv.org/pdf/1704.08063.pdf), [NormFace](https://arxiv.org/abs/1704.06369), [AM-Softmax](https://arxiv.org/abs/1801.05599), [CosFace](https://arxiv.org/abs/1801.09414), [ArcFace](https://arxiv.org/abs/1801.07698), etc. These methods are also called proxy-based, because what they optimize is essentially the similarity between a sample and a set of proxies. + + +### 3.2 Pairwise based: + +This refers to the learning paradigm based on paired samples. It takes sample pairs as input and obtains an effective feature representation by directly learning the similarity between these pairs. Common algorithms include [Contrastive loss](http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf), [ Triplet loss](https://arxiv.org/abs/1503.03832), [Lifted-Structure loss](https://arxiv.org/abs/1511.06452), [N-pair loss](https://), [Multi-Similarity loss](https://arxiv.org/pdf/1904.06627.pdf), etc. + +[CircleLoss](https://arxiv.org/abs/2002.10857), released in 2020, unifies the two learning paradigms from a fresh perspective, prompting researchers and practitioners' further reflection on Metric Learning. diff --git a/src/PaddleClas/docs/en/algorithm_introduction/model_prune_quantization_en.md b/src/PaddleClas/docs/en/algorithm_introduction/model_prune_quantization_en.md new file mode 100644 index 0000000..14568a3 --- /dev/null +++ b/src/PaddleClas/docs/en/algorithm_introduction/model_prune_quantization_en.md @@ -0,0 +1,52 @@ +# Algorithms of Model Pruning and Quantization + +Deep learning limits the deployment of corresponding models in some scenarios and devices due to its computational complexity or parameter redundancy, thus requiring model compression, optimization acceleration. Model compression algorithms can effectively decrease parameter redundancy, thus reducing storage footprint, communication bandwidth, and computational complexity, which are conducive to the application and deployment of models of deep learning. Among them, model quantization and pruning enjoy great popularity. In PaddleClas, the following two algorithms should be mainly applied. + +- Quantization: PACT +- Pruning: FPGM + +See [PaddeSlim](https://github.com/PaddlePaddle/PaddleSlim/) for detailed parameters. + +## Catlogue + +- [1. PACT](#1) +- [2. FPGM](#2) + + + +## 1. PACT + +The model quantization comprises two main parts, the quantization of the Weight and the Activation. Simultaneous quantization of the two parts is necessary to maximize the computational efficiency gain. The weight can be distributed as compactly as possible by means of network regularization to reduce outliers and uneven distribution, while there is a lack of effective means for activation. + +**PACT (PArameterized Clipping acTivation)** is a new quantization method that minimizes the loss of accuracy, or even achieves great accuracy by removing some outliers before the quantization of activation. The method was proposed when the author found that "the quantized activation differed significantly from the full accuracy results when the weight quantization is adopted". The author also found that the quantization of activation can cause a great error (as a result of RELU, the range of activation is infinite compared to the weight which is basically within 0 to 1), so the activation function **clipped RELU** was introduced. The clipping ceiling, i.e., $α$, is a learnable parameter, which ensures that each layer can learn a different quantization range through training and minimizes the rounding error caused by quantization. The schematic diagram of quantization is shown below. **PACT** solves the problem by continuously trimming the activation range so that the activation distribution is narrowed, thus reducing the quantization mapping loss. It can acquire a more reasonable quantization scale and cut the quantization loss by clipping the activation, thus reducing the outliers in the activation distribution. + +![img](../../images/algorithm_introduction/quantization.jpg) + +The quantization formula of **PACT** is as follows: + +![img](../../images/algorithm_introduction/quantization_formula.png) + +It is shown that PACT is about adopting the above quantization as a substitute for the *ReLU* function to clip the part greater than zero with a threshold of $a$. However, the above formula is further improved in *PaddleSlim* as follows: + +![img](../../images/algorithm_introduction/quantization_formula_slim.png) + + + +After the above improvement, *PACT* preprocessing is inserted between the activation and the OP (convolution, full connection, etc.) to be quantized, which not only clips the distribution greater than 0 but also perform the same for the part less than 0, so as to better obtain the range to be quantized and minimize the quantization loss. At the same time, the clipping threshold is a trainable parameter, which can be detected automatically and reasonably by the model during the quantization training, thus further lowering the quantization accuracy loss. + +For specific algorithm parameters, please refer to [Introduction to Parameters](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/quanter/qat.rst#qat) in PaddleSlim. + + + +## 2. FPGM + +Model pruning is an essential practice to reduce the model size and improve inference efficiency. In previous articles on network pruning, the norm of the network filter is generally adopted to measure its importance, **the smaller the norm value, the less important the filter is** and the more significant it will be to clip it from the network. **FPGM** believes that the previous approach relies on the following two points: + +- The deviation of the filter's norm should be large so that important and unimportant filters can be well separated +- The norm of the unimportant filter should be small enough + +Based on this, **FPGM** takes advantage of the geometric center property of the filter. Since filters near the center can be expressed by others, they can be eliminated, thus avoiding the above two pruning conditions. As a result, the pruning is conducted in consideration of the redundancy of information instead of a small norm. The following figure shows how the **FPGM** differs from the previous method, see [paper](https://openaccess.thecvf.com/content_CVPR_2019/papers/He_Filter_Pruning_via_Geometric_Median_) for more details. + +![img](../../images/algorithm_introduction/fpgm.png) + +For specific algorithm parameters, please refer to [Introduction to Parameters](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/pruners/fpgm_filter_pruner.rst#fpgmfilterpruner) in PaddleSlim. diff --git a/src/PaddleClas/docs/en/change_log.md b/src/PaddleClas/docs/en/change_log.md new file mode 100644 index 0000000..406a49e --- /dev/null +++ b/src/PaddleClas/docs/en/change_log.md @@ -0,0 +1,3 @@ +# Release Notes + +* 2020.04.14: first commit diff --git a/src/PaddleClas/docs/en/conf.py b/src/PaddleClas/docs/en/conf.py new file mode 100644 index 0000000..fef10ee --- /dev/null +++ b/src/PaddleClas/docs/en/conf.py @@ -0,0 +1,65 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +import sphinx_rtd_theme +from recommonmark.parser import CommonMarkParser +# -- Project information ----------------------------------------------------- + +project = 'PaddleClas-en' +copyright = '2022, PaddleClas' +author = 'PaddleClas' + +# The full version, including alpha/beta/rc tags +release = '2.3' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +source_parsers = { + '.md': CommonMarkParser, +} +source_suffix = ['.rst', '.md'] +extensions = [ + 'recommonmark', + 'sphinx_markdown_tables' + ] +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The root document. +root_doc = 'doc_en' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +# 更改文档配色 +html_theme = "sphinx_rtd_theme" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] diff --git a/src/PaddleClas/docs/en/data_preparation/classification_dataset_en.md b/src/PaddleClas/docs/en/data_preparation/classification_dataset_en.md new file mode 100644 index 0000000..3903a00 --- /dev/null +++ b/src/PaddleClas/docs/en/data_preparation/classification_dataset_en.md @@ -0,0 +1,130 @@ +# Image Classification Datasets + +This document elaborates on the dataset format adopted by PaddleClas for image classification tasks, as well as other common datasets in this field. + +------ + +## Catalogue + +- [1.Dataset Format](#1) +- [2.Common Datasets for Image Classification](#2) + - [2.1 ImageNet1k](#2.1) + - [2.2 Flowers102](#2.2) + - [2.3 CIFAR10 / CIFAR100](#2.3) + - [2.4 MNIST](#2.4) + - [2.5 NUS-WIDE](#2.5) + + + +## 1.Dataset Format + +PaddleClas adopts `txt` files to assign the training and test sets. Taking the `ImageNet1k` dataset as an example, where `train_list.txt` and `val_list.txt` have the following formats: + +``` +# Separate the image path and annotation with "space" for each line + +# train_list.txt has the following format +train/n01440764/n01440764_10026.JPEG 0 +... + +# val_list.txt has the following format +val/ILSVRC2012_val_00000001.JPEG 65 +... +``` + + + +## 2.Common Datasets for Image Classification + +Here we present a compilation of commonly used image classification datasets, which is continuously updated and expects your supplement. + + +### 2.1 ImageNet1k + +[ImageNet](https://image-net.org/) is a large visual database for visual target recognition research with over 14 million manually labeled images. ImageNet-1k is a subset of the ImageNet dataset, which contains 1000 categories with 1281167 images for the training set and 50000 for the validation set. Since 2010, ImageNet began to hold an annual image classification competition, namely, the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) with ImageNet-1k as its specified dataset. To date, ImageNet-1k has become one of the most significant contributors to the development of computer vision, based on which numerous initial models of downstream computer vision tasks are trained. + +| Dataset | Size of Training Set | Size of Test Set | Number of Category | Note | +| ------------------------------------------------------------ | -------------------- | ---------------- | ------------------ | ---- | +| [ImageNet1k](http://www.image-net.org/challenges/LSVRC/2012/) | 1.2M | 50k | 1000 | | + +After downloading the data from official sources, organize it in the following format to train with the ImageNet1k dataset in PaddleClas. + +``` +PaddleClas/dataset/ILSVRC2012/ +|_ train/ +| |_ n01440764 +| | |_ n01440764_10026.JPEG +| | |_ ... +| |_ ... +| | +| |_ n15075141 +| |_ ... +| |_ n15075141_9993.JPEG +|_ val/ +| |_ ILSVRC2012_val_00000001.JPEG +| |_ ... +| |_ ILSVRC2012_val_00050000.JPEG +|_ train_list.txt +|_ val_list.txt +``` + + + +### 2.2 Flowers102 + +| Dataset | Size of Training Set | Size of Test Set | Number of Category | Note | +| ------------------------------------------------------------ | -------------------- | ---------------- | ------------------ | ---- | +| [flowers102](https://www.robots.ox.ac.uk/~vgg/data/flowers/102/) | 1k | 6k | 102 | | + +Unzip the downloaded data to see the following directory. + +``` +jpg/ +setid.mat +imagelabels.mat +``` + +Place the files above under `PaddleClas/dataset/flowers102/` . + +Run `generate_flowers102_list.py` to generate `train_list.txt` and `val_list.txt`: + +``` +python generate_flowers102_list.py jpg train > train_list.txt +python generate_flowers102_list.py jpg valid > val_list.txt +``` + +Structure the data as follows: + +``` +PaddleClas/dataset/flowers102/ +|_ jpg/ +| |_ image_03601.jpg +| |_ ... +| |_ image_02355.jpg +|_ train_list.txt +|_ val_list.txt +``` + + + +### 2.3 CIFAR10 / CIFAR100 + +The CIFAR-10 dataset comprises 60,000 color images of 10 classes with 32x32 image resolution, each with 6,000 images including 5,000 images in the training set and 1,000 images in the validation set. The 10 different classes represent airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks. The CIFAR-100 dataset is an extension of CIFAR-10 and consists of 60,000 color images of 100 classes with 32x32 image resolution, each with 600 images including 500 images in the training set and 100 images in the validation set. + +Website:http://www.cs.toronto.edu/~kriz/cifar.html + + + +### 2.4 MNIST + +MMNIST is a renowned dataset for handwritten digit recognition and is used as an introductory sample for deep learning in many sources. It contains 60,000 images, 50,000 for the training set and 10,000 for the validation set, with a size of 28 * 28. + +Website:http://yann.lecun.com/exdb/mnist/ + + + +### 2.5 NUS-WIDE + +NUS-WIDE is a multi-category dataset. It contains 269,648 images and 81 categories with each image being labeled as one or more of the 81 categories. + +Website:https://lms.comp.nus.edu.sg/wp-content/uploads/2019/research/nuswide/NUS-WIDE.html diff --git a/src/PaddleClas/docs/en/data_preparation/index.rst b/src/PaddleClas/docs/en/data_preparation/index.rst new file mode 100644 index 0000000..e668126 --- /dev/null +++ b/src/PaddleClas/docs/en/data_preparation/index.rst @@ -0,0 +1,8 @@ +data_preparation +================================ + +.. toctree:: + :maxdepth: 2 + + recognition_dataset_en.md + classification_dataset_en.md diff --git a/src/PaddleClas/docs/en/data_preparation/recognition_dataset_en.md b/src/PaddleClas/docs/en/data_preparation/recognition_dataset_en.md new file mode 100644 index 0000000..32a2798 --- /dev/null +++ b/src/PaddleClas/docs/en/data_preparation/recognition_dataset_en.md @@ -0,0 +1,141 @@ +# Image Recognition Datasets + +This document elaborates on the dataset format adopted by PaddleClas for image recognition tasks, as well as other common datasets in this field. + +------ + +## Catalogue + +- [1.Dataset Format](#1) +- [2.Common Datasets for Image Recognition](#2) + - [2.1 General Datasets](#2.1) + - [2.2 Vertical Class Datasets](#2.2) + - [2.2.1 Animation Character Recognition](#2.2.1) + - [2.2.2 Product Recognition](#2.2.2) + - [2.2.3 Logo Recognition](#2.2.3) + - [2.2.4 Vehicle Recognition](#2.2.4) + + + +## 1.Dataset Format + +The dataset for the vector search, unlike those for classification tasks, is divided into the following three parts: + +- Train dataset: Used to train the model to learn the image features involved. +- Gallery dataset: Used to provide the gallery data in the vector search task. It can either be the same as the train or query datasets or different, and when it is the same as the train dataset, the category system of the query dataset and train dataset should be the same. +- Query dataset: Used to test the performance of the model. It usually extracts features from each query image of the dataset, followed by distance matching with those in the gallery dataset to get the recognition results, based on which the metrics of the whole query dataset are calculated. + +The above three datasets all adopt `txt` files for assignment. Taking the `CUB_200_2011` dataset as an example, the `train_list.txt` of the train dataset has the following format: + +``` +# Use "space" as the separator +... +train/99/Ovenbird_0136_92859.jpg 99 2 +... +train/99/Ovenbird_0128_93366.jpg 99 6 +... +``` + +The `test_list.txt` of the query dataset (both gallery dataset and query dataset in`CUB_200_2011`) has the following format: + +``` +# Use "space" as the separator +... +test/200/Common_Yellowthroat_0126_190407.jpg 200 1 +... +test/200/Common_Yellowthroat_0114_190501.jpg 200 6 +... +``` + +Each row of data is separated by "space", and the three columns of data stand for the path, label information, and unique id of training data. + +**Note**: + +1. When the gallery dataset and query dataset are the same, to remove the first retrieved data (the images themselves require no evaluation), each data should have its unique id (ensuring that each image has a different id, which can be represented by the row number) for subsequent evaluation of mAP, recall@1, and other metrics. The dataset of yaml configuration file is `VeriWild`. + +2. When the gallery dataset and query dataset are different, there is no need to add a unique id. Both `query_list.txt` and `gallery_list.txt` contain two columns, which are the path and label information of the training data. The dataset of yaml configuration file is ` ImageNetDataset`. + + + +## 2.Common Datasets for Image Recognition + +Here we present a compilation of commonly used image recognition datasets, which is continuously updated and expects your supplement. + + +### 2.1 General Datasets + +- SOP: The SOP dataset is a common product dataset in general recognition research and MetricLearning technology research, which contains 120,053 images of 22,634 products downloaded from eBay.com. There are 59,551 images of 11,318 in the training set and 60,502 images of 11,316 categories in the validation set. + + Website: https://cvgl.stanford.edu/projects/lifted_struct/ + +- Cars196: The Cars dataset contains 16,185 images of 196 categories of cars. The data is classified into 8144 training images and 8041 query images, with each category split roughly in a 50-50 ratio. The classification is normally based on the manufacturing, model and year of the car, e.g. 2012 Tesla Model S or 2012 BMW M3 coupe. + + Website: https://ai.stanford.edu/~jkrause/cars/car_dataset.html + +- CUB_200_2011: The CUB_200_2011 dataset is a fine-grained dataset proposed by the California Institute of Technology (Caltech) in 2010 and is currently the benchmark image dataset for fine-grained classification recognition research. There are 11788 bird images in this dataset with 200 subclasses, including 5994 images in the train dataset and 5794 images in the query dataset. Each image provides label information, the bounding box of the bird, the key part information of the bird, and the attribute of the bird. The dataset is shown in the figure below. + +- In-shop Clothes: In-shop Clothes is one of the 4 subsets of the DeepFashion dataset. It is a seller show image dataset with multi-angle images of each product id being collected in the same folder. The dataset contains 7982 items with 52712 images, each with 463 attributes, Bbox, landmarks, and store descriptions. + + Website: http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion.html + + + +### 2.2 Vertical Class Datasets + + + +#### 2.2.1 Animation Character Recognition + +- iCartoonFace: iCartoonFace, developed by iQiyi (an online video platform), is the world's largest manual labeled detection and recognition dataset for cartoon characters, which contains more than 5013 cartoon characters and 389,678 high-quality live images. Compared with other datasets, it boasts features of large scale, high quality, rich diversity, and challenging difficulty, making it one of the most commonly used datasets to study cartoon character recognition. + +- Website: http://challenge.ai.iqiyi.com/detail?raceId=5def69ace9fcf68aef76a75d + +- Manga109: Manga109 is a dataset released in May 2020 for the study of cartoon character detection and recognition, which contains 21142 images and is officially banned from commercial use. Manga109-s, a subset of this dataset, is available for industrial use, mainly for tasks such as text detection, sketch line-based search, and character image generation. + + Website:http://www.manga109.org/en/ + +- IIT-CFW: The IIF-CFW dataset contains a total of 8928 labeled cartoon portraits of celebrity characters, covering 100 characters with varying numbers of portraits for each. In addition, it also provides 1000 real face photos (10 real portraits for 100 public figures). This dataset can be employed to study both animation character recognition and cross-modal search tasks. + + Website: http://cvit.iiit.ac.in/research/projects/cvit-projects/cartoonfaces + + + +#### 2.2.2 Product Recognition + +- AliProduct: The AliProduct dataset is the largest open source product dataset. As an SKU-level image classification dataset, it contains 50,000 categories and 3 million images, ranking the first in both aspects in the industry. This dataset covers a large number of household goods, food, etc. Due to its lack of manual annotation, the data is messy and unevenly distributed with many similar product images. + + Website: https://retailvisionworkshop.github.io/recognition_challenge_2020/ + +- Product-10k: Products-10k dataset has all its images from Jingdong Mall, covering 10,000 frequently purchased SKUs that are organized into a hierarchy. In total, there are nearly 190,000 images. In the real application scenario, the distribution of image volume is uneven. All images are manually checked/labeled by a team of production experts. + + Website:https://www.kaggle.com/c/products-10k/data?select=train.csv + +- DeepFashion-Inshop: The same as the common datasets In-shop Clothes. + + + +### 2.2.3 Logo Recognition + +- Logo-2K+: Logo-2K+ is a dataset exclusively for logo image recognition, which contains 10 major categories, 2341 minor categories, and 167,140 images. + + Website: https://github.com/msn199959/Logo-2k-plus-Dataset + +- Tsinghua-Tencent 100K: This dataset is a large traffic sign benchmark dataset based on 100,000 Tencent Street View panoramas. 30,000 traffic sign instances included, it provides 100,000 images covering a wide range of illumination, and weather conditions. Each traffic sign in the benchmark test is labeled with the category, bounding box and pixel mask. A total of 222 categories (0 background + 221 traffic signs) are incorporated. + + Website: https://cg.cs.tsinghua.edu.cn/traffic-sign/ + + + +### 2.2.4 Vehicle Recognition + +- CompCars: The images, 136,726 images of the whole car and 27,618 partial ones, are mainly from network and surveillance data. The network data contains 163 vehicle manufacturers and 1,716 vehicle models and includes the bounding box, viewing angle, and 5 attributes (maximum speed, displacement, number of doors, number of seats, and vehicle type). And the surveillance data comprises 50,000 front view images. + + Website: http://mmlab.ie.cuhk.edu.hk/datasets/comp_cars/ + +- BoxCars: The dataset contains a total of 21,250 vehicles, 63,750 images, 27 vehicle manufacturers, and 148 subcategories. All of them are derived from surveillance data. + + Website: https://github.com/JakubSochor/BoxCars + +- PKU-VD Dataset: The dataset contains two large vehicle datasets (VD1 and VD2) that capture images from real-world unrestricted scenes in two cities. VD1 is obtained from high-resolution traffic cameras, while images in VD2 are acquired from surveillance videos. The authors have performed vehicle detection on the raw data to ensure that each image contains only one vehicle. Due to privacy constraints, all the license numbers have been obscured with black overlays. All images are captured from the front view, and diverse attribute annotations are provided for each image in the dataset, including identification numbers, accurate vehicle models, and colors. VD1 originally contained 1097649 images, 1232 vehicle models, and 11 vehicle colors, and remains 846358 images and 141756 vehicles after removing images with multiple vehicles inside and those taken from the rear of the vehicle. VD2 contains 807260 images, 79763 vehicles, 1112 vehicle models, and 11 vehicle colors. + + Website: https://pkuml.org/resources/pku-vds.html diff --git a/src/PaddleClas/docs/en/doc_en.rst b/src/PaddleClas/docs/en/doc_en.rst new file mode 100644 index 0000000..aa25829 --- /dev/null +++ b/src/PaddleClas/docs/en/doc_en.rst @@ -0,0 +1,23 @@ +Welcome to PaddleClas! +================================ + +.. toctree:: + :maxdepth: 1 + + introduction/index + installation/index + quick_start/index + image_recognition_pipeline/index + data_preparation/index + models_training/index + inference_deployment/index + models/index + algorithm_introduction/index + advanced_tutorials/index + others/index + faq_series/index + + + + + diff --git a/src/PaddleClas/docs/en/faq_series/faq_2020_s1_en.md b/src/PaddleClas/docs/en/faq_series/faq_2020_s1_en.md new file mode 100644 index 0000000..de5a50c --- /dev/null +++ b/src/PaddleClas/docs/en/faq_series/faq_2020_s1_en.md @@ -0,0 +1,390 @@ +# Image Classification FAQ Summary - 2020 Season 1 + +## Catalogue + +- [1. Issue 1](#1)(2020.11.03) +- [2. Issue 2](#2)(2020.11.11) +- [3. Issue 3](#3)(2020.11.18) +- [4. Issue 4](#4)(2020.12.07) +- [5. Issue 5](#5)(2020.12.17) +- [6. Issue 6](#6)(2020.12.30) + + + +## Issue 1 + +### Q1.1: What can PaddleClas be used for? + +**A**:PaddleClas is an image recognition toolset for industry and academia, helping users train better computer vision models and apply them in real scenarios. + +It provides the whole process of model training, evaluation, inference, and deployment based on image classification to facilitate users' efficient learning. Specifically, PaddleClas contains the following features. + +- PaddleClas provides 36 families of classification network structures (ResNet, ResNet_vd, MobileNetV3, Res2Net, HRNet, etc.) and training configurations, 175 pre-trained models, and performance evaluation and inference for free choice and application. +- PaddleClas provides a variety of inference deployment solutions such as TensorRT inference, python inference, c++ inference, Paddle-Lite inference deployment, PaddleServing, PaddleHub, etc., to facilitate inference deployment in multiple environments. +- PaddleClas provides a simple SSLD knowledge distillation scheme, based on which the recognition accuracy of distillation models register a general improvement of more than 3%. +- PaddleClas provides 8 data augmentation algorithms such as AutoAugment, Cutout, Cutmix, etc. with a detailed introduction, code replication, and evaluation of effectiveness in a unified experimental environment. +- PaddleClas supports CPU/GPU-based adoption in Windows/Linux/MacOS environments. + +### Q1.2: What is the ResNet series model? What are they? Why are they so popular on the server side? + +**A**: ResNet takes the lead to introduce the residual structure, and construct the ResNet network by stacking multiple residual structures. Experiments show that the use of residual blocks can effectively improve convergence speed and accuracy. In PaddleClas, ResNet has such structures containing 18, 34, 50, 101, 152, and 200 layers in order. These models, proposed in 2015, has been validated in different application scenarios, such as classification, detection, segmentation, etc., and has long been optimized by the industry and acquired obvious advantages in terms of speed and accuracy, let alone its well support for the inference of TensorRT and FP16. Therefore, it is recommended to adopt the ResNet series model. Considering their large storage footprint, they are often used on the server side. For more information about ResNet models, please refer to the paper [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385). + +### Q1.3: What's the difference between the structure of ResNet_vd, ResNet and ResNet_vc? + +**A**: The structure of ResNet_va to vd is shown in the figure below. ResNet was first proposed as va structure, in the left feature transformation path (Path A) of the downsampling residual module, the first 1x1 convolution is downsampled, which leads to information loss (the kernel size of the convolution is 1, stride is 2, some features in the input feature graph are not involved in the calculation of convolution). In the vb structure, the downsampling step is adjusted from the first 1x1 convolution at the beginning to the 3x3 convolution in the middle, thus avoiding the loss of information, and the default ResNet model in PaddleClas is ResNet_vb. The vc structure turns the initial 7x7 convolution into 3 3x3 convolutions with almost the same computation and storage size and improved accuracy when the perceptual field remains unchanged. The vd structure is a modification of the feature path (Path B) on the right side of the downsampling residual module, replacing the downsampling with average pooling. This collection of improvements (va->vd), with little extra inference time, and combined with appropriate training strategies, such as label smoothing and mixup data augmentation, can improve the accuracy by up to 2.7%. + +![](../../images/faq/ResNet_vabcd_structure.png) + +### Q1.4 How to choose appropriate ResNet models for the actual scenario? + +**A**: + +Among the ResNet series model, the ResNet_vd model is recommended for it has a significant improvement in accuracy with almost constant inference speed compared to other models. When the batch size=4, the variation of inference time, FLOPs, Params and accuracy for different models on T4 GPU are demonstrated in the [ResNet and its vd series models](../models/ResNet_and_vd_en.md). If you want the smallest possible model storage or the fastest inference speed, please use ResNet18_vd model, and if you want to get the highest possible accuracy, we recommend the ResNet152_vd or ResNet200_vd models. For more information about the ResNet series model, please refer to [ResNet and its vd series models](../models/ResNet_and_vd_en.md) + +- Variation of precision-inference speed + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.png) + +- Variation of precision-params + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png) + +- Variation of precision-flops + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png) + +### Q1.5 Is conv-bn-relu a fixed form in a block of the network? + +**A**: + +Before the advent of batch-norm, the mainstream convolutional neural networks were fixed in the form of conv-relu. At the moment, conv-bn-relu is the fixed form of blocks in most of the convolutional networks, which is a relatively robust design. Besides, the block in DenseNet is adopted in the form of bn-relu-conv, which is the same combination used in ResNet-V2. In MobileNetV2, the middle layer of some blocks adopts conv-bn instead of the relu activation function to avoid information loss. + +### Q1.6 What's the difference between ResNet34 and ResNet50? + +**A**: + +There are two different kinds of blocks in the ResNet series, basic-block and bottleneck-block, and the ResNet network is constructed by the stacking of such blocks. basic-block is a stack of two 3x3 convolutional kernels with shortcut, while bottleneck-block is a stack of a 1x1 convolutional kernel, 3x3 convolutional kernel, and 1x1 convolutional kernel with shortcut, so there are two layers in the former one and three in the latter. The number of blocks stacked in ResNet34 and ResNet50 is the same, but the types of stacking are basic-block and bottleneck-block, respectively. + +### Q1.7 Do large convolution kernels necessarily lead to positive returns? + +**A**: + +Not really, increasing all the convolutional kernels in the network may not lead to performance improvement or even the opposite. In the paper [MixConv: Mixed Depthwise Convolutional Kernels](https://arxiv.org/abs/1907.09595), it is pointed out that increasing the size of the convolutional kernels within a certain range plays a positive role in the accuracy improvement, but a size beyond may lead to accuracy loss. Therefore, considering the size of the model and the computation, large convolutional kernels are generally abandoned to design the network. Also, there are experiments on large convolution kernels in the article [PP-LCNet](../models/PP-LCNet_en.md). + + + +## Issue 2 + +### Q2.1: How does PaddleClas train its backbone? + +**A**:The process is as follows: + +- First, create a new model structure file under the folder `ppcls/arch/backbone/model_zoo/`, i.e. your own backbone. You can refer to resnet.py for model construction; +- Then add your own backbone class in `ppcls/arch/backbone/__init__.py`; +- Next, configure the yaml file for training, here you can refer to `ppcls/configs/ImageNet/ResNet/ResNet50.yaml`; +- Now you can start the training. + +### Q2.2: How to transfer the existing models and weights to your own classification tasks? + +**A**: The process is as follows: + +- First, a good pre-training model tends to be better transferred, so it is recommended to adopt a pre-training model with higher accuracy, for instance, series of industry-leading pre-training models provided by PaddleClas; +- Second, determine and train hyperparameters based on the size of the dataset to be transferred, which need to be debugged to find a local optimal value. If you have no relevant experience, it is recommended to start with the learning rate, which generally has a smaller dataset adopting a small learning rate, such as 0.001. In addition, the warmup strategy is suggested for the learning rate to avoid the weight damage of the pre-training model resulting from a large learning rate. During the transfer, the learning rate of different layers in the backbone can also be set, and it is often better to gradually reduce the learning rate from the head to the tail of the network. Data augmentation strategies can also be useful for small datasets, and PaddleClas offers 8 powerful data augmentation strategies for higher accuracy. +- After training, the above process can be iterated repeatedly until a local optimal value is found. + +### Q2.3: Is the default parameter under configs in PaddleClas available for all datasets? + +**A**: + +The default parameter of the configuration file under `ppcls/configs/ImageNet/` in PaddleClas is the training parameter of ImageNet-1k, which is not suitable for all datasets, and the specific datasets need to be further debugged on this basis. + +### Q2.4 The resolution varies for different models in PaddleClas, so what is the standard? + +**A**: + +PaddleClas strictly follows the resolution used by the authors of the paper. Since AlexNet in 2012, most of the convolutional neural networks trained on ImageNet have a resolution of 224x224, and Google adjusted the resolution to 299x299 when designing InceptionV3 to fit the network structure, which was the same one for later Xception and InceptionV4. In addition, in EfficeintNet, the authors analyze that different resolutions should be used for networks of different sizes, so does it in this series. In practical scenarios, it is recommended to adopt the default resolution, but networks with deeper layers or larger widths can also try larger ones. + +### Q2.5 There are many ssld models available in PaddleClas, what is the value of their application? + +**A**: + +There are many ssld pre-training models available in PaddleClas, which obtain better pre-training weights by semi-supervised knowledge distillation, so that the accuracy can be improved by replacing the ssld pre-training models with higher accuracy in transfer tasks or downstream vision tasks without replacing the structure files. For example, in PaddleSeg, [HRNet](../models/HRNet_en.md) , with the weight of the ssld pre-training model, achieves much better accuracy than other same models in the industry; In PaddleDetection, [PP- YOLO](https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/configs/ppyolo/README_cn.md)with ssld pre-training weights has further improvement in the already high baseline. The transfer of classification with ssld pre-training weights also yields impressive results, and the benefits of knowledge distillation for the transfer of classification task is detailed in [SSLD Distillation Strategy](../advanced_tutorials/knowledge_distillation_en.md) + + + +## Issue 3 + +### Q3.1: What is the improvement of DenseNet model over ResNet? What are the features or application scenarios? + +**A**: + +DenseNet is designed with a more aggressive dense connectivity mechanism compared to ResNet, which further reduces the number of parameters by considering feature reuse and bypass settings, and mitigates the gradient dispersion problem to some extent. What's more, the model is easier to train and equipped with some regularization effect due to the introduction of dense connectivity. DenseNet is a good choice in image classification scenarios where the amount of data is limited. More information about DenseNet and this series can be found in [DenseNet Models](../models/DPN_DenseNet_en.md). + +### Q3.2: What are the improvements of the DPN network over DenseNet? + +**A**: + +The full name of DPN is Dual Path Networks, or Dual Channel Networks. It is a combination of DenseNet and ResNeXt, which demonstrates that DenseNet can extract new features from the previous layers, while ResNeXt is essentially reuse of features already extracted from the previous layers. The authors further analyze and find that ResNeXt has a high reuse rate for features but low redundancy, while DenseNet can create new features but has high redundancy. Combining the advantages of both structures, the DPN network is designed. Finally, the DPN network achieves better results than ResNeXt and DenseNet with the same FLOPS and number of parameters. More introduction and series models of DPN can be found in [DPN Models](../models/DPN_DenseNet_en.md). + +### Q3.3: How to use multiple models for inference fusion? + +**A**: + +When adopting multiple models for inference, it is recommended to first export the pre-training model as an inference model to get rid of the dependence on the network structure definition, you can refer to [model export script](../../../tools/export_model.py) for model exporting, and then see [inference script for the inference model](../../../deploy/python/predict_cls.py), where you need to create multiple predictors according to the number of employed models. + +### Q3.4: How to add your own data augmentation methods in PaddleClas? + +**A**: + +- For single-image augmentation, you can refer to [Single-image based data augmentation script](../../../ppcls/data/preprocess/ops). Learning from the data operator ` ResizeImage ` or `CropImage` to create a new class, and then implement the corresponding augmentation method in `__call__`. +- For a batch image, you can refer to the [batch data-based data augmentation script](../../../ppcls/data/preprocess/batch_ops). Learning from the data operator `MixupOperator` or `CutmixOperator` to create a new class, and then implement the corresponding augmentation method in `__call__`. + +## Q3.5: How to further accelerate the model training? + +**A**: + +- You can adopt auto-mixed precision training, which can gain a significantly faster speed with almost zero precision loss. Take ResNet50 as an example, the configuration file of auto-mixed precision training in PaddleClas can be found at: [ResNet50_fp16.yml](../../../ppcls/configs/ImageNet/ResNet/ResNet50_fp16.yaml). The main step is to add the following lines to the standard configuration file. + +``` +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + use_pure_fp16: &use_pure_fp16 True +``` + +- You can turn on dali to run the data preprocessing method on GPU. When the model is relatively small (reader accounts for a higher percentage of time consumption), an obviously faster speed can be obtained with dali on, which could be employed by adding `-o Global.use_dali=True` during training. You can refer to [dali installation tutorial](https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html#nightly-builds) for more details. + + + +## Issue 4 + +### Q4.1: How many types of model files are there in PaddlePaddle? + +**A**: + +- There are two types of model-related files saved in PaddlePaddle. +- One is the files used for *inference deployment*, including files with the suffixes ``pdiparams``, ``model``, where the ``pdiparams` " file stores model parameter information, and "`model`" file stores model network structure information. For inference deployment files, the `paddle.jit.save` and `paddle.jit.load` interfaces are used for saving and loading. +- Another one is used in the *training tuning* process, including files with the suffixes "`pdparams`" and "`pdopt`", where the "`pdparams` " file stores the model parameters information during training, and "`pdopt`" file stores the optimizer information during model training. For training tuning files, `paddle.save` and `paddle.load` interfaces are used for saving and loading. +- The inference deployment file enables you to build the model network structure and load the model parameters for inference, while the training tuning file allows you to load the model parameters and optimizer information for resuming the training process. + +### Q4.2: What are the innovations of HRNet? + +**A**: + +- In the field of image classification, most neural networks are designed with the idea of extracting high-dimensional features of images. Specifically, the input image usually has a high spatial resolution, and through multi-layer convolution and pooling, a feature graph with lower spatial resolution but higher dimension can be gradually obtained and applied in scenarios such as classification. +- However, the authors of *HRNet* believe that the idea of gradually decreasing spatial resolution is not suitable for scenarios such as target detection (classification task of image region-level) and semantic segmentation (classification task of image pixel-level), because a lot of information is lost in this process and the final learned features can hardly represent the information of the original image at the high spatial resolution, while both the task of region-level and pixel-level classification are very sensitive to spatial accuracy. +- Therefore, the authors of *HRNet* propose the idea of paralleling feature graphs with different spatial resolutions, while in contrast, neural networks such as *VGG* cascade feature graphs with different spatial resolutions by different convolutional pooling layers. Moreover, *HRNet* connects feature graphs of equal depth and disparate spatial resolutions, so that the information can be fully exchanged. The specific network structure is shown in the figure below. + +![](../../images/faq/HRNet.png) + +### Q4.3: In HRNet, how are connections made between feature graphs with different spatial resolutions? + +**A**: + +- First, in *HRNet*, the *3 × 3* convolution with *stride* of *2* can be used to obtain a feature graph with low spatial resolution but higher dimension; and for those with low spatial resolution, the *1 × 1* convolution is first used to match the number of channels, and then the nearest neighbor interpolation is used for upsampling to obtain a feature graph with the same spatial resolution and number of channels as the high spatial resolution graph. And for the feature map with the same spatial resolution, the constant mapping can be performed directly. The details are shown in the following figure. + +![](../../images/faq/HRNet_block.png) + +### Q4.4: What does "SE" in the model stand for? + +**A**: + +- SE indicates that the model uses an SE structure, which is derived from the winning solution of the 2017 ImageNet classification competition *Squeeze-and-Excitation Networks (SENet)*, and can be migrated to any other networks. The *scale* vector dimension is the same as the number of channels in the feature map, and the value in each dimension of the learned *scale* vector indicates the enhancement or weakening of the feature channels in that dimension, so as to enhance the important feature channel and weaken the unimportant ones, thus making the extracted features more directional. + +### Q4.5: How does the SE structure implemented? + +![](../../images/faq/SE_structure.png) + +**A**: + +- The *SE* structure is shown in the figure above. First, *Ftr* represents the regular convolution operation, and *X* and *U* are the input and output feature maps of *Ftr*. After obtaining the feature map *U*, operate the *Fsq* and *Fex* to obtain the *scale* vector, which has a dimension of *C*, the same as the number of *U* channels, so it can be applied to *U* by multiplying, and then obtain *X~*. +- Specifically, *Fsq* is the *Global Average Pooling* operation, which is called *Squeeze* by *SENet* authors because it compresses *U* from *C × H × W* to *C × 1 × 1*, and then conduct the *Fex* operation on the output of *Fsq*. +- The *Fex* operation represents two full joins, which is referred to as *Excitation* by the authors. The first full join compresses the dimension of the vector from *1 × 1 × C* to *1 × 1 × C/r*, followed by the use of *RELU*, and then restores the dimension of the vector to *C* by the second full join. The purpose of this operation is to reduce the computation. The *SENet* authors conclude experimentally that a balance between gain and computational effort could be obtained when *r=16*. +- For *Fsq*, the key is to obtain the vector of *C* dimension, so it is not limited to the *Global Average Pooling*. The *SENet* authors believe that the final *scale* is applied to *U* separately by channel, so it is necessary to calculate the corresponding *scale* based on the information of the corresponding channel, so the simplest *Global Average Pooling* is adopted, and the final *scale* vector represents the distribution between different channels, ignoring the situation in the same channel. +- For *Fex*, its role is to find the distribution based on all the training data through training on each *mini batch*. Since our training is performed on *mini batches* and the *scale* based on all training data is the best, we can adopt the *Fex* to train on each *mini batch* to obtain a more reliable *scale*. + + + +## Issue 5 + +### Q5.1 How to choose an optimizer? + +**A**: + +Since the emergence of deep learning, there has been a lot of research on optimizers, which aim to minimize the loss function to find the right weights for a given task. Currently, the main optimizers used in the industry are SGD, RMSProp, Adam, AdaDelt, etc. Among them, since the SGD optimizer with momentum is widely used in academia and industry (only for classification tasks), most of the models we published also adopt this optimizer to achieve gradient descent of the loss function. It has two disadvantages, one is the slow convergence speed, and the other is the reliance on experiences of the initial learning rate setting. However, if the initial learning rate is set properly with the sufficient number of iterations, the optimizer will also stand out among many other optimizers, obtaining higher accuracy on the validation set. Some optimizers with adaptive learning rates, such as Adam and RMSProp, tend to converge fast, but the final convergence accuracy will be slightly worse. If you pursue faster convergence speed, we recommend using these adaptive learning rate optimizers, and SGD optimizers with momentum for higher convergence accuracy. The specific information of the dataset is as follows: + +- ImageNet-1k: It is recommended to use the SGD optimizer with momentum only. +- Other datasets (ImageNet-1k pre-training by default): When loading the pre-training model, you can consider an optimizer such as Adam (which may work better), but the SGD optimizer with momentum is definitely a good solution. + +In addition, to further speed up the training, Lookahead optimizer is also a good choice. On ImageNet-1k, it can guarantee the same convergence accuracy at a faster rate, but the performance is less stable on some datasets and requires further tuning. + +### Q5.2 How to set the initial learning rate and the learning rate decay strategy? + +**A**: The choice of learning rate is often related to the optimizer as well as the data and the task. The learning rate determines how quickly the network weights are updated. The lower the learning rate, the slower the loss function will change. While using a low learning rate ensures that no local minimal values are missed, it also means that it takes longer to converge, especially if trapped in a plateau region. + +Throughout the whole training process, we cannot adopt the same learning rate to update the weights, otherwise, the optimal point cannot be reached, So we need to adjust the learning rate during the training. In the initial stage of training, since the weights are in a random initialization state and the loss function decreases fast, a larger learning rate can be set. And in the later stage of training, since the weights are close to the optimal value, a larger learning rate cannot further find the optimal value, so a smaller learning rate needs is a better choice. As for the learning rate decay strategy, many researchers or practitioners use piecewise_decay (step_decay), which is a stepwise decay learning rate. In addition, there are also other methods proposed by researchers, such as polynomial_decay, exponential_ decay, cosine_decay, etc. Among them, cosine_decay requires no adjustment of hyperparameters and has higher robustness, thus emerging as the preferred learning rate decay method to improve model accuracy. + +The learning rates of cosine_decay and piecewise_decay are shown in the following figure. It is easy to observe that cosine_decay keeps a large learning rate throughout the training, so it is slow in convergence, but its final effect is better than peicewise_decay. + +![](../../images/models/lr_decay.jpeg) + +In addition, it is also observed that only a few rounds in cosine_decay use a small learning rate, which affects the final accuracy. So it is recommended to iterate more rounds for better results. + +Finally, when training a neural network with a large batch_size, it is recommended to use the warmup strategy, which, as the name implies, is a warm-up for the learning rate with no direct adoption of maximum learning rate at the beginning of training, but to train the network with a gradually increasing rate, and then decay the learning rate when it peaks. Experiments show that warmup can steadily improve the accuracy of the model when the batch_size is large. Specifically for the dataset. The specific information of the dataset is as follows: + +- ImageNet-1k: The recommended batch-size is 256, the initial learning rate is 0.1, and the cosine-decay to decrease the learning rate. +- Other datasets (ImageNet-1k pre-training by default): the larger the dataset, the larger the initial learning rate, not exceeding 0.1 for the best (when the batch-size is 256); the smaller the dataset, the smaller the initial learning rate, when the dataset is small, the use of warmup will also bring some accuracy improvement, and cosine-decay is still recommended as the learning rate decay strategy. + +### Q5.3 How to set the batch-size? + +**A**: + +Batch_size is an important hyperparameter in neural networks training, whose value determines how much data is fed into the neural network for training at a time. Previous researchers have experimentally found that when the value of batch_size is linearly related to the value of learning rate, the convergence accuracy is almost unaffected. When training ImageNet-1k data, most of the neural networks choose an initial learning rate of 0.1 and a batch_size of 256. The specific information of the dataset is as follows: + +- ImageNet-1k: learning rate is set to 0.1*k, batch_size is set to 256*k. +- Other datasets (ImageNet-1k pre-training by default): can be set according to the actual situation (e.g. smaller learning rate), but when adjusting the learning rate or batch size, another value should be adjusted at the same time. + +### Q5.4 What is weight_decay? How to set it? + +**A**: + +Overfitting is a common term in machine learning, which is simply understood as a model that performs well on training data but less satisfactory on test data. In image classification, there is also the problem of overfitting, and many regularization methods are proposed to avoid it, among which weight_decay is one of the widely used ways. When using SGD optimizer, weight_decay is equivalent to adding L2 regularization after the final loss function, which makes the weights of the network tend to choose smaller values, so eventually, the parameter values in the whole network tend to be more towards 0, and the generalization performance of the model is improved accordingly. In the implementation of major deep learning frameworks, this value means the coefficient before the L2 regularization, which is called L2Decay in the PaddlePaddle framework. The larger the coefficient is, the stronger the added regularization is, and the more the model tends to be underfitted. The specific information of the dataset is as follows: + +- ImageNet-1k: Most networks set the value of this parameter to 1e-4, and in some smaller networks such as the MobileNet series network, the value is set between 1e-5 and 4e-5 to avoid the underfitting. The following table shows the accuracy of MobileNetV1_x0_25 on ImageNet-1k using different L2Decay. Since MobileNetV1_x0_25 is a relatively small network, an overly large L2Decay will tend to underfit the network, so 3e-5 is a better choice in this network compared to 1e-4. + +| Model | L2Decay | Train acc1/acc5 | Test acc1/acc5 | +| ----------------- | ------- | --------------- | -------------- | +| MobileNetV1_x0_25 | 1e-4 | 43.79%/67.61% | 50.41%/74.70% | +| MobileNetV1_x0_25 | 3e-5 | 47.38%/70.83% | 51.45%/75.45% | + +In addition, the setting of this value is also related to whether other regularizations are used during training. If the data preprocessing is complicated, which equates with a harder training task, the value can be reduced appropriately. The following table shows the accuracy of ResNet50 on ImageNet-1k using different L2Decay after the RandAugment preprocessing. It is easy to observe that a smaller l2_decay helps to improve the model accuracy for a harder task. + +| Model | L2Decay | Train acc1/acc5 | Test acc1/acc5 | +| -------- | ------- | --------------- | -------------- | +| ResNet50 | 1e-4 | 75.13%/90.42% | 77.65%/93.79% | +| ResNet50 | 7e-5 | 75.56%/90.55% | 78.04%/93.74% | + +- Other datasets (ImageNet-1k pre-training loaded by default): When transferring, it is better not to change the value of L2Decay when training ImageNet-1k (i.e. training to get the L2Decay value of pre-training, the L2Decay value of each backbone is in the corresponding yaml file), and the change of learning rate is enough for general datasets. + +### Q5.5 Should I use label_smoothing and how to set the value of the parameter? + +**A**: + +Label_smoothing is a regularization method in deep learning, whose full name is Label Smoothing Regularization (LSR). In the traditional classification task, the loss function is calculated by the cross-entropy of the real one hot label and the output of the neural network, while label_smoothing is a label smoothing of the real one hot label, so that the label learned by the network is no longer a hard label, but a soft label with a probability value, where the probability at the position corresponding to the category is the largest and others small. In label_smoothing, the epsilon parameter describes the degree of label softening, the larger the value, the smaller the label probability value of the label vector after label smoothing, the smoother the label, and vice versa. The specific information of the dataset is as follows: + +- ImageNet-1k: This value is usually set to 0.1 in experiments training ImageNet-1k, and there is a steady increase in accuracy for models of the ResNet50 size and above after using label_smooting. The following table shows the accuracy metrics of ResNet50_vd before and after using label_smoothing. + +| Model | Use_label_smoothing(0.1) | Test acc1 | +| ----------- | ------------------------ | --------- | +| ResNet50_vd | 0 | 77.9% | +| ResNet50_vd | 1 | 78.4% | + +At the same time, since label_smoohing can be regarded as a regularization method, the accuracy improvement is not obvious or even decreases on a relatively small model. The following table shows the accuracy metrics of ResNet18 before and after using label_smoothing on ImageNet-1k. It is clear that the accuracy drops after using label_smoothing. + +| Model | Use_label_smoohing(0.1) | Train acc1/acc5 | Test acc1/acc5 | +| -------- | ----------------------- | --------------- | -------------- | +| ResNet18 | 0 | 69.81%/87.70% | 70.98%/89.92% | +| ResNet18 | 1 | 68.00%/86.56% | 70.81%/89.89% | + +Here is a trick to make label-smoothing effective even in smaller models, i.e., a fully connected layer of size 1000-2000 after the Global-Average-Pool, which works better with label-smoothing. + +- Other datasets (loaded with ImageNet-1k pre-training by default): the use of label-smooth tends to improve the accuracy, the smaller the dataset the larger the epsilon value can be. And in some smaller fine-grained images, the best model is usually obtained with the value set to 0.4-0.5. + +### Q5.6 Is random-crop still adjustable in the default image preprocessing? How ? + +**A**: + +In the standard preprocessing of ImageNet-1k data, the random_crop function defines two values, scale and ratio, which respectively determine the size of the image crop and the degree of image stretching, where the default value of the former is 0.08-1 (lower_scale-upper_scale), and the latter is 3/4-4/3 (lower_ratio-upper_ratio). In very small networks, this kind of data augmentation can lead to network underfitting and decreased accuracy. To the end, the data augmentation can be made weaker by increasing the crop area of the image or decreasing the stretching of the image. Weaker image transformation can be achieved by increasing the value of lower_scale or reducing the difference between lower_ratio and upper_scale, respectively. The specific information of the dataset is as follows: + +- ImageNet-1k: It is recommended to use only the default value for networks that are not particularly small, and to increase the value of lower_scale (to increase the crop area) or decrease the range of ratio values (to weaken the image stretching) for networks that are particularly small, and conduct the opposite for networks that are particularly large. The following table shows the accuracy of training MobileNetV2_x0_25 with different lower_scale, and we can see that the training accuracy and verification accuracy are improved by increasing the crop area of the images. + +| Model | Range of Scale | Train_acc1/acc5 | Test_acc1/acc5 | +| ----------------- | -------------- | --------------- | -------------- | +| MobileNetV2_x0_25 | [0.08,1] | 50.36%/72.98% | 52.35%/75.65% | +| MobileNetV2_x0_25 | [0.2,1] | 54.39%/77.08% | 53.18%/76.14% | + +- Other datasets (ImageNet-1k pre-training is loaded by default): it is recommended to use the default value, if the overfitting is too over, please consider adjusting the value of lower_scale (to reduce the crop area) or increasing the range of ratio values (to enhance the image stretching). + +### Q5.7 What are the common data augmentation? How to choose? + +**A**: + +In general, the size of the dataset is crucial to the performance, but the annotation of images is often expensive, hence there are rare annotated images, which highlight the importance of data augmentation. In the standard data augmentation for training ImageNet-1k, two methods, Random_Crop and Random_Flip, are mainly adopted. However, in recent years, an increasing number of data augmentation methods have been proposed, such as cutout, mixup, cutmix, AutoAugment, etc. Experiments show that these methods can effectively improve the accuracy of the model. The specific information of the dataset is as follows: + +- ImageNet-1k: The following table lists the performance of ResNet50 adopting 8 different data augmentation methods. It can be seen that all of them are beneficial compared to baseline, with cutmix being the most effective data augmentation so far. For more information about data augmentation, please refer to the chapter of [**Data Augmentation**](../advanced_tutorials/DataAugmentation_en.md). + +| Model | Date Augmentation Method | Test top-1 | +| -------- | ------------------------ | ---------- | +| ResNet50 | Standard Transformation | 77.31% | +| ResNet50 | Auto-Augment | 77.95% | +| ResNet50 | Mixup | 78.28% | +| ResNet50 | Cutmix | 78.39% | +| ResNet50 | Cutout | 78.01% | +| ResNet50 | Gridmask | 77.85% | +| ResNet50 | Random-Augment | 77.70% | +| ResNet50 | Random-Erasing | 77.91% | +| ResNet50 | Hide-and-Seek | 77.43% | + +- Other datasets (ImageNet-1k pre-training is loaded by default): In other datasets except those using Auto-Augment, there is generally an accuracy gain. Auto-Augment will search for each dataset with an independent hyper-parameter which determines how the data is processed, so the default ImageNet-1k hyper-parameter is not suitable for all datasets, but you can use Random-Augmentation instead of Auto-Augmentation. Other strategies can be used normally, but for harder tasks or smaller networks, it is not recommended to adopt strong data augmentation. + +In addition, multiple data augmentations can be overlaid to further improve accuracy when the data set is simple or the data size is small. + +### Q5.8 How to determine the tuning strategy by train_acc and test_acc? + +**A**: + +In the process of training a network, the accuracy of the training set and validation set are usually printed for each epoch, which portrays the performance of the model on both datasets. Generally speaking, the training set accuracy reflects the data accuracy after Random-Crop, and since the data is often more complex after Random-Crop, the training set accuracy and the validation set accuracy are often not the same concepts. + +- ImageNet-1k: Generally speaking, it is good to have a comparable accuracy or a slightly higher accuracy in the training set than in the validation set. If we find that the accuracy of the training set is much higher than the validation set, it means that the training set is overfitted and we need to add more regularity, such as increasing the value of L2Decay, adding more data augmentation strategies, introducing label_smoothing strategies, etc. If we find that the accuracy of the training set is lower than the validation set, it means that the training set is probably underfitted, and the regularization effect should be weakened during the training, such as reducing the value of L2Decay, decreasing the data augmentation methods, increasing the area of the crop area, weakening the image stretching, removing label_smoothing, etc. +- Other datasets (ImageNet-1k pretraining loaded by default): basically the same as ImageNet-1k training, in addition, if the model on other datasets tends to overfit (train acc much larger than test acc), you can also use better pretraining weights. PaddleClas provides distillation pretraining weights of SSLD for common networks, which are better than those of ImageNet-1k, expecting your preference. +- **[Note]** It is not recommended to readjust the training strategy according to the loss. After using different data augmentation, the size of the train loss varies greatly. For example, after using Cutmix or RandAugmentation, the train loss will exceed the test loss, and when the data augmentation strategy is weakened, the train loss will be smaller than the test loss, making it more difficult to adjust. + +### Q5.9 How to improve the accuracy of your own dataset by pre-training the model? + +**A**: + +At this stage, it has become a common practice in the image recognition field to load pre-trained models to train their own tasks, which can often improve the accuracy of a particular task compared to training from random initialization. In general, the pre-training model widely used in the industry is obtained by training the ImageNet-1k dataset of 1.28 million images of 1000 classes. The fc layer weights of this pre-training model are a matrix of k*1000, where k is the number of neurons before the fc layer, and it is not necessary to load the fc layer weights when loading the pre-training weights. In terms of the learning rate, if your dataset is particularly small (e.g., less than 1,000), we recommend you to adopt a small initial learning rate, e.g., 0.001 (batch_size:256, the same below), so as not to corrupt the pre-training weights with a larger learning rate. If your training dataset is relatively large (>100,000), we suggest you try a larger initial learning rate, such as 0.01 or above. If the target dataset is small, you can also freeze some shallow weights. Also, if you want to train a small dataset for a specific vertical class, you can train a pre-training weight on a related large dataset first, and then fine-tune the model with a smaller learning rate on that weight. + +### Q5.10 Existing strategies have saturated the accuracy of the model, how can the accuracy of a particular model be further improved? + +**A**: If the existing strategy cannot further improve the accuracy of the model, it means that the model has almost reached saturation with the existing dataset and strategy, and two methods are provided here. + +- Mining relevant data: Use the model trained on the existing dataset to make predictions on the relevant data, label the data with higher confidence and add it to the training set for further training. Repeat the steps above to further improve the accuracy of the model. +- Knowledge distillation: You can use a larger model to train a teacher model with higher accuracy on the dataset, and then adopt the teacher model to teach a Student model, where the Student model is the target model. PaddleClas provides Baidu's own SSLD knowledge distillation scheme, which can steadily improve by more than 3% even on such a challenging classification task as ImageNet-1k. For the chapter on SSLD knowledge distillation, please refer to [**SSLD Knowledge Distillation**](../advanced_tutorials/knowledge_distillation_en.md). + + + +## Issue 6 + +### Q6.1: What are the differences between the several branches of PaddleClas? How should I choose? + +**A**: PaddleClas currently has 3 branches: + +- Develop: develop branch is the development branch of PaddleClas as well as the most updated branch. All new features and changes will proceed on this branch first. If you want to keep track of the latest progress of PaddleClas, you can follow this branch. This branch mainly supports dynamic graphs and will be updated along with the version of paddlepaddle. +- Stable release (e.g. release/2.1.3): Fast updates keep followers informed of the latest progress, but they can also bring instability. Therefore, at critical points, we pull branches from the develop branch to provide stable releases, and the latest stable branch is also the default branch. Note that we only maintain the latest stable release, and generally fix bugs only without updating new features and models unless there are special circumstances. +- Static branch is a branch mainly for old users that adopts the static version of the graph, receiving simple maintenance only with no new features and models updated. It is not recommended for new users, and those who still employ it is recommended to turn to the dynamic graph branch or the stable release branch if the condition permits. + +In general, it is recommended to choose the develop branch if you want to keep up with the latest developments of PaddleClas, and the latest stable release branch if you need a stable version. + +### Q6.2: What is the static graph mode? + +**A**: + +The static graph mode is declarative programming, which is initially adopted by many deep learning frameworks such as tensorflow, mxnet, etc. In the static graph mode, you need to define the model structure first, and then the framework will compile and optimize the model structure to build the "computational graph". It can be simply understood that the mode is a static and unchanging pattern of the "computational graph". The advantage of it is that the compiler generally builds the graph once, which is relatively efficient, but the disadvantage lies in that it is not flexible enough and troublesome to debug. For example, if you run a static graph model in paddle, you need to complete all the operations, then extract the output according to a specific key, which means you cannot get the result in real-time. + +### Q6.3: What is the dynamic graph mode? + +**A**: + +Dynamic diagram mode is imperative programming, where users do not need to pre-define the network structure, and each line of code can be run directly to get the result. Compared with static graph mode, this one is more user-friendly and easier to debug. In addition, the structure design of dynamic graph mode is more flexible, and the structure can be adjusted at any time during the operation. + +PaddleClas currently uses a dynamic graph model for its continuously updated develop branch and the stable release branch. If you are new, it is recommended to use dynamic graph mode for development and training. If there is a performance requirement for inference and prediction, you can convert the dynamic graph model to a static one to improve efficiency after the training. + +### Q6.5: When building a classification dataset, how to build the data of the "background" category? + +**A**: + +In practice, it is often necessary to construct your own classification dataset for training purposes. In addition to the required category data, an additional category is needed, i.e., a "background" category. For example, if we create a cat and dog classification, with cats as one category and dogs as another, then an input image of a rabbit will be forced into one of these two categories. Therefore, during training, we should add some data from non-target categories as the "background" category data. + +When constructing the data for the "background" category, the first step is to consider the actual requirements. For example, if the actual test data are all animals, the "background" category data should include some animals other than dogs and cats. If the test data contains more categories, such as a tree, then the "background" category should be enriched. To put it simply, the data in the "background" category should be collected according to the situations that may occur in the actual scenario. The more situations included, the more types of data need to be covered, and the more difficult the task will be. Therefore, in practice, it is better to limit the problem to avoid the waste of resources and computing power. diff --git a/src/PaddleClas/docs/en/faq_series/faq_2021_s1_en.md b/src/PaddleClas/docs/en/faq_series/faq_2021_s1_en.md new file mode 100644 index 0000000..c730f25 --- /dev/null +++ b/src/PaddleClas/docs/en/faq_series/faq_2021_s1_en.md @@ -0,0 +1,267 @@ +# Image Classification FAQ Summary - 2021 Season 1 + +## Catalogue + +- [1. Issue 1](#1)(2021.01.05) +- [2. Issue 2](#2)(2021.01.14) +- [3. Issue 3](#3)(2020.01.21) +- [4. Issue 4](#4)(2021.01.28) +- [5. Issue 5](#5)(2021.02.03) + + + +## Issue 1 + +### Q1.1: Why is the prediction accuracy of the exported inference model very low ? + +**A**:You can check the following aspects: + +- Check whether the path of the pre-training model is correct or not. +- The default class number is 1000 when exporting the model. If the pre-training model has a custom class number, you need to specify the parameter `--class_num=k` when exporting, k is the custom class number. +- Compare the output class id and score of `tools/infer/infer.py` and `tools/infer/predict.py` for the same input. If they are exactly the same, the pre-trained model may have poor accuracy itself. + +### Q1.2: How to deal with the unbalanced categories of training samples? + +**A**:There are several commonly used methods. + +- From the perspective of sampling + - The samples can be sampled dynamically according to the categories, with different sampling probabilities for each category and ensure that the number of training samples in different categories is basically the same or in the desired proportion in the same minibatch or epoch. + - You can use the oversampling method to oversample the categories with a small number of images. +- From the perspective of loss function + - The OHEM (online hard example miniing) method can be used to filter the hard example based on the loss of the samples for gradient backpropagation and parameter update of the model. + - The Focal loss method can be used to assign a smaller weight to the loss of some easy samples and a larger weight to the loss of hard samples, so that the loss of easy samples contributes to the overall loss of the network without dominating the loss. + +### Q1.3 When training in docker, the data path and configuration are fine, but it keeps reporting `SystemError: (Fatal) Blocking queue is killed because the data reader raises an exception`, why is this? + +**A**: + +This may be caused by the small shared memory in docker. When creating docker, the default size of `/dev/shm` is 64M, if you use multiple processes to read data, the shared memory may fall short, so you need to allocate more space to `/dev/shm`. When creating a docker, input `--shm-size=8g` to allocate 8G to `/dev/shm`, which is usually enough. + +### Q1.4 Where can I download the 10W class image classification pre-training model provided by PaddleClas and how to use it? + +**A**: + +Based on ResNet50_vd, Baidu open-sourced its own large-scale classification pre-training model with 100,000 categories and 43 million images. The former is available for download at [download address](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_10w_pretrained.tar), where it should be noted that the pre-training model does not provide the final FC layer parameters and thus cannot be used directly for inference; however, it can be used as a pre-training model to fine-tune it on your own dataset. It is verified that this pre-training model has a more significant accuracy gain of up to 30% on different datasets than the ResNet50_vd pre-training model based on the ImageNet1k dataset. + +### Q1.5 How to accelerate when using C++ for inference deployment? + +**A**:You can speed up the inference in the following ways. + +1. For CPU inference, you can turn on mkldnn and increase the number of threads (cpu_math_library_num_threads, in `tools/config.txt`), which is usually 6~10. +2. For GPU inference, you can enable TensorRT inference and FP16 inference if the hardware condition allows, which can further speed up the speed. +3. If the memory or video memory is sufficient, the batch size of inference can be increased. +4. The image preprocessing logic (mainly designed for resize, crop, normalize, etc.) can be run on the GPU, which can further speed up the process. + +You are welcomed to add more tips on inference deployment acceleration. + + + +## Issue 2 + +### Q2.1: Does PaddleClas have to start from 0 when setting labels, and does class_num have to equal the number of classes in the dataset? + +**A**: + +In PaddleClas, the label start from 0 by default, so try to set the label from 0. Of course, it is possible to set them from other values, which will result in a larger class_num and will in turn lead to a larger number of FC layer parameters for the classification, so the weight file will take up more storage space. In the case of a continuous set of classes, set class_num equal to the number of classes in the dataset (of course, it is acceptable to set it greater than the number of classes in the dataset, and even higher accuracy can be obtained in many datasets, but it will also result in a larger number of FC layers), and in the case of a discontinuous set of classes, the class_num should be equal to the largest class_id+1 in the dataset. + +### Q2.2: How to address the the problem of large space occupation of weight file resulted from great FC due to numerous class number? + +**A**: + +The final FC weight is a large matrix of size C*class_num, where C is the number of neural units in the previous layer of FC, e.g., C is 2048 in ResNet50, and the size of FC weight can be further reduced by decreasing the value of C. For example, a layer of FC with smaller dimension can be added after GAP, which can greatly reduce the weight size of the final classification layer. + +### Q2.3: Why did the training of ssld distillation on a custom dataset using PaddleClas fail to meet the expectation? + +First, it is necessary to ensure that the accuracy of the Teacher model. Second, it is necessary to ensure that the Student model is successfully loaded with the pre-training weights of ImageNet-1k and the Teacher model is successfully loaded with the weights of the training custom dataset. Finally, it is necessary to ensure that the initial learning rate is not too large, or at least smaller than the value of the ImageNet-1k training. + +### Q2.4: Which networks have advantages on mobile or embedded side? + +It is recommended to use the Mobile Series network, and the details can be found in [Introduction to Mobile Series Network Structure](../models/Mobile_en.md). If the speed of the task is the priority, MobileNetV3 series can be considered, and if the model size is more important, the specific structure can be determined based on the StorageSize - Accuracy in the Introduction to the Mobile Series Network Structure. + +### Q2.5: Why use a network with large number of parameters and computation such as ResNet when the mobile network is so fast? + +Different network structures have various speed advantages running on disparate devices. On the mobile side, mobile series networks run faster than server-side networks, but on the server side, networks with specific optimizations such as ResNet have greater advantages for the same accuracy. So the specific network structure needs to be decided on a case-by-case basis. + + + +## Issue 3 + +### Q3.1: What are the characteristics of a double (multi)-branch structure and a Plain structure, respectively? + +**A**: + +Plain networks, represented by VGG, have evolved into multi-branch network structures, represented by the ResNet series (with residual modules) and the Inception series (with multiple convolutional kernels in parallel). It is found that the multi-branch structure is more friendly in the model training, and the larger network width can bring stronger feature fitting ability, while the residual structure can avoid the problem of disappearing gradient of the deep network. However, in the inference phase, the model with a multi-branch structure has no speed advantage. Even though the FLOPs of the model are lower, the computational density of the multi-branch structure model is also dissatisfactory. For example, the FLOPs of VGG16 model are much larger than those of EfficientNetB3, but the inference speed of the latter is significantly faster than the former. Therefore, the multi-branch structure is more friendly in the model training, while the Plain structure model is more suitable for the inference. Starting from this, we can use a multi-branch network structure in the training phase to exchange a larger training time cost for a model with better feature fitting ability, and convert the multi-branch structure to Plain structure in the inference phase to exchange a shorter inference time. The conversion from multi-branch to a Plain structure can be achieved by the structural re-parameterization technique. + +In addition, the Plain structure is more friendly for pruning operations. + +Note: The term "Plain structure" and "structural re-parameterization" are from the paper "RepVGG: Making VGG-style ConvNets Great Again". Plain structure network model means that there is no branching structure in the whole network, i.e., the input of layer `i` is the output of layer `i-1` and the output of layer `i` is the input of layer `i+1`. + +### Q3.2: What are the main innovations of ACNet? + +**A**: ACNet means "Asymmetric Convolution Block", and the idea is from the paper "ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks", which proposes a set of three CNN convolutional kernels with "ACB" structure to replace the traditional square convolutional kernels in existing convolutional neural networks in the training phase. + +The size of the square convolution kernel is assumed to be `d*d`, i.e., the width and height are all `d`. The ACB structure used to replace this convolution kernel is three convolution kernels of size `d*d`, `1*d`, and `d*1`, and then the outputs of the three convolution kernels are added directly to obtain the same size as the original square convolution kernel. After the training, the ACB structure is replaced by the original square convolution kernel, and the parameters of which are directly added to the parameters of the three convolution kernels of the ACB structure (see `Q3.4`), so the same model structure as before is used for inference, and the ACB structure is only used in the training phase. + +During the training, the network width of the model is improved by the ACB structure, and more features are extracted using the two asymmetric convolution kernels of `1*d` and `d*1` to enrich the information of the feature maps extracted by the `d*d` convolution kernels. In the inference stage, this design idea does not bring additional parameters and computational overhead. The following figure shows the form of convolutional kernels for the training phase and the inference deployment phase, respectively. + +![](../../images/faq/TrainingtimeACNet.png) + +![](../../images/faq/DeployedACNet.png) + +Experiments by the authors of the article show that the model capability can be significantly improved by using ACNet structures in the training of the original network model, as explained by the original authors as follows. + +1. Experiments show that for a `d*d` convolution kernel, the parameters of the skeleton position (e.g., the `skeleton` position of the convolution kernel in the above figure) have a greater impact on the model accuracy than the parameters of the corner position (e.g., the `corners` position of the convolution kernel in the above figure) of the eliminated convolution kernel, so the parameters of the skeleton position of the convolution kernel are essential. And the two asymmetric convolution kernels in the ACB structure enhance the weight of the square convolution kernel skeleton position parameter, making it more significant. About whether this summation will weaken the role of the skeleton position parameter due to the offsetting effect of positive and negative numbers, the authors found through experiments that the training of the network always goes in the direction of increasing the role of the skeleton position parameter, and there is no weakening due to the offsetting effect. +2. The asymmetric convolution kernel is more robust for flipped images, as shown in the following figure, the horizontal asymmetric convolution kernel is more robust for flipped images up and down. The feature maps extracted by the asymmetric convolution kernel are the same for semantically the same position in the image before and after the flip, which is better than the square convolution kernel. + +![](../../images/faq/HorizontalKernel.png) + +### Q3.3: What are the main innovations of RepVGG? + +**A**: + +Through Q3.1 and Q3.2, it may occur to us to decouple the training phase and inference phase by ACNet, and use multi-branch structure in the training phase and Plain structure in inference phase, which is the innovation of RepVGG. The following figure shows the comparison of the network structures of ResNet and RepVGG in the training and inference phases. + +![](../../images/faq/RepVGG.png) + +First, the RepVGG in the training phase adopts a multi-branch structure, which can be regarded as a residual structure with `1*1` convolution and constant mapping on top of the traditional VGG network, while the RepVGG in the inference phase degenerates to a VGG structure. The transformation of the network structure from RepVGG in the training phase to RepVGG in the inference phase is implemented using the "structural reparameterization" technique. + +The constant mapping can be regarded as the output of the `1*1` convolution kernel with `1` parameters acting on the input feature map, so the convolution module of RepVGG in the training phase can be regarded as two `1*1` convolutions and one `3*3` convolution, and the parameters of the `1*1` convolution can be directly added to the parameters at the center of the `3*3` convolution kernel (this operation is similar to the operation of adding the parameters of the asymmetric convolution kernel to the parameters of the skeleton position of the square convolution kernel in ACNet). By doing this, the constant mapping, `1*1` convolution, and `3*3` convolution branches of the network structure can be combined into one `3*3` convolution in the inference stage, as described in `Q3.4`. + +### Q3.4: What are the similarities and differences between the struct re-parameters in ACNet and RepVGG? + +**A**: + +From the above, it can be simply understood that RepVGG is the extreme version of ACNet. Re-parameters operation in ACNet is shown in the following figure. + +![](../../images/faq/ACNetReParams.png) + +Take `conv2` as an example, the asymmetric convolution can be regarded as a square convolution kernel of `3*3`, except that the upper and lower six parameters of the square convolution kernel are `0`, and it is the same for `conv3`. On top of that, the sum of the results of `conv1`, `conv2`, and `conv3` is equivalent to the sum of three convolution kernels followed by convolution. With `Conv` denoting the convolution operation and `+` denoting the addition operation of the matrix, then: `Conv1(A)+Conv2(A)+Conv3(A) == Convk(A)`, where `Conv1`, ` Conv2`, `Conv3` have convolution kernels `Kernel1`, `kernel2`, `kernel3`, and `Convk` has convolution kernels `Kernel1 + kernel2 + kernel3`, respectively. + +The RepVGG network is the same as ACNet, except that the `1*d` asymmetric convolution of ACNet becomes the `1*1` convolution, and the position where the `1*1` convolutions are summed becomes the center of the `3*3` convolution. + +### Q3.5: What are the factors that affect the computation speed of a model? Does a model with a larger number of parameters necessarily have a slower computation speed? + +**A**: + +There are many factors that affect the computation speed of the model, and the number of parameters is only one of them. Specifically, without considering the hardware differences, the computation speed of the model can be referred to the following aspects. + +1. Number of parameters: the number of parameters used to measure the model, the larger the number of parameters of the model, the higher the memory (video memory) requirements of the model during computation. However, the size of the memory (video memory) footprint does not depend entirely on the number of parameters. In the figure below, assuming that the input feature map memory footprint size is `1` unit, for the residual structure on the left, the peak memory footprint during computation is twice as large as that of the Plain structure on the right, because the results of the two branches need to be recorded and then added together. + +![](../../images/faq/MemoryOccupation.png) + +2. FLOPs: Note that FLOPs are distinguished from floating point operations per second (FLOPS), which can be simply understood as the amount of computation and is usually adopted to measure the computational complexity of a model. Taking the common convolution operation as an example, considering no batch size, activation function, stride operation, and bias, assuming that the input future map size is `Min*Min` and the number of channels is `Cin`, the output future map size is `Mout*Mout` and the number of channels is `Cout`, and the conv kernel size is `K*K`, the FLOPs for a single convolution can be calculated as follows. + 1. The number of feature points contained in the output feature map is: `Cout * Mout * Mout`. + 1. For the convolution operation for each feature point in the output feature map: the number of multiplication calculations is: `Cin * K * K`; the number of addition calculations is: `Cin * K * K - 1`. + 1. So the total number of computations is: `Cout * Mout * Mout * (Cin * K * K + Cin * K * K - 1)`, i.e. `Cout * Mout * Mout * (2Cin * K * K - 1)`. + +3. Memory Access Cost (MAC): The computer needs to read the data from memory (general memory, including video memory) to the operator's Cache before performing operations on data (such as multiplication and addition), and the memory access is very time-consuming. Take grouped convolution as an example, suppose it is divided into `g` groups, although the number of parameters and FLOPs of the model remain unchanged after grouping, the number of memory accesses for grouped convolution becomes `g` times of the previous one (this is a simple calculation without considering multi-level Cache), so the MAC increases significantly and the computation speed of the model slows down accordingly. + +4. Parallelism: The term parallelism often includes data parallelism and model parallelism, in this case, model parallelism. Take convolutional operation as an example, the number of parameters in a convolutional layer is usually very large, so if the matrix in the convolutional layer is chunked and then handed over to multiple GPUs separately, the purpose of acceleration can be achieved. Even some network layers with too many parameters for a single GPU memory may be divided into multiple GPUs, but whether they can be divided into multiple GPUs in parallel depends not only on hardware conditions, but also on the specific form of operation. Of course, the higher the degree of parallelism, the faster the model can run. + + + + + +## Issue 4 + +### Q4.1: There is certain synthetic data in image classification task, is it necessary to use sample equalization? + +**A**: + +1. If the number of samples of different categories varies greatly, and the samples of one category are expanded to more than several times of other categories due to the synthetic data set, it is necessary to reduce the weights of that category appropriately. +2. If some categories are synthetic and some are semi-synthetic and semi-real, the equalization is not needed as long as the number is in an order of magnitude. Or you can try to train it, testing whether the synthetic category samples can be accurately identified. +3. If the performance of the category of different sources of data is degraded due to the increase of synthetic data, it is necessary to consider whether the synthetic dataset has noise or difficult samples. You can also properly increase the weight of the category to obtain better recognition performance of the category. + +### Q4.2: What new opportunities and challenges will be brought by the introduction of Vision Transformer (ViT) into the field of image classification by academia? What are the advantages over CNN? + +Paper address: [AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE](https://openreview.net/pdf?id=YicbFdNTTy) + +**A**: + +1. The dependence of images on CNNs is unnecessary, and the computational efficiency and scalability of the Transformer allow for training very large models without saturation as the model and dataset grow. Inspired by the Transformer for NLP, when being used in image classification tasks, images are divided into sequential patches that are fed into a linear unit embedding as input to the transformer. +2. In medium-sized datasets such as ImageNet1k, ImageNet21k, the visual Transformer model is several percentage points lower than ResNet of the same size. It is speculated that this is because the transformer lacks the Locality and Spatial Invariance that CNNs have, and it is difficult to outperform convolutional networks when the amount of data is not large enough. But for this problem, the data augmentation adopted by [DeiT](https://arxiv.org/abs/2012.12877) to some extent addresses the reliance of Vision Transformer on very large datasets for training. +3. This approach can go beyond local information and model more long-range dependencies when training on super large-scale datasets 14M-300M, while CNN can better focus on local information but is weak in capturing global information. +4. Transformer once reigned in the field of NLP, but was also questioned as not applicable to the CV field. The current several pieces of visual field articles also deliver competitive performance as the SOTA of CNN. We believe that a joint Vision-Language or multimodal model will be proposed that can solve both visual and linguistic problems. + +### Q4.3: For the Vision Transformer model, how is the image converted into sequence information for the Encoder? + +**A**: + +1. Using the Transformer model, mainly the attention approach. We want to conceive a scenario where semantic embedding information is applicable. But image classification is not very relevant to the semantic information of sequences, so Vision Transformer has its own unique design, and it is precisely the goal of ViT to use attention mechanisms instead of CNNs. +2. Consider the input form of the Encoder in Transformer, as shown below: + - (1) variable-length sequential input, because it is RNN structure with various amounts of words in one sentence. If it is an NLP scene, the change of word order affects little of the semantics, but the position of the image means a lot since great misunderstanding can be caused when different regions are connected in a different order. + - (2) Single patch position is transformed into a vector with fixed dimension. Encoder input is patch pixel information embedding, combined with some fixed position vector concate to synthesize a vector with fixed dimension and position information in it. + +![](../../images/faq/Transformer_input.png) + +3. Consider the following question: How to pass an image to an encoder? + +- As the following figure shows. Suppose the input image is [224,224,3], which is cut into many patches in order from left to right and top to bottom, and the patch size can be [p,p,3] (p can be 16, 32). Convert it into a feature vector using the Linear Projection of Flattened Patches module and concat a position vector into the Encoder. + +![](../../images/faq/ViT_structure.png) + +4. As shown above, given an image of `H×W×C` and a block size P, the image can be divided into `N` blocks of `P×P×C`, `N=H×W/(P×P)`. After getting the blocks, we have to use linear transformation to convert them into D-dimensional feature vectors, and then add the position encoding vectors. Similar to BERT, ViT also adds a classification flag bit before the sequence, denoted as `[CLS]`. The ViT input sequence `z` is shown in the following equation, where `x` represents an image block. + +![](../../images/faq/ViT.png) + +5. ViT model is basically the same as Transformer, where the input sequence is passed into ViT and then the final output features are classified using the `[CLS]` flags. viT consists mainly of MSA (multiheaded self-attentive) and MLP (two-layer fully connected network using GELU activation function), with LayerNorm and residual connections before MSA and MLP + +### Q4.4: How to understand Inductive Bias? + +**A**: + +1. In machine learning, some assumptions are made about the problem to be applied, and this assumption is called inductive preference. Certain a priori rules are inducted from the phenomena observed in real life, and then certain constraints are made on the model, thus playing the role of model selection. In CNN, it is assumed that the features have the characteristics of Locality and Spatial Invariance, that is, the adjacent features are connected but not those that are far away, and the adjacent features are fused together to produce "solutions" more easily; there is also the attention mechanism, which is the rule inducted from human intuition and life experience. +2. Vision Transformer utilizes an inductive bias that is linked to Sequentiality and Time Invariance, i.e., the time interval in sequence order, and therefore also yields better performance than CNN-like models on larger datasets. In the Conclusion of the article, "Unlike prior works using self-attention in computer vision, we do not introduce any image-specific inductive biases into the architecture" and "We find that large scale training trumps inductive bias" in the Introduction, we can conclude that intuitively the generation of inductive bias in the case of large amounts of data is performance-degrading and should be discarded whenever possible. + +### Q4.5: Why does ViT add a [CLS] flag bit? Why is the vector corresponding to the [CLS] used as the semantic representation of the whole sequence? + +**A**: + +1. Similar to BERT, ViT adds a `[CLS]` flag bit before the first patch, and the vector corresponding to the last end flag bit can be used as a semantic representation of the whole image, and thus for downstream classification tasks, etc. Therefore, the whole embedding group can characterize the features of the image at different locations. +2. The vector corresponding to the `[CLS]` flag bit is used as the semantic representation of the whole image because this symbol with no obvious semantic information will "fairly" integrate the semantic information of each patch in the image compared with other patches, and thus better represent the semantic of the whole image. + + + +## Issue 5 + +### Q5.1: What is included in the PaddleClas training profile? How to modify during the model training? + +**A**: PaddleClas configures 6 modules, namely: global configuration, network architecture, learning rate, optimizer, training and validation. + +The global configuration contains information about the configuration of the task, such as the number of categories, the amount of data in the training set, the number of epochs to train, the size of the network input, etc. If you want to train a custom task or use your own training set, please pay attention to this section. + +The configuration of the network structure defines the network to be used. In practice, the first step is to select the appropriate configuration file, so this part of the configuration is usually not modified. Modifications are only made when customizing the network structure, or when there are special requirements for the task. + +It is recommended to use the default configuration for the learning rate and optimizer. These parameters are the ones that are already tuned. Fine-tuning can also be done if the changes to the task are significant. + +The training and inference configurations include batch_size, dataset, data transforms (transforms), number of workers (num_workers) and other important configurations, which should be modified according to the actual environment. Note that the batch_size in paddleClas is a single card configuration, if it is a multi-card training, the total batch_size is a multiple of the one set in the configuration file. For example, if the configuration file has the batch_size of 64 and 4 cards trained, the total batch_size is 4*64=256. num_workers defines the number of processes on a single card, i.e., if num_workers is 8 with 4 cards for training, there are actually 32 workers. + +### Q5.2: How to quickly modify the configuration in the command line? + +**A**: + +During training, we often need to constantly fine-tune individual configurations without frequent modification of the configuration file. This can be adjusted using -o. The modification is done by first writing the name of the configuration to be changed by level, splitting the levels with dots, and then writing the value to be modified. For example, if we want to modify batch_size, we can add -o DataLoader.TRAIN.sampler.batch_size=512 after the training command. + +### Q5.3: How to choose the right model according to the accuracy curve of PaddleClas? + +**A**: + +PaddleClas provides benchmarks for several models and plots performance curves. There are mainly three kinds: accuracy-inference time curve, accuracy-parameter count curve and accuracy-FLOPS curve, with accuracy on the vertical axis and the other three on the horizontal axis. in general, different models perform consistently on the three plots. Models of the same series are represented on the plots using the same symbols and connected by curves. + +Taking the accuracy-inference time curve as an example, a higher point indicates higher accuracy, and a left one indicates faster speed. For example, the model in the upper-left region is a fast and accurate model, while the leftmost point close to the vertical axis is a lightweight model. When using this, you can choose the right model by considering both accuracy and time. As an example, if we want the most accurate model that runs under 10ms, first draw a vertical line 10ms out from the horizontal axis, and then find the highest point on the left side, which is the model that meets the requirements. + +In practice, the number of parameters and FLOPS of the model are constant, while the operation time varies under different hardware and software conditions. If you want to choose the model more accurately, then you can run the test in your own environment and get the corresponding performance graph. + +### Q5.4: If I want to add two classes in imagenet, can I fix the parameters of the existing fully connected layer and only train the new two? + +**A**: + +This idea works in theory, but I am afraid it will not work too well. If only the fully-connected layers are fixed and the parameters of the preceding convolutional layers are changed, there is no guarantee that these fully-connected layers will work the same as they did at the beginning. If the parameters of the entire network are kept constant and only the two new categories of fully connected layers are trained, it is also difficult to train the desired results. + +If you really need the original 1000 categories to be accurate, you can add the data of the new categories to the original training set, and then finetune with the pre-training model. if you only need a few of the 1000 categories, you can pick out this part of the data, and finetune it after mixing it with the new data. + +### Q5.5: When using classification models as pre-training models for other tasks, which layers should be selected as features? + +**A**: + +There are many strategies to use classification models as the backbone for other tasks, and a more basic approach is presented here. First, remove the final fully-connected layer, which mainly contains the classification information of the original task. If the task is relatively simple, just use the output of the previous layer as featuremap and add the structure corresponding to the task on top of it. If the task involves multiple scales, and the anchor of different scales needs to be selected, such as some detection models, then the output of the layer before each downsampling can be selected as the featuremap. diff --git a/src/PaddleClas/docs/en/faq_series/faq_2021_s2_en.md b/src/PaddleClas/docs/en/faq_series/faq_2021_s2_en.md new file mode 100644 index 0000000..c18da5b --- /dev/null +++ b/src/PaddleClas/docs/en/faq_series/faq_2021_s2_en.md @@ -0,0 +1,356 @@ +# PaddleClas FAQ Summary - 2021 Season 2 + +## Before You Read + +- We collect some frequently asked questions in issues and user groups since PaddleClas is open-sourced and provide brief answers, aiming to give some reference for the majority to save you from twists and turns. +- There are many talents in the field of image classification, recognition and retrieval with quickly updated models and papers, and the answers here mainly rely on our limited project practice, so it is not possible to cover all facets. We sincerely hope that the man of insight will help to supplement and correct the content, thanks a lot. + +## Catalogue + +- [1. Theory](#1) + - [1.1 Basic Knowledge of PaddleClas](#1.1) + - [1.2 Backbone Network and Pre-trained Model Library](#1.2) + - [1.3 Image Classification](#1.3) + - [1.4 General Detection](#1.4) + - [1.5 Image Recognition](#1.5) + - [1.6 Vector Search](#1.6) +- [2. Practice](#2) + - [2.1 Common Problems in Training and Evaluation](#2.1) + - [2.2 Image Classification](#2.2) + - [2.3 General Detection](#2.3) + - [2.4 Image Recognition](#2.4) + - [2.5 Vector Search](#2.5) + - [2.6 Model Inference Deployment](#2.6) + + + +## 1. Theory + + + +### 1.1 Basic Knowledge of PaddleClas + +#### Q1.1.1 Differences between PaddleClas and PaddleDetection + +**A**:PaddleClas is an image recognition repo that integrates mainbody detection, image classification, and image retrieval to solve most image recognition problems. It can be easily adopted by users to solve small sample and multi-category issues in the field. PaddleDetection provides the ability of target detection, keypoint detection, multi-target tracking, etc., which is convenient for users to locate the points and regions of interest in images, and is widely used in industrial quality inspection, remote sensing image detection, unmanned inspection and other projects. + +#### Q1.1.3: What does the parameter momentum mean in the Momentum optimizer? + +**A**: + +Momentum optimizer is based on SGD optimizer and introduces the concept of "momentum". In the SGD optimizer, the update of the parameter `w` at the time `t+1` can be expressed as + +``` +w_t+1 = w_t - lr * grad +``` + +`lr` is the learning rate and `grad` is the gradient of the parameter `w` at this point. With the introduction of momentum, the update of the parameter `w` can be expressed as + +``` +v_t+1 = m * v_t + lr * grad +w_t+1 = w_t - v_t+1 +``` + +Here `m` is the `momentum`, which is the weighted value of the cumulative momentum, generally taken as `0.9`. And when the value is less than `1`, the earlier the gradient is, the smaller the impact on the current. For example, when the momentum parameter `m` takes `0.9`, the weighted value of the gradient of `t-5` is `0.9 ^ 5 = 0.59049` at time `t`, while the value at time `t-2` is `0.9 ^ 2 = 0.81`. Therefore, it is intuitive that gradient information that is too "far away" is of little significance for the current reference, while "recent" historical gradient information matters more. + +[](../../images/faq/momentum.jpeg) + +By introducing the concept of momentum, the effect of historical updates is taken into account in parameter updates, thus speeding up the convergence and improving the loss (cost, loss) oscillation caused by the `SGD` optimizer. + +#### Q1.1.4: Does PaddleClas have an implementation of the paper `Fixing the train-test resolution discrepancy`? + +**A**: Currently, it is not implemented. If needed, you can try to modify the code yourself. In brief, the idea proposed in this paper is to fine-tune the final FC layer of the trained model using a larger resolution as input. Specifically, train the model network on a lower resolution dataset first, then set the parameter `stop_gradient=True ` for the weights of all layers of the network except the final FC layer, and at last fine-tune the network with a larger resolution input. + + + +### 1.2 Backbone Network and Pre-trained Model Library + + + +### 1.3 Image Classification + +#### Q1.3.1: Does PaddleClas provide data enhancement for adjusting image brightness, contrast, saturation, hue, etc.? + +**A**: + +PaddleClas provides a variety of data augmentation methods, which can be divided into 3 categories. + +1. Image transformation : AutoAugment, RandAugment; +2. Image cropping: CutOut、RandErasing、HideAndSeek、GridMask; +3. Image aliasing :Mixup, Cutmix. + +Among them, RandAngment provides a variety of random combinations of data augmentation methods, which can meet the needs of brightness, contrast, saturation, hue and other aspects. + + + +### 1.4 General Detection + +#### Q1.4.1 Does the mainbody detection only export one subject detection box at a time? + +**A**:The number of outputs for the main body detection is configurable through the configuration file. In the configuration file, Global.threshold controls the threshold value for detection, so boxes smaller than this threshold are discarded; and Global.max_det_results controls the maximum number of results returned. The two together determine the number of output detection boxes. + +#### Q1.4.2 How is the data selected for training the mainbody detection model? Will it harm the accuracy to switch to a smaller model? + +**A**: + +The training data is a randomly selected subset of publicly available datasets such as COCO, Object365, RPC, and LogoDet. We are currently introducing an ultra-lightweight mainbody detection model in version 2.3, which can be found in [Mainbody Detection](../../en/image_recognition_pipeline/mainbody_detection_en.md#2-model-selection). + +#### Q1.4.3: Is there any false detections in some scenarios with the current mainbody detection model? + +**A**:The current mainbody detection model is trained using publicly available datasets such as COCO, Object365, RPC, LogoDet, etc. If the data to be detected is similar to industrial quality inspection and other data with large differences from common categories, it is necessary to fine-tune the training based on the current detection model again. + + + +### 1.5 Image Recognition + +#### Q1.5.1 Is `triplet loss` needed for `circle loss` ? + +**A**: + +`circle loss` is a unified form of sample pair learning and classification learning, and `triplet loss` can be added if it is a classification learning. + +#### Q1.5.2 Which recognition model is better if not to recognize open source images in all four directions? + +**A**: + +The product recognition model is recommended. For one, the range of products is wider and the probability that the recognized image is a product is higher. For two, the training data of the product recognition model uses 50,000 categories of data, which has better generalization ability and more robust features. + +#### Q1.5.3 Why is 512-dimensional vector is finally adopted instead of 1024 or others? + +**A**: + +Vectors with small dimensions should be adopted. 128 or even smaller are practically used to speed up the computation. In general, a dimension of 512 is large enough to adequately represent the features. + + + +### 1.6 Vector Search + +#### Q1.6.1 Does the Möbius vector search algorithm currently used by PaddleClas support index.add() similar to the one used by faiss? Also, do I have to train every time I build a new graph? Is the train here to speed up the search or to build similar graphs? + +**A**:The faiss retrieval module is now supported in the release/2.3 branch and is no longer supported by Möbius, which provides a graph-based algorithm that is similar to the nearest neighbor search and currently supports two types of distance calculation: inner product and L2 distance. However, Möbius does not support the index.add function provided in faiss. So if you need to add content to the search library, you need to rebuild a new index from scratch. The search algorithm internally performs a train-like process each time the index is built, which is different from the train interface provided by faiss. Therefore, if you need the faiss module, you can use the release/2.3 branch, and if you need Möbius, you need to fall back to the release/2.2 branch for now. + +#### Q1.6.2: What exactly are the `Query` and `Gallery` configurations used for in the PaddleClas image recognition for Eval configuration file? + +**A**: + + Both `Query` and `Gallery` are data set configurations, where `Gallery` is used to configure the base library data and `Query` is used to configure the validation set. When performing Eval, the model is first used to forward compute feature vectors on the `Gallery` base library data, which are used to construct the base library, and then the model forward computes feature vectors on the data in the `Query` validation set, and then computes metrics such as recall rate in the base library. + + + +## 2. Practice + + + +### 2.1 Common Problems in Training and Evaluation + +#### Q2.1.1 Where is the `train_log` file in PaddleClas? + +**A**:`train.log` is stored in the path where the weights are stored. + +#### Q2.1.2 Why nan is the output of the model training? + +**A**: 1. Make sure the pre-trained model is loaded correctly, the easiest way is to add the parameter `-o Arch.pretrained=True`; 2. When fine-tuning the model, the learning rate should not be too large, e.g. 0.001. + +#### Q2.1.3 Is it possible to perform frame-by-frame prediction in a video? + +**A**:Yes, but currently PaddleClas does not support video input. You can try to modify the code of PaddleClas or store the video frame by frame before using PaddleClas. + +#### Q2.1.4: In data preprocessing, what setting can be adopted without cropping the input data? Or how to set the size of the crop? + +**A**: The data preprocessing operators supported by PaddleClas can be viewed in `ppcls/data/preprocess/__init__.py`, and all supported operators can be configured in the configuration file. The name of the operator needs to be the same as the operator class name, and the parameters need to be the same as the constructor parameters of the corresponding operator class. If you do not need to crop the image, you can remove `CropImage` and `RandCropImage` and replace them with `ResizeImage`, and you can set different resize methods with its parameters by using the `size` parameter to directly scale the image to a fixed size, and using the `resize_short` parameter to maintain the image aspect ratio for scaling. To set the crop size, use the `size` parameter of the `CropImage` operator, or the `size` parameter of the `RandCropImage` operator. + +#### Q2.1.5: Why do I get a usage error after PaddlePaddle installation and cannot import any modules under paddle (import paddle.xxx)? + +**A**: + +You can first test if Paddle is installed correctly by using the following code. + +``` +import paddle +paddle.utils.install_check.run_check() +``` + +When installed correctly, the following prompts will be displayed. + +``` +PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now. +``` + +Otherwise, the relevant question will prompt out. Also, after installing both the CPU and the GPU version of Paddle, you will need to uninstall both versions and reinstall the required version due to conflicts between the two versions. + +#### Q2.1.6: How to save the optimal model during training? + +**A**: + +PaddleClas saves/updates the following three types of models during training. + +1. the latest model (`latest.pdopt`, `latest.pdparams`, `latest.pdstates`), which can be used to resume training when it is unexpectedly interrupted. +2. the best model (`best_model.pdopt`, `best_model.pdparams`, `best_model.pdstates`). +3. breakpoints at the end of an epoch during training (`epoch_xxx.pdopt`, `epoch_xxx.pdparams`, `epoch_xxx.pdstates`). The `Global.save_interval` field in the training profile indicates the save interval for this model. If you make it larger than the total number of epochs, intermediate breakpoint models will no longer be saved. + +#### Q2.1.7: How to address the `ERROR: Unexpected segmentation fault encountered in DataLoader workers.` during training? + +**A**:Try setting the field `num_workers` in the training profile to `0`; try making the field `batch_size` in the training profile smaller; ensure that the dataset format and the dataset path in the profile are correct. + +#### Q2.1.8: How to use `Mixup` and `Cutmix` during training? + +**A**: + +- For `Mixup`, please refer to [Mixup](../../../ppcls/configs/ImageNet/DataAugment/ResNet50_ Mixup.yaml#L63-L65); and`Cuxmix`, please refer to [Cuxmix](../../../ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml#L63-L65). +- The training accuracy (Acc) metric cannot be calculated when using `Mixup` or `Cutmix` for training, so you need to remove the `Metric.Train.TopkAcc` field in the configuration file, please refer to [Metric.Train.TopkAcc](../../../ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml#L125-L128). + +#### Q2.1.9: What are the fields `Global.pretrain_model` and `Global.checkpoints` used for in the training configuration file yaml? + +**A**: + +- When `fine-tune` is required, the path of the file of pre-training model weights can be configured via the field `Global.pretrain_model`, which usually has the suffix `.pdparams`. +- During training, the training program automatically saves the breakpoint information at the end of each epoch, including the optimizer information `.pdopt` and model weights information `.pdparams`. In the event that the training process is unexpectedly interrupted and needs to be resumed, the breakpoint information file saved during training can be configured via the field `Global.checkpoints`, for example by configuring `checkpoints: . /output/ResNet18/epoch_18` to restore the breakpoint information at the end of 18 epoch training. PaddleClas will automatically load `epoch_18.pdopt` and `epoch_18.pdparams` to continue training from 19 epoch. + + + +### 2.2 Image Classification + +#### Q2.2.1 How to distill the small model after pre-training the large model on 500M data and then distill the fintune model on 1M data in SSLD? + +**A**:The steps are as follows: + +1. Obtain the `ResNet50-vd` model based on the distillation of the open-source `ResNeXt101-32x16d-wsl` model from Facebook. +2. Use this `ResNet50-vd` to distill `MobilNetV3` on a 500W dataset. +3. Considering that the distribution of the 500W dataset is not exactly the same as that of the 100W data, this piece of data is finetuned on the 100W data to slightly improve the accuracy. + +#### Q2.2.2 nan appears in loss when training SwinTransformer + +**A**:When training SwinTransformer, please use `Paddle` `2.1.1` or above, and load the pre-trained model we provide. Also, the learning rate should be kept at an appropriate level. + + + +### 2.3 General Detection + +#### Q2.3.1 Why are there some images that are detected as the original image? + +**A**:The mainbody detection model returns the detection frame, but in fact, in order to make the subsequent recognition model more accurate, the original image is also returned along with the detection frame. Subsequently, the original image or the detection frame will be sorted according to its similarity with the images in the library, and the label of the image in the library with the highest similarity will be the label of the recognized image. + +#### Q2.3.2: + +**A**:A real-time detection presents high requirements for the detection speed; PP-YOLO is a lightweight target detection model provided by Paddle team, which strikes a good balance of detection speed and accuracy, you can try PP-YOLO for detection. For the use of PP-YOLO, you can refer to [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/configs/ppyolo/README_cn.md). + +#### Q2.3.3: For unknown labels, adding gallery dataset can be used for subsequent classification recognition (without training), but if the previous detection model cannot locate and detect the unknown labels, is it still necessary to train the previous detection model? + +**A**:If the detection model does not perform well on your own dataset, you need to finetune it again on your own detection dataset. + + + +### 2.4 Image Recognition + +#### Q2.4.1: Why is `Illegal instruction` reported during the recognition inference? + +**A**:If you are using the release/2.2 branch, it is recommended to update it to the release/2.3 branch, where we replaced the Möbius search model with the faiss search module, as described in [Vector Search Tutorial](../image_recognition_pipeline/vector_search_en.md). If you still have problems, you can contact us in the WeChat group or raise an issue on GitHub. + +#### Q2.4.2: How can recognition models be fine-tuned to train on the basis of pre-trained models? + +**A**:The fine-tuning training of the recognition model is similar to that of the classification model. The recognition model can be loaded with a pre-trained model of the product, and the training process can be found in [recognition model training](../../models_training/recognition_en.md), and we will continue to refine the documentation. + +#### Q2.4.3: Why does it fail to run all mini-batches in each epoch when training metric learning? + +**A**:When training metric learning, the Sampler used is DistributedRandomIdentitySampler, which does not sample all the images, resulting in each epoch sampling only part of the data, so it is normal that the mini-batch cannot run through the display. This issue has been optimized in the release/2.3 branch, please update to release/2.3 to use it. + +#### Q2.4.4: Why do some images have no recognition results? + +**A**:In the configuration file (e.g. inference_product.yaml), `IndexProcess.score_thres` controls the minimum value of cosine similarity of the recognized image to the image in the library. When the cosine similarity is less than this value, the result will not be printed. You can adjust this value according to your actual data. + + + +### 2.5 Vector Search + +#### Q2.5.1: Why is the error `assert text_num >= 2` reported after adding an image to the index? + +**A**:Make sure that the image path and the image name in data_file.txt is separated by a single table instead of a space. + +#### Q2.5.2: Do I need to rebuild the index to add new base data? + +**A**:Starting from release/2.3 branch, we have replaced the Möbius search model with the faiss search module, which already supports the addition of base data without building the base library, as described in [Vector Search Tutorial](../image_recognition_pipeline/vector_search_en.md). + +#### Q2.5.3: How to deal with the reported error clang: error: unsupported option '-fopenmp' when recompiling index.so in Mac? + +**A**: + +If you are using the release/2.2 branch, it is recommended to update it to the release/2.3 branch, where we replaced the Möbius search model with the faiss search module, as described in [Vector Search Tutorial](../image_recognition_pipeline/vector_search_en.md). If you still have problems, you can contact us in the user WeChat group or raise an issue on GitHub. + +#### Q2.5.4: How to set the parameter `pq_size` when build searches the base library? + +**A**: + +`pq_size` is a parameter of the PQ search algorithm, which can be simply understood as a "tiered" search algorithm. And `pq_size` is the "capacity" of each tier, so the setting of this parameter will affect the performance. However, in the case that the total data volume of the base library is not too large (less than 10,000), this parameter has little impact on the performance. So for most application scenarios, there is no need to modify this parameter when building the base library. For more details on the PQ search algorithm, see the related [paper](https://lear.inrialpes.fr/pubs/2011/JDS11/jegou_searching_with_quantization.pdf). + + + +### 2.6 Model Inference Deployment + +#### Q2.6.1: How to add the parameter of a module that is enabled by hub serving? + +**A**:See [hub serving parameters](../../../deploy/hubserving/clas/params.py) for more details. + +#### Q2.6.2: Why is the result not accurate enough when exporting the inference model for inference deployment? + +**A**: + +This problem is usually caused by the incorrect loading of the model parameters when exporting. First check the export log for something like the following. + +``` +UserWarning: Skip loading for ***. *** is not found in the provided dict. +``` + +If it exists, the model weights were not loaded successfully. Please further check the `Global.pretrained_model` field in the configuration file to see if the path of the model weights file is correctly configured. The suffix of the model weights file is usually `pdparams`, note that the file suffix is not required when configuring this path. + +#### Q2.6.3: How to convert the model to `ONNX` format? + +**A**: + +Paddle supports two ways and relies on the `paddle2onnx` tool, which first requires the installation of `paddle2onnx`. + +``` +pip install paddle2onnx +``` + +- From inference model to ONNX format model: + + Take the `combined` format inference model (containing `.pdmodel` and `.pdiparams` files) exported from the dynamic graph as an example, run the following command to convert the model format: + + ``` + paddle2onnx --model_dir ${model_path} --model_filename ${model_path}/inference.pdmodel --params_filename ${model_path}/inference.pdiparams --save_file ${save_path}/model.onnx --enable_onnx_checker True + ``` + + In the above commands: + + - `model_dir`: this parameter needs to contain `.pdmodel` and `.pdiparams` files. + - `model_filename`: this parameter is used to specify the path of the `.pdmodel` file under the parameter `model_dir`. + - `params_filename`: this parameter is used to specify the path of the `.pdiparams` file under the parameter `model_dir`. + - `save_file`: this parameter is used to specify the path to the directory where the converted model is saved. + + For the conversion of a non-`combined` format inference model exported from a static diagram (usually containing the file `__model__` and multiple parameter files), and more parameter descriptions, please refer to the official documentation of [paddle2onnx](https://github.com/PaddlePaddle/Paddle2ONNX/blob/develop/README.md#parameters). + +- Exporting ONNX format models directly from the model networking code. + + Take the model networking code of dynamic graphs as an example, the model class is a subclass that inherits from `paddle.nn.Layer` and the code is shown below: + + ```python + import paddle + from paddle.static import InputSpec + + class SimpleNet(paddle.nn.Layer): + def __init__(self): + pass + def forward(self, x): + pass + + net = SimpleNet() + x_spec = InputSpec(shape=[None, 3, 224, 224], dtype='float32', name='x') + paddle.onnx.export(layer=net, path="./SimpleNet", input_spec=[x_spec]) + ``` + + Among them: + + - `InputSpec()` function is used to describe the signature information of the model input, including the `shape`, `type` and `name` of the input data (can be omitted). + - The `paddle.onnx.export()` function needs to specify the model grouping object `net`, the save path of the exported model `save_path`, and the description of the model's input data `input_spec`. + + Note that the `paddlepaddle` `2.0.0` or above should be adopted.See [paddle.onnx.export](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/onnx/) for more details on the parameters of the `paddle.onnx.export()` function. diff --git a/src/PaddleClas/docs/en/faq_series/faq_selected_30_en.md b/src/PaddleClas/docs/en/faq_series/faq_selected_30_en.md new file mode 100644 index 0000000..54f6ca1 --- /dev/null +++ b/src/PaddleClas/docs/en/faq_series/faq_selected_30_en.md @@ -0,0 +1,291 @@ +# FAQ + +## Before You Read + +- We collect some frequently asked questions in issues and user groups since PaddleClas is open-sourced and provide brief answers, aiming to give some reference for the majority to save you from twists and turns. +- There are many talents in the field of image classification, recognition and retrieval with quickly updated models and papers, and the answers here mainly rely on our limited project practice, so it is not possible to cover all facets. We sincerely hope that the man of insight will help to supplement and correct the content, thanks a lot. + +## Catalogue + +- [1. 30 Questions About Image Classification](#1) + - [1.1 Basic Knowledge](#1.1) + - [1.2 Model Training](#1.2) + - [1.3 Data](#1.3) + - [1.4 Model Inference and Prediction](#1.4) +- [2. Application of PaddleClas](#2) + + +## 1. 30 Questions About Image Classification + + +### 1.1 Basic Knowledge + +- Q: How many classification metrics are commonly used in the field of image classification? +- A: + - For a single-label image classification (containing only 1 category and background), the evaluation metrics are Accuracy, Precision, Recall, F-score, etc. If TP(True Positive) means predicting positive class as positive, FP(False Positive) means predicting negative class as positive, TN( True Negative) means the negative class is predicted to be negative, and FN(False Negative) means the positive class is predicted to be negative. Then Accuracy=(TP + TN) / NUM, Precision=TP /(TP + FP), Recall=TP /(TP + FN). + - For the image classification problem with the number of classes greater than 1, the evaluation metrics are Accuary and Class-wise Accuracy. Accuary indicates the percentage of the number of images correctly predicted by all classes to the total number of images; Class-wise Accuracy is obtained by calculating the Accuracy for each class of images and then averaging the Accuracy of all classes. + +> > + +- Q: 怎样根据自己的任务选择合适的模型进行训练?How to choose the right training model? +- A: If you want to deploy on the server with a high requirement for accuracy but not model storage size or prediction speed, then it is recommended to use ResNet_vd, Res2Net_vd, DenseNet, Xception, etc., which are suitable for server-side models. If you want to deploy on the mobile side, then it is recommended to use MobileNetV3 and GhostNet. Meanwhile, we suggest you refer to the speed-accuracy metrics chart in [Model Library](../models/models_intro_en.md) when choosing models. + +> > + +- Q: How to initialize the parameters and what kind of initialization can speed up the convergence of the model? +- A: It is well known that the initialization of parameters can affect the final performance of the model. In general, if the target dataset is not very large, it is recommended to use the pre-trained model obtained by training ImageNet-1k for initialization. If the network is designed manually or there are no pre-trained weights based on ImageNet-1k training, you can use Xavier initialization or MSRA initialization, where the former is proposed for Sigmoid function, which is less friendly to RELU function. The deeper the network is, the smaller the variance of each layer input, the harder the network is to train. So when more RELU activation functions are used in the neural network, MSRA initialization is a better choice. + +> > + +- Q: What are the better solutions to the problem of parameter redundancy in deep neural networks? +- A: There are several major approaches to compressing models and reducing the model parameter redundancy, such as pruning, quantization, and knowledge distillation. Model pruning refers to removing relatively unimportant weights from the weight matrix and then fine-tuning the network again. Model quantization refers to a technique that converts floating-point computation into low-ratio specific-point computation, such as 8-bit, 4-bit, etc., which can effectively reduce the computational intensity, parameter size, and memory consumption of the model. Knowledge distillation refers to the use of a teacher model to guide a student model to learn a specific task, ensuring that the small model has a great performance improvement or even obtains similar accuracy metrics as the large model with the same number of parameters. + +> > + +- Q: How to choose the right classification model as a backbone network in other tasks, such as target detection, image segmentation, key point detection, etc.? + +- A: + + Without considering the speed, it is most recommended to use pre-training models and backbone networks with higher accuracy. A series of SSLD knowledge distillation pre-training models are open-sourced in PaddleClas, such as ResNet50_vd_ssld, Res2Net200_vd_26w_4s_ssld, etc., which excel in both model accuracy and speed. For specific tasks, such as image segmentation or key point detection, which require higher image resolution, it is recommended to use neural network models such as HRNet that can take into account both network depth and resolution. And PaddleClas also provides HRNet SSLD distillation series pre-training models including HRNet_W18_C_ssld, HRNet_W48_C_ssld, etc., which have very high accuracy. You can use these models and the backbone network to improve your own model accuracy on other tasks. + +> > + +- Q: What is the attention mechanism? What are the common methods of it? +- A: The Attention Mechanism (AM) originated from the study of human vision. Using the mechanism on computer vision tasks can effectively capture the useful regions in the images and thus improve the overall network performance. Currently, the most commonly used ones are [SE block](https://arxiv.org/abs/1709.01507), [SK-block](https://arxiv.org/abs/1903.06586), [Non-local block](https://arxiv. org/abs/1711.07971), [GC block](https://arxiv.org/abs/1904.11492), [CBAM](https://arxiv.org/abs/1807.06521), etc. The core idea is to learn the importance of feature maps in different regions or different channels, so that the network can pay more attention to the regions of salience. + + + +### 1.2 Model Training + +> > + +- Q: What will happen if a model with 10 million classes is trained during the image classification with deep convolutional networks? +- A: Because of the large number of parameters in the FC layer, the memory/video memory/model storage usage will increase significantly; the model convergence speed will also be slower. In this case, it is recommended to add a layer of FC with a smaller dimension before the last FC layer, which can drastically reduce the storage size of the model. + +> > + +- Q: What are the possible reasons if the model converges poorly during the training process? +- A: There are several points that can be investigated: (1) The data annotation should be checked to ensure that there are no problems with the labeling of the training and validation sets. (2) Try to adjust the learning rate (initially by a factor of 10). A learning rate that is too large (training oscillation) or too small (slow convergence) may lead to poor convergence. (3) Huge amount of data and an overly small model may prevent it from learning all the features of the data. (4) See if normalization is used in the data preprocessing process. It may be slower without normalization operation. (5) If the amount of data is relatively small, you can try to load the pre-trained model based on ImageNet-1k dataset provided in PaddleClas, which can greatly improve the training convergence speed. (6) There is a long tail problem in the dataset, you can refer to the [solution to the long tail problem of data](#long_tail). + +> > + +- Q: How to choose the right optimizer when training image classification tasks? +- A: Since the emergence of deep learning, there has been a lot of research on optimizers, which aim to minimize the loss function to find the right weights for a given task. Currently, the main optimizers used in the industry are SGD, RMSProp, Adam, AdaDelt, etc. Among them, since the SGD optimizer with momentum is widely used in academia and industry (only for classification tasks), most of the models we published also adopt this optimizer to achieve gradient descent of the loss function. It has two disadvantages, one is the slow convergence speed, and the other is the reliance on experiences of the initial learning rate setting. However, if the initial learning rate is set properly with a sufficient number of iterations, the optimizer will also stand out among many other optimizers, obtaining higher accuracy on the validation set. Some optimizers with adaptive learning rates, such as Adam and RMSProp, tend to converge fast, but the final convergence accuracy will be slightly worse. If you pursue faster convergence speed, we recommend using these adaptive learning rate optimizers, and SGD optimizers with momentum for higher convergence accuracy. + +- Q: What are the current mainstream learning rate decay strategies? How to choose? +- A: The learning rate is the speed at which the hyperparameters of the network weights are adjusted by the gradient of the loss function. The lower the learning rate, the slower the loss function will change. While using a low learning rate ensures that no local minimal values are missed, it also means that it takes longer to converge, especially if trapped in a plateau region. Throughout the whole training process, we cannot adopt the same learning rate to update the weights, otherwise, the optimal point cannot be reached, So we need to adjust the learning rate during the training. In the initial stage of training, since the weights are in a random initialization state and the loss function decreases fast, a larger learning rate can be set. And in the later stage of training, since the weights are close to the optimal value, a larger learning rate cannot further find the optimal value, so a smaller learning rate needs is a better choice. As for the learning rate decay strategy, many researchers or practitioners use piecewise_decay (step_decay), which is a stepwise decay learning rate. In addition, there are also other methods proposed by researchers, such as polynomial_decay, exponential_ decay, cosine_decay, etc. Among them, cosine_decay requires no adjustment of hyperparameters and has higher robustness, thus emerging as the preferred learning rate decay method to improve model accuracy. The learning rates of cosine_decay and piecewise_decay are shown in the following figure. It is easy to observe that cosine_decay keeps a large learning rate throughout the training, so it is slow in convergence, but its final effect is better than peicewise_decay. + +![](../../images/models/lr_decay.jpeg) + +> > + +- Q: What is the Warmup strategy? Where is it applied? +- A: The warmup strategy, which, as the name implies, is a warm-up for the learning rate with no direct adoption of maximum learning rate at the beginning of training, but to train the network with a gradually increasing rate, and then decay the learning rate when it peaks. When training a neural network with a large batch_size, it is recommended to use the warmup strategy. Experiments show that warmup can steadily improve the accuracy of the model when the batch_size is large. For example, when training MobileNetV3, we set the epoch in warmup to 5 by default, i.e., first increase the learning rate from 0 to the maximum value with 5 epochs, and then conduct the corresponding decay of the learning rate. + +> > + +- Q: What is `batch size`?How to choose the appropriate `batch size` during training? +- A: `batch size` is an important hyperparameter in neural networks training, whose value determines how much data is fed into the neural network for training at a time. According to the paper [Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour](https://arxiv.org/abs/1706.02677), when the value of `batch size` is linearly related to the value of learning rate, the convergence accuracy is almost unaffected. When training ImageNet-1k data, most of the neural networks choose an initial learning rate of 0.1 and a `batch size` of 256. Therefore, depending on the actual model size and video memory, the learning rate can be set to 0.1*k and the batch_size to 256*k. This setting can also be used as the initial parameter to further adjust the learning rate parameter and obtain better performance in real tasks. + +> > + +- Q: What is weight_decay?How to choose? +- A: Overfitting is a common term in machine learning, which is simply understood as a model that performs well on training data but less satisfactory on test data. In image classification, there is also the problem of overfitting, and many regularization methods are proposed to avoid it, among which weight_decay is one of the widely used ways. When using SGD optimizer, weight_decay is equivalent to adding L2 regularization after the final loss function, which makes the weights of the network tend to choose smaller values, so eventually, the parameter values in the whole network tend to be more towards 0, and the generalization performance of the model is improved accordingly. In the implementation of major deep learning frameworks, this value means the coefficient before the L2 regularization, which is called L2Decay in the PaddlePaddle framework. The larger the coefficient is, the stronger the added regularization is, and the more the model tends to be underfitted. When training ImageNet, most networks set the value of this parameter to 1e-4, and in some smaller networks such as the MobileNet series network, the value is set between 1e-5 and 4e-5 to avoid the underfitting. Of course, the setting of this value is also related to specific datasets. When the dataset of the task is large, the network itself tends to be under-fitted and the value should be reduced appropriately, and when it is small, the network itself tends to be over-fitted and the value should be increased. The following table shows the accuracy of MobileNetV1_x0_25 on ImageNet-1k using different l2_decay. Since MobileNetV1_x0_25 is a relatively small network, too large a l2_decay will tend to underfit the network, so 3e-5 is a better choice in this network compared to 1e-4. + +| Model | L2_decay | Train acc1/acc5 | Test acc1/acc5 | +| ----------------- | -------- | --------------- | -------------- | +| MobileNetV1_x0_25 | 1e-4 | 43.79%/67.61% | 50.41%/74.70% | +| MobileNetV1_x0_25 | 3e-5 | 47.38%/70.83% | 51.45%/75.45% | + +> > + +- Q: What does label smoothing (label_smoothing) refer to? What is the effect? What kind of scenarios does it usually apply to? +- A: Label_smoothing is a regularization method in deep learning, whose full name is Label Smoothing Regularization (LSR). In the traditional classification task, the loss function is calculated by the cross-entropy of the real one hot label and the output of the neural network, while label_smoothing is a label smoothing of the real one hot label, so that the label learned by the network is no longer a hard label, but a soft label with a probability value, where the probability at the position corresponding to the category is the largest and others small. See the paper[2] for detailed calculation methods. In label_smoothing, the epsilon parameter describes the degree of label softening, the larger the value, the smaller the label probability value of the label vector after label smoothing, the smoother the label, and vice versa. The value is usually set to 0.1 in experiments training ImageNet-1k, and there is a steady increase in accuracy for models of the ResNet50 size and above after using label_smooting. The following table shows the accuracy metrics of ResNet50_vd before and after using label_smoothing. At the same time, since label_smoohing can be regarded as a regularization method, the accuracy improvement is not obvious or even decreases on a relatively small model. The following table shows the accuracy metrics of ResNet18 before and after using label_smoothing on ImageNet-1k. It is clear that the accuracy drops after using label_smoothing. + +| Model | Use_label_smoothing | Test acc1 | +| ----------- | ------------------- | --------- | +| ResNet50_vd | 0 | 77.9% | +| ResNet50_vd | 1 | 78.4% | +| ResNet18 | 0 | 71.0% | +| ResNet18 | 1 | 70.8% | + +> > + +- Q: How to determine the tuning strategy by the accuracy or loss of the training and validation sets during training? +- A: In the process of training a network, the accuracy of the training set and validation set are usually printed for each epoch, which portrays the performance of the model on both datasets. Generally speaking, it is good to have a comparable accuracy or a slightly higher accuracy in the training set than in the validation set. If we find that the accuracy of the training set is much higher than the validation set, it means that the training set is overfitted and we need to add more regularity, such as increasing the value of L2Decay, adding more data augmentation strategies, introducing label_smoothing strategies, etc. If we find that the accuracy of the training set is lower than the validation set, it means that the training set is probably underfitted, and the regularization effect should be weakened during the training, such as reducing the value of L2Decay, decreasing the data augmentation methods, increasing the area of the crop area, weakening the image stretching, removing label_smoothing, etc. + +> > + +- Q: How to improve the accuracy of my own dataset by pre-training the model? +- A: At this stage, it has become a common practice in the image recognition field to load pre-trained models to train their own tasks, which can often improve the accuracy of a particular task compared to training from random initialization. In general, the pre-training model widely used in the industry is obtained by training the ImageNet-1k dataset of 1.28 million images of 1000 classes. The fc layer weights of this pre-training model are a matrix of k*1000, where k is the number of neurons before the fc layer, and it is not necessary to load the fc layer weights when loading the pre-training weights. In terms of the learning rate, if your dataset is particularly small (e.g., less than 1,000), we recommend you to adopt a small initial learning rate, e.g., 0.001 (batch_size:256, the same below), so as not to corrupt the pre-training weights with a larger learning rate. If your training dataset is relatively large (>100,000), we suggest you try a larger initial learning rate, such as 0.01 or above. + + +### 1.3 Data + +> > + +- Q: What are the general steps involved in the data pre-processing for image classification? +- A: When training ResNet50 on ImageNet-1k dataset, an image is fed into the network, and there are several steps: image decoding, random cropping, random horizontal flipping, normalization, data rearrangement, group batching and feeding into the network. Image decoding refers to reading the image file into memory; random cropping refers to randomly stretching and cropping the read image to an image with the length and width of 224 ; random horizontal flipping refers to flipping the cropped image horizontally with a probability of 0.5; normalization refers to centering the data of each channel of the image by de-meaning, so that the data conforms to the `N(0,1)` normal distribution as much as possible; data rearrangement refers to changing the data from `[224,224,3]` format to `[3,224,224]`; and group batching refers to forming a batch of multiple images and feeding them into the network for training. + +> > + +- Q: How does random-crop affect the performance of small model training? +- A: In the standard preprocessing of ImageNet-1k data, the random_crop function defines two values, scale and ratio, which respectively determine the size of the image crop and the degree of image stretching, where the default value of the former is 0.08-1 (lower_scale-upper_scale), and the latter is 3/4-4/3 (lower_ratio-upper_ratio). In very small networks, this kind of data augmentation can lead to network underfitting and decreased accuracy. To the end, the data augmentation can be made weaker by increasing the crop area of the image or decreasing the stretching of the image. Weaker image transformation can be achieved by increasing the value of lower_scale or reducing the difference between lower_ratio and upper_scale, respectively. The following table shows the accuracy of training MobileNetV2_x0_25 with different lower_scale, and we can see that the training accuracy and verification accuracy are improved by increasing the crop area of the images. + +| Model | Range of Scale | Train_acc1/acc5 | Test_acc1/acc5 | +| ----------------- | -------------- | --------------- | -------------- | +| MobileNetV2_x0_25 | [0.08,1] | 50.36%/72.98% | 52.35%/75.65% | +| MobileNetV2_x0_25 | [0.2,1] | 54.39%/77.08% | 53.18%/76.14% | + +> > + +- Q: What are the common data augmentation methods currently available to increase the richness of training samples when the amount of data is insufficient? +- A: PaddleClas classifies data augmentation methods into three categories, which are image transformation, image cropping and image aliasing. Image transformation mainly includes AutoAugment and RandAugment, image cropping contains CutOut, RandErasing, HideAndSeek and GridMask, and image aliasing comprises Mixup and Cutmix. More detailed introduction to data augmentation can be found in the chapter of [Data Augmentation ](../algorithm_introduction/DataAugmentation_en.md). + +> > + +- Q: For image classification scenarios where occlusion is common, what data augmentation methods should be used to improve the accuracy of the model? +- A: During the training, you can try to adopt cropping data augmentations including CutOut, RandErasing, HideAndSeek and GridMask on the training set, so that the model can learn not only the significant regions but also the non-significant regions, thus better performing the recognition task. + +> > + +- Q: What data augmentation methods should be used to improve model accuracy in the case of complex color transformations? +- A: Consider using the data augmentation strategies of AutoAugment or RandAugment, both of which include rich color transformations such as sharpening and histogram equalization, allowing the model to be more robust to these transformations during the training process. + +> > + +- Q: How do Mixup and Cutmix work? Why are they effective methods of data augmentation? +- A: Mixup generates a new image by linearly overlaying two images, and the corresponding labels also undertake the same process for training, while Cutmix crops a random region of interest (ROI) from an image and overlays the corresponding region in the current image, and the labels are linearly overlaid in proportion to the image area. They actually generate different samples and labels from the training set and for the learning of the network, thus enriching the samples. + +> > + +- Q: What is the size of the training dataset for an image classification task that does not require high accuracy? +- A: The amount of the training data is related to the complexity of the problem to be solved. The greater the difficulty and the higher the accuracy requirement, the larger the dataset needs to be. And it is a universal rule that the more training data the better the result in practice. Of course, in general, 10-20 images per category with pre-trained models can guarantee the basic classification effect; or at least 100-200 images per category without pre-training models. + + + +> > + +- Q: What are the common methods currently used for datasets with long-tailed distributions? +- A:(1) the categories with fewer data can be resampled to increase the probability of their occurrence; (2) the loss can be modified to increase the loss weight of images in categories corresponding to fewer images; (3) the method of transfer learning can be borrowed to learn generic knowledge from common categories and then migrate to the categories with fewer samples. + + + +### 1.4 Model Inference and Prediction + +> > + +- Q: How to deal with the poor recognition performance when the original image is taken for classification with only a small part of the image being the foreground object of interest? +- A: A mainbody detection model can be added before classification to detect the foreground objects, which can greatly improve the final recognition results. If time cost is not a concern, multi-crop can also be used to fuse all the predictions to determine the final category. + +> > + +- Q: What are the currently recommended model inference methods? +- A: After the model is trained, it is recommended to use the exported inference model to make inferences based on the Paddle inference engine, which currently supports python inference and cpp inference. If you want to deploy the inference model based on service, it is recommended to use the PaddleServing. + +> > + +- Q: What are the appropriate inference methods to further improve the model accuracy after training? +- A:(1) A larger inference scale can be used, e.g., 224 for training, then 288 or 320 for inference, which will directly bring about a 0.5% improvement in accuracy. (2) Test Time Augmentation (TTA) can be used to create multiple copies of the test set by rotating, flipping, color transforming, and so on, and then fuse all the prediction results, which can greatly improve its accuracy and robustness. (3) Of course, a multi-model fusion strategy can also be adopted to fuse the prediction results of multiple models for the same images. + +> > + +- Q: How to choose the best model for the fusion of multiple models? +- A: Without considering the inference speed, models with the highest possible are recommended; it is also suggested to choose models with different structures or series for fusion. For example, the model fusion results of ResNet50_vd and Xception65 tend to be better than those of ResNet50_vd and ResNet101_vd with similar accuracy. + +> > + +- Q: What are the common acceleration methods when using a fixed model for inference? +- A: (1) Using a GPU with better performance; (2) increasing the batch size; (3) using TenorRT and FP16 half-precision floating-point methods. + + + +## 2. Application of PaddleClas + +> > + +- Q: Why can't I import parameters even though I have specified the address of the folder where the pre-trained model is located during evaluation and inference? +- A: When loading a pretrained model, you need to specify the prefix of it. For example, if the folder where the pretrained model parameters are located is `output/ResNet50_vd/19` and the name of the pretrained model parameters is `output/ResNet50_vd/19/ppcls.pdparams`, then the `pretrained_model ` parameter needs to be specified as `output/ResNet50_vd/19/ppcls`, and PaddleClas will automatically complete the `.pdparams` suffix. + +> > + +- Q: Why the final accuracy is always about 0.3% lower than the official one when evaluating the `EfficientNetB0_small` model? +- A: The `EfficientNet` series network uses `cubic interpolation` for resize (the interpolation value of the resize parameter is set to 2), while other models are None by default, so the interpolation value of resize needs to be explicitly specified during training and evaluation. Specifically, you can refer to the ResizeImage parameter in the preprocessing process in the following configuration. + +``` + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: 2 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + +> > + +- Q: Why `TypeError: __init__() missing 1 required positional argument: 'sync_cycle'` is reported when using visualdl under python2? +- A: Currently visualdl only supports running under python3 with a required version of 2.0 or higher. If visualdl is not the right version, you can install it as follows: `pip3 install visualdl -i https://mirror.baidu.com/pypi/simple` + +> > + +- Q: Why is it that the inference speed of a single image by ResNet50_vd is much lower than the benchmark provided by the official website while the CPU is much faster than GPU? +- A: The model inference needs to be initialized, and it is time-consuming. Therefore, when counting the inference speed, we need to run a batch of images, remove the inference time of the first few images, and then count the average time.GPU is slower than CPU to test a single image because the initialization of GPU is much slower than CPU. + +> > + +- Q: Can grayscale maps be used for model training? +- A: The grayscale image can also be used for model training, but the input shape of the model needs to be modified to `[1, 224, 224]`, and the data augmentation also needs to be adapted. However, for better use of the PaddleClas code, it is recommended to adapt the grayscale image to a 3-channel image for training (RGB channels have equal pixel values). + +> > + +- Q: How to train the model on windows or cpu? +- A: You can refer to [Getting Started Tutorial](../models_training/classification_en.md) for detailed tutorials on model training, evaluation and inference in Linux , Windows, CPU, and other environments. + +> > + +- Q: How to use label smoothing in model training? +- A: This can be set in the `Loss` field in the configuration file as follows. `epsilon=0.1` means set the value to 0.1, if the `epsilon` field is not set, then `label smoothing` will not be used. + +``` +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 +``` + +> > + +- Q: Is the 10W class image classification pre-training model provided by PaddleClas available for model inference? +- A: This 10W class image classification pre-training model does not provide parameters for the fc fully connected layer, which cannot be used for model inference but is available for model fine-tuning at present. + +> > + +- Q: Why is `Error: Pass tensorrt_subgraph_pass has not been registered` reported When using `deploy/python/predict_cls.py` for model prediction? +- A: If you want to use TensorRT for model prediction and inference, you need to install or compile PaddlePaddle with TensorRT by yourself. For Linux, Windows, macOS users, you can refer to [download inference library](https://paddleinference.paddlepaddle.org.cn/user_guides/download_lib.html). If there is no required version, you need to compile and install it locally, which is detailed in [source code compilation](https://paddleinference.paddlepaddle.org.cn/user_guides/source_compile.html). + +> > + +- Q: How to train with Automatic Mixed Precision (AMP) during training? +- A: You can refer to [ResNet50_fp16.yaml](../../../ppcls/configs/ImageNet/ResNet/ResNet50_fp16.yaml). Specifically, if you want your configuration file to support automatic mixed precision during model training, you can add the following information to the file. + +``` +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + use_pure_fp16: &use_pure_fp16 True +``` diff --git a/src/PaddleClas/docs/en/faq_series/index.rst b/src/PaddleClas/docs/en/faq_series/index.rst new file mode 100644 index 0000000..69a9f2d --- /dev/null +++ b/src/PaddleClas/docs/en/faq_series/index.rst @@ -0,0 +1,10 @@ +faq_series +================================ + +.. toctree:: + :maxdepth: 2 + + faq_2021_s2_en.md + faq_2021_s1_en.md + faq_2020_s1_en.md + faq_selected_30_en.md diff --git a/src/PaddleClas/docs/en/image_recognition_pipeline/feature_extraction_en.md b/src/PaddleClas/docs/en/image_recognition_pipeline/feature_extraction_en.md new file mode 100644 index 0000000..f86562a --- /dev/null +++ b/src/PaddleClas/docs/en/image_recognition_pipeline/feature_extraction_en.md @@ -0,0 +1,182 @@ +# Feature Extraction + +## Catalogue + +- [1.Introduction](#1) +- [2.Network Structure](#2) +- [3.General Recognition Models](#3) +- [4.Customized Feature Extraction](#4) + - [4.1 Data Preparation](#4.1) + - [4.2 Model Training](#4.2) + - [4.3 Model Evaluation](#4.3) + - [4.4 Model Inference](#4.4) + + +## 1.Introduction + +Feature extraction plays a key role in image recognition, which serves to transform the input image into a fixed dimensional feature vector for subsequent [vector search](./vector_search_en.md). Good features boast great similarity preservation, i.e., in the feature space, pairs of images with high similarity should have higher feature similarity (closer together), and pairs of images with low similarity should have less feature similarity (further apart). [Deep Metric Learning](../algorithm_introduction/metric_learning_en.md) is applied to explore how to obtain features with high representational power through deep learning. + + +## 2.Network Structure + +In order to customize the image recognition task flexibly, the whole network is divided into Backbone, Neck, Head, and Loss. The figure below illustrates the overall structure: + +![img](../../images/feature_extraction_framework_en.png) + +Functions of the above modules : + +- **Backbone**: Specifies the backbone network to be used. It is worth noting that the ImageNet-based pre-training model provided by PaddleClas has an output of 1000 for the last layer, which demands for customization according to the required feature dimensions. +- **Neck**: Used for feature augmentation and feature dimension transformation. Here it can be a simple Linear Layer for feature dimension transformation, or a more complex FPN structure for feature augmentation. +- **Head**: Used to transform features into logits. In addition to the common Fc Layer, cosmargin, arcmargin, circlemargin and other modules are all available choices. +- **Loss**: Specifies the Loss function to be used. It is designed as a combined form to facilitate the combination of Classification Loss and Pair_wise Loss. + + +## 3.General Recognition Models + +In PP-Shitu, we have [PP_LCNet_x2_5](../models/PP-LCNet.md) as the backbone network, Linear Layer for Neck, [ArcMargin](../../../ppcls/arch/gears/arcmargin.py) for Head, and CELoss for Loss. See the details in [General Recognition_configuration files](../../../ppcls/configs/GeneralRecognition/). The involved training data covers the following seven public datasets: + +| Datasets | Data Size | Class Number | Scenarios | URL | +| ------------ | --------- | ------------ | ------------------ | ------------------------------------------------------------ | +| Aliproduct | 2498771 | 50030 | Commodities | [URL](https://retailvisionworkshop.github.io/recognition_challenge_2020/) | +| GLDv2 | 1580470 | 81313 | Landmarks | [URL](https://github.com/cvdfoundation/google-landmark) | +| VeRI-Wild | 277797 | 30671 | Vehicle | [URL](https://github.com/PKU-IMRE/VERI-Wild) | +| LogoDet-3K | 155427 | 3000 | Logo | [URL](https://github.com/Wangjing1551/LogoDet-3K-Dataset) | +| iCartoonFace | 389678 | 5013 | Cartoon Characters | [URL](http://challenge.ai.iqiyi.com/detail?raceId=5def69ace9fcf68aef76a75d) | +| SOP | 59551 | 11318 | Commodities | [URL](https://cvgl.stanford.edu/projects/lifted_struct/) | +| Inshop | 25882 | 3997 | Commodities | [URL](http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion.html) | +| **Total** | **5M** | **185K** | ---- | ---- | + +The results are shown in the table below: + +| Model | Aliproduct | VeRI-Wild | LogoDet-3K | iCartoonFace | SOP | Inshop | Latency(ms) | +| ------------- | ---------- | --------- | ---------- | ------------ | ----- | ------ | ----------- | +| PP-LCNet-2.5x | 0.839 | 0.888 | 0.861 | 0.841 | 0.793 | 0.892 | 5.0 | + +- Evaluation metric: `Recall@1` +- CPU of the speed evaluation machine: `Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz`. +- Evaluation conditions for the speed metric: MKLDNN enabled, number of threads set to 10 +- Address of the pre-training model: [General recognition pre-training model](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/general_PPLCNet_x2_5_pretrained_v1.0.pdparams) + + +## 4.Customized Feature Extraction + +Customized feature extraction refers to retraining the feature extraction model based on one's own task. It consists of four main steps: 1) data preparation, 2) model training, 3) model evaluation, and 4) model inference. + + +### 4.1 Data Preparation + +To start with, customize your dataset based on the task (See [Format description](../data_preparation/recognition_dataset_en.md#1) for the dataset format). Before initiating the model training, modify the data-related content in the configuration files, including the address of the dataset and the class number. The corresponding locations in configuration files are shown below: + +``` + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 #Number of class +``` + +``` +Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ #The directory where the train dataset is located + cls_label_path: ./dataset/train_reg_all_data.txt #The address of label file for train dataset +``` + +``` + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/. #The directory where the query dataset is located + cls_label_path: ./dataset/Aliproduct/val_list.txt. #The address of label file for query dataset +``` + +``` + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ #The directory where the gallery dataset is located + cls_label_path: ./dataset/Aliproduct/val_list.txt. #The address of label file for gallery dataset +``` + + +### 4.2 Model Training + +- Single machine single card training + +``` +export CUDA_VISIBLE_DEVICES=0 +python tools/train.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml +``` + +- Single machine multi card training + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" tools/train.py \ + -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml +``` + +**Note:** The configuration file adopts `online evaluation` by default, if you want to speed up the training and remove `online evaluation`, just add `-o eval_during_train=False` after the above command. After training, the final model files `latest`, `best_model` and the training log file `train.log` will be generated under the directory output. Among them, `best_model` is utilized to store the best model under the current evaluation metrics while`latest` is adopted to store the latest generated model, making it convenient to resume the training from where it was interrupted. + +- Resumption of Training: + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" tools/train.py \ + -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ + -o Global.checkpoint="output/RecModel/latest" +``` + + +### 4.3 Model Evaluation + +- Single Card Evaluation + +``` +export CUDA_VISIBLE_DEVICES=0 +python tools/eval.py \ +-c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ +-o Global.pretrained_model="output/RecModel/best_model" +``` + +- Multi Card Evaluation + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" tools/eval.py \ + -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ + -o Global.pretrained_model="output/RecModel/best_model" +``` + +**Recommendation:** It is suggested to employ multi-card evaluation, which can quickly obtain the feature set of the overall dataset using multi-card parallel computing, accelerating the evaluation process. + + +### 4.4 Model Inference + +Two steps are included in the inference: 1)exporting the inference model; 2)obtaining the feature vector. + +#### 4.4.1 Export Inference Model + +``` +python tools/export_model.py \ +-c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ +-o Global.pretrained_model="output/RecModel/best_model" +``` + +The generated inference models are under the directory `inference`, which comprises three files, namely, `inference.pdmodel`、`inference.pdiparams`、`inference.pdiparams.info`. Among them, `inference.pdmodel` serves to store the structure of inference model while `inference.pdiparams` and `inference.pdiparams.info` are mobilized to store model-related parameters. + +#### 4.4.2 Obtain Feature Vector + +``` +cd deploy +python python/predict_rec.py \ +-c configs/inference_rec.yaml \ +-o Global.rec_inference_model_dir="../inference" +``` + +The output format of the obtained features is shown in the figure below:![img](../../images/feature_extraction_output.png) + +In practical use, however, business operations require more than simply obtaining features. To further perform image recognition by feature retrieval, please refer to the document [vector search](./vector_search_en.md). diff --git a/src/PaddleClas/docs/en/image_recognition_pipeline/index.rst b/src/PaddleClas/docs/en/image_recognition_pipeline/index.rst new file mode 100644 index 0000000..95aa67d --- /dev/null +++ b/src/PaddleClas/docs/en/image_recognition_pipeline/index.rst @@ -0,0 +1,9 @@ +image_recognition_pipeline +================================ + +.. toctree:: + :maxdepth: 2 + + mainbody_detection_en.md + feature_extraction_en.md + vector_search_en.md diff --git a/src/PaddleClas/docs/en/image_recognition_pipeline/mainbody_detection_en.md b/src/PaddleClas/docs/en/image_recognition_pipeline/mainbody_detection_en.md new file mode 100644 index 0000000..9ff310e --- /dev/null +++ b/src/PaddleClas/docs/en/image_recognition_pipeline/mainbody_detection_en.md @@ -0,0 +1,242 @@ +# Mainbody Detection + +The mainbody detection technology is currently a widely used detection technology, which refers to a whole image recognition process of identifying the coordinate position of one or more objects and then cropping down the corresponding area for recognition. Mainbody detection is the first step of the recognition task, which can effectively improve the recognition accuracy. + +This tutorial will introduce the technology from three aspects, namely, the datasets, model selection and model training. + +## Catalogue + +- [1. Dataset](#1) +- [2. Model Selection](#2) + - [2.1 Lightweight Mainbody Detection Model](#2.1) + - [2.2 Server-side Mainbody Detection Model](#2.2) +- [3. Model Training](#3) + - [3.1 Prepare For the Environment](#3.1) + - [3.2 Prepare For the Dataset](#3.2) + - [3.3 Configuration Files](#3.3) + - [3.4 Begin the Training Process](#3.4) + - [3.5 Model Prediction](#3.5) + - [3.6 Model Export and Inference Deployment](#3.6) + + + +## 1. Dataset + +The datasets we used for mainbody detection tasks are shown in the following table. + +| Dataset | Image Number | Image Number Used in Mainbody Detection | Scenarios | Dataset Link | +| ------------ | ------------ | --------------------------------------- | ----------------- | ---------------------------------------------------------- | +| Objects365 | 170W | 6k | General Scenarios | [Link](https://www.objects365.org/overview.html) | +| COCO2017 | 12W | 5k | General Scenarios | [Link](https://cocodataset.org/) | +| iCartoonFace | 2k | 2k | Cartoon Face | [Link](https://github.com/luxiangju-PersonAI/iCartoonFace) | +| LogoDet-3k | 3k | 2k | Logo | [Link](https://github.com/Wangjing1551/LogoDet-3K-Dataset) | +| RPC | 3k | 3k | Product | [Link](https://rpc-dataset.github.io/) | + +In the actual training process, all datasets are mixed together. Categories of all the labeled boxes are modified as `foreground`, and the detection model we trained only contains one category (`foreground`). + + + +## 2. Model Selection + +There are a wide variety of object detection methods, such as the commonly used two-stage detectors (FasterRCNN series, etc.), single-stage detectors (YOLO, SSD, etc.), anchor-free detectors (FCOS, etc.) and so on. PaddleDetection has its self-developed PP-YOLO models for server-side scenarios and PicoDet models for end-side scenarios (CPU and mobile), which all take the lead in the area. + +Build on the studies above, PaddleClas provides lightweight and server-side main body detection models for end-side scenarios and server-side scenarios respectively. The table below presents the average mAP of the 5 datasets and the comparison of their model sizes and inference speed. + +| Model | Model Structure | Download Link of Pre-trained Model | Download Link of Inference Model | mAP | Size of Inference Model (MB) | Inference Time per Image (preprocessing excluded)(ms) | +| ------------------------------------ | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ----- | ---------------------------- | ----------------------------------------------------- | +| Lightweight Mainbody Detection Model | PicoDet | [Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_pretrained.pdparams) | [Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar) | 40.1% | 30.1 | 29.8 | +| Server-side Mainbody Detection Model | PP-YOLOv2 | [Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/ppyolov2_r50vd_dcn_mainbody_v1.0_pretrained.pdparams) | [Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar) | 42.5% | 210.5 | 466.6 | + +Notes: + +- Detailed information of the CPU of the speed evaluation machine:`Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz`.The speed indicator is the testing result when mkldnn is on and the number of threads is set to 10. +- Mainbody detection has a time-consuming preprocessing procedure, with an average time of about 40 to 55 ms per image in the above machine. Therefore, it is not included in the inference time. + + + +### 2.1 Lightweight Mainbody Detection Model + +PicoDet, introduced by [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection), is an object detection algorithm applied to CPU or mobile-side scenarios. It integrates the following optimization algorithm. + +- [ATSS](https://arxiv.org/abs/1912.02424) +- [Generalized Focal Loss](https://arxiv.org/abs/2006.04388) +- Cosine learning rate decay +- Cycle-EMA +- Lightweight detection head + +For more details of optimized PicoDet and benchmark, you can refer to [Tutorials of PicoDet Models](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/picodet/README.md). + +To balance the detection speed and effects in lightweight mainbody detection tasks, we adopt PPLCNet_x2_5 as the backbone of the model and revise the image scale for training and inference to 640x640, with the rest configured the same as [picodet_m_shufflenetv2_416_coco.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/picodet/picodet_m_shufflenetv2_416_coco.yml). The final detection model is obtained after the training of customized mainbody detection datasets. + + + +### 2.2 Server-side Mainbody Detection Model + +PP-YOLO is proposed by [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection). It greatly optimizes the yolov3 model from multiple perspectives such as backbone, data augmentation, regularization strategy, loss function, and post-processing. It reaches the state of the art in terms of "speed-precision". The optimization strategy is as follows. + +- Better backbone: ResNet50vd-DCN +- Larger training batch size of 8 GPUs and mini-batch size of 24 on each GPU, which is corresponding to learning rate and the number of iterations. +- [Drop Block](https://arxiv.org/abs/1810.12890) +- [Exponential Moving Average](https://www.investopedia.com/terms/e/ema.asp) +- [IoU Loss](https://arxiv.org/pdf/1902.09630.pdf) +- [Grid Sensitive](https://arxiv.org/abs/2004.10934) +- [Matrix NMS](https://arxiv.org/pdf/2003.10152.pdf) +- [CoordConv](https://arxiv.org/abs/1807.03247) +- [Spatial Pyramid Pooling](https://arxiv.org/abs/1406.4729) +- Better Pre-trained Model + +For more information about PP-YOLO, you can refer to [PP-YOLO tutorial](https://github.com/PaddlePaddle/PaddleDetection/blob/release%2F2.1/configs/ppyolo/README.md). + +In the mainbody detection task, we use `ResNet50vd-DCN` as our backbone for better performance. The config file is [ppyolov2_r50vd_dcn_365e_coco.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml), in which the dataset path is modified to the customized mainbody detection dataset. The final detection model can be downloaded [here](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar). + + + +## 3. Model Training + +This section mainly talks about how to train your own mainbody detection model using PaddleDetection on your own datasets. + + + +### 3.1 Prepare For the Environment + +Download PaddleDetection and install requirements. + +```shell +cd +git clone https://github.com/PaddlePaddle/PaddleDetection.git + +cd PaddleDetection +# install requirements +pip install -r requirements.txt +``` + +For more installation tutorials, please refer to [Installation Tutorial](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/docs/tutorials/INSTALL.md) + + + +### 3.2 Prepare For the Dataset + +For customized dataset, you should convert it to COCO format. Please refer to [Customized Dataset Tutorial](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/static/docs/tutorials/Custom_DataSet.md) to build your own datasets with COCO format. + +In mainbody detection task, all the objects belong to foregroud. Therefore, `category_id` of all the objects in the annotation file should be modified to 1. And the `categories` map should be modified as follows, in which just class `foregroud` is included. + +``` +[{u'id': 1, u'name': u'foreground', u'supercategory': u'foreground'}] +``` + + + +### 3.3 Configuration Files + +We use `configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml` to train the model, mode details are as follows. + + [![img](../../images/det/PaddleDetection_config.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/det/PaddleDetection_config.png) + + + +`ppyolov2_r50vd_dcn_365e_coco.yml` depends on other configuration files, their meanings are as follows. + +``` +coco_detection.yml:path of train/eval/test dataset. + +runtime.yml:public runtime parameters, including whethre to use GPU, epoch number for checkpoint saving, etc. + +optimizer_365e.yml:learning rate and optimizer. + +ppyolov2_r50vd_dcn.yml:model architecture and backbone. + +ppyolov2_reader.yml:train/eval/test reader, such as batch size, the number of concurrently loaded sub-processes, etc., and includes post-read pre-processing operations, such as resize, data enhancement, etc. +``` + +In mainbody detection task, you need to modify `num_classes` in `datasets/coco_detection.yml` to 1 (only `foreground` is included), while modify the paths of the training and testing datasets to those of the customized datasets. + +In addition, the above files can also be modified according to real situations, for example, if the video memory is overflowing, the batch size and learning rate can be reduced in equal proportion. + + + +### 3.4 Begin the Training Process + +PaddleDetection supports many ways of training process. + +- Training using single GPU + +``` +# not needed for windows and Mac +export CUDA_VISIBLE_DEVICES=0 +python tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml +``` + +- Training using multiple GPUs + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --eval +``` + +--eval: evaluation while training + +- (**Recommend**) Model finetune If you want to finetune the trained model in PaddleClas on your own datasets, you can run the following command. + +``` +export CUDA_VISIBLE_DEVICES=0 +# assign pretrain_weights, load the general mainbody-detection pretrained model +python tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml -o pretrain_weights=https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/ppyolov2_r50vd_dcn_mainbody_v1.0_pretrained.pdparams +``` + +- Resume training + + you can use `-r` to load checkpoints and resume training. + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --eval -r output/ppyolov2_r50vd_dcn_365e_coco/10000 +``` + +Note: If `Out of memory error` occurs, you can try to decrease `batch_size` in `ppyolov2_reader.yml` while reducing learning rate in equal proportion. + + + +### 3.5 Model Prediction + +Use the following command to finish the prediction process. + +``` +export CUDA_VISIBLE_DEVICES=0 +python tools/infer.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --infer_img=your_image_path.jpg --output_dir=infer_output/ --draw_threshold=0.5 -o weights=output/ppyolov2_r50vd_dcn_365e_coco/model_final +``` + +`--draw_threshold` is an optional parameter. According to NMS calculation, different thresholds will produce different results. `keep_top_k` indicates the maximum number of output targets, with a default value of 100 that can be modified according to their actual situation. + + + +### 3.6 Model Export and Inference Deployment + +Use the following to export the inference model: + +``` +python tools/export_model.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --output_dir=./inference -o weights=output/ppyolov2_r50vd_dcn_365e_coco/model_final.pdparams +``` + +The inference model will be saved under the directory `inference/ppyolov2_r50vd_dcn_365e_coco`, which contains`infer_cfg.yml` (optional for mainbody detection), `model.pdiparams`, `model.pdiparams.info`, `model.pdmodel`. + +Note: Inference model that `PaddleDetection` exports is named `model.xxx`,if you want to keep it consistent with PaddleClas,you can rename `model.xxx` to `inference.xxx` for subsequent inference deployment of mainbody detection. + +For more model export tutorials, please refer to [EXPORT_MODEL](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/deploy/EXPORT_MODEL.md). + +The final directory contains `inference/ppyolov2_r50vd_dcn_365e_coco`, `inference.pdiparams`, `inference.pdiparams.info`, and `inference.pdmodel`,among which`inference.pdiparams` refers to saved weight files of the inference model while `inference.pdmodel` stands for structural files. + +After exporting the model, the path of the detection model can be changed to the inference model path to complete the prediction task. + +Take product recognition as an example,you can modify the field `Global.det_inference_model_dir` in its config file [inference_product.yaml](../../../deploy/configs/inference_product.yaml) to the directory of exported inference model, and then finish the detection and recognition of the product with reference to [Quick Start for Image Recognition](../quick_start/quick_start_recognition_en.md). + +## FAQ + +#### Q: Is it compatible with other mainbody detection models? + +- A: Yes, but the current preprocessing process only supports PicoDet and YOLO models, so it is recommended to use these two for training. If you want to use other models such as Faster RCNN, you need to revise the logic of preprocessing in accordance with that of PaddleDetection. You are welcomed to resort to Github Issue or WeChat group for any needs or questions. + +#### Q: Can I modify the prediction scale of mainbody detection? + +- A: Yes, but there are 2 things that require attention + - The mainbody detection model provided in PaddleClas is trained based on `640x640` resolution, so this is also the default value of prediction process. The accuracy will be reduced if other resolutions are used. + - When exporting the model, it is recommended to modify the resolution of the exported model to keep it consistent with the prediction process. diff --git a/src/PaddleClas/docs/en/image_recognition_pipeline/vector_search_en.md b/src/PaddleClas/docs/en/image_recognition_pipeline/vector_search_en.md new file mode 100644 index 0000000..9a6d545 --- /dev/null +++ b/src/PaddleClas/docs/en/image_recognition_pipeline/vector_search_en.md @@ -0,0 +1,120 @@ +# Vector Search + +Vector search finds wide applications in image recognition and image retrieval. It aims to obtain the similarity ranking for a given query vector by performing a similarity or distance calculation of feature vectors with all the vectors to be queried in an established vector library. In the image recognition system, [Faiss](https://github.com/facebookresearch/faiss) is adopted for corresponding support, please check [the official website of Faiss](https://github.com/facebookresearch/faiss) for more details. The main advantages of `Faiss` can be generalized as the following: + +- Great adaptability: support Windows, Linux, and MacOS systems +- Easy installation: support `python` interface and direct installation with `pip` +- Rich algorithms: support a variety of search algorithms to cover different scenarios +- Support both CPU and GPU, which accelerates the search process + +It is worth noting that the current version of `PaddleClas` **only uses CPU for vector retrieval** for the moment in pursuit of better adaptability. + +[![img](../../images/structure.jpg)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/structure.jpg) + +As shown in the figure above, two parts constitute the vector search in the whole `PP-ShiTu` system. + +- The green part: the establishment of search libraries for the search query, while providing functions such as adding and deleting images. +- The blue part: the search function, i.e., given the feature vector of a picture and return the label of similar images in the library. + +This document mainly introduces the installation of the search module in PaddleClas, the adopted search algorithms, the library building process, and the parameters in the relevant configuration files. + +------ + +## Catalogue + +- [1. Installation of the Search Library](#1) +- [2. Search Algorithms](#2) +- [3. Introduction of and Configuration Files](#3) + - [3.1 Parameters of Library Building and Configuration Files](#3.1) + - [3.2 Parameters of Search Configuration Files](#3.2) + + + +## 1. Installation of the Search Library + +`Faiss` can be installed as follows: + +``` +pip install faiss-cpu==1.7.1post2 +``` + +If the above cannot be properly used, please `uninstall` and then `install` again, especially when you are using`windows`. + + + +## 2. Search Algorithms + +Currently, the search module in `PaddleClas` supports the following three search algorithms: + +- **HNSW32**: A graph indexing method boasts high retrieval accuracy and fast speed. However, the feature library only supports the function of adding images, not deleting image features. (Default method) +- **IVF**: An inverted index search method with fast speed but slightly lower precision. The feature library supports functions of adding and deleting image features. +- **FLAT**: A violent search algorithm presenting the highest precision, but slower retrieval speed in face of large data volume. The feature library supports functions of adding and deleting image features. + +Each search algorithm can find its right place in different scenarios. `HNSW32`, as the default method, strikes a balance between accuracy and speed, see its detailed introduction in the [official document](https://github.com/facebookresearch/faiss/wiki). + + + +## 3. Introduction of Configuration Files + +Configuration files involving the search module are under `deploy/configs/`, where `build_*.yaml` is related to building the feature library, and `inference_*.yaml` is the inference file for retrieval or classification. + + + +### 3.1 Parameters of Library Building and Configuration Files + +The building of the library is detailed as follows: + +``` +# Enter deploy directory +cd deploy +# Change the yaml file to the specific one you need +python python/build_gallery.py -c configs/build_***.yaml +``` + +The `yaml` file is configured as follows for library building, please make necessary corrections to fit the real operation. The construction will extract the features of the images under `image_root` according to the image list in `data_file` and store them under `index_dir` for subsequent search. + +The `data_file` stores the path and label of the image file, with each line presenting the format `image_path label`. The intervals are spaced by the `delimiter` parameter in the `yaml` file. + +The specific model parameters for feature extraction can be found in the `yaml` file. + +``` +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + index_dir: "./recognition_demo_data_v1.1/gallery_product/index" + image_root: "./recognition_demo_data_v1.1/gallery_product/" + data_file: "./recognition_demo_data_v1.1/gallery_product/data_file.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 +``` + +- **index_method**: the search algorithm. It currently supports three, HNSW32, IVF, and Flat. +- **index_dir**: the folder where the built feature library is stored. +- **image_root**: the location of the folder where the annotated images needed to build the feature library are stored. +- **data_file**: the data list of the annotated images needed to build the feature library, the format of each line: relative_path label. +- **index_operation**: the operation to build a library: `new` for initiating an operation, `append` for adding the image feature of data_file to the feature library, `remove` for deleting the image of data_file from the feature library. +- **delimiter**: delimiter for each line in **data_file** +- **dist_type**: the method of similarity calculation adopted in feature matching. For example, Inner Product(`IP`) and Euclidean distance(`L2`). +- **embedding_size**: feature dimensionality + + + +### 3.2 Parameters of Search Configuration Files + +To integrate the search into the overall `PP-ShiTu` process, please refer to `The Introduction of PP-ShiTu Image Recognition System` in [README](../../../README_en.md). Please check the [Quick Start for Image Recognition](../quick_start/quick_start_recognition_en.md) for the specific operation of the search. + +The search part is configured as follows. Please refer to `deploy/configs/inference_*.yaml` for the complete version. + +``` +IndexProcess: + index_dir: "./recognition_demo_data_v1.1/gallery_logo/index/" + return_k: 5 + score_thres: 0.5 +``` + +The following are new parameters other than those of the library building configuration file: + +- `return_k`: `k` results are returned +- `score_thres`: the threshold for retrieval and match diff --git a/src/PaddleClas/docs/en/index.rst b/src/PaddleClas/docs/en/index.rst new file mode 100644 index 0000000..0bb50d3 --- /dev/null +++ b/src/PaddleClas/docs/en/index.rst @@ -0,0 +1,18 @@ +欢迎使用PaddleClas图像分类库! +================================ + +.. toctree:: + :maxdepth: 2 + + models_training/index + introduction/index + image_recognition_pipeline/index + others/index + faq_series/index + data_preparation/index + installation/index + models/index + advanced_tutorials/index + algorithm_introduction/index + inference_deployment/index + quick_start/index diff --git a/src/PaddleClas/docs/en/inference_deployment/cpp_deploy_en.md b/src/PaddleClas/docs/en/inference_deployment/cpp_deploy_en.md new file mode 100644 index 0000000..3f92b66 --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/cpp_deploy_en.md @@ -0,0 +1,298 @@ +# Server-side C++ inference + +This tutorial will introduce the detailed steps of deploying the PaddleClas classification model on the server side. The deployment of the recognition model will be supported in the near future. Please look forward to it. + +--- + +## Catalogue + +- [1. Prepare the environment](#1) + - [1.1 Compile OpenCV](#1.1) + - [1.2 Compile or download the Paddle Inference Library](#1.2) + - [1.2.1 Compile from the source code](#1.2.1) + - [1.2.2 Direct download and installation](#1.2.2) +- [2. Compile](#2) + - [2.1 Compile PaddleClas C++ inference demo](#2.1) + - [2.2 Compile config lib and cls lib](#2.2) +- [3. Run](#3) + - [3.1 Prepare inference model](#3.1) + - [3.2 Run demo](#3.2) + + +## 1. Prepare the environment + +### Environment + +- Linux, docker is recommended. +- Windows, compilation based on `Visual Studio 2019 Community` is supported. In addition, you can refer to [How to use PaddleDetection to make a complete project](https://zhuanlan.zhihu.com/p/145446681) to compile by generating the `sln solution`. +- This document mainly introduces the compilation and inference of PaddleClas using C++ in Linux environment. + + +### 1.1 Compile opencv + +* First of all, you need to download the source code compiled package in the Linux environment from the opencv official website. Taking opencv3.4.7 as an example, the download and uncompress command are as follows. + +``` +wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz +tar -xf 3.4.7.tar.gz +``` + +Finally, you can see the folder of `opencv-3.4.7/` in the current directory. + +* Compile opencv, the opencv source path (`root_path`) and installation path (`install_path`) should be set by yourself. Among them, `root_path` is the downloaded opencv source code path, and `install_path` is the installation path of opencv. In this case, the opencv source is `./opencv-3.4.7`. + +```shell +cd ./opencv-3.4.7 +export root_path=$PWD +export install_path=${root_path}/opencv3 +``` + +* After entering the opencv source code path, you can compile it in the following way. + + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + +make -j +make install +``` + +* After `make install` is completed, the opencv header file and library file will be generated in this folder for later PaddleClas source code compilation. + +Take opencv3.4.7 for example, the final file structure under the opencv installation path is as follows. **NOTICE**:The following file structure may be different for different Versions of Opencv. + +``` +opencv3/ +|-- bin +|-- include +|-- lib64 +|-- share +``` + + +### 1.2 Compile or download the Paddle Inference Library + +* There are 2 ways to obtain the Paddle Inference Library, described in detail below. + + +#### 1.2.1 Compile from the source code +* If you want to get the latest Paddle Inference Library features, you can download the latest code from Paddle GitHub repository and compile the inference library from the source code. +* You can refer to [Paddle Inference Library](https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code) to get the Paddle source code from github, and then compile To generate the latest inference library. The method of using git to access the code is as follows. + + +```shell +git clone https://github.com/PaddlePaddle/Paddle.git +``` + +* After entering the Paddle directory, the compilation method is as follows. + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DWITH_CONTRIB=OFF \ + -DWITH_MKL=ON \ + -DWITH_MKLDNN=ON \ + -DWITH_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_INFERENCE_API_TEST=OFF \ + -DON_INFER=ON \ + -DWITH_PYTHON=ON +make -j +make inference_lib_dist +``` + +For more compilation parameter options, please refer to the official website of the Paddle C++ inference library:[https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code](https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code). + + +* After the compilation process, you can see the following files in the folder of `build/paddle_inference_install_dir/`. + +``` +build/paddle_inference_install_dir/ +|-- CMakeCache.txt +|-- paddle +|-- third_party +|-- version.txt +``` + +Among them, `paddle` is the Paddle library required for C++ prediction later, and `version.txt` contains the version information of the current inference library. + + +#### 1.2.2 Direct download and installation + +* Different cuda versions of the Linux inference library (based on GCC 4.8.2) are provided on the +[Paddle Inference Library official website](https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html). You can view and select the appropriate version of the inference library on the official website. + +* Please select the `develop` version. + +* After downloading, use the following method to uncompress. + +``` +tar -xf paddle_inference.tgz +``` + +Finally you can see the following files in the folder of `paddle_inference/`. + + + +## 2. Compile + + +### 2.1 Compile PaddleClas C++ inference demo + + +* The compilation commands are as follows. The addresses of Paddle C++ inference library, opencv and other Dependencies need to be replaced with the actual addresses on your own machines. + +```shell +sh tools/build.sh +``` + +Specifically, the content in `tools/build.sh` is as follows. + +```shell +OPENCV_DIR=your_opencv_dir +LIB_DIR=your_paddle_inference_dir +CUDA_LIB_DIR=your_cuda_lib_dir +CUDNN_LIB_DIR=your_cudnn_lib_dir +TENSORRT_DIR=your_tensorrt_lib_dir + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DDEMO_NAME=clas_system \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DTENSORRT_DIR=${TENSORRT_DIR} \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + +make -j +``` + +In the above parameters of command: + +* `OPENCV_DIR` is the opencv installation path; + +* `LIB_DIR` is the download (`paddle_inference` folder) or the generated Paddle Inference Library path (`build/paddle_inference_install_dir` folder); + +* `CUDA_LIB_DIR` is the cuda library file path, in docker; it is `/usr/local/cuda/lib64`; + +* `CUDNN_LIB_DIR` is the cudnn library file path, in docker it is `/usr/lib/x86_64-linux-gnu/`. + +* `TENSORRT_DIR` is the tensorrt library file path,in dokcer it is `/usr/local/TensorRT6-cuda10.0-cudnn7/`,TensorRT is just enabled for GPU. + +After the compilation is completed, an executable file named `clas_system` will be generated in the `build` folder. + + +### 2.2 Compile config lib and cls lib + +In addition to compiling the demo directly, you can also compile only config lib and cls lib by running the following command: + +```shell +sh tools/build_lib.sh +``` + +The contents of the above command are as follows: + +```shell +OpenCV_DIR=path/to/opencv +PADDLE_LIB_DIR=path/to/paddle + +BUILD_DIR=./lib/build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DOpenCV_DIR=${OpenCV_DIR} \ + -DPADDLE_LIB=${PADDLE_LIB_DIR} \ + -DCMP_STATIC=ON \ + +make +``` + +The specific description of each compilation option is as follows: +* `DOpenCV_DIR`: The directory to the OpenCV compilation library. In this example, it is `opencv-3.4.7/opencv3/share/OpenCV`. Note that there needs to be a `OpenCVConfig.cmake` file under this directory; +* `DPADDLE_LIB`: The directory to the paddle prediction library which generally is the path of `paddle_inference` downloaded and decompressed or compiled, such as `build/paddle_inference_install_dir`. Note that there should be two subdirectories `paddle` and `third_party` in this directory; +* `DCMP_STATIC`: Whether to compile config lib and cls lib into static link library (`.a`). The default is `ON`. If you need to compile into dynamic link library (`.so`), please set it to `OFF`. + +After executing the above commands, the dynamic link libraries (`libcls.so` and `libconfig.so`) or static link libraries (`cls.a` and `libconfig.a`) of config lib and cls lib will be generated in the directory. In the [2.1 Compile PaddleClas C++ inference demo](#2.1), you can specify the compilation option `DCLS_LIB` and `DCONFIG_LIB` to the path of the existing link library of `cls lib` and `config lib`, which can also be used for development. + + + +## 3. Run the demo + + +### 3.1 Prepare the inference model + +* You can refer to [Model inference](../../../tools/export_model.py),export the inference model. After the model is exported, assuming it is placed in the `inference` directory, the directory structure is as follows. + +``` +inference/ +|--cls_infer.pdmodel +|--cls_infer.pdiparams +``` + +**NOTICE**: Among them, `cls_infer.pdmodel` file stores the model structure information and the `cls_infer.pdiparams` file stores the model parameter information.The paths of the two files need to correspond to the parameters of `cls_model_path` and `cls_params_path` in the configuration file `tools/config.txt`. + + +### 3.2 Run demo + +First, please modify the `tools/config.txt` and `tools/run.sh`. + +* Some key words in `tools/config.txt` is as follows. + * use_gpu: Whether to use GPU. + * gpu_id: GPU id. + * gpu_mem:GPU memory. + * cpu_math_library_num_threads:Number of thread for math library acceleration. + * use_mkldnn:Whether to use mkldnn. + * use_tensorrt: Whether to use tensorRT. + * use_fp16:Whether to use Float16 (half precision), it is just enabled when use_tensorrt is set as 1. + * cls_model_path: Model path of inference model. + * cls_params_path: Params path of inference model. + * resize_short_size:Short side length of the image after resize. + * crop_size:Image size after center crop. + +* You could modify `tools/run.sh`(`./build/clas_system ./tools/config.txt ./docs/imgs/ILSVRC2012_val_00000666.JPEG`): + * ./build/clas_system: the path of executable file compiled; + * ./tools/config.txt: the path of config; + * ./docs/imgs/ILSVRC2012_val_00000666.JPEG: the path of image file to be predicted. + +* Then execute the following command to complete the classification of an image. + +```shell +sh tools/run.sh +``` + +* The prediction results will be shown on the screen, which is as follows. + +![](../../images/inference_deployment/cpp_infer_result.png) + +* In the above results,`class id` represents the id corresponding to the category with the highest confidence, and `score` represents the probability that the image belongs to that category. diff --git a/src/PaddleClas/docs/en/inference_deployment/export_model_en.md b/src/PaddleClas/docs/en/inference_deployment/export_model_en.md new file mode 100644 index 0000000..8fe3c46 --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/export_model_en.md @@ -0,0 +1,103 @@ +# Export model + +PaddlePaddle supports exporting inference model for deployment. Compared with training, inference model files store network weights and network structures persistently, and PaddlePaddle supports more fast prediction engine loading inference model to deployment. + +--- + +## Catalogue + +- [1. Environmental preparation](#1) +- [2. Export classification model](#2) +- [3. Export mainbody detection model](#3) +- [4. Export recognition model](#4) +- [5. Parameter description](#5) + + + + +## 1. Environmental preparation + +First, refer to the [Installing PaddlePaddle](../installation/install_paddle_en.md) and the [Installing PaddleClas](../installation/install_paddleclas_en.md) to prepare environment. + + + +## 2. Export classification model + +Change the working directory to PaddleClas: + +```shell +cd /path/to/PaddleClas +``` + +Taking the classification model ResNet50_vd as an example, download the pre-trained model: + +```shell +wget -P ./cls_pretrain/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams +``` + +The above model weights is trained by ResNet50_vd model on ImageNet1k dataset and training configuration file is `ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml`. To export the inference model, just run the following command: + +```shell +python tools/export_model.py + -c ./ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml \ + -o Global.pretrained_model=./cls_pretrain/ResNet50_vd_pretrained \ + -o Global.save_inference_dir=./deploy/models/class_ResNet50_vd_ImageNet_infer +``` + + + +## 3. Export mainbody detection model + +About exporting mainbody detection model in details, please refer[mainbody detection](../image_recognition_pipeline/mainbody_detection_en.md). + + + +## 4. Export recognition model + +Change the working directory to PaddleClas: + +```shell +cd /path/to/PaddleClas +``` + +Take the feature extraction model in products recognition as an example, download the pretrained model: + +```shell +wget -P ./product_pretrain/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/product_ResNet50_vd_Aliproduct_v1.0_pretrained.pdparams +``` + +The above model weights file is trained by ResNet50_vd on AliProduct dataset, and the training configuration file is `ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml`. The command to export inference model is as follow: + +```shell +python3 tools/export_model.py \ + -c ./ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml \ + -o Global.pretrained_model=./product_pretrain/product_ResNet50_vd_Aliproduct_v1.0_pretrained \ + -o Global.save_inference_dir=./deploy/models/product_ResNet50_vd_aliproduct_v1.0_infer +``` + +Notice, the inference model exported by above command is truncated on embedding layer, so the output of the model is n-dimensional embedding feature. + + + +## 5. Parameter description + +In the above model export command, the configuration file used must be the same as the training configuration file. The following fields in the configuration file are used to configure exporting model parameters. + +* `Global.image_shape`:To specify the input data size of the model, which does not contain the batch dimension; +* `Global.save_inference_dir`:To specify directory of saving inference model files exported; +* `Global.pretrained_model`:To specify the path of model weight file saved during training. This path does not need to contain the suffix `.pdparams` of model weight file; + +The exporting model command will generate the following three files: + +* `inference.pdmodel`:To store model network structure information; +* `inference.pdiparams`:To store model network weight information; +* `inference.pdiparams.info`:To store the parameter information of the model, which can be ignored in the classification model and recognition model; + +The inference model exported is used to deployment by using prediction engine. You can refer the following docs according to different deployment modes / platforms + +* [Python inference](./python_deploy_en.md) +* [C++ inference](./cpp_deploy_en.md)(Only support classification) +* [Python Whl inference](./whl_deploy_en.md)(Only support classification) +* [PaddleHub Serving inference](./paddle_hub_serving_deploy_en.md)(Only support classification) +* [PaddleServing inference](./paddle_serving_deploy_en.md) +* [PaddleLite inference](./paddle_lite_deploy_en.md)(Only support classification) diff --git a/src/PaddleClas/docs/en/inference_deployment/index.rst b/src/PaddleClas/docs/en/inference_deployment/index.rst new file mode 100644 index 0000000..1e3c344 --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/index.rst @@ -0,0 +1,19 @@ +inference_deployment +================================ + +.. toctree:: + :maxdepth: 2 + + export_model_en.md + python_deploy_en.md + cpp_deploy_en.md + paddle_serving_deploy_en.md + paddle_hub_serving_deploy_en.md + paddle_lite_deploy_en.md + whl_deploy_en.md + + + + + + diff --git a/src/PaddleClas/docs/en/inference_deployment/paddle_hub_serving_deploy_en.md b/src/PaddleClas/docs/en/inference_deployment/paddle_hub_serving_deploy_en.md new file mode 100644 index 0000000..56e68fa --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/paddle_hub_serving_deploy_en.md @@ -0,0 +1,236 @@ +# Service deployment based on PaddleHub Serving + +PaddleClas supports rapid service deployment through Paddlehub. At present, it supports the deployment of image classification. Please look forward to the deployment of image recognition. + +--- + +## Catalogue + +- [1. Introduction](#1) +- [2. Prepare the environment](#2) +- [3. Download inference model](#3) +- [4. Install Service Module](#4) +- [5. Start service](#5) + - [5.1 Start with command line parameters](#5.1) + - [5.2 Start with configuration file](#5.2) +- [6. Send prediction requests](#6) +- [7. User defined service module modification](#7) + + +## 1. Introduction + +HubServing service pack contains 3 files, the directory is as follows: + +``` +hubserving/clas/ + └─ __init__.py Empty file, required + └─ config.json Configuration file, optional, passed in as a parameter when using configuration to start the service + └─ module.py Main module file, required, contains the complete logic of the service + └─ params.py Parameter file, required, including parameters such as model path, pre- and post-processing parameters +``` + + +## 2. Prepare the environment + +```shell +# Install version 2.0 of PaddleHub +pip3 install paddlehub==2.1.0 --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + + +## 3. Download inference model + +Before installing the service module, you need to prepare the inference model and put it in the correct path. The default model path is: + +* Model structure file: `PaddleClas/inference/inference.pdmodel` +* Model parameters file: `PaddleClas/inference/inference.pdiparams` + +**Notice**: +* The model file path can be viewed and modified in `PaddleClas/deploy/hubserving/clas/params.py`. +* It should be noted that the prefix of model structure file and model parameters file must be `inference`. +* More models provided by PaddleClas can be obtained from the [model library](../models/models_intro_en.md). You can also use models trained by yourself. + + +## 4. Install Service Module + +* On Linux platform, the examples are as follows. +```shell +cd PaddleClas/deploy +hub install hubserving/clas/ +``` + +* On Windows platform, the examples are as follows. +```shell +cd PaddleClas\deploy +hub install hubserving\clas\ +``` + + +## 5. Start service + + +### 5.1 Start with command line parameters + +This method only supports CPU. Command as follow: + +```shell +$ hub serving start --modules Module1==Version1 \ + --port XXXX \ + --use_multiprocess \ + --workers \ +``` + +**parameters:** + +|parameters|usage| +|-|-| +|--modules/-m|PaddleHub Serving pre-installed model, listed in the form of multiple Module==Version key-value pairs
*`When Version is not specified, the latest version is selected by default`*| +|--port/-p|Service port, default is 8866| +|--use_multiprocess|Enable concurrent mode, the default is single-process mode, this mode is recommended for multi-core CPU machines
*`Windows operating system only supports single-process mode`*| +|--workers|The number of concurrent tasks specified in concurrent mode, the default is `2*cpu_count-1`, where `cpu_count` is the number of CPU cores| + +For example, start service: + +```shell +hub serving start -m clas_system +``` + +This completes the deployment of a service API, using the default port number 8866. + + +### 5.2 Start with configuration file + +This method supports CPU and GPU. Command as follow: + +```shell +hub serving start --config/-c config.json +``` + +Wherein, the format of `config.json` is as follows: + +```json +{ + "modules_info": { + "clas_system": { + "init_args": { + "version": "1.0.0", + "use_gpu": true, + "enable_mkldnn": false + }, + "predict_args": { + } + } + }, + "port": 8866, + "use_multiprocess": false, + "workers": 2 +} +``` + +- The configurable parameters in `init_args` are consistent with the `_initialize` function interface in `module.py`. Among them, + - when `use_gpu` is `true`, it means that the GPU is used to start the service. + - when `enable_mkldnn` is `true`, it means that use MKL-DNN to accelerate. +- The configurable parameters in `predict_args` are consistent with the `predict` function interface in `module.py`. + +**Note:** +- When using the configuration file to start the service, other parameters will be ignored. +- If you use GPU prediction (that is, `use_gpu` is set to `true`), you need to set the environment variable CUDA_VISIBLE_DEVICES before starting the service, such as: ```export CUDA_VISIBLE_DEVICES=0```, otherwise you do not need to set it. +- **`use_gpu` and `use_multiprocess` cannot be `true` at the same time.** +- **When both `use_gpu` and `enable_mkldnn` are set to `true` at the same time, GPU is used to run and `enable_mkldnn` will be ignored.** + +For example, use GPU card No. 3 to start the 2-stage series service: + +```shell +cd PaddleClas/deploy +export CUDA_VISIBLE_DEVICES=3 +hub serving start -c hubserving/clas/config.json +``` + + +## 6. Send prediction requests + +After the service starting, you can use the following command to send a prediction request to obtain the prediction result: + +```shell +cd PaddleClas/deploy +python hubserving/test_hubserving.py server_url image_path +``` + +Two required parameters need to be passed to the script: + +- **server_url**: service address,format of which is +`http://[ip_address]:[port]/predict/[module_name]` +- **image_path**: Test image path, can be a single image path or an image directory path +- **batch_size**: [**Optional**] batch_size. Default by `1`. +- **resize_short**: [**Optional**] In preprocessing, resize according to short size. Default by `256`。 +- **crop_size**: [**Optional**] In preprocessing, centor crop size. Default by `224`。 +- **normalize**: [**Optional**] In preprocessing, whether to do `normalize`. Default by `True`。 +- **to_chw**: [**Optional**] In preprocessing, whether to transpose to `CHW`. Default by `True`。 + +**Notice**: +If you want to use `Transformer series models`, such as `DeiT_***_384`, `ViT_***_384`, etc., please pay attention to the input size of model, and need to set `--resize_short=384`, `--crop_size=384`. + +**Eg.** +```shell +python hubserving/test_hubserving.py --server_url http://127.0.0.1:8866/predict/clas_system --image_file ./hubserving/ILSVRC2012_val_00006666.JPEG --batch_size 8 +``` + +The returned result is a list, including the `top_k`'s classification results, corresponding scores and the time cost of prediction, details as follows. + +``` +list: The returned results +└─ list: The result of first picture + └─ list: The top-k classification results, sorted in descending order of score + └─ list: The scores corresponding to the top-k classification results, sorted in descending order of score + └─ float: The time cost of predicting the picture, unit second +``` + +**Note:** If you need to add, delete or modify the returned fields, you can modify the corresponding module. For the details, refer to the user-defined modification service module in the next section. + + +## 7. User defined service module modification + +If you need to modify the service logic, the following steps are generally required: + +1. Stop service +```shell +hub serving stop --port/-p XXXX +``` + +2. Modify the code in the corresponding files, like `module.py` and `params.py`, according to the actual needs. You need re-install(hub install hubserving/clas/) and re-deploy after modifing `module.py`. +After modifying and installing and before deploying, you can use `python hubserving/clas/module.py` to test the installed service module. + +For example, if you need to replace the model used by the deployed service, you need to modify model path parameters `cfg.model_file` and `cfg.params_file` in `params.py`. Of course, other related parameters may need to be modified at the same time. Please modify and debug according to the actual situation. + +3. Uninstall old service module +```shell +hub uninstall clas_system +``` + +4. Install modified service module +```shell +hub install hubserving/clas/ +``` + +5. Restart service +```shell +hub serving start -m clas_system +``` + +**Note**: + +Common parameters can be modified in params.py: +* Directory of model files(include model structure file and model parameters file): + ```python + "inference_model_dir": + ``` +* The number of Top-k results returned during post-processing: + ```python + 'topk': + ``` +* Mapping file corresponding to label and class ID during post-processing: + ```python + 'class_id_map_file': + ``` + +In order to avoid unnecessary delay and be able to predict in batch, the preprocessing (include resize, crop and other) is completed in the client, so modify [test_hubserving.py](../../../deploy/hubserving/test_hubserving.py#L35-L52) if necessary. diff --git a/src/PaddleClas/docs/en/inference_deployment/paddle_lite_deploy_en.md b/src/PaddleClas/docs/en/inference_deployment/paddle_lite_deploy_en.md new file mode 100644 index 0000000..12d45dd --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/paddle_lite_deploy_en.md @@ -0,0 +1,270 @@ +# Tutorial of PaddleClas Mobile Deployment + +This tutorial will introduce how to use [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) to deploy PaddleClas models on mobile phones. + +Paddle-Lite is a lightweight inference engine for PaddlePaddle. It provides efficient inference capabilities for mobile phones and IoTs, and extensively integrates cross-platform hardware to provide lightweight deployment solutions for mobile-side deployment issues. + +If you only want to test speed, please refer to [The tutorial of Paddle-Lite mobile-side benchmark test](../extension/paddle_mobile_inference_en.md). + +--- + +## Catalogue + +- [1. Preparation](#1) + - [1.1 Build Paddle-Lite library](#1.1) + - [1.2 Download inference library for Android or iOS](#1.2) +- [2. Start running](#2) + - [2.1 Inference Model Optimization](#2.1) + - [2.1.1 [RECOMMEND] Use pip to install Paddle-Lite and optimize model](#2.1.1) + - [2.1.2 Compile Paddle-Lite to generate opt tool](#2.1.2) + - [2.1.3 Demo of get the optimized model](#2.1.3) + - [2.2 Run optimized model on Phone](#2.2) +- [3. FAQ](#3) + + +## 1. Preparation + +PaddeLite currently supports the following platforms: +- Computer (for compiling Paddle-Lite) +- Mobile phone (arm7 or arm8) + + +### 1.1 Prepare cross-compilation environment + +The cross-compilation environment is used to compile the C++ demos of Paddle-Lite and PaddleClas. + +For the detailed compilation directions of different development environments, please refer to the corresponding [document](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html). + + +## 1.2 Download inference library for Android or iOS + +|Platform|Inference Library Download Link| +|-|-| +|Android|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv7.gcc.c++_static.with_extra.with_cv.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv8.gcc.c++_static.with_extra.with_cv.tar.gz)| +|iOS|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv7.with_cv.with_extra.tiny_publish.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv8.with_cv.with_extra.tiny_publish.tar.gz)| + +**NOTE**: + +1. If you download the inference library from [Paddle-Lite official document](https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#android-toolchain-gcc), please choose `with_extra=ON` , `with_cv=ON` . + +2. It is recommended to build inference library using [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) develop branch if you want to deploy the [quantitative](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/deploy/slim/quantization/README_en.md) model to mobile phones. Please refer to the [link](https://paddle-lite.readthedocs.io/zh/latest/user_guides/Compile/Android.html#id2) for more detailed information about compiling. + + +The structure of the inference library is as follows: + +``` +inference_lite_lib.android.armv8/ +|-- cxx C++ inference library and header files +| |-- include C++ header files +| | |-- paddle_api.h +| | |-- paddle_image_preprocess.h +| | |-- paddle_lite_factory_helper.h +| | |-- paddle_place.h +| | |-- paddle_use_kernels.h +| | |-- paddle_use_ops.h +| | `-- paddle_use_passes.h +| `-- lib C++ inference library +| |-- libpaddle_api_light_bundled.a C++ static library +| `-- libpaddle_light_api_shared.so C++ dynamic library +|-- java Java inference library +| |-- jar +| | `-- PaddlePredictor.jar +| |-- so +| | `-- libpaddle_lite_jni.so +| `-- src +|-- demo C++ and java demos +| |-- cxx C++ demos +| `-- java Java demos +``` + + +## 2. Start running + + +## 2.1 Inference Model Optimization + +Paddle-Lite provides a variety of strategies to automatically optimize the original training model, including quantization, sub-graph fusion, hybrid scheduling, Kernel optimization and so on. In order to make the optimization process more convenient and easy to use, Paddle-Lite provides `opt` tool to automatically complete the optimization steps and output a lightweight, optimal executable model. + +**NOTE**: If you have already got the `.nb` file, you can skip this step. + + +### 2.1.1 [RECOMMEND] Use `pip` to install Paddle-Lite and optimize model + +* Use pip to install Paddle-Lite. The following command uses `pip3.7` . + +```shell +pip install paddlelite==2.8 +``` +**Note**:The version of `paddlelite`'s wheel must match that of inference lib. + +* Use `paddle_lite_opt` to optimize inference model, the parameters of `paddle_lite_opt` are as follows: + +| Parameters | Explanation | +| ----------------------- | ------------------------------------------------------------ | +| --model_dir | Path to the PaddlePaddle model (no-combined) file to be optimized. | +| --model_file | Path to the net structure file of PaddlePaddle model (combined) to be optimized. | +| --param_file | Path to the net weight files of PaddlePaddle model (combined) to be optimized. | +| --optimize_out_type | Type of output model, `protobuf` by default. Supports `protobuf` and `naive_buffer` . Compared with `protobuf`, you can use`naive_buffer` to get a more lightweight serialization/deserialization model. If you need to predict on the mobile-side, please set it to `naive_buffer`. | +| --optimize_out | Path to output model, not needed to add `.nb` suffix. | +| --valid_targets | The executable backend of the model, `arm` by default. Supports one or some of `x86` , `arm` , `opencl` , `npu` , `xpu`. If set more than one, please separate the options by space, and the `opt` tool will choose the best way automatically. If need to support Huawei NPU (DaVinci core carried by Kirin 810/990 SoC), please set it to `npu arm` . | +| --record_tailoring_info | Whether to enable `Cut the Library Files According To the Model` , `false` by default. If need to record kernel and OP infos of optimized model, please set it to `true`. | + +In addition, you can run `paddle_lite_opt` to get more detailed information about how to use. + + +### 2.1.2 Compile Paddle-Lite to generate `opt` tool + +Optimizing model requires Paddle-Lite's `opt` executable file, which can be obtained by compiling the Paddle-Lite. The steps are as follows: + +```shell +# get the Paddle-Lite source code, if have gotten , please skip +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +git checkout develop +# compile +./lite/tools/build.sh build_optimize_tool +``` + +After the compilation is complete, the `opt` file is located under `build.opt/lite/api/`. + +`opt` tool is used in the same way as `paddle_lite_opt` , please refer to [2.1.1](#2.1.1). + + +### 2.1.3 Demo of get the optimized model + +Taking the `MobileNetV3_large_x1_0` model of PaddleClas as an example, we will introduce how to use `paddle_lite_opt` to complete the conversion from the pre-trained model to the inference model, and then to the Paddle-Lite optimized model. + +```shell +# enter PaddleClas root directory +cd PaddleClas_root_path + +# download and uncompress the inference model +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_infer.tar +tar -xf MobileNetV3_large_x1_0_infer.tar + + +# convert inference model to Paddle-Lite optimized model +paddle_lite_opt --model_file=./MobileNetV3_large_x1_0_infer/inference.pdmodel --param_file=./MobileNetV3_large_x1_0_infer/inference.pdiparams --optimize_out=./MobileNetV3_large_x1_0 +``` + +When the above code command is completed, there will be ``MobileNetV3_large_x1_0.nb` in the current directory, which is the converted model file. + + +## 2.2 Run optimized model on Phone + +1. Prepare an Android phone with `arm8`. If the compiled inference library and `opt` file are `armv7`, you need an `arm7` phone and modify `ARM_ABI = arm7` in the Makefile. + +2. Install the ADB tool on the computer. + + * Install ADB for MAC + + Recommend use homebrew to install. + + ```shell + brew cask install android-platform-tools + ``` + * Install ADB for Linux + + ```shell + sudo apt update + sudo apt install -y wget adb + ``` + * Install ADB for windows + If install ADB fo Windows, you need to download from Google's Android platform: [Download Link](https://developer.android.com/studio). + + First, make sure the phone is connected to the computer, turn on the `USB debugging` option of the phone, and select the `file transfer` mode. Verify whether ADB is installed successfully as follows: + + ```shell + $ adb devices + + List of devices attached + 744be294 device + ``` + + If there is `device` output like the above, it means the installation was successful. + +4. Prepare optimized model, inference library files, test image and dictionary file used. + +```shell +cd PaddleClas_root_path +cd deploy/lite/ + +# prepare.sh will put the inference library files, the test image and the dictionary files in demo/cxx/clas +sh prepare.sh /{lite inference library path}/inference_lite_lib.android.armv8 + +# enter the working directory of lite demo +cd /{lite inference library path}/inference_lite_lib.android.armv8/ +cd demo/cxx/clas/ + +# copy the C++ inference dynamic library file (ie. .so) to the debug folder +cp ../../../cxx/lib/libpaddle_light_api_shared.so ./debug/ +``` + +The `prepare.sh` take `PaddleClas/deploy/lite/imgs/tabby_cat.jpg` as the test image, and copy it to the `demo/cxx/clas/debug/` directory. + +You should put the model that optimized by `paddle_lite_opt` under the `demo/cxx/clas/debug/` directory. In this example, use `MobileNetV3_large_x1_0.nb` model file generated in [2.1.3](#2.1.3). + +The structure of the clas demo is as follows after the above command is completed: + +``` +demo/cxx/clas/ +|-- debug/ +| |--MobileNetV3_large_x1_0.nb class model +| |--tabby_cat.jpg test image +| |--imagenet1k_label_list.txt dictionary file +| |--libpaddle_light_api_shared.so C++ .so file +| |--config.txt config file +|-- config.txt config file +|-- image_classfication.cpp source code +|-- Makefile compile file +``` + +**NOTE**: + +* `Imagenet1k_label_list.txt` is the category mapping file of the `ImageNet1k` dataset. If use a custom category, you need to replace the category mapping file. +* `config.txt` contains the hyperparameters, as follows: + +```shell +clas_model_file ./MobileNetV3_large_x1_0.nb # path of model file +label_path ./imagenet1k_label_list.txt # path of category mapping file +resize_short_size 256 # the short side length after resize +crop_size 224 # side length used for inference after cropping + +visualize 0 # whether to visualize. If you set it to 1, an image file named 'clas_result.png' will be generated in the current directory. +``` + +5. Run Model on Phone + +```shell +# run compile to get the executable file 'clas_system' +make -j + +# move the compiled executable file to the debug folder +mv clas_system ./debug/ + +# push the debug folder to Phone +adb push debug /data/local/tmp/ + +adb shell +cd /data/local/tmp/debug +export LD_LIBRARY_PATH=/data/local/tmp/debug:$LD_LIBRARY_PATH + +# the usage of clas_system is as follows: +# ./clas_system "path of config file" "path of test image" +./clas_system ./config.txt ./tabby_cat.jpg +``` + +**NOTE**: If you make changes to the code, you need to recompile and repush the `debug ` folder to the phone. + +The result is as follows: + +![](../../images/inference_deployment/lite_demo_result.png) + + +## 3. FAQ + +Q1:If I want to change the model, do I need to go through the all process again? +A1:If you have completed the above steps, you only need to replace the `.nb` model file after replacing the model. At the same time, you may need to modify the path of `.nb` file in the config file and change the category mapping file to be compatible the model . + +Q2:How to change the test picture? +A2:Replace the test image under debug folder with the image you want to test,and then repush to the Phone again. diff --git a/src/PaddleClas/docs/en/inference_deployment/paddle_serving_deploy_en.md b/src/PaddleClas/docs/en/inference_deployment/paddle_serving_deploy_en.md new file mode 100644 index 0000000..7a60292 --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/paddle_serving_deploy_en.md @@ -0,0 +1,280 @@ +# Model Service Deployment + +## Catalogue + +- [1. Introduction](#1) +- [2. Installation of Serving](#2) +- [3. Service Deployment for Image Classification](#3) + - [3.1 Model Transformation](#3.1) + - [3.2 Service Deployment and Request](#3.2) +- [4. Service Deployment for Image Recognition](#4) + - [4.1 Model Transformation](#4.1) + - [4.2 Service Deployment and Request](#4.2) +- [5. FAQ](#5) + + +## 1. Introduction + +[Paddle Serving](https://github.com/PaddlePaddle/Serving) is designed to provide easy deployment of on-line prediction services for deep learning developers, it supports one-click deployment of industrial-grade services, highly concurrent and efficient communication between client and server, and multiple programming languages for client development. + +This section, exemplified by HTTP deployment of prediction service, describes how to deploy model services in PaddleClas with PaddleServing. Currently, only deployment on Linux platform is supported. Windows platform is not supported. + + +## 2. Installation of Serving + +It is officially recommended to use docker for the installation and environment deployment of Serving. First, pull the docker and create a Serving-based one. + +``` +docker pull paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel +nvidia-docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel bash +nvidia-docker exec -it test bash +``` + +Once you are in docker, install the Serving-related python packages. + +``` +pip3 install paddle-serving-client==0.7.0 +pip3 install paddle-serving-server==0.7.0 # CPU +pip3 install paddle-serving-app==0.7.0 +pip3 install paddle-serving-server-gpu==0.7.0.post102 #GPU with CUDA10.2 + TensorRT6 +# For other GPU environemnt, confirm the environment before choosing which one to execute +pip3 install paddle-serving-server-gpu==0.7.0.post101 # GPU with CUDA10.1 + TensorRT6 +pip3 install paddle-serving-server-gpu==0.7.0.post112 # GPU with CUDA11.2 + TensorRT8 +``` + +- Speed up the installation process by replacing the source with `-i https://pypi.tuna.tsinghua.edu.cn/simple`. +- For other environment configuration and installation, please refer to [Install Paddle Serving using docker](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Install_EN.md) +- To deploy CPU services, please install the CPU version of serving-server with the following command. + +``` +pip install paddle-serving-server +``` + + +## 3. Service Deployment for Image Classification + + +### 3.1 Model Transformation + +When adopting PaddleServing for service deployment, the saved inference model needs to be converted to a Serving model. The following part takes the classic ResNet50_vd model as an example to introduce the deployment of image classification service. + +- Enter the working directory: + +``` +cd deploy/paddleserving +``` + +- Download the inference model of ResNet50_vd: + +``` +# Download and decompress the ResNet50_vd model +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar +``` + +- Convert the downloaded inference model into a format that is readily deployable by Server with the help of paddle_serving_client. + +``` +# Convert the ResNet50_vd model +python3 -m paddle_serving_client.convert --dirname ./ResNet50_vd_infer/ \ + --model_filename inference.pdmodel \ + --params_filename inference.pdiparams \ + --serving_server ./ResNet50_vd_serving/ \ + --serving_client ./ResNet50_vd_client/ +``` + +After the transformation, `ResNet50_vd_serving` and `ResNet50_vd_client` will be added to the current folder in the following format: + +``` +|- ResNet50_vd_server/ + |- __model__ + |- __params__ + |- serving_server_conf.prototxt + |- serving_server_conf.stream.prototxt +|- ResNet50_vd_client + |- serving_client_conf.prototxt + |- serving_client_conf.stream.prototxt +``` + +Having obtained the model file, modify the alias name in `serving_server_conf.prototxt` under directory `ResNet50_vd_server` by changing `alias_name` in `fetch_var` to `prediction`. + +**Notes**: Serving supports input and output renaming to ensure its compatibility with the deployment of different models. In this case, modifying the alias_name of the configuration file is the only step needed to complete the inference and deployment of all kinds of models. The modified serving_server_conf.prototxt is shown below: + +``` +feed_var { + name: "inputs" + alias_name: "inputs" + is_lod_tensor: false + feed_type: 1 + shape: 3 + shape: 224 + shape: 224 +} +fetch_var { + name: "save_infer_model/scale_0.tmp_1" + alias_name: "prediction" + is_lod_tensor: true + fetch_type: 1 + shape: -1 +} +``` + + +### 3.2 Service Deployment and Request + +Paddleserving's directory contains the code to start the pipeline service and send prediction requests, including: + +``` +__init__.py +config.yml # Configuration file for starting the service +pipeline_http_client.py # Script for sending pipeline prediction requests by http +pipeline_rpc_client.py # Script for sending pipeline prediction requests by rpc +classification_web_service.py # Script for starting the pipeline server +``` + +- Start the service: + +``` +# Start the service and the run log is saved in log.txt +python3 classification_web_service.py &>log.txt & +``` + +Once the service is successfully started, a log will be printed in log.txt similar to the following ![img](../../../deploy/paddleserving/imgs/start_server.png) + +- Send request: + +``` +# Send service request +python3 pipeline_http_client.py +``` + +Once the service is successfully started, the prediction results will be printed in the cmd window, see the following example:![img](../../../deploy/paddleserving/imgs/results.png) + + + +## 4. Service Deployment for Image Recognition + +When using PaddleServing for service deployment, the saved inference model needs to be converted to a Serving model. The following part, exemplified by the ultra-lightweight model for image recognition in PP-ShiTu, details the deployment of image recognition service. + + + +## 4.1 Model Transformation + +- Download inference models for general detection and general recognition + +``` +cd deploy +# Download and decompress general recogntion models +wget -P models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar +cd models +tar -xf general_PPLCNet_x2_5_lite_v1.0_infer.tar +# Download and decompress general detection models +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar +tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar +``` + +- Convert the inference model for recognition into a Serving model: + +``` +# Convert the recognition model +python3 -m paddle_serving_client.convert --dirname ./general_PPLCNet_x2_5_lite_v1.0_infer/ \ + --model_filename inference.pdmodel \ + --params_filename inference.pdiparams \ + --serving_server ./general_PPLCNet_x2_5_lite_v1.0_serving/ \ + --serving_client ./general_PPLCNet_x2_5_lite_v1.0_client/ +``` + +After the transformation, `general_PPLCNet_x2_5_lite_v1.0_serving/` and `general_PPLCNet_x2_5_lite_v1.0_serving/` will be added to the current folder. Modify the alias name in serving_server_conf.prototxt under the directory `general_PPLCNet_x2_5_lite_v1.0_serving/` by changing `alias_name` to `features` in `fetch_var`. The modified serving_server_conf.prototxt is similar to the following: + +``` +feed_var { + name: "x" + alias_name: "x" + is_lod_tensor: false + feed_type: 1 + shape: 3 + shape: 224 + shape: 224 +} +fetch_var { + name: "save_infer_model/scale_0.tmp_1" + alias_name: "features" + is_lod_tensor: true + fetch_type: 1 + shape: -1 +} +``` + +- Convert the inference model for detection into a Serving model: + +``` +# Convert the general detection model +python3 -m paddle_serving_client.convert --dirname ./picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/ \ + --model_filename inference.pdmodel \ + --params_filename inference.pdiparams \ + --serving_server ./picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/ \ + --serving_client ./picodet_PPLCNet_x2_5_mainbody_lite_v1.0_client/ +``` + +After the transformation, `picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/` and `picodet_PPLCNet_x2_5_ mainbody_lite_v1.0_client/` will be added to the current folder. + +**Note:** The alias name in the serving_server_conf.prototxt under the directory`picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/` requires no modification. + +- Download and decompress the constructed search library index + +``` +cd ../ +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar && tar -xf drink_dataset_v1.0.tar +``` + + +## 4.2 Service Deployment and Request + +**Note:** Since the recognition service involves multiple models, PipeLine is adopted for better performance. This deployment method does not support the windows platform for now. + +- Enter the working directory + +``` +cd ./deploy/paddleserving/recognition +``` + +Paddleserving's directory contains the code to start the pipeline service and send prediction requests, including: + +``` +__init__.py +config.yml # Configuration file for starting the service +pipeline_http_client.py # Script for sending pipeline prediction requests by http +pipeline_rpc_client.py # Script for sending pipeline prediction requests by rpc +recognition_web_service.py # Script for starting the pipeline server +``` + +- Start the service: + +``` +# Start the service and the run log is saved in log.txt +python3 recognition_web_service.py &>log.txt & +``` + +Once the service is successfully started, a log will be printed in log.txt similar to the following ![img](../../../deploy/paddleserving/imgs/start_server_shitu.png) + +- Send request: + +``` +python3 pipeline_http_client.py +``` + +Once the service is successfully started, the prediction results will be printed in the cmd window, see the following example: ![img](../../../deploy/paddleserving/imgs/results_shitu.png) + + + +## 5.FAQ + +**Q1**: After sending a request, no result is returned or the output is prompted with a decoding error. + +**A1**: Please turn off the proxy before starting the service and sending requests, try the following command: + +``` +unset https_proxy +unset http_proxy +``` + +For more types of service deployment, such as `RPC prediction services`, you can refer to the [github official website](https://github.com/PaddlePaddle/Serving/tree/v0.7.0/examples) of Serving. diff --git a/src/PaddleClas/docs/en/inference_deployment/python_deploy_en.md b/src/PaddleClas/docs/en/inference_deployment/python_deploy_en.md new file mode 100644 index 0000000..22dd4e6 --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/python_deploy_en.md @@ -0,0 +1,142 @@ +# Infering based on Python prediction engine + +The inference model (the model saved by `paddle.jit.save`) is generally a solidified model saved after the model training is completed, and is mostly used to give prediction in deployment. + +The model saved during the training process is the checkpoints model, which saves the parameters of the model and is mostly used to resume training. + +Compared with the checkpoints model, the inference model will additionally save the structural information of the model. Therefore, it is easier to deploy because the model structure and model parameters are already solidified in the inference model file, and is suitable for integration with actual systems. + +Please refer to the document [install paddle](../installation/install_paddle_en.md) and [install paddleclas](../installation/install_paddleclas_en.md) to prepare the environment. + +--- + +## Catalogue + +- [1. Image classification inference](#1) +- [2. Mainbody detection model inference](#2) +- [3. Feature Extraction model inference](#3) +- [4. Concatenation of mainbody detection, feature extraction and vector search](#4) + + + +## 1. Image classification inference + +First, please refer to the document [export model](./export_model_en.md) to prepare the inference model files. All the command should be run under `deploy` folder of PaddleClas: + +```shell +cd deploy +``` + +For classification model inference, you can execute the following commands: + +```shell +python python/predict_cls.py -c configs/inference_cls.yaml +``` + +In the configuration file `configs/inference_cls.yaml`, the following fields are used to configure prediction parameters: +* `Global.infer_imgs`: The path of image to be predicted; +* `Global.inference_model_dir`: The directory of inference model files. There should be contain the model files (`inference.pdmodel` and `inference.pdiparams`); +* `Global.use_tensorrt`: Whether use `TensorRT`, `False` by default; +* `Global.use_gpu`: Whether use GPU, `True` by default; +* `Global.enable_mkldnn`: Whether use `MKL-DNN`, `False` by default. Valid only when `use_gpu` is `False`; +* `Global.use_fp16`: Whether use `FP16`, `False` by default; +* `PreProcess`: To config the preprocessing of image to be predicted; +* `PostProcess`: To config the postprocessing of prediction results; +* `PostProcess.Topk.class_id_map_file`: The path of file mapping label and class id. By default ImageNet1k (`./utils/imagenet1k_label_list.txt`). + +**Notice**: +* If VisionTransformer series models used, such as `DeiT_***_384`, `ViT_***_384`, please notice the size of model input. And you could need to specify the `PreProcess.resize_short=384`, `PreProcess.resize=384`. +* If you want to improve the speed of the evaluation, it is recommended to enable TensorRT when using GPU, and MKL-DNN when using CPU. + +```shell +python python/predict_cls.py -c configs/inference_cls.yaml -o Global.infer_imgs=images/ILSVRC2012_val_00010010.jpeg +``` + +If you want to use the CPU for prediction, you can switch value of `use_gpu` in config file to `False`. Or you can execute the command as follows +``` +python python/predict_cls.py -c configs/inference_cls.yaml -o Global.use_gpu=False +``` + + +## 2. Mainbody detection model inference + +The following will introduce the mainbody detection model inference. All the command should be run under `deploy` folder of PaddleClas: + +```shell +cd deploy +``` + +For mainbody detection model inference, you can execute the following commands: + +```shell +mkdir -p models +cd models +# download mainbody detection inference model +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar && tar -xf ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar +cd .. +# predict +python python/predict_det.py -c configs/inference_det.yaml +``` + +The input example image is as follows: +[](../images/recognition/product_demo/wangzai.jpg) + +The output will be: + +```text +[{'class_id': 0, 'score': 0.4762245, 'bbox': array([305.55115, 226.05322, 776.61084, 930.42395], dtype=float32), 'label_name': 'foreground'}] +``` + +And the visualise result is as follows: +[](../images/recognition/product_demo/wangzai_det_result.jpg) + +If you want to detect another image, you can change the value of `infer_imgs` in `configs/inference_det.yaml`, +or you can use `-o Global.infer_imgs` argument. For example, if you want to detect `images/anmuxi.jpg`: + +```shell +python python/predict_det.py -c configs/inference_det.yaml -o Global.infer_imgs=images/anmuxi.jpg +``` + +If you want to use the CPU for prediction, you can switch value of `use_gpu` in config file to `False`. Or you can execute the command as follows +``` +python python/predict_det.py -c configs/inference_det.yaml -o Global.use_gpu=False +``` + + +## 3. Feature Extraction model inference + +First, please refer to the document [export model](./export_model_en.md) to prepare the inference model files. All the command should be run under `deploy` folder of PaddleClas: + +```shell +cd deploy +``` + +For feature extraction model inference, you can execute the following commands: + +```shell +mkdir -p models +cd models +# download feature extraction inference model +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_aliproduct_v1.0_infer.tar && tar -xf product_ResNet50_vd_aliproduct_v1.0_infer.tar +cd .. +# predict +python python/predict_rec.py -c configs/inference_rec.yaml +``` +You can get a 512-dim feature printed in the command line. + +If you want to extract feature of another image, you can change the value of `infer_imgs` in `configs/inference_rec.yaml`, +or you can use `-o Global.infer_imgs` argument. For example, if you want to try `images/anmuxi.jpg`: + +```shell +python python/predict_rec.py -c configs/inference_rec.yaml -o Global.infer_imgs=images/anmuxi.jpg +``` + +If you want to use the CPU for prediction, you can switch value of `use_gpu` in config file to `False`. Or you can execute the command as follows + +``` +python python/predict_rec.py -c configs/inference_rec.yaml -o Global.use_gpu=False +``` + + +## 4. Concatenation of mainbody detection, feature extraction and vector search + Please refer to [Quick Start of Recognition](../quick_start/quick_start_recognition_en.md) diff --git a/src/PaddleClas/docs/en/inference_deployment/whl_deploy_en.md b/src/PaddleClas/docs/en/inference_deployment/whl_deploy_en.md new file mode 100644 index 0000000..224d41a --- /dev/null +++ b/src/PaddleClas/docs/en/inference_deployment/whl_deploy_en.md @@ -0,0 +1,256 @@ +# PaddleClas wheel package + +Paddleclas supports Python WHL package for prediction. At present, WHL package only supports image classification, but does not support subject detection, feature extraction and vector retrieval. + +--- + +## Catalogue + +- [1. Installation](#1) +- [2. Quick Start](#2) +- [3. Definition of Parameters](#3) +- [4. Usage](#4) + - [4.1 View help information](#4.1) + - [4.2 Prediction using inference model provide by PaddleClas](#4.2) + - [4.3 Prediction using local model files](#4.3) + - [4.4 Prediction by batch](#4.4) + - [4.5 Prediction of Internet image](#4.5) + - [4.6 Prediction of `NumPy.array` format image](#4.6) + - [4.7 Save the prediction result(s)](#4.7) + - [4.8 Specify the mapping between class id and label name](#4.8) + + +## 1. Installation + +* installing from pypi + +```bash +pip3 install paddleclas==2.2.1 +``` + +* build own whl package and install + +```bash +python3 setup.py bdist_wheel +pip3 install dist/* +``` + + +## 2. Quick Start +* Using the `ResNet50` model provided by PaddleClas, the following image(`'docs/images/inference_deployment/whl_demo.jpg'`) as an example. + +![](../../images/inference_deployment/whl_demo.jpg) + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs='docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +**Note**: `PaddleClas.predict()` is a `generator`. Therefore you need to use `next()` or `for` call it iteratively. It will perform a prediction by `batch_size` and return the prediction result(s) when called. Examples of returned results are as follows: + +``` +>>> result +[{'class_ids': [8, 7, 136, 80, 84], 'scores': [0.79368, 0.16329, 0.01853, 0.00959, 0.00239], 'label_names': ['hen', 'cock', 'European gallinule, Porphyrio porphyrio', 'black grouse', 'peacock']}] +``` + +* CLI +```bash +paddleclas --model_name=ResNet50 --infer_imgs="docs/images/inference_deployment/whl_demo.jpg" +``` + +``` +>>> result +filename: docs/images/inference_deployment/whl_demo.jpg, top-5, class_ids: [8, 7, 136, 80, 84], scores: [0.79368, 0.16329, 0.01853, 0.00959, 0.00239], label_names: ['hen', 'cock', 'European gallinule, Porphyrio porphyrio', 'black grouse', 'peacock'] +Predict complete! +``` + + +## 3. Definition of Parameters + +The following parameters can be specified in Command Line or used as parameters of the constructor when instantiating the PaddleClas object in Python. +* model_name(str): If using inference model based on ImageNet1k provided by Paddle, please specify the model's name by the parameter. +* inference_model_dir(str): Local model files directory, which is valid when `model_name` is not specified. The directory should contain `inference.pdmodel` and `inference.pdiparams`. +* infer_imgs(str): The path of image to be predicted, or the directory containing the image files, or the URL of the image from Internet. +* use_gpu(bool): Whether to use GPU or not, default by `True`. +* gpu_mem(int): GPU memory usages,default by `8000`。 +* use_tensorrt(bool): Whether to open TensorRT or not. Using it can greatly promote predict preformance, default by `False`. +* enable_mkldnn(bool): Whether enable MKLDNN or not, default `False`. +* cpu_num_threads(int): Assign number of cpu threads, valid when `--use_gpu` is `False` and `--enable_mkldnn` is `True`, default by `10`. +* batch_size(int): Batch size, default by `1`. +* resize_short(int): Resize the minima between height and width into `resize_short`, default by `256`. +* crop_size(int): Center crop image to `crop_size`, default by `224`. +* topk(int): Print (return) the `topk` prediction results, default by `5`. +* class_id_map_file(str): The mapping file between class ID and label, default by `ImageNet1K` dataset's mapping. +* pre_label_image(bool): whether prelabel or not, default=False. +* save_dir(str): The directory to save the prediction results that can be used as pre-label, default by `None`, that is, not to save. + +**Note**: If you want to use `Transformer series models`, such as `DeiT_***_384`, `ViT_***_384`, etc., please pay attention to the input size of model, and need to set `resize_short=384`, `resize=384`. The following is a demo. + +* CLI: +```bash +from paddleclas import PaddleClas, get_default_confg +paddleclas --model_name=ViT_base_patch16_384 --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' --resize_short=384 --crop_size=384 +``` + +* Python: +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ViT_base_patch16_384', resize_short=384, crop_size=384) +``` + + +## 4. Usage + +PaddleClas provides two ways to use: +1. Python interative programming; +2. Bash command line programming. + + +### 4.1 View help information + +* CLI +```bash +paddleclas -h +``` + + +### 4.2 Prediction using inference model provide by PaddleClas +You can use the inference model provided by PaddleClas to predict, and only need to specify `model_name`. In this case, PaddleClas will automatically download files of specified model and save them in the directory `~/.paddleclas/`. + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs = 'docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' +``` + + +### 4.3 Prediction using local model files +You can use the local model files trained by yourself to predict, and only need to specify `inference_model_dir`. Note that the directory must contain `inference.pdmodel` and `inference.pdiparams`. + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(inference_model_dir='./inference/') +infer_imgs = 'docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --inference_model_dir='./inference/' --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' +``` + + +### 4.4 Prediction by batch +You can predict by batch, only need to specify `batch_size` when `infer_imgs` is direcotry contain image files. + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50', batch_size=2) +infer_imgs = 'docs/images/' +result=clas.predict(infer_imgs) +for r in result: + print(r) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/' --batch_size 2 +``` + + +### 4.5 Prediction of Internet image +You can predict the Internet image, only need to specify URL of Internet image by `infer_imgs`. In this case, the image file will be downloaded and saved in the directory `~/.paddleclas/images/`. + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs = 'https://raw.githubusercontent.com/paddlepaddle/paddleclas/release/2.2/docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='https://raw.githubusercontent.com/paddlepaddle/paddleclas/release/2.2/docs/images/inference_deployment/whl_demo.jpg' +``` + + +### 4.6 Prediction of NumPy.array format image +In Python code, you can predict the `NumPy.array` format image, only need to use the `infer_imgs` to transfer variable of image data. Note that the models in PaddleClas only support to predict 3 channels image data, and channels order is `RGB`. + +* python +```python +import cv2 +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs = cv2.imread("docs/en/inference_deployment/whl_deploy_en.md")[:, :, ::-1] +result=clas.predict(infer_imgs) +print(next(result)) +``` + + +### 4.7 Save the prediction result(s) +You can save the prediction result(s) as pre-label, only need to use `pre_label_out_dir` to specify the directory to save. + +* python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50', save_dir='./output_pre_label/') +infer_imgs = 'docs/images/inference_deployment/whl_' # it can be infer_imgs folder path which contains all of images you want to predict. +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/inference_deployment/whl_' --save_dir='./output_pre_label/' +``` + + +### 4.8 Specify the mapping between class id and label name +You can specify the mapping between class id and label name, only need to use `class_id_map_file` to specify the mapping file. PaddleClas uses ImageNet1K's mapping by default. + +The content format of mapping file shall be: + +``` +class_idclass_name<\n> +``` + +For example: + +``` +0 tench, Tinca tinca +1 goldfish, Carassius auratus +2 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias +...... +``` + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50', class_id_map_file='./ppcls/utils/imagenet1k_label_list.txt') +infer_imgs = 'docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' --class_id_map_file='./ppcls/utils/imagenet1k_label_list.txt' +``` diff --git a/src/PaddleClas/docs/en/installation/index.rst b/src/PaddleClas/docs/en/installation/index.rst new file mode 100644 index 0000000..39d432a --- /dev/null +++ b/src/PaddleClas/docs/en/installation/index.rst @@ -0,0 +1,8 @@ +installation +================================ + +.. toctree:: + :maxdepth: 2 + + install_paddle_en.md + install_paddleclas_en.md diff --git a/src/PaddleClas/docs/en/installation/install_paddle_en.md b/src/PaddleClas/docs/en/installation/install_paddle_en.md new file mode 100644 index 0000000..c282f3e --- /dev/null +++ b/src/PaddleClas/docs/en/installation/install_paddle_en.md @@ -0,0 +1,100 @@ +# Install PaddlePaddle + +--- + +## Catalogue + +- [1. Environment requirements](#1) +- [2.(Recommended) Prepare a docker environment](#2) +- [3. Install PaddlePaddle using pip](#3) +- [4. Verify installation](#4) + +At present, **PaddleClas** requires **PaddlePaddle** version `>=2.0`. Docker is recomended to run Paddleclas, for more detailed information about docker and nvidia-docker, you can refer to the [tutorial](https://docs.docker.com/get-started/). If you do not want to use docker, you can skip section [2. (Recommended) Prepare a docker environment](#2), and go into section [3. Install PaddlePaddle using pip](#3). + + + +## 1. Environment requirements + +- python 3.x +- cuda >= 10.1 (necessary if paddlepaddle-gpu is used) +- cudnn >= 7.6.4 (necessary if paddlepaddle-gpu is used) +- nccl >= 2.1.2 (necessary distributed training/eval is used) +- gcc >= 8.2 + +**Recomends**: +* When CUDA version is 10.1, the driver version `>= 418.39`; +* When CUDA version is 10.2, the driver version `>= 440.33`; +* For more CUDA versions and specific driver versions, please refer to [link](https://docs.nvidia.com/deploy/cuda-compatibility/index.html). + + + +## 2. (Recommended) Prepare a docker environment + +* Switch to the working directory + +```shell +cd /home/Projects +``` + +* Create docker container +The following commands will create a docker container named ppcls and map the current working directory to the `/paddle' directory in the container. + +```shell +# For GPU users +sudo nvidia-docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0-gpu-cuda10.2-cudnn7 /bin/bash + +# For CPU users +sudo docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0 /bin/bash +``` + +**Notices**: +* The first time you use this docker image, it will be downloaded automatically. Please be patient; +* The above command will create a docker container named ppcls, and there is no need to run the command again when using the container again; +* The parameter `--shm-size=8g` will set the shared memory of the container to 8g. If conditions permit, it is recommended to set this parameter to a larger value, such as `64g`; +* You can also access [DockerHub](https://hub.Docker.com/r/paddlepaddle/paddle/tags/) to obtain the image adapted to your machine; +* Exit / Enter the docker container: + * After entering the docker container, you can exit the current container by pressing `Ctrl + P + Q` without closing the container; + * To re-enter the container, use the following command: + ```shell + sudo Docker exec -it ppcls /bin/bash + ``` + + + +## 3. Install PaddlePaddle using pip + +If you want to use PaddlePaddle on GPU, you can use the following command to install PaddlePaddle. + +```bash +pip install paddlepaddle-gpu --upgrade -i https://mirror.baidu.com/pypi/simple +``` + +If you want to use PaddlePaddle on CPU, you can use the following command to install PaddlePaddle. + +```bash +pip install paddlepaddle --upgrade -i https://mirror.baidu.com/pypi/simple +``` + +**Note:** +* If you have already installed CPU version of PaddlePaddle and want to use GPU version now, you should uninstall CPU version of PaddlePaddle and then install GPU version to avoid package confusion. +* You can also compile PaddlePaddle from source code, please refer to [PaddlePaddle Installation tutorial](http://www.paddlepaddle.org.cn/install/quick) to more compilation options. + + + +## 4. Verify Installation + +```python +import paddle +paddle.utils.run_check() +``` + +Check PaddlePaddle version: + +```bash +python -c "import paddle; print(paddle.__version__)" +``` + +Note: +* Make sure the compiled source code is later than PaddlePaddle2.0. +* Indicate `WITH_DISTRIBUTE=ON` when compiling, Please refer to [Instruction](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#id3) for more details. +* When running in docker, in order to ensure that the container has enough shared memory for dataloader acceleration of Paddle, please set the parameter `--shm-size=8g` at creating a docker container, if conditions permit, you can set it to a larger value. diff --git a/src/PaddleClas/docs/en/installation/install_paddleclas_en.md b/src/PaddleClas/docs/en/installation/install_paddleclas_en.md new file mode 100644 index 0000000..332db69 --- /dev/null +++ b/src/PaddleClas/docs/en/installation/install_paddleclas_en.md @@ -0,0 +1,32 @@ +# Install PaddleClas + +--- + +## Catalogue + +* [1. Clone PaddleClas source code](#1) +* [2. Install requirements](#2) + + + +### 1. Clone PaddleClas source code + +```shell +git clone https://github.com/PaddlePaddle/PaddleClas.git -b develop +``` + +If it is too slow for you to download from github, you can download PaddleClas from gitee. The command is as follows. + +```shell +git clone https://gitee.com/paddlepaddle/PaddleClas.git -b develop +``` + + + +## 2. Install requirements + +PaddleClas dependencies are listed in file `requirements.txt`, you can use the following command to install the dependencies. + +``` +pip install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple +``` diff --git a/src/PaddleClas/docs/en/introduction/function_intro_en.md b/src/PaddleClas/docs/en/introduction/function_intro_en.md new file mode 100644 index 0000000..1a1a54b --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/function_intro_en.md @@ -0,0 +1,13 @@ +## Features of PaddleClas + +PaddleClas is an image recognition toolset for industry and academia, helping users train better computer vision models and apply them in real scenarios. Specifically, it contains the following core features. + +- Practical image recognition system: Integrate detection, feature learning, and retrieval modules to be applicable to all types of image recognition tasks. Four sample solutions are provided, including product recognition, vehicle recognition, logo recognition, and animation character recognition. +- Rich library of pre-trained models: Provide a total of 175 ImageNet pre-trained models of 36 series, among which 7 selected series of models support fast structural modification. +- Comprehensive and easy-to-use feature learning components: 12 metric learning methods are integrated and can be combined and switched at will through configuration files. +- SSLD knowledge distillation: The 14 classification pre-training models generally improved their accuracy by more than 3%; among them, the ResNet50_vd model achieved a Top-1 accuracy of 84.0% on the Image-Net-1k dataset and the Res2Net200_vd pre-training model achieved a Top-1 accuracy of 85.1%. +- Data augmentation: Provide 8 data augmentation algorithms such as AutoAugment, Cutout, Cutmix, etc. with the detailed introduction, code replication, and evaluation of effectiveness in a unified experimental environment. + +![](../../images/recognition.gif) + +For more information about the quick start of image recognition, algorithm details, model training and evaluation, and prediction and deployment methods, please refer to the [README Tutorial](../../../README_ch.md) on home page. diff --git a/src/PaddleClas/docs/en/introduction/index.rst b/src/PaddleClas/docs/en/introduction/index.rst new file mode 100644 index 0000000..e22a647 --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/index.rst @@ -0,0 +1,8 @@ +introduction +================================ + +.. toctree:: + :maxdepth: 2 + + function_intro_en.md + more_demo/index diff --git a/src/PaddleClas/docs/en/introduction/more_demo/cartoon.md b/src/PaddleClas/docs/en/introduction/more_demo/cartoon.md new file mode 100644 index 0000000..042fbf2 --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/more_demo/cartoon.md @@ -0,0 +1,53 @@ +# Cartoon Demo Images + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/en/introduction/more_demo/index.rst b/src/PaddleClas/docs/en/introduction/more_demo/index.rst new file mode 100644 index 0000000..f09bccf --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/more_demo/index.rst @@ -0,0 +1,11 @@ +more_demo +================================ + +.. toctree:: + :maxdepth: 1 + + product.md + logo.md + cartoon.md + more_demo.md + vehicle.md diff --git a/src/PaddleClas/docs/en/introduction/more_demo/logo.md b/src/PaddleClas/docs/en/introduction/more_demo/logo.md new file mode 100644 index 0000000..0b8ee1b --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/more_demo/logo.md @@ -0,0 +1,65 @@ +# Logo Demo Images + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/en/introduction/more_demo/more_demo.md b/src/PaddleClas/docs/en/introduction/more_demo/more_demo.md new file mode 100644 index 0000000..1e8d00d --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/more_demo/more_demo.md @@ -0,0 +1,34 @@ +## Demo images +- Product recognition +
+
+
+
+
+ +[More demo images](product.md) + +- Cartoon character recognition +
+
+
+ +[More demo images](cartoon.md) + +- Logo recognition +
+
+
+
+ +
+
+ +[More demo images](logo.md) + +- Car recognition +
+
+
+ +[More demo images](vehicle.md) diff --git a/src/PaddleClas/docs/en/introduction/more_demo/product.md b/src/PaddleClas/docs/en/introduction/more_demo/product.md new file mode 100644 index 0000000..f80203f --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/more_demo/product.md @@ -0,0 +1,179 @@ +# Product Demo Images + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/en/introduction/more_demo/vehicle.md b/src/PaddleClas/docs/en/introduction/more_demo/vehicle.md new file mode 100644 index 0000000..2f37e39 --- /dev/null +++ b/src/PaddleClas/docs/en/introduction/more_demo/vehicle.md @@ -0,0 +1,33 @@ +# Vehicle Demo Images + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/en/make.bat b/src/PaddleClas/docs/en/make.bat new file mode 100644 index 0000000..922152e --- /dev/null +++ b/src/PaddleClas/docs/en/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/src/PaddleClas/docs/en/models/DLA_en.md b/src/PaddleClas/docs/en/models/DLA_en.md new file mode 100644 index 0000000..0d7b838 --- /dev/null +++ b/src/PaddleClas/docs/en/models/DLA_en.md @@ -0,0 +1,27 @@ +# DLA series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## Overview + +DLA (Deep Layer Aggregation). Visual recognition requires rich representations that span levels from low to high, scales from small to large, and resolutions from fine to coarse. Even with the depth of features in a convolutional network, a layer in isolation is not enough: compounding and aggregating these representations improves inference of what and where. Although skip connections have been incorporated to combine layers, these connections have been "shallow" themselves, and only fuse by simple, one-step operations. The authors augment standard architectures with deeper aggregation to better fuse information across layers. Deep layer aggregation structures iteratively and hierarchically merge the feature hierarchy to make networks with better accuracy and fewer parameters. Experiments across architectures and tasks show that deep layer aggregation improves recognition and resolution compared to existing branching and merging schemes. [paper](https://arxiv.org/abs/1707.06484) + + +## 2. Accuracy, FLOPs and Parameters + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:-----------------:|:----------:|:---------:|:---------:|:---------:| +| DLA34 | 15.8 | 3.1 | 76.03 | 92.98 | +| DLA46_c | 1.3 | 0.5 | 63.21 | 85.30 | +| DLA46x_c | 1.1 | 0.5 | 64.36 | 86.01 | +| DLA60 | 22.0 | 4.2 | 76.10 | 92.92 | +| DLA60x | 17.4 | 3.5 | 77.53 | 93.78 | +| DLA60x_c | 1.3 | 0.6 | 66.45 | 87.54 | +| DLA102 | 33.3 | 7.2 | 78.93 | 94.52 | +| DLA102x | 26.4 | 5.9 | 78.10 | 94.00 | +| DLA102x2 | 41.4 | 9.3 | 78.85 | 94.45 | +| DLA169 | 53.5 | 11.6 | 78.09 | 94.09 | diff --git a/src/PaddleClas/docs/en/models/DPN_DenseNet_en.md b/src/PaddleClas/docs/en/models/DPN_DenseNet_en.md new file mode 100644 index 0000000..8976766 --- /dev/null +++ b/src/PaddleClas/docs/en/models/DPN_DenseNet_en.md @@ -0,0 +1,78 @@ +# DPN and DenseNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on V100 GPU](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +DenseNet is a new network structure proposed in 2017 and was the best paper of CVPR. The network has designed a new cross-layer connected block called dense-block. Compared to the bottleneck in ResNet, dense-block has designed a more aggressive dense connection module, that is, connecting all the layers to each other, and each layer will accept all the layers in front of it as its additional input. DenseNet stacks all dense-blocks into a densely connected network. The dense connection makes DenseNet easier to backpropagate, making the network easier to train and converge. The full name of DPN is Dual Path Networks, which is a network composed of DenseNet and ResNeXt, which proves that DenseNet can extract new features from the previous level, and ResNeXt essentially reuses the extracted features . The author further analyzes and finds that ResNeXt has high reuse rate for features, but low redundancy, while DenseNet can create new features, but with high redundancy. Combining the advantages of the two structures, the author designed the DPN network. In the end, the DPN network achieved better results than ResNeXt and DenseNet under the same FLOPs and parameters. + +The FLOPs, parameters, and inference time on the T4 GPU of this series of models are shown in the figure below. + +![](../../images/models/T4_benchmark/t4.fp32.bs4.DPN.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.DPN.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.DPN.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.DPN.png) + +The pretrained models of these two types of models (a total of 10) are open sourced in PaddleClas at present. The indicators are shown in the figure above. It is easy to observe that under the same FLOPs and parameters, DPN has higher accuracy than DenseNet. However,because DPN has more branches, its inference speed is slower than DenseNet. Since DenseNet264 has the deepest layers in all DenseNet networks, it has the largest parameters,DenseNet161 has the largest width, resulting the largest FLOPs and the highest accuracy in this series. From the perspective of inference speed, DenseNet161, which has a large FLOPs and high accuracy, has a faster speed than DenseNet264, so it has a greater advantage than DenseNet264. + +For DPN series networks, the larger the model's FLOPs and parameters, the higher the model's accuracy. Among them, since the width of DPN107 is the largest, it has the largest number of parameters and FLOPs in this series of networks. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| DenseNet121 | 0.757 | 0.926 | 0.750 | | 5.690 | 7.980 | +| DenseNet161 | 0.786 | 0.941 | 0.778 | | 15.490 | 28.680 | +| DenseNet169 | 0.768 | 0.933 | 0.764 | | 6.740 | 14.150 | +| DenseNet201 | 0.776 | 0.937 | 0.775 | | 8.610 | 20.010 | +| DenseNet264 | 0.780 | 0.939 | 0.779 | | 11.540 | 33.370 | +| DPN68 | 0.768 | 0.934 | 0.764 | 0.931 | 4.030 | 10.780 | +| DPN92 | 0.799 | 0.948 | 0.793 | 0.946 | 12.540 | 36.290 | +| DPN98 | 0.806 | 0.951 | 0.799 | 0.949 | 22.220 | 58.460 | +| DPN107 | 0.809 | 0.953 | 0.802 | 0.951 | 35.060 | 82.970 | +| DPN131 | 0.807 | 0.951 | 0.801 | 0.949 | 30.510 | 75.360 | + + + + +## 3. Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|-------------|-----------|-------------------|--------------------------| +| DenseNet121 | 224 | 256 | 4.371 | +| DenseNet161 | 224 | 256 | 8.863 | +| DenseNet169 | 224 | 256 | 6.391 | +| DenseNet201 | 224 | 256 | 8.173 | +| DenseNet264 | 224 | 256 | 11.942 | +| DPN68 | 224 | 256 | 11.805 | +| DPN92 | 224 | 256 | 17.840 | +| DPN98 | 224 | 256 | 21.057 | +| DPN107 | 224 | 256 | 28.685 | +| DPN131 | 224 | 256 | 28.083 | + + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| DenseNet121 | 224 | 256 | 4.16436 | 7.2126 | 10.50221 | 4.40447 | 9.32623 | 15.25175 | +| DenseNet161 | 224 | 256 | 9.27249 | 14.25326 | 20.19849 | 10.39152 | 22.15555 | 35.78443 | +| DenseNet169 | 224 | 256 | 6.11395 | 10.28747 | 13.68717 | 6.43598 | 12.98832 | 20.41964 | +| DenseNet201 | 224 | 256 | 7.9617 | 13.4171 | 17.41949 | 8.20652 | 17.45838 | 27.06309 | +| DenseNet264 | 224 | 256 | 11.70074 | 19.69375 | 24.79545 | 12.14722 | 26.27707 | 40.01905 | +| DPN68 | 224 | 256 | 11.7827 | 13.12652 | 16.19213 | 11.64915 | 12.82807 | 18.57113 | +| DPN92 | 224 | 256 | 18.56026 | 20.35983 | 29.89544 | 18.15746 | 23.87545 | 38.68821 | +| DPN98 | 224 | 256 | 21.70508 | 24.7755 | 40.93595 | 21.18196 | 33.23925 | 62.77751 | +| DPN107 | 224 | 256 | 27.84462 | 34.83217 | 60.67903 | 27.62046 | 52.65353 | 100.11721 | +| DPN131 | 224 | 256 | 28.58941 | 33.01078 | 55.65146 | 28.33119 | 46.19439 | 89.24904 | diff --git a/src/PaddleClas/docs/en/models/ESNet_en.md b/src/PaddleClas/docs/en/models/ESNet_en.md new file mode 100644 index 0000000..fbfcb5d --- /dev/null +++ b/src/PaddleClas/docs/en/models/ESNet_en.md @@ -0,0 +1,23 @@ +# ESNet Series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +ESNet (Enhanced ShuffleNet) is a lightweight network developed by Baidu. This network combines the advantages of MobileNetV3, GhostNet, and PPLCNet on the basis of ShuffleNetV2 to form a faster and more accurate network on ARM devices, Because of its excellent performance, [PP-PicoDet](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.3/configs/picodet) launched in PaddleDetection uses this model as a backbone, with stronger object detection algorithm, the final mAP index refreshed the SOTA index of the object detection model on the ARM device in one fell swoop. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | FLOPs
(M) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:| +| ESNet_x0_25 | 62.48 | 83.46 | 30.9 | 2.83 | +| ESNet_x0_5 | 68.82 | 88.04 | 67.3 | 3.25 | +| ESNet_x0_75 | 72.24 | 90.45 | 123.7 | 3.87 | +| ESNet_x1_0 | 73.92 | 91.40 | 197.3 | 4.64 | + +Please stay tuned for information such as Inference speed. diff --git a/src/PaddleClas/docs/en/models/EfficientNet_and_ResNeXt101_wsl_en.md b/src/PaddleClas/docs/en/models/EfficientNet_and_ResNeXt101_wsl_en.md new file mode 100644 index 0000000..cd9a2d2 --- /dev/null +++ b/src/PaddleClas/docs/en/models/EfficientNet_and_ResNeXt101_wsl_en.md @@ -0,0 +1,91 @@ +# EfficientNet and ResNeXt101_wsl series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on V100 GPU](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +EfficientNet is a lightweight NAS-based network released by Google in 2019. EfficientNetB7 refreshed the classification accuracy of ImageNet-1k at that time. In this paper, the author points out that the traditional methods to improve the performance of neural networks mainly start with the width of the network, the depth of the network, and the resolution of the input picture. +However, the author found that balancing these three dimensions is essential for improving accuracy and efficiency through experiments. +Therefore, the author summarized how to balance the three dimensions at the same time through a series of experiments. +At the same time, based on this scaling method, the author built a total of 7 networks B1-B7 in the EfficientNet series on the basis of EfficientNetB0, and with the same FLOPs and parameters, the accuracy reached state-of-the-art effect. + +ResNeXt is an improved version of ResNet that proposed by Facebook in 2016. In 2019, Facebook researchers studied the accuracy limit of the series network on ImageNet through weakly-supervised-learning. In order to distinguish the previous ResNeXt network, the suffix of this series network is WSL, where WSL is the abbreviation of weakly-supervised-learning. In order to have stronger feature extraction capability, the researchers further enlarged the network width, among which the largest ResNeXt101_32x48d_wsl has 800 million parameters. It was trained under 940 million weak-labeled images, and the results were finetune trained on imagenet-1k. Finally, the acc-1 of imagenet-1k reaches 85.4%, which is also the network with the highest precision under the resolution of 224x224 on imagenet-1k so far. In Fix-ResNeXt, the author used a larger image resolution, made a special Fix strategy for the inconsistency of image data preprocessing in training and testing, and made ResNeXt101_32x48d_wsl have a higher accuracy. Since it used the Fix strategy, it was named Fix-ResNeXt101_32x48d_wsl. + +The FLOPs, parameters, and inference time on the T4 GPU of this series of models are shown in the figure below. + +![](../../images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs1.EfficientNet.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs1.EfficientNet.png) + +At present, there are a total of 14 pretrained models of the two types of models that PaddleClas open source. It can be seen from the above figure that the advantages of the EfficientNet series network are very obvious. The ResNeXt101_wsl series model uses more data, and the final accuracy is also higher. EfficientNet_B0_small removes SE_block based on EfficientNet_B0, which has faster inference speed. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ResNeXt101_
32x8d_wsl | 0.826 | 0.967 | 0.822 | 0.964 | 29.140 | 78.440 | +| ResNeXt101_
32x16d_wsl | 0.842 | 0.973 | 0.842 | 0.972 | 57.550 | 152.660 | +| ResNeXt101_
32x32d_wsl | 0.850 | 0.976 | 0.851 | 0.975 | 115.170 | 303.110 | +| ResNeXt101_
32x48d_wsl | 0.854 | 0.977 | 0.854 | 0.976 | 173.580 | 456.200 | +| Fix_ResNeXt101_
32x48d_wsl | 0.863 | 0.980 | 0.864 | 0.980 | 354.230 | 456.200 | +| EfficientNetB0 | 0.774 | 0.933 | 0.773 | 0.935 | 0.720 | 5.100 | +| EfficientNetB1 | 0.792 | 0.944 | 0.792 | 0.945 | 1.270 | 7.520 | +| EfficientNetB2 | 0.799 | 0.947 | 0.803 | 0.950 | 1.850 | 8.810 | +| EfficientNetB3 | 0.812 | 0.954 | 0.817 | 0.956 | 3.430 | 11.840 | +| EfficientNetB4 | 0.829 | 0.962 | 0.830 | 0.963 | 8.290 | 18.760 | +| EfficientNetB5 | 0.836 | 0.967 | 0.837 | 0.967 | 19.510 | 29.610 | +| EfficientNetB6 | 0.840 | 0.969 | 0.842 | 0.968 | 36.270 | 42.000 | +| EfficientNetB7 | 0.843 | 0.969 | 0.844 | 0.971 | 72.350 | 64.920 | +| EfficientNetB0_
small | 0.758 | 0.926 | | | 0.720 | 4.650 | + + +## 3. Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|-------------------------------|-----------|-------------------|--------------------------| +| ResNeXt101_
32x8d_wsl | 224 | 256 | 19.127 | +| ResNeXt101_
32x16d_wsl | 224 | 256 | 23.629 | +| ResNeXt101_
32x32d_wsl | 224 | 256 | 40.214 | +| ResNeXt101_
32x48d_wsl | 224 | 256 | 59.714 | +| Fix_ResNeXt101_
32x48d_wsl | 320 | 320 | 82.431 | +| EfficientNetB0 | 224 | 256 | 2.449 | +| EfficientNetB1 | 240 | 272 | 3.547 | +| EfficientNetB2 | 260 | 292 | 3.908 | +| EfficientNetB3 | 300 | 332 | 5.145 | +| EfficientNetB4 | 380 | 412 | 7.609 | +| EfficientNetB5 | 456 | 488 | 12.078 | +| EfficientNetB6 | 528 | 560 | 18.381 | +| EfficientNetB7 | 600 | 632 | 27.817 | +| EfficientNetB0_
small | 224 | 256 | 1.692 | + + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|---------------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| ResNeXt101_
32x8d_wsl | 224 | 256 | 18.19374 | 21.93529 | 34.67802 | 18.52528 | 34.25319 | 67.2283 | +| ResNeXt101_
32x16d_wsl | 224 | 256 | 18.52609 | 36.8288 | 62.79947 | 25.60395 | 71.88384 | 137.62327 | +| ResNeXt101_
32x32d_wsl | 224 | 256 | 33.51391 | 70.09682 | 125.81884 | 54.87396 | 160.04337 | 316.17718 | +| ResNeXt101_
32x48d_wsl | 224 | 256 | 50.97681 | 137.60926 | 190.82628 | 99.01698256 | 315.91261 | 551.83695 | +| Fix_ResNeXt101_
32x48d_wsl | 320 | 320 | 78.62869 | 191.76039 | 317.15436 | 160.0838242 | 595.99296 | 1151.47384 | +| EfficientNetB0 | 224 | 256 | 3.40122 | 5.95851 | 9.10801 | 3.442 | 6.11476 | 9.3304 | +| EfficientNetB1 | 240 | 272 | 5.25172 | 9.10233 | 14.11319 | 5.3322 | 9.41795 | 14.60388 | +| EfficientNetB2 | 260 | 292 | 5.91052 | 10.5898 | 17.38106 | 6.29351 | 10.95702 | 17.75308 | +| EfficientNetB3 | 300 | 332 | 7.69582 | 16.02548 | 27.4447 | 7.67749 | 16.53288 | 28.5939 | +| EfficientNetB4 | 380 | 412 | 11.55585 | 29.44261 | 53.97363 | 12.15894 | 30.94567 | 57.38511 | +| EfficientNetB5 | 456 | 488 | 19.63083 | 56.52299 | - | 20.48571 | 61.60252 | - | +| EfficientNetB6 | 528 | 560 | 30.05911 | - | - | 32.62402 | - | - | +| EfficientNetB7 | 600 | 632 | 47.86087 | - | - | 53.93823 | - | - | +| EfficientNetB0_small | 224 | 256 | 2.39166 | 4.36748 | 6.96002 | 2.3076 | 4.71886 | 7.21888 | diff --git a/src/PaddleClas/docs/en/models/HRNet_en.md b/src/PaddleClas/docs/en/models/HRNet_en.md new file mode 100644 index 0000000..f6cf537 --- /dev/null +++ b/src/PaddleClas/docs/en/models/HRNet_en.md @@ -0,0 +1,75 @@ +# HRNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on V100 GPU](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +HRNet is a brand new neural network proposed by Microsoft research Asia in 2019. Different from the previous convolutional neural network, this network can still maintain high resolution in the deep layer of the network, so the heat map of the key points predicted is more accurate, and it is also more accurate in space. In addition, the network performs particularly well in other visual tasks sensitive to resolution, such as detection and segmentation. + +The FLOPs, parameters, and inference time on the T4 GPU of this series of models are shown in the figure below. + +![](../../images/models/T4_benchmark/t4.fp32.bs4.HRNet.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.HRNet.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.HRNet.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.HRNet.png) + +At present, there are 7 pretrained models of such models open-sourced by PaddleClas, and their indicators are shown in the figure. Among them, the reason why the accuracy of the HRNet_W48_C indicator is abnormal may be due to fluctuations in training. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| HRNet_W18_C | 0.769 | 0.934 | 0.768 | 0.934 | 4.140 | 21.290 | +| HRNet_W18_C_ssld | 0.816 | 0.958 | 0.768 | 0.934 | 4.140 | 21.290 | +| HRNet_W30_C | 0.780 | 0.940 | 0.782 | 0.942 | 16.230 | 37.710 | +| HRNet_W32_C | 0.783 | 0.942 | 0.785 | 0.942 | 17.860 | 41.230 | +| HRNet_W40_C | 0.788 | 0.945 | 0.789 | 0.945 | 25.410 | 57.550 | +| HRNet_W44_C | 0.790 | 0.945 | 0.789 | 0.944 | 29.790 | 67.060 | +| HRNet_W48_C | 0.790 | 0.944 | 0.793 | 0.945 | 34.580 | 77.470 | +| HRNet_W48_C_ssld | 0.836 | 0.968 | 0.793 | 0.945 | 34.580 | 77.470 | +| HRNet_W64_C | 0.793 | 0.946 | 0.795 | 0.946 | 57.830 | 128.060 | +| SE_HRNet_W64_C_ssld | 0.847 | 0.973 | | | 57.830 | 128.970 | + + +## 3. Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|-------------|-----------|-------------------|--------------------------| +| HRNet_W18_C | 224 | 256 | 7.368 | +| HRNet_W18_C_ssld | 224 | 256 | 7.368 | +| HRNet_W30_C | 224 | 256 | 9.402 | +| HRNet_W32_C | 224 | 256 | 9.467 | +| HRNet_W40_C | 224 | 256 | 10.739 | +| HRNet_W44_C | 224 | 256 | 11.497 | +| HRNet_W48_C | 224 | 256 | 12.165 | +| HRNet_W48_C_ssld | 224 | 256 | 12.165 | +| HRNet_W64_C | 224 | 256 | 15.003 | + + + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| HRNet_W18_C | 224 | 256 | 6.79093 | 11.50986 | 17.67244 | 7.40636 | 13.29752 | 23.33445 | +| HRNet_W18_C_ssld | 224 | 256 | 6.79093 | 11.50986 | 17.67244 | 7.40636 | 13.29752 | 23.33445 | +| HRNet_W30_C | 224 | 256 | 8.98077 | 14.08082 | 21.23527 | 9.57594 | 17.35485 | 32.6933 | +| HRNet_W32_C | 224 | 256 | 8.82415 | 14.21462 | 21.19804 | 9.49807 | 17.72921 | 32.96305 | +| HRNet_W40_C | 224 | 256 | 11.4229 | 19.1595 | 30.47984 | 12.12202 | 25.68184 | 48.90623 | +| HRNet_W44_C | 224 | 256 | 12.25778 | 22.75456 | 32.61275 | 13.19858 | 32.25202 | 59.09871 | +| HRNet_W48_C | 224 | 256 | 12.65015 | 23.12886 | 33.37859 | 13.70761 | 34.43572 | 63.01219 | +| HRNet_W48_C_ssld | 224 | 256 | 12.65015 | 23.12886 | 33.37859 | 13.70761 | 34.43572 | 63.01219 | +| HRNet_W64_C | 224 | 256 | 15.10428 | 27.68901 | 40.4198 | 17.57527 | 47.9533 | 97.11228 | +| SE_HRNet_W64_C_ssld | 224 | 256 | 32.33651 | 69.31189 | 116.07245 | 31.69770 | 94.99546 | 174.45766 | + diff --git a/src/PaddleClas/docs/en/models/HarDNet_en.md b/src/PaddleClas/docs/en/models/HarDNet_en.md new file mode 100644 index 0000000..7388896 --- /dev/null +++ b/src/PaddleClas/docs/en/models/HarDNet_en.md @@ -0,0 +1,21 @@ +# HarDNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +HarDNet(Harmonic DenseNet)is a brand new neural network proposed by National Tsing Hua University in 2019, which to achieve high efficiency in terms of both low MACs and memory traffic. The new network achieves 35%, 36%, 30%, 32%, and 45% inference time reduction compared with FC-DenseNet-103, DenseNet-264, ResNet-50, ResNet-152, and SSD-VGG, respectively. We use tools including Nvidia profiler and ARM Scale-Sim to measure the memory traffic and verify that the inference latency is indeed proportional to the memory traffic consumption and the proposed network consumes low memory traffic. [Paper](https://arxiv.org/abs/1909.00948). + + +## 2. Accuracy, FLOPs and Parameters + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:---------------------:|:----------:|:---------:|:---------:|:---------:| +| HarDNet68 | 17.6 | 4.3 | 75.46 | 92.65 | +| HarDNet85 | 36.7 | 9.1 | 77.44 | 93.55 | +| HarDNet39_ds | 3.5 | 0.4 | 71.33 | 89.98 | +| HarDNet68_ds | 4.2 | 0.8 | 73.62 | 91.52 | \ No newline at end of file diff --git a/src/PaddleClas/docs/en/models/Inception_en.md b/src/PaddleClas/docs/en/models/Inception_en.md new file mode 100644 index 0000000..cf521d9 --- /dev/null +++ b/src/PaddleClas/docs/en/models/Inception_en.md @@ -0,0 +1,74 @@ +# Inception series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on V100 GPU](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +GoogLeNet is a new neural network structure designed by Google in 2014, which, together with VGG network, became the twin champions of the ImageNet challenge that year. GoogLeNet introduces the Inception structure for the first time, and stacks the Inception structure in the network so that the number of network layers reaches 22, which is also the mark of the convolutional network exceeding 20 layers for the first time. Since 1x1 convolution is used in the Inception structure to reduce the dimension of channel number, and Global pooling is used to replace the traditional method of processing features in multiple fc layers, the final GoogLeNet network has much less FLOPs and parameters than VGG network, which has become a beautiful scenery of neural network design at that time. + +InceptionV3 is an improvement of InceptionV2 by Google. First of all, the author optimized the Inception module in InceptionV3. At the same time, more types of Inception modules were designed and used. Further, the larger square two-dimensional convolution kernel in some Inception modules in InceptionV3 was disassembled into two smaller asymmetric convolution kernels, which can greatly save the amount of parameters. + +Xception is another improvement to InceptionV3 that Google proposed after Inception. In Xception, the author used the depthwise separable convolution to replace the traditional convolution operation, which greatly saved the network FLOPs and the number of parameters, but improved the accuracy. In DeeplabV3+, the author further improved the Xception and increased the number of Xception layers, and designed the network of Xception65 and Xception71. + +InceptionV4 is a new neural network designed by Google in 2016, when residual structure were all the rage, but the authors believe that high performance can be achieved using only Inception structure. InceptionV4 uses more Inception structure to achieve even greater precision on Imagenet-1k. + +The FLOPs, parameters, and inference time on the T4 GPU of this series of models are shown in the figure below. + +![](../../images/models/T4_benchmark/t4.fp32.bs4.Inception.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.Inception.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.Inception.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.Inception.png) + +The figure above reflects the relationship between the accuracy of Xception series and InceptionV4 and other indicators. Among them, Xception_deeplab is consistent with the structure of the paper, and Xception is an improved model developed by PaddleClas, which improves the accuracy by about 0.6% when the inference speed is basically unchanged. Details of the improved model are being updated, so stay tuned. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| GoogLeNet | 0.707 | 0.897 | 0.698 | | 2.880 | 8.460 | +| Xception41 | 0.793 | 0.945 | 0.790 | 0.945 | 16.740 | 22.690 | +| Xception41
_deeplab | 0.796 | 0.944 | | | 18.160 | 26.730 | +| Xception65 | 0.810 | 0.955 | | | 25.950 | 35.480 | +| Xception65
_deeplab | 0.803 | 0.945 | | | 27.370 | 39.520 | +| Xception71 | 0.811 | 0.955 | | | 31.770 | 37.280 | +| InceptionV3 | 0.791 | 0.946 | 0.788 | 0.944 | 11.460 | 23.830 | +| InceptionV4 | 0.808 | 0.953 | 0.800 | 0.950 | 24.570 | 42.680 | + + + +## 3. Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|------------------------|-----------|-------------------|--------------------------| +| GoogLeNet | 224 | 256 | 1.807 | +| Xception41 | 299 | 320 | 3.972 | +| Xception41_
deeplab | 299 | 320 | 4.408 | +| Xception65 | 299 | 320 | 6.174 | +| Xception65_
deeplab | 299 | 320 | 6.464 | +| Xception71 | 299 | 320 | 6.782 | +| InceptionV4 | 299 | 320 | 11.141 | + + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|--------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| GoogLeNet | 299 | 320 | 1.75451 | 3.39931 | 4.71909 | 1.88038 | 4.48882 | 6.94035 | +| Xception41 | 299 | 320 | 2.91192 | 7.86878 | 15.53685 | 4.96939 | 17.01361 | 32.67831 | +| Xception41_
deeplab | 299 | 320 | 2.85934 | 7.2075 | 14.01406 | 5.33541 | 17.55938 | 33.76232 | +| Xception65 | 299 | 320 | 4.30126 | 11.58371 | 23.22213 | 7.26158 | 25.88778 | 53.45426 | +| Xception65_
deeplab | 299 | 320 | 4.06803 | 9.72694 | 19.477 | 7.60208 | 26.03699 | 54.74724 | +| Xception71 | 299 | 320 | 4.80889 | 13.5624 | 27.18822 | 8.72457 | 31.55549 | 69.31018 | +| InceptionV3 | 299 | 320 | 3.67502 | 6.36071 | 9.82645 | 6.64054 | 13.53630 | 22.17355 | +| InceptionV4 | 299 | 320 | 9.50821 | 13.72104 | 20.27447 | 12.99342 | 25.23416 | 43.56121 | diff --git a/src/PaddleClas/docs/en/models/LeViT_en.md b/src/PaddleClas/docs/en/models/LeViT_en.md new file mode 100644 index 0000000..6cc7245 --- /dev/null +++ b/src/PaddleClas/docs/en/models/LeViT_en.md @@ -0,0 +1,24 @@ +# LeViT series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview +LeViT is a fast inference hybrid neural network for image classification tasks. Its design considers the performance of the network model on different hardware platforms, so it can better reflect the real scenarios of common applications. Through a large number of experiments, the author found a better way to combine the convolutional neural network and the Transformer system, and proposed an attention-based method to integrate the position information encoding in the Transformer. [Paper](https://arxiv.org/abs/2104.01136)。 + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(M) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| LeViT-128S | 0.7598 | 0.9269 | 0.766 | 0.929 | 305 | 7.8 | +| LeViT-128 | 0.7810 | 0.9371 | 0.786 | 0.940 | 406 | 9.2 | +| LeViT-192 | 0.7934 | 0.9446 | 0.800 | 0.947 | 658 | 11 | +| LeViT-256 | 0.8085 | 0.9497 | 0.816 | 0.954 | 1120 | 19 | +| LeViT-384 | 0.8191 | 0.9551 | 0.826 | 0.960 | 2353 | 39 | + + +**Note**:The difference in accuracy from Reference is due to the difference in data preprocessing and the absence of distilled head as output. diff --git a/src/PaddleClas/docs/en/models/MixNet_en.md b/src/PaddleClas/docs/en/models/MixNet_en.md new file mode 100644 index 0000000..c104731 --- /dev/null +++ b/src/PaddleClas/docs/en/models/MixNet_en.md @@ -0,0 +1,27 @@ +# MixNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +MixNet is a lightweight network proposed by Google. The main idea of MixNet is to explore the combination of different size of kernels. The author found that the current network has the following two problems: + +- Small convolution kernel has small receptive field and few parameters, but the accuracy is not high. +- The larger convolution kernel has larger receptive field and higher accuracy, but the parameters also increase a lot . + + In order to solve the above two problems, MDConv(mixed depthwise convolution) is proposed. In this method, different size of kernels are mixed in a convolution operation block. And based on AutoML, a series of networks called MixNets are proposed, which have achieved good results on Imagenet. [paper](https://arxiv.org/pdf/1907.09595.pdf) + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | FLOPs
(M) | Params
(G | +| :------: | :---: | :---: | :---------------: | :----------: | ------------- | +| MixNet_S | 76.28 | 92.99 | 75.8 | 252.977 | 4.167 | +| MixNet_M | 77.67 | 93.64 | 77.0 | 357.119 | 5.065 | +| MixNet_L | 78.60 | 94.37 | 78.9 | 579.017 | 7.384 | + +Inference speed and other information are coming soon. diff --git a/src/PaddleClas/docs/en/models/Mobile_en.md b/src/PaddleClas/docs/en/models/Mobile_en.md new file mode 100644 index 0000000..7834ef0 --- /dev/null +++ b/src/PaddleClas/docs/en/models/Mobile_en.md @@ -0,0 +1,158 @@ +# Mobile and Embedded Vision Applications Network series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed and storage size based on SD855](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +MobileNetV1 is a network launched by Google in 2017 for use on mobile devices or embedded devices. The network replaces the depthwise separable convolution with the traditional convolution operation, that is, the combination of depthwise convolution and pointwise convolution. Compared with the traditional convolution operation, this combination can greatly save the number of parameters and computation. At the same time, MobileNetV1 can also be used for object detection, image segmentation and other visual tasks. + +MobileNetV2 is a lightweight network proposed by Google following MobileNetV1. Compared with MobileNetV1, MobileNetV2 proposed Linear bottlenecks and Inverted residual block as a basic network structures, to constitute MobileNetV2 network architecture through stacking these basic module a lot. In the end, higher classification accuracy was achieved when FLOPs was only half of MobileNetV1. + +The ShuffleNet series network is the lightweight network structure proposed by MEGVII. So far, there are two typical structures in this series network, namely, ShuffleNetV1 and ShuffleNetV2. A Channel Shuffle operation in ShuffleNet can exchange information between groups and perform end-to-end training. In the paper of ShuffleNetV2, the author proposes four criteria for designing lightweight networks, and designs the ShuffleNetV2 network according to the four criteria and the shortcomings of ShuffleNetV1. + +MobileNetV3 is a new and lightweight network based on NAS proposed by Google in 2019. In order to further improve the effect, the activation functions of relu and sigmoid were replaced with hard_swish and hard_sigmoid activation functions, and some improved strategies were introduced to reduce the amount of network computing. + +GhosttNet is a brand-new lightweight network structure proposed by Huawei in 2020. By introducing the ghost module, the problem of redundant calculation of features in traditional deep networks is greatly alleviated, which greatly reduces the amount of network parameters and calculations. + +![](../../images/models/mobile_arm_top1.png) + +![](../../images/models/mobile_arm_storage.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.params.png) + +Currently there are 32 pretrained models of the mobile series open source by PaddleClas, and their indicators are shown in the figure below. As you can see from the picture, newer lightweight models tend to perform better, and MobileNetV3 represents the latest lightweight neural network architecture. In MobileNetV3, the author used 1x1 convolution after global-avg-pooling in order to obtain higher accuracy,this operation significantly increases the number of parameters but has little impact on the amount of computation, so if the model is evaluated from a storage perspective of excellence, MobileNetV3 does not have much advantage, but because of its smaller computation, it has a faster inference speed. In addition, the SSLD distillation model in our model library performs excellently, refreshing the accuracy of the current lightweight model from various perspectives. Due to the complex structure and many branches of the MobileNetV3 model, which is not GPU friendly, the GPU inference speed is not as good as that of MobileNetV1. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 0.514 | 0.755 | 0.506 | | 0.070 | 0.460 | +| MobileNetV1_x0_5 | 0.635 | 0.847 | 0.637 | | 0.280 | 1.310 | +| MobileNetV1_x0_75 | 0.688 | 0.882 | 0.684 | | 0.630 | 2.550 | +| MobileNetV1 | 0.710 | 0.897 | 0.706 | | 1.110 | 4.190 | +| MobileNetV1_ssld | 0.779 | 0.939 | | | 1.110 | 4.190 | +| MobileNetV2_x0_25 | 0.532 | 0.765 | | | 0.050 | 1.500 | +| MobileNetV2_x0_5 | 0.650 | 0.857 | 0.654 | 0.864 | 0.170 | 1.930 | +| MobileNetV2_x0_75 | 0.698 | 0.890 | 0.698 | 0.896 | 0.350 | 2.580 | +| MobileNetV2 | 0.722 | 0.907 | 0.718 | 0.910 | 0.600 | 3.440 | +| MobileNetV2_x1_5 | 0.741 | 0.917 | | | 1.320 | 6.760 | +| MobileNetV2_x2_0 | 0.752 | 0.926 | | | 2.320 | 11.130 | +| MobileNetV2_ssld | 0.7674 | 0.9339 | | | 0.600 | 3.440 | +| MobileNetV3_large_
x1_25 | 0.764 | 0.930 | 0.766 | | 0.714 | 7.440 | +| MobileNetV3_large_
x1_0 | 0.753 | 0.923 | 0.752 | | 0.450 | 5.470 | +| MobileNetV3_large_
x0_75 | 0.731 | 0.911 | 0.733 | | 0.296 | 3.910 | +| MobileNetV3_large_
x0_5 | 0.692 | 0.885 | 0.688 | | 0.138 | 2.670 | +| MobileNetV3_large_
x0_35 | 0.643 | 0.855 | 0.642 | | 0.077 | 2.100 | +| MobileNetV3_small_
x1_25 | 0.707 | 0.895 | 0.704 | | 0.195 | 3.620 | +| MobileNetV3_small_
x1_0 | 0.682 | 0.881 | 0.675 | | 0.123 | 2.940 | +| MobileNetV3_small_
x0_75 | 0.660 | 0.863 | 0.654 | | 0.088 | 2.370 | +| MobileNetV3_small_
x0_5 | 0.592 | 0.815 | 0.580 | | 0.043 | 1.900 | +| MobileNetV3_small_
x0_35 | 0.530 | 0.764 | 0.498 | | 0.026 | 1.660 | +| MobileNetV3_small_
x0_35_ssld | 0.556 | 0.777 | 0.498 | | 0.026 | 1.660 | +| MobileNetV3_large_
x1_0_ssld | 0.790 | 0.945 | | | 0.450 | 5.470 | +| MobileNetV3_large_
x1_0_ssld_int8 | 0.761 | | | | | | +| MobileNetV3_small_
x1_0_ssld | 0.713 | 0.901 | | | 0.123 | 2.940 | +| ShuffleNetV2 | 0.688 | 0.885 | 0.694 | | 0.280 | 2.260 | +| ShuffleNetV2_x0_25 | 0.499 | 0.738 | | | 0.030 | 0.600 | +| ShuffleNetV2_x0_33 | 0.537 | 0.771 | | | 0.040 | 0.640 | +| ShuffleNetV2_x0_5 | 0.603 | 0.823 | 0.603 | | 0.080 | 1.360 | +| ShuffleNetV2_x1_5 | 0.716 | 0.902 | 0.726 | | 0.580 | 3.470 | +| ShuffleNetV2_x2_0 | 0.732 | 0.912 | 0.749 | | 1.120 | 7.320 | +| ShuffleNetV2_swish | 0.700 | 0.892 | | | 0.290 | 2.260 | +| GhostNet_x0_5 | 0.668 | 0.869 | 0.662 | 0.866 | 0.082 | 2.600 | +| GhostNet_x1_0 | 0.740 | 0.916 | 0.739 | 0.914 | 0.294 | 5.200 | +| GhostNet_x1_3 | 0.757 | 0.925 | 0.757 | 0.927 | 0.440 | 7.300 | +| GhostNet_x1_3_ssld | 0.794 | 0.945 | 0.757 | 0.927 | 0.440 | 7.300 | + + +## 3. Inference speed and storage size based on SD855 + +| Models | Batch Size=1(ms) | Storage Size(M) | +|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 3.220 | 1.900 | +| MobileNetV1_x0_5 | 9.580 | 5.200 | +| MobileNetV1_x0_75 | 19.436 | 10.000 | +| MobileNetV1 | 32.523 | 16.000 | +| MobileNetV1_ssld | 32.523 | 16.000 | +| MobileNetV2_x0_25 | 3.799 | 6.100 | +| MobileNetV2_x0_5 | 8.702 | 7.800 | +| MobileNetV2_x0_75 | 15.531 | 10.000 | +| MobileNetV2 | 23.318 | 14.000 | +| MobileNetV2_x1_5 | 45.624 | 26.000 | +| MobileNetV2_x2_0 | 74.292 | 43.000 | +| MobileNetV2_ssld | 23.318 | 14.000 | +| MobileNetV3_large_x1_25 | 28.218 | 29.000 | +| MobileNetV3_large_x1_0 | 19.308 | 21.000 | +| MobileNetV3_large_x0_75 | 13.565 | 16.000 | +| MobileNetV3_large_x0_5 | 7.493 | 11.000 | +| MobileNetV3_large_x0_35 | 5.137 | 8.600 | +| MobileNetV3_small_x1_25 | 9.275 | 14.000 | +| MobileNetV3_small_x1_0 | 6.546 | 12.000 | +| MobileNetV3_small_x0_75 | 5.284 | 9.600 | +| MobileNetV3_small_x0_5 | 3.352 | 7.800 | +| MobileNetV3_small_x0_35 | 2.635 | 6.900 | +| MobileNetV3_small_x0_35_ssld | 2.635 | 6.900 | +| MobileNetV3_large_x1_0_ssld | 19.308 | 21.000 | +| MobileNetV3_large_x1_0_ssld_int8 | 14.395 | 10.000 | +| MobileNetV3_small_x1_0_ssld | 6.546 | 12.000 | +| ShuffleNetV2 | 10.941 | 9.000 | +| ShuffleNetV2_x0_25 | 2.329 | 2.700 | +| ShuffleNetV2_x0_33 | 2.643 | 2.800 | +| ShuffleNetV2_x0_5 | 4.261 | 5.600 | +| ShuffleNetV2_x1_5 | 19.352 | 14.000 | +| ShuffleNetV2_x2_0 | 34.770 | 28.000 | +| ShuffleNetV2_swish | 16.023 | 9.100 | +| GhostNet_x0_5 | 5.714 | 10.000 | +| GhostNet_x1_0 | 13.558 | 20.000 | +| GhostNet_x1_3 | 19.982 | 29.000 | +| GhostNet_x1_3_ssld | 19.982 | 29.000 | + + +## 4. Inference speed based on T4 GPU + +| Models | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------| +| MobileNetV1_x0_25 | 0.68422 | 1.13021 | 1.72095 | 0.67274 | 1.226 | 1.84096 | +| MobileNetV1_x0_5 | 0.69326 | 1.09027 | 1.84746 | 0.69947 | 1.43045 | 2.39353 | +| MobileNetV1_x0_75 | 0.6793 | 1.29524 | 2.15495 | 0.79844 | 1.86205 | 3.064 | +| MobileNetV1 | 0.71942 | 1.45018 | 2.47953 | 0.91164 | 2.26871 | 3.90797 | +| MobileNetV1_ssld | 0.71942 | 1.45018 | 2.47953 | 0.91164 | 2.26871 | 3.90797 | +| MobileNetV2_x0_25 | 2.85399 | 3.62405 | 4.29952 | 2.81989 | 3.52695 | 4.2432 | +| MobileNetV2_x0_5 | 2.84258 | 3.1511 | 4.10267 | 2.80264 | 3.65284 | 4.31737 | +| MobileNetV2_x0_75 | 2.82183 | 3.27622 | 4.98161 | 2.86538 | 3.55198 | 5.10678 | +| MobileNetV2 | 2.78603 | 3.71982 | 6.27879 | 2.62398 | 3.54429 | 6.41178 | +| MobileNetV2_x1_5 | 2.81852 | 4.87434 | 8.97934 | 2.79398 | 5.30149 | 9.30899 | +| MobileNetV2_x2_0 | 3.65197 | 6.32329 | 11.644 | 3.29788 | 7.08644 | 12.45375 | +| MobileNetV2_ssld | 2.78603 | 3.71982 | 6.27879 | 2.62398 | 3.54429 | 6.41178 | +| MobileNetV3_large_x1_25 | 2.34387 | 3.16103 | 4.79742 | 2.35117 | 3.44903 | 5.45658 | +| MobileNetV3_large_x1_0 | 2.20149 | 3.08423 | 4.07779 | 2.04296 | 2.9322 | 4.53184 | +| MobileNetV3_large_x0_75 | 2.1058 | 2.61426 | 3.61021 | 2.0006 | 2.56987 | 3.78005 | +| MobileNetV3_large_x0_5 | 2.06934 | 2.77341 | 3.35313 | 2.11199 | 2.88172 | 3.19029 | +| MobileNetV3_large_x0_35 | 2.14965 | 2.7868 | 3.36145 | 1.9041 | 2.62951 | 3.26036 | +| MobileNetV3_small_x1_25 | 2.06817 | 2.90193 | 3.5245 | 2.02916 | 2.91866 | 3.34528 | +| MobileNetV3_small_x1_0 | 1.73933 | 2.59478 | 3.40276 | 1.74527 | 2.63565 | 3.28124 | +| MobileNetV3_small_x0_75 | 1.80617 | 2.64646 | 3.24513 | 1.93697 | 2.64285 | 3.32797 | +| MobileNetV3_small_x0_5 | 1.95001 | 2.74014 | 3.39485 | 1.88406 | 2.99601 | 3.3908 | +| MobileNetV3_small_x0_35 | 2.10683 | 2.94267 | 3.44254 | 1.94427 | 2.94116 | 3.41082 | +| MobileNetV3_small_x0_35_ssld | 2.10683 | 2.94267 | 3.44254 | 1.94427 | 2.94116 | 3.41082 | +| MobileNetV3_large_x1_0_ssld | 2.20149 | 3.08423 | 4.07779 | 2.04296 | 2.9322 | 4.53184 | +| MobileNetV3_small_x1_0_ssld | 1.73933 | 2.59478 | 3.40276 | 1.74527 | 2.63565 | 3.28124 | +| ShuffleNetV2 | 1.95064 | 2.15928 | 2.97169 | 1.89436 | 2.26339 | 3.17615 | +| ShuffleNetV2_x0_25 | 1.43242 | 2.38172 | 2.96768 | 1.48698 | 2.29085 | 2.90284 | +| ShuffleNetV2_x0_33 | 1.69008 | 2.65706 | 2.97373 | 1.75526 | 2.85557 | 3.09688 | +| ShuffleNetV2_x0_5 | 1.48073 | 2.28174 | 2.85436 | 1.59055 | 2.18708 | 3.09141 | +| ShuffleNetV2_x1_5 | 1.51054 | 2.4565 | 3.41738 | 1.45389 | 2.5203 | 3.99872 | +| ShuffleNetV2_x2_0 | 1.95616 | 2.44751 | 4.19173 | 2.15654 | 3.18247 | 5.46893 | +| ShuffleNetV2_swish | 2.50213 | 2.92881 | 3.474 | 2.5129 | 2.97422 | 3.69357 | +| GhostNet_x0_5 | 2.64492 | 3.48473 | 4.48844 | 2.36115 | 3.52802 | 3.89444 | +| GhostNet_x1_0 | 2.63120 | 3.92065 | 4.48296 | 2.57042 | 3.56296 | 4.85524 | +| GhostNet_x1_3 | 2.89715 | 3.80329 | 4.81661 | 2.81810 | 3.72071 | 5.92269 | diff --git a/src/PaddleClas/docs/en/models/Others_en.md b/src/PaddleClas/docs/en/models/Others_en.md new file mode 100644 index 0000000..37bb659 --- /dev/null +++ b/src/PaddleClas/docs/en/models/Others_en.md @@ -0,0 +1,64 @@ +# Other networks +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed and storage size based on SD855](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +In 2012, AlexNet network proposed by Alex et al. won the ImageNet competition by far surpassing the second place, and the convolutional neural network and even deep learning attracted wide attention. AlexNet used relu as the activation function of CNN to solve the gradient dispersion problem of sigmoid when the network is deep. During the training, Dropout was used to randomly lose a part of the neurons, avoiding the overfitting of the model. In the network, overlapping maximum pooling is used to replace the average pooling commonly used in CNN, which avoids the fuzzy effect of average pooling and improves the feature richness. In a sense, AlexNet has exploded the research and application of neural networks. + +SqueezeNet achieved the same precision as AlexNet on Imagenet-1k, but only with 1/50 parameters. The core of the network is the Fire module, which used the convolution of 1x1 to achieve channel dimensionality reduction, thus greatly saving the number of parameters. The author created SqueezeNet by stacking a large number of Fire modules. + +VGG is a convolutional neural network developed by researchers at Oxford University's Visual Geometry Group and DeepMind. The network explores the relationship between the depth of the convolutional neural network and its performance. By repeatedly stacking the small convolutional kernel of 3x3 and the maximum pooling layer of 2x2, the multi-layer convolutional neural network is successfully constructed and has achieved good convergence accuracy. In the end, VGG won the runner-up of ILSVRC 2014 classification and the champion of positioning. + +DarkNet53 is designed for object detection by YOLO author in the paper. The network is basically composed of 1x1 and 3x3 kernel, with a total of 53 layers, named DarkNet53. + + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| AlexNet | 0.567 | 0.792 | 0.5720 | | 1.370 | 61.090 | +| SqueezeNet1_0 | 0.596 | 0.817 | 0.575 | | 1.550 | 1.240 | +| SqueezeNet1_1 | 0.601 | 0.819 | | | 0.690 | 1.230 | +| VGG11 | 0.693 | 0.891 | | | 15.090 | 132.850 | +| VGG13 | 0.700 | 0.894 | | | 22.480 | 133.030 | +| VGG16 | 0.720 | 0.907 | 0.715 | 0.901 | 30.810 | 138.340 | +| VGG19 | 0.726 | 0.909 | | | 39.130 | 143.650 | +| DarkNet53 | 0.780 | 0.941 | 0.772 | 0.938 | 18.580 | 41.600 | + + + +## 3. Inference speed based on V100 GPU + + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|---------------------------|-----------|-------------------|----------------------| +| AlexNet | 224 | 256 | 1.176 | +| SqueezeNet1_0 | 224 | 256 | 0.860 | +| SqueezeNet1_1 | 224 | 256 | 0.763 | +| VGG11 | 224 | 256 | 1.867 | +| VGG13 | 224 | 256 | 2.148 | +| VGG16 | 224 | 256 | 2.616 | +| VGG19 | 224 | 256 | 3.076 | +| DarkNet53 | 256 | 256 | 3.139 | + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| AlexNet | 224 | 256 | 1.06447 | 1.70435 | 2.38402 | 1.44993 | 2.46696 | 3.72085 | +| SqueezeNet1_0 | 224 | 256 | 0.97162 | 2.06719 | 3.67499 | 0.96736 | 2.53221 | 4.54047 | +| SqueezeNet1_1 | 224 | 256 | 0.81378 | 1.62919 | 2.68044 | 0.76032 | 1.877 | 3.15298 | +| VGG11 | 224 | 256 | 2.24408 | 4.67794 | 7.6568 | 3.90412 | 9.51147 | 17.14168 | +| VGG13 | 224 | 256 | 2.58589 | 5.82708 | 10.03591 | 4.64684 | 12.61558 | 23.70015 | +| VGG16 | 224 | 256 | 3.13237 | 7.19257 | 12.50913 | 5.61769 | 16.40064 | 32.03939 | +| VGG19 | 224 | 256 | 3.69987 | 8.59168 | 15.07866 | 6.65221 | 20.4334 | 41.55902 | +| DarkNet53 | 256 | 256 | 3.18101 | 5.88419 | 10.14964 | 4.10829 | 12.1714 | 22.15266 | diff --git a/src/PaddleClas/docs/en/models/PP-LCNet_en.md b/src/PaddleClas/docs/en/models/PP-LCNet_en.md new file mode 100644 index 0000000..1dd35e0 --- /dev/null +++ b/src/PaddleClas/docs/en/models/PP-LCNet_en.md @@ -0,0 +1,169 @@ +# PP-LCNet Series +--- + + +## Catalogue + +- [1. Abstract](#1) +- [2. Introduction](#2) +- [3. Method](#3) + - [3.1 Better Activation Function](#3.1) + - [3.2 SE Modules at Appropriate Positions](#3.2) + - [3.3 Larger Convolution Kernels](#3.3) + - [3.4 Larger Dimensional 1 × 1 Conv Layer after GAP](#3.4) +- [4. Experiments](#4) + - [4.1 Image Classification](#4.1) + - [4.2 Object Detection](#4.2) + - [4.3 Semantic Segmentation](#4.3) +- [5. Conclusion](#5) +- [6. Reference](#6) + + +## 1. Abstract + +In the field of computer vision, the quality of backbone network determines the outcome of the whole vision task. In previous studies, researchers generally focus on the optimization of FLOPs or Params, but inference speed actually serves as an importance indicator of model quality in real-world scenarios. Nevertheless, it is difficult to balance inference speed and accuracy. In view of various CPU-based applications in industry, we are now working to raise the adaptability of the backbone network to Intel CPU, so as to obtain a faster and more accurate lightweight backbone network. At the same time, the performance of downstream vision tasks such as object detection and semantic segmentation are also improved. + + +## 2. Introduction + +Recent years witnessed the emergence of many lightweight backbone networks. In past two years, in particular, there were abundant networks searched by NAS that either enjoy advantages on FLOPs or Params, or have an edge in terms of inference speed on ARM devices. However, few of them dedicated to specified optimization of Intel CPU, resulting their imperfect inference speed on the intel CPU side. Based on this, we specially design the backbone network PP-LCNet for Intel CPU devices with its acceleration library MKLDNN. Compared with other lightweight SOTA models, this backbone network can further improve the performance of the model without increasing the inference time, significantly outperforming the existing SOTA models. A comparison chart with other models is shown below. +![](../../images/PP-LCNet/PP-LCNet-Acc.png) + + +## 3. Method + +The overall structure of the network is shown in the figure below. +![](../../images/PP-LCNet/PP-LCNet.png) + +Build on extensive experiments, we found that many seemingly less time-consuming operations will increase the latency on Intel CPU-based devices, especially when the MKLDNN acceleration library is enabled. Therefore, we finally chose a block with the leanest possible structure and the fastest possible speed to form our BaseNet (similar to MobileNetV1). Based on BaseNet, we summarized four strategies that can improve the accuracy of the model without increasing the latency, and we combined these four strategies to form PP-LCNet. Each of these four strategies is introduced as below: + + +### 3.1 Better Activation Function + +Since the adoption of ReLU activation function by convolutional neural network, the network performance has been improved substantially, and variants of the ReLU activation function have appeared in recent years, such as Leaky-ReLU, P-ReLU, ELU, etc. In 2017, Google Brain searched to obtain the swish activation function, which performs well on lightweight networks. In 2019, the authors of MobileNetV3 further optimized this activation function to H-Swish, which removes the exponential operation, leading to faster speed and an almost unaffected network accuracy. After many experiments, we also recognized its excellent performance on lightweight networks. Therefore, this activation function is adopted in PP-LCNet. + + +### 3.2 SE Modules at Appropriate Positions + +The SE module is a channel attention mechanism proposed by SENet, which can effectively improve the accuracy of the model. However, on the Intel CPU side, the module also presents a large latency, leaving us the task of balancing accuracy and speed. The search of the location of the SE module in NAS search-based networks such as MobileNetV3 brings no general conclusions, but we found through our experiments that the closer the SE module is to the tail of the network the greater the improvement in model accuracy. The following table also shows some of our experimental results: + +| SE Location | Top-1 Acc(\%) | Latency(ms) | +|-------------------|---------------|-------------| +| 1100000000000 | 61.73 | 2.06 | +| 0000001100000 | 62.17 | 2.03 | +| 0000000000011 | 63.14 | 2.05 | +| 1111111111111 | 64.27 | 3.80 | + +The option in the third row of the table was chosen for the location of the SE module in PP-LCNet. + + +### 3.3 Larger Convolution Kernels + +In the paper of MixNet, the author analyzes the effect of convolutional kernel size on model performance and concludes that larger convolutional kernels within a certain range can improve the performance of the model, but beyond this range will be detrimental to the model’s performance. So the author forms MixConv with split-concat paradigm combined, which can improve the performance of the model but is not conducive to inference. We experimentally summarize the role of some larger convolutional kernels at different positions that are similar to those of the SE module, and find that larger convolutional kernels display more prominent roles in the middle and tail of the network. The following table shows the effect of the position of the 5x5 convolutional kernels on the accuracy: + +| Larger Convolution Location | Top-1 Acc(\%) | Latency(ms) | +|----------------------------|---------------|-------------| +| 1111111111111 | 63.22 | 2.08 | +| 1111111000000 | 62.70 | 2.07 | +| 0000001111111 | 63.14 | 2.05 | + + +Experiments show that a larger convolutional kernel placed at the middle and tail of the network can achieve the same accuracy as placed at all positions, coupled with faster inference. The option in the third row of the table was the final choice of PP-LCNet. + + +### 3.4 Larger Dimensional 1 × 1 Conv Layer after GAP + +Since the introduction of GoogLeNet, GAP (Global-Average-Pooling) is often directly followed by a classification layer, which fails to result in further integration and processing of features extracted after GAP in the lightweight network. If a larger 1x1 convolutional layer (equivalent to the FC layer) is used after GAP, the extracted features, instead of directly passing through the classification layer, will first be integrated, and then classified. This can greatly improve the accuracy rate without affecting the inference speed of the model. The above four improvements were made to BaseNet to obtain PP-LCNet. The following table further illustrates the impact of each scheme on the results: + +| Activation | SE-block | Large-kernal | last-1x1-conv | Top-1 Acc(\%) | Latency(ms) | +|------------|----------|--------------|---------------|---------------|-------------| +| 0 | 1 | 1 | 1 | 61.93 | 1.94 | +| 1 | 0 | 1 | 1 | 62.51 | 1.87 | +| 1 | 1 | 0 | 1 | 62.44 | 2.01 | +| 1 | 1 | 1 | 0 | 59.91 | 1.85 | +| 1 | 1 | 1 | 1 | 63.14 | 2.05 | + + +## 4. Experiments + + +### 4.1 Image Classification + +For image classification, ImageNet dataset is adopted. Compared with the current mainstream lightweight network, PP-LCNet can obtain faster inference speed with the same accuracy. When using Baidu’s self-developed SSLD distillation strategy, the accuracy is further improved, with the Top-1 Acc of ImageNet exceeding 80% at an inference speed of about 5ms on the Intel CPU side. + +| Model | Params(M) | FLOPs(M) | Top-1 Acc(\%) | Top-5 Acc(\%) | Latency(ms) | +|-------|-----------|----------|---------------|---------------|-------------| +| PP-LCNet-0.25x | 1.5 | 18 | 51.86 | 75.65 | 1.74 | +| PP-LCNet-0.35x | 1.6 | 29 | 58.09 | 80.83 | 1.92 | +| PP-LCNet-0.5x | 1.9 | 47 | 63.14 | 84.66 | 2.05 | +| PP-LCNet-0.75x | 2.4 | 99 | 68.18 | 88.30 | 2.29 | +| PP-LCNet-1x | 3.0 | 161 | 71.32 | 90.03 | 2.46 | +| PP-LCNet-1.5x | 4.5 | 342 | 73.71 | 91.53 | 3.19 | +| PP-LCNet-2x | 6.5 | 590 | 75.18 | 92.27 | 4.27 | +| PP-LCNet-2.5x | 9.0 | 906 | 76.60 | 93.00 | 5.39 | +| PP-LCNet-0.5x\* | 1.9 | 47 | 66.10 | 86.46 | 2.05 | +| PP-LCNet-1.0x\* | 3.0 | 161 | 74.39 | 92.09 | 2.46 | +| PP-LCNet-2.5x\* | 9.0 | 906 | 80.82 | 95.33 | 5.39 | + +\* denotes the model after using SSLD distillation. + +Performance comparison with other lightweight networks: + +| Model | Params(M) | FLOPs(M) | Top-1 Acc(\%) | Top-5 Acc(\%) | Latency(ms) | +|-------|-----------|----------|---------------|---------------|-------------| +| MobileNetV2-0.25x | 1.5 | 34 | 53.21 | 76.52 | 2.47 | +| MobileNetV3-small-0.35x | 1.7 | 15 | 53.03 | 76.37 | 3.02 | +| ShuffleNetV2-0.33x | 0.6 | 24 | 53.73 | 77.05 | 4.30 | +| PP-LCNet-0.25x | 1.5 | 18 | 51.86 | 75.65 | 1.74 | +| MobileNetV2-0.5x | 2.0 | 99 | 65.03 | 85.72 | 2.85 | +| MobileNetV3-large-0.35x | 2.1 | 41 | 64.32 | 85.46 | 3.68 | +| ShuffleNetV2-0.5x | 1.4 | 43 | 60.32 | 82.26 | 4.65 | +| PP-LCNet-0.5x | 1.9 | 47 | 63.14 | 84.66 | 2.05 | +| MobileNetV1-1x | 4.3 | 578 | 70.99 | 89.68 | 3.38 | +| MobileNetV2-1x | 3.5 | 327 | 72.15 | 90.65 | 4.26 | +| MobileNetV3-small-1.25x | 3.6 | 100 | 70.67 | 89.51 | 3.95 | +| PP-LCNet-1x | 3.0 | 161 | 71.32 | 90.03 | 2.46 | + + +### 4.2 Object Detection + +For object detection, we adopt Baidu’s self-developed PicoDet, which focuses on lightweight object detection scenarios. The following table shows the comparison between the results of PP-LCNet and MobileNetV3 on the COCO dataset. PP-LCNet has an obvious advantage in both accuracy and speed. + +| Backbone | mAP(%) | Latency(ms) | +|-------|-----------|----------| +MobileNetV3-large-0.35x | 19.2 | 8.1 | +PP-LCNet-0.5x | 20.3 | 6.0 | +MobileNetV3-large-0.75x | 25.8 | 11.1 | +PP-LCNet-1x | 26.9 | 7.9 | + + +### 4.3 Semantic Segmentation + +For semantic segmentation, DeeplabV3+ is adopted. The following table presents the comparison between PP-LCNet and MobileNetV3 on the Cityscapes dataset, and PP-LCNet also stands out in terms of accuracy and speed. + +| Backbone | mIoU(%) | Latency(ms) | +|-------|-----------|----------| +MobileNetV3-large-0.5x | 55.42 | 135 | +PP-LCNet-0.5x | 58.36 | 82 | +MobileNetV3-large-0.75x | 64.53 | 151 | +PP-LCNet-1x | 66.03 | 96 | + + +## 5. Conclusion + +Rather than holding on to perfect FLOPs and Params as academics do, PP-LCNet focuses on analyzing how to add Intel CPU-friendly modules to improve the performance of the model, which can better balance accuracy and inference time. The experimental conclusions therein are available to other researchers in network structure design, while providing NAS search researchers with a smaller search space and general conclusions. The finished PP-LCNet can also be better accepted and applied in industry. + + +## 6. Reference + +Reference to cite when you use PP-LCNet in a paper: +``` +@misc{cui2021pplcnet, + title={PP-LCNet: A Lightweight CPU Convolutional Neural Network}, + author={Cheng Cui and Tingquan Gao and Shengyu Wei and Yuning Du and Ruoyu Guo and Shuilong Dong and Bin Lu and Ying Zhou and Xueying Lv and Qiwen Liu and Xiaoguang Hu and Dianhai Yu and Yanjun Ma}, + year={2021}, + eprint={2109.15099}, + archivePrefix={arXiv}, + primaryClass={cs.CV} +} +``` diff --git a/src/PaddleClas/docs/en/models/PVTV2_en.md b/src/PaddleClas/docs/en/models/PVTV2_en.md new file mode 100644 index 0000000..39b9b8a --- /dev/null +++ b/src/PaddleClas/docs/en/models/PVTV2_en.md @@ -0,0 +1,26 @@ +# PVTV2 + +--- + +## Content + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +PVTV2 is VisionTransformer series model, which build on PVT (Pyramid Vision Transformer). PVT use Transformer block to build feature pyramid network. The mainly designs of PVTV2 are: (1) overlapping patch embedding, (2) convolutional feedforward networks, and (3) linear complexity attention layers. [Paper](https://arxiv.org/pdf/2106.13797.pdf). + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| PVT_V2_B0 | 0.705 | 0.902 | 0.705 | - | 0.53 | 3.7 | +| PVT_V2_B1 | 0.787 | 0.945 | 0.787 | - | 2.0 | 14.0 | +| PVT_V2_B2 | 0.821 | 0.960 | 0.820 | - | 3.9 | 25.4 | +| PVT_V2_B3 | 0.831 | 0.965 | 0.831 | - | 6.7 | 45.2 | +| PVT_V2_B4 | 0.836 | 0.967 | 0.836 | - | 9.8 | 62.6 | +| PVT_V2_B5 | 0.837 | 0.966 | 0.838 | - | 11.4 | 82.0 | +| PVT_V2_B2_Linear | 0.821 | 0.961 | 0.821 | - | 3.8 | 22.6 | diff --git a/src/PaddleClas/docs/en/models/ReXNet_en.md b/src/PaddleClas/docs/en/models/ReXNet_en.md new file mode 100644 index 0000000..63f693c --- /dev/null +++ b/src/PaddleClas/docs/en/models/ReXNet_en.md @@ -0,0 +1,24 @@ +# ReXNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## Overview + + ReXNet is proposed by NAVER AI Lab, which is based on new network design principles. Aiming at the problem of representative bottleneck in the existing network, a set of design principles are proposed. The author believes that the conventional design produce representational bottlenecks, which would affect model performance. To investigate the representational bottleneck, the author study the matrix rank of the features generated by ten thousand random networks. Besides, entire layer’s channel configuration is also studied to design more accurate network architectures. In the end, the author proposes a set of simple and effective design principles to mitigate the representational bottleneck. [paper](https://arxiv.org/pdf/2007.00992.pdf) + + +## Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | FLOPs
(G) | Params
(M) | +| :--------: | :---: | :---: | :---------------: | :-----------: | -------------- | +| ReXNet_1_0 | 77.46 | 93.70 | 77.9 | 0.415 | 4.838 | +| ReXNet_1_3 | 79.13 | 94.64 | 79.5 | 0.683 | 7.611 | +| ReXNet_1_5 | 80.06 | 95.12 | 80.3 | 0.900 | 9.791 | +| ReXNet_2_0 | 81.22 | 95.36 | 81.6 | 1.561 | 16.449 | +| ReXNet_3_0 | 82.09 | 96.12 | 82.8 | 3.445 | 34.833 | + +Inference speed and other information are coming soon. diff --git a/src/PaddleClas/docs/en/models/RedNet_en.md b/src/PaddleClas/docs/en/models/RedNet_en.md new file mode 100644 index 0000000..0926837 --- /dev/null +++ b/src/PaddleClas/docs/en/models/RedNet_en.md @@ -0,0 +1,22 @@ +# RedNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +In the backbone of ResNet and in all bottleneck positions of backbone, the convolution is replaced by Involution, but all convolutions are reserved for channel mapping and fusion. These carefully redesigned entities combine to form a new efficient backbone network, called Rednet. [paper](https://arxiv.org/abs/2103.06255). + + +## 2. Accuracy, FLOPs and Parameters + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:---------------------:|:----------:|:---------:|:---------:|:---------:| +| RedNet26 | 9.2 | 1.7 | 75.95 | 93.19 | +| RedNet38 | 12.4 | 2.2 | 77.47 | 93.56 | +| RedNet50 | 15.5 | 2.7 | 78.33 | 94.17 | +| RedNet101 | 25.7 | 4.7 | 78.94 | 94.36 | +| RedNet152 | 34.0 | 6.8 | 79.17 | 94.40 | \ No newline at end of file diff --git a/src/PaddleClas/docs/en/models/RepVGG_en.md b/src/PaddleClas/docs/en/models/RepVGG_en.md new file mode 100644 index 0000000..551feaf --- /dev/null +++ b/src/PaddleClas/docs/en/models/RepVGG_en.md @@ -0,0 +1,29 @@ +# RepVGG series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +RepVGG (Making VGG-style ConvNets Great Again) series model is a simple but powerful convolutional neural network architecture proposed by Tsinghua University (Guiguang Ding's team), MEGVII Technology (Jian Sun et al.), HKUST and Aberystwyth University in 2021. The architecture has an inference time agent similar to VGG. The main body is composed of 3x3 convolution and relu stack, while the training time model has multi branch topology. The decoupling of training time and inference time is realized by re-parameterization technology, so the model is called repvgg. [paper](https://arxiv.org/abs/2101.03697). + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1| FLOPs
(G) | +|:--:|:--:|:--:|:--:|:--:| +| RepVGG_A0 | 0.7131 | 0.9016 | 0.7241 | | +| RepVGG_A1 | 0.7380 | 0.9146 | 0.7446 | | +| RepVGG_A2 | 0.7571 | 0.9264 | 0.7648 | | +| RepVGG_B0 | 0.7450 | 0.9213 | 0.7514 | | +| RepVGG_B1 | 0.7773 | 0.9385 | 0.7837 | | +| RepVGG_B2 | 0.7813 | 0.9410 | 0.7878 | | +| RepVGG_B1g2 | 0.7732 | 0.9359 | 0.7778 | | +| RepVGG_B1g4 | 0.7675 | 0.9335 | 0.7758 | | +| RepVGG_B2g4 | 0.7881 | 0.9448 | 0.7938 | | +| RepVGG_B3g4 | 0.7965 | 0.9485 | 0.8021 | | + +Params, FLOPs, Inference speed and other information are coming soon. diff --git a/src/PaddleClas/docs/en/models/ResNeSt_RegNet_en.md b/src/PaddleClas/docs/en/models/ResNeSt_RegNet_en.md new file mode 100644 index 0000000..b6ce389 --- /dev/null +++ b/src/PaddleClas/docs/en/models/ResNeSt_RegNet_en.md @@ -0,0 +1,32 @@ +# ResNeSt and RegNet series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on T4 GPU](#3) + + +## 1. Overview + +The ResNeSt series was proposed in 2020. The original resnet network structure has been improved by introducing K groups and adding an attention module similar to SEBlock in different groups, the accuracy is greater than that of the basic model ResNet, but the parameter amount and flops are almost the same as the basic ResNet. + +RegNet was proposed in 2020 by Facebook to deepen the concept of design space. Based on AnyNetX, the model performance is gradually improved by shared bottleneck ratio, shared group width, adjusting network depth or width and other strategies. What's more, the design space structure is simplified, whose interpretability is also be improved. The quality of design space is improved while its diversity is maintained. Under similar conditions, the performance of the designed RegNet model performs better than EfficientNet and 5 times faster than EfficientNet. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ResNeSt50_fast_1s1x64d | 0.8035 | 0.9528| 0.8035 | -| 8.68 | 26.3 | +| ResNeSt50 | 0.8083 | 0.9542| 0.8113 | -| 10.78 | 27.5 | +| RegNetX_4GF | 0.7850 | 0.9416| 0.7860 | -| 8.0 | 22.1 | + + +## 3. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|--------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| ResNeSt50_fast_1s1x64d | 224 | 256 | 3.46466 | 5.56647 | 9.11848 | 3.45405 | 8.72680 | 15.48710 | +| ResNeSt50 | 224 | 256 | 7.05851 | 8.97676 | 13.34704 | 6.16248 | 12.0633 | 21.49936 | +| RegNetX_4GF | 224 | 256 | 6.69042 | 8.01664 | 11.60608 | 6.46478 | 11.19862 | 16.89089 | diff --git a/src/PaddleClas/docs/en/models/ResNet_and_vd_en.md b/src/PaddleClas/docs/en/models/ResNet_and_vd_en.md new file mode 100644 index 0000000..70312fd --- /dev/null +++ b/src/PaddleClas/docs/en/models/ResNet_and_vd_en.md @@ -0,0 +1,104 @@ +# ResNet and ResNet_vd series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on V100 GPU](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +The ResNet series model was proposed in 2015 and won the championship in the ILSVRC2015 competition with a top5 error rate of 3.57%. The network innovatively proposed the residual structure, and built the ResNet network by stacking multiple residual structures. Experiments show that using residual blocks can improve the convergence speed and accuracy effectively. + +Joyce Xu of Stanford university calls ResNet one of three architectures that "really redefine the way we think about neural networks." Due to the outstanding performance of ResNet, more and more scholars and engineers from academia and industry have improved its structure. The well-known ones include wide-resnet, resnet-vc, resnet-vd, Res2Net, etc. The number of parameters and FLOPs of resnet-vc and resnet-vd are almost the same as those of ResNet, so we hereby unified them into the ResNet series. + +The models of the ResNet series released this time include 14 pre-trained models including ResNet50, ResNet50_vd, ResNet50_vd_ssld, and ResNet200_vd. At the training level, ResNet adopted the standard training process for training ImageNet, while the rest of the improved model adopted more training strategies, such as cosine decay for the decline of learning rate and the regular label smoothing method,mixup was added to the data preprocessing, and the total number of iterations increased from 120 epoches to 200 epoches. + +Among them, ResNet50_vd_v2 and ResNet50_vd_ssld adopted knowledge distillation, which further improved the accuracy of the model while keeping the structure unchanged. Specifically, the teacher model of ResNet50_vd_v2 is ResNet152_vd (top1 accuracy 80.59%), the training set is imagenet-1k, the teacher model of ResNet50_vd_ssld is ResNeXt101_32x16d_wsl (top1 accuracy 84.2%), and the training set is the combination of 4 million data mined by imagenet-22k and ImageNet-1k . The specific methods of knowledge distillation are being continuously updated. + +The FLOPs, parameters, and inference time on the T4 GPU of this series of models are shown in the figure below. + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.ResNet.png) + + +As can be seen from the above curves, the higher the number of layers, the higher the accuracy, but the corresponding number of parameters, calculation and latency will increase. ResNet50_vd_ssld further improves the accuracy of top-1 of the ImageNet-1k validation set by using stronger teachers and more data, reaching 82.39%, refreshing the accuracy of ResNet50 series models. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ResNet18 | 0.710 | 0.899 | 0.696 | 0.891 | 3.660 | 11.690 | +| ResNet18_vd | 0.723 | 0.908 | | | 4.140 | 11.710 | +| ResNet34 | 0.746 | 0.921 | 0.732 | 0.913 | 7.360 | 21.800 | +| ResNet34_vd | 0.760 | 0.930 | | | 7.390 | 21.820 | +| ResNet34_vd_ssld | 0.797 | 0.949 | | | 7.390 | 21.820 | +| ResNet50 | 0.765 | 0.930 | 0.760 | 0.930 | 8.190 | 25.560 | +| ResNet50_vc | 0.784 | 0.940 | | | 8.670 | 25.580 | +| ResNet50_vd | 0.791 | 0.944 | 0.792 | 0.946 | 8.670 | 25.580 | +| ResNet50_vd_v2 | 0.798 | 0.949 | | | 8.670 | 25.580 | +| ResNet101 | 0.776 | 0.936 | 0.776 | 0.938 | 15.520 | 44.550 | +| ResNet101_vd | 0.802 | 0.950 | | | 16.100 | 44.570 | +| ResNet152 | 0.783 | 0.940 | 0.778 | 0.938 | 23.050 | 60.190 | +| ResNet152_vd | 0.806 | 0.953 | | | 23.530 | 60.210 | +| ResNet200_vd | 0.809 | 0.953 | | | 30.530 | 74.740 | +| ResNet50_vd_ssld | 0.824 | 0.961 | | | 8.670 | 25.580 | +| ResNet50_vd_ssld_v2 | 0.830 | 0.964 | | | 8.670 | 25.580 | +| Fix_ResNet50_vd_ssld_v2 | 0.840 | 0.970 | | | 17.696 | 25.580 | +| ResNet101_vd_ssld | 0.837 | 0.967 | | | 16.100 | 44.570 | + +* Note: `ResNet50_vd_ssld_v2` is obtained by adding AutoAugment in training process on the basis of `ResNet50_vd_ssld` training strategy.`Fix_ResNet50_vd_ssld_v2` stopped all parameter updates of `ResNet50_vd_ssld_v2` except the FC layer,and fine-tuned on ImageNet1k dataset, the resolution is 320x320. + + +## 3. Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|------------------|-----------|-------------------|--------------------------| +| ResNet18 | 224 | 256 | 1.499 | +| ResNet18_vd | 224 | 256 | 1.603 | +| ResNet34 | 224 | 256 | 2.272 | +| ResNet34_vd | 224 | 256 | 2.343 | +| ResNet34_vd_ssld | 224 | 256 | 2.343 | +| ResNet50 | 224 | 256 | 2.939 | +| ResNet50_vc | 224 | 256 | 3.041 | +| ResNet50_vd | 224 | 256 | 3.165 | +| ResNet50_vd_v2 | 224 | 256 | 3.165 | +| ResNet101 | 224 | 256 | 5.314 | +| ResNet101_vd | 224 | 256 | 5.252 | +| ResNet152 | 224 | 256 | 7.205 | +| ResNet152_vd | 224 | 256 | 7.200 | +| ResNet200_vd | 224 | 256 | 8.885 | +| ResNet50_vd_ssld | 224 | 256 | 3.165 | +| ResNet101_vd_ssld | 224 | 256 | 5.252 | + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| ResNet18 | 224 | 256 | 1.3568 | 2.5225 | 3.61904 | 1.45606 | 3.56305 | 6.28798 | +| ResNet18_vd | 224 | 256 | 1.39593 | 2.69063 | 3.88267 | 1.54557 | 3.85363 | 6.88121 | +| ResNet34 | 224 | 256 | 2.23092 | 4.10205 | 5.54904 | 2.34957 | 5.89821 | 10.73451 | +| ResNet34_vd | 224 | 256 | 2.23992 | 4.22246 | 5.79534 | 2.43427 | 6.22257 | 11.44906 | +| ResNet34_vd | 224 | 256 | 2.23992 | 4.22246 | 5.79534 | 2.43427 | 6.22257 | 11.44906 | +| ResNet50 | 224 | 256 | 2.63824 | 4.63802 | 7.02444 | 3.47712 | 7.84421 | 13.90633 | +| ResNet50_vc | 224 | 256 | 2.67064 | 4.72372 | 7.17204 | 3.52346 | 8.10725 | 14.45577 | +| ResNet50_vd | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| ResNet50_vd_v2 | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| ResNet101 | 224 | 256 | 5.04037 | 7.73673 | 10.8936 | 6.07125 | 13.40573 | 24.3597 | +| ResNet101_vd | 224 | 256 | 5.05972 | 7.83685 | 11.34235 | 6.11704 | 13.76222 | 25.11071 | +| ResNet152 | 224 | 256 | 7.28665 | 10.62001 | 14.90317 | 8.50198 | 19.17073 | 35.78384 | +| ResNet152_vd | 224 | 256 | 7.29127 | 10.86137 | 15.32444 | 8.54376 | 19.52157 | 36.64445 | +| ResNet200_vd | 224 | 256 | 9.36026 | 13.5474 | 19.0725 | 10.80619 | 25.01731 | 48.81399 | +| ResNet50_vd_ssld | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| ResNet50_vd_ssld_v2 | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| Fix_ResNet50_vd_ssld_v2 | 320 | 320 | 3.42818 | 7.51534 | 13.19370 | 5.07696 | 14.64218 | 27.01453 | +| ResNet101_vd_ssld | 224 | 256 | 5.05972 | 7.83685 | 11.34235 | 6.11704 | 13.76222 | 25.11071 | diff --git a/src/PaddleClas/docs/en/models/SEResNext_and_Res2Net_en.md b/src/PaddleClas/docs/en/models/SEResNext_and_Res2Net_en.md new file mode 100644 index 0000000..18c8ace --- /dev/null +++ b/src/PaddleClas/docs/en/models/SEResNext_and_Res2Net_en.md @@ -0,0 +1,126 @@ +# SEResNeXt and Res2Net series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) +* [3. Inference speed based on V100 GPU](#3) +* [4. Inference speed based on T4 GPU](#4) + + +## 1. Overview + +ResNeXt, one of the typical variants of ResNet, was presented at the CVPR conference in 2017. Prior to this, the methods to improve the model accuracy mainly focused on deepening or widening the network, which increased the number of parameters and calculation, and slowed down the inference speed accordingly. The concept of cardinality was proposed in ResNeXt structure. The author found that increasing the number of channel groups was more effective than increasing the depth and width through experiments. It can improve the accuracy without increasing the parameter complexity and reduce the number of parameters at the same time, so it is a more successful variant of ResNet. + +SENet is the winner of the 2017 ImageNet classification competition. It proposes a new SE structure that can be migrated to any other network. It controls the scale to enhance the important features between each channel, and weaken the unimportant features. So that the extracted features are more directional. + +Res2Net is a brand-new improvement of ResNet proposed in 2019. The solution can be easily integrated with other excellent modules. Without increasing the amount of calculation, the performance on ImageNet, CIFAR-100 and other data sets exceeds ResNet. Res2Net, with its simple structure and superior performance, further explores the multi-scale representation capability of CNN at a more fine-grained level. Res2Net reveals a new dimension to improve model accuracy, called scale, which is an essential and more effective factor in addition to the existing dimensions of depth, width, and cardinality. The network also performs well in other visual tasks such as object detection and image segmentation. + +The FLOPs, parameters, and inference time on the T4 GPU of this series of models are shown in the figure below. + + +![](../../images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.SeResNeXt.png) + + +At present, there are a total of 24 pretrained models of the three categories open sourced by PaddleClas, and the indicators are shown in the figure. It can be seen from the diagram that under the same Flops and Params, the improved model tends to have higher accuracy, but the inference speed is often inferior to the ResNet series. On the other hand, Res2Net performed better. Compared with group operation in ResNeXt and SE structure operation in SEResNet, Res2Net tended to have better accuracy in the same Flops, Params and inference speed. + + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| Res2Net50_26w_4s | 0.793 | 0.946 | 0.780 | 0.936 | 8.520 | 25.700 | +| Res2Net50_vd_26w_4s | 0.798 | 0.949 | | | 8.370 | 25.060 | +| Res2Net50_vd_26w_4s_ssld | 0.831 | 0.966 | | | 8.370 | 25.060 | +| Res2Net50_14w_8s | 0.795 | 0.947 | 0.781 | 0.939 | 9.010 | 25.720 | +| Res2Net101_vd_26w_4s | 0.806 | 0.952 | | | 16.670 | 45.220 | +| Res2Net101_vd_26w_4s_ssld | 0.839 | 0.971 | | | 16.670 | 45.220 | +| Res2Net200_vd_26w_4s | 0.812 | 0.957 | | | 31.490 | 76.210 | +| Res2Net200_vd_26w_4s_ssld | **0.851** | 0.974 | | | 31.490 | 76.210 | +| ResNeXt50_32x4d | 0.778 | 0.938 | 0.778 | | 8.020 | 23.640 | +| ResNeXt50_vd_32x4d | 0.796 | 0.946 | | | 8.500 | 23.660 | +| ResNeXt50_64x4d | 0.784 | 0.941 | | | 15.060 | 42.360 | +| ResNeXt50_vd_64x4d | 0.801 | 0.949 | | | 15.540 | 42.380 | +| ResNeXt101_32x4d | 0.787 | 0.942 | 0.788 | | 15.010 | 41.540 | +| ResNeXt101_vd_32x4d | 0.803 | 0.951 | | | 15.490 | 41.560 | +| ResNeXt101_64x4d | 0.784 | 0.945 | 0.796 | | 29.050 | 78.120 | +| ResNeXt101_vd_64x4d | 0.808 | 0.952 | | | 29.530 | 78.140 | +| ResNeXt152_32x4d | 0.790 | 0.943 | | | 22.010 | 56.280 | +| ResNeXt152_vd_32x4d | 0.807 | 0.952 | | | 22.490 | 56.300 | +| ResNeXt152_64x4d | 0.795 | 0.947 | | | 43.030 | 107.570 | +| ResNeXt152_vd_64x4d | 0.811 | 0.953 | | | 43.520 | 107.590 | +| SE_ResNet18_vd | 0.733 | 0.914 | | | 4.140 | 11.800 | +| SE_ResNet34_vd | 0.765 | 0.932 | | | 7.840 | 21.980 | +| SE_ResNet50_vd | 0.795 | 0.948 | | | 8.670 | 28.090 | +| SE_ResNeXt50_32x4d | 0.784 | 0.940 | 0.789 | 0.945 | 8.020 | 26.160 | +| SE_ResNeXt50_vd_32x4d | 0.802 | 0.949 | | | 10.760 | 26.280 | +| SE_ResNeXt101_32x4d | 0.7939 | 0.9443 | 0.793 | 0.950 | 15.020 | 46.280 | +| SENet154_vd | 0.814 | 0.955 | | | 45.830 | 114.290 | + + + +## 3. Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | +|-----------------------|-----------|-------------------|--------------------------| +| Res2Net50_26w_4s | 224 | 256 | 4.148 | +| Res2Net50_vd_26w_4s | 224 | 256 | 4.172 | +| Res2Net50_14w_8s | 224 | 256 | 5.113 | +| Res2Net101_vd_26w_4s | 224 | 256 | 7.327 | +| Res2Net200_vd_26w_4s | 224 | 256 | 12.806 | +| ResNeXt50_32x4d | 224 | 256 | 10.964 | +| ResNeXt50_vd_32x4d | 224 | 256 | 7.566 | +| ResNeXt50_64x4d | 224 | 256 | 13.905 | +| ResNeXt50_vd_64x4d | 224 | 256 | 14.321 | +| ResNeXt101_32x4d | 224 | 256 | 14.915 | +| ResNeXt101_vd_32x4d | 224 | 256 | 14.885 | +| ResNeXt101_64x4d | 224 | 256 | 28.716 | +| ResNeXt101_vd_64x4d | 224 | 256 | 28.398 | +| ResNeXt152_32x4d | 224 | 256 | 22.996 | +| ResNeXt152_vd_32x4d | 224 | 256 | 22.729 | +| ResNeXt152_64x4d | 224 | 256 | 46.705 | +| ResNeXt152_vd_64x4d | 224 | 256 | 46.395 | +| SE_ResNet18_vd | 224 | 256 | 1.694 | +| SE_ResNet34_vd | 224 | 256 | 2.786 | +| SE_ResNet50_vd | 224 | 256 | 3.749 | +| SE_ResNeXt50_32x4d | 224 | 256 | 8.924 | +| SE_ResNeXt50_vd_32x4d | 224 | 256 | 9.011 | +| SE_ResNeXt101_32x4d | 224 | 256 | 19.204 | +| SENet154_vd | 224 | 256 | 50.406 | + + +## 4. Inference speed based on T4 GPU + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| Res2Net50_26w_4s | 224 | 256 | 3.56067 | 6.61827 | 11.41566 | 4.47188 | 9.65722 | 17.54535 | +| Res2Net50_vd_26w_4s | 224 | 256 | 3.69221 | 6.94419 | 11.92441 | 4.52712 | 9.93247 | 18.16928 | +| Res2Net50_14w_8s | 224 | 256 | 4.45745 | 7.69847 | 12.30935 | 5.4026 | 10.60273 | 18.01234 | +| Res2Net101_vd_26w_4s | 224 | 256 | 6.53122 | 10.81895 | 18.94395 | 8.08729 | 17.31208 | 31.95762 | +| Res2Net200_vd_26w_4s | 224 | 256 | 11.66671 | 18.93953 | 33.19188 | 14.67806 | 32.35032 | 63.65899 | +| ResNeXt50_32x4d | 224 | 256 | 7.61087 | 8.88918 | 12.99674 | 7.56327 | 10.6134 | 18.46915 | +| ResNeXt50_vd_32x4d | 224 | 256 | 7.69065 | 8.94014 | 13.4088 | 7.62044 | 11.03385 | 19.15339 | +| ResNeXt50_64x4d | 224 | 256 | 13.78688 | 15.84655 | 21.79537 | 13.80962 | 18.4712 | 33.49843 | +| ResNeXt50_vd_64x4d | 224 | 256 | 13.79538 | 15.22201 | 22.27045 | 13.94449 | 18.88759 | 34.28889 | +| ResNeXt101_32x4d | 224 | 256 | 16.59777 | 17.93153 | 21.36541 | 16.21503 | 19.96568 | 33.76831 | +| ResNeXt101_vd_32x4d | 224 | 256 | 16.36909 | 17.45681 | 22.10216 | 16.28103 | 20.25611 | 34.37152 | +| ResNeXt101_64x4d | 224 | 256 | 30.12355 | 32.46823 | 38.41901 | 30.4788 | 36.29801 | 68.85559 | +| ResNeXt101_vd_64x4d | 224 | 256 | 30.34022 | 32.27869 | 38.72523 | 30.40456 | 36.77324 | 69.66021 | +| ResNeXt152_32x4d | 224 | 256 | 25.26417 | 26.57001 | 30.67834 | 24.86299 | 29.36764 | 52.09426 | +| ResNeXt152_vd_32x4d | 224 | 256 | 25.11196 | 26.70515 | 31.72636 | 25.03258 | 30.08987 | 52.64429 | +| ResNeXt152_64x4d | 224 | 256 | 46.58293 | 48.34563 | 56.97961 | 46.7564 | 56.34108 | 106.11736 | +| ResNeXt152_vd_64x4d | 224 | 256 | 47.68447 | 48.91406 | 57.29329 | 47.18638 | 57.16257 | 107.26288 | +| SE_ResNet18_vd | 224 | 256 | 1.61823 | 3.1391 | 4.60282 | 1.7691 | 4.19877 | 7.5331 | +| SE_ResNet34_vd | 224 | 256 | 2.67518 | 5.04694 | 7.18946 | 2.88559 | 7.03291 | 12.73502 | +| SE_ResNet50_vd | 224 | 256 | 3.65394 | 7.568 | 12.52793 | 4.28393 | 10.38846 | 18.33154 | +| SE_ResNeXt50_32x4d | 224 | 256 | 9.06957 | 11.37898 | 18.86282 | 8.74121 | 13.563 | 23.01954 | +| SE_ResNeXt50_vd_32x4d | 224 | 256 | 9.25016 | 11.85045 | 25.57004 | 9.17134 | 14.76192 | 19.914 | +| SE_ResNeXt101_32x4d | 224 | 256 | 19.34455 | 20.6104 | 32.20432 | 18.82604 | 25.31814 | 41.97758 | +| SENet154_vd | 224 | 256 | 49.85733 | 54.37267 | 74.70447 | 53.79794 | 66.31684 | 121.59885 | diff --git a/src/PaddleClas/docs/en/models/SwinTransformer_en.md b/src/PaddleClas/docs/en/models/SwinTransformer_en.md new file mode 100644 index 0000000..8f76a66 --- /dev/null +++ b/src/PaddleClas/docs/en/models/SwinTransformer_en.md @@ -0,0 +1,28 @@ +# SwinTransformer +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview +Swin Transformer a new vision Transformer, that capably serves as a general-purpose backbone for computer vision. It is a hierarchical Transformer whose representation is computed with shifted windows. The shifted windowing scheme brings greater efficiency by limiting self-attention computation to non-overlapping local windows while also allowing for cross-window connection. [Paper](https://arxiv.org/abs/2103.14030)。 + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| SwinTransformer_tiny_patch4_window7_224 | 0.8069 | 0.9534 | 0.812 | 0.955 | 4.5 | 28 | +| SwinTransformer_small_patch4_window7_224 | 0.8275 | 0.9613 | 0.832 | 0.962 | 8.7 | 50 | +| SwinTransformer_base_patch4_window7_224 | 0.8300 | 0.9626 | 0.835 | 0.965 | 15.4 | 88 | +| SwinTransformer_base_patch4_window12_384 | 0.8439 | 0.9693 | 0.845 | 0.970 | 47.1 | 88 | +| SwinTransformer_base_patch4_window7_224[1] | 0.8487 | 0.9746 | 0.852 | 0.975 | 15.4 | 88 | +| SwinTransformer_base_patch4_window12_384[1] | 0.8642 | 0.9807 | 0.864 | 0.980 | 47.1 | 88 | +| SwinTransformer_large_patch4_window7_224[1] | 0.8596 | 0.9783 | 0.863 | 0.979 | 34.5 | 197 | +| SwinTransformer_large_patch4_window12_384[1] | 0.8719 | 0.9823 | 0.873 | 0.982 | 103.9 | 197 | + +[1]: Based on imagenet22k dataset pre-training, and then in imagenet1k dataset transfer learning. + +**Note**: The difference of precision with reference from the difference of data preprocessing. diff --git a/src/PaddleClas/docs/en/models/TNT_en.md b/src/PaddleClas/docs/en/models/TNT_en.md new file mode 100644 index 0000000..fd20736 --- /dev/null +++ b/src/PaddleClas/docs/en/models/TNT_en.md @@ -0,0 +1,19 @@ +# TNT series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +TNT(Transformer-iN-Transformer) series models were proposed by Huawei-Noah in 2021 for modeling both patch-level and pixel-level representation. In each TNT block, an outer transformer block is utilized to process patch embeddings, and an inner transformer block extracts local features from pixel embeddings. The pixel-level feature is projected to the space of patch embedding by a linear transformation layer and then added into the patch. By stacking the TNT blocks, we build the TNT model for image recognition. Experiments on ImageNet benchmark and downstream tasks demonstrate the superiority and efficiency of the proposed TNT architecture. For example, our TNT achieves 81.3% top-1 accuracy on ImageNet which is 1.5% higher than that of DeiT with similar computational cost. [Paper](https://arxiv.org/abs/2103.00112). + + + +## 2. Accuracy, FLOPs and Parameters + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:---------------------:|:----------:|:---------:|:---------:|:---------:| +| TNT_small | 23.8 | 5.2 | 81.12 | 95.56 | \ No newline at end of file diff --git a/src/PaddleClas/docs/en/models/Twins_en.md b/src/PaddleClas/docs/en/models/Twins_en.md new file mode 100644 index 0000000..0096066 --- /dev/null +++ b/src/PaddleClas/docs/en/models/Twins_en.md @@ -0,0 +1,24 @@ +# Twins +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview +The Twins network includes Twins-PCPVT and Twins-SVT, which focuses on the meticulous design of the spatial attention mechanism, resulting in a simple but more effective solution. Since the architecture only involves matrix multiplication, and the current deep learning framework has a high degree of optimization for matrix multiplication, the architecture is very efficient and easy to implement. Moreover, this architecture can achieve excellent performance in a variety of downstream vision tasks such as image classification, target detection, and semantic segmentation. [Paper](https://arxiv.org/abs/2104.13840). + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| pcpvt_small | 0.8082 | 0.9552 | 0.812 | - | 3.7 | 24.1 | +| pcpvt_base | 0.8242 | 0.9619 | 0.827 | - | 6.4 | 43.8 | +| pcpvt_large | 0.8273 | 0.9650 | 0.831 | - | 9.5 | 60.9 | +| alt_gvt_small | 0.8140 | 0.9546 | 0.817 | - | 2.8 | 24 | +| alt_gvt_base | 0.8294 | 0.9621 | 0.832 | - | 8.3 | 56 | +| alt_gvt_large | 0.8331 | 0.9642 | 0.837 | - | 14.8 | 99.2 | + +**Note**:The difference in accuracy from Reference is due to the difference in data preprocessing. diff --git a/src/PaddleClas/docs/en/models/ViT_and_DeiT_en.md b/src/PaddleClas/docs/en/models/ViT_and_DeiT_en.md new file mode 100644 index 0000000..d8e36b9 --- /dev/null +++ b/src/PaddleClas/docs/en/models/ViT_and_DeiT_en.md @@ -0,0 +1,41 @@ +# ViT and DeiT series +--- +## Catalogue + +* [1. Overview](#1) +* [2. Accuracy, FLOPs and Parameters](#2) + + +## 1. Overview + +ViT(Vision Transformer) series models were proposed by Google in 2020. These models only use the standard transformer structure, completely abandon the convolution structure, splits the image into multiple patches and then inputs them into the transformer, showing the potential of transformer in the CV field.。[Paper](https://arxiv.org/abs/2010.11929)。 + +DeiT(Data-efficient Image Transformers) series models were proposed by Facebook at the end of 2020. Aiming at the problem that the ViT models need large-scale dataset training, the DeiT improved them, and finally achieved 83.1% Top1 accuracy on ImageNet. More importantly, using convolution model as teacher model, and performing knowledge distillation on these models, the Top1 accuracy of 85.2% can be achieved on the ImageNet dataset. + + +## 2. Accuracy, FLOPs and Parameters + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ViT_small_patch16_224 | 0.7769 | 0.9342 | 0.7785 | 0.9342 | | | +| ViT_base_patch16_224 | 0.8195 | 0.9617 | 0.8178 | 0.9613 | | | +| ViT_base_patch16_384 | 0.8414 | 0.9717 | 0.8420 | 0.9722 | | | +| ViT_base_patch32_384 | 0.8176 | 0.9613 | 0.8166 | 0.9613 | | | +| ViT_large_patch16_224 | 0.8323 | 0.9650 | 0.8306 | 0.9644 | | | +| ViT_large_patch16_384 | 0.8513 | 0.9736 | 0.8517 | 0.9736 | | | +| ViT_large_patch32_384 | 0.8153 | 0.9608 | 0.815 | - | | | + + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| DeiT_tiny_patch16_224 | 0.718 | 0.910 | 0.722 | 0.911 | | | +| DeiT_small_patch16_224 | 0.796 | 0.949 | 0.799 | 0.950 | | | +| DeiT_base_patch16_224 | 0.817 | 0.957 | 0.818 | 0.956 | | | +| DeiT_base_patch16_384 | 0.830 | 0.962 | 0.829 | 0.972 | | | +| DeiT_tiny_distilled_patch16_224 | 0.741 | 0.918 | 0.745 | 0.919 | | | +| DeiT_small_distilled_patch16_224 | 0.809 | 0.953 | 0.812 | 0.954 | | | +| DeiT_base_distilled_patch16_224 | 0.831 | 0.964 | 0.834 | 0.965 | | | +| DeiT_base_distilled_patch16_384 | 0.851 | 0.973 | 0.852 | 0.972 | | | + + +Params, FLOPs, Inference speed and other information are coming soon. diff --git a/src/PaddleClas/docs/en/models/index.rst b/src/PaddleClas/docs/en/models/index.rst new file mode 100644 index 0000000..4642eb1 --- /dev/null +++ b/src/PaddleClas/docs/en/models/index.rst @@ -0,0 +1,30 @@ +models +================================ + +.. toctree:: + :maxdepth: 2 + + DPN_DenseNet_en.md + models_intro_en.md + RepVGG_en.md + EfficientNet_and_ResNeXt101_wsl_en.md + ViT_and_DeiT_en.md + SwinTransformer_en.md + Others_en.md + SEResNext_and_Res2Net_en.md + ESNet_en.md + HRNet_en.md + ReXNet_en.md + Inception_en.md + TNT_en.md + RedNet_en.md + DLA_en.md + ResNeSt_RegNet_en.md + PP-LCNet_en.md + HarDNet_en.md + ResNet_and_vd_en.md + LeViT_en.md + Mobile_en.md + MixNet_en.md + Twins_en.md + PVTV2_en.md diff --git a/src/PaddleClas/docs/en/models_training/classification_en.md b/src/PaddleClas/docs/en/models_training/classification_en.md new file mode 100644 index 0000000..0a9bce2 --- /dev/null +++ b/src/PaddleClas/docs/en/models_training/classification_en.md @@ -0,0 +1,360 @@ +# Image Classification + +------ + +Image Classification is a fundamental task that classifies the image by semantic information and assigns it to a specific label. Image Classification is the foundation of Computer Vision tasks, such as object detection, image segmentation, object tracking and behavior analysis. Image Classification has comprehensive applications, including face recognition and smart video analysis in the security and protection field, traffic scenario recognition in the traffic field, image retrieval and electronic photo album classification in the internet industry, and image recognition in the medical industry. + +Generally speaking, Image Classification attempts to comprehend an entire image as a whole by feature engineering and assigns labels by a classifier. Hence, how to extract the features of image is the essential part. Before deep learning, the most used classification method is the Bag of Words model. However, Image Classification based on deep learning can learn the hierarchical feature description by supervised and unsupervised learning, replacing the manually image feature selection. Recently, Convolution Neural Network in deep learning has an awesome performance in the image field. CNN uses the pixel information as the input to get the all information of images. Additionally, since the model uses convolution to extract features, and the output is classification result. Thus, this kind of end-to-end method achieves ideal performance and is applied widely. + +Image Classification is a very basic but important field in the subject of computer vision. Its research results have always influenced the development of computer vision and even deep learning. Image classification has many sub-fields, such as multi-label image classification and fine-grained image classification. Here is only a brief description of single-label image classification. + +See [here](../algorithm_introduction/image_classification_en.md) for the detailed introduction of image classification algorithms. + +## Catalogue + +- [1. Dataset Introduction](#1) + - [1.1 ImageNet-1k](#1.1) + - [1.2 CIFAR-10/CIFAR-100](#1.2) +- [2. Image Classification Process](#2) + - [2.1 Data and Its Preprocessing](#2.1) + - [2.2 Prepare the Model](#2.2) + - [2.3 Train the Model](#2.3) + - [2.4 Evaluate the Model](#2.4) +- [3. Application Methods](#3) + - [3.1 Training and Evaluation on CPU or Single GPU](#3.1) + - [3.1.1 Model Training](#3.1.1) + - [3.1.2 Model Finetuning](#3.1.2) + - [3.1.3 Resume Training](#3.1.3) + - [3.1.4 Model Evaluation](#3.1.4) + - [3.2 Training and Evaluation on Linux+ Multi-GPU](#3.2) + - [3.2.1 Model Training](#3.2.1) + - [3.2.2 Model Finetuning](#3.2.2) + - [3.2.3 Resume Training](#3.2.3) + - [3.2.4 Model Evaluation](#3.2.4) + - [3.3 Use the Pre-trained Model to Predict](#3.3) + - [3.4 Use the Inference Model to Predict](#3.4) + + + +## 1. Dataset Introduction + + + +### 1.1 ImageNet-1k + +The ImageNet is a large-scale visual database for the research of visual object recognition. More than 14 million images have been annotated manually to point out objects in the picture in this project, and at least more than 1 million images provide bounding box. ImageNet-1k is a subset of the ImageNet dataset, which contains 1000 categories. The training set contains 1281167 image data, and the validation set contains 50,000 image data. Since 2010, the ImageNet project has held an image classification competition every year, which is the ImageNet Large-scale Visual Recognition Challenge (ILSVRC). The dataset used in the challenge is ImageNet-1k. So far, ImageNet-1k has become one of the most important data sets for the development of computer vision, and it promotes the development of the entire computer vision. The initialization models of many computer vision downstream tasks are based on the weights trained on this dataset. + + + +### 1.2 CIFAR-10/CIFAR-100 + +The CIFAR-10 dataset consists of 60,000 color images in 10 categories, with an image resolution of 32x32, and each category has 6000 images, including 5000 in the training set and 1000 in the validation set. 10 different classes represent airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships and trucks. The CIFAR-100 data set is an extension of CIFAR-10. It consists of 60,000 color images in 100 classes, with an image resolution of 32x32, and each class has 600 images, including 500 in the training set and 100 in the validation set. Researchers can try different algorithms quickly because these two data sets are small in scale. These two datasets are also commonly used data sets for testing the quality of models in the image classification field. + + + +## 2. Image Classification Process + +The prepared training data is preprocessed and then passed through the image classification model. The output of the model and the real label are used in a cross-entropy loss function. This loss function describes the convergence direction of the model. Then the corresponding gradient descent for the final loss function is calculated and returned to the model, which update the weight of the model by optimizers. Finally, an image classification model can be obtained. + + + +### 2.1 Data Preprocessing + +The quality and quantity of data often determine the performance of a model. In the field of image classification, data includes images and labels. In most cases, labeled data is scarce, so the amount of data is difficult to reach the level of saturation of the model. In order to enable the model to learn more image features, a lot of image transformation or data augmentation is required before the image enters the model, so as to ensure the diversity of input image data and ensure that the model has better generalization capabilities. PaddleClas provides standard image transformation for training ImageNet-1k, and also provides 8 data augmentation methods. For related codes, please refer to [data preprocess](../../../ppcls/data/preprocess),The configuration file refer to [Data Augmentation Configuration File](../../../ppcls/configs/ImageNet/DataAugment). For related algorithms, please refer to [data augment algorithms](../algorithm_introduction/DataAugmentation_en.md). + + + +### 2.2 Prepare the Model + +After the data is determined, the model often determines the upper limit of the final accuracy. In the field of image classification, classic models emerge in an endless stream. PaddleClas provides 35 series and a total of 164 ImageNet pre-trained models. For specific accuracy, speed and other indicators, please refer to [Backbone Network Introduction](../algorithm_introduction/ImageNet_models_en.md). + + + +### 2.3 Train + +After preparing the data and model, you can start training the model and update the parameters of the model. After many iterations, a trained model can finally be obtained for image classification tasks. The training process of image classification requires a lot of experience and involves the setting of many hyperparameters. PaddleClas provides a series of [training tuning methods](./train_strategy_en.md), which can quickly help you obtain a high-precision model. + +PaddleClas support training with VisualDL to visualize the metric. VisualDL is a visualization analysis tool of PaddlePaddle, provides a variety of charts to show the trends of parameters, and visualizes model structures, data samples, histograms of tensors, PR curves , ROC curves and high-dimensional data distributions. It enables users to understand the training process and the model structure more clearly and intuitively so as to optimize models efficiently. For more information, please refer to [VisualDL](../others/VisualDL_en.md). + + + +### 2.4 Evaluation + +After a model is trained, the evaluation results of the model on the validation set can determine the performance of the model. The evaluation index is generally Top1-Acc or Top5-Acc. The higher the index, the better the model performance. + + + +## 3. Application Methods + +Please refer to [Installation](../installation/install_paddleclas_en.md) to setup environment at first, and prepare flower102 dataset by following the instruction mentioned in the [Quick Start](../quick_start/quick_start_classification_new_user_en.md). + +So far, PaddleClas supports the following training/evaluation environments: + +``` +└── CPU/Single GPU + ├── Linux + └── Windows + +└── Multi card GPU + └── Linux +``` + + + +### 3.1 Training and Evaluation on CPU or Single GPU + +If training and evaluation are performed on CPU or single GPU, it is recommended to use the `tools/train.py` and `tools/eval.py`. For training and evaluation in multi-GPU environment on Linux, please refer to [3.2 Training and evaluation on Linux+GPU](#3.2). + + + +#### 3.1.1 Model Training + +After preparing the configuration file, The training process can be started in the following way. + +```shell +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Arch.pretrained=False \ + -o Global.device=gpu +``` + +Among them, `-c` is used to specify the path of the configuration file, `-o` is used to specify the parameters needed to be modified or added, `-o Arch.pretrained=False` means to not using pre-trained models. `-o Global.device=gpu` means to use GPU for training. If you want to use the CPU for training, you need to set `Global.device` to `cpu`. + +Of course, you can also directly modify the configuration file to update the configuration. For specific configuration parameters, please refer to [Configuration Document](config_description_en.md). + +The output log examples are as follows: + +- If mixup or cutmix is used in training, top-1 and top-k (default by 5) will not be printed in the log: + + ``` + ... + [Train][Epoch 3/20][Avg]CELoss: 6.46287, loss: 6.46287 + ... + [Eval][Epoch 3][Avg]CELoss: 5.94309, loss: 5.94309, top1: 0.01961, top5: 0.07941 + ... + ``` + +- If mixup or cutmix is not used during training, in addition to the above information, top-1 and top-k (The default is 5) will also be printed in the log: + + ``` + ... + [Train][Epoch 3/20][Avg]CELoss: 6.12570, loss: 6.12570, top1: 0.01765, top5: 0.06961 + ... + [Eval][Epoch 3][Avg]CELoss: 5.40727, loss: 5.40727, top1: 0.07549, top5: 0.20980 + ... + ``` + +During training, you can view loss changes in real time through `VisualDL`, see [VisualDL](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.2/docs/en/extension/VisualDL_en.md) for details. + + + +#### 3.1.2 Model Finetuning + +After correcting config file, you can load pretrained model weight to finetune. The command is as follows: + +```shell +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Arch.pretrained=True \ + -o Global.device=gpu +``` + +Among them,`Arch.pretrained` is used to set the address to load the pretrained weights. When using it, you need to replace it with your own pretrained weights' path, or you can modify the path directly in the configuration file. You can also set it into `True` to use pretrained weights that trained in ImageNet1k. + +We also provide a lot of pre-trained models trained on the ImageNet-1k dataset. For the model list and download address, please refer to the [model library overview](../algorithm_introduction/ImageNet_models_en.md). + + + +#### 3.1.3 Resume Training + +If the training process is terminated for some reasons, you can also load the checkpoints to continue training. + +```shell +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.checkpoints="./output/MobileNetV3_large_x1_0/epoch_5" \ + -o Global.device=gpu +``` + +The configuration file does not need to be modified. You only need to add the `Global.checkpoints` parameter during training, which represents the path of the checkpoints. The parameter weights, learning rate, optimizer and other information will be loaded using this parameter. + +**Note**: + +- The `-o Global.checkpoints` parameter does not need to include the suffix of the checkpoints. The above training command will generate the checkpoints as shown below during the training process. If you want to continue training from the epoch `5`, Just set the `Global.checkpoints` to `../output/MobileNetV3_large_x1_0/epoch_5`, PaddleClas will automatically fill in the `pdopt` and `pdparams` suffixes. Files in the output directory are structured as follows: + + ``` + output + ├── MobileNetV3_large_x1_0 + │ ├── best_model.pdopt + │ ├── best_model.pdparams + │ ├── best_model.pdstates + │ ├── epoch_1.pdopt + │ ├── epoch_1.pdparams + │ ├── epoch_1.pdstates + . + . + . + ``` + + + +#### 3.1.4 Model Evaluation + +The model evaluation process can be started as follows. + +```shell +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.pretrained_model=./output/MobileNetV3_large_x1_0/best_model +``` + +The above command will use `./configs/quick_start/MobileNetV3_large_x1_0.yaml` as the configuration file to evaluate the model `./output/MobileNetV3_large_x1_0/best_model`. You can also set the evaluation by changing the parameters in the configuration file, or you can update the configuration with the `-o` parameter, as shown above. + +Some of the configurable evaluation parameters are described as follows: + +- `Arch.name`:Model name +- `Global.pretrained_model`:The path of the model file to be evaluated + +**Note:** When loading the model to be evaluated, you only need to specify the path of the model file stead of the suffix. PaddleClas will automatically add the `.pdparams` suffix, such as [3.1.3 Resume Training](#3.1.3). + +When loading the model to be evaluated, you only need to specify the path of the model file stead of the suffix. PaddleClas will automatically add the `.pdparams` suffix, such as [3.1.3 Resume Training](https://github.com/PaddlePaddle/PaddleClas/blob/ develop/docs/zh_CN/models_training/classification.md#3.1.3). + + + +### 3.2 Training and Evaluation on Linux+ Multi-GPU + +If you want to run PaddleClas on Linux with GPU, it is highly recommended to use `paddle.distributed.launch` to start the model training script(`tools/train.py`) and evaluation script(`tools/eval.py`), which can start on multi-GPU environment more conveniently. + + + +#### 3.2.1 Model Training + +The training process can be started in the following way. `paddle.distributed.launch` specifies the GPU running card number by setting `gpus`: + +```shell +# PaddleClas initiates multi-card multi-process training via launch + +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml +``` + +The format of output log information is the same as above, see [3.1.1 Model training](#3.1.1) for details. + + + +#### 3.2.2 Model Finetuning + +After configuring the yaml file, you can finetune it by loading the pretrained weights. The command is as below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Arch.pretrained=True +``` + +Among them, `Arch.pretrained` is set to `True` or `False`. It also can be used to set the address to load the pretrained weights. When using it, you need to replace it with your own pretrained weights' path, or you can modify the path directly in the configuration file. + +There contains a lot of examples of model finetuning in the [new user version](../quick_start/quick_start_classification_new_user_en.md) and [professional version](../quick_start/quick_start_classification_professional_en.md) of PaddleClas Trial in 30 mins. You can refer to this tutorial to finetune the model on a specific dataset. + + + +#### 3.2.3 Resume Training + +If the training process is terminated for some reasons, you can also load the checkpoints to continue training. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.checkpoints="./output/MobileNetV3_large_x1_0/epoch_5" \ + -o Global.device=gpu +``` + +The configuration file does not need to be modified. You only need to add the `Global.checkpoints` parameter during training, which represents the path of the checkpoints. The parameter weights, learning rate, optimizer and other information will be loaded using this parameter as described in [3.1.3 Resume training](#3.1.3). + + + +#### 3.2.4 Model Evaluation + +The model evaluation process can be started as follows. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.pretrained_model=./output/MobileNetV3_large_x1_0/best_model +``` + +About parameter description, see [3.1.4 Model evaluation](#3.1.4) for details. + + + +### 3.3 Use the Pre-trained Model to Predict + +After the training is completed, you can predict by using the pre-trained model obtained by the training. A complete example is provided in `tools/infer/infer.py` of the model library, run the following command to conduct model prediction: + +``` +python3 tools/infer.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Infer.infer_imgs=dataset/flowers102/jpg/image_00001.jpg \ + -o Global.pretrained_model=./output/MobileNetV3_large_x1_0/best_model +``` + +Parameters: + +- `Infer.infer_imgs`:The path of the image file or folder to be predicted. +- `Global.pretrained_model`:Weight file path, such as`./output/MobileNetV3_large_x1_0/best_model` + + + +### 3.4 Use the Inference Model to Predict + +By exporting the inference model,PaddlePaddle supports inference using prediction engines, which will be introduced next. Firstly, you should export inference model using `tools/export_model.py`. + +```shell +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.pretrained_model=output/MobileNetV3_large_x1_0/best_model +``` + +Among them, `Global.pretrained_model` parameter is used to specify the model file path that does not need to include the file suffix name.(such as [3.1.3 Resume Training](#3.1.3))。 + +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: + +Go to the deploy directory: + +``` +cd deploy +``` + +Using inference engine to inference. Because the mapping file of ImageNet1k dataset is `class_id_map_file` by default, here it should be set to None. + +```shell +python3 python/predict_cls.py \ + -c configs/inference_cls.yaml \ + -o Global.infer_imgs=../dataset/flowers102/jpg/image_00001.jpg \ + -o Global.inference_model_dir=../inference/ \ + -o PostProcess.Topk.class_id_map_file=None +``` + +Among them: + +- `Global.infer_imgs`:The path of the image file to be predicted. +- `Global.inference_model_dir`:Model structure file path, such as `../inference/`. +- `Global.use_tensorrt`:Whether to use the TesorRT, default by `False`. +- `Global.use_gpu`:Whether to use the GPU, default by `True`. +- `Global.enable_mkldnn`:Wheter to use `MKL-DNN`, default by `False`. It is valid when `Global.use_gpu` is `False`. +- `Global.use_fp16`:Whether to enable FP16, default by `False`. + +Note: If you want to use `Transformer` series models, such as `DeiT_***_384`, `ViT_***_384`, etc.,please pay attention to the input size of model, and need to set `resize_short=384`, `resize=384`. + +If you want to evaluate the speed of the model, it is recommended to enable TensorRT to accelerate for GPU, and MKL-DNN for CPU. diff --git a/src/PaddleClas/docs/en/models_training/config_description_en.md b/src/PaddleClas/docs/en/models_training/config_description_en.md new file mode 100644 index 0000000..d002547 --- /dev/null +++ b/src/PaddleClas/docs/en/models_training/config_description_en.md @@ -0,0 +1,270 @@ +# Configuration Instruction + +------ + +## Introdction + +The parameters in the PaddleClas configuration file(`ppcls/configs/*.yaml`)are described for you to customize or modify the hyperparameter configuration more quickly. + +## Details + +### Catalogue + +- [1. Classification model](#1) + - [1.1 Global Configuration](#1.1) + - [1.2 Architecture](#1.2) + - [1.3 Loss function](#1.3) + - [1.4 Optimizer](#1.4) + - [1.5 Data reading module(DataLoader)](#1.5) + - [1.5.1 dataset](#1.5.1) + - [1.5.2 sampler](#1.5.2) + - [1.5.3 loader](#1.5.3) + - [1.6 Evaluation metric](#1.6) + - [1.7 Inference](#1.7) +- [2. Distillation model](#2) + - [2.1 Architecture](#2.1) + - [2.2 Loss function](#2.2) + - [2.3 Evaluation metric](#2.3) +- [3. Recognition model](#3) + - [3.1 Architechture](#3.1) + - [3.2 Evaluation metric](#3.2) + + + +### 1. Classification model + +Here the configuration of `ResNet50_vd` on`ImageNet-1k`is used as an example to explain the each parameter in detail. [Configure Path](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml). + + +#### 1.1 Global Configuration + +| Parameter name | Specific meaning | Defult value | Optional value | +| ------------------ | ------------------------------------------------------- | ---------------- | ----------------- | +| checkpoints | Breakpoint model path for resuming training | null | str | +| pretrained_model | Pre-trained model path | null | str | +| output_dir | Save model path | "./output/" | str | +| save_interval | How many epochs to save the model at each interval | 1 | int | +| eval_during_train | Whether to evaluate at training | True | bool | +| eval_interval | How many epochs to evaluate at each interval | 1 | int | +| epochs | Total number of epochs in training | | int | +| print_batch_step | How many mini-batches to print out at each interval | 10 | int | +| use_visualdl | Whether to visualize the training process with visualdl | False | bool | +| image_shape | Image size | [3,224,224] | list, shape: (3,) | +| save_inference_dir | Inference model save path | "./inference" | str | +| eval_mode | Model of eval | "classification" | "retrieval" | + +**Note**:The http address of pre-trained model can be filled in the `pretrained_model` + + +#### 1.2 Architecture + +| Parameter name | Specific meaning | Defult value | Optional value | +| -------------- | ----------------- | ------------ | --------------------- | +| name | Model Arch name | ResNet50 | PaddleClas model arch | +| class_num | Category number | 1000 | int | +| pretrained | Pre-trained model | False | bool, str | + +**Note**: Here pretrained can be set to True or False, so does the path of the weights. In addition, the pretrained is disabled when Global.pretrained_model is also set to the corresponding path. + + +#### 1.3 Loss function + +| Parameter name | Specific meaning | Defult value | Optional value | +| -------------- | ------------------------------------------- | ------------ | ---------------------- | +| CELoss | cross-entropy loss function | —— | —— | +| CELoss.weight | The weight of CELoss in the whole Loss | 1.0 | float | +| CELoss.epsilon | The epsilon value of label_smooth in CELoss | 0.1 | float,between 0 and 1 | + + +#### 1.4 Optimizer + +| Parameter name | Specific meaning | Defult value | Optional value | +| ----------------- | -------------------------------- | ------------ | -------------------------------------------------- | +| name | optimizer method name | "Momentum" | Other optimizer including "RmsProp" | +| momentum | momentum value | 0.9 | float | +| lr.name | method of dropping learning rate | "Cosine" | Other dropping methods of "Linear" and "Piecewise" | +| lr.learning_rate | initial value of learning rate | 0.1 | float | +| lr.warmup_epoch | warmup rounds | 0 | int,such as 5 | +| regularizer.name | regularization method name | "L2" | ["L1", "L2"] | +| regularizer.coeff | regularization factor | 0.00007 | float | + +**Note**:The new parameters may be different when `lr.name` is different , as when `lr.name=Piecewise`, the following parameters need to be added: + +``` + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] +``` + +Referring to [learning_rate.py](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/optimizer/learning_rate.py) for adding method and parameters. + + +#### 1.5 Data reading module(DataLoader) + + +##### 1.5.1 dataset + +| Parameter name | Specific meaning | Defult value | Optional value | +| ------------------- | ------------------------------------ | ----------------------------------- | ------------------------------ | +| name | The name of the class to read the data | ImageNetDataset | VeriWild and other Dataet type | +| image_root | The path where the dataset is stored | ./dataset/ILSVRC2012/ | str | +| cls_label_path | data label list | ./dataset/ILSVRC2012/train_list.txt | str | +| transform_ops | data preprocessing for single images | —— | —— | +| batch_transform_ops | Data preprocessing for batch images | —— | —— | + +The parameter meaning of transform_ops: + +| Function name | Parameter name | Specific meaning | +| -------------- | -------------- | --------------------- | +| DecodeImage | to_rgb | data to RGB | +| | channel_first | image data by CHW | +| RandCropImage | size | Random crop | +| RandFlipImage | | Random flip | +| NormalizeImage | scale | Normalize scale value | +| | mean | Normalize mean value | +| | std | normalized variance | +| | order | Normalize order | +| CropImage | size | crop size | +| ResizeImage | resize_short | resize by short edge | + +The parameter meaning of batch_transform_ops: + +| Function name | Parameter name | Specific meaning | +| ------------- | -------------- | --------------------------------------- | +| MixupOperator | alpha | Mixup parameter value,the larger the value, the stronger the augment | + + +##### 1.5.2 sampler + +| Parameter name | Specific meaning | Default value | Optional value | +| -------------- | ------------------------------------------------------------ | ----------------------- | -------------------------------------------------- | +| name | sampler type | DistributedBatchSampler | DistributedRandomIdentitySampler and other Sampler | +| batch_size | batch size | 64 | int | +| drop_last | Whether to drop the last data that does reach the batch-size | False | bool | +| shuffle | whether to shuffle the data | True | bool | + +##### 1.5.3 loader + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| ----------------- | ---------------------------- | --------------- | ---------------- | +| num_workers | Number of data read threads | 4 | int | +| use_shared_memory | Whether to use shared memory | True | bool | + + +#### 1.6 Evaluation metric + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| -------------- | ---------------- | --------------- | ---------------- | +| TopkAcc | TopkAcc | [1, 5] | list, int | + + +#### 1.7 Inference + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| ----------------------------- | --------------------------------- | ------------------------------------- | ---------------- | +| infer_imgs | Image address to be inferred | docs/images/whl/demo.jpg | str | +| batch_size | batch size | 10 | int | +| PostProcess.name | Post-process name | Topk | str | +| PostProcess.topk | topk value | 5 | int | +| PostProcess.class_id_map_file | mapping file of class id and name | ppcls/utils/imagenet1k_label_list.txt | str | + +**Note**:The interpretation of `transforms` in the Infer module refers to the interpretation of`transform_ops`in the dataset in the data reading module. + + +### 2. Distillation model + +**Note**:Here the training configuration of `MobileNetV3_large_x1_0` on `ImageNet-1k` distilled MobileNetV3_small_x1_0 is used as an example to explain the meaning of each parameter in detail. [Configure path](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml). Only parameters that are distinct from the classification model are introduced here. + + +#### 2.1 Architecture + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| ------------------ | --------------------------------------------------------- | ---------------------- | ---------------------------------- | +| name | model arch name | DistillationModel | —— | +| class_num | category number | 1000 | int | +| freeze_params_list | freeze_params_list | [True, False] | list | +| models | model list | [Teacher, Student] | list | +| Teacher.name | teacher model name | MobileNetV3_large_x1_0 | PaddleClas model | +| Teacher.pretrained | teacher model pre-trained weights | True | Boolean or pre-trained weight path | +| Teacher.use_ssld | whether teacher model pretrained weights are ssld weights | True | Boolean | +| infer_model_name | type of the model being inferred | Student | Teacher | + +**Note**: + +1. list is represented in yaml as follows: + +``` + freeze_params_list: + - True + - False +``` + +2.Student's parameters are similar and will not be repeated. + + +#### 2.2 Loss function + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| ----------------------------------- | ------------------------------------------------------------ | --------------- | ---------------- | +| DistillationCELoss | Distillation's cross-entropy loss function | —— | —— | +| DistillationCELoss.weight | Loss weight | 1.0 | float | +| DistillationCELoss.model_name_pairs | ["Student", "Teacher"] | —— | —— | +| DistillationGTCELoss.weight | Distillation's cross-entropy loss function of model and true Label | —— | —— | +| DistillationGTCELos.weight | Loss weight | 1.0 | float | +| DistillationCELoss.model_names | Model names with real label for cross-entropy | ["Student"] | —— | + + +#### 2.3 Evaluation metric + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| ----------------------------- | ------------------- | ---------------------------- | ---------------- | +| DistillationTopkAcc | DistillationTopkAcc | including model_key and topk | —— | +| DistillationTopkAcc.model_key | the evaluated model | "Student" | "Teacher" | +| DistillationTopkAcc.topk | Topk value | [1, 5] | list, int | + +**Note**: `DistillationTopkAcc` has the same meaning as `TopkAcc`, except that it is only used in distillation tasks. + + +### 3. Recognition model + +**Note**:The training configuration of`ResNet50` on`LogoDet-3k` is used here as an example to explain the meaning of each parameter in detail. [configure path](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/Logo/ResNet50_ReID.yaml). Only parameters that are distinct from the classification model are presented here. + + +#### 3.1 Architechture + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| ---------------------- | ------------------------------------------------------------ | --------------------------- | ------------------------------------------------------------ | +| name | Model arch | "RecModel" | ["RecModel"] | +| infer_output_key | inference output value | “feature” | ["feature", "logits"] | +| infer_add_softmax | softmaxwhether to add softmax to infercne | False | [True, False] | +| Backbone.name | Backbone name | ResNet50_last_stage_stride1 | other backbone provided by PaddleClas | +| Backbone.pretrained | Backbone pre-trained model | True | Boolean value or pre-trained model path | +| BackboneStopLayer.name | The name of the output layer in Backbone | True | The`full_name`of the feature output layer in Backbone | +| Neck.name | The name of the Neck part | VehicleNeck | the dictionary structure to be passed in, the specific input parameters for the Neck network layer | +| Neck.in_channels | Input dimension size of the Neck part | 2048 | the size is the same as BackboneStopLayer.name | +| Neck.out_channels | Output the dimension size of the Neck part, i.e. feature dimension size | 512 | int | +| Head.name | Network Head part nam | CircleMargin | Arcmargin. Etc | +| Head.embedding_size | Feature dimension size | 512 | Consistent with Neck.out_channels | +| Head.class_num | number of classes | 3000 | int | +| Head.margin | margin value in CircleMargin | 0.35 | float | +| Head.scale | scale value in CircleMargin | 64 | int | + +**Note**: + +1.In PaddleClas, the `Neck` part is the connection part between Backbone and embedding layer, and `Head` part is the connection part between embedding layer and classification layer.。 + +2.`BackboneStopLayer.name` can be obtained by visualizing the model, visualization can be referred to [Netron](https://github.com/lutzroeder/netron) or [visualdl](https://github.com/PaddlePaddle/VisualDL). + +3.Calling tools/export_model.py will convert the model weights to inference model, where the infer_add_softmax parameter will control whether to add the Softmax activation function afterwards, the code default is True (the last output layer in the classification task will be connected to the Softmax activation function). In the recognition task, the activation function is not required for the feature layer, so it should be set to False here. + + + + +#### 3.2 Evaluation metric + +| Parameter name | Specific meaning | Default meaning | Optional meaning | +| -------------- | --------------------------- | --------------- | ---------------- | +| Recallk | Recall rate | [1, 5] | list, int | +| mAP | Average retrieval precision | None | None | diff --git a/src/PaddleClas/docs/en/models_training/index.rst b/src/PaddleClas/docs/en/models_training/index.rst new file mode 100644 index 0000000..1d27e65 --- /dev/null +++ b/src/PaddleClas/docs/en/models_training/index.rst @@ -0,0 +1,10 @@ +models_training +================================ + +.. toctree:: + :maxdepth: 2 + + config_description_en.md + recognition_en.md + classification_en.md + train_strategy_en.md diff --git a/src/PaddleClas/docs/en/models_training/recognition_en.md b/src/PaddleClas/docs/en/models_training/recognition_en.md new file mode 100644 index 0000000..57f2b12 --- /dev/null +++ b/src/PaddleClas/docs/en/models_training/recognition_en.md @@ -0,0 +1,341 @@ +# Image Recognition + + + +Image recognition, in PaddleClas, means that the system is able to recognize the label of a given query image. Broadly speaking, image classification falls under image recognition. But unlike ordinary image recognition, it can only discriminate the learned categories and require retraining to add new ones. The image recognition in PaddleClas, however, only need to update the corresponding search library to identify the category of the unfamiliar images without retraining the model, which not only significantly promotes the usability of the recognition system but also reduces the demand for model updates, facilitating users' deployment of the application. + +For an image to be queried, the image recognition process in PaddleClas is divided into three main parts: + +1. Mainbody Detection: for a given query image, the mainbody detector first identifies the object, thus removing useless background information to improve the recognition accuracy. +2. Feature Extraction: for each candidate region of mainbody detection, feature extraction is performed by the feature model +3. Vector Search: the extracted features are compared with the vectors in the feature gallery for similarity to obtain their label information + +The feature gallery is built in advance using the labeled image datasets. The complete image recognition system is shown in the figure below. + +![img](../../images/structure.jpg) + +To experience the whole image recognition system, or learn how to build a feature gallery, please refer to [Quick Start of Image Recognition](../quick_start/quick_start_recognition_en.md), which explains the overall application process. The following parts expound on the training part of the above three steps. + +Please first refer to the [Installation Guide](../installation/install_paddleclas_en.md) to configure the runtime environment. + +## Catalogue + +- [1. Mainbody Detection](#1) +- [2. Feature Model Training](#2) + - [2.1. Data Preparation](#2.1) + - [2. 2 Single GPU-based Training and Evaluation](#2.2) + - [2.2.1 Model Training](#2.2.1) + - [2.2.2 Resume Training](#2.2.2) + - [2.2.3 Model Evaluation](#2.2.3) + - [2.3 Export Inference Model](#2.3) +- [3. Vector Search](#3) +- [4. Basic Knowledge](#4) + + + +## 1. Mainbody Detection + +The mainbody detection training is based on [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/tree/develop), the only difference is that all the detection boxes in the mainbody detection task belong to the foreground, but it is necessary to modify `category_id` of the detection box in the annotation file to 1, while changing the `categories` mapping table in the whole annotation file to the following format, i.e., the whole category mapping table contains only `foreground`. + +``` +[{u'id': 1, u'name': u'foreground', u'supercategory': u'foreground'}] +``` + +For more information about the training method of mainbody detection, please refer to: [PaddleDetection Training Tutorial](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md#4-训练). + +For more information on the introduction and download of the model provided in PaddleClas for body detection, please refer to: [PaddleDetection Tutorial](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/image_recognition_pipeline/mainbody_detection.md). + + + +## 2. Feature Model Training + + + +### 2.1 Data Preparation + +- Go to PaddleClas directory. + +``` +## linux or mac, $path_to_PaddleClas indicates the root directory of PaddleClas,which the user needs to modify according to their real directory +cd $path_to_PaddleClas +``` + +- Go to the `dataset`. which the user needs to modify according to their real directory [CUB_200_2011](http://vision.ucsd.edu/sites/default/files/WelinderEtal10_CUB-200.pdf), which is a fine grid dataset with 200 different types of birds. Firstly, we need to download the dataset. For download, please refer to [Official Website](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html). + +```shell +# linux or mac +cd dataset + +# Copy the downloaded data into a directory. +cp {Data storage path}/CUB_200_2011.tgz . + +# Unzip +tar -xzvf CUB_200_2011.tgz + +# Go to CUB_200_2011 +cd CUB_200_2011 +``` + +When using the dataset for image retrieval, we usually use the first 100 classes as the training set, and the last 100 classes as the testing set, so we need to process those data so as to adapt the model training of image retrieval. + +```shell +# Create train and test directories +mkdir train && mkdir test + +# Divide data into training set with the first 100 classes and testing set with the last 100 classes. +ls images | awk -F "." '{if(int($1)<101)print "mv images/"$0" train/"int($1)}' | sh +ls images | awk -F "." '{if(int($1)>100)print "mv images/"$0" test/"int($1)}' | sh + +# Generate train_list and test_list +tree -r -i -f train | grep jpg | awk -F "/" '{print $0" "int($2) " "NR}' > train_list.txt +tree -r -i -f test | grep jpg | awk -F "/" '{print $0" "int($2) " "NR}' > test_list.txt +``` + +So far, we have the training set (in the `train` catalog), testing set (in the `test` catalog), `train_list.txt` and `test_list.txt` of `CUB_200_2011`. + +After data preparation, the `train` directory of `CUB_200_2011` should be: + +``` +├── 1 +│ ├── Black_Footed_Albatross_0001_796111.jpg +│ ├── Black_Footed_Albatross_0002_55.jpg + ... +├── 10 +│ ├── Red_Winged_Blackbird_0001_3695.jpg +│ ├── Red_Winged_Blackbird_0005_5636.jpg +... +``` + +`train_list.txt` should be: + +``` +train/99/Ovenbird_0137_92639.jpg 99 1 +train/99/Ovenbird_0136_92859.jpg 99 2 +train/99/Ovenbird_0135_93168.jpg 99 3 +train/99/Ovenbird_0131_92559.jpg 99 4 +train/99/Ovenbird_0130_92452.jpg 99 5 +... +``` + +The separators are shown as spaces, and the meaning of those three columns of data are the directory, label and unique id of training sets. + +The format of testing set is the same as the one of training set. + +**Note**: + +- When the gallery dataset and query dataset are the same, in order to remove the first data retrieved (the retrieved images themselves do not need to be evaluated), each data needs to correspond to a unique id for subsequent evaluation of metrics such as mAP, recall@1, etc. Please refer to [Introduction to image retrieval datasets](#Introduction to Image Retrieval Datasets) for the analysis of gallery datasets and query datasets, and [Image retrieval evaluation metrics](#Image Retrieval Evaluation Metrics) for the evaluation of mAP, recall@1, etc. + +Back to `PaddleClas` root directory. + +```shell +# linux or mac +cd ../../ +``` + + + +### 2.2 Single GPU-based Training and Evaluation + +For training and evaluation on a single GPU, the `tools/train.py` and `tools/eval.py` scripts are recommended. + +PaddleClas support training with VisualDL to visualize the metric. VisualDL is a visualization analysis tool of PaddlePaddle, provides a variety of charts to show the trends of parameters, and visualizes model structures, data samples, histograms of tensors, PR curves , ROC curves and high-dimensional data distributions. It enables users to understand the training process and the model structure more clearly and intuitively so as to optimize models efficiently. For more information, please refer to [VisualDL](../others/VisualDL_en.md). + + + +#### 2.2.1 Model Training + +Once you have prepared the configuration file, you can start training the image retrieval task in the following way. the method used by PaddleClas to train the image retrieval is metric learning, referring to [metric learning](#metric learning) for more explanations. + +```shell +# Single GPU +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Arch.Backbone.pretrained=True \ + -o Global.device=gpu +# Multi GPU +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Arch.Backbone.pretrained=True \ + -o Global.device=gpu +``` + +`-c` is used to specify the path to the configuration file, and `-o` is used to specify the parameters that need to be modified or added, where `-o Arch.Backbone.pretrained=True` indicates that the Backbone part uses the pre-trained model. In addtion,`Arch.Backbone.pretrained` can also specify the address of a specific model weight file, which needs to be replaced with the path to your own pre-trained model weight file when using it. `-o Global.device=gpu` indicates that the GPU is used for training. If you want to use a CPU for training, you need to set `Global.device` to `cpu`. + +For more detailed training configuration, you can also modify the corresponding configuration file of the model directly. Refer to the [configuration document](config_description_en.md) for specific configuration parameters. + +Run the above commands to check the output log, an example is as follows: + +```` +``` +... +[Train][Epoch 1/50][Avg]CELoss: 6.59110, TripletLossV2: 0.54044, loss: 7.13154 +... +[Eval][Epoch 1][Avg]recall1: 0.46962, recall5: 0.75608, mAP: 0.21238 +... +``` +```` + +The Backbone here is MobileNetV1, if you want to use other backbone, you can rewrite the parameter `Arch.Backbone.name`, for example by adding `-o Arch.Backbone.name={other Backbone}` to the command. In addition, as the input dimension of the `Neck` section differs between models, replacing a Backbone may require rewriting the input size here in a similar way to replacing the Backbone's name. + +In the Training Loss section, [CELoss](../../../ppcls/loss/celoss.py) and [TripletLossV2](../../../ppcls/loss/triplet.py) are used here with the following configuration files: + +``` +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 +``` + +The final total Loss is a weighted sum of all Losses, where weight defines the weight of a particular Loss in the final total. If you want to replace other Losses, you can also change the Loss field in the configuration file, for the currently supported Losses please refer to [Loss](../../../ppcls/loss). + + + +#### 2.2.2 Resume Training + +If the training task is terminated for some reasons, it can be recovered by loading the checkpoints weights file and continue training: + +```shell +# Single card +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.checkpoints="./output/RecModel/epoch_5" \ + -o Global.device=gpu +# Multi card +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.checkpoints="./output/RecModel/epoch_5" \ + -o Global.device=gpu +``` + +There is no need to modify the configuration file, just set the `Global.checkpoints` parameter when continuing training, indicating the path to the loaded breakpoint weights file, using this parameter will load both the saved checkpoints weights and information about the learning rate, optimizer, etc. + +**Note**: + +- The `-o Global.checkpoints` parameter need not contain the suffix name of the checkpoint weights file, the above training command will generate the breakpoint weights file as shown below during training, if you want to continue training from breakpoint `5` then the `Global.checkpoints` parameter just needs to be set to `". /output/RecModel/epoch_5"` and PaddleClas will automatically supplement the suffix name. + + ``` + output/ + └── RecModel + ├── best_model.pdopt + ├── best_model.pdparams + ├── best_model.pdstates + ├── epoch_1.pdopt + ├── epoch_1.pdparams + ├── epoch_1.pdstates + . + . + . + ``` + + + +#### 2.2.3 Model Evaluation + +Model evaluation can be carried out with the following commands. + +```shell +# Single card +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.pretrained_model=./output/RecModel/best_model +# Multi card +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.pretrained_model=./output/RecModel/best_model +``` + +The above command will use `./configs/quick_start/MobileNetV1_retrieval.yaml` as a configuration file to evaluate the model obtained from the above training `./output/RecModel/best_model` for evaluation. You can also set up the evaluation by changing the parameters in the configuration file, or you can update the configuration with the `-o` parameter, as shown above. + +Some of the configurable evaluation parameters are introduced as follows. + +- `Arch.name`:the name of the model +- `Global.pretrained_model`:path to the pre-trained model file of the model to be evaluated, unlike `Global.Backbone.pretrained`, the pre-trained model is the weight of the whole model instead of the Backbone only. When it is time to do model evaluation, the weights of the whole model need to be loaded. +- `Metric.Eval`:the metric to be evaluated, by default evaluates recall@1, recall@5, mAP. when you are not going to evaluate a metric, you can remove the corresponding trial marker from the configuration file; when you want to add a certain evaluation metric, you can also refer to [Metric](../../../ppcls/metric/metrics.py) section to add the relevant metric to the configuration file `Metric.Eval`. + +**Note:** + +- When loading the model to be evaluated, the path to the model file needs to be specified, but it is not necessary to include the file suffix, PaddleClas will automatically complete the `.pdparams` suffix, e.g. [2.2.2 Resume Training](#2.2.2). +- Metric learning are generally not evaluated for TopkAcc. + + + +### 2.3 Export Inference Model + +By exporting the inference model, PaddlePaddle supports the transformation of the trained model using prediction with inference engine. + +```shell +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.pretrained_model=output/RecModel/best_model \ + -o Global.save_inference_dir=./inference +``` + +`Global.pretrained_model` is used to specify the model file path, which still does not need to contain the model file suffix (e.g.[2.2.2 Model Recovery Training](#2.2.2)). When executed, it will generate the `./inference` directory, which contains the `inference.pdiparams`,`inference.pdiparams.info`, and`inference.pdmodel` files.`Global.save_inference_dir` allows you to specify the path to export the inference model. The inference model saved here is truncated at the embedding feature level, i.e. the final output of the model is n-dimensional embedding features. + +The above command will generate the model structure file (`inference.pdmodel`) and the model weights file (`inference.pdiparams`), which can then be used for inference using the inference engine. The process of inference using the inference model can be found in [Predictive inference based on the Python prediction engine](../inference_deployment/python_deploy_en.md). + + + +## 3. Vector Search + +Vector search in PaddleClas currently supports the following environments: + +``` +└── CPU + ├── Linux + ├── MacOS + └── Windows +``` + +[Faiss](https://github.com/facebookresearch/faiss) is adopted as a search library, which is an efficient one for feature search and clustering. A variety of similarity search algorithms are integrated in this library to meet different scenarios. In PaddleClas, three search algorithms are supported. + +- **HNSW32**: A graph indexing method boasts high retrieval accuracy and fast speed. However, the feature library only supports the function of adding images, not deleting image features. (Default method) +- **IVF**: An inverted index search method with fast speed but slightly lower precision. The feature library supports functions of adding and deleting image features. +- **FLAT**: A violent search algorithm presenting the highest precision, but slower retrieval speed in face of large data volume. The feature library supports functions of adding and deleting image features. + +See its detailed introduction in the [official document](https://github.com/facebookresearch/faiss/wiki). + +`Faiss` can be installed as follows: + +``` +pip install faiss-cpu==1.7.1post2 +``` + +If the above cannot be properly referenced, please `uninstall` and then `install` again, especially when you are using`windows`. + + + +## 4. Basic Knowledge + +Image retrieval refers to a query image given a specific instance (e.g. a specific target, scene, item, etc.) that contains the same instance from a database image. Unlike image classification, image retrieval solves an open set problem where the training set may not contain the class of the image being recognised. The overall process of image retrieval is: firstly, the images are represented in a suitable feature vector, secondly, a nearest neighbour search is performed on these image feature vectors using Euclidean or Cosine distances to find similar images in the base, and finally, some post-processing techniques can be used to fine-tune the retrieval results and determine information such as the category of the image being recognised. Therefore, the key to determining the performance of an image retrieval algorithm lies in the goodness of the feature vectors corresponding to the images. + + + +- Metric Learning + +Metric learning studies how to learn a distance function on a particular task so that the distance function can help nearest-neighbour based algorithms (kNN, k-means, etc.) to achieve better performance. Deep Metric Learning is a method of metric learning that aims to learn a mapping from the original features to a low-dimensional dense vector space (embedding space) such that similar objects on the embedding space are closer together using commonly used distance functions (Euclidean distance, cosine distance, etc.) ) on the embedding space, while the distances between objects of different classes are not close to each other. Deep metric learning has achieved very successful applications in the field of computer vision, such as face recognition, commodity recognition, image retrieval, pedestrian re-identification, etc. See [HERE](../algorithm_introduction/metric_learning_en.md) for detailed information. + + + +- Introduction to Image Retrieval Datasets + - Training Dataset: used to train the model so that it can learn the image features of the collection. + - Gallery Dataset: used to provide the gallery data for the image retrieval task. The gallery dataset can be the same as the training set or the test set, or different. + - Test Set (Query Dataset): used to test the goodness of the model, usually each test image in the test set is extracted with features, and then matched with the features of the underlying data to obtain recognition results, and then the metrics of the whole test set are calculated based on the recognition results. + + + +- Image Retrieval Evaluation Metrics + + - recall: indicates the number of predicted positive cases with positive labels / the number of cases with positive labels + - recall@1: Number of predicted positive cases in top-1 with positive label / Number of cases with positive label + - recall@5: Number of all predicted positive cases in top-5 retrieved with positive label / Number of cases with positive label + + - mean Average Precision(mAP) + - AP: AP refers to the average precision on different recall rates + - mAP: Average of the APs for all images in the test set diff --git a/src/PaddleClas/docs/en/models_training/train_strategy_en.md b/src/PaddleClas/docs/en/models_training/train_strategy_en.md new file mode 100644 index 0000000..9c5c722 --- /dev/null +++ b/src/PaddleClas/docs/en/models_training/train_strategy_en.md @@ -0,0 +1,122 @@ +# Tricks for Training + +## Catalogue + +- [1. Choice of Optimizers](#1) +- [2. Choice of Learning Rate and Learning Rate Declining Strategy](#2) + - [2.1 Concept of Learning Rate](#2.1) + - [2.2 Learning Rate Decline Strategy](#2.2) + - [2.3 Warmup Strategy](#2.3) +- [3. Choice of Batch_size](#3) +- [4. Choice of Weight_decay](#4) +- [5. Choice of Label_smoothing](#5) +- [6. Change the Crop Area and Stretch Transformation Degree of the Images for Small Models](#6) +- [7. Use Data Augmentation to Improve Accuracy](#7) +- [8. Determine the Tuning Strategy by Train_acc and Test_acc](#8) +- [9. Improve the Accuracy of Your Own Data Set with Existing Pre-trained Models](#9) + + +## 1. Choice of Optimizers +Since the development of deep learning, there have been many researchers working on the optimizer. The purpose of the optimizer is to make the loss function as small as possible, so as to find suitable parameters to complete a certain task. At present, the main optimizers used in model training are SGD, RMSProp, Adam, AdaDelt and so on. The SGD optimizers with momentum is widely used in academia and industry, so most of models we release are trained by SGD optimizer with momentum. But the SGD optimizer with momentum has two disadvantages, one is that the convergence speed is slow, the other is that the initial learning rate is difficult to set, however, if the initial learning rate is set properly and the models are trained in sufficient iterations, the models trained by SGD with momentum can reach higher accuracy compared with the models trained by other optimizers. Some other optimizers with adaptive learning rate such as Adam, RMSProp and so on tent to converge faster, but the final convergence accuracy will be slightly worse. If you want to train a model in faster convergence speed, we recommend you use the optimizers with adaptive learning rate, but if you want to train a model with higher accuracy, we recommend you to use SGD optimizer with momentum. + + +## 2. Choice of Learning Rate and Learning Rate Declining Strategy +The choice of learning rate is related to the optimizer, data set and tasks. Here we mainly introduce the learning rate of training ImageNet-1K with momentum + SGD as the optimizer and the choice of learning rate decline. + + +### 2.1 Concept of Learning Rate +the learning rate is the hyperparameter to control the learning speed, the lower the learning rate, the slower the change of the loss value, though using a low learning rate can ensure that you will not miss any local minimum, but it also means that the convergence speed is slow, especially when the gradient is trapped in a gradient plateau area. + + +### 2.2 Learning Rate Decline Strategy +During training, if we always use the same learning rate, we cannot get the model with highest accuracy, so the learning rate should be adjust during training. In the early stage of training, the weights are in a random initialization state and the gradients are tended to descent, so we can set a relatively large learning rate for faster convergence. In the late stage of training, the weights are close to the optimal values, the optimal value cannot be reached by a relatively large learning rate, so a relatively smaller learning rate should be used. During training, many researchers use the piecewise_decay learning rate reduction strategy, which is a stepwise decline learning rate. For example, in the training of ResNet50, the initial learning rate we set is 0.1, and the learning rate drops to 1/10 every 30 epoches, the total epoches for training is 120. Besides the piecewise_decay, many researchers also proposed other ways to decrease the learning rate, such as polynomial_decay, exponential_decay and cosine_decay and so on, among them, cosine_decay has become the preferred learning rate reduction method for improving model accuracy beacause there is no need to adjust hyperparameters and the robustness is relatively high. The learning rate curves of cosine_decay and piecewise_decay are shown in the following figures, it is easy to observe that during the entire training process, cosine_decay keeps a relatively large learning rate, so its convergence is slower, but the final convergence accuracy is better than the one using piecewise_decay. + +![](../../images/models/lr_decay.jpeg) + +In addition, we can also see from the figures that the number of epoches with a small learning rate in cosine_decay is fewer, which will affect the final accuracy, so in order to make cosine_decay play a better effect, it is recommended to use cosine_decay in large epoched, such as 200 epoches. + + +### 2.3 Warmup Strategy +If a large batch_size is adopted to train nerual network, we recommend you to adopt warmup strategy. as the name suggests, the warmup strategy is to let model learning first warm up, we do not directly use the initial learning rate at the begining of training, instead, we use a gradually increasing learning rate to train the model, when the increasing learning rate reaches the initial learning rate, the learning rate reduction method mentioned in the learning rate reduction strategy is then used to decay the learning rate. Experiments show that when the batch size is large, warmup strategy can improve the accuracy. Some model training with large batch_size such as MobileNetV3 training, we set the epoch in warmup to 5 by default, that is, first in 5 epoches, the learning rate increases from 0 to initial learning rate, then learning rate decay begins. + + +## 3. Choice of Batch_size +Batch_size is an important hyperparameter in training neural networks, batch_size determines how much data is sent to the neural network to for training at a time. In the paper [1], the author found in experiments that when batch_size is linearly related to the learning rate, the convergence accuracy is hardly affected. When training ImageNet data, an initial learning rate of 0.1 are commonly chosen for training, and batch_size is 256, so according to the actual model size and memory, you can set the learning rate to 0.1\*k, batch_size to 256\*k. + + +## 4. Choice of Weight_decay +Overfitting is a common term in machine learning. A simple understanding is that the model performs well on the training data, but it performs poorly on the test data. In the convolutional neural network, there also exists the problem of overfitting. To avoid overfitting, many regular ways have been proposed. Among them, weight_decay is one of the widely used ways to avoid overfitting. After the final loss function, L2 regularization(weight_decay) is added to the loss function, with the help of L2 regularization, the weight of the network tend to choose a smaller value, and finally the parameters in the entire network tends to 0, and the generalization performance of the model is improved accordingly. In different kinds of Deep learning frame, the meaning of L2_decay is the coefficient of L2 regularization, on paddle, the name of this value is L2_decay, so in the following the value is called L2_decay. the larger the coefficient, the more the model tends to be underfitting. In the task of training ImageNet, this parameter is set to 1e-4 in most network. In some small networks such as MobileNet networks, in order to avoid network underfitting, the value is set to 1e-5 ~ 4e-5. Of course, the setting of this value is also related to the specific data set, When the data set is large, the network itself tends to be under-fitted, and the value can be appropriately reduced. When the data set is small, the network tends to overfit itself, so the value can be increased appropriately. The following table shows the accuracy of MobileNetV1_x0_25 using different l2_decay on ImageNet-1k. Since MobileNetV1_x0_25 is a relatively small network, the large l2_decay will make the network tend to be underfitting, so in this network, 3e-5 are better choices compared with 1e-4. + +| Model | L2_decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 1e-4 | 43.79%/67.61% | 50.41%/74.70% | +| MobileNetV1_x0_25 | 3e-5 | 47.38%/70.83% | 51.45%/75.45% | + +In addition, the setting of L2_decay is also related to whether other regularization is used during training. If the data argument during the training is more complicated, which means that the training becomes more difficult, L2_decay can be appropriately reduced. The following table shows that the precision of ResNet50 using a different l2_decay on ImageNet-1K. It is easy to observe that after the training becomes difficult, using a smaller l2_decay helps to improve the accuracy of the model. + +| Model | L2_decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| ResNet50 | 1e-4 | 75.13%/90.42% | 77.65%/93.79% | +| ResNet50 | 7e-5 | 75.56%/90.55% | 78.04%/93.74% | + +In summary, l2_decay can be adjusted according to specific tasks and models. Usually simple tasks or larger models are recommended to use Larger l2_decay, complex tasks or smaller models are recommended to use smaller l2_decay. + + +## 5. Choice of Label_smoothing +Label_smoothing is a regularization method in deep learning. Its full name is Label Smoothing Regularization (LSR), that is, label smoothing regularization. In the traditional classification task, when calculating the loss function, the real one hot label and the output of the neural network are calculated in cross-entropy formula, the label smoothing aims to make the real one hot label become smooth label, which makes the neural network no longer learn from the hard labels, but the soft labels with a probability value, where the probability of the position corresponding to the category is the largest and the probability of other positions are very small value, specific calculation method can be seen in the paper[2]. In label-smoothing, there is an epsilon parameter describing the degree of softening the label. The larger epsilon, the smaller the probability and smoother the label, on the contrary, the label tends to be hard label. during training on ImageNet-1K, the parameter is usually set to 0.1. In the experiments of training ResNet50, when using label_smoothing, the accuracy is higher than the one without label_smoothing, the following table shows the performance of ResNet50_vd with label smoothing and without label smoothing. + +| Model | Use_label_smoothing | Test acc1 | +|:--:|:--:|:--:| +| ResNet50_vd | 0 | 77.9% | +| ResNet50_vd | 1 | 78.4% | + +But, because label smoothing can be regarded as a regular way, on relatively small models, the accuracy improvement is not obvious or even decreases, the following table shows the accuracy performance of ResNet18 with label smoothing and without label smoothing on ImageNet-1K, it can be clearly seen that after using label smoothing, the accuracy of ResNet has decreased. + +| Model | Use_label_smoohing | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| ResNet18 | 0 | 69.81%/87.70% | 70.98%/89.92% | +| ResNet18 | 1 | 68.00%/86.56% | 70.81%/89.89% | + + +In summary, the use of label_smoohing for larger models can effectively improve the accuracy of the model, and the use of label_smoohing for smaller models may reduce the accuracy of the model, so before deciding whether to use label_smoohing, you need to evaluate the size of the model and the difficulty of the task. + + +## 6. Change the Crop Area and Stretch Transformation Degree of the Images for Small Models +In the standard preprocessing of ImageNet-1k data, two values of scale and ratio are defined in the random_crop function. These two values respectively determine the size of the image crop and the degree of stretching of the image. The default value of scale is 0.08-1(lower_scale-upper_scale), the default value range of ratio is 3/4-4/3(lower_ratio-upper_ratio). In small network training, such data argument will make the network underfitting, resulting in a decrease in accuracy. In order to improve the accuracy of the network, you can make the data argument weaker, that is, increase the crop area of the images or weaken the degree of stretching and transformation of the images, we can achieve weaker image transformation by increasing the value of lower_scale or narrowing the gap between lower_ratio and upper_scale. The following table lists the accuracy of training MobileNetV2_x0_25 with different lower_scale. It can be seen that the training accuracy and validation accuracy are improved after increasing the crop area of the images + +| Model | Scale Range | Train_acc1/acc5 | Test_acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV2_x0_25 | [0.08,1] | 50.36%/72.98% | 52.35%/75.65% | +| MobileNetV2_x0_25 | [0.2,1] | 54.39%/77.08% | 53.18%/76.14% | + + +## 7. Use Data Augmentation to Improve Accuracy +In general, the size of the data set is critical to the performances, but the annotation of images are often more expensive, so the number of annotated images are often scarce. In this case, the data argument is particularly important. In the standard data augmentation for training on ImageNet-1k, two data augmentation methods which are random_crop and random_flip are mainly used. However, in recent years, more and more data augmentation methods have been proposed, such as cutout, mixup, cutmix, AutoAugment, etc. Experiments show that these data augmentation methods can effectively improve the accuracy of the model. The following table lists the performance of ResNet50 in 8 different data augmentation methods. It can be seen that compared to the baseline, all data augmentation methods can be useful for the accuracy of ResNet50, among them cutmix is currently the most effective data argument. More data argument can be seen here[**Data Argument**](https://paddleclas.readthedocs.io/zh_CN/latest/advanced_tutorials/image_augmentation/ImageAugment.html). + +| Model | Data Argument | Test top-1 | +|:--:|:--:|:--:| +| ResNet50 | Baseline | 77.31% | +| ResNet50 | Auto-Augment | 77.95% | +| ResNet50 | Mixup | 78.28% | +| ResNet50 | Cutmix | 78.39% | +| ResNet50 | Cutout | 78.01% | +| ResNet50 | Gridmask | 77.85% | +| ResNet50 | Random-Augment | 77.70% | +| ResNet50 | Random-Erasing | 77.91% | +| ResNet50 | Hide-and-Seek | 77.43% | + + +## 8. Determine the Tuning Strategy by Train_acc and Test_acc +In the process of training the network, the training set accuracy rate and validation set accuracy rate of each epoch are usually printed. Generally speaking, the accuracy of the training set is slightly higher than the accuracy of the validation set or the same are good state in training, but if you find that the accuracy of training set is much higher than the one of validation set, it means that overfitting happens in your task, which need more regularization, such as increase the value of L2_decay, using more data argument or label smoothing and so on. If you find that the accuracy of training set is lower than the one of validation set, it means that underfitting happens in your task, which recommend you to decrease the value of L2_decay, using fewer data argument, increase the area of the crop area of the images, weaken the stretching transformation of the images, remove label_smoothing, etc. + + +## 9. Improve the Accuracy of Your Own Data Set with Existing Pre-trained Models +In the field of computer vision, it has become common to load pre-trained models to train one's own tasks. Compared with starting training from random initialization, loading pre-trained models can often improve the accuracy of specific tasks. In general, the pre-trained model widely used in the industry is obtained from the ImageNet-1k dataset. The fc layer weight of the pre-trained model is a matrix of k\*1000, where k is The number of neurons before, and the weights of the fc layer is not need to load because of the different tasks. In terms of learning rate, if your training data set is particularly small (such as less than 1,000), we recommend that you use a smaller initial learning rate, such as 0.001 (batch_size: 256, the same below), to avoid a large learning rate undermine pre-training weights, if your training data set is relatively large (greater than 100,000), we recommend that you try a larger initial learning rate, such as 0.01 or greater. + + +> If you think this guide is helpful to you, welcome to star our repo:[https://github.com/PaddlePaddle/PaddleClas](https://github.com/PaddlePaddle/PaddleClas) + +## Reference +[1]P. Goyal, P. Dolla ́r, R. B. Girshick, P. Noordhuis, L. Wesolowski, A. Kyrola, A. Tulloch, Y. Jia, and K. He. Accurate, large minibatch SGD: training imagenet in 1 hour. CoRR, abs/1706.02677, 2017. + +[2]C.Szegedy,V.Vanhoucke,S.Ioffe,J.Shlens,andZ.Wojna. Rethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015. diff --git a/src/PaddleClas/docs/en/others/VisualDL_en.md b/src/PaddleClas/docs/en/others/VisualDL_en.md new file mode 100644 index 0000000..34ff4b8 --- /dev/null +++ b/src/PaddleClas/docs/en/others/VisualDL_en.md @@ -0,0 +1,57 @@ +# Use VisualDL to visualize the training + +--- + +## Catalogue + +* [1. Preface](#1) +* [2. Use VisualDL in PaddleClas](#2) + * [2.1 Set config and start training](#2.1) + * [2.2 Start VisualDL](#2.2) + + +## 1. Preface +VisualDL, a visualization analysis tool of PaddlePaddle, provides a variety of charts to show the trends of parameters, and visualizes model structures, data samples, histograms of tensors, PR curves , ROC curves and high-dimensional data distributions. It enables users to understand the training process and the model structure more clearly and intuitively so as to optimize models efficiently. For more information, please refer to [VisualDL](https://github.com/PaddlePaddle/VisualDL/). + + +## 2. Use VisualDL in PaddleClas +Now PaddleClas support use VisualDL to visualize the changes of learning rate, loss, accuracy in training. + + +### 2.1 Set config and start training +You only need to set the field `Global.use_visualdl` to `True` in train config: + +```yaml +# config.yaml +Global: +... + use_visualdl: True +... +``` + +PaddleClas will save the VisualDL logs to subdirectory `vdl/` under the output directory specified by `Global.output_dir`. And then you just need to start training normally: + +```shell +python3 tools/train.py -c config.yaml +``` + + +### 2.2 Start VisualDL +After starting the training program, you can start the VisualDL service in a new terminal session: + +```shell + visualdl --logdir ./output/vdl/ +``` + +In the above command, `--logdir` specify the directory of the VisualDL logs produced in training. VisualDL will traverse and iterate to find the subdirectories of the specified directory to visualize all the experimental results. You can also use the following parameters to set the IP and port number of the VisualDL service: + +* `--host`:ip, default is 127.0.0.1 +* `--port`:port, default is 8040 + +More information about the command,please refer to [VisualDL](https://github.com/PaddlePaddle/VisualDL/blob/develop/README.md#2-launch-panel). + +Then you can enter the address `127.0.0.1:8840` and view the training process in the browser: + + +![](../../images/VisualDL/train_loss.png) + diff --git a/src/PaddleClas/docs/en/others/competition_support_en.md b/src/PaddleClas/docs/en/others/competition_support_en.md new file mode 100644 index 0000000..da63d96 --- /dev/null +++ b/src/PaddleClas/docs/en/others/competition_support_en.md @@ -0,0 +1,21 @@ +### Competition Support + +PaddleClas stems from the Baidu's visual business applications and the exploration of frontier visual capabilities. It has helped us achieve leading results in many key events, and continues to promote more frontier visual solutions and landing applications. + + +* 1st place in 2018 Kaggle Open Images V4 object detection challenge + + +* 2nd place in 2019 Kaggle Open Images V5 object detection challenge + * The report is avaiable here: [https://arxiv.org/pdf/1911.07171.pdf](https://arxiv.org/pdf/1911.07171.pdf) + * The pretrained model and code is avaiable here: [source code](https://github.com/PaddlePaddle/PaddleDetection/blob/master/docs/featured_model/OIDV5_BASELINE_MODEL.md) + +* 2nd place in Kacggle Landmark Retrieval Challenge 2019 + * The report is avaiable here: [https://arxiv.org/abs/1906.03990](https://arxiv.org/abs/1906.03990) + * The pretrained model and code is avaiable here: [source code](https://github.com/PaddlePaddle/Research/tree/master/CV/landmark) + +* 2nd place in Kaggle Landmark Recognition Challenge 2019 + * The report is avaiable here: [https://arxiv.org/abs/1906.03990](https://arxiv.org/abs/1906.03990) + * The pretrained model and code is avaiable here: [source code](https://github.com/PaddlePaddle/Research/tree/master/CV/landmark) + +* A-level certificate of three tasks: printed text OCR, face recognition and landmark recognition in the first multimedia information recognition technology competition diff --git a/src/PaddleClas/docs/en/others/feature_visiualization_en.md b/src/PaddleClas/docs/en/others/feature_visiualization_en.md new file mode 100644 index 0000000..1d20525 --- /dev/null +++ b/src/PaddleClas/docs/en/others/feature_visiualization_en.md @@ -0,0 +1,107 @@ +# Guide to Feature Graph Visualization + +------ + +## Catalogue + +- [1. Overview](#1) +- [2. Prepare Work](#2) +- [3. Model Modification](#3) +- [4. Results](#4) + + + + + +## 1. Overview + +The feature graph is the feature representation of the input image in the convolutional network, and the study of which can be beneficial to our understanding and design of the model. Therefore, we employ this tool to visualize the feature graph based on the dynamic graph. + + + +## 2. Prepare Work + +The first step is to select the model to be studied, here we choose ResNet50. Copy the model networking code [resnet.py](../../../ppcls/arch/backbone/legendary_models/resnet.py) to [directory](../../../ppcls/utils/feature_maps_visualization/) and download the [ResNet50 pre-training model](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_pretrained.pdparams) or follow the command below. + +```bash +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_pretrained.pdparams +``` + +For other pre-training models and codes of network structure, please download [model library](../../../ppcls/arch/backbone/) and [pre-training models](../models/models_intro_en.md). + + + +## 3. Model Modification + +Having found the location of the needed feature graph, set self.fm to fetch it out. Here we adopt the feature graph after the stem layer in resnet50 as an example. + +Specify the feature graph to be visualized in the forward function of ResNet50 + +```python + def forward(self, x): + with paddle.static.amp.fp16_guard(): + if self.data_format == "NHWC": + x = paddle.transpose(x, [0, 2, 3, 1]) + x.stop_gradient = True + x = self.stem(x) + fm = x + x = self.max_pool(x) + x = self.blocks(x) + x = self.avg_pool(x) + x = self.flatten(x) + x = self.fc(x) + return x, fm +``` + +Then modify the code [fm_vis.py](../../../ppcls/utils/feature_maps_visualization/fm_vis.py) to import `ResNet50`,instantiating the `net` object: + +``` +from resnet import ResNet50 +net = ResNet50() +``` + +Finally, execute the function + +``` +python tools/feature_maps_visualization/fm_vis.py \ + -i the image you want to test \ + -c channel_num -p pretrained model \ + --show whether to show \ + --interpolation interpolation method\ + --save_path where to save \ + --use_gpu whether to use gpu +``` + +Parameters: + +- `-i`: the path of the image file to be predicted, such as`./test.jpeg` +- `-c`: the dimension of feature graph, such as `5` +- `-p`: path of the weight file, such as `./ResNet50_pretrained` +- `--interpolation`: image interpolation method, default value 1 +- `--save_path`: save path, such as `./tools/` +- `--use_gpu`: whether to enable GPU inference, default value: True + + + +## 4. Results + +- Import the Image: + +![](../../images/feature_maps/feature_visualization_input.jpg) + +- Run the following script of feature graph visualization + +``` +python tools/feature_maps_visualization/fm_vis.py \ + -i ./docs/images/feature_maps/feature_visualization_input.jpg \ + -c 5 \ + -p pretrained/ResNet50_pretrained/ \ + --show=True \ + --interpolation=1 \ + --save_path="./output.png" \ + --use_gpu=False +``` + +- Save the output feature graph as `output.png`, as shown below. + +![](../../images/feature_maps/feature_visualization_output.jpg) diff --git a/src/PaddleClas/docs/en/others/index.rst b/src/PaddleClas/docs/en/others/index.rst new file mode 100644 index 0000000..d106343 --- /dev/null +++ b/src/PaddleClas/docs/en/others/index.rst @@ -0,0 +1,15 @@ +others +================================ + +.. toctree:: + :maxdepth: 2 + + transfer_learning_en.md + train_with_DALI_en.md + VisualDL_en.md + train_on_xpu_en.md + feature_visiualization_en.md + paddle_mobile_inference_en.md + competition_support_en.md + update_history_en.md + versions_en.md diff --git a/src/PaddleClas/docs/en/others/paddle_mobile_inference_en.md b/src/PaddleClas/docs/en/others/paddle_mobile_inference_en.md new file mode 100644 index 0000000..4cb7317 --- /dev/null +++ b/src/PaddleClas/docs/en/others/paddle_mobile_inference_en.md @@ -0,0 +1,130 @@ +# Benchmark on Mobile + +--- + +## Catalogue + +* [1. Introduction](#1) +* [2. Evaluation Steps](#2) + * [2.1 Export the Inference Model](#2.1) + * [2.2 Download Benchmark Binary File](#2.2) + * [2.3 Inference benchmark](#2.3) + * [2.4 Model Optimization and Speed Evaluation](#2.4) + + +## 1. Introduction + +[Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) is a set of lightweight inference engine which is fully functional, easy to use and then performs well. Lightweighting is reflected in the use of fewer bits to represent the weight and activation of the neural network, which can greatly reduce the size of the model, solve the problem of limited storage space of the mobile device, and the inference speed is better than other frameworks on the whole. + +In [PaddleClas](https://github.com/PaddlePaddle/PaddleClas), we uses Paddle-Lite to [evaluate the performance on the mobile device](../models/Mobile_en.md), in this section we uses the `MobileNetV1` model trained on the `ImageNet1k` dataset as an example to introduce how to use `Paddle-Lite` to evaluate the model speed on the mobile terminal (evaluated on SD855) + + +## 2. Evaluation Steps + + +### 2.1 Export the Inference Model + +* First you should transform the saved model during training to the special model which can be used to inference, the special model can be exported by `tools/export_model.py`, the specific way of transform is as follows. + +```shell +python tools/export_model.py -m MobileNetV1 -p pretrained/MobileNetV1_pretrained/ -o inference/MobileNetV1 +``` + +Finally the `model` and `parmas` can be saved in `inference/MobileNetV1`. + + +### 2.2 Download Benchmark Binary File + +* Use the adb (Android Debug Bridge) tool to connect the Android phone and the PC, then develop and debug. After installing adb and ensuring that the PC and the phone are successfully connected, use the following command to view the ARM version of the phone and select the pre-compiled library based on ARM version. + +```shell +adb shell getprop ro.product.cpu.abi +``` + +* Download Benchmark_bin File + +```shell +wget -c https://paddle-inference-dist.bj.bcebos.com/PaddleLite/benchmark_0/benchmark_bin_v8 +``` + +If the ARM version is v7, the v7 benchmark_bin file should be downloaded, the command is as follow. + +```shell +wget -c https://paddle-inference-dist.bj.bcebos.com/PaddleLite/benchmark_0/benchmark_bin_v7 +``` + + +### 2.3 Inference benchmark + +After the PC and mobile phone are successfully connected, use the following command to start the model evaluation. + +``` +sh deploy/lite/benchmark/benchmark.sh ./benchmark_bin_v8 ./inference result_armv8.txt true +``` + +Where `./benchmark_bin_v8` is the path of the benchmark binary file, `./inference` is the path of all the models that need to be evaluated, `result_armv8.txt` is the result file, and the final parameter `true` means that the model will be optimized before evaluation. Eventually, the evaluation result file of `result_armv8.txt` will be saved in the current folder. The specific performances are as follows. + +``` +PaddleLite Benchmark +Threads=1 Warmup=10 Repeats=30 +MobileNetV1 min = 30.89100 max = 30.73600 average = 30.79750 + +Threads=2 Warmup=10 Repeats=30 +MobileNetV1 min = 18.26600 max = 18.14000 average = 18.21637 + +Threads=4 Warmup=10 Repeats=30 +MobileNetV1 min = 10.03200 max = 9.94300 average = 9.97627 +``` + +Here is the model inference speed under different number of threads, the unit is FPS, taking model on one threads as an example, the average speed of MobileNetV1 on SD855 is `30.79750FPS`. + + +### 2.4 Model Optimization and Speed Evaluation + +* In II.III section, we mention that the model will be optimized before evaluation, here you can first optimize the model, and then directly load the optimized model for speed evaluation + +* Paddle-Lite +In Paddle-Lite, we provides multiple strategies to automatically optimize the original training model, which contain Quantify, Subgraph fusion, Hybrid scheduling, Kernel optimization and so on. In order to make the optimization more convenient and easy to use, we provide opt tools to automatically complete the optimization steps and output a lightweight, optimal and executable model in Paddle-Lite, which can be downloaded on [Paddle-Lite Model Optimization Page](https://paddle-lite.readthedocs.io/zh/latest/user_guides/model_optimize_tool.html). Here we take `MacOS` as our development environment, download[opt_mac](https://paddlelite-data.bj.bcebos.com/model_optimize_tool/opt_mac) model optimization tools and use the following commands to optimize the model. + + +```shell +model_file="../MobileNetV1/model" +param_file="../MobileNetV1/params" +opt_models_dir="./opt_models" +mkdir ${opt_models_dir} +./opt_mac --model_file=${model_file} \ + --param_file=${param_file} \ + --valid_targets=arm \ + --optimize_out_type=naive_buffer \ + --prefer_int8_kernel=false \ + --optimize_out=${opt_models_dir}/MobileNetV1 +``` + +Where the `model_file` and `param_file` are exported model file and the file address respectively, after transforming successfully, the `MobileNetV1.nb` will be saved in `opt_models` + + + +Use the benchmark_bin file to load the optimized model for evaluation. The commands are as follows. + +```shell +bash benchmark.sh ./benchmark_bin_v8 ./opt_models result_armv8.txt +``` + +Finally the result is saved in `result_armv8.txt` and shown as follow. + +``` +PaddleLite Benchmark +Threads=1 Warmup=10 Repeats=30 +MobileNetV1_lite min = 30.89500 max = 30.78500 average = 30.84173 + +Threads=2 Warmup=10 Repeats=30 +MobileNetV1_lite min = 18.25300 max = 18.11000 average = 18.18017 + +Threads=4 Warmup=10 Repeats=30 +MobileNetV1_lite min = 10.00600 max = 9.90000 average = 9.96177 +``` + + +Taking the model on one threads as an example, the average speed of MobileNetV1 on SD855 is `30.84173FPS`. + +More specific parameter explanation and Paddle-Lite usage can refer to [Paddle-Lite docs](https://paddle-lite.readthedocs.io/zh/latest/)。 diff --git a/src/PaddleClas/docs/en/others/train_on_xpu_en.md b/src/PaddleClas/docs/en/others/train_on_xpu_en.md new file mode 100644 index 0000000..5fb44b1 --- /dev/null +++ b/src/PaddleClas/docs/en/others/train_on_xpu_en.md @@ -0,0 +1,87 @@ +# Introduction to Image Classification Model Kunlun (Continuously updated) + +------ + +## Catalogue + +- [1. Foreword](#1) +- [2. Training of Kunlun](#2) + - [2.1 ResNet50](#2.1) + - [2.2 MobileNetV3](#2.2) + - [2.3 HRNet](#2.3) + - [2.4 VGG16/19](#2.4) + + + +## 1. Forword + +- This document describes the models currently supported by Kunlun and how to train these models on Kunlun devices. To install PaddlePaddle that supports Kunlun, please refer to [install_kunlun](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/09_hardware_support/xpu_docs/paddle_install_cn.html) + + + +## 2. Training of Kunlun + +- See [quick_start](../quick_start/quick_start_classification_new_user_en.md)for data sources and pre-trained models. The training effect of Kunlun is aligned with CPU/GPU. + + + +### 2.1 ResNet50 + +- Command: + +``` +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/ResNet50_vd_finetune_kunlun.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` + +The difference with cpu/gpu training lies in the addition of -o use_xpu=True, indicating that the execution is on a Kunlun device. + + + +### 2.2 MobileNetV3 + +- Command: + +``` +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` + + + +### 2.3 HRNet + +- Command: + +``` +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/HRNet_W18_C_finetune_kunlun.yaml \ + -o is_distributed=False \ + -o use_xpu=True \ + -o use_gpu=False +``` + + + +### 2.4 VGG16/19 + +- Command: + +``` +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/VGG16_finetune_kunlun.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/VGG19_finetune_kunlun.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` diff --git a/src/PaddleClas/docs/en/others/train_with_DALI_en.md b/src/PaddleClas/docs/en/others/train_with_DALI_en.md new file mode 100644 index 0000000..790b469 --- /dev/null +++ b/src/PaddleClas/docs/en/others/train_with_DALI_en.md @@ -0,0 +1,79 @@ +# Train with DALI + +--- + +## Catalogue + +* [1. Preface](#1) +* [2. Installing DALI](#2) +* [3. Using DALI](#3) +* [4. Train with FP16](#4) + + + +## 1. Preface + +[The NVIDIA Data Loading Library](https://docs.nvidia.com/deeplearning/dali/user-guide/docs/index.html) (DALI) is a library for data loading and pre-processing to accelerate deep learning applications. It can build Dataloader of PaddlePaddle. + +Since the Deep Learning relies on a large amount of data in the training stage, these data need to be loaded and preprocessed. These operations are usually executed on the CPU, which limits the further improvement of the training speed, especially when the batch_size is large, which become the bottleneck of training speed. DALI can use GPU to accelerate these operations, thereby further improve the training speed. + + + +## 2. Installing DALI + +DALI only support Linux x64 and version of CUDA is 10.2 or later. + +* For CUDA 10: + + pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda100 + +* For CUDA 11.0: + + pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda110 + +For more information about installing DALI, please refer to [DALI](https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html). + + + +## 3. Using DALI + +Paddleclas supports training with DALI. Since DALI only supports GPU training, `CUDA_VISIBLE_DEVICES` needs to be set, and DALI needs to occupy GPU memory, so it needs to reserve GPU memory for Dali. To train with DALI, just set the fields in the training config `use_dali = True`, or start the training by the following command: + +```shell +# set the GPUs that can be seen +export CUDA_VISIBLE_DEVICES="0" + +python ppcls/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50.yaml -o Global.use_dali=True +``` + +And you can train with muti-GPUs: + +```shell +# set the GPUs that can be seen +export CUDA_VISIBLE_DEVICES="0,1,2,3" + +# set the GPU memory used for neural network training, generally 0.8 or 0.7, and the remaining GPU memory is reserved for DALI +export FLAGS_fraction_of_gpu_memory_to_use=0.80 + +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + ppcls/train.py \ + -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml \ + -o Global.use_dali=True +``` + + + +## 4. Train with FP16 + +On the basis of the above, using FP16 half-precision can further improve the training speed, you can refer to the following command. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +export FLAGS_fraction_of_gpu_memory_to_use=0.8 + +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + ppcls/train.py \ + -c ./ppcls/configs/ImageNet/ResNet/ResNet50_fp16_dygraph.yaml +``` diff --git a/src/PaddleClas/docs/en/others/transfer_learning_en.md b/src/PaddleClas/docs/en/others/transfer_learning_en.md new file mode 100644 index 0000000..05ee6cb --- /dev/null +++ b/src/PaddleClas/docs/en/others/transfer_learning_en.md @@ -0,0 +1,103 @@ +# Transfer learning in image classification + +Transfer learning is an important part of machine learning, which is widely used in various fields such as text and images. Here we mainly introduce transfer learning in the field of image classification, which is often called domain transfer, such as migration of the ImageNet classification model to the specified image classification task, such as flower classification. + +--- + +## Catalogue + +* [1. Hyperparameter search](#1) + * [1.1 Grid search](#1.1) + * [1.2 Bayesian search](#1.2) +* [2. Large-scale image classification](#2) +* [3. Reference](#3) + + +## 1. Hyperparameter search + +ImageNet is the widely used dataset for image classification. A series of empirical hyperparameters have been summarized. High accuracy can be got using the hyperparameters. However, when applied in the specified dataset, the hyperparameters may not be optimal. There are two commonly used hyperparameter search methods that can be used to help us obtain better model hyperparameters. + + +### 1.1 Grid search + +For grid search, which is also called exhaustive search, the optimal value is determined by finding the best solution from all solutions in the search space. The method is simple and effective, but when the search space is large, it takes huge computing resource. + + +### 1.2 Bayesian search + +Bayesian search, which is also called Bayesian optimization, is realized by randomly selecting a group of hyperparameters in the search space. Gaussian process is used to update the hyperparameters, compute their expected mean and variance according to the performance of the previous hyperparameters. The larger the expected mean, the greater the probability of being close to the optimal solution. The larger the expected variance, the greater the uncertainty. Usually, the hyperparameter point with large expected mean is called `exporitation`, and the hyperparameter point with large variance is called `exploration`. Acquisition function is defined to balance the expected mean and variance. The currently selected hyperparameter point is viewed as the optimal position with maximum probability. + +According to the above two search schemes, we carry out some experiments based on fixed scheme and two search schemes on 8 open source datasets. As the experimental scheme in [1], we search for 4 hyperparameters, the search space and The experimental results are as follows: + +a fixed set of parameter experiments and two search schemes on 8 open source data sets. With reference to the experimental scheme of [1], we search for 4 hyperparameters, the search space and the experimental results are as follows: + + +- Fixed scheme. + +``` +lr=0.003,l2 decay=1e-4,label smoothing=False,mixup=False +``` + +- Search space of the hyperparameters. + +``` +lr: [0.1, 0.03, 0.01, 0.003, 0.001, 0.0003, 0.0001] + +l2 decay: [1e-3, 3e-4, 1e-4, 3e-5, 1e-5, 3e-6, 1e-6] + +label smoothing: [False, True] + +mixup: [False, True] +``` + +It takes 196 times for grid search, and takes 10 times less for Bayesian search. The baseline is trained by using ImageNet1k pretrained model based on ResNet50_vd and fixed scheme. The follow shows the experiments. + + +| Dataset | Fix scheme | Grid search | Grid search time | Bayesian search | Bayesian search time| +| ------------------ | -------- | -------- | -------- | -------- | ---------- | +| Oxford-IIIT-Pets | 93.64% | 94.55% | 196 | 94.04% | 20 | +| Oxford-102-Flowers | 96.08% | 97.69% | 196 | 97.49% | 20 | +| Food101 | 87.07% | 87.52% | 196 | 87.33% | 23 | +| SUN397 | 63.27% | 64.84% | 196 | 64.55% | 20 | +| Caltech101 | 91.71% | 92.54% | 196 | 92.16% | 14 | +| DTD | 76.87% | 77.53% | 196 | 77.47% | 13 | +| Stanford Cars | 85.14% | 92.72% | 196 | 92.72% | 25 | +| FGVC Aircraft | 80.32% | 88.45% | 196 | 88.36% | 20 | + + +- The above experiments verify that Bayesian search only reduces the accuracy by 0% to 0.4% under the condition of reducing the number of searches by about 10 times compared to grid search. +- The search space can be expaned easily using Bayesian search. + + +## Large-scale image classification + +In practical applications, due to the lack of training data, the classification model trained on the ImageNet1k data set is often used as the pretrained model for other image classification tasks. In order to further help solve practical problems, based on ResNet50_vd, Baidu open sourced a self-developed large-scale classification pretrained model, in which the training data contains 100,000 categories and 43 million pictures. The pretrained model can be downloaded as follows:[**download link**](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vd_10w_pretrained.pdparams) + +We conducted transfer learning experiments on 6 self-collected datasets, + +using a set of fixed parameters and a grid search method, in which the number of training rounds was set to 20epochs, the ResNet50_vd model was selected, and the ImageNet pre-training accuracy was 79.12%. The comparison results of the experimental data set parameters and model accuracy are as follows: + + +Fixed scheme: + +``` +lr=0.001,l2 decay=1e-4,label smoothing=False,mixup=False +``` + +| Dataset | Statstics | **Pretrained moel on ImageNet
Top-1(fixed)/Top-1(search)** | **Pretrained moel on large-scale dataset
Top-1(fixed)/Top-1(search)** | +| --------------- | ----------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------- | +| Flowers | class:102
train:5789
valid:2396 | 0.7779/0.9883 | 0.9892/0.9954 | +| Hand-painted stick figures | Class:18
train:1007
valid:432 | 0.8795/0.9196 | 0.9107/0.9219 | +| Leaves | class:6
train:5256
valid:2278 | 0.8212/0.8482 | 0.8385/0.8659 | +| Container vehicle | Class:115
train:4879
valid:2094 | 0.6230/0.9556 | 0.9524/0.9702 | +| Chair | class:5
train:169
valid:78 | 0.8557/0.9688 | 0.9077/0.9792 | +| Geology | class:4
train:671
valid:296 | 0.5719/0.8094 | 0.6781/0.8219 | + +- The above experiments verified that for fixed parameters, compared with the pretrained model on ImageNet, using the large-scale classification model as a pretrained model can help us improve the model performance on a new dataset in most cases. Parameter search can be further helpful to the model performance. + + +## Reference + +[1] Kornblith, Simon, Jonathon Shlens, and Quoc V. Le. "Do better imagenet models transfer better?." *Proceedings of the IEEE conference on computer vision and pattern recognition*. 2019. + +[2] Kolesnikov, Alexander, et al. "Large Scale Learning of General Visual Representations for Transfer." *arXiv preprint arXiv:1912.11370* (2019). diff --git a/src/PaddleClas/docs/en/others/update_history_en.md b/src/PaddleClas/docs/en/others/update_history_en.md new file mode 100644 index 0000000..23c425f --- /dev/null +++ b/src/PaddleClas/docs/en/others/update_history_en.md @@ -0,0 +1,55 @@ +# Release Notes + +- 2021.04.15 + - Add `MixNet` and `ReXNet` pretrained models, `MixNet_L`'s Top-1 Acc on ImageNet-1k reaches 78.6% and `ReXNet_3_0` reaches 82.09%. +- 2021.01.27 + * Add ViT and DeiT pretrained models, ViT's Top-1 Acc on ImageNet reaches 81.05%, and DeiT reaches 85.5%. +- 2021.01.08 + * Add support for whl package and its usage, Model inference can be done by simply install paddleclas using pip. +- 2020.12.16 + * Add support for TensorRT when using cpp inference to obain more obvious acceleration. +- 2020.12.06 + * Add `SE_HRNet_W64_C_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 84.75%. +- 2020.11.23 + * Add `GhostNet_x1_3_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 79.38%. +- 2020.11.09 + * Add `InceptionV3` architecture and pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 79.1%. + +* 2020.10.20 + * Add `Res2Net50_vd_26w_4s_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 83.1%. + * Add `Res2Net101_vd_26w_4s_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 83.9%. + +- 2020.10.12 + * Add Paddle-Lite demo. + +- 2020.10.10 + * Add cpp inference demo. + * Improve FAQ tutorials. + +* 2020.09.17 + * Add `HRNet_W48_C_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 83.62%. + * Add `ResNet34_vd_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 79.72%. + +* 2020.09.07 + * Add `HRNet_W18_C_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 81.16%. + * Add `MobileNetV3_small_x0_35_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 55.55%. + +* 2020.07.14 + * Add `Res2Net200_vd_26w_4s_ssld` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 85.13%. + * Add `Fix_ResNet50_vd_ssld_v2` pretrained model, whose Top-1 Acc on ImageNet1k dataset reaches 84.00%. + +* 2020.06.17 + * Add English documents. + +* 2020.06.12 + * Add support for training and evaluation on Windows or CPU. + +* 2020.05.17 + * Add support for mixed precision training. + +* 2020.05.09 + * Add user guide about Paddle Serving and Paddle-Lite. + * Add benchmark about FP16/FP32 on T4 GPU. + +* 2020.04.14 + * First commit. diff --git a/src/PaddleClas/docs/en/others/versions_en.md b/src/PaddleClas/docs/en/others/versions_en.md new file mode 100644 index 0000000..e983a92 --- /dev/null +++ b/src/PaddleClas/docs/en/others/versions_en.md @@ -0,0 +1,60 @@ +# Version Updates + +------ + +## Catalogue + +- [1. v2.3](#1) +- [2. v2.2](#2) + + + +## 1. v2.3 + +- Model Update + - Add pre-training weights for lightweight models, including detection models and feature models + - Release PP-LCNet series of models, which are self-developed ones designed to run on CPU + - Enable SwinTransformer, Twins, and Deit to support direct training from scrach to achieve thesis accuracy. +- Basic framework capabilities + - Add DeepHash module, which supports feature model to directly export binary features + - Add PKSampler, which tackles the problem that feature models cannot be trained by multiple machines and cards + - Support PaddleSlim: support quantization, pruning training, and offline quantization of classification models and feature models + - Enable legendary models to support intermediate model output + - Support multi-label classification training +- Inference Deployment + - Replace the original feature retrieval library with Faiss to improve platform adaptability + - Support PaddleServing: support the deployment of classification models and image recognition process +- Versions of the Recommendation Library + - python: 3.7 + - PaddlePaddle: 2.1.3 + - PaddleSlim: 2.2.0 + - PaddleServing: 0.6.1 + + + +## 2. v2.2 + +- Model Updates + - Add models including LeViT, Twins, TNT, DLA, HardNet, RedNet, and SwinTransfomer +- Basic framework capabilities + - Divide the classification models into two categories + - legendary models: introduce TheseusLayer base class, add the interface to modify the network function, and support the networking data truncation and output + - model zoo: other common classification models + - Add the support of Metric Learning algorithm + - Add a variety of related loss algorithms, and the basic network module gears (allow the combination with backbone and loss) for convenient use + - Support both the general classification and metric learning-related training + - Support static graph training + - Classification training with dali acceleration supported + - Support fp16 training +- Application Updates + - Add specific application cases and related models of product recognition, vehicle recognition (vehicle fine-grained classification, vehicle ReID), logo recognition, animation character recognition + - Add a complete pipeline for image recognition, including detection module, feature extraction module, and vector search module +- Inference Deployment + - Add Mobius, Baidu's self-developed vector search module, to support the inference deployment of the image recognition system + - Image recognition, build feature library that allows batch_size>1 +- Documents Update + - Add image recognition related documents + - Fix bugs in previous documents +- Versions of the Recommendation Library + - python: 3.7 + - PaddlePaddle: 2.1.2 diff --git a/src/PaddleClas/docs/en/quick_start/index.rst b/src/PaddleClas/docs/en/quick_start/index.rst new file mode 100644 index 0000000..2edd78d --- /dev/null +++ b/src/PaddleClas/docs/en/quick_start/index.rst @@ -0,0 +1,10 @@ +quick_start +================================ + +.. toctree:: + :maxdepth: 2 + + quick_start_classification_new_user_en.md + quick_start_classification_professional_en.md + quick_start_recognition_en.md + quick_start_multilabel_classification_en.md diff --git a/src/PaddleClas/docs/en/quick_start/quick_start_classification_new_user_en.md b/src/PaddleClas/docs/en/quick_start/quick_start_classification_new_user_en.md new file mode 100644 index 0000000..12a5e74 --- /dev/null +++ b/src/PaddleClas/docs/en/quick_start/quick_start_classification_new_user_en.md @@ -0,0 +1,194 @@ +# Trial in 30mins(new users) + +This tutorial is mainly for new users, that is, users who are in the introductory stage of deep learning-related theoretical knowledge, know some python grammar, and can read simple codes. This content mainly includes the use of PaddleClas for image classification network training and model prediction. + +--- + +## Catalogue + +- [1. Basic knowledge](#1) +- [2. Environmental installation and configuration](#2) +- [3. Data preparation and processing](#3) +- [4. Model training](#4) + - [4.1 Use CPU for model training](#4.1) + - [4.1.1 Training without using pre-trained models](#4.1.1) + - [4.1.2 Use pre-trained models for training](#4.1.2) + - [4.2 Use GPU for model training](#4.2) + - [4.2.1 Training without using pre-trained models](#4.2.1) + - [4.2.2 Use pre-trained models for training](#4.2.2) +- [5. Model prediction](#5) + + +## 1. Basic knowledge + +Image classification is a pattern classification problem, which is the most basic task in computer vision. Its goal is to classify different images into different categories. We will briefly explain some concepts that need to be understood during model training. We hope to be helpful to you who are experiencing PaddleClas for the first time: + +- train/val/test dataset represents training set, validation set and test set respectively: + - Training dataset: used to train the model so that the model can recognize different types of features; + - Validation set (val dataset): the test set during the training process, which is convenient for checking the status of the model during the training process; + - Test dataset: After training the model, the test dataset is used to evaluate the results of the model. + +- Pre-trained model + + Using a pre-trained model trained on a larger dataset, that is, the weights of the parameters are preset, can help the model converge faster on the new dataset. Especially for some tasks with scarce training data, when the neural network parameters are very large, we may not be able to fully train the model with a small amount of training data. The method of loading the pre-trained model can be thought of as allowing the model to learn based on a better initial weight, so as to achieve better performance. + +- epoch + + The total number of training epochs of the model. The model passes through all the samples in the training set once, which is an epoch. When the difference between the error rate of the validation set and the error rate of the training set is small, the current number of epochs can be considered appropriate; when the error rate of the validation set first decreases and then becomes larger, it means that the number of epochs is too large and the number of epochs needs to be reduced. Otherwise, the model may overfit the training set. + +- Loss Function + + During the training process, measure the difference between the model output (predicted value) and the ground truth. + +- Accuracy (Acc): indicates the proportion of the number of samples with correct predictions to the total data + + - Top1 Acc: If the classification with the highest probability in the prediction result is correct, it is judged to be correct; + - Top5 Acc: If there is a correct classification among the top 5 probability rankings in the prediction result, it is judged as correct; + + +## 2. Environmental installation and configuration + +For specific installation steps, please refer to [Paddle Installation Document](../installation/install_paddle_en.md), [PaddleClas Installation Document](../installation/install_paddleclas_en.md). + + +## 3. Data preparation and processing + +Enter the PaddleClas directory: + +```shell +# linux or mac, $path_to_PaddleClas represents the root directory of PaddleClas, and users need to modify it according to their real directory. +cd $path_to_PaddleClas +``` + +Enter the `dataset/flowers102` directory, download and unzip the flowers102 dataset: + +```shell +# linux or mac +cd dataset/ +# If you want to download directly from the browser, you can copy the link and visit, then download and unzip +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/flowers102.zip +# unzip +unzip flowers102.zip +``` + +If there is no `wget` command or if you are downloading in the Windows operating system, you need to copy the address to the browser to download, and unzip it to the directory `PaddleClas/dataset/`. + +After the unzip operation is completed, there are three `.txt` files for training and testing under the directory `PaddleClas/dataset/flowers102`: `train_list.txt` (training set, 1020 images), `val_list.txt` (validation Set, 1020 images), `train_extra_list.txt` (larger training set, 7169 images). The format of each line in the file: **image relative path** **image label_id** (note: there is a space between the two columns), and there is also a mapping file for label id and category name: `flowers102_label_list.txt` . + +The image files of the flowers102 dataset are stored in the `dataset/flowers102/jpg` directory. The image examples are as follows: + +
+![](../../images/quick_start/Examples-Flower-102.png) +
+ +Return to the root directory of `PaddleClas`: + +```shell +# linux or mac +cd ../../ +# windoes users can open the PaddleClas root directory +``` + + +## 4. Model training + + +### 4.1 Use CPU for model training + +Since the CPU is used for model training, the calculation speed is slow, so here is ShuffleNetV2_x0_25 as an example. This model has a small amount of calculation and a faster calculation speed on the CPU. But also because the model is small, the accuracy of the trained model will also be limited. + + +#### 4.1.1 Training without using pre-trained models + +```shell +# If you are using the windows operating system, please enter the root directory of PaddleClas in cmd and execute this command: +python tools/train.py -c ./ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml +``` + +- The `-c` parameter is to specify the path of the configuration file for training, and the specific hyperparameters for training can be viewed in the `yaml` file +- The `Global.device` parameter in the `yaml` file is set to `cpu`, that is, the CPU is used for training (if not set, this parameter defaults to `gpu`) +- The `epochs` parameter in the `yaml` file is set to 20, indicating that 20 epoch iterations are performed on the entire data set. It is estimated that the training can be completed in about 20 minutes (different CPUs have slightly different training times). At this time, the training model is not sufficient. To improve the accuracy of the training model, please set this parameter to a larger value, such as **40**, the training time will be extended accordingly + + +#### 4.1.2 Use pre-trained models for training + +```shell +python tools/train.py -c ./ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml -o Arch.pretrained=True +``` + +- The `-o` parameter can be set to `True` or `False`, or it can be the storage path of the pre-training model. When `True` is selected, the pre-training weights will be automatically downloaded to the local. Note: If it is a pre-training model path, do not add: `.pdparams` + +You can compare whether to use the pre-trained model and observe the drop in loss. + + +### 4.2 Use GPU for model training + +Since GPU training is faster and more complex models can be used, take ResNet50_vd as an example. Compared with ShuffleNetV2_x0_25, this model is more computationally intensive, and the accuracy of the trained model will be higher. + +First, you must set the environment variables and use the 0th GPU for training: + +- For Linux users: + + ```shell + export CUDA_VISIBLE_DEVICES=0 + ``` + +- For Windows users + + ```shell + set CUDA_VISIBLE_DEVICES=0 + ``` + + +#### 4.2.1 Training without using pre-trained models + +```shell +python tools/train.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml +``` + +After the training is completed, the `Top1 Acc` curve of the validation set is shown below, and the highest accuracy rate is 0.2735. + +![](../../images/quick_start/r50_vd_acc.png) + + +#### 4.2.2 Use pre-trained models for training + +Based on ImageNet1k classification pre-trained model for fine-tuning, the training script is as follows: + +```shell +python tools/train.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Arch.pretrained=True +``` + +**Note**: This training script uses GPU. If you use CPU, you can modify it as shown in [4.1 Use CPU for model training] (#4.1) above. + +The `Top1 Acc` curve of the validation set is shown below. The highest accuracy rate is `0.9402`. After loading the pre-trained model, the accuracy of the flowers102 data set has been greatly improved, and the absolute accuracy has increased by more than 65%. + +![](../../images/quick_start/r50_vd_pretrained_acc.png) + + +## 5. Model prediction + +After the training is completed, the trained model can be used to predict the image category. Take the trained ResNet50_vd model as an example, the prediction code is as follows: + +```shell +cd $path_to_PaddleClas +python tools/infer.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Infer.infer_imgs=dataset/flowers102/jpg/image_00001.jpg -o Global.pretrained_model=output/ResNet50_vd/best_model +``` + +`-i` indicates the path of a single image. After running successfully, the sample results are as follows: + +`[{'class_ids': [76, 51, 37, 33, 9], 'scores': [0.99998, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00001.jpg', 'label_names': ['passion flower', 'wild pansy', 'great masterwort', 'mexican aster', 'globe thistle']}]` + + +Of course, you can also use the trained ShuffleNetV2_x0_25 model for prediction, the code is as follows: + +```shell +cd $path_to_PaddleClas +python tools/infer.py -c ./ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml -o Infer.infer_imgs=dataset/flowers102/jpg/image_00001.jpg -o Global.pretrained_model=output/ShuffleNetV2_x0_25/best_model +``` + +The `-i` parameter can also be the directory of the image file to be tested (`dataset/flowers102/jpg/`). After running successfully, some sample results are as follows: + +`[{'class_ids': [76, 51, 37, 33, 9], 'scores': [0.99998, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00001.jpg', 'label_names': ['passion flower', 'wild pansy', 'great masterwort', 'mexican aster', 'globe thistle']}, {'class_ids': [76, 51, 37, 33, 32], 'scores': [0.99999, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00002.jpg', 'label_names': ['passion flower', 'wild pansy', 'great masterwort', 'mexican aster', 'love in the mist']}, {'class_ids': [76, 12, 39, 73, 78], 'scores': [0.99998, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00003.jpg', 'label_names': ['passion flower', 'king protea', 'lenten rose', 'rose', 'toad lily']}, {'class_ids': [76, 37, 34, 12, 9], 'scores': [0.86282, 0.11177, 0.00717, 0.00599, 0.00397], 'file_name': 'dataset/flowers102/jpg/image_00004.jpg', 'label_names': ['passion flower', 'great masterwort', 'alpine sea holly', 'king protea', 'globe thistle']}, {'class_ids': [76, 37, 33, 51, 69], 'scores': [0.9999, 1e-05, 1e-05, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00005.jpg', 'label_names': ['passion flower', 'great masterwort', 'mexican aster', 'wild pansy', 'tree poppy']}, {'class_ids': [76, 37, 51, 33, 73], 'scores': [0.99999, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00006.jpg', 'label_names': ['passion flower', 'great masterwort', 'wild pansy', 'mexican aster', 'rose']}, {'class_ids': [76, 37, 12, 91, 30], 'scores': [0.98746, 0.00211, 0.00201, 0.00136, 0.0007], 'file_name': 'dataset/flowers102/jpg/image_00007.jpg', 'label_names': ['passion flower', 'great masterwort', 'king protea', 'bee balm', 'carnation']}, {'class_ids': [76, 37, 81, 77, 72], 'scores': [0.99976, 3e-05, 2e-05, 2e-05, 1e-05], 'file_name': 'dataset/flowers102/jpg/image_00008.jpg', 'label_names': ['passion flower', 'great masterwort', 'clematis', 'lotus', 'water lily']}, {'class_ids': [76, 37, 13, 12, 34], 'scores': [0.99646, 0.00144, 0.00092, 0.00035, 0.00027], 'file_name': 'dataset/flowers102/jpg/image_00009.jpg', 'label_names': ['passion flower', 'great masterwort', 'spear thistle', 'king protea', 'alpine sea holly']}, {'class_ids': [76, 37, 34, 33, 51], 'scores': [0.99999, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00010.jpg', 'label_names': ['passion flower', 'great masterwort', 'alpine sea holly', 'mexican aster', 'wild pansy']}]` + +Among them, the length of the list is the size of batch_size. \ No newline at end of file diff --git a/src/PaddleClas/docs/en/quick_start/quick_start_classification_professional_en.md b/src/PaddleClas/docs/en/quick_start/quick_start_classification_professional_en.md new file mode 100644 index 0000000..fe559fe --- /dev/null +++ b/src/PaddleClas/docs/en/quick_start/quick_start_classification_professional_en.md @@ -0,0 +1,306 @@ +# Trial in 30mins(professional) + +Here is a quick start tutorial for professional users to use PaddleClas on the Linux operating system. The main content is based on the CIFAR-100 data set. You can quickly experience the training of different models, experience loading different pre-trained models, experience the SSLD knowledge distillation solution, and experience data augmentation. Please refer to [Installation Guide](../installation/install_paddleclas_en.md) to configure the operating environment and clone PaddleClas code. + +------ + +## Catalogue + +- [1. Data and model preparation](#1) + - [1.1 Data preparation](#1.1) + - [1.1.1 Prepare CIFAR100](#1.1.1) +- [2. Model training](#2) + - [2.1 Single label training](#2.1) + - [2.1.1 Training without loading the pre-trained model](#2.1.1) + - [2.1.2 Transfer learning](#2.1.2) +- [3. Data Augmentation](#3) + - [3.1 Data augmentation-Mixup](#3.1) +- [4. Knowledge distillation](#4) +- [5. Model evaluation and inference](#5) + - [5.1 Single-label classification model evaluation and inference](#5.1) + - [5.1.1 Single-label classification model evaluation](#5.1.1) + - [5.1.2 Single-label classification model prediction](#5.1.2) + - [5.1.3 Single-label classification uses inference model for model inference](#5.1.3) + + + +## 1. Data and model preparation + + + +### 1.1 Data preparation + + +* Enter the PaddleClas directory. + +``` +cd path_to_PaddleClas +``` + + + +#### 1.1.1 Prepare CIFAR100 + +* Enter the `dataset/` directory, download and unzip the CIFAR100 dataset. + +```shell +cd dataset +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/CIFAR100.tar +tar -xf CIFAR100.tar +cd ../ +``` + + + +## 2. Model training + + + +### 2.1 Single label training + + + +#### 2.1.1 Training without loading the pre-trained model + +* Based on the ResNet50_vd model, the training script is shown below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" +``` + +The highest accuracy of the validation set is around 0.415. + + + + +#### 2.1.2 Transfer learning + +* Based on ImageNet1k classification pre-training model ResNet50_vd_pretrained (accuracy rate 79.12%) for fine-tuning, the training script is shown below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" \ + -o Arch.pretrained=True +``` + +The highest accuracy of the validation set is about 0.718. After loading the pre-trained model, the accuracy of the CIFAR100 data set has been greatly improved, with an absolute accuracy increase of 30%. + +* Based on ImageNet1k classification pre-training model ResNet50_vd_ssld_pretrained (accuracy rate of 82.39%) for fine-tuning, the training script is shown below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" \ + -o Arch.pretrained=True \ + -o Arch.use_ssld=True +``` + +In the final CIFAR100 verification set, the top-1 accuracy is 0.73. Compared with the fine-tuning of the pre-trained model with a top-1 accuracy of 79.12%, the top-1 accuracy of the new data set can be increased by 1.2% again. + +* Replace the backbone with MobileNetV3_large_x1_0 for fine-tuning, the training script is shown below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV3_large_x1_0_CIFAR100_finetune.yaml \ + -o Global.output_dir="output_CIFAR" \ + -o Arch.pretrained=True +``` + +The highest accuracy of the validation set is about 0.601, which is nearly 12% lower than ResNet50_vd. + + + + +## 3. Data Augmentation + +PaddleClas contains many data augmentation methods, such as Mixup, Cutout, RandomErasing, etc. For specific methods, please refer to [Data augmentation chapter](../algorithm_introduction/DataAugmentation_en.md)。 + + + +### 3.1 Data augmentation-Mixup + +Based on the training method in [Data Augmentation Chapter](../algorithm_introduction/DataAugmentation_en.md) in Section 3.3, combined with Mixup's data augmentation method for training, the specific training script is shown below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_mixup_CIFAR100_finetune.yaml \ + -o Global.output_dir="output_CIFAR" + +``` + + +The final accuracy on the CIFAR100 verification set is 0.73, and the use of data augmentation can increase the model accuracy by about 1.2% again. + + +* **Note** + +* For other data augmentation configuration files, please refer to the configuration files in `ppcls/configs/ImageNet/DataAugment/`. +* The number of epochs for training CIFAR100 is small, so the accuracy of the validation set may fluctuate by about 1%. + + + + +## 4. Knowledge distillation + + +PaddleClas includes a self-developed SSLD knowledge distillation scheme. For specific content, please refer to [Knowledge Distillation Chapter](../algorithm_introduction/knowledge_distillation_en.md). This section will try to use knowledge distillation technology to train the MobileNetV3_large_x1_0 model. Here we use the ResNet50_vd model trained in section 2.1.2 as the teacher model for distillation. First, save the ResNet50_vd model trained in section 2.1.2 to the specified directory. The script is as follows. + +```shell +mkdir pretrained +cp -r output_CIFAR/ResNet50_vd/best_model.pdparams ./pretrained/ +``` + +The model name, teacher model and student model configuration, pre-training address configuration, and freeze_params configuration in the configuration file are as follows, where the two values in `freeze_params_list` represent whether the teacher model and the student model freeze parameter training respectively. + +```yaml +Arch: + name: "DistillationModel" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - True + - False + models: + - Teacher: + name: ResNet50_vd + pretrained: "./pretrained/best_model" + - Student: + name: MobileNetV3_large_x1_0 + pretrained: True +``` + +The loss configuration is as follows, where the training loss is the cross entropy of the output of the student model and the teacher model, and the validation loss is the cross entropy of the output of the student model and the true label. + +```yaml +Loss: + Train: + - DistillationCELoss: + weight: 1.0 + model_name_pairs: + - ["Student", "Teacher"] + Eval: + - DistillationGTCELoss: + weight: 1.0 + model_names: ["Student"] +``` + +The final training script is shown below. + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/R50_vd_distill_MV3_large_x1_0_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" + +``` + + +In the end, the accuracy on the CIFAR100 validation set was 64.4%. Using the teacher model for knowledge distillation, the accuracy of MobileNetV3 increased by 4.3%. + +* **Note** + +* In the distillation process, the pre-trained model used by the teacher model is the training result on the CIFAR100 dataset, and the student model uses the MobileNetV3_large_x1_0 pre-trained model with an accuracy of 75.32% on the ImageNet1k dataset. + * The distillation process does not need to use real labels, so more unlabeled data can be used. In the process of use, you can generate fake `train_list.txt` from unlabeled data, and then merge it with the real `train_list.txt`, You can experience it yourself based on your own data. + + + +## 5. Model evaluation and inference + + + +### 5.1 Single-label classification model evaluation and inference + + + +#### 5.1.1 Single-label classification model evaluation + +After training the model, you can use the following commands to evaluate the accuracy of the model. + +```bash +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.pretrained_model="output_CIFAR/ResNet50_vd/best_model" +``` + + + +#### 5.1.2 Single-label classification model prediction + +After the model training is completed, the pre-trained model obtained by the training can be loaded for model prediction. A complete example is provided in `tools/infer.py`, the model prediction can be completed by executing the following command: + +```python +python3 tools/infer.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Infer.infer_imgs=./dataset/CIFAR100/test/0/0001.png \ + -o Global.pretrained_model=output_CIFAR/ResNet50_vd/best_model +``` + + + +#### 5.1.3 Single-label classification uses inference model for model inference + +We need to export the inference model, PaddlePaddle supports the use of prediction engines for inference. Here, we will introduce how to use the prediction engine for inference: +First, export the trained model to inference model: + +```bash +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.pretrained_model=output_CIFAR/ResNet50_vd/best_model +``` + +* By default, `inference.pdiparams`, `inference.pdmodel` and `inference.pdiparams.info` files will be generated in the `inference` folder. + +Use prediction engines for inference: + +Enter the deploy directory: + +```bash +cd deploy +``` + +Change the `inference_cls.yaml` file. Since the resolution used for training CIFAR100 is 32x32, the relevant resolution needs to be changed. The image preprocessing in the final configuration file is as follows: + +```yaml +PreProcess: + transform_ops: + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: +``` + +Execute the command to make predictions. Since the default `class_id_map_file` is the mapping file of the ImageNet dataset, you need to set None here. + +```bash +python3 python/predict_cls.py \ + -c configs/inference_cls.yaml \ + -o Global.infer_imgs=../dataset/CIFAR100/test/0/0001.png \ + -o PostProcess.Topk.class_id_map_file=None +``` diff --git a/src/PaddleClas/docs/en/quick_start/quick_start_multilabel_classification_en.md b/src/PaddleClas/docs/en/quick_start/quick_start_multilabel_classification_en.md new file mode 100644 index 0000000..39adbb7 --- /dev/null +++ b/src/PaddleClas/docs/en/quick_start/quick_start_multilabel_classification_en.md @@ -0,0 +1,117 @@ +# Quick Start of Multi-label Classification + +Experience the training, evaluation, and prediction of multi-label classification based on the [NUS-WIDE-SCENE](https://lms.comp.nus.edu.sg/wp-content/uploads/2019/research/nuswide/NUS-WIDE.html) dataset, which is a subset of the NUS-WIDE dataset. Please first install PaddlePaddle and PaddleClas, see [Paddle Installation](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/installation) and [PaddleClas installation](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/installation/install_ paddleclas.md) for more details. + +## Catalogue + +- [1. Data and Model Preparation](#1) +- [2. Model Training](#2) +- [3. Model Evaluation](#3) +- [4. Model Prediction](#4) +- [5. Predictive engine-based Prediction](#5) + - [5.1 Export inference model](#5.1) + - [5.2 Predictive engine-based Prediction](#5.2) + + + +## 1. Data and Model Preparation + +- Go to `PaddleClas`. + +``` +cd path_to_PaddleClas +``` + +- Create and go to `dataset/NUS-WIDE-SCENE`, download and unzip the NUS-WIDE-SCENE dataset. + +``` +mkdir dataset/NUS-WIDE-SCENE +cd dataset/NUS-WIDE-SCENE +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/NUS-SCENE-dataset.tar +tar -xf NUS-SCENE-dataset.tar +``` + +- Return to `PaddleClas` root directory + +``` +cd ../../ +``` + + + +## 2. Model Training + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml +``` + +After training 10 epochs, the best correctness of the validation set should be around 0.95. + + + +## 3. Model Evaluation + +``` +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + + + +## 4. Model Prediction + +``` +python3 tools/infer.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + +Obtain an output silimar to the following: + +``` +[{'class_ids': [6, 13, 17, 23, 26, 30], 'scores': [0.95683, 0.5567, 0.55211, 0.99088, 0.5943, 0.78767], 'file_name': './deploy/images/0517_2715693311.jpg', 'label_names': []}] +``` + + + +## 5. Predictive engine-based Prediction + + + +### 5.1 Export inference model + +``` +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + +The path of the inference model is by default under the current path `. /inference`. + + + +### 5.2 Predictive engine-based Prediction + +Go to the `deploy` first: + +``` +cd ./deploy +``` + +Inference and prediction through predictive engines: + +``` +python3 python/predict_cls.py \ + -c configs/inference_multilabel_cls.yaml +``` + +Obtain an output silimar to the following: + +``` +0517_2715693311.jpg: class id(s): [6, 13, 17, 23, 26, 30], score(s): [0.96, 0.56, 0.55, 0.99, 0.59, 0.79], label_name(s): [] +``` diff --git a/src/PaddleClas/docs/en/quick_start/quick_start_recognition_en.md b/src/PaddleClas/docs/en/quick_start/quick_start_recognition_en.md new file mode 100644 index 0000000..61c6f23 --- /dev/null +++ b/src/PaddleClas/docs/en/quick_start/quick_start_recognition_en.md @@ -0,0 +1,296 @@ +# Quick Start of Recognition + +This tutorial contains 3 parts: Environment Preparation, Image Recognition Experience, and Unknown Category Image Recognition Experience. + +If the image category already exists in the image index database, then you can take a reference to chapter [Image Recognition Experience](#2),to complete the progress of image recognition;If you wish to recognize unknow category image, which is not included in the index database,you can take a reference to chapter [Unknown Category Image Recognition Experience](#3),to complete the process of creating an index to recognize it。 + +## Catalogue + +* [1. Enviroment Preparation](#1) +* [2. Image Recognition Experience](#2) + * [2.1 Download and Unzip the Inference Model and Demo Data](#2.1) + * [2.2 Product Recognition and Retrieval](#2.2) + * [2.2.1 Single Image Recognition](#2.2.1) + * [2.2.2 Folder-based Batch Recognition](#2.2.2) +* [3. Unknown Category Image Recognition Experience](#3) + * [3.1 Prepare for the new images and labels](#3.1) + * [3.2 Build a new Index Library](#3.2) + * [3.3 Recognize the Unknown Category Images](#3.3) + + + +## 1. Enviroment Preparation + +* Installation:Please take a reference to [Quick Installation ](../installation/)to configure the PaddleClas environment. + +* Using the following command to enter Folder `deploy`. All content and commands in this section need to be run in folder `deploy`. + + ``` + cd deploy + ``` + + +## 2. Image Recognition Experience + +The detection model with the recognition inference model for the 4 directions (Logo, Cartoon Face, Vehicle, Product), the address for downloading the test data and the address of the corresponding configuration file are as follows. + +| Models Introduction | Recommended Scenarios | inference Model | Predict Config File | Config File to Build Index Database | +| ------------ | ------------- | -------- | ------- | -------- | +| Generic mainbody detection model | General Scenarios |[Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar) | - | - | +| Logo Recognition Model | Logo Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/logo_rec_ResNet50_Logo3K_v1.0_infer.tar) | [inference_logo.yaml](../../../deploy/configs/inference_logo.yaml) | [build_logo.yaml](../../../deploy/configs/build_logo.yaml) | +| Cartoon Face Recognition Model| Cartoon Face Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/cartoon_rec_ResNet50_iCartoon_v1.0_infer.tar) | [inference_cartoon.yaml](../../../deploy/configs/inference_cartoon.yaml) | [build_cartoon.yaml](../../../deploy/configs/build_cartoon.yaml) | +| Vehicle Fine-Grained Classfication Model | Vehicle Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/vehicle_cls_ResNet50_CompCars_v1.0_infer.tar) | [inference_vehicle.yaml](../../../deploy/configs/inference_vehicle.yaml) | [build_vehicle.yaml](../../../deploy/configs/build_vehicle.yaml) | +| Product Recignition Model | Product Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_aliproduct_v1.0_infer.tar) | [inference_product.yaml](../../../deploy/configs/inference_product.yaml) | [build_product.yaml](../../../deploy/configs/build_product.yaml) | +| Vehicle ReID Model | Vehicle ReID Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/vehicle_reid_ResNet50_VERIWild_v1.0_infer.tar) | - | - | + +| Models Introduction | Recommended Scenarios | inference Model | Predict Config File | Config File to Build Index Database | +| ------------ | ------------- | -------- | ------- | -------- | +| Lightweight generic mainbody detection model | General Scenarios |[Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar) | - | - | +| Lightweight generic recognition model | General Scenarios | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar) | [inference_product.yaml](../../../deploy/configs/inference_product.yaml) | [build_product.yaml](../../../deploy/configs/build_product.yaml) | + + +Demo data in this tutorial can be downloaded here: [download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.1.tar). + + +**Attention** +1. If you do not have wget installed on Windows, you can download the model by copying the link into your browser and unzipping it in the appropriate folder; for Linux or macOS users, you can right-click and copy the download link to download it via the `wget` command. +2. If you want to install `wget` on macOS, you can run the following command. +3. The predict config file of the lightweight generic recognition model and the config file to build index database are used for the config of product recognition model of server-side. You can modify the path of the model to complete the index building and prediction. + +```shell +# install homebrew +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; +# install wget +brew install wget +``` + +3. If you want to isntall `wget` on Windows, you can refer to [link](https://www.cnblogs.com/jeshy/p/10518062.html). If you want to install `tar` on Windows, you can refer to [link](https://www.cnblogs.com/chooperman/p/14190107.html). + + +* You can download and unzip the data and models by following the command below + +```shell +mkdir models +cd models +# Download and unzip the inference model +wget {Models download link} && tar -xf {Name of the tar archive} +cd .. + +# Download the demo data and unzip +wget {Data download link} && tar -xf {Name of the tar archive} +``` + + + +### 2.1 Download and Unzip the Inference Model and Demo Data + +Take the product recognition as an example, download the detection model, recognition model and product recognition demo data with the following commands. + +```shell +mkdir models +cd models +# Download the generic detection inference model and unzip it +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar && tar -xf ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar +# Download and unpack the inference model +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_aliproduct_v1.0_infer.tar && tar -xf product_ResNet50_vd_aliproduct_v1.0_infer.tar +cd .. + +# Download the demo data and unzip it +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.1.tar && tar -xf recognition_demo_data_en_v1.1.tar +``` + +Once unpacked, the `recognition_demo_data_v1.1` folder should have the following file structure. + +``` +├── recognition_demo_data_v1.1 +│ ├── gallery_cartoon +│ ├── gallery_logo +│ ├── gallery_product +│ ├── gallery_vehicle +│ ├── test_cartoon +│ ├── test_logo +│ ├── test_product +│ └── test_vehicle +├── ... +``` + +here, original images to build index are in folder `gallery_xxx`, test images are in folder `test_xxx`. You can also access specific folder for more details. + +The `models` folder should have the following file structure. + +``` +├── product_ResNet50_vd_aliproduct_v1.0_infer +│ ├── inference.pdiparams +│ ├── inference.pdiparams.info +│ └── inference.pdmodel +├── ppyolov2_r50vd_dcn_mainbody_v1.0_infer +│ ├── inference.pdiparams +│ ├── inference.pdiparams.info +│ └── inference.pdmodel +``` + +**Attention** +If you want to use the lightweight generic recognition model, you need to re-extract the features of the demo data and re-build the index. The way is as follows: + +```shell +python3.7 python/build_gallery.py -c configs/build_product.yaml -o Global.rec_inference_model_dir=./models/general_PPLCNet_x2_5_lite_v1.0_infer +``` + + +### 2.2 Product Recognition and Retrieval + +Take the product recognition demo as an example to show the recognition and retrieval process (if you wish to try other scenarios of recognition and retrieval, replace the corresponding configuration file after downloading and unzipping the corresponding demo data and model to complete the prediction). + +**Note:** `faiss` is used as search library. The installation method is as follows: + +``` +pip install faiss-cpu==1.7.1post2 +``` + +If error happens when using `import faiss`, please uninstall `faiss` and reinstall it, especially on `Windows`. + + + +#### 2.2.1 Single Image Recognition + +Run the following command to identify and retrieve the image `./recognition_demo_data_v1.1/test_product/daoxiangcunjinzhubing_6.jpg` for recognition and retrieval + +```shell +# use the following command to predict using GPU. +python3.7 python/predict_system.py -c configs/inference_product.yaml +# use the following command to predict using CPU +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.use_gpu=False +``` + + +The image to be retrieved is shown below. + +![](../../images/recognition/product_demo/query/daoxiangcunjinzhubing_6.jpg) + + +The final output is shown below. + +``` +[{'bbox': [287, 129, 497, 326], 'rec_docs': 'Daoxaingcun Golden Piggie Cake', 'rec_scores': 0.8309420347213745}, {'bbox': [99, 242, 313, 426], 'rec_docs': 'Daoxaingcun Golden Piggie Cake', 'rec_scores': 0.7245651483535767}] +``` + + +where bbox indicates the location of the detected object, rec_docs indicates the labels corresponding to the label in the index dabase that are most similar to the detected object, and rec_scores indicates the corresponding confidence. + + +The detection result is also saved in the folder `output`, for this image, the visualization result is as follows. + +![](../../images/recognition/product_demo/result/daoxiangcunjinzhubing_6_en.jpg) + + + +#### 2.2.2 Folder-based Batch Recognition + +If you want to predict the images in the folder, you can directly modify the `Global.infer_imgs` field in the configuration file, or you can also modify the corresponding configuration through the following `-o` parameter. + +```shell +# using the following command to predict using GPU, you can append `-o Global.use_gpu=False` to predict using CPU. +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.1/test_product/" +``` + + +The results on the screen are shown as following. + +``` +... +[{'bbox': [37, 29, 123, 89], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.6163763999938965}, {'bbox': [153, 96, 235, 175], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5279821157455444}] +[{'bbox': [735, 562, 1133, 851], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5588355660438538}] +[{'bbox': [124, 50, 230, 129], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.6980369687080383}] +[{'bbox': [0, 0, 275, 183], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5818190574645996}] +[{'bbox': [400, 1179, 905, 1537], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.9814301133155823}, {'bbox': [295, 713, 820, 1046], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.9496176242828369}, {'bbox': [153, 236, 694, 614], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.8395382761955261}] +[{'bbox': [544, 4, 1482, 932], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5143815279006958}] +... +``` + +All the visualization results are also saved in folder `output`. + + +Furthermore, the recognition inference model path can be changed by modifying the `Global.rec_inference_model_dir` field, and the path of the index to the index databass can be changed by modifying the `IndexProcess.index_dir` field. + + + +## 3. Recognize Images of Unknown Category + +To recognize the image `./recognition_demo_data_v1.1/test_product/anmuxi.jpg`, run the command as follows: + +```shell +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.1/test_product/anmuxi.jpg" +``` + +The image to be retrieved is shown below. + +![](../../images/recognition/product_demo/query/anmuxi.jpg) + +The output is empty. + +Since the index infomation is not included in the corresponding index databse, the recognition result is empty or not proper. At this time, we can complete the image recognition of unknown categories by constructing a new index database. + +When the index database cannot cover the scenes we actually recognise, i.e. when predicting images of unknown categories, we need to add similar images of the corresponding categories to the index databasey, thus completing the recognition of images of unknown categories ,which does not require retraining. + + +### 3.1 Prepare for the new images and labels + +First, you need to copy the images which are similar with the image to retrieval to the original images for the index database. The command is as follows. + +```shell +cp -r ../docs/images/recognition/product_demo/gallery/anmuxi ./recognition_demo_data_/gallery_product/gallery/ +``` + +Then you need to create a new label file which records the image path and label information. Use the following command to create a new file based on the original one. + +```shell +# copy the file +cp recognition_demo_data_v1.1/gallery_product/data_file.txt recognition_demo_data_v1.1/gallery_product/data_file_update.txt +``` + +Then add some new lines into the new label file, which is shown as follows. + +``` +gallery/anmuxi/001.jpg Anmuxi Ambrosial Yogurt +gallery/anmuxi/002.jpg Anmuxi Ambrosial Yogurt +gallery/anmuxi/003.jpg Anmuxi Ambrosial Yogurt +gallery/anmuxi/004.jpg Anmuxi Ambrosial Yogurt +gallery/anmuxi/005.jpg Anmuxi Ambrosial Yogurt +gallery/anmuxi/006.jpg Anmuxi Ambrosial Yogurt +``` + +Each line can be splited into two fields. The first field denotes the relative image path, and the second field denotes its label. The `delimiter` is `tab` here. + + + +### 3.2 Build a new Index Base Library + +Use the following command to build the index to accelerate the retrieval process after recognition. + +```shell +python3.7 python/build_gallery.py -c configs/build_product.yaml -o IndexProcess.data_file="./recognition_demo_data_v1.1/gallery_product/data_file_update.txt" -o IndexProcess.index_dir="./recognition_demo_data_v1.1/gallery_product/index_update" +``` + +Finally, the new index information is stored in the folder`./recognition_demo_data_v1.1/gallery_product/index_update`. Use the new index database for the above index. + + + +### 3.3 Recognize the Unknown Category Images + +To recognize the image `./recognition_demo_data_v1.1/test_product/anmuxi.jpg`, run the command as follows. + +```shell +# using the following command to predict using GPU, you can append `-o Global.use_gpu=False` to predict using CPU. +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.1/test_product/anmuxi.jpg" -o IndexProcess.index_dir="./recognition_demo_data_v1.1/gallery_product/index_update" +``` + +The output is as follows: + +``` +[{'bbox': [243, 80, 523, 522], 'rec_docs': 'Anmuxi Ambrosial Yogurt', 'rec_scores': 0.5570770502090454}] +``` + +The final recognition result is `Anmuxi Ambrosial Yogurt`, which is corrrect, the visualization result is as follows. + +![](../../images/recognition/product_demo/result/anmuxi_en.jpg) + diff --git a/src/PaddleClas/docs/images/10w_cls.png b/src/PaddleClas/docs/images/10w_cls.png new file mode 100644 index 0000000..9db4833 Binary files /dev/null and b/src/PaddleClas/docs/images/10w_cls.png differ diff --git a/src/PaddleClas/docs/images/PP-LCNet/PP-LCNet-Acc.png b/src/PaddleClas/docs/images/PP-LCNet/PP-LCNet-Acc.png new file mode 100644 index 0000000..57c6da6 Binary files /dev/null and b/src/PaddleClas/docs/images/PP-LCNet/PP-LCNet-Acc.png differ diff --git a/src/PaddleClas/docs/images/PP-LCNet/PP-LCNet.png b/src/PaddleClas/docs/images/PP-LCNet/PP-LCNet.png new file mode 100644 index 0000000..df35aa7 Binary files /dev/null and b/src/PaddleClas/docs/images/PP-LCNet/PP-LCNet.png differ diff --git a/src/PaddleClas/docs/images/VisualDL/train_loss.png b/src/PaddleClas/docs/images/VisualDL/train_loss.png new file mode 100644 index 0000000..6697707 Binary files /dev/null and b/src/PaddleClas/docs/images/VisualDL/train_loss.png differ diff --git a/src/PaddleClas/docs/images/algorithm_introduction/fpgm.png b/src/PaddleClas/docs/images/algorithm_introduction/fpgm.png new file mode 100644 index 0000000..a773e8d Binary files /dev/null and b/src/PaddleClas/docs/images/algorithm_introduction/fpgm.png differ diff --git a/src/PaddleClas/docs/images/algorithm_introduction/quantization.jpg b/src/PaddleClas/docs/images/algorithm_introduction/quantization.jpg new file mode 100644 index 0000000..abb99b7 Binary files /dev/null and b/src/PaddleClas/docs/images/algorithm_introduction/quantization.jpg differ diff --git a/src/PaddleClas/docs/images/algorithm_introduction/quantization_formula.png b/src/PaddleClas/docs/images/algorithm_introduction/quantization_formula.png new file mode 100644 index 0000000..4d9dbe2 Binary files /dev/null and b/src/PaddleClas/docs/images/algorithm_introduction/quantization_formula.png differ diff --git a/src/PaddleClas/docs/images/algorithm_introduction/quantization_formula_slim.png b/src/PaddleClas/docs/images/algorithm_introduction/quantization_formula_slim.png new file mode 100644 index 0000000..989f6ac Binary files /dev/null and b/src/PaddleClas/docs/images/algorithm_introduction/quantization_formula_slim.png differ diff --git a/src/PaddleClas/docs/images/det/PaddleDetection_config.png b/src/PaddleClas/docs/images/det/PaddleDetection_config.png new file mode 100644 index 0000000..d18932b Binary files /dev/null and b/src/PaddleClas/docs/images/det/PaddleDetection_config.png differ diff --git a/src/PaddleClas/docs/images/det/pssdet.png b/src/PaddleClas/docs/images/det/pssdet.png new file mode 100644 index 0000000..e3b213e Binary files /dev/null and b/src/PaddleClas/docs/images/det/pssdet.png differ diff --git a/src/PaddleClas/docs/images/distillation/22k_1k_val_compare_w_sift.png b/src/PaddleClas/docs/images/distillation/22k_1k_val_compare_w_sift.png new file mode 100644 index 0000000..d97e6f9 Binary files /dev/null and b/src/PaddleClas/docs/images/distillation/22k_1k_val_compare_w_sift.png differ diff --git a/src/PaddleClas/docs/images/distillation/distillation_perform.png b/src/PaddleClas/docs/images/distillation/distillation_perform.png new file mode 100644 index 0000000..34cbacd Binary files /dev/null and b/src/PaddleClas/docs/images/distillation/distillation_perform.png differ diff --git a/src/PaddleClas/docs/images/distillation/distillation_perform_s.jpg b/src/PaddleClas/docs/images/distillation/distillation_perform_s.jpg new file mode 100644 index 0000000..181a490 Binary files /dev/null and b/src/PaddleClas/docs/images/distillation/distillation_perform_s.jpg differ diff --git a/src/PaddleClas/docs/images/distillation/ppcls_distillation.png b/src/PaddleClas/docs/images/distillation/ppcls_distillation.png new file mode 100644 index 0000000..d6cd7af Binary files /dev/null and b/src/PaddleClas/docs/images/distillation/ppcls_distillation.png differ diff --git a/src/PaddleClas/docs/images/distillation/ppcls_distillation_s.jpg b/src/PaddleClas/docs/images/distillation/ppcls_distillation_s.jpg new file mode 100644 index 0000000..95402d4 Binary files /dev/null and b/src/PaddleClas/docs/images/distillation/ppcls_distillation_s.jpg differ diff --git a/src/PaddleClas/docs/images/drink_demo.gif b/src/PaddleClas/docs/images/drink_demo.gif new file mode 100644 index 0000000..599a525 Binary files /dev/null and b/src/PaddleClas/docs/images/drink_demo.gif differ diff --git a/src/PaddleClas/docs/images/faq/ACNetFusion.png b/src/PaddleClas/docs/images/faq/ACNetFusion.png new file mode 100644 index 0000000..7068d93 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/ACNetFusion.png differ diff --git a/src/PaddleClas/docs/images/faq/ACNetReParams.png b/src/PaddleClas/docs/images/faq/ACNetReParams.png new file mode 100644 index 0000000..91dae1b Binary files /dev/null and b/src/PaddleClas/docs/images/faq/ACNetReParams.png differ diff --git a/src/PaddleClas/docs/images/faq/DeployedACNet.png b/src/PaddleClas/docs/images/faq/DeployedACNet.png new file mode 100644 index 0000000..e4900e0 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/DeployedACNet.png differ diff --git a/src/PaddleClas/docs/images/faq/HRNet.png b/src/PaddleClas/docs/images/faq/HRNet.png new file mode 100644 index 0000000..87d2992 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/HRNet.png differ diff --git a/src/PaddleClas/docs/images/faq/HRNet_block.png b/src/PaddleClas/docs/images/faq/HRNet_block.png new file mode 100644 index 0000000..03c244a Binary files /dev/null and b/src/PaddleClas/docs/images/faq/HRNet_block.png differ diff --git a/src/PaddleClas/docs/images/faq/HorizontalKernel.png b/src/PaddleClas/docs/images/faq/HorizontalKernel.png new file mode 100644 index 0000000..eb00792 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/HorizontalKernel.png differ diff --git a/src/PaddleClas/docs/images/faq/MemoryOccupation.png b/src/PaddleClas/docs/images/faq/MemoryOccupation.png new file mode 100644 index 0000000..d4dec8d Binary files /dev/null and b/src/PaddleClas/docs/images/faq/MemoryOccupation.png differ diff --git a/src/PaddleClas/docs/images/faq/RepVGG.png b/src/PaddleClas/docs/images/faq/RepVGG.png new file mode 100644 index 0000000..5c09ae7 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/RepVGG.png differ diff --git a/src/PaddleClas/docs/images/faq/RepVGGReParams.png b/src/PaddleClas/docs/images/faq/RepVGGReParams.png new file mode 100644 index 0000000..5b95156 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/RepVGGReParams.png differ diff --git a/src/PaddleClas/docs/images/faq/ResNet_vabcd_structure.png b/src/PaddleClas/docs/images/faq/ResNet_vabcd_structure.png new file mode 100644 index 0000000..8aacb67 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/ResNet_vabcd_structure.png differ diff --git a/src/PaddleClas/docs/images/faq/SE_structure.png b/src/PaddleClas/docs/images/faq/SE_structure.png new file mode 100644 index 0000000..1d96ec3 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/SE_structure.png differ diff --git a/src/PaddleClas/docs/images/faq/TrainingtimeACNet.png b/src/PaddleClas/docs/images/faq/TrainingtimeACNet.png new file mode 100644 index 0000000..1d8d0a1 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/TrainingtimeACNet.png differ diff --git a/src/PaddleClas/docs/images/faq/Transformer_input.png b/src/PaddleClas/docs/images/faq/Transformer_input.png new file mode 100644 index 0000000..977f092 Binary files /dev/null and b/src/PaddleClas/docs/images/faq/Transformer_input.png differ diff --git a/src/PaddleClas/docs/images/faq/ViT.png b/src/PaddleClas/docs/images/faq/ViT.png new file mode 100644 index 0000000..41a36ef Binary files /dev/null and b/src/PaddleClas/docs/images/faq/ViT.png differ diff --git a/src/PaddleClas/docs/images/faq/ViT_structure.png b/src/PaddleClas/docs/images/faq/ViT_structure.png new file mode 100644 index 0000000..25ebe9f Binary files /dev/null and b/src/PaddleClas/docs/images/faq/ViT_structure.png differ diff --git a/src/PaddleClas/docs/images/faq/momentum.jpeg b/src/PaddleClas/docs/images/faq/momentum.jpeg new file mode 100644 index 0000000..cb3cb0b Binary files /dev/null and b/src/PaddleClas/docs/images/faq/momentum.jpeg differ diff --git a/src/PaddleClas/docs/images/feature_compare.png b/src/PaddleClas/docs/images/feature_compare.png new file mode 100644 index 0000000..e553231 Binary files /dev/null and b/src/PaddleClas/docs/images/feature_compare.png differ diff --git a/src/PaddleClas/docs/images/feature_extraction_framework.png b/src/PaddleClas/docs/images/feature_extraction_framework.png new file mode 100644 index 0000000..5fafdbd Binary files /dev/null and b/src/PaddleClas/docs/images/feature_extraction_framework.png differ diff --git a/src/PaddleClas/docs/images/feature_extraction_framework_en.png b/src/PaddleClas/docs/images/feature_extraction_framework_en.png new file mode 100644 index 0000000..653d2a8 Binary files /dev/null and b/src/PaddleClas/docs/images/feature_extraction_framework_en.png differ diff --git a/src/PaddleClas/docs/images/feature_extraction_output.png b/src/PaddleClas/docs/images/feature_extraction_output.png new file mode 100644 index 0000000..8e8d0dd Binary files /dev/null and b/src/PaddleClas/docs/images/feature_extraction_output.png differ diff --git a/src/PaddleClas/docs/images/feature_maps/feature_visualization_input.jpg b/src/PaddleClas/docs/images/feature_maps/feature_visualization_input.jpg new file mode 100644 index 0000000..6eb5b71 Binary files /dev/null and b/src/PaddleClas/docs/images/feature_maps/feature_visualization_input.jpg differ diff --git a/src/PaddleClas/docs/images/feature_maps/feature_visualization_output.jpg b/src/PaddleClas/docs/images/feature_maps/feature_visualization_output.jpg new file mode 100644 index 0000000..6d7d2a6 Binary files /dev/null and b/src/PaddleClas/docs/images/feature_maps/feature_visualization_output.jpg differ diff --git a/src/PaddleClas/docs/images/icartoon1.png b/src/PaddleClas/docs/images/icartoon1.png new file mode 100644 index 0000000..c52989f Binary files /dev/null and b/src/PaddleClas/docs/images/icartoon1.png differ diff --git a/src/PaddleClas/docs/images/icartoon2.jpeg b/src/PaddleClas/docs/images/icartoon2.jpeg new file mode 100644 index 0000000..1601126 Binary files /dev/null and b/src/PaddleClas/docs/images/icartoon2.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/gridmask-0.png b/src/PaddleClas/docs/images/image_aug/gridmask-0.png new file mode 100644 index 0000000..2d6997a Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/gridmask-0.png differ diff --git a/src/PaddleClas/docs/images/image_aug/hide-and-seek-visual.png b/src/PaddleClas/docs/images/image_aug/hide-and-seek-visual.png new file mode 100644 index 0000000..7f25576 Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/hide-and-seek-visual.png differ diff --git a/src/PaddleClas/docs/images/image_aug/image_aug_samples.png b/src/PaddleClas/docs/images/image_aug/image_aug_samples.png new file mode 100644 index 0000000..0861fcd Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/image_aug_samples.png differ diff --git a/src/PaddleClas/docs/images/image_aug/image_aug_samples_s.jpg b/src/PaddleClas/docs/images/image_aug/image_aug_samples_s.jpg new file mode 100644 index 0000000..aad144a Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/image_aug_samples_s.jpg differ diff --git a/src/PaddleClas/docs/images/image_aug/image_aug_samples_s_en.jpg b/src/PaddleClas/docs/images/image_aug/image_aug_samples_s_en.jpg new file mode 100644 index 0000000..2cd1a3a Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/image_aug_samples_s_en.jpg differ diff --git a/src/PaddleClas/docs/images/image_aug/main_image_aug.png b/src/PaddleClas/docs/images/image_aug/main_image_aug.png new file mode 100644 index 0000000..82a517a Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/main_image_aug.png differ diff --git a/src/PaddleClas/docs/images/image_aug/main_image_aug_s.jpg b/src/PaddleClas/docs/images/image_aug/main_image_aug_s.jpg new file mode 100644 index 0000000..efaa27c Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/main_image_aug_s.jpg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_autoaugment.jpeg b/src/PaddleClas/docs/images/image_aug/test_autoaugment.jpeg new file mode 100644 index 0000000..207017f Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_autoaugment.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_baseline.jpeg b/src/PaddleClas/docs/images/image_aug/test_baseline.jpeg new file mode 100644 index 0000000..3fa2d3a Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_baseline.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_cutmix.png b/src/PaddleClas/docs/images/image_aug/test_cutmix.png new file mode 100644 index 0000000..9a396be Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_cutmix.png differ diff --git a/src/PaddleClas/docs/images/image_aug/test_cutout.jpeg b/src/PaddleClas/docs/images/image_aug/test_cutout.jpeg new file mode 100644 index 0000000..ad18f9d Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_cutout.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_gridmask.jpeg b/src/PaddleClas/docs/images/image_aug/test_gridmask.jpeg new file mode 100644 index 0000000..698c793 Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_gridmask.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_hideandseek.jpeg b/src/PaddleClas/docs/images/image_aug/test_hideandseek.jpeg new file mode 100644 index 0000000..55f1ada Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_hideandseek.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_mixup.png b/src/PaddleClas/docs/images/image_aug/test_mixup.png new file mode 100644 index 0000000..e5d2807 Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_mixup.png differ diff --git a/src/PaddleClas/docs/images/image_aug/test_randaugment.jpeg b/src/PaddleClas/docs/images/image_aug/test_randaugment.jpeg new file mode 100644 index 0000000..7126f05 Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_randaugment.jpeg differ diff --git a/src/PaddleClas/docs/images/image_aug/test_randomerassing.jpeg b/src/PaddleClas/docs/images/image_aug/test_randomerassing.jpeg new file mode 100644 index 0000000..ff31bc2 Binary files /dev/null and b/src/PaddleClas/docs/images/image_aug/test_randomerassing.jpeg differ diff --git a/src/PaddleClas/docs/images/inference_deployment/cpp_infer_result.png b/src/PaddleClas/docs/images/inference_deployment/cpp_infer_result.png new file mode 100644 index 0000000..fe9de1a Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/cpp_infer_result.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/lite_demo_result.png b/src/PaddleClas/docs/images/inference_deployment/lite_demo_result.png new file mode 100644 index 0000000..b778f15 Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/lite_demo_result.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/vs2019_step1.png b/src/PaddleClas/docs/images/inference_deployment/vs2019_step1.png new file mode 100644 index 0000000..58fdf2f Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/vs2019_step1.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/vs2019_step2.png b/src/PaddleClas/docs/images/inference_deployment/vs2019_step2.png new file mode 100644 index 0000000..f1b5fd0 Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/vs2019_step2.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/vs2019_step3.png b/src/PaddleClas/docs/images/inference_deployment/vs2019_step3.png new file mode 100644 index 0000000..cb1b2ae Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/vs2019_step3.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/vs2019_step4.png b/src/PaddleClas/docs/images/inference_deployment/vs2019_step4.png new file mode 100644 index 0000000..5fc0408 Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/vs2019_step4.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/vs2019_step5.png b/src/PaddleClas/docs/images/inference_deployment/vs2019_step5.png new file mode 100644 index 0000000..fbb2e4c Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/vs2019_step5.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/vs2019_step6.png b/src/PaddleClas/docs/images/inference_deployment/vs2019_step6.png new file mode 100644 index 0000000..86a8039 Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/vs2019_step6.png differ diff --git a/src/PaddleClas/docs/images/inference_deployment/whl_demo.jpg b/src/PaddleClas/docs/images/inference_deployment/whl_demo.jpg new file mode 100644 index 0000000..cc7bff4 Binary files /dev/null and b/src/PaddleClas/docs/images/inference_deployment/whl_demo.jpg differ diff --git a/src/PaddleClas/docs/images/joinus.png b/src/PaddleClas/docs/images/joinus.png new file mode 100644 index 0000000..5fddb4a Binary files /dev/null and b/src/PaddleClas/docs/images/joinus.png differ diff --git a/src/PaddleClas/docs/images/logo.png b/src/PaddleClas/docs/images/logo.png new file mode 100644 index 0000000..bc1135a Binary files /dev/null and b/src/PaddleClas/docs/images/logo.png differ diff --git a/src/PaddleClas/docs/images/logo/logodet3k.jpg b/src/PaddleClas/docs/images/logo/logodet3k.jpg new file mode 100644 index 0000000..4c3e719 Binary files /dev/null and b/src/PaddleClas/docs/images/logo/logodet3k.jpg differ diff --git a/src/PaddleClas/docs/images/main_features.png b/src/PaddleClas/docs/images/main_features.png new file mode 100644 index 0000000..d663c99 Binary files /dev/null and b/src/PaddleClas/docs/images/main_features.png differ diff --git a/src/PaddleClas/docs/images/main_features_s.png b/src/PaddleClas/docs/images/main_features_s.png new file mode 100644 index 0000000..266fa22 Binary files /dev/null and b/src/PaddleClas/docs/images/main_features_s.png differ diff --git a/src/PaddleClas/docs/images/main_features_s_en.png b/src/PaddleClas/docs/images/main_features_s_en.png new file mode 100644 index 0000000..8f038fd Binary files /dev/null and b/src/PaddleClas/docs/images/main_features_s_en.png differ diff --git a/src/PaddleClas/docs/images/mainpage/cartoon_vis_en_v1.0.gif b/src/PaddleClas/docs/images/mainpage/cartoon_vis_en_v1.0.gif new file mode 100644 index 0000000..9450f09 Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/cartoon_vis_en_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/mainpage/cartoon_vis_v1.0.gif b/src/PaddleClas/docs/images/mainpage/cartoon_vis_v1.0.gif new file mode 100644 index 0000000..86b3f8a Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/cartoon_vis_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/mainpage/logo_vis_en_v1.0.gif b/src/PaddleClas/docs/images/mainpage/logo_vis_en_v1.0.gif new file mode 100644 index 0000000..a3fceb2 Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/logo_vis_en_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/mainpage/logo_vis_v1.0.gif b/src/PaddleClas/docs/images/mainpage/logo_vis_v1.0.gif new file mode 100644 index 0000000..d8062ac Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/logo_vis_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/mainpage/product_vis_en_v1.0.gif b/src/PaddleClas/docs/images/mainpage/product_vis_en_v1.0.gif new file mode 100644 index 0000000..eec4487 Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/product_vis_en_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/mainpage/product_vis_v1.0.gif b/src/PaddleClas/docs/images/mainpage/product_vis_v1.0.gif new file mode 100644 index 0000000..3042aca Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/product_vis_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/mainpage/recognition_pipeline_en.png b/src/PaddleClas/docs/images/mainpage/recognition_pipeline_en.png new file mode 100644 index 0000000..854fe55 Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/recognition_pipeline_en.png differ diff --git a/src/PaddleClas/docs/images/mainpage/vehicle_vis_en_v1.0.gif b/src/PaddleClas/docs/images/mainpage/vehicle_vis_en_v1.0.gif new file mode 100644 index 0000000..75e218e Binary files /dev/null and b/src/PaddleClas/docs/images/mainpage/vehicle_vis_en_v1.0.gif differ diff --git a/src/PaddleClas/docs/images/ml_illustration.jpg b/src/PaddleClas/docs/images/ml_illustration.jpg new file mode 100644 index 0000000..69dced9 Binary files /dev/null and b/src/PaddleClas/docs/images/ml_illustration.jpg differ diff --git a/src/PaddleClas/docs/images/ml_pipeline.jpg b/src/PaddleClas/docs/images/ml_pipeline.jpg new file mode 100644 index 0000000..cac6508 Binary files /dev/null and b/src/PaddleClas/docs/images/ml_pipeline.jpg differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs1.EfficientNet.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs1.EfficientNet.png new file mode 100644 index 0000000..1c87d71 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs1.EfficientNet.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.DPN.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.DPN.png new file mode 100644 index 0000000..1eb3939 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.DPN.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.HRNet.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.HRNet.png new file mode 100644 index 0000000..f21d63c Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.HRNet.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.Inception.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.Inception.png new file mode 100644 index 0000000..8095a3c Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.Inception.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.ResNet.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.ResNet.png new file mode 100644 index 0000000..dd25276 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.ResNet.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.SeResNeXt.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.SeResNeXt.png new file mode 100644 index 0000000..960e62a Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp16.bs4.SeResNeXt.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs1.EfficientNet.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs1.EfficientNet.png new file mode 100644 index 0000000..395a32f Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs1.EfficientNet.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs1.main_fps_top1.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs1.main_fps_top1.png new file mode 100644 index 0000000..0497028 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs1.main_fps_top1.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.flops.png new file mode 100644 index 0000000..24aabf8 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.params.png new file mode 100644 index 0000000..689e73d Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.params.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.png new file mode 100644 index 0000000..dc3922d Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.DPN.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.flops.png new file mode 100644 index 0000000..deacfac Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.params.png new file mode 100644 index 0000000..7177bbc Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.params.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.flops.png new file mode 100644 index 0000000..062ecd7 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.params.png new file mode 100644 index 0000000..4bb3f76 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.params.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.png new file mode 100644 index 0000000..3905f0b Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.HRNet.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.flops.png new file mode 100644 index 0000000..6fdc94b Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.params.png new file mode 100644 index 0000000..25a5d16 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.params.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.png new file mode 100644 index 0000000..7ef4f33 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.Inception.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png new file mode 100644 index 0000000..57e0303 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png new file mode 100644 index 0000000..3440e3a Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.png new file mode 100644 index 0000000..8db3c2d Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.ResNet.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.flops.png new file mode 100644 index 0000000..4e6fa84 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.params.png new file mode 100644 index 0000000..afb66bd Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.params.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.png new file mode 100644 index 0000000..10cdd0a Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.main_fps_top1.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.main_fps_top1.png new file mode 100644 index 0000000..9750c19 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.main_fps_top1.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.flops.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.flops.png new file mode 100644 index 0000000..8c1be3a Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.flops.png differ diff --git a/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.params.png b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.params.png new file mode 100644 index 0000000..a41a325 Binary files /dev/null and b/src/PaddleClas/docs/images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.params.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.DPN.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.DPN.png new file mode 100644 index 0000000..10f542b Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.DPN.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.EfficientNet.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.EfficientNet.png new file mode 100644 index 0000000..0491ff3 Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.EfficientNet.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.HRNet.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.HRNet.png new file mode 100644 index 0000000..284088e Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.HRNet.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.Inception.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.Inception.png new file mode 100644 index 0000000..0e0e42e Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.Inception.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.ResNet.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.ResNet.png new file mode 100644 index 0000000..2332791 Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.ResNet.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.SeResNeXt.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.SeResNeXt.png new file mode 100644 index 0000000..610c846 Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.SeResNeXt.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.main_fps_top1_s.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.main_fps_top1_s.png new file mode 100644 index 0000000..ab7f3eb Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.main_fps_top1_s.png differ diff --git a/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.visiontransformer.png b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.visiontransformer.png new file mode 100644 index 0000000..5009619 Binary files /dev/null and b/src/PaddleClas/docs/images/models/V100_benchmark/v100.fp32.bs1.visiontransformer.png differ diff --git a/src/PaddleClas/docs/images/models/lr_decay.jpeg b/src/PaddleClas/docs/images/models/lr_decay.jpeg new file mode 100644 index 0000000..b482b35 Binary files /dev/null and b/src/PaddleClas/docs/images/models/lr_decay.jpeg differ diff --git a/src/PaddleClas/docs/images/models/mobile_arm_storage.png b/src/PaddleClas/docs/images/models/mobile_arm_storage.png new file mode 100644 index 0000000..07e1f4f Binary files /dev/null and b/src/PaddleClas/docs/images/models/mobile_arm_storage.png differ diff --git a/src/PaddleClas/docs/images/models/mobile_arm_top1.png b/src/PaddleClas/docs/images/models/mobile_arm_top1.png new file mode 100644 index 0000000..9156764 Binary files /dev/null and b/src/PaddleClas/docs/images/models/mobile_arm_top1.png differ diff --git a/src/PaddleClas/docs/images/paddlepaddle.jpg b/src/PaddleClas/docs/images/paddlepaddle.jpg new file mode 100644 index 0000000..da4cfb0 Binary files /dev/null and b/src/PaddleClas/docs/images/paddlepaddle.jpg differ diff --git a/src/PaddleClas/docs/images/ppshitu_lite_demo.png b/src/PaddleClas/docs/images/ppshitu_lite_demo.png new file mode 100644 index 0000000..c9b1766 Binary files /dev/null and b/src/PaddleClas/docs/images/ppshitu_lite_demo.png differ diff --git a/src/PaddleClas/docs/images/product/aliproduct.png b/src/PaddleClas/docs/images/product/aliproduct.png new file mode 100644 index 0000000..b57f96c Binary files /dev/null and b/src/PaddleClas/docs/images/product/aliproduct.png differ diff --git a/src/PaddleClas/docs/images/product/inshop.png b/src/PaddleClas/docs/images/product/inshop.png new file mode 100644 index 0000000..e874fdb Binary files /dev/null and b/src/PaddleClas/docs/images/product/inshop.png differ diff --git a/src/PaddleClas/docs/images/qq_group.png b/src/PaddleClas/docs/images/qq_group.png new file mode 100644 index 0000000..dad54c1 Binary files /dev/null and b/src/PaddleClas/docs/images/qq_group.png differ diff --git a/src/PaddleClas/docs/images/quick_start/Examples-Flower-102.png b/src/PaddleClas/docs/images/quick_start/Examples-Flower-102.png new file mode 100644 index 0000000..28adc5a Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/Examples-Flower-102.png differ diff --git a/src/PaddleClas/docs/images/quick_start/all_acc.png b/src/PaddleClas/docs/images/quick_start/all_acc.png new file mode 100644 index 0000000..cf9938c Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/all_acc.png differ diff --git a/src/PaddleClas/docs/images/quick_start/community/001_fork.png b/src/PaddleClas/docs/images/quick_start/community/001_fork.png new file mode 100644 index 0000000..a610381 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/community/001_fork.png differ diff --git a/src/PaddleClas/docs/images/quick_start/community/002_clone.png b/src/PaddleClas/docs/images/quick_start/community/002_clone.png new file mode 100644 index 0000000..f622634 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/community/002_clone.png differ diff --git a/src/PaddleClas/docs/images/quick_start/community/003_precommit_pass.png b/src/PaddleClas/docs/images/quick_start/community/003_precommit_pass.png new file mode 100644 index 0000000..067fb75 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/community/003_precommit_pass.png differ diff --git a/src/PaddleClas/docs/images/quick_start/community/004_create_pr.png b/src/PaddleClas/docs/images/quick_start/community/004_create_pr.png new file mode 100644 index 0000000..9276629 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/community/004_create_pr.png differ diff --git a/src/PaddleClas/docs/images/quick_start/community/code_framework.png b/src/PaddleClas/docs/images/quick_start/community/code_framework.png new file mode 100644 index 0000000..bc738dc Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/community/code_framework.png differ diff --git a/src/PaddleClas/docs/images/quick_start/community/train_framework.png b/src/PaddleClas/docs/images/quick_start/community/train_framework.png new file mode 100644 index 0000000..3501e02 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/community/train_framework.png differ diff --git a/src/PaddleClas/docs/images/quick_start/flowers102/image_06739.jpg b/src/PaddleClas/docs/images/quick_start/flowers102/image_06739.jpg new file mode 100644 index 0000000..19a1ed6 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/flowers102/image_06739.jpg differ diff --git a/src/PaddleClas/docs/images/quick_start/flowers102/image_06767.jpg b/src/PaddleClas/docs/images/quick_start/flowers102/image_06767.jpg new file mode 100644 index 0000000..28fd2db Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/flowers102/image_06767.jpg differ diff --git a/src/PaddleClas/docs/images/quick_start/flowers102/image_06773.jpg b/src/PaddleClas/docs/images/quick_start/flowers102/image_06773.jpg new file mode 100644 index 0000000..f4fde55 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/flowers102/image_06773.jpg differ diff --git a/src/PaddleClas/docs/images/quick_start/r50_vd_acc.png b/src/PaddleClas/docs/images/quick_start/r50_vd_acc.png new file mode 100644 index 0000000..3e28b3a Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/r50_vd_acc.png differ diff --git a/src/PaddleClas/docs/images/quick_start/r50_vd_pretrained_acc.png b/src/PaddleClas/docs/images/quick_start/r50_vd_pretrained_acc.png new file mode 100644 index 0000000..2d77049 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/r50_vd_pretrained_acc.png differ diff --git a/src/PaddleClas/docs/images/quick_start/shitu_c++_result.png b/src/PaddleClas/docs/images/quick_start/shitu_c++_result.png new file mode 100644 index 0000000..f2cbee5 Binary files /dev/null and b/src/PaddleClas/docs/images/quick_start/shitu_c++_result.png differ diff --git a/src/PaddleClas/docs/images/recognition.gif b/src/PaddleClas/docs/images/recognition.gif new file mode 100644 index 0000000..cbe150b Binary files /dev/null and b/src/PaddleClas/docs/images/recognition.gif differ diff --git a/src/PaddleClas/docs/images/recognition/crop_example.png b/src/PaddleClas/docs/images/recognition/crop_example.png new file mode 100644 index 0000000..368c3e3 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/crop_example.png differ diff --git a/src/PaddleClas/docs/images/recognition/drink_data_demo/output/mosilian.jpeg b/src/PaddleClas/docs/images/recognition/drink_data_demo/output/mosilian.jpeg new file mode 100644 index 0000000..ca7f2db Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/drink_data_demo/output/mosilian.jpeg differ diff --git a/src/PaddleClas/docs/images/recognition/drink_data_demo/output/nongfu_spring.jpeg b/src/PaddleClas/docs/images/recognition/drink_data_demo/output/nongfu_spring.jpeg new file mode 100644 index 0000000..b6669ba Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/drink_data_demo/output/nongfu_spring.jpeg differ diff --git a/src/PaddleClas/docs/images/recognition/drink_data_demo/output/youjia.jpeg b/src/PaddleClas/docs/images/recognition/drink_data_demo/output/youjia.jpeg new file mode 100644 index 0000000..a437915 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/drink_data_demo/output/youjia.jpeg differ diff --git a/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/mosilian.jpeg b/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/mosilian.jpeg new file mode 100644 index 0000000..22c6075 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/mosilian.jpeg differ diff --git a/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/nongfu_spring.jpeg b/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/nongfu_spring.jpeg new file mode 100644 index 0000000..0f4166d Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/nongfu_spring.jpeg differ diff --git a/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/youjia.jpeg b/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/youjia.jpeg new file mode 100644 index 0000000..2875a76 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/drink_data_demo/test_images/youjia.jpeg differ diff --git a/src/PaddleClas/docs/images/recognition/logo_demo/gallery/logo_gallery_demo.png b/src/PaddleClas/docs/images/recognition/logo_demo/gallery/logo_gallery_demo.png new file mode 100644 index 0000000..d748463 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/logo_demo/gallery/logo_gallery_demo.png differ diff --git a/src/PaddleClas/docs/images/recognition/logo_demo/query/logo_auxx-1.jpg b/src/PaddleClas/docs/images/recognition/logo_demo/query/logo_auxx-1.jpg new file mode 100644 index 0000000..90a9215 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/logo_demo/query/logo_auxx-1.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/logo_demo/query/logo_cola.jpg b/src/PaddleClas/docs/images/recognition/logo_demo/query/logo_cola.jpg new file mode 100644 index 0000000..97d0374 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/logo_demo/query/logo_cola.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/more_demo_images/cartoon.md b/src/PaddleClas/docs/images/recognition/more_demo_images/cartoon.md new file mode 100644 index 0000000..85dd1fa --- /dev/null +++ b/src/PaddleClas/docs/images/recognition/more_demo_images/cartoon.md @@ -0,0 +1,53 @@ +# 更多关于动漫人物图片识别的效果图请见下 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/images/recognition/more_demo_images/logo.md b/src/PaddleClas/docs/images/recognition/more_demo_images/logo.md new file mode 100644 index 0000000..03b992d --- /dev/null +++ b/src/PaddleClas/docs/images/recognition/more_demo_images/logo.md @@ -0,0 +1,65 @@ +# 更多关于商标图片识别的效果图请见下 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/images/recognition/more_demo_images/product.md b/src/PaddleClas/docs/images/recognition/more_demo_images/product.md new file mode 100644 index 0000000..7b33e27 --- /dev/null +++ b/src/PaddleClas/docs/images/recognition/more_demo_images/product.md @@ -0,0 +1,179 @@ +# 更多关于商品图片识别的效果图请见下 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/images/recognition/more_demo_images/vehicle.md b/src/PaddleClas/docs/images/recognition/more_demo_images/vehicle.md new file mode 100644 index 0000000..7fe4e92 --- /dev/null +++ b/src/PaddleClas/docs/images/recognition/more_demo_images/vehicle.md @@ -0,0 +1,33 @@ +# 更多关于车辆图片识别的效果图请见下 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/001.jpg b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/001.jpg new file mode 100644 index 0000000..586aef2 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/001.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/002.jpg b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/002.jpg new file mode 100644 index 0000000..8d4285d Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/002.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/003.jpg b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/003.jpg new file mode 100644 index 0000000..f4efa2b Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/003.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/004.jpg b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/004.jpg new file mode 100644 index 0000000..017aa82 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/004.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/005.jpg b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/005.jpg new file mode 100644 index 0000000..e7d6f88 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/005.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/006.jpg b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/006.jpg new file mode 100644 index 0000000..36a8e5d Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/gallery/anmuxi/006.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/query/anmuxi.jpg b/src/PaddleClas/docs/images/recognition/product_demo/query/anmuxi.jpg new file mode 100644 index 0000000..735ea5a Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/query/anmuxi.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/query/daoxiangcunjinzhubing_6.jpg b/src/PaddleClas/docs/images/recognition/product_demo/query/daoxiangcunjinzhubing_6.jpg new file mode 100644 index 0000000..fc64a95 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/query/daoxiangcunjinzhubing_6.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/result/anmuxi.jpg b/src/PaddleClas/docs/images/recognition/product_demo/result/anmuxi.jpg new file mode 100644 index 0000000..4b219e2 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/result/anmuxi.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/result/anmuxi_en.jpg b/src/PaddleClas/docs/images/recognition/product_demo/result/anmuxi_en.jpg new file mode 100644 index 0000000..b755a5f Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/result/anmuxi_en.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/result/daoxiangcunjinzhubing_6.jpg b/src/PaddleClas/docs/images/recognition/product_demo/result/daoxiangcunjinzhubing_6.jpg new file mode 100644 index 0000000..645ad6c Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/result/daoxiangcunjinzhubing_6.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/result/daoxiangcunjinzhubing_6_en.jpg b/src/PaddleClas/docs/images/recognition/product_demo/result/daoxiangcunjinzhubing_6_en.jpg new file mode 100644 index 0000000..102616b Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/result/daoxiangcunjinzhubing_6_en.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/wangzai.jpg b/src/PaddleClas/docs/images/recognition/product_demo/wangzai.jpg new file mode 100644 index 0000000..fe7aa77 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/wangzai.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/product_demo/wangzai_det_result.jpg b/src/PaddleClas/docs/images/recognition/product_demo/wangzai_det_result.jpg new file mode 100644 index 0000000..e7552d1 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/product_demo/wangzai_det_result.jpg differ diff --git a/src/PaddleClas/docs/images/recognition/rec_pipeline.png b/src/PaddleClas/docs/images/recognition/rec_pipeline.png new file mode 100644 index 0000000..f6a95e6 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/rec_pipeline.png differ diff --git a/src/PaddleClas/docs/images/recognition/vehicle/CompCars.png b/src/PaddleClas/docs/images/recognition/vehicle/CompCars.png new file mode 100644 index 0000000..021d8c4 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/vehicle/CompCars.png differ diff --git a/src/PaddleClas/docs/images/recognition/vehicle/cars.JPG b/src/PaddleClas/docs/images/recognition/vehicle/cars.JPG new file mode 100644 index 0000000..bb60246 Binary files /dev/null and b/src/PaddleClas/docs/images/recognition/vehicle/cars.JPG differ diff --git a/src/PaddleClas/docs/images/recognition_en.gif b/src/PaddleClas/docs/images/recognition_en.gif new file mode 100644 index 0000000..0adffea Binary files /dev/null and b/src/PaddleClas/docs/images/recognition_en.gif differ diff --git a/src/PaddleClas/docs/images/structure.jpg b/src/PaddleClas/docs/images/structure.jpg new file mode 100644 index 0000000..1d7f5a1 Binary files /dev/null and b/src/PaddleClas/docs/images/structure.jpg differ diff --git a/src/PaddleClas/docs/images/wx_group.png b/src/PaddleClas/docs/images/wx_group.png new file mode 100644 index 0000000..ab3bd91 Binary files /dev/null and b/src/PaddleClas/docs/images/wx_group.png differ diff --git a/src/PaddleClas/docs/make.bat b/src/PaddleClas/docs/make.bat new file mode 100644 index 0000000..061f32f --- /dev/null +++ b/src/PaddleClas/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/src/PaddleClas/docs/requirements.txt b/src/PaddleClas/docs/requirements.txt new file mode 100644 index 0000000..a33c569 --- /dev/null +++ b/src/PaddleClas/docs/requirements.txt @@ -0,0 +1,4 @@ +recommonmark +Sphinx +sphinx-markdown-tables +sphinx-rtd-theme diff --git a/src/PaddleClas/docs/source/index.rst b/src/PaddleClas/docs/source/index.rst new file mode 100644 index 0000000..6ff5f7e --- /dev/null +++ b/src/PaddleClas/docs/source/index.rst @@ -0,0 +1,20 @@ +.. paddleclas documentation master file, created by + sphinx-quickstart on Wed Dec 15 16:13:23 2021. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to paddleclas's documentation! +====================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/src/PaddleClas/docs/zh_CN/Makefile b/src/PaddleClas/docs/zh_CN/Makefile new file mode 100644 index 0000000..7823a52 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/Makefile @@ -0,0 +1,22 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build + +#SOURCEDIR = source +BUILDDIR = build + + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/DataAugmentation.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/DataAugmentation.md new file mode 100644 index 0000000..9e5159a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/DataAugmentation.md @@ -0,0 +1,331 @@ +# 数据增强分类实战 +--- + +本节将基于 ImageNet-1K 的数据集详细介绍数据增强实验,如果想快速体验此方法,可以参考 [**30 分钟玩转 PaddleClas(进阶版)**](../quick_start/quick_start_classification_professional.md)中基于 CIFAR100 的数据增强实验。如果想了解相关算法的内容,请参考[数据增强算法介绍](../algorithm_introduction/DataAugmentation.md)。 + + +## 目录 + +- [1. 参数配置](#1) + - [1.1 AutoAugment](#1.1) + - [1.2 RandAugment](#1.2) + - [1.3 TimmAutoAugment](#1.3) + - [1.4 Cutout](#1.4) + - [1.5 RandomErasing](#1.5) + - [1.6 HideAndSeek](#1.6) + - [1.7 GridMask](#1.7) + - [1.8 Mixup](#1.8) + - [1.9 Cutmix](#1.9) + - [1.10 Mixup 与 Cutmix 同时使用](#1.10) +- [2. 启动命令](#2) +- [3. 注意事项](#3) +- [4. 实验结果](#4) + + +## 1. 参数配置 + +由于不同的数据增强方式含有不同的超参数,为了便于理解和使用,我们在 `configs/DataAugment` 里分别列举了 8 种训练 ResNet50 的数据增强方式的参数配置文件,用户可以在 `tools/run.sh` 里直接替换配置文件的路径即可使用。此处分别挑选了图像变换、图像裁剪、图像混叠中的一个示例展示,其他参数配置用户可以自查配置文件。 + + +### 1.1 AutoAugment + +`AotoAugment` 的图像增广方式的配置如下。`AutoAugment` 是在 uint8 的数据格式上转换的,所以其处理过程应该放在归一化操作(`NormalizeImage`)之前。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + + +### 1.2 RandAugment + +`RandAugment` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `num_layers` 与 `magnitude`,默认的数值分别是 `2` 和 `5`。`RandAugment` 是在 uint8 的数据格式上转换的,所以其处理过程应该放在归一化操作(`NormalizeImage`)之前。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - RandAugment: + num_layers: 2 + magnitude: 5 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + + +### 1.3 TimmAutoAugment + +`TimmAutoAugment` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `config_str`、`interpolation`、`img_size`,默认的数值分别是 `rand-m9-mstd0.5-inc1`、`bicubic`、`224`。`TimmAutoAugment` 是在 uint8 的数据格式上转换的,所以其处理过程应该放在归一化操作(`NormalizeImage`)之前。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + + +### 1.4 Cutout + +`Cutout` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `n_holes` 与 `length`,默认的数值分别是 `1` 和 `112`。类似其他图像裁剪类的数据增强方式,`Cutout` 既可以在 uint8 格式的数据上操作,也可以在归一化)(`NormalizeImage`)后的数据上操作,此处给出的是在归一化后的操作。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - Cutout: + n_holes: 1 + length: 112 +``` + + +### 1.5 RandomErasing + +`RandomErasing` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `EPSILON`、`sl`、`sh`、`r1`、`attempt`、`use_log_aspect`、`mode`,默认的数值分别是 `0.25`、`0.02`、`1.0/3.0`、`0.3`、`10`、`True`、`pixel`。类似其他图像裁剪类的数据增强方式,`RandomErasing` 既可以在 uint8 格式的数据上操作,也可以在归一化(`NormalizeImage`)后的数据上操作,此处给出的是在归一化后的操作。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel +``` + + +### 1.6 HideAndSeek + +`HideAndSeek` 的图像增广方式的配置如下。类似其他图像裁剪类的数据增强方式,`HideAndSeek` 既可以在 uint8 格式的数据上操作,也可以在归一化(`NormalizeImage`)后的数据上操作,此处给出的是在归一化后的操作。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - HideAndSeek: +``` + + + +### 1.7 GridMask + +`GridMask` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `d1`、`d2`、`rotate`、`ratio`、`mode`, 默认的数值分别是 `96`、`224`、`1`、`0.5`、`0`。类似其他图像裁剪类的数据增强方式,`GridMask` 既可以在 uint8 格式的数据上操作,也可以在归一化(`NormalizeImage`)后的数据上操作,此处给出的是在归一化后的操作。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - GridMask: + d1: 96 + d2: 224 + rotate: 1 + ratio: 0.5 + mode: 0 +``` + + +### 1.8 Mixup + +`Mixup` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `alpha`,默认的数值是 `0.2`。类似其他图像混合类的数据增强方式,`Mixup` 是在图像做完数据处理后将每个 batch 内的数据做图像混叠,将混叠后的图像和标签输入网络中训练,所以其是在图像数据处理(图像变换、图像裁剪)后操作。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 +``` + + +### 1.9 Cutmix + +`Cutmix` 的图像增广方式的配置如下,其中用户需要指定其中的参数 `alpha`,默认的数值是 `0.2`。类似其他图像混合类的数据增强方式,`Cutmix` 是在图像做完数据处理后将每个 batch 内的数据做图像混叠,将混叠后的图像和标签输入网络中训练,所以其是在图像数据处理(图像变换、图像裁剪)后操作。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - CutmixOperator: + alpha: 0.2 +``` + + +### 1.10 Mixup 与 Cutmix 同时使用 + +`Mixup` 与 `Cutmix` 同时使用的配置如下,其中用户需要指定额外的参数 `prob`,该参数控制不同数据增强的概率,默认为 `0.5`。 + +```yaml + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 +``` + + +## 2. 启动命令 + +当用户配置完训练环境后,类似于训练其他分类任务,只需要将 `tools/train.sh` 中的配置文件替换成为相应的数据增强方式的配置文件即可。 + +其中 `train.sh` 中的内容如下: + +```bash + +python3 -m paddle.distributed.launch \ + --selected_gpus="0,1,2,3" \ + --log_dir=ResNet50_Cutout \ + tools/train.py \ + -c ./ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml +``` + +运行 `train.sh`: + +```bash +sh tools/train.sh +``` + + +## 3. 注意事项 + +* 由于图像混叠时需对 label 进行混叠,无法计算训练数据的准确率,所以在训练过程中没有打印训练准确率。 + +* 在使用数据增强后,由于训练数据更难,所以训练损失函数可能较大,训练集的准确率相对较低,但其有拥更好的泛化能力,所以验证集的准确率相对较高。 + +* 在使用数据增强后,模型可能会趋于欠拟合状态,建议可以适当的调小 `l2_decay` 的值来获得更高的验证集准确率。 + +* 几乎每一类图像增强均含有超参数,我们只提供了基于 ImageNet-1k 的超参数,其他数据集需要用户自己调试超参数,具体超参数的含义用户可以阅读相关的论文,调试方法也可以参考[训练技巧](../models_training/train_strategy.md)。 + + +## 4. 实验结果 + +基于 PaddleClas,在 ImageNet1k 数据集上的分类精度如下。 + +| 模型 | 初始学习率策略 | l2 decay | batch size | epoch | 数据变化策略 | Top1 Acc | 论文中结论 | +|-------------|------------------|--------------|------------|-------|----------------|------------|----| +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | 标准变换 | 0.7731 | - | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | AutoAugment | 0.7795 | 0.7763 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | mixup | 0.7828 | 0.7790 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | cutmix | 0.7839 | 0.7860 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | cutout | 0.7801 | - | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | gridmask | 0.7785 | 0.7790 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | random-augment | 0.7770 | 0.7760 | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | random erasing | 0.7791 | - | +| ResNet50 | 0.1/cosine_decay | 0.0001 | 256 | 300 | hide and seek | 0.7743 | 0.7720 | + +**注意**: +* 在这里的实验中,为了便于对比,我们将 l2 decay 固定设置为 1e-4,在实际使用中,我们推荐尝试使用更小的 l2 decay。结合数据增强,我们发现将 l2 decay 由 1e-4 减小为 7e-5 均能带来至少 0.3~0.5% 的精度提升。 +* 我们目前尚未对不同策略进行组合并验证效果,这一块后续我们会开展更多的对比实验,敬请期待。 diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/code_overview.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/code_overview.md new file mode 100644 index 0000000..ef4e503 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/code_overview.md @@ -0,0 +1,259 @@ +# PaddleClas 代码解析 + +## 目录 + +- [1. 整体代码和目录概览](#1) +- [2. 训练模块定义](#2) + - [2.1 数据](#2.1) + - [2.2 模型结构](#2.2) + - [2.3 损失函数](#2.3) + - [2.4 优化器和学习率衰减、权重衰减策略](#2.4) + - [2.5 训练时评估](#2.5) + - [2.6 模型存储](#2.6) + - [2.7 模型裁剪与量化](#2.7) +- [3. 预测部署代码和方式](#3) + + +## 1. 整体代码和目录概览 + +PaddleClas 主要代码和目录结构如下 + +* benchmark: 文件夹下存放了一些 shell 脚本,主要是为了测试 PaddleClas 中不同模型的速度指标,如单卡训练速度指标、多卡训练速度指标等。 +* dataset:文件夹下存放数据集和用于处理数据集的脚本。脚本负责将数据集处理为适合 Dataloader 处理的格式。 +* deploy:部署核心代码,文件夹存放的是部署工具,支持 python/cpp inference、Hub Serveing、Paddle Lite、Slim 离线量化等多种部署方式。 +* ppcls:训练核心代码,文件夹下存放 PaddleClas 框架主体。配置文件、模型训练、评估、预测、动转静导出等具体代码实现均在这里。 +* tools:训练、评估、预测、模型动转静导出的入口函数和脚本均在该文件下。 +* requirements.txt 文件用于安装 PaddleClas 的依赖项。使用 pip 进行升级安装使用。 +* tests:PaddleClas 模型从训练到预测的全链路测试,验证各功能是否能够正常使用。 + + +## 2. 训练模块定义 + +深度学习模型训练模块,主要包含数据、模型结构、损失函数、优化器和学习率衰减、权重衰减策略等,以下一一解读。 + + +### 2.1 数据 + +对于有监督任务来说,训练数据一般包含原始数据及其标注。 +在基于单标签的图像分类任务中,原始数据指的是图像数据,而标注则是该图像数据所属的类别。 +PaddleClas 中,训练时需要提供标签文件,形式如下,每一行包含一条训练样本,分别表示图片路径和类别标签,用分隔符隔开(默认为空格)。 + +``` +train/n01440764/n01440764_10026.JPEG 0 +train/n01440764/n01440764_10027.JPEG 0 +``` + +在代码 `ppcls/data/dataloader/common_dataset.py` 中,包含 `CommonDataset` 类,继承自 `paddle.io.Dataset`, +该数据集类可以通过一个键值进行索引并获取指定样本。`ImageNetDataset`, `LogoDataset`, `CommonDataset` 等数据集类都继承自这个类别 + +对于读入的数据,需要通过数据转换,将原始的图像数据进行转换。训练时,标准的数据预处理包含:`DecodeImage`, `RandCropImage`, +`RandFlipImage`, `NormalizeImage`, `ToCHWImage`。 +在配置文件中体现如下,数据预处理主要包含在 `transforms` 字段中,以列表形式呈现,会按照顺序对数据依次做这些转换。 + +```yaml +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + +PaddleClas 中也包含了 `AutoAugment`, `RandAugment` 等数据增广方法,也可以通过在配置文件中配置,从而添加到训练过程的数据预处理中。 +每个数据转换的方法均以类实现,方便迁移和复用,更多的数据处理具体实现过程可以参考 `ppcls/data/preprocess/ops/` 下的代码。 + +对于组成一个 batch 的数据,也可以使用 mixup 或者 cutmix 等方法进行数据增广。 +PaddleClas 中集成了 `MixupOperator`, `CutmixOperator`, `FmixOperator` 等基于 batch 的数据增广方法, +可以在配置文件中配置 mix 参数进行配置,更加具体的实现可以参考 `ppcls/data/preprocess/batch_ops/batch_operators.py` 。 + +图像分类中,数据后处理主要为 `argmax` 操作,在此不再赘述。 + + +### 2.2 模型结构 + +在配置文件中,模型结构定义如下 + +```yaml +Arch: + name: ResNet50 + class_num: 1000 + pretrained: False + use_ssld: False +``` + +`Arch.name` 表示模型名称,`Arch.pretrained` 表示是否添加预训练模型,`Arch.use_ssld` 表示是否使用基于 `SSLD` 知识蒸馏得到的预训练模型。 +所有的模型名称均在 `ppcls/arch/backbone/__init__.py` 中定义。 + +对应的,在 `ppcls/arch/__init__.py` 中,通过 `build_model` 方法创建模型对象。 + +```python +def build_model(config): + config = copy.deepcopy(config) + model_type = config.pop("name") + mod = importlib.import_module(__name__) + arch = getattr(mod, model_type)(**config) + return arch +``` + + +### 2.3 损失函数 + +PaddleClas 中,包含了 `CELoss`, `JSDivLoss`, `TripletLoss`, `CenterLoss` 等损失函数,均定义在 `ppcls/loss` 中。 + +在 `ppcls/loss/__init__.py` 文件中,使用 `CombinedLoss` 来构建及合并损失函数,不同训练策略中所需要的损失函数与计算方法不同,PaddleClas 在构建损失函数过程中,主要考虑了以下几个因素。 + +1. 是否使用 label smooth +2. 是否使用 mixup 或者 cutmix +3. 是否使用蒸馏方法进行训练 +4. 是否是训练 metric learning + + +用户可以在配置文件中指定损失函数的类型及权重,如在训练中添加 TripletLossV2,配置文件如下: + +```yaml +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 +``` + + +### 2.4 优化器和学习率衰减、权重衰减策略 + +图像分类任务中,`Momentum` 是一种比较常用的优化器,PaddleClas 中提供了 `Momentum` 、 `RMSProp`、`Adam` 及 `AdamW` 等几种优化器策略。 + +权重衰减策略是一种比较常用的正则化方法,主要用于防止模型过拟合。 PaddleClas 中提供了 `L1Decay` 和 `L2Decay` 两种权重衰减策略。 + +学习率衰减是图像分类任务中必不可少的精度提升训练方法,PaddleClas 目前支持 `Cosine`, `Piecewise`, `Linear` 等学习率衰减策略。 + +在配置文件中,优化器、权重衰减策略、学习率衰减策略可以通过以下的字段进行配置。 + +```yaml +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 +``` + +在 `ppcls/optimizer/__init__.py` 中使用 `build_optimizer` 创建优化器和学习率对象。 + +```python +def build_optimizer(config, epochs, step_each_epoch, parameters): + config = copy.deepcopy(config) + # step1 build lr + lr = build_lr_scheduler(config.pop('lr'), epochs, step_each_epoch) + logger.debug("build lr ({}) success..".format(lr)) + # step2 build regularization + if 'regularizer' in config and config['regularizer'] is not None: + reg_config = config.pop('regularizer') + reg_name = reg_config.pop('name') + 'Decay' + reg = getattr(paddle.regularizer, reg_name)(**reg_config) + else: + reg = None + logger.debug("build regularizer ({}) success..".format(reg)) + # step3 build optimizer + optim_name = config.pop('name') + if 'clip_norm' in config: + clip_norm = config.pop('clip_norm') + grad_clip = paddle.nn.ClipGradByNorm(clip_norm=clip_norm) + else: + grad_clip = None + optim = getattr(optimizer, optim_name)(learning_rate=lr, + weight_decay=reg, + grad_clip=grad_clip, + **config)(parameters=parameters) + logger.debug("build optimizer ({}) success..".format(optim)) + return optim, lr +``` + + 不同优化器和权重衰减策略均以类的形式实现,具体实现可以参考文件 `ppcls/optimizer/optimizer.py`. + 不同的学习率衰减策略可以参考文件 `ppcls/optimizer/learning_rate.py` 。 + + +### 2.5 训练时评估 + +模型在训练的时候,可以设置模型保存的间隔,也可以选择每隔若干个 epoch 对验证集进行评估, +从而可以保存在验证集上精度最佳的模型。配置文件中,可以通过下面的字段进行配置。 + +```yaml +Global: + save_interval: 1 # 模型保存的 epoch 间隔 + eval_during_train: True # 是否进行训练时评估 + eval_interval: 1 # 评估的 epoch 间隔 +``` + + +### 2.6 模型存储 +模型存储是通过 Paddle 框架的 `paddle.save()` 函数实现的,存储的是模型的动态图版本,以字典的形式存储,便于继续训练。具体实现如下 + +```python +def save_model(program, model_path, epoch_id, prefix='ppcls'): + model_path = os.path.join(model_path, str(epoch_id)) + _mkdir_if_not_exist(model_path) + model_prefix = os.path.join(model_path, prefix) + paddle.static.save(program, model_prefix) + logger.info( + logger.coloring("Already save model in {}".format(model_path), "HEADER")) +``` + +在保存的时候有两点需要注意: +1. 只在 0 号节点上保存模型。否则多卡训练的时候,如果所有节点都保存模型到相同的路径, +2. 则多个节点写文件时可能会发生写文件冲突,导致最终保存的模型无法被正确加载。 +3. 优化器参数也需要存储,方便后续的加载断点进行训练。 + + + +### 2.7 模型裁剪与量化 +如果想对模型进行压缩训练,则通过下面字段进行配置 +1.模型裁剪: + +```yaml +Slim: + prune: + name: fpgm + pruned_ratio: 0.3 +``` + +2.模型量化: + +```yaml +Slim: + quant: + name: pact +``` + +训练方法详见模型[裁剪量化使用介绍](../advanced_tutorials/model_prune_quantization.md), +算法介绍详见[裁剪量化算法介绍](../algorithm_introduction/model_prune_quantization.md)。 + + +## 3. 预测部署代码和方式 + +* 如果希望将对分类模型进行离线量化,可以参考 [模型量化裁剪教程](../advanced_tutorials/model_prune_quantization.md) 中离线量化部分。 +* 如果希望在服务端使用 python 进行部署,可以参考 [python inference 预测教程](../inference_deployment/python_deploy.md)。 +* 如果希望在服务端使用 cpp 进行部署,可以参考 [cpp inference 预测教程](../inference_deployment/cpp_deploy.md)。 +* 如果希望将分类模型部署为服务,可以参考 [hub serving 预测部署教程](../inference_deployment/paddle_hub_serving_deploy.md)。 +* 如果希望在移动端使用分类模型进行预测,可以参考 [PaddleLite 预测部署教程](../inference_deployment/paddle_lite_deploy.md)。 +* 如果希望使用 whl 包对分类模型进行预测,可以参考 [whl 包预测](../inference_deployment/whl_deploy.md)。 diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/how_to_contribute.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/how_to_contribute.md new file mode 100644 index 0000000..681a7c7 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/how_to_contribute.md @@ -0,0 +1,252 @@ +# PaddleClas 社区贡献指南 +------ + +## 目录 + +- [1. 如何贡献代码](#1) + - [1.1 PaddleClas 分支说明](#1.1) + - [1.2 PaddleClas 代码提交流程与规范](#1.2) + - [1.2.1 fork 和 clone 代码](#1.2.1) + - [1.2.2 和远程仓库建立连接](#1.2.2) + - [1.2.3 创建本地分支](#1.2.3) + - [1.2.4 使用 pre-commit 勾子](#1.2.4) + - [1.2.5 修改与提交代码](#1.2.5) + - [1.2.6 保持本地仓库最新](#1.2.6) + - [1.2.7 push 到远程仓库](#1.2.7) + - [1.2.8 提交 Pull Request](#1.2.8) + - [1.2.9 签署 CLA 协议和通过单元测试](#1.2.9) + - [1.2.10 删除分支](#1.2.10) + - [1.2.11 提交代码的一些约定](#1.2.11) +- [2. 总结](#2) +- [3. 参考文献](#3) + + +## 1. 如何贡献代码 + + +### 1.1 PaddleClas 分支说明 + +PaddleClas 未来将维护 2 种分支,分别为: + +* release/x.x 系列分支:为稳定的发行版本分支,会适时打 tag 发布版本,适配 Paddle 的 release 版本。当前最新的分支为 release/2.3 分支,是当前默认分支,适配 Paddle v2.1.0 。随着版本迭代, release/x.x 系列分支会越来越多,默认维护最新版本的 release 分支,前 1 个版本分支会修复 bug,其他的分支不再维护。 +* develop 分支:为开发分支,适配 Paddle 的 develop 版本,主要用于开发新功能。如果有同学需要进行二次开发,请选择 develop 分支。为了保证 develop 分支能在需要的时候拉出 release/x.x 分支, develop 分支的代码只能使用 Paddle 最新 release 分支中有效的 api 。也就是说,如果 Paddle develop 分支中开发了新的 api,但尚未出现在 release 分支代码中,那么请不要在 PaddleClas 中使用。除此之外,对于不涉及 api 的性能优化、参数调整、策略更新等,都可以正常进行开发。 + +PaddleClas 的历史分支,未来将不再维护。考虑到一些同学可能仍在使用,这些分支还会继续保留: + +* release/static 分支:这个分支曾用于静态图的开发与测试,目前兼容 >=1.7 版本的 Paddle 。如果有特殊需求,要适配旧版本的 Paddle,那还可以使用这个分支,但除了修复 bug 外不再更新代码。 +* dygraph-dev 分支:这个分支将不再维护,也不再接受新的代码,请使用的同学尽快迁移到 develop 分支。 + + +PaddleClas 欢迎大家向 repo 中积极贡献代码,下面给出一些贡献代码的基本流程。 + + +### 1.2 PaddleClas 代码提交流程与规范 + + +#### 1.2.1 fork 和 clone 代码 + +* 跳转到 [PaddleClas GitHub 首页](https://github.com/PaddlePaddle/PaddleClas),然后单击 Fork 按钮,生成自己目录下的仓库,比如 `https://github.com/USERNAME/PaddleClas` 。 + + +![](../../images/quick_start/community/001_fork.png) + +* 将远程仓库 clone 到本地 + +```shell +# 拉取 develop 分支的代码 +git clone https://github.com/USERNAME/PaddleClas.git -b develop +cd PaddleClas +``` + +clone 的地址可以从下面获取 + +![](../../images/quick_start/community/002_clone.png) + + +#### 1.2.2 和远程仓库建立连接 + +首先通过 `git remote -v` 查看当前远程仓库的信息。 + +``` +origin https://github.com/USERNAME/PaddleClas.git (fetch) +origin https://github.com/USERNAME/PaddleClas.git (push) +``` + +上面的信息只包含了 clone 的远程仓库的信息,也就是自己用户名下的 PaddleClas,接下来我们创建一个原始 PaddleClas 仓库的远程主机,命名为 upstream 。 + +```shell +git remote add upstream https://github.com/PaddlePaddle/PaddleClas.git +``` + +使用 `git remote -v` 查看当前远程仓库的信息,输出如下,发现包括了 origin 和 upstream 2 个远程仓库。 + +``` +origin https://github.com/USERNAME/PaddleClas.git (fetch) +origin https://github.com/USERNAME/PaddleClas.git (push) +upstream https://github.com/PaddlePaddle/PaddleClas.git (fetch) +upstream https://github.com/PaddlePaddle/PaddleClas.git (push) +``` + +这主要是为了后续在提交 pull request(PR)时,始终保持本地仓库最新。 + + +#### 1.2.3 创建本地分支 + +可以基于当前分支创建新的本地分支,命令如下。 + +```shell +git checkout -b new_branch +``` + +也可以基于远程或者上游的分支创建新的分支,命令如下。 + +```shell +# 基于用户远程仓库(origin)的 develop 创建 new_branch 分支 +git checkout -b new_branch origin/develop +# 基于上游远程仓库(upstream)的 develop 创建 new_branch 分支 +# 如果需要从 upstream 创建新的分支,需要首先使用 git fetch upstream 获取上游代码 +git checkout -b new_branch upstream/develop +``` + +最终会显示切换到新的分支,输出信息如下 + +``` +Branch new_branch set up to track remote branch develop from upstream. +Switched to a new branch 'new_branch' +``` + + +#### 1.2.4 使用 pre-commit 勾子 + +Paddle 开发人员使用 pre-commit 工具来管理 Git 预提交钩子。 它可以帮助我们格式化源代码(C++,Python),在提交(commit)前自动检查一些基本事宜(如每个文件只有一个 EOL,Git 中不要添加大文件等)。 + +pre-commit 测试是 Travis-CI 中单元测试的一部分,不满足钩子的 PR 不能被提交到 PaddleClas,首先安装并在当前目录运行它: + +```shell +pip install pre-commit +pre-commit install +``` + +* **注意** + +1. Paddle 使用 clang-format 来调整 C/C++ 源代码格式,请确保 `clang-format` 版本在 3.8 以上。 +2. 通过 `pip install pre-commit` 和 `conda install -c conda-forge pre-commit` 安装的 `yapf` 稍有不同的,PaddleClas 开发人员使用的是 `pip install pre-commit` 。 + + +#### 1.2.5 修改与提交代码 + +可以通过 `git status` 查看改动的文件。 +对 PaddleClas 的 `README.md` 做了一些修改,希望提交上去。则可以通过以下步骤 + +```shell +git add README.md +pre-commit +``` + +重复上述步骤,直到 pre-comit 格式检查不报错。如下所示。 + +![](../../images/quick_start/community/003_precommit_pass.png) + +使用下面的命令完成提交。 + +```shell +git commit -m "your commit info" +``` + + +#### 1.2.6 保持本地仓库最新 + +获取 upstream 的最新代码并更新当前分支。这里的 upstream 来自于 1.2 节的`和远程仓库建立连接`部分。 + +```shell +git fetch upstream +# 如果是希望提交到其他分支,则需要从 upstream 的其他分支 pull 代码,这里是 develop +git pull upstream develop +``` + + +#### 1.2.7 push 到远程仓库 + +```shell +git push origin new_branch +``` + + +#### 1.2.8 提交 Pull Request + +点击 new pull request,选择本地分支和目标分支,如下图所示。在 PR 的描述说明中,填写该 PR 所完成的功能。接下来等待 review,如果有需要修改的地方,参照上述步骤更新 origin 中的对应分支即可。 + +![](../../images/quick_start/community/004_create_pr.png) + +#### 1.2.9 签署 CLA 协议和通过单元测试 + +* 签署 CLA +在首次向 PaddlePaddle 提交 Pull Request 时,您需要您签署一次 CLA(Contributor License Agreement)协议,以保证您的代码可以被合入,具体签署方式如下: + +1. 请您查看 PR 中的 Check 部分,找到 license/cla,并点击右侧 detail,进入 CLA 网站 +2. 点击 CLA 网站中的 `Sign in with GitHub to agree`, 点击完成后将会跳转回您的 Pull Request 页面 + + +#### 1.2.10 删除分支 + +* 删除远程分支 + +在 PR 被 merge 进主仓库后,我们可以在 PR 的页面删除远程仓库的分支。 + +也可以使用 `git push origin :分支名` 删除远程分支,如: + + +```shell +git push origin :new_branch +``` + +* 删除本地分支 + +```shell +# 切换到 develop 分支,否则无法删除当前分支 +git checkout develop + +# 删除 new_branch 分支 +git branch -D new_branch +``` + + +#### 1.2.11 提交代码的一些约定 + +为了使官方维护人员在评审代码时更好地专注于代码本身,请您每次提交代码时,遵守以下约定: + +1)请保证 Travis-CI 中单元测试能顺利通过。如果没过,说明提交的代码存在问题,官方维护人员一般不做评审。 + +2)提交 Pull Request 前: + +请注意 commit 的数量。 + +原因:如果仅仅修改一个文件但提交了十几个 commit,每个 commit 只做了少量的修改,这会给评审人带来很大困扰。评审人需要逐一查看每个 commit 才能知道做了哪些修改,且不排除 commit 之间的修改存在相互覆盖的情况。 + +建议:每次提交时,保持尽量少的 commit,可以通过 `git commit --amend` 补充上次的 commit 。对已经 Push 到远程仓库的多个 commit,可以参考 [squash commits after push](https://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed)。 + +请注意每个 commit 的名称:应能反映当前 commit 的内容,不能太随意。 + +3)如果解决了某个 Issue 的问题,请在该 Pull Request 的第一个评论框中加上: `fix #issue_number`,这样当该 Pull Request 被合并后,会自动关闭对应的 Issue 。关键词包括: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved,请选择合适的词汇。详细可参考 [Closing issues via commit messages](https://help.github.com/articles/closing-issues-via-commit-messages)。 + +此外,在回复评审人意见时,请您遵守以下约定: + +1)官方维护人员的每一个 review 意见都希望得到回复,这样会更好地提升开源社区的贡献。 + +- 对评审意见同意且按其修改完的,给个简单的 Done 即可; +- 对评审意见不同意的,请给出您自己的反驳理由。 + +2)如果评审意见比较多, + +- 请给出总体的修改情况。 +- 请采用 `start a review` 进行回复,而非直接回复的方式。原因是每个回复都会发送一封邮件,会造成邮件灾难。 + + +## 2. 总结 + +* 开源社区依赖于众多开发者与用户的贡献和反馈,在这里感谢与期待大家向 PaddleClas 提出宝贵的意见与 Pull Request,希望我们可以一起打造一个领先实用全面的图像识别代码仓库! + + +## 3. 参考文献 +1. [PaddlePaddle 本地开发指南](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/08_contribution/index_cn.html) +2. [向开源框架提交 pr 的过程](https://blog.csdn.net/vim_wj/article/details/78300239) diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/index.rst b/src/PaddleClas/docs/zh_CN/advanced_tutorials/index.rst new file mode 100644 index 0000000..760ec5c --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/index.rst @@ -0,0 +1,13 @@ +高级教程 +================================ + +.. toctree:: + :maxdepth: 2 + + DataAugmentation.md + knowledge_distillation.md + model_prune_quantization.md + code_overview.md + how_to_contribute.md + + diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/knowledge_distillation.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/knowledge_distillation.md new file mode 100644 index 0000000..d3e6d77 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/knowledge_distillation.md @@ -0,0 +1,275 @@ + +# 知识蒸馏 + +## 目录 + - [1. 模型压缩与知识蒸馏方法简介](#1) + - [2. SSLD 蒸馏策略](#2) + - [2.1 简介](#2.1) + - [2.2 数据选择](#2.2) + - [3. 实验](#3) + - [3.1 教师模型的选择](#3.1) + - [3.2 大数据蒸馏](#3.2) + - [3.3 ImageNet1k 训练集 finetune](#3.3) + - [3.4 数据增广以及基于 Fix 策略的微调](#3.4) + - [3.5 实验过程中的一些问题](#3.5) + - [4. 蒸馏模型的应用](#4) + - [4.1 使用方法](#4.1) + - [4.2 迁移学习 finetune](#4.2) + - [4.3 目标检测](#4.3) + - [5. SSLD 实战](#5) + - [5.1 参数配置](#5.1) + - [5.2 启动命令](#5.2) + - [5.3 注意事项](#5.3) + - [6. 参考文献](#6) + + +## 1. 模型压缩与知识蒸馏方法简介 + +近年来,深度神经网络在计算机视觉、自然语言处理等领域被验证是一种极其有效的解决问题的方法。通过构建合适的神经网络,加以训练,最终网络模型的性能指标基本上都会超过传统算法。 + +在数据量足够大的情况下,通过合理构建网络模型的方式增加其参数量,可以显著改善模型性能,但是这又带来了模型复杂度急剧提升的问题。大模型在实际场景中使用的成本较高。 + +深度神经网络一般有较多的参数冗余,目前有几种主要的方法对模型进行压缩,减小其参数量。如裁剪、量化、知识蒸馏等,其中知识蒸馏是指使用教师模型(teacher model)去指导学生模型(student model)学习特定任务,保证小模型在参数量不变的情况下,得到比较大的性能提升,甚至获得与大模型相似的精度指标 [1]。 PaddleClas 融合已有的蒸馏方法 [2,3],提供了一种简单的半监督标签知识蒸馏方案(SSLD,Simple Semi-supervised Label Distillation),基于 ImageNet1k 分类数据集,在 ResNet_vd 以及 MobileNet 系列上的精度均有超过 3% 的绝对精度提升,具体指标如下图所示。 + +![](../../images/distillation/distillation_perform_s.jpg) + +## 2. SSLD 蒸馏策略 + + +### 2.1 简介 + +SSLD 的流程图如下图所示。 + +![](../../images/distillation/ppcls_distillation.png) +首先,我们从 ImageNet22k 中挖掘出了近 400 万张图片,同时与 ImageNet-1k 训练集整合在一起,得到了一个新的包含 500 万张图片的数据集。然后,我们将学生模型与教师模型组合成一个新的网络,该网络分别输出学生模型和教师模型的预测分布,与此同时,固定教师模型整个网络的梯度,而学生模型可以做正常的反向传播。最后,我们将两个模型的 logits 经过 softmax 激活函数转换为 soft label,并将二者的 soft label 做 JS 散度作为损失函数,用于蒸馏模型训练。下面以 MobileNetV3(该模型直接训练,精度为 75.3%)的知识蒸馏为例,介绍该方案的核心关键点(baseline 为 79.12% 的 ResNet50_vd 模型蒸馏 MobileNetV3,训练集为 ImageNet1k 训练集,loss 为 cross entropy loss,迭代轮数为 120epoch,精度指标为 75.6%)。 + +* 教师模型的选择。在进行知识蒸馏时,如果教师模型与学生模型的结构差异太大,蒸馏得到的结果反而不会有太大收益。相同结构下,精度更高的教师模型对结果也有很大影响。相比于 79.12% 的 ResNet50_vd 教师模型,使用 82.4% 的 ResNet50_vd 教师模型可以带来 0.4% 的绝对精度收益(`75.6%->76.0%`)。 + +* 改进 loss 计算方法。分类 loss 计算最常用的方法就是 cross entropy loss,我们经过实验发现,在使用 soft label 进行训练时,相对于 cross entropy loss,KL div loss 对模型性能提升几乎无帮助,但是使用具有对称特性的 JS div loss 时,在多个蒸馏任务上相比 cross entropy loss 均有 0.2% 左右的收益(`76.0%->76.2%`),SSLD 中也基于 JS div loss 展开实验。 + +* 更多的迭代轮数。蒸馏的 baseline 实验只迭代了 120 个 epoch 。实验发现,迭代轮数越多,蒸馏效果越好,最终我们迭代了 360 epoch,精度指标可以达到 77.1%(`76.2%->77.1%`)。 + +* 无需数据集的真值标签,很容易扩展训练集。 SSLD 的 loss 在计算过程中,仅涉及到教师和学生模型对于相同图片的处理结果(经过 softmax 激活函数处理之后的 soft label),因此即使图片数据不包含真值标签,也可以用来进行训练并提升模型性能。该蒸馏方案的无标签蒸馏策略也大大提升了学生模型的性能上限(`77.1%->78.5%`)。 + +* ImageNet1k 蒸馏 finetune 。 我们仅使用 ImageNet1k 数据,使用蒸馏方法对上述模型进行 finetune,最终仍然可以获得 0.4% 的性能提升(`78.5%->78.9%`)。 + + + +### 2.2 数据选择 + +* SSLD 蒸馏方案的一大特色就是无需使用图像的真值标签,因此可以任意扩展数据集的大小,考虑到计算资源的限制,我们在这里仅基于 ImageNet22k 数据集对蒸馏任务的训练集进行扩充。在 SSLD 蒸馏任务中,我们使用了 `Top-k per class` 的数据采样方案 [3] 。具体步骤如下。 + * 训练集去重。我们首先基于 SIFT 特征相似度匹配的方式对 ImageNet22k 数据集与 ImageNet1k 验证集进行去重,防止添加的 ImageNet22k 训练集中包含 ImageNet1k 验证集图像,最终去除了 4511 张相似图片。部分过滤的相似图片如下所示。 + + ![](../../images/distillation/22k_1k_val_compare_w_sift.png) + + * 大数据集 soft label 获取,对于去重后的 ImageNet22k 数据集,我们使用 `ResNeXt101_32x16d_wsl` 模型进行预测,得到每张图片的 soft label 。 + * Top-k 数据选择,ImageNet1k 数据共有 1000 类,对于每一类,找出属于该类并且得分最高的 `k` 张图片,最终得到一个数据量不超过 `1000*k` 的数据集(某些类上得到的图片数量可能少于 `k` 张)。 + * 将该数据集与 ImageNet1k 的训练集融合组成最终蒸馏模型所使用的数据集,数据量为 500 万。 + + +## 3. 实验 + +* PaddleClas 的蒸馏策略为`大数据集训练 + ImageNet1k 蒸馏 finetune` 的策略。选择合适的教师模型,首先在挑选得到的 500 万数据集上进行训练,然后在 ImageNet1k 训练集上进行 finetune,最终得到蒸馏后的学生模型。 + + +### 3.1 教师模型的选择 + +为了验证教师模型和学生模型的模型大小差异和教师模型的模型精度对蒸馏结果的影响,我们做了几组实验验证。训练策略统一为:`cosine_decay_warmup,lr=1.3, epoch=120, bs=2048`,学生模型均为从头训练。 + +|Teacher Model | Teacher Top1 | Student Model | Student Top1| +|- |:-: |:-: | :-: | +| ResNeXt101_32x16d_wsl | 84.2% | MobileNetV3_large_x1_0 | 75.78% | +| ResNet50_vd | 79.12% | MobileNetV3_large_x1_0 | 75.60% | +| ResNet50_vd | 82.35% | MobileNetV3_large_x1_0 | 76.00% | + + +从表中可以看出 + +> 教师模型结构相同时,其精度越高,最终的蒸馏效果也会更好一些。 +> +> 教师模型与学生模型的模型大小差异不宜过大,否则反而会影响蒸馏结果的精度。 + + +因此最终在蒸馏实验中,对于 ResNet 系列学生模型,我们使用 `ResNeXt101_32x16d_wsl` 作为教师模型;对于 MobileNet 系列学生模型,我们使用蒸馏得到的 `ResNet50_vd` 作为教师模型。 + + +### 3.2 大数据蒸馏 + +基于 PaddleClas 的蒸馏策略为`大数据集训练 + imagenet1k finetune` 的策略。 + +针对从 ImageNet22k 挑选出的 400 万数据,融合 imagenet1k 训练集,组成共 500 万的训练集进行训练,具体地,在不同模型上的训练超参及效果如下。 + + +|Student Model | num_epoch | l2_ecay | batch size/gpu cards | base lr | learning rate decay | top1 acc | +| - |:-: |:-: | :-: |:-: |:-: |:-: | +| MobileNetV1 | 360 | 3e-5 | 4096/8 | 1.6 | cosine_decay_warmup | 77.65% | +| MobileNetV2 | 360 | 1e-5 | 3072/8 | 0.54 | cosine_decay_warmup | 76.34% | +| MobileNetV3_large_x1_0 | 360 | 1e-5 | 5760/24 | 3.65625 | cosine_decay_warmup | 78.54% | +| MobileNetV3_small_x1_0 | 360 | 1e-5 | 5760/24 | 3.65625 | cosine_decay_warmup | 70.11% | +| ResNet50_vd | 360 | 7e-5 | 1024/32 | 0.4 | cosine_decay_warmup | 82.07% | +| ResNet101_vd | 360 | 7e-5 | 1024/32 | 0.4 | cosine_decay_warmup | 83.41% | +| Res2Net200_vd_26w_4s | 360 | 4e-5 | 1024/32 | 0.4 | cosine_decay_warmup | 84.82% | + + +### 3.3 ImageNet1k 训练集 finetune + +对于在大数据集上训练的模型,其学习到的特征可能与 ImageNet1k 数据特征有偏,因此在这里使用 ImageNet1k 数据集对模型进行 finetune。 finetune 的超参和 finetune 的精度收益如下。 + + +|Student Model | num_epoch | l2_ecay | batch size/gpu cards | base lr | learning rate decay | top1 acc | +| - |:-: |:-: | :-: |:-: |:-: |:-: | +| MobileNetV1 | 30 | 3e-5 | 4096/8 | 0.016 | cosine_decay_warmup | 77.89% | +| MobileNetV2 | 30 | 1e-5 | 3072/8 | 0.0054 | cosine_decay_warmup | 76.73% | +| MobileNetV3_large_x1_0 | 30 | 1e-5 | 2048/8 | 0.008 | cosine_decay_warmup | 78.96% | +| MobileNetV3_small_x1_0 | 30 | 1e-5 | 6400/32 | 0.025 | cosine_decay_warmup | 71.28% | +| ResNet50_vd | 60 | 7e-5 | 1024/32 | 0.004 | cosine_decay_warmup | 82.39% | +| ResNet101_vd | 30 | 7e-5 | 1024/32 | 0.004 | cosine_decay_warmup | 83.73% | +| Res2Net200_vd_26w_4s | 360 | 4e-5 | 1024/32 | 0.004 | cosine_decay_warmup | 85.13% | + + +### 3.4 数据增广以及基于 Fix 策略的微调 + +* 基于前文所述的实验结论,我们在训练的过程中加入自动增广(AutoAugment)[4],同时进一步减小了 l2_decay(4e-5->2e-5),最终 ResNet50_vd 经过 SSLD 蒸馏策略,在 ImageNet1k 上的精度可以达到 82.99%,相比之前不加数据增广的蒸馏策略再次增加了 0.6% 。 + + +* 对于图像分类任务,在测试的时候,测试尺度为训练尺度的 1.15 倍左右时,往往在不需要重新训练模型的情况下,模型的精度指标就可以进一步提升 [5],对于 82.99% 的 ResNet50_vd 在 320x320 的尺度下测试,精度可达 83.7%,我们进一步使用 Fix 策略,即在 320x320 的尺度下进行训练,使用与预测时相同的数据预处理方法,同时固定除 FC 层以外的所有参数,最终在 320x320 的预测尺度下,精度可以达到 **84.0%**。 + + +### 3.5 实验过程中的一些问题 + +* 在预测过程中,batch norm 的平均值与方差是通过加载预训练模型得到(设其模式为 test mode)。在训练过程中,batch norm 是通过统计当前 batch 的信息(设其模式为 train mode),与历史保存信息进行滑动平均计算得到,在蒸馏任务中,我们发现通过 train mode,即教师模型的均值与方差实时变化的模式,去指导学生模型,比通过 test mode 蒸馏,得到的学生模型性能更好一些,下面是一组实验结果。因此我们在该蒸馏方案中,均使用 train mode 去得到教师模型的 soft label 。 + +|Teacher Model | Teacher Top1 | Student Model | Student Top1| +|- |:-: |:-: | :-: | +| ResNet50_vd | 82.35% | MobileNetV3_large_x1_0 | 76.00% | +| ResNet50_vd | 82.35% | MobileNetV3_large_x1_0 | 75.84% | + + +## 4. 蒸馏模型的应用 + + +### 4.1 使用方法 + +* 中间层学习率调整。蒸馏得到的模型的中间层特征图更加精细化,因此将蒸馏模型预训练应用到其他任务中时,如果采取和之前相同的学习率,容易破坏中间层特征。而如果降低整体模型训练的学习率,则会带来训练收敛速度慢的问题。因此我们使用了中间层学习率调整的策略。具体地: + * 针对 ResNet50_vd,我们设置一个学习率倍数列表,res block 之前的 3 个 conv2d 卷积参数具有统一的学习率倍数,4 个 res block 的 conv2d 分别有一个学习率参数,共需设置 5 个学习率倍数的超参。在实验中发现。用于迁移学习 finetune 分类模型时,`[0.1,0.1,0.2,0.2,0.3]` 的中间层学习率倍数设置在绝大多数的任务中都性能更好;而在目标检测任务中,`[0.05,0.05,0.05,0.1,0.15]` 的中间层学习率倍数设置能够带来更大的精度收益。 + * 对于 MoblileNetV3_large_x1_0,由于其包含 15 个 block,我们设置每 3 个 block 共享一个学习率倍数参数,因此需要共 5 个学习率倍数的参数,最终发现在分类和检测任务中,`[0.25,0.25,0.5,0.5,0.75]` 的中间层学习率倍数能够带来更大的精度收益。 + + +* 适当的 l2 decay 。不同分类模型在训练的时候一般都会根据模型设置不同的 l2 decay,大模型为了防止过拟合,往往会设置更大的 l2 decay,如 ResNet50 等模型,一般设置为 `1e-4` ;而如 MobileNet 系列模型,在训练时往往都会设置为 `1e-5~4e-5`,防止模型过度欠拟合,在蒸馏时亦是如此。在将蒸馏模型应用到目标检测任务中时,我们发现也需要调节 backbone 甚至特定任务模型模型的 l2 decay,和预训练蒸馏时的 l2 decay 尽可能保持一致。以 Faster RCNN MobiletNetV3 FPN 为例,我们发现仅修改该参数,在 COCO2017 数据集上就可以带来最多 0.5% 左右的精度(mAP)提升(默认 Faster RCNN l2 decay 为 1e-4,我们修改为 1e-5~4e-5 均有 0.3%~0.5% 的提升)。 + + +### 4.2 迁移学习 finetune +* 为验证迁移学习的效果,我们在 10 个小的数据集上验证其效果。在这里为了保证实验的可对比性,我们均使用 ImageNet1k 数据集训练的标准预处理过程,对于蒸馏模型我们也添加了蒸馏模型中间层学习率的搜索。 +* 对于 ResNet50_vd, baseline 为 Top1 Acc 79.12% 的预训练模型基于 grid search 搜索得到的最佳精度,对比实验则为基于该精度对预训练和中间层学习率进一步搜索得到的最佳精度。下面给出 10 个数据集上所有 baseline 和蒸馏模型的精度对比。 + + +| Dataset | Model | Baseline Top1 Acc | Distillation Model Finetune | +|- |:-: |:-: | :-: | +| Oxford102 flowers | ResNete50_vd | 97.18% | 97.41% | +| caltech-101 | ResNete50_vd | 92.57% | 93.21% | +| Oxford-IIIT-Pets | ResNete50_vd | 94.30% | 94.76% | +| DTD | ResNete50_vd | 76.48% | 77.71% | +| fgvc-aircraft-2013b | ResNete50_vd | 88.98% | 90.00% | +| Stanford-Cars | ResNete50_vd | 92.65% | 92.76% | +| SUN397 | ResNete50_vd | 64.02% | 68.36% | +| cifar100 | ResNete50_vd | 86.50% | 87.58% | +| cifar10 | ResNete50_vd | 97.72% | 97.94% | +| Food-101 | ResNete50_vd | 89.58% | 89.99% | + +* 可以看出在上面 10 个数据集上,结合适当的中间层学习率倍数设置,蒸馏模型平均能够带来 1% 以上的精度提升。 + + +### 4.3 目标检测 + +我们基于两阶段目标检测 Faster/Cascade RCNN 模型验证蒸馏得到的预训练模型的效果。 + +* ResNet50_vd + +设置训练与评测的尺度均为 640x640,最终 COCO 上检测指标如下。 + +| Model | train/test scale | pretrain top1 acc | feature map lr | coco mAP | +|- |:-: |:-: | :-: | :-: | +| Faster RCNN R50_vd FPN | 640/640 | 79.12% | [1.0,1.0,1.0,1.0,1.0] | 34.8% | +| Faster RCNN R50_vd FPN | 640/640 | 79.12% | [0.05,0.05,0.1,0.1,0.15] | 34.3% | +| Faster RCNN R50_vd FPN | 640/640 | 82.18% | [0.05,0.05,0.1,0.1,0.15] | 36.3% | + +在这里可以看出,对于未蒸馏模型,过度调整中间层学习率反而降低最终检测模型的性能指标。基于该蒸馏模型,我们也提供了领先的服务端实用目标检测方案,详细的配置与训练代码均已开源,可以参考 [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/rcnn_enhance)。 + + +## 5. SSLD 实战 + +本节将基于 ImageNet-1K 的数据集详细介绍 SSLD 蒸馏实验,如果想快速体验此方法,可以参考 [**30 分钟玩转 PaddleClas(进阶版)**](../quick_start/quick_start_classification_professional.md)中基于 CIFAR100 的 SSLD 蒸馏实验。 + + +### 5.1 参数配置 + +实战部分提供了 SSLD 蒸馏的示例,在 `ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml` 中提供了 `MobileNetV3_large_x1_0` 蒸馏 `MobileNetV3_small_x1_0` 的配置文件,用户可以在 `tools/train.sh` 里直接替换配置文件的路径即可使用。 + +```yaml +Arch: + name: "DistillationModel" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - True + - False + models: + - Teacher: + name: MobileNetV3_large_x1_0 + pretrained: True + use_ssld: True + - Student: + name: MobileNetV3_small_x1_0 + pretrained: False + + infer_model_name: "Student" +``` + +在参数配置中,`freeze_params_list` 中需要指定模型是否需要冻结参数,`models` 中需要指定 Teacher 模型和 Student 模型,其中 Teacher 模型需要加载预训练模型。用户可以直接在此处更改模型。 + + +### 5.2 启动命令 + +当用户配置完训练环境后,类似于训练其他分类任务,只需要将 `tools/train.sh` 中的配置文件替换成为相应的蒸馏配置文件即可。 + +其中 `train.sh` 中的内容如下: + +```bash + +python -m paddle.distributed.launch \ + --selected_gpus="0,1,2,3" \ + --log_dir=mv3_large_x1_0_distill_mv3_small_x1_0 \ + tools/train.py \ + -c ./ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml +``` + +运行 `train.sh` : + +```bash +sh tools/train.sh +``` + + +### 5.3 注意事项 + +* 用户在使用 SSLD 蒸馏之前,首先需要在目标数据集上训练一个教师模型,该教师模型用于指导学生模型在该数据集上的训练。 + +* 如果学生模型没有加载预训练模型,训练的其他超参数可以参考该学生模型在 ImageNet-1k 上训练的超参数,如果学生模型加载了预训练模型,学习率可以调整到原来的 1/10 或者 1/100 。 + +* 在 SSLD 蒸馏的过程中,学生模型只学习 soft-label 导致训练目标变的更加复杂,建议可以适当的调小 `l2_decay` 的值来获得更高的验证集准确率。 + +* 若用户准备添加无标签的训练数据,只需要将新的训练数据放置在原本训练数据的路径下,生成新的数据 list 即可,另外,新生成的数据 list 需要将无标签的数据添加伪标签(只是为了统一读数据)。 + + +## 6. 参考文献 + +[1] Hinton G, Vinyals O, Dean J. Distilling the knowledge in a neural network[J]. arXiv preprint arXiv:1503.02531, 2015. + +[2] Bagherinezhad H, Horton M, Rastegari M, et al. Label refinery: Improving imagenet classification through label progression[J]. arXiv preprint arXiv:1805.02641, 2018. + +[3] Yalniz I Z, Jégou H, Chen K, et al. Billion-scale semi-supervised learning for image classification[J]. arXiv preprint arXiv:1905.00546, 2019. + +[4] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123. + +[5] Touvron H, Vedaldi A, Douze M, et al. Fixing the train-test resolution discrepancy[C]//Advances in Neural Information Processing Systems. 2019: 8250-8260. diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/model_prune_quantization.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/model_prune_quantization.md new file mode 100644 index 0000000..f6b4afc --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/model_prune_quantization.md @@ -0,0 +1,173 @@ + +# 模型量化、裁剪使用介绍 + +复杂的模型有利于提高模型的性能,但也导致模型中存在一定冗余。此部分提供精简模型的功能,包括两部分:模型量化(量化训练、离线量化)、模型剪枝。 + +其中模型量化将全精度缩减到定点数减少这种冗余,达到减少模型计算复杂度,提高模型推理性能的目的。 +模型量化可以在基本不损失模型的精度的情况下,将 FP32 精度的模型参数转换为 Int8 精度,减小模型参数大小并加速计算,使用量化后的模型在移动端等部署时更具备速度优势。 + +模型剪枝将 CNN 中不重要的卷积核裁剪掉,减少模型参数量,从而降低模型计算复杂度。 + +本教程将介绍如何使用飞桨模型压缩库 PaddleSlim 做 PaddleClas 模型的压缩,即裁剪、量化功能。 +[PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim)集成了模型剪枝、量化(包括量化训练和离线量化)、蒸馏和神经网络搜索等多种业界常用且领先的模型压缩功能,如果您感兴趣,可以关注并了解。 + +在开始本教程之前,建议先了解 [PaddleClas 模型的训练方法](../models_training/classification.md)以及 [PaddleSlim](https://paddleslim.readthedocs.io/zh_CN/latest/index.html),相关裁剪、量化方法可以参考[模型裁剪量化算法介绍文档](../algorithm_introduction/model_prune_quantization.md)。 + +----------- + +## 目录 + + - [1. 准备环境](#1) + - [1.1 安装 PaddleSlim](#1.1) + - [1.2 准备训练好的模型](#1.2) + - [2. 快速开始](#2) + - [2.1 模型量化](#2.1) + - [2.1.1 在线量化训练](#2.1.1) + - [2.1.2 离线量化](#2.1.2) + - [2.2 模型剪枝](#2.2) + - [3. 导出模型](#3) + - [4. 模型部署](#4) + - [5. 训练超参数建议](#5) + + + +## 1. 准备环境 +当训练出一个模型后,如果希望进一步的压缩模型大小并加速预测,可使用量化或者剪枝的方法压缩模型。 + +模型压缩主要包括五个步骤: +1. 安装 PaddleSlim +2. 准备训练好的模型 +3. 模型压缩 +4. 导出量化推理模型 +5. 量化模型预测部署 + + +### 1.1 安装 PaddleSlim + +* 可以通过 pip install 的方式进行安装。 + +```bash +pip install paddleslim -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +* 如果获取 PaddleSlim 的最新特性,可以从源码安装。 + +```bash +git clone https://github.com/PaddlePaddle/PaddleSlim.git +cd Paddleslim +python3.7 setup.py install +``` + + +### 1.2 准备训练好的模型 + +PaddleClas 提供了一系列训练好的[模型](../models/models_intro.md),如果待量化的模型不在列表中,需要按照[常规训练](../models_training/classification.md)方法得到训练好的模型。 + + +## 2. 快速开始 + +进入 PaddleClas 根目录 + +```bash +cd PaddleClas +``` + +`slim` 训练相关代码已经集成到 `ppcls/engine/` 下,离线量化代码位于 `deploy/slim/quant_post_static.py`。 + + +### 2.1 模型量化 + +量化训练包括离线量化训练和在线量化训练,在线量化训练效果更好,需加载预训练模型,在定义好量化策略后即可对模型进行量化。 + + +#### 2.1.1 在线量化训练 + +训练指令如下: + +* CPU/单卡 GPU + +以 CPU 为例,若使用 GPU,则将命令中改成 `cpu` 改成 `gpu` + +```bash +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.device=cpu +``` + +其中 `yaml` 文件解析详见[参考文档](../models_training/config_description.md)。为了保证精度,`yaml` 文件中已经使用 `pretrained model`. + + +* 单机多卡/多机多卡启动 + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +``` + + +#### 2.1.2 离线量化 + +**注意**:目前离线量化,必须使用已经训练好的模型,导出的 `inference model` 进行量化。一般模型导出 `inference model` 可参考[教程](../inference_deployment/export_model.md). + +一般来说,离线量化损失模型精度较多。 + +生成 `inference model` 后,离线量化运行方式如下 + +```bash +python3.7 deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./deploy/models/class_ResNet50_vd_ImageNet_infer +``` + +`Global.save_inference_dir` 是 `inference model` 存放的目录。 + +执行成功后,在 `Global.save_inference_dir` 的目录下,生成 `quant_post_static_model` 文件夹,其中存储生成的离线量化模型,其可以直接进行预测部署,无需再重新导出模型。 + + +### 2.2 模型剪枝 + +训练指令如下: + +- CPU/单卡 GPU + +以 CPU 为例,若使用 GPU,则将命令中改成 `cpu` 改成 `gpu` + +```bash +python3.7 tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.device=cpu +``` + +- 单机单卡/单机多卡/多机多卡启动 + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml +``` + + +## 3. 导出模型 + +在得到在线量化训练、模型剪枝保存的模型后,可以将其导出为 inference model,用于预测部署,以模型剪枝为例: + +```bash +python3.7 tools/export.py \ + -c ppcls/configs/slim/ResNet50_vd_prune.yaml \ + -o Global.pretrained_model=./output/ResNet50_vd/best_model \ + -o Global.save_inference_dir=./inference +``` + + +## 4. 模型部署 + +上述步骤导出的模型可以直接使用 inferecne 进行部署,参考 [inference 部署](../inference_deployment/)。 + +也通过 PaddleLite 的 opt 模型转换工具,完成 inference 模型到移动端模型转换,用于移动端的模型部署。 +移动端模型部署的可参考 [移动端模型部署](../inference_deployment/paddle_lite_deploy.md)。 + + +## 5. 训练超参数建议 + +* 量化、裁剪训练时,建议加载常规训练得到的预训练模型,加速量化训练收敛。 +* 量化训练时,建议初始学习率修改为常规训练的 `1/20~1/10`,同时将训练 epoch 数修改为常规训练的 `1/5~1/2`,学习率策略方面,加上 Warmup,其他配置信息不建议修改。 +* 裁剪训练时,建议超参数配置与普通训练一致。 diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/shitu_deploy.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/shitu_deploy.md new file mode 100644 index 0000000..064f68e --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/shitu_deploy.md @@ -0,0 +1,97 @@ +# PP-ShiTu迁移应用及调优 + +## 目录 + +- [1.使用官方模型](#1) + - [1.1 下载官方模型及数据准备](#1.1) + - [1.2 建立检索库(gallery)](#1.2) + - [1.3 精度测试](#1.3) +- [2.模型调优](#2) + - [2.1 检测模型调优](#2.1) + - [2.2 识别模型调优](#2.2) +- [3.模型加速](#3) + +在[PP-ShiTu快速开始](../quick_start/quick_start_recognition.md)中,主要展示了`PP-ShiTu`的快速开始demo。那么本文档主要介绍,如何将`PP-ShiTu`应用到自己的需求中,及如何继续调优,优化识别效果。具体可以分成以下三种情况 + +- 直接使用官方模型 +- 根据需求对模型进行调优 +- 模型加速 + +以下分别对上面三种情况进行具体讲解。 + + + +## 1. 使用官方模型 + +对于其他的应用,首先建议使用此种方法,因为PaddleClas官方模型,是经过大量数据训练得到的,具有强大泛化性能的轻量级通用模型。其速度较快、精度较高,在Intel cpu上直接部署,也能快速得到结果。同时,直接使用官方模型,则无需训练新的模型,节约时间,方便快速部署。 + +使用官方模型具体步骤如下: + +- 下载模型及数据准备 +- 检索库更新 +- 精度测试 + + + +### 1.1 下载官方模型及数据准备 + +模型下载及pipline 运行详见[图像识别快速开始](../quick_start/quick_start_recognition.md) + +下载模型后,要准备相应的数据,即所迁移应用的具体数据,数据量根据实际情况,自行决定,但是不能太少,会影响精度。将准备的数据分成两部分:1)建库图像(gallery),2)测试图像。其中建库数据无需过多,但需保证每个类别包含此类别物体不同角度的图像,建议每个类别至少5张图,请根据实际情况,具体调节。 + +数据标注工具可以使用[lebalme](https://github.com/wkentaro/labelme)。标注数据时。请标注待识别物体的的包围框(BoundingBox),注意只需要标注**建库图像**。。 + +建议一个类别一共准备30张图左右,其中约至少5张图作为建库图像,剩下的作为测试图像。 + + + +### 1.2 建立检索库(gallery) + +对于加入检索的数据,每个类别尽量准备此类别的各角度的图像,丰富类别信息。准备的图像只能包含此类别,同时图像背景尽可能的少、简单。即将要加入检索根据标注的包围框信息,裁剪出bbox图像作为新的要加入的图像,以提高检索库的图像质量。 + +收集好图像后,数据整理及建库流程详见[图像识别快速开始](../quick_start/quick_start_recognition.md)中`3.2 建立新的索引库` + + + +### 1.3 精度测试 + +使用测试图像,对整个pipline进行简单的精度测试。如发现类别不正确,则需对gallery进行调整,将不正确的测试图像的相似图片(标注并裁剪出没有背景的物体)加入gallery中,反复迭代。经过调整后,可以测试出整个pipeline的精度。如果精度能够满足需求,则可继续使用。若精度不达预期,则需对模型进行调优,参考下面文档。 + + + +## 2. 模型调优 + +在使用官方模型之后,如果发现精度不达预期,则可对模型进行训练调优。同时,根据官方模型的结果,需要进一步大概判断出 检测模型精度、还是识别模型精度问题。不同模型的调优,可参考以下文档。 + + + +### 2.1 检测模型调优 + +`PP-ShiTu`中检测模型采用的 `PicoDet `算法,具体算法请参考[此文档](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.3/configs/picodet)。检测模型的训练及调优,请参考[此文档](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.3/README_cn.md)。 + +对模型进行训练的话,需要自行准备数据,并对数据进行标注,建议一个类别至少准备200张标注图像,并将标注图像及groudtruth文件转成coco文件格式,以方便使用PaddleDetection进行训练。主体检测的预训练权重及相关配置文件相见[主体检测文档](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/application/mainbody_detection)。训练的时候,请加载主体检测的预训练权重。 + + + +### 2.2 识别模型调优 + +在使用官方模型后,如果不满足精度需求,则可以参考此部分文档,进行模型调优 + +因为要对模型进行训练,所以收集自己的数据集。数据准备及相应格式请参考:[特征提取文档](../image_recognition_pipeline/feature_extraction.md)中 `4.1数据准备`部分、[识别数据集说明](../data_preparation/recognition_dataset.md)。值得注意的是,此部分需要准备大量的数据,以保证识别模型效果。训练配置文件参考:[通用识别模型配置文件](../../../ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml),训练方法参考:[识别模型训练](../models_training/recognition.md) + +- 数据增强:根据实际情况选择不同数据增强方法。如:实际应用中数据遮挡比较严重,建议添加`RandomErasing`增强方法。详见[数据增强文档](./DataAugmentation.md) +- 换不同的`backbone`,一般来说,越大的模型,特征提取能力更强。不同`backbone`详见[模型介绍](../models/models_intro.md) +- 选择不同的`Metric Learning`方法。不同的`Metric Learning`方法,对不同的数据集效果可能不太一样,建议尝试其他`Loss`,详见[Metric Learning](../algorithm_introduction/metric_learning.md) +- 采用蒸馏方法,对小模型进行模型能力提升,详见[模型蒸馏](../algorithm_introduction/knowledge_distillation.md) +- 增补数据集。针对错误样本,添加badcase数据 + +模型训练完成后,参照[1.2 检索库更新](#1.2)进行检索库更新。同时,对整个pipeline进行测试,如果精度不达预期,则重复此步骤。 + + + +## 3. 模型加速 + +模型加速主要以下几种方法: + +- 替换小模型:一般来说,越小的模型预测速度相对越快 +- 模型裁剪、量化:请参考文档[模型压缩](./model_prune_quantization.md),压缩配置文件修改请参考[slim相关配置文件](../../../ppcls/configs/slim/)。 diff --git a/src/PaddleClas/docs/zh_CN/advanced_tutorials/theseus_layer.md b/src/PaddleClas/docs/zh_CN/advanced_tutorials/theseus_layer.md new file mode 100644 index 0000000..56f2c97 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/advanced_tutorials/theseus_layer.md @@ -0,0 +1,275 @@ +# TheseusLayer 使用说明 + +基于 TheseusLayer 构建的网络模型,支持网络截断、返回网络中间层输出和修改网络中间层的功能。 + +--- + +## 目录 + +- [1. 前言](#1) +- [2. 网络层描述符说明](#2) +- [3. 功能介绍](#3) + - [3.1 网络截断(stop_after)](#3.1) + - [3.2 返回网络中间层输出(update_res)](#3.2) + - [3.3 修改网络中间层(upgrade_sublayer)](#3.3) + + + +## 1. 前言 + +`TheseusLayer` 是继承了 `nn.Layer` 的子类,使用 `TheseusLayer` 作为父类构建的网络模型,可以通过 `TheseusLayer` 的 `stop_after()`、`update_res()` 和 `upgrade_sublayer()` 实现网络截断、返回中间层输出以及修改网络中间层的功能。目前 PaddleClas 中 `ppcls.arch.backbone.legendary_models` 下的所有模型均支持上述操作。 + +如需基于 `TheseusLayer` 构建新的网络结构,只需继承 `TheseusLayer` 即可: + +```python +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer + +class net(TheseusLayer): + def __init__(): + super().__init__() + + def forward(x): + pass +``` + + + +## 2. 网络层描述符说明 + +使用 `TheseusLayer` 提供的方法对模型进行操作/修改时,需要通过参数指定网络中间层,因此 `TheseusLayer` 规定了用于描述网络中间层的网络层描述符。 + +网络层描述符的使用需要符合以下规则: +* 为 Python 字符串(str)类型; +* 使用网络层对象的变量名指定该网络层; +* 以 `.` 作为网络层级的分隔符; +* 对于 `nn.Sequential` 类型或是 `nn.LayerList` 类型的层,使用 `["index"]` 指定其子层。 + +以 `MobileNetV1` 网络为例,其模型结构定义在 [MobileNetV1](../../../ppcls/arch/backbone/legendary_models/mobilenet_v1.py),为方便说明,可参考下方网络结构及不同网络层所对应的网络层描述符。可以清晰看出,对于 `MobileNetV1` 网络的任一子层,均可按层级结构逐层指定,不同层级结构间使用 `.` 进行分隔即可。 + +```shell +# 网络层对象的变量名(该对象所属类)....................(该网络层对应的网络层描述符) + +MobileNetV1 +├── conv (ConvBNLayer)............................("conv") +│   ├── conv (nn.Conv2D)..........................("conv.conv") +│   ├── bn (nn.BatchNorm).........................("conv.bn") +│   └── relu (nn.ReLU)............................("conv.relu") +│ +├── blocks (nn.Sequential)........................("blocks") +│   ├── blocks0 (DepthwiseSeparable)..............("blocks[0]") +│   │   ├── depthwise_conv (ConvBNLayer)..........("blocks[0].depthwise_conv") +│   │   │   ├── conv (nn.Conv2D)..................("blocks[0].depthwise_conv.conv") +│   │   │   ├── bn (nn.BatchNorm).................("blocks[0].depthwise_conv.bn") +│   │   │   └── relu (nn.ReLU)....................("blocks[0].depthwise_conv.relu") +│   │   └── pointwise_conv (ConvBNLayer)..........("blocks[0].pointwise_conv") +│   │   ├── conv (nn.Conv2D)..................("blocks[0].pointwise_conv.conv") +│   │   ├── bn (nn.BatchNorm).................("blocks[0].pointwise_conv.bn") +│   │   └── relu (nn.ReLU)....................("blocks[0].pointwise_conv.relu") +│   . +│   . +│   . +│   └── blocks12 (DepthwiseSeparable).............("blocks[12]") +│      ├── depthwise_conv (ConvBNLayer)..........("blocks[0].depthwise_conv") +│      │   ├── conv (nn.Conv2D)..................("blocks[0].depthwise_conv.conv") +│      │   ├── bn (nn.BatchNorm).................("blocks[0].depthwise_conv.bn") +│      │   └── relu (nn.ReLU)....................("blocks[0].depthwise_conv.relu") +│      └── pointwise_conv (ConvBNLayer)..........("blocks[0].pointwise_conv") +│      ├── conv (nn.Conv2D)..................("blocks[0].pointwise_conv.conv") +│      ├── bn (nn.BatchNorm).................("blocks[0].pointwise_conv.bn") +│      └── relu (nn.ReLU)....................("blocks[0].pointwise_conv.relu") +│ +├── avg_pool (nn.AdaptiveAvgPool2D)...............("avg_pool") +│ +├── flatten (nn.Flatten)..........................("flatten") +│ +└── fc (nn.Linear)................................("fc") +``` + +因此,对于 `MobileNetV1` 网络: +* 网络层描述符 `flatten`,其指定了网络 `MobileNetV1` 的 `flatten` 这一层。 +* 网络层描述符 `blocks[5]`,其指定了网络 `MobileNetV1` 的 `blocks` 层中的第 `6` 个 `DepthwiseSeparable` 对象这一层; +* 网络层描述符 `blocks[0].depthwise_conv.conv`,其指定了网络 `MobileNetV1` 的 `blocks` 层中的第 `1` 个 `DepthwiseSeparable` 对象中的 `depthwise_conv` 中的 `conv` 这一层; + + + +## 3. 方法说明 + +PaddleClas 提供的 backbone 网络均基于图像分类数据集训练得到,因此网络的尾部带有用于分类的全连接层,而在特定任务场景下,需要去掉分类的全连接层。在部分下游任务中,例如目标检测场景,需要获取到网络中间层的输出结果,也可能需要对网络的中间层进行修改,因此 `TheseusLayer` 提供了 3 个接口函数用于实现不同的修改功能。 + + + +### 3.1 网络截断(stop_after) + +```python +def stop_after(self, stop_layer_name: str) -> bool: + """stop forward and backward after 'stop_layer_name'. + + Args: + stop_layer_name (str): The name of layer that stop forward and backward after this layer. + + Returns: + bool: 'True' if successful, 'False' otherwise. + """ +``` + +该方法可通过参数 `stop_layer_name` 指定网络中的特定子层,并停止该层之后的所有层的前后向传输,在逻辑上,该层之后不再有其他网络层。 + +* 参数: + * `stop_layer_name`: `str` 类型的对象,用于指定网络子层的网络层描述符。关于网络层描述符的具体规则,请查看[网络层描述符说明](#2)。 +* 返回值: + * 当该方法成功执行时,其返回值为 `True`,否则为 `False`。 + +以 `MobileNetV1` 网络为例,参数 `stop_layer_name` 为 `"blocks[0].depthwise_conv.conv"`,具体效果可以参考下方代码案例进行尝试。 + +```python +# cd or pip install paddleclas to import paddleclas +import paddleclas + +net = paddleclas.MobileNetV1() +print("========== the origin mobilenetv1 net arch ==========") +print(net) + +res = net.stop_after(stop_layer_name="blocks[0].depthwise_conv.conv") +print("The result returned by stop_after(): ", res) +# The result returned by stop_after(): True + +print("\n\n========== the truncated mobilenetv1 net arch ==========") +print(net) +``` + + + +### 3.2 返回网络中间层输出(update_res) + +```python +def update_res( + self, + return_patterns: Union[str, List[str]]) -> Dict[str, nn.Layer]: + """update the result(s) to be returned. + + Args: + return_patterns (Union[str, List[str]]): The name of layer to return output. + + Returns: + Dict[str, nn.Layer]: The pattern(str) and corresponding layer(nn.Layer) that have been set successfully. + """ +``` + +该方法可通过参数 `return_patterns` 指定一层(str 对象)或多层(list 对象)网络的中间子层,并在网络前向时,将指定层的输出结果与网络的最终结果一同返回。 + +* 参数: + * `return_patterns`:作为网络层描述符的 `str` 对象,或是 `str` 对象所组成的 `list` 对象,其元素为用于指定网络子层的网络层描述符。关于网络层描述符的具体规则,请查看[网络层描述符说明](#2)。 +* 返回值: + * 该方法的返回值为 `list` 对象,元素为设置成功的子层的网络层描述符。 + +以 `MobileNetV1` 网络为例,当 `return_patterns` 为 `["blocks[0]", "blocks[2]", "blocks[4]", "blocks[10]"]`,在网络前向推理时,网络的输出结果将包含以上 4 层的输出和网络最终的输出,具体效果可以参考下方代码案例进行尝试。 + +```python +import numpy as np +import paddle + +# cd or pip install paddleclas to import paddleclas +import paddleclas + +np_input = np.zeros((1, 3, 224, 224)) +pd_input = paddle.to_tensor(np_input, dtype="float32") + +net = paddleclas.MobileNetV1(pretrained=True) + +output = net(pd_input) +print("The output's type of origin net: ", type(output)) +# The output's type of origin net: + +res = net.update_res(return_patterns=["blocks[0]", "blocks[2]", "blocks[4]", "blocks[10]"]) +print("The result returned by update_res(): ", res) +# The result returned by update_res(): ['blocks[0]', 'blocks[2]', 'blocks[4]', 'blocks[10]'] + +output = net(pd_input) +print("The output's keys of processed net: ", output.keys()) +# The output's keys of net: dict_keys(['output', 'blocks[0]', 'blocks[2]', 'blocks[4]', 'blocks[10]']) +# 网络前向输出 output 为 dict 类型对象,其中,output["output"] 为网络最终输出,output["blocks[0]"] 等为网络中间层输出结果 +``` + +除了通过调用方法 `update_res()` 的方式之外,也同样可以在实例化网络对象时,通过指定参数 `return_patterns` 实现相同效果: + +```python +net = paddleclas.MobileNetV1(pretrained=True, return_patterns=["blocks[0]", "blocks[2]", "blocks[4]", "blocks[10]"]) +``` + +并且在实例化网络对象时,还可以通过参数 `return_stages` 指定网络不同 `stage` 的输出,如下方代码所示: + +```python +# 当 `return_stages` 为 `True`,会将网络所有 stage 的前向输出一并返回,如下所示: +net = paddleclas.MobileNetV1(pretrained=True, return_stages=True) + +# 当 `return_stages` 为 list 对象,可以指定需要返回输出结果的 stage 的序号,如下所示: +net = paddleclas.MobileNetV1(pretrained=True, return_stages=[0, 1, 2, 3]) +``` + + + +### 3.3 修改网络中间层(upgrade_sublayer) + +```python +def upgrade_sublayer(self, + layer_name_pattern: Union[str, List[str]], + handle_func: Callable[[nn.Layer, str], nn.Layer] + ) -> Dict[str, nn.Layer]: + """use 'handle_func' to modify the sub-layer(s) specified by 'layer_name_pattern'. + + Args: + layer_name_pattern (Union[str, List[str]]): The name of layer to be modified by 'handle_func'. + handle_func (Callable[[nn.Layer, str], nn.Layer]): The function to modify target layer specified by 'layer_name_pattern'. The formal params are the layer(nn.Layer) and pattern(str) that is (a member of) layer_name_pattern (when layer_name_pattern is List type). And the return is the layer processed. + + Returns: + Dict[str, nn.Layer]: The key is the pattern and corresponding value is the result returned by 'handle_func()'. + """ +``` + +该方法可通过参数 `layer_name_pattern` 指定一层(str 对象)或多层(list 对象)网络中间子层,并使用参数 `handle_func` 所指定的函数对指定的子层进行修改。 + +* 参数: + * `layer_name_pattern`:作为网络层描述符的 `str` 对象,或是 `str` 对象所组成的 `list` 对象,其元素为用于指定网络子层的网络层描述符。关于网络层描述符的具体规则,请查看[网络层描述符说明](#2)。 + * `handle_func`:有 2 个形参的可调用对象,第 1 个形参为 `nn.Layer` 类型,第 2 个形参为 `str` 类型,该可调用对象返回值必须为 `nn.Layer` 类型对象或是有 `forward` 方法的对象。 +* 返回值: + * 该方法的返回值为 `list` 对象,元素为修改成功的网络子层的网络层描述符。 + +`upgrade_sublayer` 方法会根据 `layer_name_pattern` 查找对应的网络子层,并将查找到的子层和其 `pattern` 传入可调用对象 `handle_func`,并使用 `handle_func` 的返回值替换该层。 + +以 `MobileNetV1` 网络为例,将网络最后的 2 个 block 中的深度可分离卷积(depthwise_conv)改为 `5*5` 大小的卷积核,同时将 padding 改为 `2`,如下方代码所示: + +```python +from paddle import nn + +# cd or pip install paddleclas to import paddleclas +import paddleclas + +# 该函数必须有两个形参 +# 第一个形参用于接受指定的网络中间子层 +# 第二个形参用于接受指定网络子层的网络层描述符 +def rep_func(layer: nn.Layer, pattern: str): + new_layer = nn.Conv2D( + # layer 为 blocks[11].depthwise_conv.conv 或 + # blocks[12].depthwise_conv.conv 所对应的网络中间子层 + # 因此,新的网络层(new_layer)与被替换掉的网络层具有相同的 + # in_channels 属性和 out_channels 属性 + in_channels=layer._in_channels, + out_channels=layer._out_channels, + kernel_size=5, + padding=2 + ) + # 该函数返回值为新的网络层 + # upgrade_sublayer() 方法将使用该返回值替换对应的网络中间子层 + return new_layer + +net = paddleclas.MobileNetV1(pretrained=True) +print("========== the origin mobilenetv1 net arch ==========") +print(net) + +res = net.upgrade_sublayer(layer_name_pattern=["blocks[11].depthwise_conv.conv", "blocks[12].depthwise_conv.conv"], handle_func=rep_func) +print("The result returned by upgrade_sublayer() is", res) +# The result returned by upgrade_sublayer() is ['blocks[11].depthwise_conv.conv', 'blocks[12].depthwise_conv.conv'] + +print("\n\n========== the upgraded mobilenetv1 net arch ==========") +print(net) +``` diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/DataAugmentation.md b/src/PaddleClas/docs/zh_CN/algorithm_introduction/DataAugmentation.md new file mode 100644 index 0000000..32bdfd9 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/DataAugmentation.md @@ -0,0 +1,277 @@ +# 数据增强 +------ +## 目录 + + - [1. 数据增强简介](#1) + - [2. 常用数据增强方法](#2) + - [2.1 图像变换类](#2.1) + - [2.1.1 AutoAugment](#2.1.1) + - [2.1.2 RandAugment](#2.1.2) + - [2.1.3 TimmAutoAugment](#2.1.3) + - [2.2 图像裁剪类](#2.2) + - [2.2.1 Cutout](#2.2.1) + - [2.2.2 RandomErasing](#2.2.2) + - [2.2.3 HideAndSeek](#2.2.3) + - [2.2.4 GridMask](#2.2.4) + - [2.3 图像混叠类](#2.3) + - [2.3.1 Mixup](#2.3.1) + - [2.3.2 Cutmix](#2.3.2) + + +## 1. 数据增强简介 + +在图像分类任务中,图像数据的增广是一种常用的正则化方法,常用于数据量不足或者模型参数较多的场景。在本章节中,我们将对除 ImageNet 分类任务标准数据增强外的 8 种数据增强方式进行简单的介绍和对比,用户也可以将这些增广方法应用到自己的任务中,以获得模型精度的提升。这 8 种数据增强方式在 ImageNet 上的精度指标如下所示。 + +![](../../images/image_aug/main_image_aug.png) + + +## 2. 常用数据增强方法 + +如果没有特殊说明,本章节中所有示例为 ImageNet 分类,并且假设最终输入网络的数据维度为:`[batch-size, 3, 224, 224]` + +其中 ImageNet 分类训练阶段的标准数据增强方式分为以下几个步骤: + +1. 图像解码:简写为 `ImageDecode` +2. 随机裁剪到长宽均为 224 的图像:简写为 `RandCrop` +3. 水平方向随机翻转:简写为 `RandFlip` +4. 图像数据的归一化:简写为 `Normalize` +5. 图像数据的重排,`[224, 224, 3]` 变为 `[3, 224, 224]`:简写为 `Transpose` +6. 多幅图像数据组成 batch 数据,如 `batch-size` 个 `[3, 224, 224]` 的图像数据拼组成 `[batch-size, 3, 224, 224]`:简写为 `Batch` + +相比于上述标准的图像增广方法,研究者也提出了很多改进的图像增广策略,这些策略均是在标准增广方法的不同阶段插入一定的操作,基于这些策略操作所处的不同阶段,我们将其分为了三类: + +1. 对 `RandCrop` 后的 224 的图像进行一些变换: AutoAugment,RandAugment +2. 对 `Transpose` 后的 224 的图像进行一些裁剪: CutOut,RandErasing,HideAndSeek,GridMask +3. 对 `Batch` 后的数据进行混合: Mixup,Cutmix + +增广后的可视化效果如下所示。 + +![](../../images/image_aug/image_aug_samples_s.jpg) + +具体如下表所示: + + +| 变换方法 | 输入 | 输出 | Auto-
Augment\[1\] | Rand-
Augment\[2\] | CutOut\[3\] | Rand
Erasing\[4\] | HideAnd-
Seek\[5\] | GridMask\[6\] | Mixup\[7\] | Cutmix\[8\] | +|-------------|---------------------------|---------------------------|------------------|------------------|-------------|------------------|------------------|---------------|------------|------------| +| Image
Decode | Binary | (224, 224, 3)
uint8 | Y | Y | Y | Y | Y | Y | Y | Y | +| RandCrop | (:, :, 3)
uint8 | (224, 224, 3)
uint8 | Y | Y | Y | Y | Y | Y | Y | Y | +| **Process** | (224, 224, 3)
uint8 | (224, 224, 3)
uint8 | Y | Y | \- | \- | \- | \- | \- | \- | +| RandFlip | (224, 224, 3)
uint8 | (224, 224, 3)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| Normalize | (224, 224, 3)
uint8 | (3, 224, 224)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| Transpose | (224, 224, 3)
float32 | (3, 224, 224)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| **Process** | (3, 224, 224)
float32 | (3, 224, 224)
float32 | \- | \- | Y | Y | Y | Y | \- | \- | +| Batch | (3, 224, 224)
float32 | (N, 3, 224, 224)
float32 | Y | Y | Y | Y | Y | Y | Y | Y | +| **Process** | (N, 3, 224, 224)
float32 | (N, 3, 224, 224)
float32 | \- | \- | \- | \- | \- | \- | Y | Y | + + +PaddleClas 中集成了上述所有的数据增强策略,每种数据增强策略的参考论文与参考开源代码均在下面的介绍中列出。下文将介绍这些策略的原理与使用方法,并以下图为例,对变换后的效果进行可视化。为了说明问题,本章节中将 `RandCrop` 替换为 `Resize`。 + +![][test_baseline] + +### 2.1 图像变换类 + +图像变换类指的是对 `RandCrop` 后的 224 的图像进行一些变换,主要包括 + ++ AutoAugment ++ RandAugment ++ TimmAutoAugment + +#### 2.1.1 AutoAugment + +论文地址:[https://arxiv.org/abs/1805.09501v1](https://arxiv.org/abs/1805.09501v1) + +开源代码 github 地址:[https://github.com/DeepVoltaire/AutoAugment](https://github.com/DeepVoltaire/AutoAugment) + +不同于常规的人工设计图像增广方式,AutoAugment 是在一系列图像增广子策略的搜索空间中通过搜索算法找到的适合特定数据集的图像增广方案。针对 ImageNet 数据集,最终搜索出来的数据增强方案包含 25 个子策略组合,每个子策略中都包含两种变换,针对每幅图像都随机的挑选一个子策略组合,然后以一定的概率来决定是否执行子策略中的每种变换。 + +经过 AutoAugment 数据增强后结果如下图所示。 + +![][test_autoaugment] + +#### 2.1.2 RandAugment + +论文地址:[https://arxiv.org/pdf/1909.13719.pdf](https://arxiv.org/pdf/1909.13719.pdf) + +开源代码 github 地址:[https://github.com/heartInsert/randaugment](https://github.com/heartInsert/randaugment) + + +`AutoAugment` 的搜索方法比较暴力,直接在数据集上搜索针对该数据集的最优策略,其计算量很大。在 `RandAugment` 文章中作者发现,一方面,针对越大的模型,越大的数据集,使用 `AutoAugment` 方式搜索到的增广方式产生的收益也就越小;另一方面,这种搜索出的最优策略是针对该数据集的,其迁移能力较差,并不太适合迁移到其他数据集上。 + +在 `RandAugment` 中,作者提出了一种随机增广的方式,不再像 `AutoAugment` 中那样使用特定的概率确定是否使用某种子策略,而是所有的子策略都会以同样的概率被选择到,论文中的实验也表明这种数据增强方式即使在大模型的训练中也具有很好的效果。 + + +经过 RandAugment 数据增强后结果如下图所示。 + +![][test_randaugment] + +#### 2.1.3 TimmAutoAugment + +开源代码 github 地址:[https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/auto_augment.py](https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/auto_augment.py) + +`TimmAutoAugment` 是开源作者对 AutoAugment 和 RandAugment 的改进,事实证明,其在很多视觉任务上有更好的表现,目前绝大多数 VisionTransformer 模型都是基于 TimmAutoAugment 去实现的。 + + +### 2.2 图像裁剪类 + +图像裁剪类主要是对 `Transpose` 后的 224 的图像进行一些裁剪,并将裁剪区域的像素值置为特定的常数(默认为 0),主要包括: + ++ CutOut ++ RandErasing ++ HideAndSeek ++ GridMask + +图像裁剪的这些增广并非一定要放在归一化之后,也有不少实现是放在归一化之前的,也就是直接对 uint8 的图像进行操作,两种方式的差别是:如果直接对 uint8 的图像进行操作,那么再经过归一化之后被裁剪的区域将不再是纯黑或纯白(减均值除方差之后像素值不为 0)。而对归一后之后的数据进行操作,裁剪的区域会是纯黑或纯白。 + +上述的裁剪变换思路是相同的,都是为了解决训练出的模型在有遮挡数据上泛化能力较差的问题,不同的是他们的裁剪方式、区域不太一样。 + +#### 2.2.1 Cutout + +论文地址:[https://arxiv.org/abs/1708.04552](https://arxiv.org/abs/1708.04552) + +开源代码 github 地址:[https://github.com/uoguelph-mlrg/Cutout](https://github.com/uoguelph-mlrg/Cutout) + +Cutout 可以理解为 Dropout 的一种扩展操作,不同的是 Dropout 是对图像经过网络后生成的特征进行遮挡,而 Cutout 是直接对输入的图像进行遮挡,相对于 Dropout 对噪声的鲁棒性更好。作者在论文中也进行了说明,这样做法有以下两点优势:(1)通过 Cutout 可以模拟真实场景中主体被部分遮挡时的分类场景;(2)可以促进模型充分利用图像中更多的内容来进行分类,防止网络只关注显著性的图像区域,从而发生过拟合。 + + +经过 RandAugment 数据增强后结果如下图所示。 + +![][test_cutout] + +#### 2.2.2 RandomErasing + +论文地址:[https://arxiv.org/pdf/1708.04896.pdf](https://arxiv.org/pdf/1708.04896.pdf) + +开源代码 github 地址:[https://github.com/zhunzhong07/Random-Erasing](https://github.com/zhunzhong07/Random-Erasing) + +`RandomErasing` 与 `Cutout` 方法类似,同样是为了解决训练出的模型在有遮挡数据上泛化能力较差的问题,作者在论文中也指出,随机裁剪的方式与随机水平翻转具有一定的互补性。作者也在行人再识别(REID)上验证了该方法的有效性。与 `Cutout` 不同的是,在 `RandomErasing` 中,图片以一定的概率接受该种预处理方法,生成掩码的尺寸大小与长宽比也是根据预设的超参数随机生成。 + + +PaddleClas 中 `RandomErasing` 的使用方法如下所示。 + +经过 RandomErasing 数据增强后结果如下图所示。 + +![][test_randomerassing] + + +#### 2.2.3 HideAndSeek + +论文地址:[https://arxiv.org/pdf/1811.02545.pdf](https://arxiv.org/pdf/1811.02545.pdf) + +开源代码 github 地址:[https://github.com/kkanshul/Hide-and-Seek](https://github.com/kkanshul/Hide-and-Seek) + + +`HideAndSeek` 论文将图像分为若干块区域(patch),对于每块区域,都以一定的概率生成掩码,不同区域的掩码含义如下图所示。 + + +![][hide_and_seek_mask_expanation] + + +PaddleClas 中 `HideAndSeek` 的使用方法如下所示。 + + +经过 HideAndSeek 数据增强后结果如下图所示。 + +![][test_hideandseek] + + +#### 2.2.4 GridMask +论文地址:[https://arxiv.org/abs/2001.04086](https://arxiv.org/abs/2001.04086) + +开源代码 github 地址:[https://github.com/akuxcw/GridMask](https://github.com/akuxcw/GridMask) + + +作者在论文中指出,此前存在的基于对图像 crop 的方法存在两个问题,如下图所示: + +1. 过度删除区域可能造成目标主体大部分甚至全部被删除,或者导致上下文信息的丢失,导致增广后的数据成为噪声数据; +2. 保留过多的区域,对目标主体及上下文基本产生不了什么影响,失去增广的意义。 + +![][gridmask-0] + +因此如果避免过度删除或过度保留成为需要解决的核心问题。 + + +`GridMask` 是通过生成一个与原图分辨率相同的掩码,并将掩码进行随机翻转,与原图相乘,从而得到增广后的图像,通过超参数控制生成的掩码网格的大小。 + + +在训练过程中,有两种以下使用方法: +1. 设置一个概率 p,从训练开始就对图片以概率 p 使用 `GridMask` 进行增广。 +2. 一开始设置增广概率为 0,随着迭代轮数增加,对训练图片进行 `GridMask` 增广的概率逐渐增大,最后变为 p。 + +论文中验证上述第二种方法的训练效果更好一些。 + +经过 GridMask 数据增强后结果如下图所示。 + +![][test_gridmask] + + +### 2.3 图像混叠类 + +图像混叠主要对 `Batch` 后的数据进行混合,包括: + ++ Mixup ++ Cutmix + +前文所述的图像变换与图像裁剪都是针对单幅图像进行的操作,而图像混叠是对两幅图像进行融合,生成一幅图像,两种方法的主要区别为混叠的方式不太一样。 + +#### 2.3.1 Mixup + +论文地址:[https://arxiv.org/pdf/1710.09412.pdf](https://arxiv.org/pdf/1710.09412.pdf) + +开源代码 github 地址:[https://github.com/facebookresearch/mixup-cifar10](https://github.com/facebookresearch/mixup-cifar10) + +Mixup 是最先提出的图像混叠增广方案,其原理简单、方便实现,不仅在图像分类上,在目标检测上也取得了不错的效果。为了便于实现,通常只对一个 batch 内的数据进行混叠,在 `Cutmix` 中也是如此。 + +如下是 `imaug` 中的实现,需要指出的是,下述实现会出现对同一幅进行相加的情况,也就是最终得到的图和原图一样,随着 `batch-size` 的增加这种情况出现的概率也会逐渐减小。 + + +经过 Mixup 数据增强结果如下图所示。 + +![][test_mixup] + +#### 2.3.2 Cutmix + +论文地址:[https://arxiv.org/pdf/1905.04899v2.pdf](https://arxiv.org/pdf/1905.04899v2.pdf) + +开源代码 github 地址:[https://github.com/clovaai/CutMix-PyTorch](https://github.com/clovaai/CutMix-PyTorch) + +与 `Mixup` 直接对两幅图进行相加不一样,`Cutmix` 是从一幅图中随机裁剪出一个 `ROI`,然后覆盖当前图像中对应的区域,代码实现如下所示: + +经过 Cutmix 数据增强后结果如下图所示。 + +![][test_cutmix] + +关于数据增强相关的实战部分实参考[数据增强实战](../advanced_tutorials/DataAugmentation.md)。 + + +## 参考文献 + +[1] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123. + + +[2] Cubuk E D, Zoph B, Shlens J, et al. Randaugment: Practical automated data augmentation with a reduced search space[J]. arXiv preprint arXiv:1909.13719, 2019. + +[3] DeVries T, Taylor G W. Improved regularization of convolutional neural networks with cutout[J]. arXiv preprint arXiv:1708.04552, 2017. + +[4] Zhong Z, Zheng L, Kang G, et al. Random erasing data augmentation[J]. arXiv preprint arXiv:1708.04896, 2017. + +[5] Singh K K, Lee Y J. Hide-and-seek: Forcing a network to be meticulous for weakly-supervised object and action localization[C]//2017 IEEE international conference on computer vision (ICCV). IEEE, 2017: 3544-3553. + +[6] Chen P. GridMask Data Augmentation[J]. arXiv preprint arXiv:2001.04086, 2020. + +[7] Zhang H, Cisse M, Dauphin Y N, et al. mixup: Beyond empirical risk minimization[J]. arXiv preprint arXiv:1710.09412, 2017. + +[8] Yun S, Han D, Oh S J, et al. Cutmix: Regularization strategy to train strong classifiers with localizable features[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 6023-6032. + + + +[test_baseline]: ../../images/image_aug/test_baseline.jpeg +[test_autoaugment]: ../../images/image_aug/test_autoaugment.jpeg +[test_cutout]: ../../images/image_aug/test_cutout.jpeg +[test_gridmask]: ../../images/image_aug/test_gridmask.jpeg +[gridmask-0]: ../../images/image_aug/gridmask-0.png +[test_hideandseek]: ../../images/image_aug/test_hideandseek.jpeg +[test_randaugment]: ../../images/image_aug/test_randaugment.jpeg +[test_randomerassing]: ../../images/image_aug/test_randomerassing.jpeg +[hide_and_seek_mask_expanation]: ../../images/image_aug/hide-and-seek-visual.png +[test_mixup]: ../../images/image_aug/test_mixup.png +[test_cutmix]: ../../images/image_aug/test_cutmix.png diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/ImageNet_models.md b/src/PaddleClas/docs/zh_CN/algorithm_introduction/ImageNet_models.md new file mode 100644 index 0000000..a61d882 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/ImageNet_models.md @@ -0,0 +1,599 @@ + + + +# ImageNet 预训练模型库 + +## 目录 + +- [1. 模型库概览图](#1) +- [2. SSLD 知识蒸馏预训练模型](#2) + - [2.1 服务器端知识蒸馏模型](#2.1) + - [2.2 移动端知识蒸馏模型](#2.2) + - [2.3 Intel CPU 端知识蒸馏模型](#2.3) +- [3. PP-LCNet 系列](#3) +- [4. ResNet 系列](#4) +- [5. 移动端系列](#5) +- [6. SEResNeXt 与 Res2Net 系列](#6) +- [7. DPN 与 DenseNet 系列](#7) +- [8. HRNet 系列](#8) +- [9. Inception 系列](#9) +- [10. EfficientNet 与 ResNeXt101_wsl 系列](#10) +- [11. ResNeSt 与 RegNet 系列](#11) +- [12. ViT_and_DeiT 系列](#12) +- [13. RepVGG 系列](#13) +- [14. MixNet 系列](#14) +- [15. ReXNet 系列](#15) +- [16. SwinTransformer 系列](#16) +- [17. LeViT 系列](#17) +- [18. Twins 系列](#18) +- [19. HarDNet 系列](#19) +- [20. DLA 系列](#20) +- [21. RedNet 系列](#21) +- [22. TNT 系列](#22) +- [23. 其他模型](#23) +- [参考文献](#reference) + + + +## 1. 模型库概览图 + +基于 ImageNet1k 分类数据集,PaddleClas 支持 37 个系列分类网络结构以及对应的 217 个图像分类预训练模型,训练技巧、每个系列网络结构的简单介绍和性能评估将在相应章节展现,下面所有的速度指标评估环境如下: +* Arm CPU 的评估环境基于骁龙 855(SD855)。 +* Intel CPU 的评估环境基于 Intel(R) Xeon(R) Gold 6148。 +* GPU 评估环境基于 V100 机器,在 FP32+TensorRT 配置下运行 2100 次测得(去除前 100 次的 warmup 时间)。 +* FLOPs 与 Params 通过 `paddle.flops()` 计算得到(PaddlePaddle 版本为 2.2) + +常见服务器端模型的精度指标与其预测耗时的变化曲线如下图所示。 + +![](../../images/models/V100_benchmark/v100.fp32.bs1.main_fps_top1_s.png) + +常见移动端模型的精度指标与其预测耗时的变化曲线如下图所示。 + +![](../../images/models/mobile_arm_top1.png) + +部分VisionTransformer模型的精度指标与其预测耗时的变化曲线如下图所示. + +![](../../images/models/V100_benchmark/v100.fp32.bs1.visiontransformer.png) + + + +## 2. SSLD 知识蒸馏预训练模型 +基于 SSLD 知识蒸馏的预训练模型列表如下所示,更多关于 SSLD 知识蒸馏方案的介绍可以参考:[SSLD 知识蒸馏文档](./knowledge_distillation.md)。 + + + +### 2.1 服务器端知识蒸馏模型 + +| 模型 | Top-1 Acc | Reference
Top-1 Acc | Acc gain | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|---------------------|-----------|-----------|---------------|----------------|-----------|----------|-----------|-----------------------------------|-----------------------------------|-----------------------------------| +| ResNet34_vd_ssld | 0.797 | 0.760 | 0.037 | 2.00 | 3.28 | 5.84 | 3.93 | 21.84 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_ssld_pretrained.pdparams)   | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_vd_ssld_infer.tar)   | +| ResNet50_vd_ssld | 0.830 | 0.792 | 0.039 | 2.60 | 4.86 | 7.63 | 4.35 | 25.63 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_ssld_infer.tar) | +| ResNet101_vd_ssld | 0.837 | 0.802 | 0.035 | 4.43 | 8.25 | 12.60 | 8.08 | 44.67 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_vd_ssld_infer.tar) | +| Res2Net50_vd_26w_4s_ssld | 0.831 | 0.798 | 0.033 | 3.59 | 6.35 | 9.50 | 4.28 | 25.76 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_vd_26w_4s_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_vd_26w_4s_ssld_infer.tar) | +| Res2Net101_vd_
26w_4s_ssld | 0.839 | 0.806 | 0.033 | 6.34 | 11.02 | 16.13 | 8.35 | 45.35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net101_vd_26w_4s_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net101_vd_26w_4s_ssld_infer.tar) | +| Res2Net200_vd_
26w_4s_ssld | 0.851 | 0.812 | 0.049 | 11.45 | 19.77 | 28.81 | 15.77 | 76.44 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net200_vd_26w_4s_ssld_infer.tar) | +| HRNet_W18_C_ssld | 0.812 | 0.769 | 0.043 | 6.66 | 8.94 | 11.95 | 4.32 | 21.35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W18_C_ssld_infer.tar) | +| HRNet_W48_C_ssld | 0.836 | 0.790 | 0.046 | 11.07 | 17.06 | 27.28 | 17.34 | 77.57 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W48_C_ssld_infer.tar) | +| SE_HRNet_W64_C_ssld | 0.848 | - | - | 17.11 | 26.87 | 43.24 | 29.00 | 129.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/SE_HRNet_W64_C_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_HRNet_W64_C_ssld_infer.tar) | + + + +### 2.2 移动端知识蒸馏模型 + +| 模型 | Top-1 Acc | Reference
Top-1 Acc | Acc gain | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | FLOPs(M) | Params(M) | 模型大小(M) | 预训练模型下载地址 | inference模型下载地址 | +|---------------------|-----------|-----------|---------------|----------------|-----------|----------|-----------|-----------------------------------|-----------------------------------|-----------------------------------|-----------------------------------| +| MobileNetV1_ssld | 0.779 | 0.710 | 0.069 | 30.24 | 17.86 | 10.30 | 578.88 | 4.25 | 16 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_ssld_infer.tar) | +| MobileNetV2_ssld | 0.767 | 0.722 | 0.045 | 20.74 | 12.71 | 8.10 | 327.84 | 3.54 | 14 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_ssld_infer.tar) | +| MobileNetV3_small_x0_35_ssld | 0.556 | 0.530 | 0.026 | 2.23 | 1.66 | 1.43 | 14.56 | 1.67 | 6.9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_35_ssld_infer.tar) | +| MobileNetV3_large_x1_0_ssld | 0.790 | 0.753 | 0.036 | 16.55 | 10.09 | 6.84 | 229.66 | 5.50 | 21 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_ssld_infer.tar) | +| MobileNetV3_small_x1_0_ssld | 0.713 | 0.682 | 0.031 | 5.63 | 3.65 | 2.60 | 63.67 | 2.95 | 12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_0_ssld_infer.tar) | +| GhostNet_x1_3_ssld | 0.794 | 0.757 | 0.037 | 19.16 | 12.25 | 9.40 | 236.89 | 7.38 | 29 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_3_ssld_infer.tar) | + + + +### 2.3 Intel CPU 端知识蒸馏模型 + +| 模型 | Top-1 Acc | Reference
Top-1 Acc | Acc gain | Intel-Xeon-Gold-6148 time(ms)
bs=1 | FLOPs(M) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|---------------------|-----------|-----------|---------------|----------------|----------|-----------|-----------------------------------|-----------------------------------| +| PPLCNet_x0_5_ssld | 0.661 | 0.631 | 0.030 | 2.05 | 47.28 | 1.89 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_5_ssld_infer.tar) | +| PPLCNet_x1_0_ssld | 0.744 | 0.713 | 0.033 | 2.46 | 160.81 | 2.96 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_0_ssld_infer.tar) | +| PPLCNet_x2_5_ssld | 0.808 | 0.766 | 0.042 | 5.39 | 906.49 | 9.04 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x2_5_ssld_infer.tar) | + +* 注: `Reference Top-1 Acc` 表示 PaddleClas 基于 ImageNet1k 数据集训练得到的预训练模型精度。 + + + +## 3. PP-LCNet 系列 [[28](#ref28)] + +PP-LCNet 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[PP-LCNet 系列模型文档](../models/PP-LCNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | Intel-Xeon-Gold-6148 time(ms)
bs=1 | FLOPs(M) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|:--:|:--:|:--:|:--:|----|----|----|:--:| +| PPLCNet_x0_25 |0.5186 | 0.7565 | 1.61785 | 18.25 | 1.52 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_25_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_25_infer.tar) | +| PPLCNet_x0_35 |0.5809 | 0.8083 | 2.11344 | 29.46 | 1.65 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_35_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_35_infer.tar) | +| PPLCNet_x0_5 |0.6314 | 0.8466 | 2.72974 | 47.28 | 1.89 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_5_infer.tar) | +| PPLCNet_x0_75 |0.6818 | 0.8830 | 4.51216 | 98.82 | 2.37 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_75_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x0_75_infer.tar) | +| PPLCNet_x1_0 |0.7132 | 0.9003 | 6.49276 | 160.81 | 2.96 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_0_infer.tar) | +| PPLCNet_x1_5 |0.7371 | 0.9153 | 12.2601 | 341.86 | 4.52 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_5_infer.tar) | +| PPLCNet_x2_0 |0.7518 | 0.9227 | 20.1667 | 590 | 6.54 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x2_0_infer.tar) | +| PPLCNet_x2_5 |0.7660 | 0.9300 | 29.595 | 906 | 9.04 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x2_5_infer.tar) | + + + +## 4. ResNet 系列 [[1](#ref1)] + +ResNet 及其 Vd 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[ResNet 及其 Vd 系列模型文档](../models/ResNet_and_vd.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|---------------------|-----------|-----------|-----------------------|----------------------|----------|-----------|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------| +| ResNet18 | 0.7098 | 0.8992 | 1.22 | 2.19 | 3.63 | 1.83 | 11.70 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet18_infer.tar) | +| ResNet18_vd | 0.7226 | 0.9080 | 1.26 | 2.28 | 3.89 | 2.07 | 11.72 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet18_vd_infer.tar) | +| ResNet34 | 0.7457 | 0.9214 | 1.97 | 3.25 | 5.70 | 3.68 | 21.81 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_infer.tar) | +| ResNet34_vd | 0.7598 | 0.9298 | 2.00 | 3.28 | 5.84 | 3.93 | 21.84 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_vd_infer.tar) | +| ResNet34_vd_ssld | 0.7972 | 0.9490 | 2.00 | 3.28 | 5.84 | 3.93 | 21.84 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet34_vd_ssld_infer.tar) | +| ResNet50 | 0.7650 | 0.9300 | 2.54 | 4.79 | 7.40 | 4.11 | 25.61 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_infer.tar) | +| ResNet50_vc | 0.7835 | 0.9403 | 2.57 | 4.83 | 7.52 | 4.35 | 25.63 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vc_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vc_infer.tar) | +| ResNet50_vd | 0.7912 | 0.9444 | 2.60 | 4.86 | 7.63 | 4.35 | 25.63 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar) | +| ResNet101 | 0.7756 | 0.9364 | 4.37 | 8.18 | 12.38 | 7.83 | 44.65 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_infer.tar) | +| ResNet101_vd | 0.8017 | 0.9497 | 4.43 | 8.25 | 12.60 | 8.08 | 44.67 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_vd_infer.tar) | +| ResNet152 | 0.7826 | 0.9396 | 6.05 | 11.41 | 17.33 | 11.56 | 60.34 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet152_infer.tar) | +| ResNet152_vd | 0.8059 | 0.9530 | 6.11 | 11.51 | 17.59 | 11.80 | 60.36 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet152_vd_infer.tar) | +| ResNet200_vd | 0.8093 | 0.9533 | 7.70 | 14.57 | 22.16 | 15.30 | 74.93 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet200_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet200_vd_infer.tar) | +| ResNet50_vd_
ssld | 0.8300 | 0.9640 | 2.60 | 4.86 | 7.63 | 4.35 | 25.63 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_ssld_infer.tar) | +| ResNet101_vd_
ssld | 0.8373 | 0.9669 | 4.43 | 8.25 | 12.60 | 8.08 | 44.67 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet101_vd_ssld_infer.tar) | + + + +## 5. 移动端系列 [[3](#ref3)][[4](#ref4)][[5](#ref5)][[6](#ref6)][[23](#ref23)] + +移动端系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[移动端系列模型文档](../models/Mobile.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | FLOPs(M) | Params(M) | 模型大小(M) | 预训练模型下载地址 | inference模型下载地址 | +|----------------------------------|-----------|-----------|------------------------|----------|-----------|---------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| MobileNetV1_
x0_25 | 0.5143 | 0.7546 | 2.88 | 1.82 | 1.26 | 43.56 | 0.48 | 1.9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_25_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_x0_25_infer.tar) | +| MobileNetV1_
x0_5 | 0.6352 | 0.8473 | 8.74 | 5.26 | 3.09 | 154.57 | 1.34 | 5.2 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_x0_5_infer.tar) | +| MobileNetV1_
x0_75 | 0.6881 | 0.8823 | 17.84 | 10.61 | 6.21 | 333.00 | 2.60 | 10 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_75_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_x0_75_infer.tar) | +| MobileNetV1 | 0.7099 | 0.8968 | 30.24 | 17.86 | 10.30 | 578.88 | 4.25 | 16 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_infer.tar) | +| MobileNetV1_
ssld | 0.7789 | 0.9394 | 30.24 | 17.86 | 10.30 | 578.88 | 4.25 | 16 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV1_ssld_infer.tar) | +| MobileNetV2_
x0_25 | 0.5321 | 0.7652 | 3.46 | 2.51 | 2.03 | 34.18 | 1.53 | 6.1 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_25_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x0_25_infer.tar) | +| MobileNetV2_
x0_5 | 0.6503 | 0.8572 | 7.69 | 4.92 | 3.57 | 99.48 | 1.98 | 7.8 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x0_5_infer.tar) | +| MobileNetV2_
x0_75 | 0.6983 | 0.8901 | 13.69 | 8.60 | 5.82 | 197.37 | 2.65 | 10 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_75_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x0_75_infer.tar) | +| MobileNetV2 | 0.7215 | 0.9065 | 20.74 | 12.71 | 8.10 | 327.84 | 3.54 | 14 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_infer.tar) | +| MobileNetV2_
x1_5 | 0.7412 | 0.9167 | 40.79 | 24.49 | 15.50 | 702.35 | 6.90 | 26 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x1_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x1_5_infer.tar) | +| MobileNetV2_
x2_0 | 0.7523 | 0.9258 | 67.50 | 40.03 | 25.55 | 1217.25 | 11.33 | 43 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x2_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_x2_0_infer.tar) | +| MobileNetV2_
ssld | 0.7674 | 0.9339 | 20.74 | 12.71 | 8.10 | 327.84 | 3.54 | 14 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV2_ssld_infer.tar) | +| MobileNetV3_
large_x1_25 | 0.7641 | 0.9295 | 24.52 | 14.76 | 9.89 | 362.70 | 7.47 | 29 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_25_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_25_infer.tar) | +| MobileNetV3_
large_x1_0 | 0.7532 | 0.9231 | 16.55 | 10.09 | 6.84 | 229.66 | 5.50 | 21 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_infer.tar) | +| MobileNetV3_
large_x0_75 | 0.7314 | 0.9108 | 11.53 | 7.06 | 4.94 | 151.70 | 3.93 | 16 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_75_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x0_75_infer.tar) | +| MobileNetV3_
large_x0_5 | 0.6924 | 0.8852 | 6.50 | 4.22 | 3.15 | 71.83 | 2.69 | 11 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x0_5_infer.tar) | +| MobileNetV3_
large_x0_35 | 0.6432 | 0.8546 | 4.43 | 3.11 | 2.41 | 40.90 | 2.11 | 8.6 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_35_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x0_35_infer.tar) | +| MobileNetV3_
small_x1_25 | 0.7067 | 0.8951 | 7.88 | 4.91 | 3.45 | 100.07 | 3.64 | 14 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_25_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_25_infer.tar) | +| MobileNetV3_
small_x1_0 | 0.6824 | 0.8806 | 5.63 | 3.65 | 2.60 | 63.67 | 2.95 | 12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_0_infer.tar) | +| MobileNetV3_
small_x0_75 | 0.6602 | 0.8633 | 4.50 | 2.96 | 2.19 | 46.02 | 2.38 | 9.6 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_75_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_75_infer.tar) | +| MobileNetV3_
small_x0_5 | 0.5921 | 0.8152 | 2.89 | 2.04 | 1.62 | 22.60 | 1.91 | 7.8 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_5_infer.tar) | +| MobileNetV3_
small_x0_35 | 0.5303 | 0.7637 | 2.23 | 1.66 | 1.43 | 14.56 | 1.67 | 6.9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_35_infer.tar) | +| MobileNetV3_
small_x0_35_ssld | 0.5555 | 0.7771 | 2.23 | 1.66 | 1.43 | 14.56 | 1.67 | 6.9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x0_35_ssld_infer.tar) | +| MobileNetV3_
large_x1_0_ssld | 0.7896 | 0.9448 | 16.55 | 10.09 | 6.84 | 229.66 | 5.50 | 21 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_ssld_infer.tar) | +| MobileNetV3_small_
x1_0_ssld | 0.7129 | 0.9010 | 5.63 | 3.65 | 2.60 | 63.67 | 2.95 | 12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_small_x1_0_ssld_infer.tar) | +| ShuffleNetV2 | 0.6880 | 0.8845 | 9.72 | 5.97 | 4.13 | 148.86 | 2.29 | 9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x1_0_infer.tar) | +| ShuffleNetV2_
x0_25 | 0.4990 | 0.7379 | 1.94 | 1.53 | 1.43 | 18.95 | 0.61 | 2.7 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_25_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x0_25_infer.tar) | +| ShuffleNetV2_
x0_33 | 0.5373 | 0.7705 | 2.23 | 1.70 | 1.79 | 24.04 | 0.65 | 2.8 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_33_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x0_33_infer.tar) | +| ShuffleNetV2_
x0_5 | 0.6032 | 0.8226 | 3.67 | 2.63 | 2.06 | 42.58 | 1.37 | 5.6 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x0_5_infer.tar) | +| ShuffleNetV2_
x1_5 | 0.7163 | 0.9015 | 17.21 | 10.56 | 6.81 | 301.35 | 3.53 | 14 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x1_5_infer.tar) | +| ShuffleNetV2_
x2_0 | 0.7315 | 0.9120 | 31.21 | 18.98 | 11.65 | 571.70 | 7.40 | 28 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x2_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_x2_0_infer.tar) | +| ShuffleNetV2_
swish | 0.7003 | 0.8917 | 31.21 | 9.06 | 5.74 | 148.86 | 2.29 | 9.1 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_swish_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ShuffleNetV2_swish_infer.tar) | +| GhostNet_
x0_5 | 0.6688 | 0.8695 | 5.28 | 3.95 | 3.29 | 46.15 | 2.60 | 10 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x0_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x0_5_infer.tar) | +| GhostNet_
x1_0 | 0.7402 | 0.9165 | 12.89 | 8.66 | 6.72 | 148.78 | 5.21 | 20 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_0_infer.tar) | +| GhostNet_
x1_3 | 0.7579 | 0.9254 | 19.16 | 12.25 | 9.40 | 236.89 | 7.38 | 29 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_3_infer.tar) | +| GhostNet_
x1_3_ssld | 0.7938 | 0.9449 | 19.16 | 12.25 | 9.40 | 236.89 | 7.38 | 29 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GhostNet_x1_3_ssld_infer.tar) | +| ESNet_x0_25 | 0.6248 | 0.8346 |4.12|2.97|2.51| 30.85 | 2.83 | 11 |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_25_pretrained.pdparams) |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x0_25_infer.tar) | +| ESNet_x0_5 | 0.6882 | 0.8804 |6.45|4.42|3.35| 67.31 | 3.25 | 13 |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_5_pretrained.pdparams) |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x0_5_infer.tar) | +| ESNet_x0_75 | 0.7224 | 0.9045 |9.59|6.28|4.52| 123.74 | 3.87 | 15 |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_75_pretrained.pdparams) |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x0_75_infer.tar) | +| ESNet_x1_0 | 0.7392 | 0.9140 |13.67|8.71|5.97| 197.33 | 4.64 | 18 |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x1_0_pretrained.pdparams) |[下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ESNet_x1_0_infer.tar) | + + + +## 6. SEResNeXt 与 Res2Net 系列 [[7](#ref7)][[8](#ref8)][[9](#ref9)] + +SEResNeXt 与 Res2Net 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[SEResNeXt 与 Res2Net 系列模型文档](../models/SEResNext_and_Res2Net.md)。 + + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|---------------------------|-----------|-----------|-----------------------|----------------------|----------|-----------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| Res2Net50_
26w_4s | 0.7933 | 0.9457 | 3.52 | 6.23 | 9.30 | 4.28 | 25.76 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_26w_4s_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_26w_4s_infer.tar) | +| Res2Net50_vd_
26w_4s | 0.7975 | 0.9491 | 3.59 | 6.35 | 9.50 | 4.52 | 25.78 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_vd_26w_4s_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_vd_26w_4s_infer.tar) | +| Res2Net50_
14w_8s | 0.7946 | 0.9470 | 4.39 | 7.21 | 10.38 | 4.20 | 25.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_14w_8s_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net50_14w_8s_infer.tar) | +| Res2Net101_vd_
26w_4s | 0.8064 | 0.9522 | 6.34 | 11.02 | 16.13 | 8.35 | 45.35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net101_vd_26w_4s_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net101_vd_26w_4s_infer.tar) | +| Res2Net200_vd_
26w_4s | 0.8121 | 0.9571 | 11.45 | 19.77 | 28.81 | 15.77 | 76.44 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net200_vd_26w_4s_infer.tar) | +| Res2Net200_vd_
26w_4s_ssld | 0.8513 | 0.9742 | 11.45 | 19.77 | 28.81 | 15.77 | 76.44 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Res2Net200_vd_26w_4s_ssld_infer.tar) | +| ResNeXt50_
32x4d | 0.7775 | 0.9382 | 5.07 | 8.49 | 12.02 | 4.26 | 25.10 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_32x4d_infer.tar) | +| ResNeXt50_vd_
32x4d | 0.7956 | 0.9462 | 5.29 | 8.68 | 12.33 | 4.50 | 25.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_vd_32x4d_infer.tar) | +| ResNeXt50_
64x4d | 0.7843 | 0.9413 | 9.39 | 13.97 | 20.56 | 8.02 | 45.29 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_64x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_64x4d_infer.tar) | +| ResNeXt50_vd_
64x4d | 0.8012 | 0.9486 | 9.75 | 14.14 | 20.84 | 8.26 | 45.31 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_64x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt50_vd_64x4d_infer.tar) | +| ResNeXt101_
32x4d | 0.7865 | 0.9419 | 11.34 | 16.78 | 22.80 | 8.01 | 44.32 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x4d_infer.tar) | +| ResNeXt101_vd_
32x4d | 0.8033 | 0.9512 | 11.36 | 17.01 | 23.07 | 8.25 | 44.33 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_vd_32x4d_infer.tar) | +| ResNeXt101_
64x4d | 0.7835 | 0.9452 | 21.57 | 28.08 | 39.49 | 15.52 | 83.66 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_64x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_64x4d_infer.tar) | +| ResNeXt101_vd_
64x4d | 0.8078 | 0.9520 | 21.57 | 28.22 | 39.70 | 15.76 | 83.68 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_64x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_vd_64x4d_infer.tar) | +| ResNeXt152_
32x4d | 0.7898 | 0.9433 | 17.14 | 25.11 | 33.79 | 11.76 | 60.15 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_32x4d_infer.tar) | +| ResNeXt152_vd_
32x4d | 0.8072 | 0.9520 | 16.99 | 25.29 | 33.85 | 12.01 | 60.17 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_vd_32x4d_infer.tar) | +| ResNeXt152_
64x4d | 0.7951 | 0.9471 | 33.07 | 42.05 | 59.13 | 23.03 | 115.27 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_64x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_64x4d_infer.tar) | +| ResNeXt152_vd_
64x4d | 0.8108 | 0.9534 | 33.30 | 42.41 | 59.42 | 23.27 | 115.29 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_64x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt152_vd_64x4d_infer.tar) | +| SE_ResNet18_vd | 0.7333 | 0.9138 | 1.48 | 2.70 | 4.32 | 2.07 | 11.81 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet18_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNet18_vd_infer.tar) | +| SE_ResNet34_vd | 0.7651 | 0.9320 | 2.42 | 3.69 | 6.29 | 3.93 | 22.00 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet34_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNet34_vd_infer.tar) | +| SE_ResNet50_vd | 0.7952 | 0.9475 | 3.11 | 5.99 | 9.34 | 4.36 | 28.16 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet50_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNet50_vd_infer.tar) | +| SE_ResNeXt50_
32x4d | 0.7844 | 0.9396 | 6.39 | 11.01 | 14.94 | 4.27 | 27.63 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNeXt50_32x4d_infer.tar) | +| SE_ResNeXt50_vd_
32x4d | 0.8024 | 0.9489 | 7.04 | 11.57 | 16.01 | 5.64 | 27.76 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_vd_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNeXt50_vd_32x4d_infer.tar) | +| SE_ResNeXt101_
32x4d | 0.7939 | 0.9443 | 13.31 | 21.85 | 28.77 | 8.03 | 49.09 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt101_32x4d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_ResNeXt101_32x4d_infer.tar) | +| SENet154_vd | 0.8140 | 0.9548 | 34.83 | 51.22 | 69.74 | 24.45 | 122.03 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SENet154_vd_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SENet154_vd_infer.tar) | + + + +## 7. DPN 与 DenseNet 系列 [[14](#ref14)][[15](#ref15)] + +DPN 与 DenseNet 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[DPN 与 DenseNet 系列模型文档](../models/DPN_DenseNet.md)。 + + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|-------------|-----------|-----------|-----------------------|----------------------|----------|-----------|--------------------------------------------------------------------------------------|-------------|-------------| +| DenseNet121 | 0.7566 | 0.9258 | 3.40 | 6.94 | 9.17 | 2.87 | 8.06 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet121_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet121_infer.tar) | +| DenseNet161 | 0.7857 | 0.9414 | 7.06 | 14.37 | 19.55 | 7.79 | 28.90 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet161_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet161_infer.tar) | +| DenseNet169 | 0.7681 | 0.9331 | 5.00 | 10.29 | 12.84 | 3.40 | 14.31 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet169_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet169_infer.tar) | +| DenseNet201 | 0.7763 | 0.9366 | 6.38 | 13.72 | 17.17 | 4.34 | 20.24 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet201_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet201_infer.tar) | +| DenseNet264 | 0.7796 | 0.9385 | 9.34 | 20.95 | 25.41 | 5.82 | 33.74 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet264_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DenseNet264_infer.tar) | +| DPN68 | 0.7678 | 0.9343 | 8.18 | 11.40 | 14.82 | 2.35 | 12.68 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN68_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN68_infer.tar) | +| DPN92 | 0.7985 | 0.9480 | 12.48 | 20.04 | 25.10 | 6.54 | 37.79 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN92_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN92_infer.tar) | +| DPN98 | 0.8059 | 0.9510 | 14.70 | 25.55 | 35.12 | 11.728 | 61.74 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN98_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN98_infer.tar) | +| DPN107 | 0.8089 | 0.9532 | 19.46 | 35.62 | 50.22 | 18.38 | 87.13 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN107_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN107_infer.tar) | +| DPN131 | 0.8070 | 0.9514 | 19.64 | 34.60 | 47.42 | 16.09 | 79.48 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN131_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DPN131_infer.tar) | + + + +## 8. HRNet 系列 [[13](#ref13)] + +HRNet 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[HRNet 系列模型文档](../models/HRNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|-------------|-----------|-----------|------------------|------------------|----------|-----------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------| +| HRNet_W18_C | 0.7692 | 0.9339 | 6.66 | 8.94 | 11.95 | 4.32 | 21.35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W18_C_infer.tar) | +| HRNet_W18_C_ssld | 0.81162 | 0.95804 | 6.66 | 8.94 | 11.95 | 4.32 | 21.35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W18_C_ssld_infer.tar) | +| HRNet_W30_C | 0.7804 | 0.9402 | 8.61 | 11.40 | 15.23 | 8.15 | 37.78 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W30_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W30_C_infer.tar) | +| HRNet_W32_C | 0.7828 | 0.9424 | 8.54 | 11.58 | 15.57 | 8.97 | 41.30 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W32_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W32_C_infer.tar) | +| HRNet_W40_C | 0.7877 | 0.9447 | 9.83 | 15.02 | 20.92 | 12.74 | 57.64 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W40_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W40_C_infer.tar) | +| HRNet_W44_C | 0.7900 | 0.9451 | 10.62 | 16.18 | 25.92 | 14.94 | 67.16 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W44_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W44_C_infer.tar) | +| HRNet_W48_C | 0.7895 | 0.9442 | 11.07 | 17.06 | 27.28 | 17.34 | 77.57 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W48_C_infer.tar) | +| HRNet_W48_C_ssld | 0.8363 | 0.9682 | 11.07 | 17.06 | 27.28 | 17.34 | 77.57 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W48_C_ssld_infer.tar) | +| HRNet_W64_C | 0.7930 | 0.9461 | 13.82 | 21.15 | 35.51 | 28.97 | 128.18 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W64_C_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HRNet_W64_C_infer.tar) | +| SE_HRNet_W64_C_ssld | 0.8475 | 0.9726 | 17.11 | 26.87 | 43.24 | 29.00 | 129.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/SE_HRNet_W64_C_ssld_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SE_HRNet_W64_C_ssld_infer.tar) | + + + +## 9. Inception 系列 [[10](#ref10)][[11](#ref11)][[12](#ref12)][[26](#ref26)] + +Inception 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[Inception 系列模型文档](../models/Inception.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|--------------------|-----------|-----------|-----------------------|----------------------|----------|-----------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| +| GoogLeNet | 0.7070 | 0.8966 | 1.41 | 3.25 | 5.00 | 1.44 | 11.54 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GoogLeNet_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/GoogLeNet_infer.tar) | +| Xception41 | 0.7930 | 0.9453 | 3.58 | 8.76 | 16.61 | 8.57 | 23.02 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception41_infer.tar) | +| Xception41_deeplab | 0.7955 | 0.9438 | 3.81 | 9.16 | 17.20 | 9.28 | 27.08 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_deeplab_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception41_deeplab_infer.tar) | +| Xception65 | 0.8100 | 0.9549 | 5.45 | 12.78 | 24.53 | 13.25 | 36.04 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception65_infer.tar) | +| Xception65_deeplab | 0.8032 | 0.9449 | 5.65 | 13.08 | 24.61 | 13.96 | 40.10 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_deeplab_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception65_deeplab_infer.tar) | +| Xception71 | 0.8111 | 0.9545 | 6.19 | 15.34 | 29.21 | 16.21 | 37.86 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception71_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Xception71_infer.tar) | +| InceptionV3 | 0.7914 | 0.9459 | 4.78 | 8.53 | 12.28 | 5.73 | 23.87 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/InceptionV3_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/InceptionV3_infer.tar) | +| InceptionV4 | 0.8077 | 0.9526 | 8.93 | 15.17 | 21.56 | 12.29 | 42.74 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/InceptionV4_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/InceptionV4_infer.tar) | + + + +## 10. EfficientNet 与 ResNeXt101_wsl 系列 [[16](#ref16)][[17](#ref17)] + +EfficientNet 与 ResNeXt101_wsl 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[EfficientNet 与 ResNeXt101_wsl 系列模型文档](../models/EfficientNet_and_ResNeXt101_wsl.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|---------------------------|-----------|-----------|------------------|------------------|----------|-----------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| ResNeXt101_
32x8d_wsl | 0.8255 | 0.9674 | 13.55 | 23.39 | 36.18 | 16.48 | 88.99 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x8d_wsl_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x8d_wsl_infer.tar) | +| ResNeXt101_
32x16d_wsl | 0.8424 | 0.9726 | 21.96 | 38.35 | 63.29 | 36.26 | 194.36 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x16d_wsl_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x16d_wsl_infer.tar) | +| ResNeXt101_
32x32d_wsl | 0.8497 | 0.9759 | 37.28 | 76.50 | 121.56 | 87.28 | 469.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x32d_wsl_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x32d_wsl_infer.tar) | +| ResNeXt101_
32x48d_wsl | 0.8537 | 0.9769 | 55.07 | 124.39 | 205.01 | 153.57 | 829.26 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x48d_wsl_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeXt101_32x48d_wsl_infer.tar) | +| Fix_ResNeXt101_
32x48d_wsl | 0.8626 | 0.9797 | 55.01 | 122.63 | 204.66 | 313.41 | 829.26 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Fix_ResNeXt101_32x48d_wsl_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/Fix_ResNeXt101_32x48d_wsl_infer.tar) | +| EfficientNetB0 | 0.7738 | 0.9331 | 1.96 | 3.71 | 5.56 | 0.40 | 5.33 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB0_infer.tar) | +| EfficientNetB1 | 0.7915 | 0.9441 | 2.88 | 5.40 | 7.63 | 0.71 | 7.86 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB1_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB1_infer.tar) | +| EfficientNetB2 | 0.7985 | 0.9474 | 3.26 | 6.20 | 9.17 | 1.02 | 9.18 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB2_infer.tar) | +| EfficientNetB3 | 0.8115 | 0.9541 | 4.52 | 8.85 | 13.54 | 1.88 | 12.324 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB3_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB3_infer.tar) | +| EfficientNetB4 | 0.8285 | 0.9623 | 6.78 | 15.47 | 24.95 | 4.51 | 19.47 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB4_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB4_infer.tar) | +| EfficientNetB5 | 0.8362 | 0.9672 | 10.97 | 27.24 | 45.93 | 10.51 | 30.56 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB5_infer.tar) | +| EfficientNetB6 | 0.8400 | 0.9688 | 17.09 | 43.32 | 76.90 | 19.47 | 43.27 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB6_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB6_infer.tar) | +| EfficientNetB7 | 0.8430 | 0.9689 | 25.91 | 71.23 | 128.20 | 38.45 | 66.66 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB7_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB7_infer.tar) | +| EfficientNetB0_
small | 0.7580 | 0.9258 | 1.24 | 2.59 | 3.92 | 0.40 | 4.69 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_small_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB0_small_infer.tar) | + + + +## 11. ResNeSt 与 RegNet 系列 [[24](#ref24)][[25](#ref25)] + +ResNeSt 与 RegNet 系列模型的精度、速度指标如下表所示,更多关于该系列的模型介绍可以参考:[ResNeSt 与 RegNet 系列模型文档](../models/ResNeSt_RegNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| ResNeSt50_
fast_1s1x64d | 0.8035 | 0.9528 | 2.73 | 5.33 | 8.24 | 4.36 | 26.27 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_fast_1s1x64d_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeSt50_fast_1s1x64d_infer.tar) | +| ResNeSt50 | 0.8083 | 0.9542 | 7.36 | 10.23 | 13.84 | 5.40 | 27.54 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNeSt50_infer.tar) | +| RegNetX_4GF | 0.785 | 0.9416 | 6.46 | 8.48 | 11.45 | 4.00 | 22.23 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetX_4GF_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RegNetX_4GF_infer.tar) | + + + +## 12. ViT_and_DeiT 系列 [[31](#ref31)][[32](#ref32)] + +ViT(Vision Transformer) 与 DeiT(Data-efficient Image Transformers)系列模型的精度、速度指标如下表所示. 更多关于该系列模型的介绍可以参考: [ViT_and_DeiT 系列模型文档](../models/ViT_and_DeiT.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|------------------------|-----------|-----------|------------------|------------------|----------|------------------------|------------------------|------------------------|------------------------| +| ViT_small_
patch16_224 | 0.7769 | 0.9342 | 3.71 | 9.05 | 16.72 | 9.41 | 48.60 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_small_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_small_patch16_224_infer.tar) | +| ViT_base_
patch16_224 | 0.8195 | 0.9617 | 6.12 | 14.84 | 28.51 | 16.85 | 86.42 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_base_patch16_224_infer.tar) | +| ViT_base_
patch16_384 | 0.8414 | 0.9717 | 14.15 | 48.38 | 95.06 | 49.35 | 86.42 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_base_patch16_384_infer.tar) | +| ViT_base_
patch32_384 | 0.8176 | 0.9613 | 4.94 | 13.43 | 24.08 | 12.66 | 88.19 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch32_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_base_patch32_384_infer.tar) | +| ViT_large_
patch16_224 | 0.8323 | 0.9650 | 15.53 | 49.50 | 94.09 | 59.65 | 304.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_large_patch16_224_infer.tar) | +|ViT_large_
patch16_384| 0.8513 | 0.9736 | 39.51 | 152.46 | 304.06 | 174.70 | 304.12 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_large_patch16_384_infer.tar) | +|ViT_large_
patch32_384| 0.8153 | 0.9608 | 11.44 | 36.09 | 70.63 | 44.24 | 306.48 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch32_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ViT_large_patch32_384_infer.tar) | + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|------------------------|-----------|-----------|------------------|------------------|----------|------------------------|------------------------|------------------------|------------------------| +| DeiT_tiny_
patch16_224 | 0.718 | 0.910 | 3.61 | 3.94 | 6.10 | 1.07 | 5.68 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_tiny_patch16_224_infer.tar) | +| DeiT_small_
patch16_224 | 0.796 | 0.949 | 3.61 | 6.24 | 10.49 | 4.24 | 21.97 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_small_patch16_224_infer.tar) | +| DeiT_base_
patch16_224 | 0.817 | 0.957 | 6.13 | 14.87 | 28.50 | 16.85 | 86.42 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_patch16_224_infer.tar) | +| DeiT_base_
patch16_384 | 0.830 | 0.962 | 14.12 | 48.80 | 97.60 | 49.35 | 86.42 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_patch16_384_infer.tar) | +| DeiT_tiny_
distilled_patch16_224 | 0.741 | 0.918 | 3.51 | 4.05 | 6.03 | 1.08 | 5.87 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_distilled_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_tiny_distilled_patch16_224_infer.tar) | +| DeiT_small_
distilled_patch16_224 | 0.809 | 0.953 | 3.70 | 6.20 | 10.53 | 4.26 | 22.36 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_distilled_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_small_distilled_patch16_224_infer.tar) | +| DeiT_base_
distilled_patch16_224 | 0.831 | 0.964 | 6.17 | 14.94 | 28.58 | 16.93 | 87.18 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_distilled_patch16_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_distilled_patch16_224_infer.tar) | +| DeiT_base_
distilled_patch16_384 | 0.851 | 0.973 | 14.12 | 48.76 | 97.09 | 49.43 | 87.18 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_distilled_patch16_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DeiT_base_distilled_patch16_384_infer.tar) | + + + +## 13. RepVGG 系列 [[36](#ref36)] + +关于 RepVGG 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[RepVGG 系列模型文档](../models/RepVGG.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| RepVGG_A0 | 0.7131 | 0.9016 | | | | 1.36 | 8.31 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_A0_infer.tar) | +| RepVGG_A1 | 0.7380 | 0.9146 | | | | 2.37 | 12.79 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A1_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_A1_infer.tar) | +| RepVGG_A2 | 0.7571 | 0.9264 | | | | 5.12 | 25.50 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_A2_infer.tar) | +| RepVGG_B0 | 0.7450 | 0.9213 | | | | 3.06 | 14.34 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B0_infer.tar) | +| RepVGG_B1 | 0.7773 | 0.9385 | | | | 11.82 | 51.83 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B1_infer.tar) | +| RepVGG_B2 | 0.7813 | 0.9410 | | | | 18.38 | 80.32 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B2_infer.tar) | +| RepVGG_B1g2 | 0.7732 | 0.9359 | | | | 8.82 | 41.36 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1g2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B1g2_infer.tar) | +| RepVGG_B1g4 | 0.7675 | 0.9335 | | | | 7.31 | 36.13 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1g4_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B1g4_infer.tar) | +| RepVGG_B2g4 | 0.7881 | 0.9448 | | | | 11.34 | 55.78 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B2g4_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B2g4_infer.tar) | +| RepVGG_B3g4 | 0.7965 | 0.9485 | | | | 16.07 | 75.63 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B3g4_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RepVGG_B3g4_infer.tar) | + + + +## 14. MixNet 系列 [[29](#ref29)] + +关于 MixNet 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[MixNet 系列模型文档](../models/MixNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(M) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| -------- | --------- | --------- | ---------------- | ---------------- | ----------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| MixNet_S | 0.7628 | 0.9299 | 2.31 | 3.63 | 5.20 | 252.977 | 4.167 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_S_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MixNet_S_infer.tar) | +| MixNet_M | 0.7767 | 0.9364 | 2.84 | 4.60 | 6.62 | 357.119 | 5.065 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_M_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MixNet_M_infer.tar) | +| MixNet_L | 0.7860 | 0.9437 | 3.16 | 5.55 | 8.03 | 579.017 | 7.384 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_L_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MixNet_L_infer.tar) | + + + +## 15. ReXNet 系列 [[30](#ref30)] + +关于 ReXNet 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[ReXNet 系列模型文档](../models/ReXNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| ReXNet_1_0 | 0.7746 | 0.9370 | 3.08 | 4.15 | 5.49 | 0.415 | 4.84 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_1_0_infer.tar) | +| ReXNet_1_3 | 0.7913 | 0.9464 | 3.54 | 4.87 | 6.54 | 0.68 | 7.61 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_3_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_1_3_infer.tar) | +| ReXNet_1_5 | 0.8006 | 0.9512 | 3.68 | 5.31 | 7.38 | 0.90 | 9.79 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_1_5_infer.tar) | +| ReXNet_2_0 | 0.8122 | 0.9536 | 4.30 | 6.54 | 9.19 | 1.56 | 16.45 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_2_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_2_0_infer.tar) | +| ReXNet_3_0 | 0.8209 | 0.9612 | 5.74 | 9.49 | 13.62 | 3.44 | 34.83 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_3_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ReXNet_3_0_infer.tar) | + + + +## 16. SwinTransformer 系列 [[27](#ref27)] + +关于 SwinTransformer 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[SwinTransformer 系列模型文档](../models/SwinTransformer.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| SwinTransformer_tiny_patch4_window7_224 | 0.8069 | 0.9534 | 6.59 | 9.68 | 16.32 | 4.35 | 28.26 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_tiny_patch4_window7_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_tiny_patch4_window7_224_infer.tar) | +| SwinTransformer_small_patch4_window7_224 | 0.8275 | 0.9613 | 12.54 | 17.07 | 28.08 | 8.51 | 49.56 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_small_patch4_window7_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_small_patch4_window7_224_infer.tar) | +| SwinTransformer_base_patch4_window7_224 | 0.8300 | 0.9626 | 13.37 | 23.53 | 39.11 | 15.13 | 87.70 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window7_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window7_224_infer.tar) | +| SwinTransformer_base_patch4_window12_384 | 0.8439 | 0.9693 | 19.52 | 64.56 | 123.30 | 44.45 | 87.70 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window12_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window12_384_infer.tar) | +| SwinTransformer_base_patch4_window7_224[1] | 0.8487 | 0.9746 | 13.53 | 23.46 | 39.13 | 15.13 | 87.70 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window7_224_22kto1k_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window7_224_infer.tar) | +| SwinTransformer_base_patch4_window12_384[1] | 0.8642 | 0.9807 | 19.65 | 64.72 | 123.42 | 44.45 | 87.70 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window12_384_22kto1k_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_base_patch4_window12_384_infer.tar) | +| SwinTransformer_large_patch4_window7_224[1] | 0.8596 | 0.9783 | 15.74 | 38.57 | 71.49 | 34.02 | 196.43 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window7_224_22kto1k_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_large_patch4_window7_224_22kto1k_infer.tar) | +| SwinTransformer_large_patch4_window12_384[1] | 0.8719 | 0.9823 | 32.61 | 116.59 | 223.23 | 99.97 | 196.43 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window12_384_22kto1k_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SwinTransformer_large_patch4_window12_384_22kto1k_infer.tar) | + +[1]:基于 ImageNet22k 数据集预训练,然后在 ImageNet1k 数据集迁移学习得到。 + + + +## 17. LeViT 系列 [[33](#ref33)] + +关于 LeViT 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[LeViT 系列模型文档](../models/LeViT.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(M) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| LeViT_128S | 0.7598 | 0.9269 | | | | 281 | 7.42 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128S_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_128S_infer.tar) | +| LeViT_128 | 0.7810 | 0.9371 | | | | 365 | 8.87 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_128_infer.tar) | +| LeViT_192 | 0.7934 | 0.9446 | | | | 597 | 10.61 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_192_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_192_infer.tar) | +| LeViT_256 | 0.8085 | 0.9497 | | | | 1049 | 18.45 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_256_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_256_infer.tar) | +| LeViT_384 | 0.8191 | 0.9551 | | | | 2234 | 38.45 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/LeViT_384_infer.tar) | + +**注**:与 Reference 的精度差异源于数据预处理不同及未使用蒸馏的 head 作为输出。 + + + +## 18. Twins 系列 [[34](#ref34)] + +关于 Twins 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[Twins 系列模型文档](../models/Twins.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| pcpvt_small | 0.8082 | 0.9552 | 7.32 | 10.51 | 15.27 |3.67 | 24.06 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_small_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/pcpvt_small_infer.tar) | +| pcpvt_base | 0.8242 | 0.9619 | 12.20 | 16.22 | 23.16 | 6.44 | 43.83 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_base_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/pcpvt_base_infer.tar) | +| pcpvt_large | 0.8273 | 0.9650 | 16.47 | 22.90 | 32.73 | 9.50 | 60.99 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_large_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/pcpvt_large_infer.tar) | +| alt_gvt_small | 0.8140 | 0.9546 | 6.94 | 9.01 | 12.27 |2.81 | 24.06 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_small_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/alt_gvt_small_infer.tar) | +| alt_gvt_base | 0.8294 | 0.9621 | 9.37 | 15.02 | 24.54 | 8.34 | 56.07 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_base_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/alt_gvt_base_infer.tar) | +| alt_gvt_large | 0.8331 | 0.9642 | 11.76 | 22.08 | 35.12 | 14.81 | 99.27 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_large_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/alt_gvt_large_infer.tar) | + +**注**:与 Reference 的精度差异源于数据预处理不同。 + + + +## 19. HarDNet 系列 [[37](#ref37)] + +关于 HarDNet 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[HarDNet 系列模型文档](../models/HarDNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| HarDNet39_ds | 0.7133 |0.8998 | 1.40 | 2.30 | 3.33 | 0.44 | 3.51 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet39_ds_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet39_ds_infer.tar) | +| HarDNet68_ds |0.7362 | 0.9152 | 2.26 | 3.34 | 5.06 | 0.79 | 4.20 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_ds_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet68_ds_infer.tar) | +| HarDNet68| 0.7546 | 0.9265 | 3.58 | 8.53 | 11.58 | 4.26 | 17.58 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet68_infer.tar) | +| HarDNet85 | 0.7744 | 0.9355 | 6.24 | 14.85 | 20.57 | 9.09 | 36.69 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet85_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/HarDNet85_infer.tar) | + + + +## 20. DLA 系列 [[38](#ref38)] + +关于 DLA 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[DLA 系列模型文档](../models/DLA.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| DLA102 | 0.7893 |0.9452 | 4.95 | 8.08 | 12.40 | 7.19 | 33.34 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA102_infer.tar) | +| DLA102x2 |0.7885 | 0.9445 | 19.58 | 23.97 | 31.37 | 9.34 | 41.42 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA102x2_infer.tar) | +| DLA102x| 0.781 | 0.9400 | 11.12 | 15.60 | 20.37 | 5.89 | 26.40 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA102x_infer.tar) | +| DLA169 | 0.7809 | 0.9409 | 7.70 | 12.25 | 18.90 | 11.59 | 53.50 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA169_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA169_infer.tar) | +| DLA34 | 0.7603 | 0.9298 | 1.83 | 3.37 | 5.98 | 3.07 | 15.76 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA34_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA34_infer.tar) | +| DLA46_c |0.6321 | 0.853 | 1.06 | 2.08 | 3.23 | 0.54 | 1.31 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA46_c_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA46_c_infer.tar) | +| DLA60 | 0.7610 | 0.9292 | 2.78 | 5.36 | 8.29 | 4.26 | 22.08 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA60_infer.tar) | +| DLA60x_c | 0.6645 | 0.8754 | 1.79 | 3.68 | 5.19 | 0.59 | 1.33 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_c_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA60x_c_infer.tar) | +| DLA60x | 0.7753 | 0.9378 | 5.98 | 9.24 | 12.52 | 3.54 | 17.41 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DLA60x_infer.tar) | + + + +## 21. RedNet 系列 [[39](#ref39)] + +关于 RedNet 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[RedNet 系列模型文档](../models/RedNet.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RedNet26 | 0.7595 |0.9319 | 4.45 | 15.16 | 29.03 | 1.69 | 9.26 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet26_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet26_infer.tar) | +| RedNet38 |0.7747 | 0.9356 | 6.24 | 21.39 | 41.26 | 2.14 | 12.43 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet38_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet38_infer.tar) | +| RedNet50| 0.7833 | 0.9417 | 8.04 | 27.71 | 53.73 | 2.61 | 15.60 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet50_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet50_infer.tar) | +| RedNet101 | 0.7894 | 0.9436 | 13.07 | 44.12 | 83.28 | 4.59 | 25.76 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet101_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet101_infer.tar) | +| RedNet152 | 0.7917 | 0.9440 | 18.66 | 63.27 | 119.48 | 6.57 | 34.14 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet152_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/RedNet152_infer.tar) | + + + +## 22. TNT 系列 [[35](#ref35)] + +关于 TNT 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[TNT 系列模型文档](../models/TNT.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| TNT_small | 0.8121 |0.9563 | | | 4.83 | 23.68 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/TNT_small_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/TNT_small_infer.tar) | + +**注**:TNT 模型的数据预处理部分 `NormalizeImage` 中的 `mean` 与 `std` 均为 0.5。 + + + +## 23. 其他模型 + +关于 AlexNet [[18](#ref18)]、SqueezeNet 系列 [[19](#ref19)]、VGG 系列 [[20](#ref20)]、DarkNet53 [[21](#ref21)] 等模型的精度、速度指标如下表所示,更多介绍可以参考:[其他模型文档](../models/Others.md)。 + +| 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 | +|------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| AlexNet | 0.567 | 0.792 | 0.81 | 1.50 | 2.33 | 0.71 | 61.10 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/AlexNet_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/AlexNet_infer.tar) | +| SqueezeNet1_0 | 0.596 | 0.817 | 0.68 | 1.64 | 2.62 | 0.78 | 1.25 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SqueezeNet1_0_infer.tar) | +| SqueezeNet1_1 | 0.601 | 0.819 | 0.62 | 1.30 | 2.09 | 0.35 | 1.24 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_1_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/SqueezeNet1_1_infer.tar) | +| VGG11 | 0.693 | 0.891 | 1.72 | 4.15 | 7.24 | 7.61 | 132.86 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG11_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG11_infer.tar) | +| VGG13 | 0.700 | 0.894 | 2.02 | 5.28 | 9.54 | 11.31 | 133.05 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG13_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG13_infer.tar) | +| VGG16 | 0.720 | 0.907 | 2.48 | 6.79 | 12.33 | 15.470 | 138.35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG16_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG16_infer.tar) | +| VGG19 | 0.726 | 0.909 | 2.93 | 8.28 | 15.21 | 19.63 | 143.66 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG19_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/VGG19_infer.tar) | +| DarkNet53 | 0.780 | 0.941 | 2.79 | 6.42 | 10.89 | 9.31 | 41.65 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DarkNet53_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/DarkNet53_infer.tar) | + + + +## 参考文献 + +[1] He K, Zhang X, Ren S, et al. Deep residual learning for image recognition[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2016: 770-778. + +[2] He T, Zhang Z, Zhang H, et al. Bag of tricks for image classification with convolutional neural networks[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2019: 558-567. + +[3] Howard A, Sandler M, Chu G, et al. Searching for mobilenetv3[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 1314-1324. + +[4] Sandler M, Howard A, Zhu M, et al. Mobilenetv2: Inverted residuals and linear bottlenecks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2018: 4510-4520. + +[5] Howard A G, Zhu M, Chen B, et al. Mobilenets: Efficient convolutional neural networks for mobile vision applications[J]. arXiv preprint arXiv:1704.04861, 2017. + +[6] Ma N, Zhang X, Zheng H T, et al. Shufflenet v2: Practical guidelines for efficient cnn architecture design[C]//Proceedings of the European Conference on Computer Vision (ECCV). 2018: 116-131. + +[7] Xie S, Girshick R, Dollár P, et al. Aggregated residual transformations for deep neural networks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 1492-1500. + +[8] Hu J, Shen L, Sun G. Squeeze-and-excitation networks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2018: 7132-7141. + +[9] Gao S, Cheng M M, Zhao K, et al. Res2net: A new multi-scale backbone architecture[J]. IEEE transactions on pattern analysis and machine intelligence, 2019. + +[10] Szegedy C, Liu W, Jia Y, et al. Going deeper with convolutions[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2015: 1-9. + +[11] Szegedy C, Ioffe S, Vanhoucke V, et al. Inception-v4, inception-resnet and the impact of residual connections on learning[C]//Thirty-first AAAI conference on artificial intelligence. 2017. + +[12] Chollet F. Xception: Deep learning with depthwise separable convolutions[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 1251-1258. + +[13] Wang J, Sun K, Cheng T, et al. Deep high-resolution representation learning for visual recognition[J]. arXiv preprint arXiv:1908.07919, 2019. + +[14] Chen Y, Li J, Xiao H, et al. Dual path networks[C]//Advances in neural information processing systems. 2017: 4467-4475. + +[15] Huang G, Liu Z, Van Der Maaten L, et al. Densely connected convolutional networks[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 4700-4708. + +[16] Tan M, Le Q V. Efficientnet: Rethinking model scaling for convolutional neural networks[J]. arXiv preprint arXiv:1905.11946, 2019. + +[17] Mahajan D, Girshick R, Ramanathan V, et al. Exploring the limits of weakly supervised pretraining[C]//Proceedings of the European Conference on Computer Vision (ECCV). 2018: 181-196. + +[18] Krizhevsky A, Sutskever I, Hinton G E. Imagenet classification with deep convolutional neural networks[C]//Advances in neural information processing systems. 2012: 1097-1105. + +[19] Iandola F N, Han S, Moskewicz M W, et al. SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and< 0.5 MB model size[J]. arXiv preprint arXiv:1602.07360, 2016. + +[20] Simonyan K, Zisserman A. Very deep convolutional networks for large-scale image recognition[J]. arXiv preprint arXiv:1409.1556, 2014. + +[21] Redmon J, Divvala S, Girshick R, et al. You only look once: Unified, real-time object detection[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2016: 779-788. + +[22] Ding X, Guo Y, Ding G, et al. Acnet: Strengthening the kernel skeletons for powerful cnn via asymmetric convolution blocks[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 1911-1920. + +[23] Han K, Wang Y, Tian Q, et al. GhostNet: More features from cheap operations[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2020: 1580-1589. + +[24] Zhang H, Wu C, Zhang Z, et al. Resnest: Split-attention networks[J]. arXiv preprint arXiv:2004.08955, 2020. + +[25] Radosavovic I, Kosaraju R P, Girshick R, et al. Designing network design spaces[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2020: 10428-10436. + +[26] C.Szegedy, V.Vanhoucke, S.Ioffe, J.Shlens, and Z.Wojna. Rethinking the inception architecture for computer vision. arXiv preprint arXiv:1512.00567, 2015. + +[27] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin and Baining Guo. Swin Transformer: Hierarchical Vision Transformer using Shifted Windows. + +[28]Cheng Cui, Tingquan Gao, Shengyu Wei, Yuning Du, Ruoyu Guo, Shuilong Dong, Bin Lu, Ying Zhou, Xueying Lv, Qiwen Liu, Xiaoguang Hu, Dianhai Yu, Yanjun Ma. PP-LCNet: A Lightweight CPU Convolutional Neural Network. + +[29]Mingxing Tan, Quoc V. Le. MixConv: Mixed Depthwise Convolutional Kernels. + +[30]Dongyoon Han, Sangdoo Yun, Byeongho Heo, YoungJoon Yoo. Rethinking Channel Dimensions for Efficient Model Design. + +[31]Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby. AN IMAGE IS WORTH 16X16 WORDS: +TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE. + +[32]Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, Herve Jegou. Training data-efficient image transformers & distillation through attention. + +[33]Benjamin Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Herve Jegou, Matthijs Douze. LeViT: a Vision Transformer in ConvNet’s Clothing for Faster Inference. + +[34]Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, Chunhua Shen. Twins: Revisiting the Design of Spatial Attention in Vision Transformers. + +[35]Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, Yunhe Wang. Transformer in Transformer. + +[36]Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, Jian Sun. RepVGG: Making VGG-style ConvNets Great Again. + +[37]Ping Chao, Chao-Yang Kao, Yu-Shan Ruan, Chien-Hsiang Huang, Youn-Long Lin. HarDNet: A Low Memory Traffic Network. + +[38]Fisher Yu, Dequan Wang, Evan Shelhamer, Trevor Darrell. Deep Layer Aggregation. + +[39]Duo Lim Jie Hu, Changhu Wang, Xiangtai Li, Qi She, Lei Zhu, Tong Zhang, Qifeng Chen. Involution: Inverting the Inherence of Convolution for Visual Recognition. diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/image_classification.md b/src/PaddleClas/docs/zh_CN/algorithm_introduction/image_classification.md new file mode 100644 index 0000000..b55aad0 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/image_classification.md @@ -0,0 +1,78 @@ +# 图像分类任务介绍 + + +## 目录 + + +- [1. 数据集介绍](#1) + - [1.1 ImageNet-1k](#1.1) + - [1.2 CIFAR-10/CIFAR-100](#1.2) +- [2. 图像分类的流程](#2) + - [2.1 数据及其预处理](#2.1) + - [2.2 模型准备](#2.2) + - [2.3 模型训练](#2.3) + - [2.4 模型评估](#2.4) +- [3. 主要算法简介](#3) + +图像分类是根据图像的语义信息将不同类别图像区分开来,是计算机视觉中重要的基本问题,也是图像检测、图像分割、物体跟踪、行为分析等其他高层视觉任务的基础。图像分类在很多领域有广泛应用,包括安防领域的人脸识别和智能视频分析等,交通领域的交通场景识别,互联网领域基于内容的图像检索和相册自动归类,医学领域的图像识别等。 + +一般来说,图像分类通过手工特征或特征学习方法对整个图像进行全部描述,然后使用分类器判别物体类别,因此如何提取图像的特征至关重要。在深度学习算法之前使用较多的是基于词袋(Bag of Words)模型的物体分类方法。而基于深度学习的图像分类方法,可以通过有监督或无监督的方式学习层次化的特征描述,从而取代了手工设计或选择图像特征的工作。深度学习模型中的卷积神经网络(Convolution Neural Network, CNN)近年来在图像领域取得了惊人的成绩,CNN 直接利用图像像素信息作为输入,最大程度上保留了输入图像的所有信息,通过卷积操作进行特征的提取和高层抽象,模型输出直接是图像识别的结果。这种基于"输入-输出"直接端到端的学习方法取得了非常好的效果,得到了广泛的应用。 + +图像分类是计算机视觉里很基础但又重要的一个领域,其研究成果一直影响着计算机视觉甚至深度学习的发展,图像分类有很多子领域,如多标签分类、细粒度分类等,此处只对单标签图像分类做一个简述。 + + +## 1. 数据集介绍 + + +### 1.1 ImageNet-1k + +ImageNet 项目是一个大型视觉数据库,用于视觉目标识别软件研究。该项目已手动注释了 1400 多万张图像,以指出图片中的对象,并在至少 100 万张图像中提供了边框。ImageNet-1k 是 ImageNet 数据集的子集,其包含 1000 个类别。训练集包含 1281167 个图像数据,验证集包含 50000 个图像数据。2010 年以来,ImageNet 项目每年举办一次图像分类竞赛,即 ImageNet 大规模视觉识别挑战赛(ILSVRC)。挑战赛使用的数据集即为 ImageNet-1k。到目前为止,ImageNet-1k 已经成为计算机视觉领域发展的最重要的数据集之一,其促进了整个计算机视觉的发展,很多计算机视觉下游任务的初始化模型都是基于该数据集训练得到的权重。 + + +### 1.2 CIFAR-10/CIFAR-100 + +CIFAR-10 数据集由 10 个类的 60000 个彩色图像组成,图像分辨率为 32x32,每个类有 6000 个图像,其中训练集 5000 张,验证集 1000 张,10 个不同的类代表飞机、汽车、鸟类、猫、鹿、狗、青蛙、马、轮船和卡车。CIFAR-100 数据集是 CIFAR-10 的扩展,由 100 个类的 60000 个彩色图像组成,图像分辨率为 32x32,每个类有 600 个图像,其中训练集 500 张,验证集 100 张。由于这两个数据集规模较小,因此可以让研究人员快速尝试不同的算法。这两个数据集也是图像分类领域测试模型好坏的常用数据集。 + + +## 2. 图像分类的流程 + +将准备好的训练数据做相应的数据预处理后经过图像分类模型,模型的输出与真实标签做交叉熵损失函数,该损失函数描述了模型的收敛方向,遍历所有的图片数据输入模型,对最终损失函数通过某些优化器做相应的梯度下降,将梯度信息回传到模型中,更新模型的权重,如此循环往复遍历多次数据,即可得到一个图像分类的模型。 + + +### 2.1 数据及其预处理 + +数据的质量及数量往往可以决定一个模型的好坏。在图像分类领域,数据包括图像及标签。在大部分情形下,带有标签的数据比较匮乏,所以数量很难达到使模型饱和的程度,为了可以使模型学习更多的图像特征,图像数据在进入模型之前要经过很多图像变换或者数据增强,来保证输入图像数据的多样性,从而保证模型有更好的泛化能力。PaddleClas 提供了训练 ImageNet-1k 的标准图像变换,也提供了 8 中数据增强的方法,相关代码可以[数据处理](../../../ppcls/data/preprocess),配置文件可以参考[数据增强配置文件](../../../ppcls/configs/ImageNet/DataAugment)。 + + +### 2.2 模型准备 + +在数据确定后,模型往往决定了最终算法精度的上限,在图像分类领域,经典的模型层出不穷,PaddleClas 提供了 36 个系列共 175 个 ImageNet 预训练模型。具体的精度、速度等指标请参考[骨干网络和预训练模型库](./ImageNet_models.md)。 + + +### 2.3 模型训练 + +在准备好数据、模型后,便可以开始迭代模型并更新模型的参数。经过多次迭代最终可以得到训练好的模型来做图像分类任务。图像分类的训练过程需要很多经验,涉及很多超参数的设置,PaddleClas 提供了一些列的[训练调优方法](../models_training/train_strategy.md),可以快速助你获得高精度的模型。 + + +### 2.4 模型评估 + +当训练得到一个模型之后,如何确定模型的好坏,需要将模型在验证集上进行评估。评估指标一般是 Top1-Acc 或者 Top5-Acc,该指标越高往往代表模型性能越好。 + + +## 3. 主要算法简介 + +- LeNet:Yan LeCun 等人于上个世纪九十年代第一次将卷积神经网络应用到图像分类任务上,创造性的提出了 LeNet,在手写数字识别任务上取得了巨大的成功。 + +- AlexNet:Alex Krizhevsky 等人在 2012 年提出了 AlexNet,并应用于 ImageNet 上,获得了 2012 年 ImageNet 分类比赛的冠军,从此,掀起了深度学习的热潮。 + +- VGG:Simonyan 和 Zisserman 于 2014 年提出了 VGG 网络结构,该网络结构使用了更小的卷积核堆叠整个网络,在 ImageNet 分类上取得了更好的性能,也为之后的网络结构设计提供了新的思路。 + +- GoogLeNet:Christian Szegedy 等人在 2014 年提出了 GoogLeNet,该网络使用了多分支结构和全局平均池化层(GAP),在保持模型精度的同时,模型存储和计算量大大缩减。该网络取得了 2014 年 ImageNet 分类比赛的冠军。 + +- ResNet:Kaiming He 等人在 2015 年提出了 ResNet,通过引入残差模块加深了网络的深度,最终该网络将 ImageNet 分类的识别错误率降低到了 3.6\%,首次超出正常人眼的识别精度。 + +- DenseNet:Huang Gao 等人在 2017 年提出了 DenseNet,该网络设计了一种更稠密连接的 block,在更小的参数量上获得了更高的性能。 + +- EfficientNet:Mingxing Tan 等人在 2019 年提出了 EfficientNet,该网络平衡了网络的宽度、网络的深度、以及输入图片的分辨率,在同样 FLOPS 与参数量的情况下,精度达到了 state-of-the-art 的效果。 + +关于更多的算法介绍,请参考[算法介绍](../models)。 diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/index.rst b/src/PaddleClas/docs/zh_CN/algorithm_introduction/index.rst new file mode 100644 index 0000000..aa56459 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/index.rst @@ -0,0 +1,12 @@ +算法介绍 +================================ + +.. toctree:: + :maxdepth: 2 + + image_classification.md + metric_learning.md + knowledge_distillation.md + model_prune_quantization.md + ImageNet_models.md + DataAugmentation.md diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/knowledge_distillation.md b/src/PaddleClas/docs/zh_CN/algorithm_introduction/knowledge_distillation.md new file mode 100644 index 0000000..5809219 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/knowledge_distillation.md @@ -0,0 +1,86 @@ +# 知识蒸馏 +--- +## 目录 + +* [1. 模型压缩和知识蒸馏方法简介](#1) +* [2. 知识蒸馏应用](#2) +* [3. 知识蒸馏算法介绍](#3) + * [3.1 Response based distillation](#3.1) + * [3.2 Feature based distillation](#3.2) + * [3.3 Relation based distillation](#3.3) +* [4. 参考文献](#4) + +## 1. 模型压缩和知识蒸馏方法简介 + +近年来,深度神经网络在计算机视觉、自然语言处理等领域被验证是一种极其有效的解决问题的方法。通过构建合适的神经网络,加以训练,最终网络模型的性能指标基本上都会超过传统算法。 + +在数据量足够大的情况下,通过合理构建网络模型的方式增加其参数量,可以显著改善模型性能,但是这又带来了模型复杂度急剧提升的问题。大模型在实际场景中使用的成本较高。 + +深度神经网络一般有较多的参数冗余,目前有几种主要的方法对模型进行压缩,减小其参数量。如裁剪、量化、知识蒸馏等,其中知识蒸馏是指使用教师模型(teacher model)去指导学生模型(student model)学习特定任务,保证小模型在参数量不变的情况下,得到比较大的性能提升,甚至获得与大模型相似的精度指标 [1]。 + +目前知识蒸馏的方法大致可以分为以下三种。 + +* Response based distillation:教师模型对学生模型的输出进行监督。 +* Feature based distillation:教师模型对学生模型的中间层 feature map 进行监督。 +* Relation based distillation:对于不同的样本,使用教师模型和学生模型同时计算样本之间 feature map 的相关性,使得学生模型和教师模型得到的相关性矩阵尽可能一致。 + + +## 2. 知识蒸馏应用 + + +知识蒸馏算法在模型轻量化过程任务中应用广泛,对于需要满足特定的精度的任务,通过使用知识蒸馏的方法,我们可以使用更小的模型便能达到要求的精度,从而减小了模型部署的成本。 + +此外,对于相同的模型结构,使用知识蒸馏训练得到的预训练模型精度往往更高,这些预训练模型往往也可以提升下游任务的模型精度。比如在图像分类任务中,基于知识蒸馏算法得到的精度更高的预训练模型,也能够在目标检测、图像分割、OCR、视频分类等任务中获得明显的精度收益。 + + + +## 3. 知识蒸馏算法介绍 + +### 3.1 Response based distillation + +最早的知识蒸馏算法 KD,由 Hinton 提出,训练的损失函数中除了 gt loss 之外,还引入了学生模型与教师模型输出的 KL 散度,最终精度超过单纯使用 gt loss 训练的精度。这里需要注意的是,在训练的时候,需要首先训练得到一个更大的教师模型,来指导学生模型的训练过程。 + +PaddleClas 中提出了一种简单使用的 SSLD 知识蒸馏算法 [6],在训练的时候去除了对 gt label 的依赖,结合大量无标注数据,最终蒸馏训练得到的预训练模型在 15 个模型上的精度提升平均高达 3%。 + +上述标准的蒸馏方法是通过一个大模型作为教师模型来指导学生模型提升效果,而后来又发展出 DML(Deep Mutual Learning)互学习蒸馏方法 [7],即通过两个结构相同的模型互相学习。具体的。相比于 KD 等依赖于大的教师模型的知识蒸馏算法,DML 脱离了对大的教师模型的依赖,蒸馏训练的流程更加简单,模型产出效率也要更高一些。 + + +### 3.2 Feature based distillation + +Heo 等人提出了 OverHaul [8], 计算学生模型与教师模型的 feature map distance,作为蒸馏的 loss,在这里使用了学生模型、教师模型的转移,来保证二者的 feature map 可以正常地进行 distance 的计算。 + +基于 feature map distance 的知识蒸馏方法也能够和 `3.1 章节` 中的基于 response 的知识蒸馏算法融合在一起,同时对学生模型的输出结果和中间层 feature map 进行监督。而对于 DML 方法来说,这种融合过程更为简单,因为不需要对学生和教师模型的 feature map 进行转换,便可以完成对齐(alignment)过程。PP-OCRv2 系统中便使用了这种方法,最终大幅提升了 OCR 文字识别模型的精度。 + + +### 3.3 Relation based distillation + + +`3.1` 和 `3.2` 章节中的论文中主要是考虑到学生模型与教师模型的输出或者中间层 feature map,这些知识蒸馏算法只关注个体的输出结果,没有考虑到个体之间的输出关系。 + +Park 等人提出了 RKD [10],基于关系的知识蒸馏算法,RKD 中进一步考虑个体输出之间的关系,使用 2 种损失函数,二阶的距离损失(distance-wise)和三阶的角度损失(angle-wise) + + +本论文提出的算法关系知识蒸馏(RKD)迁移教师模型得到的输出结果间的结构化关系给学生模型,不同于之前的只关注个体输出结果,RKD 算法使用两种损失函数:二阶的距离损失(distance-wise)和三阶的角度损失(angle-wise)。在最终计算蒸馏损失函数的时候,同时考虑 KD loss 和 RKD loss。最终精度优于单独使用 KD loss 蒸馏得到的模型精度。 + + +## 4. 参考文献 + +[1] Hinton G, Vinyals O, Dean J. Distilling the knowledge in a neural network[J]. arXiv preprint arXiv:1503.02531, 2015. + +[2] Bagherinezhad H, Horton M, Rastegari M, et al. Label refinery: Improving imagenet classification through label progression[J]. arXiv preprint arXiv:1805.02641, 2018. + +[3] Yalniz I Z, Jégou H, Chen K, et al. Billion-scale semi-supervised learning for image classification[J]. arXiv preprint arXiv:1905.00546, 2019. + +[4] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123. + +[5] Touvron H, Vedaldi A, Douze M, et al. Fixing the train-test resolution discrepancy[C]//Advances in Neural Information Processing Systems. 2019: 8250-8260. + +[6] Cui C, Guo R, Du Y, et al. Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones[J]. arXiv preprint arXiv:2103.05959, 2021. + +[7] Zhang Y, Xiang T, Hospedales T M, et al. Deep mutual learning[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2018: 4320-4328. + +[8] Heo B, Kim J, Yun S, et al. A comprehensive overhaul of feature distillation[C]//Proceedings of the IEEE/CVF International Conference on Computer Vision. 2019: 1921-1930. + +[9] Du Y, Li C, Guo R, et al. PP-OCRv2: Bag of Tricks for Ultra Lightweight OCR System[J]. arXiv preprint arXiv:2109.03144, 2021. + +[10] Park W, Kim D, Lu Y, et al. Relational knowledge distillation[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2019: 3967-3976. diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/metric_learning.md b/src/PaddleClas/docs/zh_CN/algorithm_introduction/metric_learning.md new file mode 100644 index 0000000..07cbda8 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/metric_learning.md @@ -0,0 +1,36 @@ +# Metric Learning +---- +## 目录 + +* [1. 简介](#1) +* [2. 应用](#2) +* [3. 算法](#3) + * [3.1 Classification based](#3.1) + * [3.2 Pairwise based](#3.2) + + +## 1. 简介 + 在机器学习中,我们经常会遇到度量数据间距离的问题。一般来说,对于可度量的数据,我们可以直接通过欧式距离(Euclidean Distance),向量内积(Inner Product)或者是余弦相似度(Cosine Similarity)来进行计算。但对于非结构化数据来说,我们却很难进行这样的操作,如计算一段视频和一首音乐的匹配程度。由于数据格式的不同,我们难以直接进行上述的向量运算,但先验知识告诉我们 ED(laugh_video, laugh_music) < ED(laugh_video, blue_music), 如何去有效得表征这种”距离”关系呢? 这就是 Metric Learning 所要研究的课题。 + + Metric learning 全称是 Distance Metric Learning,它是通过机器学习的形式,根据训练数据,自动构造出一种基于特定任务的度量函数。Metric Learning 的目标是学习一个变换函数(线性非线性均可)L,将数据点从原始的向量空间映射到一个新的向量空间,在新的向量空间里相似点的距离更近,非相似点的距离更远,使得度量更符合任务的要求,如下图所示。 Deep Metric Learning,就是用深度神经网络来拟合这个变换函数。 +![example](../../images/ml_illustration.jpg) + + +## 2. 应用 + Metric Learning 技术在生活实际中应用广泛,如我们耳熟能详的人脸识别(Face Recognition)、行人重识别(Person ReID)、图像检索(Image Retrieval)、细粒度分类(Fine-grained classification)等。随着深度学习在工业实践中越来越广泛的应用,目前大家研究的方向基本都偏向于 Deep Metric Learning(DML). + + 一般来说, DML 包含三个部分: 特征提取网络来 map embedding, 一个采样策略来将一个 mini-batch 里的样本组合成很多个 sub-set, 最后 loss function 在每个 sub-set 上计算 loss. 如下图所示: + ![image](../../images/ml_pipeline.jpg) + + +## 3. 算法 + Metric Learning 主要有如下两种学习范式: + +### 3.1 Classification based: + 这是一类基于分类标签的 Metric Learning 方法。这类方法通过将每个样本分类到正确的类别中,来学习有效的特征表示,学习过程中需要每个样本的显式标签参与 Loss 计算。常见的算法有 [L2-Softmax](https://arxiv.org/abs/1703.09507), [Large-margin Softmax](https://arxiv.org/abs/1612.02295), [Angular Softmax](https://arxiv.org/pdf/1704.08063.pdf), [NormFace](https://arxiv.org/abs/1704.06369), [AM-Softmax](https://arxiv.org/abs/1801.05599), [CosFace](https://arxiv.org/abs/1801.09414), [ArcFace](https://arxiv.org/abs/1801.07698)等。 + 这类方法也被称作是 proxy-based, 因为其本质上优化的是样本和一堆 proxies 之间的相似度。 + +### 3.2 Pairwise based: + 这是一类基于样本对的学习范式。他以样本对作为输入,通过直接学习样本对之间的相似度来得到有效的特征表示,常见的算法包括:[Contrastive loss](http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf), [Triplet loss](https://arxiv.org/abs/1503.03832), [Lifted-Structure loss](https://arxiv.org/abs/1511.06452), [N-pair loss](https://papers.nips.cc/paper/2016/file/6b180037abbebea991d8b1232f8a8ca9-Paper.pdf), [Multi-Similarity loss](https://arxiv.org/pdf/1904.06627.pdf)等 + +2020 年发表的[CircleLoss](https://arxiv.org/abs/2002.10857),从一个全新的视角统一了两种学习范式,让研究人员和从业者对 Metric Learning 问题有了更进一步的思考。 diff --git a/src/PaddleClas/docs/zh_CN/algorithm_introduction/model_prune_quantization.md b/src/PaddleClas/docs/zh_CN/algorithm_introduction/model_prune_quantization.md new file mode 100644 index 0000000..b47cd17 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/algorithm_introduction/model_prune_quantization.md @@ -0,0 +1,54 @@ +# 模型裁剪、量化算法介绍 + +深度学习因其计算复杂度或参数冗余,在一些场景和设备上限制了相应的模型部署,需要借助模型压缩、优化加速、异构计算等方法突破瓶颈。模型压缩算法能够有效降低参数冗余,从而减少存储占用、通信带宽和计算复杂度,有助于深度学习的应用部署。其中模型量化、裁剪应用比较广泛。在 PaddleClas 中,主要应该应用以下两种算法。 + +- 量化方法:PACT 量化 +- 裁剪:FPGM 裁剪 + +其中具体算法参数请参考 [PaddeSlim](https://github.com/PaddlePaddle/PaddleSlim/)。 + +## 目录 + +* [1. PACT 量化方法](#1) +* [2. FPGM 裁剪](#2) + + + +## 1. PACT 量化方法 + +模型量化主要包括两个部分,一是对权重 Weight 量化,一是针对激活值 Activation 量化。同时对两部分进行量化,才能获得最大的计算效率收益。权重可以借助网络正则化等手段,让权重分布尽量紧凑,减少离群点、不均匀分布情况发生,而对于激活值还缺乏有效的手段。 + +**PACT 量化(PArameterized Clipping acTivation**是一种新的量化方法,该方法通过在量化激活值之前去掉一些离群点,将模型量化带来的精度损失降到最低,甚至比原模型准确率更高。提出方法的背景是作者发现:“在运用权重量化方案来量化 activation 时,激活值的量化结果和全精度结果相差较大”。作者发现,activation 的量化可能引起的误差很大(相较于 weight 基本在 0 到 1 范围内,activation 的值的范围是无限大的,这是 RELU 的结果),所以提出**截断式 RELU** 的激活函数。该截断的上界,即$α$ 是可学习的参数,这保证了每层能够通过训练学习到不一样的量化范围,最大程度降低量化带来的舍入误差。其中量化的示意图如下图所示,**PACT** 解决问题的方法是,不断裁剪激活值范围,使得激活值分布收窄,从而降低量化映射损失。**PACT** 通过对激活数值做裁剪,从而减少激活分布中的离群点,使量化模型能够得到一个更合理的量化 scale,降低量化损失。 + +![](../../images/algorithm_introduction/quantization.jpg) + +**PACT** 量化公式如下: + +![](../../images/algorithm_introduction/quantization_formula.png) + + +可以看出 PACT 思想是用上述量化代替 *ReLU* 函数,对大于零的部分进行一个截断操作,截断阈值为$a$。但是在*PaddleSlim*中对上述公式做了进一步的改进,其改进如下: + + +![](../../images/algorithm_introduction/quantization_formula_slim.png) + +经过如上改进后,在激活值和待量化的 OP(卷积,全连接等)之间插入 *PACT* 预处理,不只对大于 0 的分布进行截断,同时也对小于 0 的部分做同样的限制,从而更好地得到待量化的范围,降低量化损失。同时,截断阈值是一个可训练的参数,在量化训练过程中,模型会自动的找到一个合理的截断阈值,从而进一步降低量化精度损失。 + +算法具体参数请参考 PaddleSlim 中[参数介绍](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/quanter/qat.rst#qat)。 + + + +## 2. FPGM 裁剪 + +模型剪枝是减小模型大小,提升预测效率的一种非常重要的手段。在之前的网络剪枝文章中一般将网络 filter 的范数作为其重要性度量,**范数值较小的代表的 filter 越不重要**,将其从网络中裁剪掉,反之也就越重要。而**FPGM**认为之前的方法要依赖如下两点 + +- filter 的范数偏差应该比较大,这样重要和非重要的 filter 才可以很好区分开 +- 不重要的 filter 的范数应该足够的小 + +基于此,**FPGM**利用层中 filter 的几何中心特性,由于那些靠近中心的 filter 可以被其它的表达,因而可以将其剔除,从而避免了上面提到的两点剪枝条件,从信息的冗余度出发,而不是选择范数少的进行剪枝。下图展示了 **FPGM** 方法与之前方法的不同,具体细节请详看[论文](https://openaccess.thecvf.com/content_CVPR_2019/papers/He_Filter_Pruning_via_Geometric_Median_for_Deep_Convolutional_Neural_Networks_CVPR_2019_paper.pdf)。 + +![](../../images/algorithm_introduction/fpgm.png) + + + +算法具体参数请参考 PaddleSlim 中[参数介绍](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/pruners/fpgm_filter_pruner.rst#fpgmfilterpruner)。 diff --git a/src/PaddleClas/docs/zh_CN/conf.py b/src/PaddleClas/docs/zh_CN/conf.py new file mode 100644 index 0000000..889ef59 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/conf.py @@ -0,0 +1,69 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +import sphinx_rtd_theme +from recommonmark.parser import CommonMarkParser +#import sphinx-markdown-tables +# -- Project information ----------------------------------------------------- + +project = 'PaddleClas' +copyright = '2021, PaddleClas' +author = 'PaddleClas' + +# The full version, including alpha/beta/rc tags +release = '2.3.0' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +source_parsers = { + '.md': CommonMarkParser, +} +source_suffix = ['.rst', '.md'] +extensions = [ + 'recommonmark', + 'sphinx_markdown_tables' + ] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'zh_CN' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] diff --git a/src/PaddleClas/docs/zh_CN/data_preparation/classification_dataset.md b/src/PaddleClas/docs/zh_CN/data_preparation/classification_dataset.md new file mode 100644 index 0000000..66f7180 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/data_preparation/classification_dataset.md @@ -0,0 +1,123 @@ +# 图像分类任务数据集说明 + +本文档将介绍 PaddleClas 所使用的图像分类任务数据集格式,以及图像分类领域的常见数据集介绍。 + +--- + +## 目录 + +- [1. 数据集格式说明](#1) +- [2. 图像分类任务常见数据集介绍](#2) + - [2.1 ImageNet1k](#2.1) + - [2.2 Flowers102](#2.2) + - [2.3 CIFAR10 / CIFAR100](#2.3) + - [2.4 MNIST](#2.4) + - [2.5 NUS-WIDE](#2.5) + + +## 1. 数据集格式说明 + +PaddleClas 使用 `txt` 格式文件指定训练集和测试集,以 `ImageNet1k` 数据集为例,其中 `train_list.txt` 和 `val_list.txt` 的格式形如: + +```shell +# 每一行采用"空格"分隔图像路径与标注 + +# 下面是 train_list.txt 中的格式样例 +train/n01440764/n01440764_10026.JPEG 0 +... + +# 下面是 val_list.txt 中的格式样例 +val/ILSVRC2012_val_00000001.JPEG 65 +... +``` + +## 2. 图像分类任务常见数据集介绍 + +这里整理了常用的图像分类任务数据集,持续更新中,欢迎各位小伙伴补充完善~ + + +### 2.1 ImageNet1k + +[ImageNet](https://image-net.org/)项目是一个大型视觉数据库,用于视觉目标识别研究任务,该项目已手动标注了 1400 多万张图像。ImageNet-1k 是 ImageNet 数据集的子集,其包含 1000 个类别。训练集包含 1281167 个图像数据,验证集包含 50000 个图像数据。2010 年以来,ImageNet 项目每年举办一次图像分类竞赛,即 ImageNet 大规模视觉识别挑战赛(ILSVRC)。挑战赛使用的数据集即为 ImageNet-1k。到目前为止,ImageNet-1k 已经成为计算机视觉领域发展的最重要的数据集之一,其促进了整个计算机视觉的发展,很多计算机视觉下游任务的初始化模型都是基于该数据集训练得到的。 + +数据集 | 训练集大小 | 测试集大小 | 类别数 | 备注| +:------:|:---------------:|:---------------------:|:-----------:|:-----------: +[ImageNet1k](http://www.image-net.org/challenges/LSVRC/2012/)|1.2M| 50k | 1000 | + +从官方下载数据后,按如下格式组织数据,即可在 PaddleClas 中使用 ImageNet1k 数据集进行训练。 + +```bash +PaddleClas/dataset/ILSVRC2012/ +|_ train/ +| |_ n01440764 +| | |_ n01440764_10026.JPEG +| | |_ ... +| |_ ... +| | +| |_ n15075141 +| |_ ... +| |_ n15075141_9993.JPEG +|_ val/ +| |_ ILSVRC2012_val_00000001.JPEG +| |_ ... +| |_ ILSVRC2012_val_00050000.JPEG +|_ train_list.txt +|_ val_list.txt +``` + + +### 2.2 Flowers102 + +数据集 | 训练集大小 | 测试集大小 | 类别数 | 备注| +:------:|:---------------:|:---------------------:|:-----------:|:-----------: +[flowers102](https://www.robots.ox.ac.uk/~vgg/data/flowers/102/)|1k | 6k | 102 | + +将下载的数据解压后,可以看到以下目录 + +```shell +jpg/ +setid.mat +imagelabels.mat +``` + +将以上文件放置在 `PaddleClas/dataset/flowers102/` 下 + +通过运行 `generate_flowers102_list.py` 生成 `train_list.txt` 和 `val_list.txt`: + +```shell +python generate_flowers102_list.py jpg train > train_list.txt +python generate_flowers102_list.py jpg valid > val_list.txt +``` + +按照如下结构组织数据: + +```shell +PaddleClas/dataset/flowers102/ +|_ jpg/ +| |_ image_03601.jpg +| |_ ... +| |_ image_02355.jpg +|_ train_list.txt +|_ val_list.txt +``` + + +### 2.3 CIFAR10 / CIFAR100 + +CIFAR-10 数据集由 10 个类的 60000 个彩色图像组成,图像分辨率为 32x32,每个类有 6000 个图像,其中训练集 5000 张,验证集 1000 张,10 个不同的类代表飞机、汽车、鸟类、猫、鹿、狗、青蛙、马、轮船和卡车。CIFAR-100 数据集是 CIFAR-10 的扩展,由 100 个类的 60000 个彩色图像组成,图像分辨率为 32x32,每个类有 600 个图像,其中训练集 500 张,验证集 100 张。 + +数据集地址:http://www.cs.toronto.edu/~kriz/cifar.html + + +### 2.4 MNIST + +MMNIST 是一个非常有名的手写体数字识别数据集,在很多资料中,这个数据集都会被用作深度学习的入门样例。其包含 60000 张图片数据,50000 张作为训练集,10000 张作为验证集,每张图片的大小为 28 * 28。 + +数据集地址:http://yann.lecun.com/exdb/mnist/ + + +### 2.5 NUS-WIDE + +NUS-WIDE 是一个多分类数据集。该数据集包含 269648 张图片, 81 个类别,每张图片被标记为该 81 个类别中的某一类或某几类。 + +数据集地址:https://lms.comp.nus.edu.sg/wp-content/uploads/2019/research/nuswide/NUS-WIDE.html diff --git a/src/PaddleClas/docs/zh_CN/data_preparation/index.rst b/src/PaddleClas/docs/zh_CN/data_preparation/index.rst new file mode 100644 index 0000000..c851ca5 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/data_preparation/index.rst @@ -0,0 +1,8 @@ +数据准备 +================================ + +.. toctree:: + :maxdepth: 2 + + recognition_dataset.md + classification_dataset.md diff --git a/src/PaddleClas/docs/zh_CN/data_preparation/recognition_dataset.md b/src/PaddleClas/docs/zh_CN/data_preparation/recognition_dataset.md new file mode 100644 index 0000000..2fb1ce4 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/data_preparation/recognition_dataset.md @@ -0,0 +1,132 @@ +# 图像识别任务数据集说明 + +本文档将介绍 PaddleClas 所使用的图像识别任务数据集格式,以及图像识别领域的常见数据集介绍。 + +--- + + +## 目录 + +- [1. 数据集格式说明](#1) +- [2. 图像识别任务常见数据集介绍](#2) + - [2.1 通用图像识别数据集](#2.1) + - [2.2 垂类图像识别数据集](#2.2) + - [2.2.1 动漫人物识别](#2.2.1) + - [2.2.2 商品识别](#2.2.2) + - [2.2.3 Logo 识别](#2.2.3) + - [2.2.4 车辆识别](#2.2.4) + + + +## 1. 数据集格式说明 + +与分类任务数据集不同,图像检索任务的数据集分为以下三部分: + +* 训练集合(train dataset):用来训练模型,使模型能够学习该集合的图像特征。 +* 底库数据集合(gallery dataset):用来提供图像检索任务中的底库数据,该集合可与训练集或测试集相同,也可以不同,当与训练集相同时,测试集的类别体系应与训练集的类别体系相同。 +* 测试数据集合(query dataset):用来测试模型的好坏,通常要对测试集的每一张测试图片进行特征提取,之后和底库数据的特征进行距离匹配,得到识别结果,后根据识别结果计算整个测试集的指标。 + +训练集、底库数据集和测试数据集均使用 `txt` 文件指定,以 `CUB_200_2011` 数据集为例,训练数据集 `train_list.txt` 文件内容格式如下所示: + +```shell +# 采用"空格"作为分隔符号 +... +train/99/Ovenbird_0136_92859.jpg 99 2 +... +train/99/Ovenbird_0128_93366.jpg 99 6 +... +``` + +验证数据集(`CUB_200_2011` 中既是 gallery dataset,也是 query dataset)`test_list.txt` 文件内容格式如下所示: + +```shell +# 采用"空格"作为分隔符号 +... +test/200/Common_Yellowthroat_0126_190407.jpg 200 1 +... +test/200/Common_Yellowthroat_0114_190501.jpg 200 6 +... +``` + +每行数据使用“空格”分割,三列数据的含义分别是训练数据的路径、训练数据的 label 信息、训练数据的 unique id。 + +**注意**: + +1.当 gallery dataset 和 query dataset 相同时,为了去掉检索得到的第一个数据(检索图片本身无须评估),每个数据需要对应一个 unique id(每张图片的 id 不同即可,可以用行号来表示 unique id),用于后续评测 mAP、recall@1 等指标。yaml 配置文件的数据集选用 `VeriWild`。 + +2.当 gallery dataset 和 query dataset 不同时,无需增加 unique id,`query_list.txt` 和 `gallery_list.txt` 均为两列,分别是训练数据的路径、训练数据的 label 信息。yaml 配置文件的数据集选用 `ImageNetDataset`。 + + +## 2. 图像识别任务常见数据集介绍 + +这里整理了常用的图像识别任务数据集,持续更新中,欢迎各位小伙伴补充完善~ + + +### 2.1 通用图像识别数据集 +- SOP: SOP 数据集是通用识别研究领域、MetricLearning 技术研究方向常用的一个商品数据集, 其包含从 eBay.com 下载的 22,634 个产品的 120,053 张图片。其中, 训练集包含图片 59551 张, 类别数 11318; 验证集包含图片 60502 张,类别数 11316 个。 + + 地址: https://cvgl.stanford.edu/projects/lifted_struct/ + +- Cars196: +Cars 数据集包含了 196 类汽车的 16185 张图像。数据被分成 8144 张训练图像和 8041 张测试图像,每个类大致以 50-50 的比例分割。级别通常是在制造,模型,年,例如 2012 特斯拉模型 S 或 2012 宝马 M3 双门跑车。 + + 地址: https://ai.stanford.edu/~jkrause/cars/car_dataset.html +- CUB_200_2011: CUB_200_2011 数据集是由加州理工学院在 2010 年提出的细粒度数据集,也是目前细粒度分类识别研究的基准图像数据集。该数据集共有 11788 张鸟类图像,包含 200 类鸟类子类,其中训练数据集有 5994 张图像,测试集有 5794 张图像,每张图像均提供了图像类标记信息,图像中鸟的 bounding box,鸟的关键 part 信息,以及鸟类的属性信息,数据集如下图所示。 + + 地址: http://www.vision.caltech.edu/visipedia/CUB-200-2011.html + +- In-shop Clothes: In-shop Clothes 是 DeepFashion 数据集的 4 个子集之一, 它是一个卖家秀图片集,每个商品 id,有多张不同角度的卖家秀,放在同一个文件夹内。该数据集共包含 7982 件商品,共 52712 张图像,每张图片都有 463 中属性,Bbox,landmarks,以及店铺描述。 + + 地址: http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion.html + + +### 2.2 垂类图像识别数据集 + + +#### 2.2.1 动漫人物识别 ++ iCartoonFace: iCartoonFace 是由爱奇艺开放的目前全球最大的手工标注卡通人物检测数据集与识别数据集,它包含超过 5013 个卡通人物、389678 张高质量实景图片。相比于其他数据集,它具有大规模、高质量、多样性丰富、挑战难度大等特点,是目前研究动漫人物识别最常用的数据集之一。 + + 地址: http://challenge.ai.iqiyi.com/detail?raceId=5def69ace9fcf68aef76a75d + ++ Manga109: Manga109 是 2020.5 月发布的一个用于研究卡通人物检测和识别的数据集,其包含 21142 张图片,官方不允许用于商用。该数据集旗下的子集 Manga109-s,可以供工业使用,主要用于文本检测、基于线稿的任务检索、角色图像生成等任务。 + + 地址:http://www.manga109.org/en/ + ++ IIT-CFW:IIF-CFW 数据集共包含 8928 个带有标注的明星人物卡通头像,覆盖 100 个人物形象,每个人卡通头像数不等。 另外,其还提供了 1000 张真实人脸照(100 个公众人物,每个人 10 张真实头像)。该数据集既可以用于研究动漫人物识别,也经常被用于研究跨模态的检索任务。 + + 地址: http://cvit.iiit.ac.in/research/projects/cvit-projects/cartoonfaces + + +#### 2.2.2 商品识别 ++ AliProduct: AliProduct 数据集是目前开源最大的商品数据集,它是一个 SKU 级别的图像分类数据集,包含 5 万类别、300 万张商品图像,商品图像的类别和总量均为业界之最。此数据集中涵盖了大量的生活用品、食物等,数据集中没有人工标注,数据较脏,数据分布较不均衡,且有很多相似的商品图片。 + + 地址: https://retailvisionworkshop.github.io/recognition_challenge_2020/ + ++ Product-10k: Products-10k 数据集中的所有图片均来自京东商城。数据集中共包含 1 万个经常购买的 SKU。所有 SKU 组织成一个层次结构。总共有近 19 万张图片。在实际应用场景中,图像量的分布是不均衡的。所有图像都由生产专家团队手工检查/标记。 + + 地址:https://www.kaggle.com/c/products-10k/data?select=train.csv + ++ DeepFashion-Inshop: 同通用图像识别数据集中的 In-shop Clothes + + +### 2.2.3 Logo 识别 ++ Logo-2K+: Logo-2K+是一个仅用于 logo 图像识别的数据集,其包含 10 个大类,2341 个小类和 167140 张图片。 + + 地址: https://github.com/msn199959/Logo-2k-plus-Dataset + ++ Tsinghua-Tencent 100K: 该数据集是从 10 万张腾讯街景全景图中创建的一个大型交通标志基准数据集。它提供包含 30000 个交通标志实例的 100000 张图像。这些图像涵盖了照度和天气条件的巨大变化。基准测试中的每个交通标志都标注了类别标签、边界框和像素掩码。 它总共包含 222 个类别(0 background + 221 traffic signs) + + 地址: https://cg.cs.tsinghua.edu.cn/traffic-sign/ + +### 2.2.4 车辆识别 ++ CompCars: 图像主要来自网络和监控数据,其中网络数据包含 163 个汽车制造商、1716 个汽车型号的汽车。共 136,726 张全车图像,27,618 张部分车图像。其中网络汽车数据包含 bounding box、视角、5 个属性(最大速度、排量、车门数、车座数、汽车类型)。监控数据包含 50,000 张前视角图像。 + + 地址: http://mmlab.ie.cuhk.edu.hk/datasets/comp_cars/ + ++ BoxCars: 此数据集共包含 21250 辆车、63750 张图像、27 个汽车制造商、148 个细类别,此数据集全部来自监控数据。 + + 地址: https://github.com/JakubSochor/BoxCars + ++ PKU-VD Dataset:该数据集包含了两个大型车辆数据集(VD1 和 VD2),它们分别从两个城市的真实世界不受限制的场景拍摄图像。其中 VD1 是从高分辨率交通摄像头获得的,VD2 中的图像则是从监视视频中获取的。作者对原始数据执行车辆检测,以确保每个图像仅包含一辆车辆。由于隐私保护的限制,所有车牌号码都已被黑色覆盖遮挡。所有车辆图像均从前视图进行拍摄。 数据集中为每个图像提供了多样化的属性注释,包括身份编号,精确的车辆模型和车辆颜色。VD1 原先包含 1097649 张图像,1232 种车俩模型,11 种车辆颜色,但删除图像里面有多辆车辆以及从车辆后方拍摄的图片,该数据集仅剩 846358 张图像,141756 辆车辆。 VD2 包含 807260 张图像,79763 辆车辆,1112 种车辆模型,11 种车辆颜色。 + + 地址: https://pkuml.org/resources/pku-vds.html diff --git a/src/PaddleClas/docs/zh_CN/faq_series/faq_2020_s1.md b/src/PaddleClas/docs/zh_CN/faq_series/faq_2020_s1.md new file mode 100644 index 0000000..e780a54 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/faq_series/faq_2020_s1.md @@ -0,0 +1,349 @@ +# 图像分类常见问题汇总 - 2020 第 1 季 + + +## 目录 +* [1. 第 1 期](#1)(2020.11.03) +* [2. 第 2 期](#2)(2020.11.11) +* [3. 第 3 期](#3)(2020.11.18) +* [4. 第 4 期](#4)(2020.12.07) +* [5. 第 5 期](#5)(2020.12.17) +* [6. 第 6 期](#6)(2020.12.30) + + +## 第 1 期 + +### Q1.1: PaddleClas 可以用来做什么? +**A**:PaddleClas 是飞桨为工业界和学术界所准备的一个图像分类任务的工具集,助力使用者训练出更好的视觉模型和应用落地。PaddleClas 提供了基于图像分类的模型训练、评估、预测、部署全流程的服务,方便大家更加高效地学习图像分类。具体地,PaddleClas 中包含如下一些特性。 + +* PaddleClas 提供了 36 个系列的分类网络结构(ResNet, ResNet_vd, MobileNetV3, Res2Net, HRNet 等)和训练配置,175 个预训练模型和性能评估与预测,供大家选择并使用。 +* PaddleClas 提供了 TensorRT 预测、python inference、c++ inference、Paddle-Lite 预测部署、PaddleServing、PaddleHub 等多种预测部署推理方案,在方便在多种环境中进行部署推理。 +* PaddleClas 提供了一种简单的 SSLD 知识蒸馏方案,基于该方案蒸馏模型的识别准确率普遍提升 3% 以上。 +* PaddleClas 支持 AutoAugment、Cutout、Cutmix 等 8 种数据增广算法详细介绍、代码复现和在统一实验环境下的效果评估。 +* PaddleClas 支持在 Windows/Linux/MacOS 环境中基于 CPU/GPU 进行使用。 + +### Q1.2: ResNet 系列模型是什么?有哪些模型?为什么在服务器端如此推荐 ResNet 系列模型? +**A**: ResNet 中创新性地引入了残差结构,通过堆叠多个残差结构从而构建了 ResNet 网络。实验表明使用残差块可以有效地提升收敛速度和精度,PaddleClas 中,ResNet 从小到达,依次有包含 18、34、50、101、152、200 层的 ResNet 结构,ResNet 系列模型于 2015 年被提出,在不同的应用场景中,如分类、检测、分割等,都已经验证过其有效性,业界也早已对其进行了大量优化,该系列模型在速度和精度方面都有着非常明显的优势,对基于 TensorRT 以及 FP16 的预测支持得也很好,因而推荐大家使用 ResNet 系列模型;由于其模型所占存储相对较大,因此常用于服务器端。更多关于 ResNet 模型的介绍可以参考论文 [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385)。 + +### Q1.3: ResNet_vd 和 ResNet、ResNet_vc 结构有什么区别呢? +**A**: +ResNet_va 至 vd 的结构如下图所示,ResNet 最早提出时为 va 结构,在降采样残差模块这个部分,在左边的特征变换通路中(Path A),第一个 1x1 卷积部分就行了降采样,从而导致信息丢失(卷积的 kernel size 为 1,stride 为 2,输入特征图中 有部分特征没有参与卷积的计算);在 vb 结构中,把降采样的步骤从最开始的第一个 1x1 卷积调整到中间的 3x3 卷积中,从而避免了信息丢失的问题,PaddleClas 中的 ResNet 模型默认就是 ResNet_vb;vc 结构则是将最开始这个 7x7 的卷积变成 3 个 3x3 的卷积,在感受野不变的情况下,计算量和存储大小几乎不变,而且实验证明精度相对于 vb 结构有所提升;vd 结构是修改了降采样残差模块右边的特征通路(Path B)。把降采样的过程由平均池化这个操作去替代了,这一系列的改进(va->vd),几乎没有带来新增的预测耗时,结合适当的训练策略,比如说标签平滑以及 mixup 数据增广,精度可以提升高达 2.7%。 + +![](../../images/faq/ResNet_vabcd_structure.png) +### Q1.4 如果确定使用 ResNet 系列模型,怎么根据实际的场景需求选用不同的模型呢? +**A**: + +ResNet 系列模型中,相比于其他模型,ResNet_vd 模型在预测速度几乎不变的情况下,精度有非常明显的提升,因此推荐大家使用 ResNet_vd 系列模型。 +[ResNet 及其 vd 系列模型文档](../models/ResNet_and_vd.md)中给出了 batch size=4 的情况下,在 T4 GPU 上,不同模型的的预测耗时、FLOPs、Params 与精度的变化曲线,可以根据自己自己的实际部署场景中的需求,去选择合适的模型,如果希望模型存储大小尽可能小或者预测速度尽可能快,则可以使用 ResNet18_vd 模型,如果希望获得尽可能高的精度,则建议使用 ResNet152_vd 或者 ResNet200_vd 模型。更多关于 ResNet 系列模型的介绍可以参考文档:[ResNet 及其 vd 系列模型文档](../models/ResNet_and_vd.md)。 + +* 精度-预测速度变化曲线 + + ![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.png) +* 精度-params 变化曲线 + + ![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png) +* 精度-flops 变化曲线 + + ![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png) +### Q1.5 在网络中的 block 里 conv-bn-relu 是固定的形式吗? + +**A**: 在 batch-norm 出现之前,主流的卷积神经网络的固定形式是 conv-relu。在现阶段的卷积神经网络中,conv-bn-relu 是大部分网络中 block 的固定形式,这样的设计是相对鲁棒的结构,此外,DenseNet 中的 block 选用的是 bn-relu-conv 的形式,ResNet-V2 中也使用的是这种组合方式。在 MobileNetV2 中,为了不丢失信息,部分 block 中间的层没有使用 relu 激活函数,选用的是 conv-bn 的形式。 + +### Q1.6 ResNet34 与 ResNet50 的区别? + +**A**: ResNet 系列中有两种不同的 block,分别是 basic-block 和 bottleneck-block,堆叠较多这样的 block 组成了 ResNet 网络。basic-block 是带有 shortcut 的两个 3x3 的卷积核的堆叠,bottleneck-block 是带有 shortcut 的 1x1 卷积核、3x3 卷积核、1x1 卷积核的堆叠,所以 basic-block 中有两层,bottleneck-block 有三层。ResNet34 和 ResNet50 中堆叠的 block 数相同,但是堆叠的种类分别是 basic-block 和 bottleneck-block。 + +### Q1.7 大卷积核一定可以带来正向收益吗? + +**A**: 不一定,将网络中的所有卷积核都增大未必会带来性能的提升,甚至会有有损性能,在论文 [MixConv: Mixed Depthwise Convolutional Kernels](https://arxiv.org/abs/1907.09595) +中指出,在一定范围内提升卷积核大小对精度的提升有正向作用,但是超出后会有损精度。所以考虑到模型的大小、计算量等问题,一般不选用大的卷积核去设计网络。同时,在 [PP-LCNet](../models/PP-LCNet.md) 文章中,也有关于大卷积核的实验。 + + +## 第 2 期 + +### Q2.1: PaddleClas 如何训练自己的 backbone? + +**A**:具体流程如下: +* 首先在 ppcls/arch/backbone/model_zoo/ 文件夹下新建一个自己的模型结构文件,即你自己的 backbone,模型搭建可以参考 resnet.py; +* 然后在 ppcls/arch/backbone/\_\_init\_\_.py 中添加自己设计的 backbone 的类; +* 其次配置训练的 yaml 文件,此处可以参考 ppcls/configs/ImageNet/ResNet/ResNet50.yaml; +* 最后启动训练即可。 + + +### Q2.2: 如何利用已有的模型和权重对自己的分类任务进行迁移? + +**A**: 具体流程如下: +* 首先,好的预训练模型往往会有更好的迁移效果,所以建议选用精度较高的预训练模型,PaddleClas 提供了一系列业界领先的预训练模型,建议使用; +* 其次,要根据迁移的数据集的规模来确定训练超参数,一般超参数需要调试才可以寻找到一个局部最优值,如果没有相关经验,建议先从 learning rate 开始调起,一般来说,规模较小的数据集使用较小的 learning rate,如 0.001,另外,建议学习率使用 warmup 策略,避免过大的学习率破坏预训练模型的权重。在迁移过程中,也可以设置 backbone 中不同层的学习率,往往从网络的头部到尾补学习率逐渐减小效果较好。在数据集规模较小的时候,也可以使用数据增强策略,PaddleClas 提供了 8 中强有力的数据增强策略,为更高的精度保驾护航。 +* 训练结束后,可以反复迭代上述过程,直到寻找到局部最优值。 + +### Q2.3: PaddleClas 中 configs 下的默认参数适合任何一个数据集吗? + +**A**: PaddleClas 中的 ppcls/configs/ImageNet/下的配置文件默认参数是 ImageNet-1k 的训练参数,这个参数并不适合所有的数据集,具体数据集需要在此基础上进一步调试。 + + +### Q2.4 PaddleClas 中的不同的模型使用了不同的分辨率,标配的应该是多少呢? + +**A**: PaddleClas 严格遵循了论文作者的使用的分辨率。自 2012 年 AlexNet 以来,大多数的卷积神经网络在 ImageNet 上训练的分辨率为 224x224,Google 在设计 InceptionV3 的时候为了适应网络结构将分辨率调至 299x299,之后其推出的 Xception、InceptionV4 也是使用的该分辨率。此外,在 EfficeintNet 中,作者分析了不同规模的网络应该使用不同的分辨率,所以该系列网络中每个不同大小的网络都使用了不同的分辨率。在实际使用场景中,推荐使用默认的分辨率,当然,层数较深或者宽度较大的网络也可以尝试使用更大的分辨率。 + + +### Q2.5 PaddleClas 中提供了很多 ssld 模型,其应用的价值是? + +**A**: PaddleClas 中提供了很多 ssld 预训练模型,其通过半监督知识蒸馏的方法获得了更好的预训练权重,在迁移任务或者下游视觉任务中,无须替换结构文件、只需要替换精度更高的 ssld 预训练模型即可提升精度,如在 PaddleSeg 中,[HRNet](https://github.com/PaddlePaddle/PaddleSeg/blob/release/v0.7.0/docs/model_zoo.md) 使用了 ssld 预训练模型的权重后,精度大幅度超越业界同样的模型的精度,在 PaddleDetection 中,[PP-YOLO](https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/configs/ppyolo/README_cn.md) 使用了 ssld 预训练权重后,在较高的 baseline 上仍有进一步的提升。使用 ssld 预训练权重做分类的迁移表现也很抢眼,在 [SSLD 蒸馏策略](../advanced_tutorials/knowledge_distillation.md) 部分介绍了知识蒸馏对于分类任务迁移的收益。 + + + +## 第 3 期 + +### Q3.1: DenseNet 模型相比于 ResNet 有什么改进呢?有哪些特点或者应用场景呢? + +**A**: DenseNet 相比于 ResNet,设计了一个更激进的密集连接机制,通过考虑特征重用和旁路的设置,进一步减少了参数量,而且从一定程度上缓解了梯度弥散的问题,因为引入了更加密集的连接,因此模型更容易训练,而且具有一定的正则化效果。在数据量不是很多的图像分类场景中,DenseNet 是一个不错的选择。更多关于 DenseNet 的介绍与系列模型可以参考 [DenseNet 模型文档](../models/DPN_DenseNet.md)。 + + + +### Q3.2: DPN 网络相比于 DenseNet 有哪些改进呢? + +**A**:DPN 的全称是 Dual Path Networks,即双通道网络。该网络是由 DenseNet 和 ResNeXt 结合的一个网络,其证明了 DenseNet 能从靠前的层级中提取到新的特征,而 ResNeXt 本质上是对之前层级中已提取特征的复用。作者进一步分析发现,ResNeXt 对特征有高复用率,但冗余度低,DenseNet 能创造新特征,但冗余度高。结合二者结构的优势,作者设计了 DPN 网络。最终 DPN 网络在同样 FLOPS 和参数量下,取得了比 ResNeXt 与 DenseNet 更好的结果。更多关于 DPN 的介绍与系列模型可以参考 [DPN 模型文档](../models/DPN_DenseNet.md)。 + + +### Q3.3: 怎么使用多个模型进行预测融合呢? + +**A** 使用多个模型进行预测的时候,建议首先将预训练模型导出为 inference 模型,这样可以摆脱对网络结构定义的依赖,可以参考[模型导出脚本](../../../tools/export_model.py)进行模型导出,之后再参考 [inference 模型预测脚本](../../../deploy/python/predict_cls.py)进行预测即可,在这里需要根据自己使用模型的数量创建多个 predictor。 + + +### Q3.4: PaddleClas 中怎么增加自己的数据增广方法呢? + +**A**: + +* 对于单张图像的增广,可以参考[基于单张图片的数据增广脚本](../../../ppcls/data/preprocess/ops),参考 `ResizeImage `或者 `CropImage` 等数据算子的写法,创建一个新的类,然后在 `__call__` 中,实现对应的增广方法即可。 +* 对于一个 batch 图像的增广,可以参考[基于 batch 数据的数据增广脚本](../../../ppcls/data/preprocess/batch_ops),参考 `MixupOperator` 或者 `CutmixOperator` 等数据算子的写法,创建一个新的类,然后在 `__call__` 中,实现对应的增广方法即可。 + + +### Q3.5: 怎么进一步加速模型训练过程呢? + +**A**: + +* 可以使用自动混合精度进行训练,这在精度几乎无损的情况下,可以有比较明显的速度收益,以 ResNet50 为例,PaddleClas 中使用自动混合精度训练的配置文件可以参考:[ResNet50_fp16.yml](../../../ppcls/configs/ImageNet/ResNet/ResNet50_fp16.yaml),主要就是需要在标准的配置文件中添加以下几行 + +``` +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + use_pure_fp16: &use_pure_fp16 True +``` + +* 可以开启 dali,将数据预处理方法放在 GPU 上运行,在模型比较小时(reader 耗时占比更高一些),开启 dali 会带来比较明显的训练速度收益,在训练的时候,添加 `-o Global.use_dali=True` 即可使用 dali 进行训练,更多关于 dali 安装与介绍可以参考:[dali 安装教程](https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html#nightly-builds)。 + + +## 第 4 期 + +### Q4.1: PaddlePaddle 的模型文件都有哪几种? + +**A**: +* PaddlePaddle 保存的模型相关文件有两类: +* 一类是用于*推理部署*的文件,包括后缀名为 “`pdiparams`”、“`model`” 的文件,其中 “`pdiparams`” 文件存储了模型参数信息,“`model`” 文件存储了模型网络结构信息,对于推理部署文件,使用 `paddle.jit.save` 与 `paddle.jit.load` 接口进行保存、加载。 +* 另一类模型相关文件则是用于*训练调优*过程中,包括后缀名为 “`pdparams`” 和 “`pdopt`” 的文件,其中 “`pdparams`” 文件存储了训练过程中的模型参数信息,“`pdopt`” 文件存储了模型训练过程中的优化器信息,对于训练调优文件,使用 `paddle.save` 与 `paddle.load` 接口进行保存、加载。 +* 利用推理部署文件,即可构建模型网络结构并加载模型参数,用于预测,利用训练调优文件,即可加载模型参数、优化器信息,用于恢复训练过程。 + +### Q4.2: HRNet 的创新点体现在哪里? + +**A**: +* 在图像分类领域,大部分神经网络的设计思想是提取图像的高维特征,具体来说,通常输入图像的空间分辨率较高,通过多层卷积、池化,可以逐步得到空间分辨率更低,但是维度更高的特征图,然后可用于分类等场景。 +* 然而 *HRNet* 的作者认为这种逐步降低空间分辨率的设计思想并不适合目标检测(图像区域层次的分类任务)、语义分割(图像像素层次的分类任务)等场景,因为空间分辨率在逐步降低的过程中,会丢失很多信息,最终学习得到的特征难以表达原始图像在高空间分辨率的信息,而区域层次分类任务和像素层次分类任务都对空间精度十分敏感。 +* 因此 *HRNet* 的作者提出了并联不同空间分辨率特征图的思想,与此相对,*VGG* 等神经网络则是通过不同的卷积池化层来串联不同空间分辨率的特征图。并且,*HRNet* 通过连接同等深度、不同空间分辨率的特征图,使得不同空间分辨率特征图的信息可以得到充分交换,具体的网络结构如下图所示。 + +![](../../images/faq/HRNet.png) + +### Q4.3: 在 HRNet 中,对于不同空间分辨率的特征图之间,是如何建立连接的? + +**A**: +* 首先,在 *HRNet* 中,对特征图使用 *stride* 为 *2* 的 *3 × 3* 卷积,可以得到低空间分辨率但是为度更高的特征图;而对低空间分辨率特征图先使用 *1 × 1* 卷积进行通道数匹配,再使用最近邻插值的方式进行上采样,即可得到与高空间分辨率特征图相同空间分辨率、通道数的特征图;而对于相同空间分辨率的特征图,直接进行恒等映射即可。具体如下图所示。 + +![](../../images/faq/HRNet_block.png) + +### Q4.4: 模型中的“SE”表示什么意思? + +**A**: +* SE 表示该模型使用了 SE 结构。SE 结构来自于 2017 年 ImageNet 分类比赛的冠军方案 *Squeeze-and-Excitation Networks(SENet)*,*SENet* 提出的 SE 结构可以迁移到任何其他网络中。其创新点是通过额外学习 *scale* 向量作为权重作用到特征图上, *scale* 向量维度与特征图通道数相同,学习到的 *scale* 向量中每个维度上的数值表示对该维度特征通道的增强或减弱的大小,以此达到对重要的特征通道进行增强,不重要特征通道减弱的效果,从而让提取的特征指向性更强。 + +### Q4.5: SE 结构具体如何实现的? + +![](../../images/faq/SE_structure.png) +**A**: +* *SE*结构具体如上图所示,首先,*Ftr* 表示常规的卷积操作,*X* 和 *U* 则是 *Ftr* 的输入与输出的特征图,在得到特征图*U*后,使用 *Fsq* 和 *Fex* 操作求得 *scale* 向量,*scale* 向量维度为 *C*,与 *U* 通道数相同,因此可以通过乘积的方式作用到 *U* 上,进而得到 *X~*。 +* 具体地,*Fsq* 为 *Global Average Pooling* 操作,*SENet* 作者将其称之为 *Squeeze*,因为该操作可以将 *U* 从 *C × H × W* 压缩到 *C × 1 × 1*,对 *Fsq* 的输出再做 *Fex* 操作。 +* *Fex*操作表示两次全连接,作者将该操作称为 *Excitation*。其中第一次全连接将向量的维度从 *1 × 1 × C* 压缩到 *1 × 1 × C/r*,然后使用 *RELU*,再通过第二次全连接将向量的维度恢复到 *C*,这样操作的目的是为了减小计算量,*SENet* 作者通过实验得出结论:在 *r=16* 时可以获得增益与计算量之间的平衡。 +* 对于*Fsq*部分,关键是求得 *C* 维的向量,因此不局限于使用 *Global Average Pooling* 操作,*SENet* 作者认为,最终求得的 *scale* 是按通道分别作用于 *U* 的,因此需要基于对应通道的信息计算对应的 *scale*,故使用了最简单的 *Global Average Pooling* 操作,最终求得的 *scale* 向量表示了不同通道之间的分布关系,而忽略了同一个通道中的分布关系。 +* 对于 *Fex* 部分,其作用是为了在每一个 *mini batch* 上的训练来求得基于所有训练数据的分布。因为我们的训练是在*mini batch*上进行的,而基于全部训练数据求得的 *scale* 才是最佳的,使用 *Fex* 部分,可以通过在每个 *mini batch* 上的训练来求得更为逼近全部训练数据的 *scale*。 + + +## 第 5 期 + +### Q5.1 如何选择优化器? + +**A**:自深度学习发展以来,就有很多关于优化器的研究者工作,优化器的目的是为了让损失函数尽可能的小,从而找到合适的权重来完成某项任务。目前业界主要用到的优化器有 SGD、RMSProp、Adam、AdaDelt 等,其中由于带 momentum 的 SGD 优化器广泛应用于学术界和工业界(此处仅限于分类任务),所以我们发布的模型也大都使用该优化器来实现损失函数的梯度下降。带 momentum 的 SGD 优化器有两个劣势,其一是收敛速度慢,其二是初始学习率的设置需要依靠大量的经验,然而如果初始学习率设置得当并且迭代轮数充足,该优化器也会在众多的优化器中脱颖而出,使得其在验证集上获得更高的准确率。一些自适应学习率的优化器如 Adam、RMSProp 等,收敛速度往往比较快,但是最终的收敛精度会稍差一些。如果追求更快的收敛速度,我们推荐使用这些自适应学习率的优化器,如果追求更高的收敛精度,我们推荐使用带 momentum 的 SGD 优化器。具体到数据集来说: + +- ImageNet-1k: 建议只使用带 momentum 的 SGD 优化器。 + +- 其他数据集(默认加载 ImageNet-1k 预训练): 加载预训练模型的时候可以考虑使用 Adam 等优化器(效果可能会更好),但使用带 momentum 的 SGD 优化器是绝对是比较不错的方案。 + +另外,为了进一步加速训练,Lookahead 优化器也是一个不错的选择,在 ImageNet-1k 上,其可以保证在更快的收敛速度下拥有相同的收敛精度,但在部分数据集上表现不太稳定,需要进一步调参。 + +### Q5.2 如何设置初始学习率以及学习率下降策略? + +**A**:学习率的选择往往和优化器以及数据和任务有关系。学习率决定了网络种权重更新的速度。学习率越低,损失函数的变化速度就越慢。虽然使用低学习率可以确保不会错过任何局部极小值,但也意味着将花费更长的时间来进行收敛,特别是在被困在高原区域的情况下。 + +在整个训练过程中,我们不能使用同样的学习率来更新权重,否则无法到达最优点,所以需要在训练过程中调整学习率的大小。在训练初始阶段,由于权重处于随机初始化的状态,损失函数下降较快,所以可以设置一个较大的学习率。在训练后期,由于权重已经接近最优值,较大的学习率无法进一步寻找最优值,所以需要设置一个较小的学习率。至于学习率下降策略,很多研究者或者从业人员使用的学习率下降方式是 piecewise_decay(step_decay),即阶梯式下降学习率,此外,很多研究者也提出了学习率的其他下降方式,如 polynomial_decay(多项式下降)、exponential_decay(指数下降),cosine_decay(余弦下降)等,其中 cosine_decay 无需调整超参数,鲁棒性也比较高,所以成为现在提高模型精度首选的学习率下降方式。 + +Cosine_decay 和 piecewise_decay 的学习率变化曲线如下图所示,容易观察到,在整个训练过程中,cosine_decay 都保持着较大的学习率,所以其收敛较为缓慢,但是最终的收敛效果较 peicewise_decay 更好一些。 + +![](../../images/models/lr_decay.jpeg) + +另外,从图中我们也可以看到,cosine_decay 中只有少数轮数使用了较小的学习率,这样会影响到最终的精度,所以为了使得 cosine_decay 发挥更好的效果,建议迭代更多的轮数。 + +最后,如果使用较大的 batch_size 训练神经网络时,建议您使用 warmup 策略。Warmup 策略顾名思义就是让学习率先预热一下,在训练初期不直接使用最大的学习率,而是用一个逐渐增大的学习率去训练网络,当学习率增大到最高点时,再去衰减学习率的值。实验表明,在 batch_size 较大时,warmup 可以稳定提升模型的精度。具体到数据集来说: + +- ImageNet-1k:建议 batch-size 大小为 256、初始学习率为 0.1,cosine-decay 下降学习率。 + +- 其他数据集(默认加载 ImageNet-1k 预训练): 数据集规模越大,初始学习率也越大,但最好不要超过 0.1(batch-size 为 256 时候),数据集规模越小,初始学习率也越小,当数据集较小时,使用 warmup 也会带来一定的精度提升,学习率下降策略仍旧推荐 cosine-decay。 + +### Q5.3 如何设置 batch-size 的大小? + +**A**:Batch_size 是训练神经网络中的一个重要的超参数,该值决定了一次将多少数据送入神经网络中训练。之前有研究者通过实验发现,当 batch_size 的值与学习率的值呈线性关系时,收敛精度几乎不受影响。在训练 ImageNet-1k 数据时,大部分的神经网络选择的初始学习率为 0.1,batch_size 是 256。具体到数据集来说: + +- ImageNet-1k: 学习率设置为 0.1\*k,batch_size 设置为 256\*k。 + +- 其他数据集(默认加载 ImageNet-1k 预训练): 可以根据实际情况设置(如更小的学习率),但在调整学习率或者 batch-size 时,要同时调整另外一个值。 + +### Q5.4 weight_decay 是什么?怎么设置? + +**A**:过拟合是机器学习中常见的一个名词,简单理解即为模型在训练数据上表现很好,但在测试数据上表现较差,在图像分类问题中,同样存在过拟合的问题,为了避免过拟合,很多正则方式被提出,其中,weight_decay 是其中一个广泛使用的避免过拟合的方式。当使用 SGD 优化器时,weight_decay 等价于在最终的损失函数后添加 L2 正则化,L2 正则化使得网络的权重倾向于选择更小的值,最终整个网络中的参数值更趋向于 0,模型的泛化性能相应提高。在各大深度学习框架的实现中,该值表达的含义是 L2 正则前的系数,在飞桨框架中,该值的名称是 L2Decay,所以以下都称其为 L2Decay。该系数越大,表示加入的正则越强,模型越趋于欠拟合状态。具体到数据集来说: + +- ImageNet-1k:大多数的网络将该参数值设置为 1e-4,在一些小的网络如 MobileNet 系列网络中,为了避免网络欠拟合,该值设置为 1e-5~4e-5 之间。下表展示了 MobileNetV1_x0_25 在 ImageNet-1k 上使用不同 L2Decay 的精度情况。由于 MobileNetV1_x0_25 是一个比较小的网络,所以 L2Decay 过大会使网络趋向于欠拟合状态,所以在该网络中,相对 1e-4,3e-5 是更好的选择。 + +| 模型 | L2Decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 1e-4 | 43.79%/67.61% | 50.41%/74.70% | +| MobileNetV1_x0_25 | 3e-5 | 47.38%/70.83% | 51.45%/75.45% | + +另外,该值的设置也和训练过程中是否使用其他正则化有关系。如果训练过程中的数据预处理比较复杂,相当于训练任务变的更难,可以将该值适当减小,下表展示了在 ImageNet-1k 上,ResNet50 在使用 RandAugment 预处理方式后使用不同 L2Decay 的精度。容易观察到,在任务变难后,使用更小的 l2_decay 有助于模型精度的提升。 + +| 模型 | L2Decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| ResNet50 | 1e-4 | 75.13%/90.42% | 77.65%/93.79% | +| ResNet50 | 7e-5 | 75.56%/90.55% | 78.04%/93.74% | + +- 其他数据集(默认加载 ImageNet-1k 预训练):在做迁移任务的时候,最好不要改变训练 ImageNet-1k 时的 L2Decay 的值(即训练得到预训练时的 L2Decay 值,每个 backbone 对应的 L2Decay 值都在相应的训练 yaml 配置文件中),一般的数据集只改变学习率足够。 + + +### Q5.5 是否使用 label_smoothing,如何设置其中的参数值? + +**A**:Label_smoothing 是深度学习中的一种正则化方法,其全称是 Label Smoothing Regularization(LSR),即标签平滑正则化。在传统的分类任务计算损失函数时,是将真实的 one hot 标签与神经网络的输出做相应的交叉熵计算,而 label_smoothing 是将真实的 one hot 标签做一个标签平滑的处理,使得网络学习的标签不再是一个 hard label,而是一个有概率值的 soft label,其中在类别对应的位置的概率最大,其他位置概率是一个非常小的数。在 label_smoothing 中,epsilon 参数描述了将标签软化的程度,该值越大,经过 label smoothing 后的标签向量的标签概率值越小,标签越平滑,反之,标签越趋向于 hard label。具体到数据集来说: + +- ImageNet-1k:在训练 ImageNet-1k 的实验里通常将该值设置为 0.1,ResNet50 大小级别及其以上的模型在使用 label_smooting 后,精度有稳定的提升。下表展示了 ResNet50_vd 在使用 label_smoothing 前后的精度指标。 + +| 模型 | Use_label_smoothing(0.1) | Test acc1 | +|:--:|:--:|:--:| +| ResNet50_vd | 0 | 77.9% | +| ResNet50_vd | 1 | 78.4% | + +同时,由于 label_smoohing 相当于一种正则方式,在相对较小的模型上,精度提升不明显甚至会有所下降,下表展示了 ResNet18 在 ImageNet-1k 上使用 label_smoothing 前后的精度指标。可以明显看到,在使用 label_smoothing 后,精度有所下降。 + +| 模型 | Use_label_smoohing(0.1) | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| ResNet18 | 0 | 69.81%/87.70% | 70.98%/89.92% | +| ResNet18 | 1 | 68.00%/86.56% | 70.81%/89.89% | + +如何在较小的模型中也可以让 label-smoothing 有效,这里有一个技巧,即在 Global-Average-Pool 后接一个 1000-2000 大小的全连接层,该技巧可以与 label-smoothing 同时作用,发挥更好的效果。 + +- 其他数据集(默认加载 ImageNet-1k 预训练):使用 label-smooth 之后往往都会提升精度,规模越小的数据集 epsilon 值可以越大,在一些规模较小的细粒度图像中,最佳模型通常是在该值设置到 0.4-0.5 时获得的。 + +### Q5.6 默认的图像预处理中 random-crop 还可以调整吗?怎么调整? + +**A**:在 ImageNet-1k 数据的标准预处理中,random_crop 函数中定义了 scale 和 ratio 两个值,两个值分别确定了图片 crop 的大小和图片的拉伸程度,其中 scale 的默认取值范围是 0.08-1(lower_scale-upper_scale),ratio 的默认取值范围是 3/4-4/3(lower_ratio-upper_ratio)。在非常小的网络训练中,此类数据增强会使得网络欠拟合,导致精度有所下降。为了提升网络的精度,可以使其数据增强变的更弱,即增大图片的 crop 区域或者减弱图片的拉伸变换程度。可以分别通过增大 lower_scale 的值或缩小 lower_ratio 与 upper_scale 的差距来实现更弱的图片变换。具体到数据集来说: + +- ImageNet-1k:不是特别小的网络建议只用默认值,特别小的网络可以调大 lower_scale 的值(增大 crop 区域面积)或者缩小 ratio 值的范围(减弱图像伸缩变换),特别大的网络可以调小 lower_scale 的值(减小 crop 面积)或者增大 ratio 值的范围(增强图像伸缩变换)。下表列出了使用不同 lower_scale 训练 MobileNetV2_x0_25 的精度,可以看到,增大图片的 crop 区域面积后训练精度和验证精度均有提升。 + +| 模型 | Scale 取值范围 | Train_acc1/acc5 | Test_acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV2_x0_25 | [0.08,1] | 50.36%/72.98% | 52.35%/75.65% | +| MobileNetV2_x0_25 | [0.2,1] | 54.39%/77.08% | 53.18%/76.14% | + +- 其他数据集(默认加载 ImageNet-1k 预训练):建议使用默认值,如果过拟合较严重,可以考虑调小 lower_scale 的值(减小 crop 面积)或者增大 ratio 值的范围(增强图像伸缩变换)。 + +### Q5.7 目前常用数据增广有哪些?如何选择? + +**A**:一般来说,数据集的规模对性能影响至关重要,但是图片的标注往往比较昂贵,所以有标注的图片数量往往比较稀少,在这种情况下,数据的增广尤为重要。在训练 ImageNet-1k 的标准数据增广中,主要使用了 Random_Crop 与 Random_Flip 两种数据增广方式,然而,近些年,越来越多的数据增广方式被提出,如 cutout、mixup、cutmix、AutoAugment 等。实验表明,这些数据的增广方式可以有效提升模型的精度。具体到数据集来说: + +- ImageNet-1k:下表列出了 ResNet50 在 8 种不同的数据增广方式的表现,可以看出,相比 baseline,所有的数据增广方式均有收益,其中 cutmix 是目前最有效的数据增广。更多数据增广的介绍请参考[**数据增广章节**](../advanced_tutorials/DataAugmentation.md)。 + +| 模型 | 数据增广方式 | Test top-1 | +|:--:|:--:|:--:| +| ResNet50 | 标准变换 | 77.31% | +| ResNet50 | Auto-Augment | 77.95% | +| ResNet50 | Mixup | 78.28% | +| ResNet50 | Cutmix | 78.39% | +| ResNet50 | Cutout | 78.01% | +| ResNet50 | Gridmask | 77.85% | +| ResNet50 | Random-Augment | 77.70% | +| ResNet50 | Random-Erasing | 77.91% | +| ResNet50 | Hide-and-Seek | 77.43% | + +- 其他数据集(默认加载 ImageNet-1k 预训练):在其他数据集中除了使用 Auto-Augment,一般都会有精度的提升,Auto-Augment 会针对每一个数据集搜索的独立超参数,该超参数决定了数据如何处理,所以默认的 ImageNet-1k 的超参数并不适合所有的数据集,当然您可以使用 Random-Augment 来替代 Auto-Augment。其他策略可以正常使用,对于比较难的任务或者比较小的网络,建议不要使用较强的数据增广。 + +此外,多种数据增广也可以叠加使用,当数据集较为简单或数据规模较小时,叠加数据增广可以进一步提升精度。 + +### Q5.8 如何通过 train_acc 和 test_acc 确定调优策略? + +**A**:在训练网络的过程中,通常会打印每一个 epoch 的训练集准确率和验证集准确率,二者刻画了该模型在两个数据集上的表现。通常来说,训练集的准确率反映了经过 Random-Crop 后的数据的精度,由于数据经过 Random-Crop 后,数据往往较难,所以训练集的准确率和验证集的准确率往往不是一个概念。 + +- ImageNet-1k:通常来说,训练集准确率比验证集准确率微高或者二者相当是比较不错的状态。如果发现训练集的准确率比验证集高很多,说明在这个任务上已经过拟合,需要在训练过程中加入更多的正则,如增大 L2Decay 的值,加入更多的数据增广策略,加入 label_smoothing 策略等;如果发现训练集的准确率比验证集低一些,说明在这个任务上可能欠拟合,需要在训练过程中减弱正则效果,如减小 L2Decay 的值,减少数据增广方式,增大图片 crop 区域面积,减弱图片拉伸变换,去除 label_smoothing 等。 + +- 其他数据集(默认加载 ImageNet-1k 预训练):基本和训练 ImageNet-1k 的调整策略相当,此外,在其他数据集上如果模型趋向于过拟合(train acc 远大于 test acc)状态,也可以使用更优的预训练权重,PaddleClas 为常用的网络提供了 SSLD 的蒸馏预训练权重,其比 ImageNet-1k 的权重更优,您可以优先选择。 + +- **【备注】** 不太建议根据 loss 来重新调整训练策略,在使用不同的数据增广后,train loss 的大小差异较大,如使用 Cutmix 或者 RandAugment 后,train loss 会大于 test loss,当数据增广策略减弱后,train loss 会小于 test loss,所以较难调整。 + +### Q5.9 如何通过预训练模型提升自己的数据集的精度? + +**A**:在现阶段图像识别领域中,加载预训练模型来训练自己的任务已成为普遍的做法,相比从随机初始化开始训练,加载预训练模型往往可以提升特定任务的精度。一般来说,业界广泛使用的预训练模型是通过训练 128 万张图片 1000 类的 ImageNet-1k 数据集得到的,该预训练模型的 fc 层权重是是一个 k\*1000 的矩阵,其中 k 是 fc 层以前的神经元数,在加载预训练权重时,无需加载 fc 层的权重。在学习率方面,如果您的任务训练的数据集特别小(如小于 1 千张),我们建议你使用较小的初始学习率,如 0.001(batch_size:256,下同),以免较大的学习率破坏预训练权重。如果您的训练数据集规模相对较大(大于 10 万),我们建议你尝试更大的初始学习率,如 0.01 或者更大。如果目标数据集较小,也可以冻结一些浅层的权重。此外,如果训练一个特定垂类的小数据集,也可以先在相关的大的数据集上训练一个预训练权重,再在该权重上用较小的学习率微调模型。 + +### Q5.10 现有的策略已经让模型的精度趋于饱和,如何进一步提升特定模型的精度? + +**A**:如果现有的策略不能进一步提升模型的精度,说明在现有数据集和现有的策略下,模型几乎到达饱和状态,这里提供两种进一步提升模型精度的方法。 + +- 挖掘相关数据:用在现有数据集上训练饱和的模型去对相关的数据做预测,将置信度较高的数据打 label 后加入训练集进一步训练,如此循环操作,可进一步提升模型的精度。 + +- 知识蒸馏:可以先使用一个较大的模型在该数据集上训练一个精度较高的 teacher model,然后使用该 teacher model 去教导一个 Student model,其中,Student model 即为目标模型。PaddleClas 提供了百度自研的 SSLD 知识蒸馏方案,即使在 ImageNet-1k 这么有挑战的分类任务上,其也能稳定提升 3% 以上。SSLD 知识蒸馏的的章节请参考 [**SSLD 知识蒸馏**](../advanced_tutorials/knowledge_distillation.md)。 + + + +## 第 6 期 + +### Q6.1: PaddleClas 的几个分支有什么区别?应该如何选择? + +**A**: PaddleClas 目前共有 3 种分支: + +* 开发分支:develop 分支是 PaddleClas 的开发分支,也是更新最快的分支。所有的新功能、新改动都会先在 develop 分支上进行。如果想追踪 PaddleClas 的最新进展,可以关注这个分支。这个分支主要支持动态图,会跟着 paddlepaddle 的版本一起更新。 + +* 稳定版本分支(如 release/2.1.3):快速更新能够让关注者了解最新进展,但也会带来不稳定性。因此在一些关键的时间点,我们会从 develop 分支中拉出分支,提供稳定的版本,最新的稳定版分支也是默认分支。需要注意,无特殊情况,我们只会维护最新的 release 稳定分支,并且一般只会修复 bug,而不更新新的特性和模型。 + +* 静态图分支(static):static 分支是使用静态图版本的分支,主要用来支持一些老用户的使用,也只进行一些简单维护,不会更新新的特性和模型。不建议新用户使用静态图分支。老用户如果有条件,也建议迁到动态图分支或稳定版本分支。 + +总的来说,如果想跟进 PaddleClas 的最新进展,建议选择 develop 分支,如果需要稳定版本,建议选择最新的稳定版本分支。 + +### Q6.2: 什么是静态图模式? + +**A**: 静态图模式即为声明式编程模式。许多深度学习框架如 tensorflow,mxnet 等最初都使用这种模式。在静态图模式中,需要先定义好模型结构,之后框架会根据模型结构进行编译和优化,构建"计算图"。可以简单的理解为,静态图模式是"计算图"静态不变的模式。静态图的优势在于编译器一般只需要构建一次计算图,效率相对较高,缺点在于不够灵活,调试麻烦。例如在 paddle 中运行一次静态图模型,需要完整所有的运算,之后根据特定的 key 来提取输出,无法实时得到结果。 + +### Q6.3: 什么是动态图模式? + +**A**: 动态图模式即为命令式编程模式,用户无需预先定义网络结构,每行代码都可以直接运行得到结果。相比静态图模式,动态图模式对用户更加友好,调试也更方便。此外,动态图模式的结构设计也更加灵活,可以在运行过程中随时调整结构。 + +PaddleClas 目前持续更新的 develop 分支和稳定版本的 release 分支,主要采用动态图模式。如果您是新用户,建议使用动态图模式来进行开发和训练。如果推理预测时有性能需求,可以在训练完成后,将动态图模型转为静态图模型提高效率。 + +### Q6.5: 构建分类数据集时,如何构建"背景"类别的数据? + +**A**: 实际使用中,常常需要自己构建一个分类数据集来进行训练。除了所需要的类别数据之外,还需要一个额外的类别,即"背景"类别。例如做一个猫狗分类,猫为一类,狗为一类,如果我们的分类器只有两类,那么输入一张兔子的图片,也会被强制的分到这两个类别中的一个。因此在训练时,应添加一些非目标类别的数据,作为"背景"类别的数据。 + +构建"背景"类别的数据时,首先应从实际需求的角度出发。还是以猫狗分类器为例,如果实际测试的数据都是动物,那么"背景"类别的数据就应该包含一些除猫狗之外的动物。而如果测试的数据还包含更多类别,例如一棵树,那么"背景"类别的数据就要设置的更加丰富。 +简单来说,"背景"类别的数据,要根据实际场景中可能出现的情况去收集。情况越多,需要涵盖的数据种类就越多,任务也会相应的越困难。因此实际处理中,最好能对问题进行限制,避免浪费资源和算力。 diff --git a/src/PaddleClas/docs/zh_CN/faq_series/faq_2021_s1.md b/src/PaddleClas/docs/zh_CN/faq_series/faq_2021_s1.md new file mode 100644 index 0000000..cc60bf5 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/faq_series/faq_2021_s1.md @@ -0,0 +1,251 @@ +# 图像分类常见问题汇总 - 2021 第 1 季 + + +## 目录 +* [1. 第 1 期](#1)(2021.01.05) +* [2. 第 2 期](#2)(2021.01.14) +* [3. 第 3 期](#3)(2020.01.21) +* [4. 第 4 期](#4)(2021.01.28) +* [5. 第 5 期](#5)(2021.02.03) + + +## 第 1 期 + +### Q1.1: 在模型导出时,发现导出的 inference model 预测精度很低,这块是为什么呢? + +**A**:可以从以下几个方面排查 + +* 需要先排查下预训练模型路径是否正确。 +* 模型导出时,默认的类别数为 1000,如果预训练模型是自定义的类别数,则在导出的时候需要指定参数 `--class_num=k`,k 是自定义的类别数。 +* 可以对比下 `tools/infer/infer.py` 和 `tools/infer/predict.py` 针对相同输入的输出 class id 与 score,如果完全相同,则可能是预训练模型自身的精度很差。 + +### Q1.2: 训练样本的类别不均衡,这个该怎么处理呢? + +**A**:有以下几种比较常用的处理方法。 + +* 从采样的角度出发的话 + * 可以对样本根据类别进行动态采样,每个类别都设置不同的采样概率,保证不同类别的图片在同一个 minibatch 或者同一个 epoch 内,不同类别的训练样本数量基本一致或者符合自己期望的比例。 + * 可以使用过采样的方法,对图片数量较少的类别进行过采样。 +* 从损失函数的角度出发的话 + * 可以使用 OHEM(online hard example miniing)的方法,对根据样本的 loss 进行筛选,筛选出 hard example 用于模型的梯度反传和参数更新。 + * 可以使用 Focal loss 的方法,对一些比较容易的样本的 loss 赋予较小的权重,对于难样本的 loss 赋予较大的权重,从而让容易样本的 loss 对网络整体的 loss 有贡献,但是又不会主导 loss。 + + +### Q1.3 在 docker 中训练的时候,数据路径和配置均没问题,但是一直报错 `SystemError: (Fatal) Blocking queue is killed because the data reader raises an exception`,这是为什么呢? + +**A**:这可能是因为 docker 中共享内存太小导致的。创建 docker 的时候,`/dev/shm` 的默认大小为 64M,如果使用多进程读取数据,共享内存可能不够,因此需要给 `/dev/shm` 分配更大的空间,在创建 docker 的时候,传入 `--shm-size=8g` 表示给 `/dev/shm` 分配 8G 的空间,一般是够用的。 + + +### Q1.4 PaddleClas 提供的 10W 类图像分类预训练模型在哪里下载,应该怎么使用呢? + +**A**:基于 ResNet50_vd, 百度开源了自研的大规模分类预训练模型,其中训练数据为 10 万个类别,4300 万张图片。10 万类预训练模型的下载地址:[下载地址](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_10w_pretrained.tar),在这里需要注意的是,该预训练模型没有提供最后的 FC 层参数,因此无法直接拿来预测;但是可以使用它作为预训练模型,在自己的数据集上进行微调。经过验证,该预训练模型相比于基于 ImageNet1k 数据集的 ResNet50_vd 预训练模型,在不同的数据集上均有比较明显的精度收益,最多可达 30%。 + + + + +### Q1.5 使用 C++ 进行预测部署的时候怎么进行加速呢? + +**A**:可以从以下几个方面加速预测过程。 + +1. 如果是 CPU 预测的话,可以开启 mkldnn 进行预测,同时适当增大运算的线程数(cpu_math_library_num_threads,在 `tools/config.txt` 中),一般设置为 6~10 比较有效。 +2. 如果是 GPU 预测的话,在硬件条件允许的情况下,可以开启 TensorRT 预测以及 FP16 预测,这可以进一步加快预测速度。 +3. 在内存或者显存足够的情况下,可以增大预测的 batch size。 +4. 可以将图像预处理的逻辑(主要设计 resize、crop、normalize 等)放在 GPU 上运行,这可以进一步加速预测过程。 + +更多的预测部署加速技巧,也欢迎大家补充。 + + +## 第 2 期 + +### Q2.1: PaddleClas 在设置标签的时候必须从 0 开始吗?class_num 必须等于数据集的类别数吗? + +**A**:在 PaddleClas 中,标签默认是从 0 开始,所以,尽量从 0 开始设置标签,当然,从其他值开始设置也可以,这样会导致设置的 class_num 增大,进而导致分类的 FC 层参数量较大,权重文件会占用更多的存储空间。在数据集类别连续的情况下,设置的 class_num 要等于数据集类别数(当然大于数据集类别数也可以,在很多数据集上甚至可以获得更高的精度,但同样会使 FC 层参数量较大),在数据集类别数不连续的情况下,设置的 class_num 要等于数据集中最大的 class_id+1。 + +### Q2.2: 当类别数特别多的时候,最后的 FC 特别大,导致权重文件占用较大的存储空间,该怎么解决? + +**A**:最终的 FC 的权重是一个大的矩阵,大小为 C*class_num,其中 C 为 FC 前一层的神经单元个数,如 ResNet50 中的 C 为 2048,可以通过降低 C 的值来进一步减小 FC 权重的大小,比如,可以在 GAP 之后加一层维数较小的 FC 层,这样可以大大缩小最终分类层的权重大小。 + +### Q2.3: 为什么使用 PaddleClas 在自定义的数据集上训练 ssld 蒸馏没有达到预期? + +首先,需要确保 Teacher 模型的精度是否存在问题,其次,需要确保 Student 模型是否成功加载了 ImageNet-1k 的预训练权重以及 Teacher 模型是否成功加载了训练自定义数据集的权重,最后,要确保初次学习率不应太大,至少保证初始学习率不要超过训练 ImageNet-1k 的值。 + +### Q2.4: 移动端或嵌入式端上哪些网络具有优势? + +建议使用移动端系列的网络,网络详情可以参考[移动端系列网络结构介绍](../models/Mobile.md)。如果任务的速度更重要,可以考虑 MobileNetV3 系列,如果模型大小更重要,可以根据移动端系列网络结构介绍中的 StorageSize-Accuracy 来确定具体的结构。 + +### Q2.5: 既然移动端网络非常快,为什么还要使用诸如 ResNet 这样参数量和计算量较大的网络? + +不同的网络结构在不同的设备上运行速度优势不同。在移动端,移动端系列的网络比服务器端的网络运行速度更快,但是在服务器端,相同精度下,ResNet 等经过特定优化后的网络具有更大的优势,所以需要根据具体情况来选择具体的网络结构。 + + +## 第 3 期 + +### Q3.1: 双(多)分支结构与 Plain 结构,各自有什么特点? + +**A**: +以 VGG 为代表的 Plain 网络,发展到以 ResNet 系列(带有残差模块)、Inception 系列(多卷积核并行)为代表的的多分支网络结构,人们发现多分支结构在模型训练阶段更为友好,更大的网络宽度可以带来更强的特征拟合能力,而残差结构则可以避免深度网络梯度消失的问题,但是在推理阶段,带有多分支结构的模型在速度上并无优势,即使多分支结构模型的 FLOPs 要更低,但多分支结构的模型计算密度也更低。例如 VGG16 模型的 FLOPs 远远大于 EfficientNetB3,但是 VGG16 模型的推理速度却显著快于 EfficientNetB3,因此多分支结构在模型训练阶段更为友好,而 Plain 结构模型则更适合于推理阶段,那么以此为出发点,可以在训练阶段使用多分支网络结构,以更大的训练时间成本换取特征拟合能力更强的模型,而在推理阶段,将多分支结构转为 Plain 结构,从而换取更短的推理时间。实现多分支结构到 Plain 结构的转换,可以通过结构重参数化(structural re-parameterization)技术实现。 + +另外,Plain 结构对于剪枝操作也更为友好。 + +注:“Plain 结构”与“结构重参数化(structural re-parameterization)技术”出自论文“RepVGG: Making VGG-style ConvNets Great Again”。Plain 结构网络模型指整个网络不存在分支结构,也即网络中第 `i` 层 layer 的输入为第 `i-1` 层 layer 的输出,第 `i` 层 layer 的输出为第 `i+1` 层 layer 的输入。 + +### Q3.2: ACNet 的创新点主要在哪里? +**A**: +ACNet 意为“Asymmetric Convolution Block”,即为非对称卷积模块,该思想出自论文“ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks”,文章提出了以“ACB”结构的三个 CNN 卷积核为一组,用来在训练阶段替代现有卷积神经网络中的传统方形卷积核。 + +方形卷积核的尺寸为假设为 `d*d`,即宽、高相等均为 `d`,则用于替换该卷积核的 ACB 结构是尺寸为 `d*d`、`1*d`、`d*1` 的三个卷积核,然后再将三个卷积核的输出直接相加,可以得到与原有方形卷积核相同尺寸的计算结果。 +而在训练完成后,将 ACB 结构换回原有的方形卷积核,方形卷积核的参数则为 ACB 结构的三个卷积核的参数直接相加(见 `Q3.4`,因此还是使用与之前相同的模型结构用于推理,ACB 结构只是在训练阶段使用。 + +在训练中,通过 ACB 结构,模型的网络宽度得到了提高,利用 `1*d`、`d*1` 的两个非对称卷积核提取得到更多的特征用于丰富 `d*d` 卷积核提取的特征图的信息。而在推理阶段,这种设计思想并没有带来额外的参数与计算开销。如下图所示,分别是用于训练阶段和部署推理阶段的卷积核形式。 + +![](../../images/faq/TrainingtimeACNet.png) + +![](../../images/faq/DeployedACNet.png) + +文章作者的实验表明,通过在原有网络模型训练中使用 ACNet 结构可以显著提高模型能力,原作者对此有如下解释: + +1. 实验表明,对于一个 `d*d` 的卷积核,相对于消除卷积核角落位置(如上图中卷积核的 `corners` 位置)的参数而言,消除骨架位置(如上图中卷积核的 `skeleton` 位置)的参数会给模型精度带来更大的影响,因此卷积核骨架位置的参数要更为重要,而 ACB 结构中的两个非对称卷积核增强了方形卷积核骨架位置参数的权重,使之作用更为显著。这种相加是否会因正负数抵消作用而减弱骨架位置的参数作用,作者通过实验发现,网络的训练总是会向着提高骨架位置参数作用的方向发展,并没有出现正负数抵消而减弱的现象。 +2. 非对称卷积核对于翻转的图像具有更强的鲁棒性,如下图所示,水平的非对称卷积核对于上下翻转的图像具有更强的鲁棒性。对于翻转前后图像中语义上的同一位置,非对称卷积核提取的特征图是相同的,这一点要强于方形卷积核。 + +![](../../images/faq/HorizontalKernel.png) + +### Q3.3: RepVGG 的创新点主要在哪里? + +**A**: +通过 Q3.1 与 Q3.2,我们可以大胆想到,是否可以借鉴 ACNet 将训练阶段与推理阶段解耦,并且训练阶段使用多分支结构,推理阶段使用 Plain 结构,这也就是 RepVGG 的创新点。下图为 ResNet、RepVGG 训练和推理阶段网络结构的对比。 + +![](../../images/faq/RepVGG.png) + +首先训练阶段的 RepVGG 采用多分支结构,可以看作是在传统 VGG 网络的基础上,增加了 `1*1` 卷积和恒等映射的残差结构,而推理阶段的 RepVGG 则退化为 VGG 结构。训练阶段 RepVGG 到推理阶段 RepVGG 的网络结构转换使用“结构重参数化”技术实现。 + +对于恒等映射,可将其视为参数均为 `1` 的 `1*1` 卷积核作用在输入特征图的输出结果,因此训练阶段的 RepVGG 的卷积模块可以视为两个 `1*1` 卷积和一个 `3*3` 卷积,而 `1*1` 卷积的参数又可以直接相加到 `3*3` 卷积核中心位置的参数上(该操作类似于 ACNet 中,非对称卷积核参数相加到方形卷积核骨架位置参数的操作),通过上述操作,即可在推理阶段,将网络结构中的恒等映射、`1*1 `卷积、`3*3` 卷积三个分支合并为一个 `3*3` 卷积,详见 `Q3.4`。 + +### Q3.4: ACNet 与 RepVGG 中的 struct re-parameters 有何异同? + +**A**: +通过上面的了解,可以简单理解 RepVGG 是更为极端的 ACNet。ACNet 中的 re-parameters 操作如下图所示: + +![](../../images/faq/ACNetReParams.png) + +观察上图,以其中的 `conv2` 为例,该非对称卷积可以视为 `3*3` 的方形卷积核,只不过该方形卷积核的上下六个参数为 `0`,`conv3` 同理。并且,`conv1`、`conv2`、`conv3` 的结果相加,等同于三个卷积核相加再做卷积,以 `Conv` 表示卷积操作,`+`表示矩阵的加法操作,则:`Conv1(A)+Conv2(A)+Conv3(A) == Convk(A)`,其中 `Conv1`、`Conv2`、`Conv3` 的卷积核分别为 `Kernel1`、`kernel2`、`kernel3`,而 `Convk` 的卷积核为 `Kernel1 + kernel2 + kernel3`。 + +RepVGG 网络与 ACNet 同理,只不过 ACNet 的 `1*d` 非对称卷积变成了 `1*1` 卷积,`1*1` 卷积相加的位置变成了 `3*3` 卷积的中心。 + +### Q3.5: 影响模型计算速度的因素都有哪些?参数量越大的模型计算速度一定更慢吗? + +**A**: +影响模型计算速度的因素有很多,参数量只是其中之一。具体来说,在不考虑硬件差异的前提下,模型的计算速度可以参考以下几个方面: +1. 参数量:用于衡量模型的参数数量,模型的参数量越大,模型在计算时对内存(显存)的容量要求一般也更高。但内存(显存)占用大小不完全取决于参数量。如下图中,假设输入特征图内存占用大小为 `1` 个单位,对于左侧的残差结构而言,由于需要记录两个分支的运算结果,然后再相加,因此该结构在计算时的内存峰值占用是右侧 Plain 结构的两倍。 + +![](../../images/faq/MemoryOccupation.png) + +2. 浮点运算数量(FLOPs):注意与每秒浮点运算次数(FLOPS)相区分。FLOPs 可以简单理解为计算量,通常用来衡量一个模型的计算复杂度。 +以常见的卷积操作为例,在不考虑 batch size、激活函数、stride 操作、bias 的前提下,假设 input future map 尺寸为 `Min*Min`,通道数为 `Cin`,output future map 尺寸为 `Mout*Mout`,通道数为 `Cout`,conv kernel 尺寸为 `K*K`,则进行一次卷积的 FLOPs 可以通过下述方式计算: + 1. 输出特征图包含特征点的数量为:`Cout * Mout * Mout`; + 2. 对于输出特征图中的每一个特征点的卷积操作而言: + 乘法计算数量为:`Cin * K * K`; + 加法计算数量为:`Cin * K * K - 1`; + 3. 因此计算总量为:`Cout * Mout * Mout * (Cin * K * K + Cin * K * K - 1)`,也即 `Cout * Mout * Mout * (2Cin * K * K - 1)`。 +3. Memory Access Cost(MAC):内存访问成本,由于计算机在对数据进行运算(例如乘法、加法)前,需要将运算的数据从内存(此处泛指内存,包括显存)读取到运算器的 Cache 中,而内存的访问是十分耗时的。以分组卷积为例,假设分为 `g` 组,虽然分组后模型的参数量和 FLOPs 没有变化,但是分组卷积的内存访问次数成为之前的 `g` 倍(此处只是简单计算,未考虑多级 Cache),因此 MAC 显著提高,模型的计算速度也相应变慢。 +4. 并行度:常说的并行度包括数据并行和模型并行两部分,此处是指模型并行。以卷积操作为例,一个卷积层的参数量通常十分庞大,如果将卷积层中的矩阵做分块处理,然后分别交由多个 GPU 进行运算,即可达到加速的目的。甚至有的网络层参数量过大,单张 GPU 显存无法容纳时,也可能将该层分由多个 GPU 计算,但是能否分由多个 GPU 并行运算,不仅取决于硬件条件,也受特定的运算形式所限制。当然,并行度越高的模型,其运行速度也越快。 + + + +## 第 4 期 + +### Q4.1: 图像分类任务中,有一部分合成数据,这一部分合成数据是否需要使用样本均衡? + +**A**: + +1. 不同类别的样本数如果差异过大,某类样本因合成数据集扩充至其他类的数倍以上,需要做适当减小该类的权值。 +2. 如果是有的类别是合成而有的类别半合成半真实,只要数量在一个量级可不做均衡,并尝试训练一下,测试该合成类别样本是否能够准确识别。 +3. 如果不同来源数据的类别因合成数据增大问题,造成性能衰减,需要考虑合成数据集是否有噪声或者难例样本,也可适当增加该类别权重,获得该类别更好的识别性能。 + +### Q4.2: 学术界将 Vision Transformer(ViT)引入图像分类领域,将对图像分类带来什么新的机遇和挑战?相比于 CNN 的优势? + +论文地址[AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE](https://openreview.net/pdf?id=YicbFdNTTy) + +**A**: +1. 图像对 CNN 的依赖是不必要的,利用 Transformer 的计算效率和可伸缩性,可以训练很大模型,当模型和数据集增大的情形下,仍然不会存在饱和的情况。受到 Transformer 在 NLP 上的启发,在图像分类任务中使用时,将图片分成顺序排列的 patches,并将这些 patches 输入一个线性单元嵌入到 embedding 作为 transformer 的输入。 + +2. 在中等规模数据集中如 ImageNet1k,ImageNet21k,视觉 Transformer 模型低于相同规模尺寸的 ResNet 几个百分点。猜测这是因为 transformer 缺少 CNN 所具有的局部性(Locality)和空间不变性(Spatial Invariance)的特点,而在数据量不够大的时候,难以超越卷积网络,不过对于这一问题,[DeiT](https://arxiv.org/abs/2012.12877) 使用数据增强的方式在一定程度上解决了 Vision Transformer 依赖超大规模数据集训练的问题。 + +3. 在超大规模数据集 14M-300M 训练时,这种方式可以越过局部信息,建模更加长距离的依赖关系,而 CNN 能较好关注局部信息全局信息捕获能力较弱。 + +4. Transformer 一度在 NLP 领域一统江湖,也一度被质疑不适用于 CV 领域,当前出来的几片视觉领域的文章,性能也是直逼 CNN 的 SOTA。相信在未来能够提出 Vision-Language 联合或者多模态的模型,能够一并解决视觉和语言问题。 + + +### Q4.3: 对于 Vision Transformer 模型,是如何将图像转换成序列信息传给 Encoder? + +**A**: + +1. 使用 Transformer 模型,主要是使用其中的注意力方法。我们希望构想一个适用语义 embedding 信息的场景,但是图像分类与序列的语义信息关联性不大,因此 Vision Transformer 有其独特的设计。ViT 的目标也正是希望使用注意力机制来代替 CNN。 + +2. 考虑 Transformer 中 Encoder 编码器的输入形式,如下图: + * (1)不定长度的顺序输入,因为它是 RNN 结构,一句话,单词数不一样。如果是 NLP 场景,换词的顺序不太过于影响语义,但是图像换了不同区域的位置,不同区域连接顺序不同,将造成极大理解偏差。 + * (2)单个 patch 位置信息通过变换成一个维度固定的向量,Encoder 输入是 patch 像素信息 embedding,与一些固定位置的向量 concate,合成一个维度固定的向量和位置信息在其中。 + +![](../../images/faq/Transformer_input.png) + +3. 考虑以下问题:怎样将一张图片传给 encoder? + +* 如下图所示。假设输入图片是[224,224,3],按照顺序从左到右,从上到下,切分成很多个 patch,patch 大小可以为[p,p,3](p 取值可以是 16,32),对其使用 Linear Projection of Flattened Patches 模块转成特征向量,并 concat 一个位置向量,传入 Encoder 中。 + +![](../../images/faq/ViT_structure.png) + +4. 如上图,给定一个 `H×W×C` 的图像以及区块大小 P,可以把图像划分为 `N` 个 `P×P×C` 的区块,`N=H×W/(P×P)`。得到区块后要使用线性变换转为 D 维特征向量,再加上位置编码向量即可。和 BERT 类似,ViT 在序列之前也加入了一个分类标志位,记为 `[CLS]`。ViT 输入序列 `z` 如下面的公式所示,其中 `x` 表示一个图像区块。 + +![](../../images/faq/ViT.png) + +5. ViT 模型和 Transformer 基本一样,输入序列传入 ViT,然后利用 `[CLS]` 标志位的最终输出特征进行分类。ViT 主要由 MSA(多头自注意力)和 MLP(两层使用 GELU 激活函数的全连接网络)组成,在 MSA 和 MLP 之前加上 LayerNorm 和残差连接。 + +### Q4.4: 如何理解归纳偏置 Inductive Bias? + +**A**: +1. 在机器学习中,会对算需要应用的问题做一些假设,这个假设就称为归纳偏好。在现实生活中观察得到的现象中归纳出一定的先验规则,然后对模型做一定的约束,从而起到模型选择的作用。在 CNN 中,假设特征具有局部性(Locality)和空间不变性(Spatial Invariance)的特点,即把相邻的特征有联系而远离的没有,将相邻特征融合在一起,更会容易产生“解”;还有 attention 机制,也是从人的直觉、生活经验归纳的规则。 + +2. Vision Transformer 利用的归纳偏置是有序列能力 Sequentiality 和时间不变性 Time Invariance,即序列顺序上的时间间隔的联系,因此也能得出在更大规模数据集上比 CNN 类的模型有更好的性能。文章 Conclusion 里的“Unlike prior works using self-attention in computer vision, we do not introduce any image-specific inductive biases into the architecture”和 Introduction 里的“We find that large scale training trumps inductive bias”,可以得出直观上 inductive bias 在大量数据的情况中的产生是衰减性能,应该尽可能丢弃。 + +### Q4.5: ViT 为什么要增加一个[CLS]标志位? 为什么将[CLS]标志位对应的向量作为整个序列的语义表示? + +**A**: +1. 和 BERT 相类似,ViT 在第一个 patch 前添加一个`[CLS]`标志位,最后一个结束标志位对应的向量可以作为整个图像的语义表示,从而用于下游的分类任务等。从而使得整个 embedding 组可以表征该图像不同位置的特征。 + +2. 将 `[CLS]` 标志位对应的向量作为整个图像的语义表示,是因为与图像中已有的其它 patch 块图像相比,这个无明显语义信息的符号会更“公平”地融合图像中各个 patch 的语义信息,从而更好的表示整个图像的语义。 + + +## 第 5 期 + +### Q5.1: PaddleClas 训练配置文件中都包含了哪些内容?训练模型时如何进行修改? +**A**: +PaddleClas 的模型包含 6 大模块的配置,分别为:全局配置,网络结构(ARCHITECTURE),学习率(LEARNING_RATE),优化器(OPTIMIZER),训练(TRAIN)和验证(VALID)。 + +全局配置主要包含了任务的配置信息,例如类别的数量,训练集内的数据量,训练的 epoch 数量,网络输入的尺寸等等。如果要训练自定义的任务,或是使用自己的训练集,需要关注这个部分。 + +网络结构的配置定义了要使用的网络。在实际使用时,首先要选择合适的配置文件,所以通常不会修改这部分配置。只有在自定义网络结构,或者对任务有特殊要求时才进行修改。 + +学习率和优化器的配置建议优先使用默认配置,这些参数是我们已经调过的。如果任务的改动比较大,也可以做微调。 + +训练和预测两个配置包含了 batch_size,数据集,数据预处理(transforms),读数据进程数(num_workers)等比较重要的配置,这部分要根据实际环境适度修改。要注意的是,paddleclas 中的 batch_size 是单卡配置,如果是多卡训练,则总的 batch_size 是配置文件中所设置的倍数,例如配置文件中设置 batch_size 为 64,4 卡训练,总 batch_size 也就是 4*64=256。而 num_workers 定义的是单卡的进程数,即如果 num_workers 是 8,并且使用 4 卡训练,则实际有 32 个 worker. + +### Q5.2: 如何在命令行中快速的修改配置? +**A**: +在训练中,我们常常需要对个别配置不断进行微调,而不希望频繁的修改配置文件。这时可以使用 -o 来调整,修改是要先按层级写出要改的配置名称,层级之间用点分割,再写出要修改的值。例如我们想要修改 batch_size,可以在训练的命令后加上-o DataLoader.TRAIN.sampler.batch_size=512。 + +### Q5.3: 如何根据 PaddleClas 的精度曲线选择合适的模型? +**A**: +PaddleClas 提供了多个模型的 benchmark,并绘制了性能曲线,主要有三种:准确率-预测时间曲线,准确率-参数量曲线和准确率-FLOPS 曲线,纵轴为准确率,横轴分别为预测时间、参数量、FLOPS。一般来说,不同模型在三个图上的表现是一致的。同一个系列的模型在图上采用相同的符号来表示,并且用曲线连接。 + +以准确率-预测时间曲线为例,点越靠上表明准确率越高,约靠左表明速度越快。例如左上区域的模型为又快又准的模型,而最左侧贴近纵轴的点则为轻量级的模型。使用时,可以综合考虑准确率和时间因素,选择合适的模型。举个例子,我们希望模型的运行时间在 10ms 以下,选择最准确的模型。首先,在横轴的 10ms 出画一条垂直的线,之后在这条线的左侧找到最高的点,就是符合要求的模型。 + +实际使用中,模型的参数量和 FLOPS 是稳定不变的,而运算时间在不同的软硬件条件下均会有所变化。如果想更准确的选择模型,那么可以在自己的环境中运行测试,得到该环境下的性能图。 + +### Q5.4: 想在 imagenet 中增加两个类,能不能把现有全连接层的参数固定,只训练新的两个类别? +**A**: +这个想法理论上可行,但效果恐怕不会太好。如果只是固定全连接层,而前面的卷积层参数发生了变化,那么这些全连接层的作用也无法保证与开始一样。而如果保持整个网络的参数都不变,只训练全连接层的新增两个类别,也比较难训练处理想的结果。 + +如果实际使用中确实需要原有的 1000 个类别依然很准确,那么可以将新类别的数据加入到原有训练集中,再用预训练模型进行 finetune。如果只需要 1000 个类中的几个类别,那么可以把这部分的数据挑出来,和新增数据混合再 finetune。 + +### Q5.5: 使用分类模型做其他任务的预训练模型时,应该选择哪些层作为 feature? +**A**: +使用分类模型做其他任务的 backbone 有很多策略,这里介绍一种较为基础的方法。首先,去掉最后的全连接层,这一层主要包含的是原始任务的分类信息。如果任务比较简单,只要将前一层的输出作为 featuremap,并在此基础上添加与任务对应的结构即可。如果任务涉及多尺度,需要选取不同尺度的 anchor,例如某些检测模型,那么可以选取每次下采样之前一层的输出作为 featuremap。 diff --git a/src/PaddleClas/docs/zh_CN/faq_series/faq_2021_s2.md b/src/PaddleClas/docs/zh_CN/faq_series/faq_2021_s2.md new file mode 100644 index 0000000..38b9d2d --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/faq_series/faq_2021_s2.md @@ -0,0 +1,264 @@ +# PaddleClas 相关常见问题汇总 - 2021 第 2 季 + +## 写在前面 + +* 我们收集整理了开源以来在 issues 和用户群中的常见问题并且给出了简要解答,旨在为广大用户提供一些参考,也希望帮助大家少走一些弯路。 + +* 图像分类、识别、检索领域大佬众多,模型和论文更新速度也很快,本文档回答主要依赖有限的项目实践,难免挂一漏万,如有遗漏和不足,也希望有识之士帮忙补充和修正,万分感谢。 + +## 目录 + +* [1. 理论篇](#1) + * [1.1 PaddleClas 基础知识](#1.1) + * [1.2 骨干网络和预训练模型库](#1.2) + * [1.3 图像分类](#1.3) + * [1.4 通用检测模块](#1.4) + * [1.5 图像识别模块](#1.5) + * [1.6 检索模块](#1.6) +* [2. 实战篇](#2) + * [2.1 训练与评估共性问题](#2.1) + * [2.2 图像分类](#2.2) + * [2.3 通用检测模块](#2.3) + * [2.4 图像识别模块](#2.4) + * [2.5 检索模块](#2.5) + * [2.6 模型预测部署](#2.6) + + +## 1. 理论篇 + + +### 1.1 PaddleClas 基础知识 + +#### Q1.1.1 PaddleClas 和 PaddleDetection 区别 +**A**:PaddleClas 是一个兼主体检测、图像分类、图像检索于一体的图像识别 repo,用于解决大部分图像识别问题,用户可以很方便的使用 PaddleClas 来解决小样本、多类别的图像识别问题。PaddleDetection 提供了目标检测、关键点检测、多目标跟踪等能力,方便用户定位图像中的感兴趣的点和区域,被广泛应用于工业质检、遥感图像检测、无人巡检等项目。 + +#### Q1.1.3: Momentum 优化器中的 momentum 参数是什么意思呢? +**A**: Momentum 优化器是在 SGD 优化器的基础上引入了“动量”的概念。在 SGD 优化器中,在 `t+1` 时刻,参数 `w` 的更新可表示为: +```latex +w_t+1 = w_t - lr * grad +``` +其中,`lr` 为学习率,`grad` 为此时参数 `w` 的梯度。在引入动量的概念后,参数 `w` 的更新可表示为: +```latex +v_t+1 = m * v_t + lr * grad +w_t+1 = w_t - v_t+1 +``` +其中,`m` 即为动量 `momentum`,表示累积动量的加权值,一般取 `0.9`,当取值小于 `1` 时,则越早期的梯度对当前的影响越小,例如,当动量参数 `m` 取 `0.9` 时,在 `t` 时刻,`t-5` 的梯度加权值为 `0.9 ^ 5 = 0.59049`,而 `t-2` 时刻的梯度加权值为 `0.9 ^ 2 = 0.81`。因此,太过“久远”的梯度信息对当前的参考意义很小,而“最近”的历史梯度信息对当前影响更大,这也是符合直觉的。 + +![](../../images/faq/momentum.jpeg) + +通过引入动量的概念,在参数更新时考虑了历史更新的影响,因此可以加快收敛速度,也改善了 `SGD` 优化器带来的损失(cost、loss)震荡问题。 + +#### Q1.1.4: PaddleClas 是否有 `Fixing the train-test resolution discrepancy` 这篇论文的实现呢? +**A**: 目前 PaddleClas 没有实现。如果需要,可以尝试自己修改代码。简单来说,该论文所提出的思想是使用较大分辨率作为输入,对已经训练好的模型最后的 FC 层进行 fine-tune。具体操作上,首先在较低分辨率的数据集上对模型网络进行训练,完成训练后,对网络除最后的 FC 层外的其他层的权重设置参数 `stop_gradient=True`,然后使用较大分辨率的输入对网络进行 fine-tune 训练。 + + +### 1.2 骨干网络和预训练模型库 + + +### 1.3 图像分类 + +#### Q1.3.1: PaddleClas 有提供调整图片亮度,对比度,饱和度,色调等方面的数据增强吗? +**A**:PaddleClas 提供了多种数据增广方式,可分为 3 类: +1. 图像变换类: AutoAugment, RandAugment; +2. 图像裁剪类: CutOut、RandErasing、HideAndSeek、GridMask; +3. 图像混叠类:Mixup, Cutmix. + +其中,RandAngment 提供了多种数据增强方式的随机组合,可以满足亮度、对比度、饱和度、色调等多方面的数据增广需求。 + + +### 1.4 通用检测模块 + +#### Q1.4.1 主体检测是每次只输出一个主体检测框吗? +**A**:主体检测这块的输出数量是可以通过配置文件配置的。在配置文件中 Global.threshold 控制检测的阈值,小于该阈值的检测框被舍弃,Global.max_det_results 控制最大返回的结果数,这两个参数共同决定了输出检测框的数量。 + +#### Q1.4.2 训练主体检测模型的数据是如何选择的?换成更小的模型会有损精度吗? +**A**:训练数据是在 COCO、Object365、RPC、LogoDet 等公开数据集中随机抽取的子集。目前我们在 2.3 版本中推出了超轻量的主体检测模型,具体信息可以参考[主体检测](../image_recognition_pipeline/mainbody_detection.md#2-模型选择)。关于主体检测模型的更多信息请参考[主体检测](../image_recognition_pipeline/mainbody_detection.md)。 + +#### Q1.4.3: 目前使用的主体检测模型检测在某些场景中会有误检? +**A**:目前的主体检测模型训练时使用了 COCO、Object365、RPC、LogoDet 等公开数据集,如果被检测数据是类似工业质检等于常见类别差异较大的数据,需要基于目前的检测模型重新微调训练。 + + +### 1.5 图像识别模块 + +#### Q1.5.1 使用 `circle loss` 还需加 `triplet loss` 吗? +**A**:`circle loss` 是统一了样本对学习和分类学习的两种形式,如果是分类学习的形式的话,可以增加 `triplet loss`。 + +#### Q1.5.2 如果不是识别开源的四个方向的图片,该使用哪个识别模型? +**A**:建议使用商品识别模型,一来是因为商品覆盖的范围比较广,被识别的图片是商品的概率更大,二来是因为商品识别模型的训练数据使用了 5 万类别的数据,泛化能力更好,特征会更鲁棒一些。 + +#### Q1.5.3 最后使用 512 维的向量,为什么不用 1024 或者其他维度的呢? +**A**:使用维度小的向量,为了加快计算,在实际使用过程中,可能使用 128 甚至更小。一般来说,512 的维度已经够大,能充分表示特征了。 + + +### 1.6 检索模块 + +#### Q1.6.1 PaddleClas 目前使用的 Möbius 向量检索算法支持类似于 faiss 的那种 index.add()的功能吗? 另外,每次构建新的图都要进行 train 吗?这里的 train 是为了检索加速还是为了构建相似的图? +**A**:目前在 release/2.3 分支已经支持 faiss 检索模块,并且不再支持 Möbius。关于 Möbius 提供的检索算法,是一种基于图的近似最近邻搜索算法,目前支持两种距离计算方式:inner product 和 L2 distance,但是 Möbius 暂不支持 faiss 中提供的 index.add 功能,如果需要增加检索库的内容,需要从头重新构建新的 index. 在每次构建 index 时,检索算法内部执行的操作是一种类似于 train 的过程,不同于 faiss 提供的 train 接口。因此需要 faiss 模块的话,可以使用 release/2.3 分支,需要 Möbius 的话,目前需要回退到 release/2.2 分支。 + +#### Q1.6.2: PaddleClas 图像识别用于 Eval 的配置文件中,`Query` 和 `Gallery` 配置具体是用于做什么呢? +**A**: `Query` 与 `Gallery` 均为数据集配置,其中 `Gallery` 用于配置底库数据,`Query` 用于配置验证集。在进行 Eval 时,首先使用模型对 `Gallery` 底库数据进行前向计算特征向量,特征向量用于构建底库,然后模型对 `Query` 验证集中的数据进行前向计算特征向量,再与底库计算召回率等指标。 + + +## 2. 实战篇 + + +### 2.1 训练与评估共性问题 + +#### Q2.1.1 PaddleClas 的 `train_log` 文件在哪里? +**A**:在保存权重的路径中存放了 `train.log`。 + +#### Q2.1.2 模型训练出 nan,为什么? +**A**: +1.确保正确加载预训练模型, 最简单的加载方式添加参数 `-o Arch.pretrained=True` 即可; +2.模型微调时,学习率不要太大,如设置 0.001 就好。 + +#### Q2.1.3 可以对视频中每一帧画面进行逐帧预测吗? +**A**:可以,但目前 PaddleClas 并不支持视频输入。可以尝试修改一下 PaddleClas 代码,或者预先将视频逐帧转为图像存储,再使用 PaddleClas 进行预测。 + +#### Q2.1.4: 数据预处理中,不想对输入数据进行裁剪,该如何设置?或者如何设置剪裁的尺寸。 +**A**: PaddleClas 支持的数据预处理算子可在这里查看:`ppcls/data/preprocess/__init__.py`,所有支持的算子均可在配置文件中进行配置,配置的算子名称需要和算子类名一致,参数与对应算子类的构造函数参数一致。如不需要对图像裁剪,则可去掉 `CropImage`、`RandCropImage`,使用 `ResizeImage` 替换即可,可通过其参数设置不同的 resize 方式,使用 `size` 参数则直接将图像缩放至固定大小,使用 `resize_short` 参数则会维持图像宽高比进行缩放。设置裁剪尺寸时,可通过 `CropImage` 算子的 `size` 参数,或 `RandCropImage` 算子的 `size` 参数。 + +#### Q2.1.5: PaddlePaddle 安装后,使用报错,无法导入 paddle 下的任何模块(import paddle.xxx),是为什么呢? +**A**: 首先可以使用以下代码测试 Paddle 是否安装正确: +```python +import paddle +paddle.utils.install_check.run_check() +``` +正确安装时,通常会有如下提示: +``` +PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now. +``` +如未能安装成功,则会有相应问题的提示。 +另外,在同时安装 CPU 版本和 GPU 版本 Paddle 后,由于两个版本存在冲突,需要将两个版本全部卸载,然后重新安装所需要的版本。 + +#### Q2.1.6: 使用 PaddleClas 训练时,如何设置仅保存最优模型?不想保存中间模型。 +**A**: PaddleClas 在训练过程中,会保存/更新以下三类模型: +1. 最新的模型(`latest.pdopt`,`latest.pdparams`,`latest.pdstates`),当训练意外中断时,可使用最新保存的模型恢复训练; +2. 最优的模型(`best_model.pdopt`,`best_model.pdparams`,`best_model.pdstates`); +3. 训练过程中,一个 epoch 结束时的断点(`epoch_xxx.pdopt`,`epoch_xxx.pdparams`,`epoch_xxx.pdstates`)。训练配置文件中 `Global.save_interval` 字段表示该模型的保存间隔。将该字段设置大于总 epochs 数,则不再保存中间断点模型。 + +#### Q2.1.7: 在训练时,出现如下报错信息:`ERROR: Unexpected segmentation fault encountered in DataLoader workers.`,如何排查解决问题呢? +**A**:尝试将训练配置文件中的字段 `num_workers` 设置为 `0`;尝试将训练配置文件中的字段 `batch_size` 调小一些;检查数据集格式和配置文件中的数据集路径是否正确。 + +#### Q2.1.8: 如何在训练时使用 `Mixup` 和 `Cutmix` ? +**A**: +* `Mixup` 的使用方法请参考 [Mixup](../../../ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml#L63-L65);`Cuxmix` 请参考 [Cuxmix](../../../ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml#L63-L65)。 + +* 使用 `Mixup` 或 `Cutmix` 做训练时无法计算训练的精度(Acc)指标,因此需要在配置文件中取消 `Metric.Train.TopkAcc` 字段,可参考 [Metric.Train.TopkAcc](../../../ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml#L125-L128)。 + +#### Q2.1.9: 训练配置 yaml 文件中,字段 `Global.pretrain_model` 和 `Global.checkpoints` 分别用于配置什么呢? +**A**: +* 当需要 `fine-tune` 时,可以通过字段 `Global.pretrain_model` 配置预训练模型权重文件的路径,预训练模型权重文件后缀名通常为 `.pdparams`; +* 在训练过程中,训练程序会自动保存每个 epoch 结束时的断点信息,包括优化器信息 `.pdopt` 和模型权重信息 `.pdparams`。在训练过程意外中断等情况下,需要恢复训练时,可以通过字段 `Global.checkpoints` 配置训练过程中保存的断点信息文件,例如通过配置 `checkpoints: ./output/ResNet18/epoch_18` 即可恢复 18 epoch 训练结束时的断点信息,PaddleClas 将自动加载 `epoch_18.pdopt` 和 `epoch_18.pdparams`,从 19 epoch 继续训练。 + + +### 2.2 图像分类 + +#### Q2.2.1 在 SSLD 中,大模型在 500M 数据上预训练后蒸馏小模型,然后在 1M 数据上蒸馏 finetune 小模型,具体步骤是怎样做的? +**A**:步骤如下: +1. 基于 facebook 开源的 `ResNeXt101-32x16d-wsl` 模型去蒸馏得到了 `ResNet50-vd` 模型; +2. 用这个 `ResNet50-vd`,在 500W 数据集上去蒸馏 `MobilNetV3`; +3. 考虑到 500W 的数据集的分布和 100W 的数据分布不完全一致,所以这块,在 100W 上的数据上又 finetune 了一下,精度有微弱的提升。 + +#### Q2.2.2 训练 SwinTransformer,loss 出现 nan +**A**:训练 SwinTransformer 时,请使用版本大于等于 `2.1.1` 的 `Paddle`,并且加载我们提供的预训练模型,学习率也不宜过大。 + + +### 2.3 通用检测模块 + +#### Q2.3.1 为什么有一些图片检测出的结果就是原图? +**A**:主体检测模型会返回检测框,但事实上为了让后续的识别模型更加准确,在返回检测框的同时也返回了原图。后续会根据原图或者检测框与库中的图片的相似度排序,相似度最高的库中图片的标签即为被识别图片的标签。 + +#### Q2.3.2:在直播场景中,需要提供一个直播即时识别画面,能够在延迟几秒内找到特征目标物并用框圈起,这个可以实现吗? +**A**:要达到实时的检测效果,需要检测速度达到实时性的要求;PP-YOLO 是 Paddle 团队提供的轻量级目标检测模型,检测速度和精度达到了很好的平衡,可以试试 PP-YOLO 来做检测. 关于 PP-YOLO 的使用,可以参照:[PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/configs/ppyolo/README_cn.md)。 + +#### Q2.3.3: 对于未知的标签,加入 gallery dataset 可以用于后续的分类识别(无需训练),但是如果前面的检测模型对于未知的标签无法定位检测出来,是否还是要训练前面的检测模型? +**A**:如果检测模型在自己的数据集上表现不佳,需要在自己的检测数据集上再 finetune 下 + + +### 2.4 图像识别模块 + +#### Q2.4.1: 识别模块预测时报 `Illegal instruction` 错? +**A**:如果使用的是 release/2.2 分支,建议更新为 release/2.3 分支,在 release/2.3 分支中,我们使用 faiss 检索模块替换了 Möbius 检索模型,具体可以参考[向量检索教程](../../../deploy/vector_search/README.md)。如仍存在问题,可以在用户微信群中联系我们,也可以在 GitHub 提 issue。 + +#### Q2.4.2: 识别模型怎么在预训练模型的基础上进行微调训练? +**A**:识别模型的微调训练和分类模型的微调训练类似,识别模型可以加载商品的预训练模型,训练过程可以参考[识别模型训练](../../zh_CN/models_training/recognition.md),后续我们也会持续细化这块的文档。 + +#### Q2.4.3: 训练 metric learning 时,每个 epoch 中,无法跑完所有 mini-batch,为什么? +**A**:在训练 metric learning 时,使用的 Sampler 是 DistributedRandomIdentitySampler,该 Sampler 不会采样全部的图片,导致会让每一个 epoch 采样的数据不是所有的数据,所以无法跑完显示的 mini-batch 是正常现象。该问题在 release/2.3 分支已经优化,请更新到 release/2.3 使用。 + +#### Q2.4.4: 有些图片没有识别出结果,为什么? +**A**:在配置文件(如 inference_product.yaml)中,`IndexProcess.score_thres` 中会控制被识别的图片与库中的图片的余弦相似度的最小值。当余弦相似度小于该值时,不会打印结果。您可以根据自己的实际数据调整该值。 + + +### 2.5 检索模块 + +#### Q2.5.1: 添加图片后建索引报 `assert text_num >= 2` 错? +**A**:请确保 data_file.txt 中图片路径和图片名称中间的间隔为单个 table,而不是空格。 + +#### Q2.5.2: 新增底库数据需要重新构建索引吗? +**A**:从 release/2.3 分支起,我们使用 faiss 检索模块替换了 Möbius 检索模型,已经支持在不构建底库的前提下新增底库数据,具体可以参考[向量检索教程](../../../deploy/vector_search/README.md)。 + +#### Q2.5.3: Mac 重新编译 index.so 时报错如下:clang: error: unsupported option '-fopenmp', 该如何处理? +**A**:如果使用的是 release/2.2 分支,建议更新为 release/2.3 分支,在 release/2.3 分支中,我们使用 faiss 检索模块替换了 Möbius 检索模型,具体可以参考[向量检索教程](../../../deploy/vector_search/README.md)。如仍存在问题,可以在用户微信群中联系我们,也可以在 GitHub 提 issue。 + +#### Q2.5.4: 在 build 检索底库时,参数 `pq_size` 应该如何设置? +**A**:`pq_size` 是 PQ 检索算法的参数。PQ 检索算法可以简单理解为“分层”检索算法,`pq_size` 是每层的“容量”,因此该参数的设置会影响检索性能,不过,在底库总数据量不太大(小于 10000 张)的情况下,这个参数对性能的影响很小,因此对于大多数使用场景而言,在构建底库时无需修改该参数。关于 PQ 检索算法的更多内容,可以查看相关[论文](https://lear.inrialpes.fr/pubs/2011/JDS11/jegou_searching_with_quantization.pdf)。 + + +### 2.6 模型预测部署 + +#### Q2.6.1: hub serving 方式启动某个模块,怎么添加该模块的参数呢? +**A**:具体可以参考 [hub serving 参数](../../../deploy/hubserving/clas/params.py)。 + +#### Q2.6.2: 导出inference模型进行预测部署,准确率异常,为什么呢? +**A**: 该问题通常是由于在导出时未能正确加载模型参数导致的,首先检查模型导出时的日志,是否存在类似下述内容: +``` +UserWarning: Skip loading for ***. *** is not found in the provided dict. +``` +如果存在,则说明模型权重未能加载成功,请进一步检查配置文件中的 `Global.pretrained_model` 字段,是否正确配置了模型权重文件的路径。模型权重文件后缀名通常为 `pdparams`,注意在配置该路径时无需填写文件后缀名。 + +#### Q2.6.3: 如何将模型转为 `ONNX` 格式? +**A**:Paddle 支持两种转 ONNX 格式模型的方式,且依赖于 `paddle2onnx` 工具,首先需要安装 `paddle2onnx`: + +```shell +pip install paddle2onnx +``` + +* 从 inference model 转为 ONNX 格式模型: + + 以动态图导出的 `combined` 格式 inference model(包含 `.pdmodel` 和 `.pdiparams` 两个文件)为例,使用以下命令进行模型格式转换: + ```shell + paddle2onnx --model_dir ${model_path} --model_filename ${model_path}/inference.pdmodel --params_filename ${model_path}/inference.pdiparams --save_file ${save_path}/model.onnx --enable_onnx_checker True + ``` + 上述命令中: + * `model_dir`:该参数下需要包含 `.pdmodel` 和 `.pdiparams` 两个文件; + * `model_filename`:该参数用于指定参数 `model_dir` 下的 `.pdmodel` 文件路径; + * `params_filename`:该参数用于指定参数 `model_dir` 下的 `.pdiparams` 文件路径; + * `save_file`:该参数用于指定转换后的模型保存目录路径。 + + 关于静态图导出的非 `combined` 格式的 inference model(通常包含文件 `__model__` 和多个参数文件)转换模型格式,以及更多参数说明请参考 paddle2onnx 官方文档 [paddle2onnx](https://github.com/PaddlePaddle/Paddle2ONNX/blob/develop/README_zh.md#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)。 + +* 直接从模型组网代码导出 ONNX 格式模型: + + 以动态图模型组网代码为例,模型类为继承于 `paddle.nn.Layer` 的子类,代码如下所示: + + ```python + import paddle + from paddle.static import InputSpec + + class SimpleNet(paddle.nn.Layer): + def __init__(self): + pass + def forward(self, x): + pass + + net = SimpleNet() + x_spec = InputSpec(shape=[None, 3, 224, 224], dtype='float32', name='x') + paddle.onnx.export(layer=net, path="./SimpleNet", input_spec=[x_spec]) + ``` + 其中: + * `InputSpec()` 函数用于描述模型输入的签名信息,包括输入数据的 `shape`、`type` 和 `name`(可省略); + * `paddle.onnx.export()` 函数需要指定模型组网对象 `net`,导出模型的保存路径 `save_path`,模型的输入数据描述 `input_spec`。 + + 需要注意,`paddlepaddle` 版本需大于 `2.0.0`。关于 `paddle.onnx.export()` 函数的更多参数说明请参考 [paddle.onnx.export](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/onnx/export_cn.html#export)。 diff --git a/src/PaddleClas/docs/zh_CN/faq_series/faq_selected_30.md b/src/PaddleClas/docs/zh_CN/faq_series/faq_selected_30.md new file mode 100644 index 0000000..3382673 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/faq_series/faq_selected_30.md @@ -0,0 +1,242 @@ +# FAQ + +## 写在前面 + +* 我们收集整理了开源以来在 issues 和用户群中的常见问题并且给出了简要解答,旨在为图像分类的开发者提供一些参考,也希望帮助大家少走一些弯路。 + +* 图像分类领域大佬众多,模型和论文更新速度也很快,本文档回答主要依赖有限的项目实践,难免挂一漏万,如有遗漏和不足,也希望有识之士帮忙补充和修正,万分感谢。 + + +## PaddleClas 常见问题汇总 + +* [1. 图像分类 30 个问题](#1) + * [1.1 基础知识](#1.1) + * [1.2 模型训练相关](#1.2) + * [1.3 数据相关](#1.3) + * [1.4 模型推理与预测相关](#1.4) +* [2. PaddleClas 使用问题](#2) + + + +## 1. 图像分类 30 个问题 + + +### 1.1 基础知识 + +>> +* Q: 图像分类领域常用的分类指标有几种 +* A: + * 对于单个标签的图像分类问题(仅包含 1 个类别与背景),评估指标主要有 Accuracy,Precision,Recall,F-score 等,令 TP(True Positive)表示将正类预测为正类,FP(False Positive)表示将负类预测为正类,TN(True Negative)表示将负类预测为负类,FN(False Negative)表示将正类预测为负类。那么 Accuracy=(TP + TN) / NUM,Precision=TP /(TP + FP),Recall=TP /(TP + FN)。 + * 对于类别数大于 1 的图像分类问题,评估指标主要有 Accuary 和 Class-wise Accuracy,Accuary 表示所有类别预测正确的图像数量占总图像数量的百分比;Class-wise Accuracy 是对每个类别的图像计算 Accuracy,然后再对所有类别的 Accuracy 取平均得到。 + +>> +* Q: 怎样根据自己的任务选择合适的模型进行训练? +* A: 如果希望在服务器部署,或者希望精度尽可能地高,对模型存储大小或者预测速度的要求不是很高,那么推荐使用 ResNet_vd、Res2Net_vd、DenseNet、Xception 等适合于服务器端的系列模型;如果希望在移动端侧部署,则推荐使用 MobileNetV3、GhostNet 等适合于移动端的系列模型。同时,我们推荐在选择模型的时候可以参考[模型库](../models/models_intro.md)中的速度-精度指标图。 + +>> +* Q: 如何进行参数初始化,什么样的初始化可以加快模型收敛? +* A: 众所周知,参数的初始化可以影响模型的最终性能。一般来说,如果目标数据集不是很大,建议使用 ImageNet-1k 训练得到的预训练模型进行初始化。如果是自己手动设计的网络或者暂时没有基于 ImageNet-1k 训练得到的预训练权重,可以使用 Xavier 初始化或者 MSRA 初始化,其中 Xavier 初始化是针对 Sigmoid 函数提出的,对 RELU 函数不太友好,网络越深,各层输入的方差越小,网络越难训练,所以当神经网络中使用较多 RELU 激活函数时,推荐使用 MSRA 初始化。 + +>> +* Q: 针对深度神经网络参数冗余的问题,目前有哪些比较好的解决办法? +* A: 目前有几种主要的方法对模型进行压缩,减少模型参数冗余的问题,如剪枝、量化、知识蒸馏等。模型剪枝指的是将权重矩阵中相对不重要的权值剔除,然后再重新对网络进行微调;模型量化指的是一种将浮点计算转成低比特定点计算的技术,如 8 比特、4 比特等,可以有效的降低模型计算强度、参数大小和内存消耗。知识蒸馏是指使用教师模型(teacher model)去指导学生模型(student model)学习特定任务,保证小模型在参数量不变的情况下,性能有较大的提升,甚至获得与大模型相似的精度指标。 + +>> +* Q: 怎样在其他任务,如目标检测、图像分割、关键点检测等任务中选择比较合适的分类模型作为骨干网络? +* A: 在不考虑速度的情况下,在大部分的任务中,推荐使用精度更高的预训练模型和骨干网络,PaddleClas 中开源了一系列的 SSLD 知识蒸馏预训练模型,如 ResNet50_vd_ssld, Res2Net200_vd_26w_4s_ssld 等,在模型精度和速度方面都是非常有优势的,推荐大家使用。对于一些特定的任务,如图像分割或者关键点检测等任务,对图像分辨率的要求比较高,那么更推荐使用 HRNet 等能够同时兼顾网络深度和分辨率的神经网络模型,PaddleClas 也提供了 HRNet_W18_C_ssld、HRNet_W48_C_ssld 等精度非常高的 HRNet SSLD 蒸馏系列预训练模型,大家可以使用这些精度更高的预训练模型与骨干网络,提升自己在其他任务上的模型精度。 + +>> +* Q: 注意力机制是什么?目前有哪些比较常用的注意力机制方法? +* A: 注意力机制(Attention Mechanism)源于对人类视觉的研究。将注意力机制用在计算机视觉任务上,可以有效捕捉图片中有用的区域,从而提升整体网络性能。目前比较常用的有 [SE block](https://arxiv.org/abs/1709.01507)、[SK-block](https://arxiv.org/abs/1903.06586)、[Non-local block](https://arxiv.org/abs/1711.07971)、[GC block](https://arxiv.org/abs/1904.11492)、[CBAM](https://arxiv.org/abs/1807.06521) 等,核心思想就是去学习特征图在不同区域或者不同通道中的重要性,从而让网络更加注意显著性的区域。 + + +### 1.2 模型训练相关 + +>> +* Q: 使用深度卷积网络做图像分类,如果训练一个拥有 1000 万个类的模型会碰到什么问题? +* A: 因为 FC 层参数很多,内存/显存/模型的存储占用都会大幅增大;模型收敛速度也会变慢一些。建议在这种情况下,再最后的 FC 层前加一层维度较小的 FC,这样可以大幅减少模型的存储大小。 + +>> +* Q: 训练过程中,如果模型收敛效果很差,可能的原因有哪些呢? +* A: 主要有以下几个可以排查的地方:(1)应该检查数据标注,确保训练集和验证集的数据标注没有问题。(2)可以试着调整一下学习率(初期可以以 10 倍为单位进行调节),过大(训练震荡)或者过小(收敛太慢)的学习率都可能导致收敛效果差。(3)数据量太大,选择的模型太小,难以学习所有数据的特征。(4)可以看下数据预处理的过程中是否使用了归一化,如果没有使用归一化操作,收敛速度可能会比较慢。(5)如果数据量比较小,可以试着加载 PaddleClas 中提供的基于 ImageNet-1k 数据集的预训练模型,这可以大大提升训练收敛速度。(6)数据集存在长尾问题,可以参考[数据长尾问题解决方案](#long_tail)。 + +>> +* Q: 训练图像分类任务时,该怎么选择合适的优化器? +* A: 优化器的目的是为了让损失函数尽可能的小,从而找到合适的参数来完成某项任务。目前业界主要用到的优化器有 SGD、RMSProp、Adam、AdaDelt 等,其中由于带 momentum 的 SGD 优化器广泛应用于学术界和工业界,所以我们发布的模型也大都使用该优化器来实现损失函数的梯度下降。带 momentum 的 SGD 优化器有两个劣势,其一是收敛速度慢,其二是初始学习率的设置需要依靠大量的经验,然而如果初始学习率设置得当并且迭代轮数充足,该优化器也会在众多的优化器中脱颖而出,使得其在验证集上获得更高的准确率。一些自适应学习率的优化器如 Adam、RMSProp 等,收敛速度往往比较快,但是最终的收敛精度会稍差一些。如果追求更快的收敛速度,我们推荐使用这些自适应学习率的优化器,如果追求更高的收敛精度,我们推荐使用带 momentum 的 SGD 优化器。 + +>> +* Q: 当前主流的学习率下降策略有哪些?一般需要怎么选择呢? +* A: 学习率是通过损失函数的梯度调整网络权重的超参数的速度。学习率越低,损失函数的变化速度就越慢。虽然使用低学习率可以确保不会错过任何局部极小值,但也意味着将花费更长的时间来进行收敛,特别是在被困在高原区域的情况下。在整个训练过程中,我们不能使用同样的学习率来更新权重,否则无法到达最优点,所以需要在训练过程中调整学习率的大小。在训练初始阶段,由于权重处于随机初始化的状态,损失函数相对容易进行梯度下降,所以可以设置一个较大的学习率。在训练后期,由于权重参数已经接近最优值,较大的学习率无法进一步寻找最优值,所以需要设置一个较小的学习率。在训练整个过程中,很多研究者使用的学习率下降方式是 piecewise_decay,即阶梯式下降学习率,如在 ResNet50 标准的训练中,我们设置的初始学习率是 0.1,每 30 epoch 学习率下降到原来的 1/10,一共迭代 120 epoch。除了 piecewise_decay,很多研究者也提出了学习率的其他下降方式,如 polynomial_decay(多项式下降)、exponential_decay(指数下降), cosine_decay(余弦下降)等,其中 cosine_decay 无需调整超参数,鲁棒性也比较高,所以成为现在提高模型精度首选的学习率下降方式。Cosine_decay 和 piecewise_decay 的学习率变化曲线如下图所示,容易观察到,在整个训练过程中,cosine_decay 都保持着较大的学习率,所以其收敛较为缓慢,但是最终的收敛效果较 peicewise_decay 更好一些。 +![](../../images/models/lr_decay.jpeg) +>> +* Q: Warmup 学习率策略是什么?一般用在什么样的场景中? +* A: Warmup 策略顾名思义就是让学习率先预热一下,在训练初期我们不直接使用最大的学习率,而是用一个逐渐增大的学习率去训练网络,当学习率增大到最高点时,再使用学习率下降策略中提到的学习率下降方式衰减学习率的值。如果使用较大的 batch_size 训练神经网络时,我们建议您使用 warmup 策略。实验表明,在 batch_size 较大时,warmup 可以稳定提升模型的精度。在训练 MobileNetV3 等 batch_size 较大的实验中,我们默认将 warmup 中的 epoch 设置为 5,即先用 5 epoch 将学习率从 0 增加到最大值,再去做相应的学习率衰减。 + +>> +* Q: 什么是 `batch size`?在模型训练中,怎么选择合适的 `batch size`? +* A: `batch size` 是训练神经网络中的一个重要的超参数,该值决定了一次将多少数据送入神经网络参与训练。论文 [Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour](https://arxiv.org/abs/1706.02677),当 `batch size` 的值与学习率的值呈线性关系时,收敛精度几乎不受影响。在训练 ImageNet 数据时,大部分的神经网络选择的初始学习率为 0.1,`batch size` 是 256,所以根据实际的模型大小和显存情况,可以将学习率设置为 0.1*k, batch_size 设置为 256*k。在实际任务中,也可以将该设置作为初始参数,进一步调节学习率参数并获得更优的性能。 +>> +* Q: weight_decay 是什么?怎么选择合适的 weight_decay 呢? +* A: 过拟合是机器学习中常见的一个名词,简单理解即为模型在训练数据上表现很好,但在测试数据上表现较差,在卷积神经网络中,同样存在过拟合的问题,为了避免过拟合,很多正则方式被提出,其中,weight_decay 是其中一个广泛使用的避免过拟合的方式。在使用 SGD 优化器时,weight_decay 等价于在最终的损失函数后添加 L2 正则化,L2 正则化使得网络的权重倾向于选择更小的值,最终整个网络中的参数值更趋向于 0,模型的泛化性能相应提高。在各大深度学习框架的实现中,该值表达的含义是 L2 正则前的系数,在 paddle 框架中,该值的名称是 l2_decay,所以以下都称其为 l2_decay。该系数越大,表示加入的正则越强,模型越趋于欠拟合状态。在训练 ImageNet 的任务中,大多数的网络将该参数值设置为 1e-4,在一些小的网络如 MobileNet 系列网络中,为了避免网络欠拟合,该值设置为 1e-5~4e-5 之间。当然,该值的设置也和具体的数据集有关系,当任务的数据集较大时,网络本身趋向于欠拟合状态,可以将该值适当减小,当任务的数据集较小时,网络本身趋向于过拟合状态,可以将该值适当增大。下表展示了 MobileNetV1_x0_25 在 ImageNet-1k 上使用不同 l2_decay 的精度情况。由于 MobileNetV1_x0_25 是一个比较小的网络,所以 l2_decay 过大会使网络趋向于欠拟合状态,所以在该网络中,相对 1e-4,3e-5 是更好的选择。 + +| 模型 | L2_decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 1e-4 | 43.79%/67.61% | 50.41%/74.70% | +| MobileNetV1_x0_25 | 3e-5 | 47.38%/70.83% | 51.45%/75.45% | + + +>> +* Q: 标签平滑(label_smoothing)指的是什么?有什么效果呢?一般适用于什么样的场景中? +* A: Label_smoothing 是深度学习中的一种正则化方法,其全称是 Label Smoothing Regularization(LSR),即标签平滑正则化。在传统的分类任务计算损失函数时,是将真实的 one hot 标签与神经网络的输出做相应的交叉熵计算,而 label_smoothing 是将真实的 one hot 标签做一个标签平滑的处理,使得网络学习的标签不再是一个 hard label,而是一个有概率值的 soft label,其中在类别对应的位置的概率最大,其他位置概率是一个非常小的数。具体的计算方式参见论文[2]。在 label_smoothing 里,有一个 epsilon 的参数值,该值描述了将标签软化的程度,该值越大,经过 label smoothing 后的标签向量的标签概率值越小,标签越平滑,反之,标签越趋向于 hard label,在训练 ImageNet-1k 的实验里通常将该值设置为 0.1。 +在训练 ImageNet-1k 的实验中,我们发现,ResNet50 大小级别及其以上的模型在使用 label_smooting 后,精度有稳定的提升。下表展示了 ResNet50_vd 在使用 label_smoothing 前后的精度指标。同时,由于 label_smoohing 相当于一种正则方式,在相对较小的模型上,精度提升不明显甚至会有所下降,下表展示了 ResNet18 在 ImageNet-1k 上使用 label_smoothing 前后的精度指标。可以明显看到,在使用 label_smoothing 后,精度有所下降。 + +| 模型 | Use_label_smoothing | Test acc1 | +|:--:|:--:|:--:| +| ResNet50_vd | 0 | 77.9% | +| ResNet50_vd | 1 | 78.4% | +| ResNet18 | 0 | 71.0% | +| ResNet18 | 1 | 70.8% | + + +>> +* Q: 在训练的时候怎么通过训练集和验证集的准确率或者 loss 确定进一步的调优策略呢? +* A: 在训练网络的过程中,通常会打印每一个 epoch 的训练集准确率和验证集准确率,二者刻画了该模型在两个数据集上的表现。通常来说,训练集的准确率比验证集准确率微高或者二者相当是比较不错的状态。如果发现训练集的准确率比验证集高很多,说明在这个任务上已经过拟合,需要在训练过程中加入更多的正则,如增大 l2_decay 的值,加入更多的数据增广策略,加入 label_smoothing 策略等;如果发现训练集的准确率比验证集低一些,说明在这个任务上可能欠拟合,需要在训练过程中减弱正则效果,如减小 l2_decay 的值,减少数据增广方式,增大图片 crop 区域面积,减弱图片拉伸变换,去除 label_smoothing 等。 + +>> +* Q: 怎么使用已有的预训练模型提升自己的数据集的精度呢? +* A: 在现阶段计算机视觉领域中,加载预训练模型来训练自己的任务已成为普遍的做法,相比从随机初始化开始训练,加载预训练模型往往可以提升特定任务的精度。一般来说,业界广泛使用的预训练模型是通过训练 128 万张图片 1000 类的 ImageNet-1k 数据集得到的,该预训练模型的 fc 层权重是是一个 k\*1000 的矩阵,其中 k 是 fc 层以前的神经元数,在加载预训练权重时,无需加载 fc 层的权重。在学习率方面,如果您的任务训练的数据集特别小(如小于 1 千张),我们建议你使用较小的初始学习率,如 0.001(batch_size:256,下同),以免较大的学习率破坏预训练权重。如果您的训练数据集规模相对较大(大于 10 万),我们建议你尝试更大的初始学习率,如 0.01 或者更大。 + + +### 1.3 数据相关 + +>> +* Q: 图像分类的数据预处理过程一般包括哪些步骤? +* A: 以在 ImageNet-1k 数据集上训练 ResNet50 为例,一张图片被输入进网络,主要有图像解码、随机裁剪、随机水平翻转、标准化、数据重排,组 batch 并送进网络这几个步骤。图像解码指的是将图片文件读入到内存中,随机裁剪指的是将读入的图像随机拉伸并裁剪到长宽均为 224 的图像,随机水平翻转指的是对裁剪后的图片以 0.5 的概率进行水平翻转,标准化指的是将图片每个通道的数据通过去均值实现中心化的处理,使得数据尽可能符合 `N(0,1)` 的正态分布,数据重排指的是将数据由 `[224,224,3]` 的格式变为 `[3,224,224]` 的格式,组 batch 指的是将多幅图像组成一个批数据,送进网络进行训练。 + +>> +* Q: 随机裁剪是怎么影响小模型训练的性能的? +* A: 在 ImageNet-1k 数据的标准预处理中,随机裁剪函数中定义了 scale 和 ratio 两个值,两个值分别确定了图片 crop 的大小和图片的拉伸程度,其中 scale 的默认取值范围是 0.08-1(lower_scale-upper_scale),ratio 的默认取值范围是 3/4-4/3(lower_ratio-upper_ratio)。在非常小的网络训练中,此类数据增强会使得网络欠拟合,导致精度有所下降。为了提升网络的精度,可以使其数据增强变的更弱,即增大图片的 crop 区域或者减弱图片的拉伸变换程度。我们可以分别通过增大 lower_scale 的值或缩小 lower_ratio 与 upper_scale 的差距来实现更弱的图片变换。下表列出了使用不同 lower_scale 训练 MobileNetV2_x0_25 的精度,可以看到,增大图片的 crop 区域面积后训练精度和验证精度均有提升。 + +| 模型 | Scale 取值范围 | Train_acc1/acc5 | Test_acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV2_x0_25 | [0.08,1] | 50.36%/72.98% | 52.35%/75.65% | +| MobileNetV2_x0_25 | [0.2,1] | 54.39%/77.08% | 53.18%/76.14% | + + +>> +* Q: 数据量不足的情况下,目前有哪些常见的数据增广方法来增加训练样本的丰富度呢? +* A: PaddleClas 中将目前比较常见的数据增广方法分为了三大类,分别是图像变换类、图像裁剪类和图像混叠类,图像变换类主要包括 AutoAugment 和 RandAugment,图像裁剪类主要包括 CutOut、RandErasing、HideAndSeek 和 GridMask,图像混叠类主要包括 Mixup 和 Cutmix,更详细的关于数据增广的介绍可以参考:[数据增广章节](../algorithm_introduction/DataAugmentation.md)。 +>> +* Q: 对于遮挡情况比较常见的图像分类场景,该使用什么数据增广方法去提升模型的精度呢? +* A: 在训练的过程中可以尝试对训练集使用 CutOut、RandErasing、HideAndSeek 和 GridMask 等裁剪类数据增广方法,让模型也能够不止学习到显著区域,也能关注到非显著性区域,从而在遮挡的情况下,也能较好地完成识别任务。 + +>> +* Q: 对于色彩变换情况比较复杂的情况下,应该使用哪些数据增广方法提升模型精度呢? +* A: 可以考虑使用 AutoAugment 或者 RandAugment 的数据增广策略,这两种策略中都包括了锐化、直方图均衡化等丰富的颜色变换,可以让模型在训练的过程中对这些变换更加鲁棒。 +>> +* Q: Mixup 和 Cutmix 的工作原理是什么?为什么它们也是非常有效的数据增广方法? +* A: Mixup 通过线性叠加两张图片生成新的图片,对应 label 也进行线性叠加用以训练,Cutmix 则是从一幅图中随机裁剪出一个 感兴趣区域(ROI),然后覆盖当前图像中对应的区域,label 也按照图像面积比例进行线性叠加。它们其实也是生成了和训练集不同的样本和 label 并让网络去学习,从而扩充了样本的丰富度。 +>> +* Q: 对于精度要求不是那么高的图像分类任务,大概需要准备多大的训练数据集呢? +* A: 训练数据的数量和需要解决问题的复杂度有关系。难度越大,精度要求越高,则数据集需求越大,而且一般情况实际中的训练数据越多效果越好。当然,一般情况下,在加载预训练模型的情况下,每个类别包括 10-20 张图像即可保证基本的分类效果;不加载预训练模型的情况下,每个类别需要至少包含 100-200 张图像以保证基本的分类效果。 + + +>> +* Q: 对于长尾分布的数据集,目前有哪些比较常用的方法? +* A:(1)可以对数据量比较少的类别进行重采样,增加其出现的概率;(2)可以修改 loss,增加图像较少对应的类别的图片的 loss 权重;(3)可以借鉴迁移学习的方法,从常见类别中学习通用知识,然后迁移到少样本的类别中。 + + +### 1.4 模型推理与预测相关 + +>> +* Q: 有时候图像中只有小部分区域是所关注的前景物体,直接拿原图来进行分类的话,识别效果很差,这种情况要怎么做呢? +* A: 可以在分类之前先加一个主体检测的模型,将前景物体检测出来之后再进行分类,可以大大提升最终的识别效果。如果不考虑时间成本,也可以使用 multi-crop 的方式对所有的预测做融合来决定最终的类别。 +>> +* Q: 目前推荐的,模型预测方式有哪些? +* A: 在模型训练完成之后,推荐使用导出的固化模型(inference model),基于 Paddle 预测引擎进行预测,目前支持 python inference 与 cpp inference。如果希望基于服务化部署预测模型,那么推荐使用 PaddleServing 的部署方式。 +>> +* Q: 模型训练完成之后,有哪些比较合适的预测方法进一步提升模型精度呢? +* A:(1)可以使用更大的预测尺度,比如说训练的时候使用的是 224,那么预测的时候可以考虑使用 288 或者 320,这会直接带来 0.5% 左右的精度提升。(2)可以使用测试时增广的策略(Test Time Augmentation, TTA),将测试集通过旋转、翻转、颜色变换等策略,创建多个副本,并分别预测,最后将所有的预测结果进行融合,这可以大大提升预测结果的精度和鲁棒性。(3)当然,也可以使用多模型融合的策略,将多个模型针对相同图片的预测结果进行融合。 +>> +* Q: 多模型融合的时候,该怎么选择合适的模型进行融合呢? +* A: 在不考虑预测速度的情况下,建议选择精度尽量高的模型;同时建议选择不同结构或者系列的模型进行融合,比如在精度相似的情况下,ResNet50_vd 与 Xception65 的模型融合结果往往比 ResNet50_vd 与 ResNet101_vd 的模型融合结果要好一些。 + +>> +* Q: 使用固定的模型进行预测时有哪些比较常用的加速方法? +* A:(1)使用性能更优的 GPU 进行预测;(2)增大预测的 batch size;(3)使用 TenorRT 以及 FP16 半精度浮点数等方法进行预测。 + + + +## 2. PaddleClas 使用问题 + +>> +* Q: 评估和预测时,已经指定了预训练模型所在文件夹的地址,但是仍然无法导入参数,这么为什么呢? +* A: 加载预训练模型时,需要指定预训练模型的前缀,例如预训练模型参数所在的文件夹为 `output/ResNet50_vd/19`,预训练模型参数的名称为 `output/ResNet50_vd/19/ppcls.pdparams`,则 `pretrained_model` 参数需要指定为 `output/ResNet50_vd/19/ppcls`,PaddleClas 会自动补齐`.pdparams` 的后缀。 + + +>> +* Q: 在评测 `EfficientNetB0_small` 模型时,为什么最终的精度始终比官网的低 0.3% 左右? +* A: `EfficientNet` 系列的网络在进行 resize 的时候,是使用 `cubic 插值方式`(resize 参数的 interpolation 值设置为 2),而其他模型默认情况下为 None,因此在训练和评估的时候需要显式地指定 resize 的 interpolation 值。具体地,可以参考以下配置中预处理过程中 ResizeImage 的参数。 +``` + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: 2 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' +``` + +>> +* Q: python2 下,使用 visualdl 的时候,报出以下错误,`TypeError: __init__() missing 1 required positional argument: 'sync_cycle'`,这是为什么呢? +* A: 目前 visualdl 仅支持在 python3 下运行,visualdl 需要是 2.0 以上的版本,如果 visualdl 版本不对的话,可以通过以下方式进行安装:`pip3 install visualdl -i https://mirror.baidu.com/pypi/simple` + +>> +* Q: 自己在测 ResNet50_vd 预测单张图片速度的时候发现比官网提供的速度 benchmark 慢了很多,而且 CPU 速度比 GPU 速度快很多,这个是为什么呢? +* A: 模型预测需要初始化,初始化的过程比较耗时,因此在统计预测速度的时候,需要批量跑一批图片,去除前若干张图片的预测耗时,再统计下平均的时间。GPU 比 CPU 速度测试单张图片速度慢是因为 GPU 的初始化并 CPU 要慢很多。 + +>> +* Q: 灰度图可以用于模型训练吗? +* A: 灰度图也可以用于模型训练,不过需要修改模型的输入 shape 为 `[1, 224, 224]`,此外数据增广部分也需要注意适配一下。不过为了更好地使用 PaddleClas 代码的话,即使是灰度图,也建议调整为 3 通道的图片进行训练(RGB 通道的像素值相等)。 + +>> +* Q: 怎么在 windows 上或者 cpu 上面模型训练呢? +* A: 可以参考[开始使用教程](../models_training/classification.md),详细介绍了在 Linux、Windows、CPU 等环境中进行模型训练、评估与预测的教程。 +>> +* Q: 怎样在模型训练的时候使用 label smoothing 呢? +* A: 可以在配置文件中的 `Loss` 字段下进行设置,如下所示,`epsilon=0.1` 表示设置该值为 0.1,若不设置 `epsilon` 字段,则不使用 `label smoothing`。 +```yaml +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 +``` +>> +* Q: PaddleClas 提供的 10W 类图像分类预训练模型能否用于模型推断呢? +* A: 该 10W 类图像分类预训练模型没有提供 fc 全连接层的参数,无法用于模型推断,目前可以用于模型微调。 +>> +* Q: 在使用 `deploy/python/predict_cls.py` 进行模型预测的时候,报了这个问题: `Error: Pass tensorrt_subgraph_pass has not been registered`,这是为什么呢? +* A: 如果希望使用 TensorRT 进行模型预测推理的话,需要安装或是自己编译带 TensorRT 的 PaddlePaddle,Linux、Windows、macOS 系统的用户下载安装可以参考参考[下载预测库](https://paddleinference.paddlepaddle.org.cn/user_guides/download_lib.html),如果没有符合您所需要的版本,则需要本地编译安装,编译方法可以参考[源码编译](https://paddleinference.paddlepaddle.org.cn/user_guides/source_compile.html)。 +>> +* Q: 怎样在训练的时候使用自动混合精度(Automatic Mixed Precision, AMP)训练呢? +* A: 可以参考 [ResNet50_fp16.yaml](../../../ppcls/configs/ImageNet/ResNet/ResNet50_fp16.yaml) 这个配置文件;具体地,如果希望自己的配置文件在模型训练的时候也支持自动混合精度,可以在配置文件中添加下面的配置信息。 +``` +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + use_pure_fp16: &use_pure_fp16 True +``` diff --git a/src/PaddleClas/docs/zh_CN/faq_series/index.rst b/src/PaddleClas/docs/zh_CN/faq_series/index.rst new file mode 100644 index 0000000..225b82d --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/faq_series/index.rst @@ -0,0 +1,10 @@ +FAQ系列 +================================ + +.. toctree:: + :maxdepth: 2 + + faq_2021_s2.md + faq_2021_s1.md + faq_2020_s1.md + faq_selected_30.md diff --git a/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/feature_extraction.md b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/feature_extraction.md new file mode 100644 index 0000000..1438e96 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/feature_extraction.md @@ -0,0 +1,182 @@ +# 特征提取 + +## 目录 + +- [1. 简介](#1) +- [2. 网络结构](#2) +- [3. 通用识别模型](#3) +- [4. 自定义特征提取](#4) + - [4.1 数据准备](#4.1) + - [4.2 模型训练](#4.2) + - [4.3 模型评估](#4.3) + - [4.4 模型推理](#4.4) + - [4.4.1 导出推理模型](#4.4.1) + - [4.4.2 获取特征向量](#4.4.2) + + + +## 1. 简介 + +特征提取是图像识别中的关键一环,它的作用是将输入的图片转化为固定维度的特征向量,用于后续的[向量检索](./vector_search.md)。好的特征需要具备相似度保持性,即在特征空间中,相似度高的图片对其特征相似度要比较高(距离比较近),相似度低的图片对,其特征相似度要比较小(距离比较远)。[Deep Metric Learning](../algorithm_introduction/metric_learning.md)用以研究如何通过深度学习的方法获得具有强表征能力的特征。 + + + +## 2. 网络结构 +为了图像识别任务的灵活定制,我们将整个网络分为 Backbone、 Neck、 Head 以及 Loss 部分,整体结构如下图所示: +![](../../images/feature_extraction_framework.png) +图中各个模块的功能为: + +- **Backbone**: 指定所使用的骨干网络。 值得注意的是,PaddleClas 提供的基于 ImageNet 的预训练模型,最后一层的输出为 1000,我们需要依据所需的特征维度定制最后一层的输出。 +- **Neck**: 用以特征增强及特征维度变换。这儿的 Neck,可以是一个简单的 Linear Layer,用来做特征维度变换;也可以是较复杂的 FPN 结构,用以做特征增强。 +- **Head**: 用来将 feature 转化为 logits。除了常用的 Fc Layer 外,还可以替换为 cosmargin, arcmargin, circlemargin 等模块。 +- **Loss**: 指定所使用的 Loss 函数。我们将 Loss 设计为组合 loss 的形式,可以方便地将 Classification Loss 和 Pair_wise Loss 组合在一起。 + + + +## 3. 通用识别模型 + +在 PP-Shitu 中, 我们采用 [PP_LCNet_x2_5](../models/PP-LCNet.md) 作为骨干网络 Neck 部分选用 Linear Layer, Head 部分选用 [ArcMargin](../../../ppcls/arch/gears/arcmargin.py),Loss 部分选用 CELoss,详细的配置文件见[通用识别配置文件](../../../ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml)。其中,训练数据为如下 7 个公开数据集的汇总: + +| 数据集 | 数据量 | 类别数 | 场景 | 数据集地址 | +| :------------: | :-------------: | :-------: | :-------: | :--------: | +| Aliproduct | 2498771 | 50030 | 商品 | [地址](https://retailvisionworkshop.github.io/recognition_challenge_2020/) | +| GLDv2 | 1580470 | 81313 | 地标 | [地址](https://github.com/cvdfoundation/google-landmark) | +| VeRI-Wild | 277797 | 30671 | 车辆 | [地址](https://github.com/PKU-IMRE/VERI-Wild)| +| LogoDet-3K | 155427 | 3000 | Logo | [地址](https://github.com/Wangjing1551/LogoDet-3K-Dataset) | +| iCartoonFace | 389678 | 5013 | 动漫人物 | [地址](http://challenge.ai.iqiyi.com/detail?raceId=5def69ace9fcf68aef76a75d) | +| SOP | 59551 | 11318 | 商品 | [地址](https://cvgl.stanford.edu/projects/lifted_struct/) | +| Inshop | 25882 | 3997 | 商品 | [地址](http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion.html) | +| **Total** | **5M** | **185K** | ---- | ---- | + +最终的模型效果如下表所示: + +| 模型 | Aliproduct | VeRI-Wild | LogoDet-3K | iCartoonFace | SOP | Inshop | Latency(ms) | +| :----------: | :---------: | :-------: | :-------: | :--------: | :--------: | :--------: | :--------: | +PP-LCNet-2.5x | 0.839 | 0.888 | 0.861 | 0.841 | 0.793 | 0.892 | 5.0 + +* 采用的评测指标为:`Recall@1` +* 速度评测机器的 CPU 具体信息为:`Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz` +* 速度指标的评测条件为: 开启 MKLDNN, 线程数设置为 10 +* 预训练模型地址:[通用识别预训练模型](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/general_PPLCNet_x2_5_pretrained_v1.0.pdparams) + + + +## 4. 自定义特征提取 + +自定义特征提取,是指依据自己的任务,重新训练特征提取模型。主要包含四个步骤:1)数据准备;2)模型训练;3)模型评估;4)模型推理。 + + + +### 4.1 数据准备 + +首先,需要基于任务定制自己的数据集。数据集格式参见[格式说明](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/data_preparation/recognition_dataset.md#%E6%95%B0%E6%8D%AE%E9%9B%86%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E)。在启动模型训练之前,需要在配置文件中修改数据配置相关的内容, 主要包括数据集的地址以及类别数量。对应到配置文件中的位置如下所示: +``` + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 #此处表示类别数 +``` +``` + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ #此处表示train数据所在的目录 + cls_label_path: ./dataset/train_reg_all_data.txt #此处表示train数据集label文件的地址 +``` +``` + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/. #此处表示query数据集所在的目录 + cls_label_path: ./dataset/Aliproduct/val_list.txt. #此处表示query数据集label文件的地址 +``` +``` + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ #此处表示gallery数据集所在的目录 + cls_label_path: ./dataset/Aliproduct/val_list.txt. #此处表示gallery数据集label文件的地址 +``` + + + +### 4.2 模型训练 + +- 单机单卡训练 +```shell +export CUDA_VISIBLE_DEVICES=0 +python tools/train.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml +``` +- 单机多卡训练 +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" tools/train.py \ + -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml +``` +**注意:** +配置文件中默认采用`在线评估`的方式,如果你想加快训练速度,去除`在线评估`,只需要在上述命令后面,增加 `-o eval_during_train=False`。训练完毕后,在 output 目录下会生成最终模型文件 `latest`,`best_model` 和训练日志文件 `train.log`。其中,`best_model` 用来存储当前评测指标下的最佳模型;`latest` 用来存储最新生成的模型, 方便在任务中断的情况下从断点位置启动训练。 + +- 断点续训: +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" tools/train.py \ + -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ + -o Global.checkpoint="output/RecModel/latest" +``` + + + +### 4.3 模型评估 + +- 单卡评估 +```shell +export CUDA_VISIBLE_DEVICES=0 +python tools/eval.py \ +-c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ +-o Global.pretrained_model="output/RecModel/best_model" +``` + +- 多卡评估 +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" tools/eval.py \ + -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ + -o Global.pretrained_model="output/RecModel/best_model" +``` +**推荐:** 建议使用多卡评估。多卡评估方式可以利用多卡并行计算快速得到整体数据集的特征集合,能够加速评估的过程。 + + + +### 4.4 模型推理 + +推理过程包括两个步骤: 1)导出推理模型; 2)获取特征向量 + + + +#### 4.4.1 导出推理模型 + +``` +python tools/export_model.py \ +-c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml \ +-o Global.pretrained_model="output/RecModel/best_model" +``` +生成的推理模型位于 `inference` 目录,里面包含三个文件,分别为 `inference.pdmodel`、`inference.pdiparams`、`inference.pdiparams.info`。 +其中: `inference.pdmodel` 用来存储推理模型的结构, `inference.pdiparams` 和 `inference.pdiparams.info` 用来存储推理模型相关的参数信息。 + + + +#### 4.4.2 获取特征向量 + +``` +cd deploy +python python/predict_rec.py \ +-c configs/inference_rec.yaml \ +-o Global.rec_inference_model_dir="../inference" +``` +得到的特征输出格式如下图所示: +![](../../images/feature_extraction_output.png) + +在实际使用过程中,单纯得到特征往往并不能够满足业务的需求。如果想进一步通过特征检索来进行图像识别,可以参照文档[向量检索](./vector_search.md)。 diff --git a/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/index.rst b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/index.rst new file mode 100644 index 0000000..6cf5e5a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/index.rst @@ -0,0 +1,9 @@ +图像识别流程 +================================ + +.. toctree:: + :maxdepth: 2 + + mainbody_detection.md + feature_extraction.md + vector_search.md diff --git a/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/mainbody_detection.md b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/mainbody_detection.md new file mode 100644 index 0000000..f3d7989 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/mainbody_detection.md @@ -0,0 +1,248 @@ +# 主体检测 + + +主体检测技术是目前应用非常广泛的一种检测技术,它指的是检测出图片中一个或者多个主体的坐标位置,然后将图像中的对应区域裁剪下来,进行识别,从而完成整个识别过程。主体检测是识别任务的前序步骤,可以有效提升识别精度。 + +本部分主要从数据集、模型选择和模型训练 3 个方面对该部分内容进行介绍。 + +---------- + +## 目录 + +- [1. 数据集](#1) +- [2. 模型选择](#2) + - [2.1 轻量级主体检测模型](#2.1) + - [2.2 服务端主体检测模型](#2.2) +- [3. 模型训练](#3) + - [3.1 环境准备](#3.1) + - [3.2 数据准备](#3.2) + - [3.3 配置文件改动和说明](#3.3) + - [3.4 启动训练](#3.4) + - [3.5 模型预测与调试](#3.5) + - [3.6 模型导出与预测部署](#3.6) + + + +## 1. 数据集 + +在 PaddleClas 的识别任务中,训练主体检测模型时主要用到了以下几个数据集。 + +| 数据集 | 数据量 | 主体检测任务中使用的数据量 | 场景 | 数据集地址 | +| ------------ | ------ | -------------------------- | ------------ | ---------------------------------------------------------- | +| Objects365 | 170W | 6k | 通用场景 | [地址](https://www.objects365.org/overview.html) | +| COCO2017 | 12W | 5k | 通用场景 | [地址](https://cocodataset.org/) | +| iCartoonFace | 2k | 2k | 动漫人脸检测 | [地址](https://github.com/luxiangju-PersonAI/iCartoonFace) | +| LogoDet-3k | 3k | 2k | Logo 检测 | [地址](https://github.com/Wangjing1551/LogoDet-3K-Dataset) | +| RPC | 3k | 3k | 商品检测 | [地址](https://rpc-dataset.github.io/) | + +在实际训练的过程中,将所有数据集混合在一起。由于是主体检测,这里将所有标注出的检测框对应的类别都修改为 `前景` 的类别,最终融合的数据集中只包含 1 个类别,即前景。 + + + +## 2. 模型选择 + +目标检测方法种类繁多,比较常用的有两阶段检测器(如 FasterRCNN 系列等);单阶段检测器(如 YOLO、SSD 等);anchor-free 检测器(如 PicoDet、FCOS 等)。PaddleDetection 中针对服务端使用场景,自研了 PP-YOLO 系列模型;针对端侧(CPU 和移动端等)使用场景,自研了 PicoDet 系列模型,在服务端和端侧均处于业界较为领先的水平。 + +基于上述研究,PaddleClas 中提供了 2 个通用主体检测模型,为轻量级与服务端主体检测模型,分别适用于端侧场景以及服务端场景。下面的表格中给出了在上述 5 个数据集上的平均 mAP 以及它们的模型大小、预测速度对比信息。 + +| 模型 | 模型结构 | 预训练模型下载地址 | inference 模型下载地址 | mAP | inference 模型大小(MB) | 单张图片预测耗时(不包含预处理)(ms) | +| ------------------ | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ----- | ---------------------- | ---------------------------------- | +| 轻量级主体检测模型 | PicoDet | [地址](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_pretrained.pdparams) | [tar 格式文件地址](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar) [zip 格式文件地址](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.zip) | 40.1% | 30.1 | 29.8 | +| 服务端主体检测模型 | PP-YOLOv2 | [地址](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/ppyolov2_r50vd_dcn_mainbody_v1.0_pretrained.pdparams) | [tar 格式文件地址](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar) [zip 格式文件地址](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.zip) | 42.5% | 210.5 | 466.6 | + +* 注意 + * 由于部分解压缩软件在解压上述 `tar` 格式文件时存在问题,建议非命令行用户下载 `zip` 格式文件并解压。`tar` 格式文件建议使用命令 `tar xf xxx.tar` 解压。 + * 速度评测机器的 CPU 具体信息为:`Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz`,速度指标为开启 mkldnn,线程数设置为 10 测试得到。 + * 主体检测的预处理过程较为耗时,平均每张图在上述机器上的时间在 40~55 ms 左右,没有包含在上述的预测耗时统计中。 + + + +### 2.1 轻量级主体检测模型 + +PicoDet 由 [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection) 提出,是一个适用于 CPU 或者移动端场景的目标检测算法。具体地,它融合了下面一系列优化算法。 + +- [ATSS](https://arxiv.org/abs/1912.02424) +- [Generalized Focal Loss](https://arxiv.org/abs/2006.04388) +- 余弦学习率策略 +- Cycle-EMA +- 轻量级检测 head + + +更多关于 PicoDet 的优化细节与 benchmark 可以参考 [PicoDet 系列模型介绍](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/picodet/README.md)。 + +在轻量级主体检测任务中,为了更好地兼顾检测速度与效果,我们使用 PPLCNet_x2_5 作为主体检测模型的骨干网络,同时将训练与预测的图像尺度修改为了 640x640,其余配置与 [picodet_lcnet_1_5x_416_coco.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/picodet/more_config/picodet_lcnet_1_5x_416_coco.yml) 完全一致。将数据集更换为自定义的主体检测数据集,进行训练,最终得到检测模型。 + + + +### 2.2 服务端主体检测模型 + +PP-YOLO 由 [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection) 提出,从骨干网络、数据增广、正则化策略、损失函数、后处理等多个角度对 yolov3 模型进行深度优化,最终在“速度-精度”方面达到了业界领先的水平。具体地,优化的策略如下。 + +- 更优的骨干网络: ResNet50vd-DCN +- 更大的训练 batch size: 8 GPUs,每 GPU batch_size=24,对应调整学习率和迭代轮数 +- [Drop Block](https://arxiv.org/abs/1810.12890) +- [Exponential Moving Average](https://www.investopedia.com/terms/e/ema.asp) +- [IoU Loss](https://arxiv.org/pdf/1902.09630.pdf) +- [Grid Sensitive](https://arxiv.org/abs/2004.10934) +- [Matrix NMS](https://arxiv.org/pdf/2003.10152.pdf) +- [CoordConv](https://arxiv.org/abs/1807.03247) +- [Spatial Pyramid Pooling](https://arxiv.org/abs/1406.4729) +- 更优的预训练模型 + +更多关于 PP-YOLO 的详细介绍可以参考:[PP-YOLO 模型](https://github.com/PaddlePaddle/PaddleDetection/blob/release%2F2.1/configs/ppyolo/README_cn.md)。 + +在服务端主体检测任务中,为了保证检测效果,我们使用 ResNet50vd-DCN 作为检测模型的骨干网络,使用配置文件 [ppyolov2_r50vd_dcn_365e_coco.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml),更换为自定义的主体检测数据集,进行训练,最终得到检测模型。 + + + +## 3. 模型训练 + +本节主要介绍怎样基于 PaddleDetection,基于自己的数据集,训练主体检测模型。 + + + +### 3.1 环境准备 + +下载 PaddleDetection 代码,安装 requirements。 + +```shell +cd +git clone https://github.com/PaddlePaddle/PaddleDetection.git + +cd PaddleDetection +# 安装其他依赖 +pip install -r requirements.txt +``` + +更多安装教程,请参考: [安装文档](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/docs/tutorials/INSTALL_cn.md) + + + +### 3.2 数据准备 + +对于自定义数据集,首先需要将自己的数据集修改为 COCO 格式,可以参考[自定义检测数据集教程](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/static/docs/tutorials/Custom_DataSet.md)制作 COCO 格式的数据集。 + +主体检测任务中,所有的检测框均属于前景,在这里需要将标注文件中,检测框的 `category_id` 修改为 1,同时将整个标注文件中的 `categories` 映射表修改为下面的格式,即整个类别映射表中只包含`前景`类别。 + +```json +[{u'id': 1, u'name': u'foreground', u'supercategory': u'foreground'}] +``` + + + +### 3.3 配置文件改动和说明 + +我们使用 `configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml` 配置进行训练,配置文件摘要如下: + +![](../../images/det/PaddleDetection_config.png) + +从上图看到 `ppyolov2_r50vd_dcn_365e_coco.yml` 配置需要依赖其他的配置文件,这些配置文件的含义如下: + +``` +coco_detection.yml:主要说明了训练数据和验证数据的路径 + +runtime.yml:主要说明了公共的运行参数,比如是否使用 GPU、每多少个 epoch 存储 checkpoint 等 + +optimizer_365e.yml:主要说明了学习率和优化器的配置 + +ppyolov2_r50vd_dcn.yml:主要说明模型和主干网络的情况 + +ppyolov2_reader.yml:主要说明数据读取器配置,如 batch size,并发加载子进程数等,同时包含读取后预处理操作,如 resize、数据增强等等 +``` + +在主体检测任务中,需要将 `datasets/coco_detection.yml` 中的 `num_classes` 参数修改为 1(只有 1 个前景类别),同时将训练集和测试集的路径修改为自定义数据集的路径。 + +此外,也可以根据实际情况,修改上述文件,比如,如果显存溢出,可以将 batch size 和学习率等比缩小等。 + + + +### 3.4 启动训练 + +PaddleDetection 提供了单卡/多卡训练模式,满足用户多种训练需求。 + +* GPU 单卡训练 + +```bash +# windows 和 Mac 下不需要执行该命令 +export CUDA_VISIBLE_DEVICES=0 +python tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml +``` + +* GPU 多卡训练 + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --eval +``` + +--eval:表示边训练边验证。 + + +* (**推荐**)模型微调 +如果希望加载 PaddleClas 中已经训练好的主体检测模型,在自己的数据集上进行模型微调,可以使用下面的命令进行训练。 + +```bash +export CUDA_VISIBLE_DEVICES=0 +# 指定 pretrain_weights 参数,加载通用的主体检测预训练模型 +python tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml -o pretrain_weights=https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/ppyolov2_r50vd_dcn_mainbody_v1.0_pretrained.pdparams +``` + +* 模型恢复训练 + +在日常训练过程中,有的用户由于一些原因导致训练中断,可以使用 `-r` 的命令恢复训练: + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --eval -r output/ppyolov2_r50vd_dcn_365e_coco/10000 +``` + +注意:如果遇到 "`Out of memory error`" 问题, 尝试在 `ppyolov2_reader.yml` 文件中调小 `batch_size`,同时等比例调小学习率。 + + + +### 3.5 模型预测与调试 + +使用下面的命令完成 PaddleDetection 的预测过程。 + +```bash +export CUDA_VISIBLE_DEVICES=0 +python tools/infer.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --infer_img=your_image_path.jpg --output_dir=infer_output/ --draw_threshold=0.5 -o weights=output/ppyolov2_r50vd_dcn_365e_coco/model_final +``` + +`--draw_threshold` 是个可选参数. 根据 [NMS](https://ieeexplore.ieee.org/document/1699659) 的计算,不同阈值会产生不同的结果 `keep_top_k` 表示设置输出目标的最大数量,默认值为 100,用户可以根据自己的实际情况进行设定。 + + + +### 3.6 模型导出与预测部署。 + +执行导出模型脚本: + +```bash +python tools/export_model.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --output_dir=./inference -o weights=output/ppyolov2_r50vd_dcn_365e_coco/model_final.pdparams +``` + +预测模型会导出到 `inference/ppyolov2_r50vd_dcn_365e_coco` 目录下,分别为 `infer_cfg.yml` (预测不需要), `model.pdiparams`, `model.pdiparams.info`, `model.pdmodel` 。 + +注意: `PaddleDetection` 导出的 inference 模型的文件格式为 `model.xxx`,这里如果希望与 PaddleClas 的 inference 模型文件格式保持一致,需要将其 `model.xxx` 文件修改为 `inference.xxx` 文件,用于后续主体检测的预测部署。 + +更多模型导出教程,请参考: [EXPORT_MODEL](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/deploy/EXPORT_MODEL.md) + +最终,目录 `inference/ppyolov2_r50vd_dcn_365e_coco` 中包含 `inference.pdiparams`, `inference.pdiparams.info` 以及 `inference.pdmodel` 文件,其中 `inference.pdiparams` 为保存的 inference 模型权重文件,`inference.pdmodel` 为保存的 inference 模型结构文件。 + + +导出模型之后,在主体检测与识别任务中,就可以将检测模型的路径更改为该 inference 模型路径,完成预测。 + +以商品识别为例,其配置文件为 [inference_product.yaml](../../../deploy/configs/inference_product.yaml),修改其中的 `Global.det_inference_model_dir` 字段为导出的主体检测 inference 模型目录,参考[图像识别快速开始教程](../quick_start/quick_start_recognition.md),即可完成商品检测与识别过程。 + + +### FAQ + +#### Q:可以使用其他的主体检测模型结构吗? + +* A:可以的,但是目前的检测预处理过程仅适配了 PicoDet 以及 YOLO 系列的预处理,因此在使用的时候,建议优先使用这两个系列的模型进行训练,如果希望使用 Faster RCNN 等其他系列的模型,需要按照 PaddleDetection 的数据预处理,修改下预处理逻辑,这块如果您有需求或者有问题的话,欢迎提 issue 或者在微信群里反馈。 + +#### Q:可以修改主体检测的预测尺度吗? + +* A:可以的,但是需要注意 2 个地方 + * PaddleClas 中提供的主体检测模型是基于 `640x640` 的分辨率去训练的,因此预测的时候也是默认使用 `640x640` 的分辨率进行预测,使用其他分辨率预测的话,精度会有所降低。 + * 在模型导出的时候,建议也修改下模型导出的分辨率,保持模型导出、模型预测的分辨率一致。 diff --git a/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/vector_search.md b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/vector_search.md new file mode 100644 index 0000000..6cf4d20 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/image_recognition_pipeline/vector_search.md @@ -0,0 +1,120 @@ +# 向量检索 + +向量检索技术在图像识别、图像检索中应用比较广泛。其主要目标是,对于给定的查询向量,在已经建立好的向量库中,与库中所有的待查询向量,进行特征向量的相似度或距离计算,得到相似度排序。在图像识别系统中,我们使用 [Faiss](https://github.com/facebookresearch/faiss) 对此部分进行支持,具体信息请详查 [Faiss 官网](https://github.com/facebookresearch/faiss)。`Faiss` 主要有以下优势 + +- 适配性好:支持 Windos、Linux、MacOS 系统 +- 安装方便: 支持 `python` 接口,直接使用 `pip` 安装 +- 算法丰富:支持多种检索算法,满足不同场景的需求 +- 同时支持 CPU、GPU,能够加速检索过程 + +值得注意的是,为了更好是适配性,目前版本,`PaddleClas` 中暂时**只使用 CPU 进行向量检索**。 + +![](../../images/structure.jpg) + +如上图中所示,向量检索部分,在整个 `PP-ShiTu` 系统中有两部分内容 + +- 图中绿色部分:建立检索库,供检索时查询使用,同时提供增、删等功能 +- 图中蓝色部分:检索功能,即给定一张图的特征向量,返回库中相似图像的 label + +本文档主要主要介绍 PaddleClas 中检索模块的安装、使用的检索算法、建库流程的及相关配置文件中参数介绍。 + +-------------------------- + +## 目录 + +- [1. 检索库安装](#1) +- [2. 使用的检索算法](#2) +- [3. 使用及配置文档介绍](#3) + - [3.1 建库及配置文件参数](#3.1) + - [3.2 检索配置文件参数](#3.2) + + + +## 1. 检索库安装 + +`Faiss` 具体安装方法如下: + +```python +pip install faiss-cpu==1.7.1post2 +``` + +若使用时,不能正常引用,则 `uninstall` 之后,重新 `install`,尤其是 `windows` 下。 + + + +## 2. 使用的检索算法 + +目前 `PaddleClas` 中检索模块,支持如下三种检索算法 + +- **HNSW32**: 一种图索引方法。检索精度较高,速度较快。但是特征库只支持添加图像功能,不支持删除图像特征功能。(默认方法) +- **IVF**:倒排索引检索方法。速度较快,但是精度略低。特征库支持增加、删除图像特征功能。 +- **FLAT**: 暴力检索算法。精度最高,但是数据量大时,检索速度较慢。特征库支持增加、删除图像特征功能。 + +每种检索算法,满足不同场景。其中 `HNSW32` 为默认方法,此方法的检索精度、检索速度可以取得一个较好的平衡,具体算法介绍可以查看[官方文档](https://github.com/facebookresearch/faiss/wiki)。 + + + +## 3. 使用及配置文档介绍 + +涉及检索模块配置文件位于:`deploy/configs/` 下,其中 `build_*.yaml` 是建立特征库的相关配置文件,`inference_*.yaml` 是检索或者分类的推理配置文件。 + + + +### 3.1 建库及配置文件参数 + +建库的具体操作如下: + +```shell +# 进入 deploy 目录 +cd deploy +# yaml 文件根据需要改成自己所需的具体 yaml 文件 +python python/build_gallery.py -c configs/build_***.yaml +``` + +其中 `yaml` 文件的建库的配置如下,在运行时,请根据实际情况进行修改。建库操作会将根据 `data_file` 的图像列表,将 `image_root` 下的图像进行特征提取,并在 `index_dir` 下进行存储,以待后续检索使用。 + +其中 `data_file` 文件存储的是图像文件的路径和标签,每一行的格式为:`image_path label`。中间间隔以 `yaml` 文件中 `delimiter` 参数作为间隔。 + +关于特征提取的具体模型参数,可查看 `yaml` 文件。 + +```yaml +# indexing engine config +IndexProcess: + index_method: "HNSW32" # supported: HNSW32, IVF, Flat + index_dir: "./recognition_demo_data_v1.1/gallery_product/index" + image_root: "./recognition_demo_data_v1.1/gallery_product/" + data_file: "./recognition_demo_data_v1.1/gallery_product/data_file.txt" + index_operation: "new" # suported: "append", "remove", "new" + delimiter: "\t" + dist_type: "IP" + embedding_size: 512 +``` + +- **index_method**:使用的检索算法。目前支持三种,HNSW32、IVF、Flat +- **index_dir**:构建的特征库所存放的文件夹 +- **image_root**:构建特征库所需要的标注图像所存储的文件夹位置 +- **data_file**:构建特征库所需要的标注图像的数据列表,每一行的格式:relative_path label +- **index_operation**: 此次运行建库的操作:`new` 新建,`append` 将 data_file 的图像特征添加到特征库中,`remove` 将 data_file 的图像从特征库中删除 +- **delimiter**:**data_file** 中每一行的间隔符 +- **dist_type**: 特征匹配过程中使用的相似度计算方式。例如 `IP` 内积相似度计算方式,`L2` 欧式距离计算方法 +- **embedding_size**:特征维度 + + + +### 3.2 检索配置文件参数 + +将检索的过程融合到 `PP-ShiTu` 的整体流程中,请参考 [README](../../../README_ch.md) 中 `PP-ShiTu 图像识别系统介绍` 部分。检索具体使用操作请参考[识别快速开始文档](../quick_start/quick_start_recognition.md)。 + +其中,检索部分配置如下,整体检索配置文件,请参考 `deploy/configs/inference_*.yaml` 文件。 + +```yaml +IndexProcess: + index_dir: "./recognition_demo_data_v1.1/gallery_logo/index/" + return_k: 5 + score_thres: 0.5 +``` + +与建库配置文件不同,新参数主要如下: + +- `return_k`: 检索结果返回 `k` 个结果 +- `score_thres`: 检索匹配的阈值 diff --git a/src/PaddleClas/docs/zh_CN/index.rst b/src/PaddleClas/docs/zh_CN/index.rst new file mode 100644 index 0000000..a41ca9b --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/index.rst @@ -0,0 +1,18 @@ +欢迎使用PaddleClas图像分类库! +================================ + +.. toctree:: + :maxdepth: 1 + + introduction/index + installation/index + quick_start/index + image_recognition_pipeline/index + data_preparation/index + models_training/index + inference_deployment/index + models/index + algorithm_introduction/index + advanced_tutorials/index + others/index + faq_series/index diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/cpp_deploy.md b/src/PaddleClas/docs/zh_CN/inference_deployment/cpp_deploy.md new file mode 100644 index 0000000..cb7e9f3 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/cpp_deploy.md @@ -0,0 +1,298 @@ +# 服务器端 C++ 预测 + +本教程将介绍在服务器端部署 PaddleClas 分类模型的详细步骤,识别模型部署方式将在近期支持,敬请期待。 + +--- + +## 目录 + +- [1. 准备环境](#1) + - [1.1 编译 opencv 库](#1.1) + - [1.2 准备环境](#1.2) + - [1.2.1 预测库源码编译](#1.2.1) + - [1.2.2 直接下载安装](#1.2.2) +- [2. 编译](#2) + - [2.1 编译 PaddleClas C++ 预测 demo](#2.1) + - [2.2 编译 config lib 预测库与 cls lib 预测库](#2.2) +- [3. 运行](#3) + - [3.1 准备 inference model](#3.1) + - [3.2 运行 demo](#3.2) + + + +## 1. 准备环境 + +- Linux 环境,推荐使用 docker。 +- Windows 环境,目前支持基于 `Visual Studio 2019 Community` 进行编译;此外,如果您希望通过生成 `sln 解决方案` 的方式进行编译,可以参考该文档:[https://zhuanlan.zhihu.com/p/145446681](https://zhuanlan.zhihu.com/p/145446681) + +* 该文档主要介绍基于 Linux 环境下的 PaddleClas C++ 预测流程,如果需要在 Windows 环境下使用预测库进行 C++ 预测,具体编译方法请参考 [Windows 下编译教程](./cpp_deploy_on_windows.md)。 + + +### 1.1 编译 opencv 库 + +* 首先需要从 opencv 官网上下载在 Linux 环境下源码编译的包,以 3.4.7 版本为例,下载及解压缩命令如下: + +``` +wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz +tar -xvf 3.4.7.tar.gz +``` + +执行完成上述命令后,会在当前目录下生成 `opencv-3.4.7/` 的目录。 + +* 编译 opencv,首先设置 opencv 源码路径(`root_path`)以及安装路径(`install_path`),`root_path` 为下载的 opencv 源码路径,`install_path` 为 opencv 的安装路径。在本例中,源码路径即为当前目录下的 `opencv-3.4.7/`。 + +```shell +cd ./opencv-3.4.7 +export root_path=$PWD +export install_path=${root_path}/opencv3 +``` + +* 然后在 opencv 源码路径下,按照下面的命令进行编译: + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + +make -j +make install +``` + +* 执行完成上述命令后,会生成 opencv 头文件和库文件,用于后面的 PaddleClas 代码编译。 + +以 opencv3.4.7 版本为例,最终在安装路径下的文件结构如下所示。**注意**:不同的 opencv 版本,下述的文件结构可能不同。 + +``` +opencv3/ +|-- bin +|-- include +|-- lib64 +|-- share +``` + + +### 1.2 获取 Paddle 预测库 + +* 有 2 种方式获取 Paddle 预测库,下面进行详细介绍。 + + +#### 1.2.1 预测库源码编译 +如果希望获取最新预测库特性,可以从 GitHub 上克隆 Paddle 最新代码,从源码编译预测库。对于不同平台的编译流程,请参考 [Paddle 预测库官网](https://paddleinference.paddlepaddle.org.cn/v2.1/user_guides/source_compile.html) 的说明。编译示例如下: + +1. 使用 Git 获取源代码: + +```shell +git clone https://github.com/PaddlePaddle/Paddle.git +cd Paddle +``` + +2. 进入 `Paddle` 目录后,开始进行编译: + +```shell +rm -rf build +mkdir build +cd build + +cmake .. \ + -DWITH_CONTRIB=OFF \ + -DWITH_MKL=ON \ + -DWITH_MKLDNN=ON \ + -DWITH_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_INFERENCE_API_TEST=OFF \ + -DON_INFER=ON \ + -DWITH_PYTHON=ON +make -j +make inference_lib_dist +``` + +关于编译参数选项可以参考 Paddle C++ 预测库官网:[编译选项表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#bianyixuanxiangbiao)。 + + +3. 编译完成之后,可以在 `./build/paddle_inference_install_dir/` 文件下看到以下文件及目录: + +``` +build/paddle_inference_install_dir/ +|-- CMakeCache.txt +|-- paddle +|-- third_party +|-- version.txt +``` + + +#### 1.2.2 直接下载安装 + +[Paddle 预测库官网](https://paddleinference.paddlepaddle.org.cn/v2.1/user_guides/download_lib.html#c) 上提供了不同版本的 Paddle 预测库,包括多个操作系统平台和 GPU、CPU 等多个硬件平台的预编译库,可以在官网查找并选择合适的预测库版本进行下载,建议选择 `2.1.1` 版本。 + +**注意**:在选择预测库时,所选预测库版本需要与后续编译选项一致: +* CPU 预测库仅可用于 GPU 预测,具体又分为 `mkl` 和 `openblas`,分别对应其低层实现基于 `MKL` 数学运算库 和 `OpenBLAS` 数学运算库; +* GPU 预测库支持 GPU 预测和 CPU 预测,其 GPU 预测功能底层实现基于 CUDA、cuDNN,CPU 预测功能底层基于 `MKL` 实现。 + +以 `manylinux_cuda10.2_cudnn8.1_avx_mkl_trt7_gcc8.2` 的 `2.1.1` 版本为例,可使用下述命令下载并解压: + +```shell +wget https://paddle-inference-lib.bj.bcebos.com/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddle_inference.tgz +tar -xf paddle_inference.tgz +``` + +上述命令会在当前目录下生成 `paddle_inference/` 目录。 + + +## 2. 编译 + + +### 2.1 编译 PaddleClas C++ 预测 demo + +编译命令如下,其中 Paddle C++ 预测库、OpenCV 等依赖库的路径需要根据机器上的实际位置进行修改。 + +```shell +sh tools/build_demo.sh +``` + +具体地,`tools/build_demo.sh` 中内容如下: + +```shell +OpenCV_DIR=path/to/opencv +PADDLE_LIB_DIR=path/to/paddle +CUDA_LIB_DIR=path/to/cuda +CUDNN_LIB_DIR=path/to/cudnn +TENSORRT_LIB_DIR=path/to/tensorrt +CONFIG_LIB_PATH=path/to/config/library +CLS_LIB_PATH=path/to/cls/library +CMP_STATIC=ON + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DWITH_MKL=ON \ + -DWITH_GPU=ON \ + -DWITH_TENSORRT=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DOpenCV_DIR=${OpenCV_DIR} \ + -DPADDLE_LIB=${PADDLE_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCONFIG_LIB=${CONFIG_LIB_PATH} \ + -DCLS_LIB=${CLS_LIB_PATH} \ + -DCMP_STATIC=OFF \ + +make -j +``` + +上述命令中,各个编译选项的具体说明如下: +* `DWITH_MKL`:是否使用 MKL 数学运算库,默认为 `ON`,注意需要与下载的预测库版本一致。如为 `OpenBLAS` 版本预测库,则需设置为 `OFF`; +* `DWITH_GPU`:使用使用 GPU 预测库,默认为 `OFF`,当下载预测库版本为 GPU 预测库时,可置为 `ON`,同时请设置 `DCUDA_LIB` 与 `DCUDNN_LIB`,否则请设置为 `OFF`; +* `DWITH_TENSORRT`:是否使用 TensorRT,默认为 `OFF`,当 `DWITH_GPU` 设置为 `ON` 时有效,同时请设置 `DTENSORRT_LIB`; +* `DWITH_STATIC_LIB`:是否使用 Paddle 预测库中的静态链接库,默认为 `OFF`; +* `DOpenCV_DIR`:OpenCV 编译库的路径,本例中为 `opencv-3.4.7/opencv3/share/OpenCV`,注意该路径下需要有 `OpenCVConfig.cmake` 文件; +* `DPADDLE_LIB`:Paddle 预测库路径,一般使用下载并解压的预编译库路径 `paddle_inference` 即可,或编译生成的预测库的路径 `build/paddle_inference_install_dir`,注意该路径下需要有 `paddle` 和 `third_party` 两个子路径; +* `DCUDA_LIB`:CUDA 库路径,当 `DWITH_GPU` 设置为 `ON` 时有效,在 docker 中通常为 `/usr/local/cuda/lib64`; +* `DCUDNN_LIB`:cuDNN 库路径,当 `DWITH_GPU` 设置为 `ON` 时有效,在 docker 中通常为 `/usr/lib/x86_64-linux-gnu/`; +* `DTENSORRT_LIB`:TensorRT 库路径,当 `DWITH_GPU` 与 `DUSE_TENSORRT` 均设置为 `ON` 时有效,在 dokcer 中通常为 `/usr/local/TensorRT6-cuda10.0-cudnn7/`; +* `DCONFIG_LIB`:如需使用已编译好的 `config lib`,请设置为 `config lib` 的路径,否则请删除该选项; +* `DCLS_LIB`:如需使用已编译好的 `cls lib`,请设置为 `cls lib` 的路径,否则请删除该选项; +* `DCMP_STATIC`:是否将 `config lib` 和 `cls lib` 编译为静态链接库,默认为 `ON`,如需编译为动态链接库,请设置为 `OFF`。 + +在执行上述命令,编译完成之后,会在当前路径下生成 `build` 目录,其中有可执行文件 `clas_system`。并且,如未设置 `DCONFIG_LIB` 与 `DCLS_LIB`,则会在 `.\lib\` 路径下生成 `config lib` 和 `cls lib` 两个库文件,根据 `DCMP_STATIC` 的设置,两个库文件将被编译为静态链接库(`libconfig.a`、`libcls.a`)或动态链接库(`libconfig.so`、`libcls.so`)。 + + +### 2.2 编译 config lib 预测库与 cls lib 预测库 + +除了可以直接编译 demo,也同样可以仅编译 config lib 和 cls lib 预测库,只需运行如下命令: + +```shell +sh tools/build_lib.sh +``` + +具体地,`tools/build_lib.sh` 中内容如下: + +```shell +OpenCV_DIR=path/to/opencv +PADDLE_LIB_DIR=path/to/paddle + +BUILD_DIR=./lib/build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +cmake .. \ + -DOpenCV_DIR=${OpenCV_DIR} \ + -DPADDLE_LIB=${PADDLE_LIB_DIR} \ + -DCMP_STATIC=ON \ + +make +``` + +上述命令中,各个编译选项的具体说明如下: +* `DOpenCV_DIR`:OpenCV 编译库的路径,本例中为 `opencv-3.4.7/opencv3/share/OpenCV`,注意该路径下需要有 `OpenCVConfig.cmake` 文件; +* `DPADDLE_LIB`:Paddle 预测库路径,一般使用下载并解压的预编译库路径 `paddle_inference` 即可,或编译生成的预测库的路径 `build/paddle_inference_install_dir`,注意该路径下需要有 `paddle` 和 `third_party` 两个子路径; +* `DCMP_STATIC`:是否将 `config lib` 和 `cls lib` 编译为静态链接库(`.a`),默认为 `ON`,如需编译为动态链接库(`.so`),请设置为 `OFF`。 + +执行上述命令后,将在目录 `./lib/` 下生成 `config lib` 和 `cls lib` 的动态链接库(`libcls.so` 和 `libconfig.so`)或静态链接库(`libcls.a` 和 `libconfig.a`)。在[2.1 编译 PaddleClas C++ 预测 demo](#2.1)中,可以通过指定编译选项 `DCLS_LIB` 和 `DCONFIG_LIB` 指定已有链接库的路径,链接库同样也可用于二次开发。 + + +## 3. 运行 + + +### 3.1 准备 inference model + +首先需要准备 inference model,关于将模型导出为 inference model 的具体步骤,可以参考 [模型导出](./export_model.md) 文档。假设导出的预测模型文件放在 `./inference` 目录下,则目录结构如下。 + +``` +inference/ +|--inference.pdmodel +|--inference.pdiparams +``` + +**注意**:上述文件中,`cls_infer.pdmodel` 文件存储了模型网络结构信息,`cls_infer.pdiparams` 文件存储了模型参数权重信息。在运行预测时,注意两个文件的路径需要分别设置为配置文件 `tools/config.txt` 中的字段 `cls_model_path` 和 `cls_params_path` 的值。 + + +### 3.2 运行 demo + +首先修改 `tools/config.txt` 中对应字段: +* use_gpu:是否使用 GPU; +* gpu_id:使用的 GPU 卡号; +* gpu_mem:显存; +* cpu_math_library_num_threads:底层科学计算库所用线程的数量; +* use_mkldnn:是否使用 MKLDNN 加速; +* use_tensorrt: 是否使用 tensorRT 进行加速; +* use_fp16:是否使用半精度浮点数进行计算,该选项仅在 use_tensorrt 为 true 时有效; +* cls_model_path:预测模型结构文件路径; +* cls_params_path:预测模型参数文件路径; +* resize_short_size:预处理时图像缩放大小; +* crop_size:预处理时图像裁剪后的大小。 + +然后修改 `tools/run.sh`: + * `./build/clas_system ./tools/config.txt ./docs/imgs/ILSVRC2012_val_00000666.JPEG` + * 上述命令中分别为:编译得到的可执行文件 `clas_system`;运行时的配置文件 `config.txt`;待预测的图像。 + +* 最后执行以下命令,完成对一幅图像的分类。 + +```shell +sh tools/run.sh +``` + +* 最终屏幕上会输出结果,如下图所示。 + +![](../../images/inference_deployment/cpp_infer_result.png) + +其中 `class id` 表示置信度最高的类别对应的 id,score 表示图片属于该类别的概率。 diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/cpp_deploy_on_windows.md b/src/PaddleClas/docs/zh_CN/inference_deployment/cpp_deploy_on_windows.md new file mode 100644 index 0000000..b7089cb --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/cpp_deploy_on_windows.md @@ -0,0 +1,165 @@ +# 基于 Visual Studio 2019 Community CMake 编译指南 + +PaddleClas 在 Windows 平台下基于 `Visual Studio 2019 Community` 进行了测试。微软从 `Visual Studio 2017` 开始即支持直接管理 `CMake` 跨平台编译项目,但是直到 `2019` 版才提供了稳定和完全的支持,所以如果你想使用 CMake 管理项目编译构建,我们推荐使用 `Visual Studio 2019`。如果您希望通过生成 `sln 解决方案` 的方式进行编译,可以参考该文档:[https://zhuanlan.zhihu.com/p/145446681](https://zhuanlan.zhihu.com/p/145446681)。 + +----- +## 目录 +* [1. 前置条件](#1) + * [1.1 下载 PaddlePaddle C++ 预测库 paddle_inference_install_dir](#1.1) + * [1.2 安装配置 OpenCV](#1.2) +* [2. 使用 Visual Studio 2019 编译](#2) +* [3. 预测](#3) + * [3.1 准备 inference model](#3.1) + * [3.2 运行预测](#3.2) + * [3.3 注意事项](#3.3) + + +## 1. 前置条件 +* Visual Studio 2019 +* CUDA 9.0 / CUDA 10.0,cudnn 7.6+(仅在使用 GPU 版本的预测库时需要) +* CMake 3.0+ + +请确保系统已经正确安装并配置好上述基本软件,其中: + * 在安装 `Visual Studio 2019` 时,`工作负载` 需要勾选 `使用 C++的桌面开发`; + * CUDA 需要正确安装并设置系统环境变量; + * CMake 需要正确安装并将路径添加到系统环境变量中。 + +以下示例基于 `Visual Studio 2019 Community` 版本,以工作目录为 `D:\projects` 进行演示。 + + +### 1.1 下载 PaddlePaddle C++ 预测库 paddle_inference_install_dir + +PaddlePaddle C++ 预测库针对不同的 `CPU `和 `CUDA` 版本提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://paddleinference.paddlepaddle.org.cn/user_guides/download_lib.html#windows),建议选择 `2.1.1` 版本。 + +**注意**:在选择预测库时,所选预测库版本需要与后续编译选项一致: +* CPU 预测库仅可用于 GPU 预测,具体又分为 `mkl` 和 `openblas`,分别对应其低层实现基于 `MKL` 数学运算库 和 `OpenBLAS` 数学运算库; +* GPU 预测库支持 GPU 预测和 CPU 预测,其 GPU 预测功能底层实现基于 CUDA、cuDNN,CPU 预测功能底层基于 `MKL` 实现。 + +下载并解压后,目录 `D:\projects\paddle_inference_install_dir` 包含内容为: + +``` +paddle_inference_install_dir +├── paddle # paddle 核心库和头文件 +├── third_party # 第三方依赖库和头文件 +└── version.txt # 版本和编译信息 +``` + +**注意**:需要将 `Paddle 预测库` 的路径(`D:\projects\paddle_inference_install_dir\paddle\lib`)添加到系统环境变量 `Path` 中。 + + +### 1.2 安装配置 OpenCV + +1. 在 OpenCV 官网下载适用于 Windows 平台的 3.4.6 版本,[下载地址](https://sourceforge.net/projects/opencvlibrary/files/3.4.6/opencv-3.4.6-vc14_vc15.exe/download); +2. 运行下载的可执行文件,将 OpenCV 解压至指定目录,如 `D:\projects\opencv`; +3. 配置环境变量,如下流程所示: + * 此电脑(我的电脑)-> 属性 -> 高级系统设置 -> 环境变量; + * 在系统变量中找到 Path(如没有,自行创建),并双击编辑; + * 新建,将 OpenCV 路径填入并保存,如 `D:\projects\opencv\build\x64\vc14\bin`; + + +## 2. 使用 Visual Studio 2019 编译 + +1. 打开 Visual Studio 2019 Community,点击 `继续但无需代码` + +![step2](../../images/inference_deployment/vs2019_step1.png) + +2. 点击:`文件`->`打开`->`CMake` + +![step2.1](../../images/inference_deployment/vs2019_step2.png) + +选择项目代码所在路径,并打开 `CMakeList.txt`: + +![step2.2](../../images/inference_deployment/vs2019_step3.png) + +3. 点击:`项目`->`CMake 设置` + +![step3](../../images/inference_deployment/vs2019_step4.png) + +4. 请设置以下参数的值 + +| 名称 | 值 | 保存到 JSON | +| ----------------------------- | ------------------ | ----------- | +| CMAKE_BACKWARDS_COMPATIBILITY | 3.17 | [√] | +| CMAKE_BUILD_TYPE | RelWithDebInfo | [√] | +| CUDA_LIB | CUDA 的库路径 | [√] | +| CUDNN_LIB | CUDNN 的库路径 | [√] | +| OpenCV_DIR | OpenCV 的安装路径 | [√] | +| PADDLE_LIB | Paddle 预测库的路径 | [√] | +| WITH_GPU | [√] | [√] | +| WITH_MKL | [√] | [√] | +| WITH_STATIC_LIB | [√] | [√] | + +除上述选项外,还有以下两个选项可依据具体情况设置: +* `DCONFIG_LIB`:如需使用已编译好的 `config lib`,请设置为 `config lib` 的路径,否则请删除该选项; +* `DCLS_LIB`:如需使用已编译好的 `cls lib`,请设置为 `cls lib` 的路径,否则请删除该选项; + +**注意**: +* `CMAKE_BACKWARDS_COMPATIBILITY` 的值请根据自己 `cmake` 版本设置,`cmake` 版本可以通过命令:`cmake --version` 查询; +* `CUDA_LIB` 、 `CUDNN_LIB` 的值仅需在使用 **GPU 版本**预测库时指定,其中 CUDA 库版本尽量对齐,**使用 9.0、10.0 版本,不使用 9.2、10.1 等版本 CUDA 库**; +* 在设置 `CUDA_LIB`、`CUDNN_LIB`、`OPENCV_DIR`、`PADDLE_LIB` 时,点击 `浏览`,分别设置相应的路径; + * `CUDA_LIB` 和 `CUDNN_LIB`:该路径取决于 CUDA 与 CUDNN 的安装位置。 + * `OpenCV_DIR`:该路径下需要有`.cmake` 文件,一般为 `opencv/build/`; + * `PADDLE_LIB`:该路径下需要有 `CMakeCache.txt` 文件,一般为 `paddle_inference_install_dir/`。 +* 在使用 `CPU` 版预测库时,请不要勾选 `WITH_GPU` - `保存到 JSON`。 + +![step4](../../images/inference_deployment/vs2019_step5.png) + +设置完成后,点击上图中 `保存并生成 CMake 缓存以加载变量`。 + +5. 点击`生成`->`全部生成` + +![step6](../../images/inference_deployment/vs2019_step6.png) + +在编译完成后,会生成可执行文件 `clas_system.exe`。并且,如未设置 `DCONFIG_LIB` 与 `DCLS_LIB`,则会在 `.\lib\` 目录下生成 `config lib` 和 `cls lib` 两个静态链接库文件(`libconfig.a`、`libcls.a`)。类似地,你也可以仅编译生成 `config lib` 和 `cls lib` 两个静态链接库文件,只需打开路径为 `D:\projects\PaddleClas\deploy\cpp\lib\CMakeList.txt` 的 `CMake` 文件并进行编译即可,具体参考[2. 使用 Visual Studio 2019 编译](#2),完成编译后,同样可在 `.\lib\` 目录下生成静态链接库文件,静态链接库文件可用于二次开发。 + + +## 3. 预测 + + +### 3.1 准备 inference model + +首先需要准备 inference model,关于将模型导出为 inference model 的具体步骤,可以参考 [模型导出](./export_model.md) 文档。假设导出的预测模型文件放在 `./inference` 目录下,则目录结构如下。 + +``` +inference/ +|--inference.pdmodel +|--inference.pdiparams +``` + +**注意**:上述文件中,`cls_infer.pdmodel` 文件存储了模型网络结构信息,`cls_infer.pdiparams` 文件存储了模型参数权重信息。在运行预测时,注意两个文件的路径需要分别设置为配置文件 `tools/config.txt` 中的字段 `cls_model_path` 和 `cls_params_path` 的值。 + + +### 3.2 运行预测 + +首先修改 `tools/config.txt` 中对应字段: +* use_gpu:是否使用 GPU; +* gpu_id:使用的 GPU 卡号; +* gpu_mem:显存; +* cpu_math_library_num_threads:底层科学计算库所用线程的数量; +* use_mkldnn:是否使用 MKLDNN 加速; +* use_tensorrt: 是否使用 tensorRT 进行加速; +* use_fp16:是否使用半精度浮点数进行计算,该选项仅在 use_tensorrt 为 true 时有效; +* cls_model_path:预测模型结构文件路径; +* cls_params_path:预测模型参数文件路径; +* resize_short_size:预处理时图像缩放大小; +* crop_size:预处理时图像裁剪后的大小。 + +`Visual Studio 2019` 编译产出的可执行文件 `clas_system.exe` 在 `out\build\x64-Release` 目录下,打开 `cmd`,并切换到该目录: + +```shell +cd D:\projects\PaddleClas\deploy\cpp\out\build\x64-Release +``` + +可执行文件 `clas_system.exe` 即为编译产出的的预测程序,运行下述命令即可执行预测: +```shell +.\clas_system.exe D:\projects\PaddleClas\deploy\cpp\tools\config.txt .\docs\ILSVRC2012_val_00008306.JPEG +``` + +上述命令中,第一个参数(`D:\projects\PaddleClas\deploy\cpp\tools\config.txt`)为配置文件路径,第二个参数(`.\docs\ILSVRC2012_val_00008306.JPEG`)为需要预测的图片路径。 + +注意,需要在配置文件中正确设置预测参数,包括所用模型文件的路径(`cls_model_path` 和 `cls_params_path`)。 + +### 3.3 注意事项 +* 在 Windows 下的终端中执行文件 exe 时,可能会发生乱码的现象,此时需要在终端中输入 `CHCP 65001`,将终端的编码方式由 GBK 编码(默认)改为 UTF-8 编码,更加具体的解释可以参考这篇博客:[https://blog.csdn.net/qq_35038153/article/details/78430359](https://blog.csdn.net/qq_35038153/article/details/78430359); +* 如果需要使用 CPU 预测,PaddlePaddle 在 Windows 上仅支持 avx 的 CPU 预测,目前不支持 noavx 的 CPU 预测; +* 在使用生成的 `clas_system.exe` 进行预测时,如提示 `由于找不到 paddle_fluid.dll,无法继续执行代码。重新安装程序可能会解决此问题`,请检查是否将 Paddle 预测库路径添加到系统环境变量,详见[1.1 下载 PaddlePaddle C++ 预测库 paddle_inference_install_dir](#1.1)。 diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/export_model.md b/src/PaddleClas/docs/zh_CN/inference_deployment/export_model.md new file mode 100644 index 0000000..1d8decb --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/export_model.md @@ -0,0 +1,99 @@ +# 模型导出 + +PaddlePaddle 支持导出 inference 模型用于部署推理场景,相比于训练调优场景,inference 模型会将网络权重与网络结构进行持久化存储,并且 PaddlePaddle 支持使用预测引擎加载 inference 模型进行预测推理。 + +--- + + +## 目录 + +- [1. 环境准备](#1) +- [2. 分类模型导出](#2) +- [3. 主体检测模型导出](#3) +- [4. 识别模型导出](#4) +- [5. 命令参数说明](#5) + + + +## 1. 环境准备 + +首先请参考文档[安装 PaddlePaddle](../installation/install_paddle.md)和文档[安装 PaddleClas](../installation/install_paddleclas.md)配置运行环境。 + + +## 2. 分类模型导出 + +进入 PaddleClas 目录下: + +```shell +cd /path/to/PaddleClas +``` + +以 ResNet50_vd 分类模型为例,下载预训练模型: + +```shell +wget -P ./cls_pretrain/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams +``` + +上述模型是使用 ResNet50_vd 在 ImageNet 上训练的模型,使用的配置文件为 `ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml`,将该模型转为 inference 模型只需运行如下命令: + +```shell +python tools/export_model.py \ + -c ./ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml \ + -o Global.pretrained_model=./cls_pretrain/ResNet50_vd_pretrained \ + -o Global.save_inference_dir=./deploy/models/class_ResNet50_vd_ImageNet_infer +``` + + +## 3. 主体检测模型导出 + +主体检测模型的导出,可以参考[主题检测介绍](../image_recognition_pipeline/mainbody_detection.md)。 + + +## 4. 识别模型导出 + +进入 PaddleClas 目录下: + +```shell +cd /path/to/PaddleClas +``` + +以商品识别特征提取模型为例,下载预训练模型: + +```shell +wget -P ./product_pretrain/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/product_ResNet50_vd_Aliproduct_v1.0_pretrained.pdparams +``` + +上述模型是 ResNet50_vd 在 AliProduct 上训练的模型,训练使用的配置文件为 `ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml`,将该模型转为 inference 模型只需运行如下命令: + +```shell +python3 tools/export_model.py \ + -c ./ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml \ + -o Global.pretrained_model=./product_pretrain/product_ResNet50_vd_Aliproduct_v1.0_pretrained \ + -o Global.save_inference_dir=./deploy/models/product_ResNet50_vd_aliproduct_v1.0_infer +``` + +注意,此处保存的 inference 模型在 embedding 特征层做了截断,即导出后模型最终的输出为 n 维 embedding 特征。 + + +## 5. 命令参数说明 + +在上述模型导出命令中,所使用的配置文件需要与该模型的训练文件相同,在配置文件中有以下字段用于配置模型导出参数: + +* `Global.image_shape`:用于指定模型的输入数据尺寸,该尺寸不包含 batch 维度; +* `Global.save_inference_dir`:用于指定导出的 inference 模型的保存位置; +* `Global.pretrained_model`:用于指定训练过程中保存的模型权重文件路径,该路径无需包含模型权重文件后缀名 `.pdparams`。。 + +上述命令将生成以下三个文件: + +* `inference.pdmodel`:用于存储网络结构信息; +* `inference.pdiparams`:用于存储网络权重信息; +* `inference.pdiparams.info`:用于存储模型的参数信息,在分类模型和识别模型中可忽略。 + +导出的 inference 模型文件可用于预测引擎进行推理部署,根据不同的部署方式/平台,可参考: + +* [Python 预测](./python_deploy.md) +* [C++ 预测](./cpp_deploy.md)(目前仅支持分类模型) +* [Python Whl 预测](./whl_deploy.md)(目前仅支持分类模型) +* [PaddleHub Serving 部署](./paddle_hub_serving_deploy.md)(目前仅支持分类模型) +* [PaddleServing 部署](./paddle_serving_deploy.md) +* [PaddleLite 部署](./paddle_lite_deploy.md)(目前仅支持分类模型) diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/index.rst b/src/PaddleClas/docs/zh_CN/inference_deployment/index.rst new file mode 100644 index 0000000..beddc13 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/index.rst @@ -0,0 +1,17 @@ +推理部署 +================================ + +.. toctree:: + :maxdepth: 2 + + export_model.md + python_deploy.md + cpp_deploy.md + paddle_serving_deploy.md + paddle_hub_serving_deploy.md + paddle_lite_deploy.md + whl_deploy.md + cpp_deploy_on_windows.md + + + diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_hub_serving_deploy.md b/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_hub_serving_deploy.md new file mode 100644 index 0000000..1589bc6 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_hub_serving_deploy.md @@ -0,0 +1,232 @@ +# 基于 PaddleHub Serving 的服务部署 + +PaddleClas 支持通过 PaddleHub 快速进行服务化部署。目前支持图像分类的部署,图像识别的部署敬请期待。 + +--- + + +## 目录 +- [1. 简介](#1) +- [2. 准备环境](#2) +- [3. 下载推理模型](#3) +- [4. 安装服务模块](#4) +- [5. 启动服务](#5) + - [5.1 命令行命令启动](#5.1) + - [5.2 配置文件启动](#5.2) +- [6. 发送预测请求](#6) +- [7. 自定义修改服务模块](#7) + + + +## 1. 简介 + +hubserving 服务部署配置服务包 `clas` 下包含 3 个必选文件,目录如下: + +``` +hubserving/clas/ + └─ __init__.py 空文件,必选 + └─ config.json 配置文件,可选,使用配置启动服务时作为参数传入 + └─ module.py 主模块,必选,包含服务的完整逻辑 + └─ params.py 参数文件,必选,包含模型路径、前后处理参数等参数 +``` + + + +## 2. 准备环境 +```shell +# 安装 paddlehub,请安装 2.0 版本 +pip3 install paddlehub==2.1.0 --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + + + +## 3. 下载推理模型 + +安装服务模块前,需要准备推理模型并放到正确路径,默认模型路径为: + +* 分类推理模型结构文件:`PaddleClas/inference/inference.pdmodel` +* 分类推理模型权重文件:`PaddleClas/inference/inference.pdiparams` + +**注意**: +* 模型文件路径可在 `PaddleClas/deploy/hubserving/clas/params.py` 中查看和修改: + + ```python + "inference_model_dir": "../inference/" + ``` +需要注意, + * 模型文件(包括 `.pdmodel` 与 `.pdiparams`)名称必须为 `inference`。 + * 我们也提供了大量基于 ImageNet-1k 数据集的预训练模型,模型列表及下载地址详见[模型库概览](../models/models_intro.md),也可以使用自己训练转换好的模型。 + + + +## 4. 安装服务模块 + +针对 Linux 环境和 Windows 环境,安装命令如下。 + +* 在 Linux 环境下,安装示例如下: +```shell +cd PaddleClas/deploy +# 安装服务模块: +hub install hubserving/clas/ +``` + +* 在 Windows 环境下(文件夹的分隔符为`\`),安装示例如下: + +```shell +cd PaddleClas\deploy +# 安装服务模块: +hub install hubserving\clas\ +``` + + + +## 5. 启动服务 + + + +### 5.1 命令行命令启动 + +该方式仅支持使用 CPU 预测。启动命令: + +```shell +$ hub serving start --modules Module1==Version1 \ + --port XXXX \ + --use_multiprocess \ + --workers \ +``` + +**参数说明**: +|参数|用途| +|-|-| +|--modules/-m| [**必选**] PaddleHub Serving 预安装模型,以多个 Module==Version 键值对的形式列出
*`当不指定 Version 时,默认选择最新版本`*| +|--port/-p| [**可选**] 服务端口,默认为 8866| +|--use_multiprocess| [**可选**] 是否启用并发方式,默认为单进程方式,推荐多核 CPU 机器使用此方式
*`Windows 操作系统只支持单进程方式`*| +|--workers| [**可选**] 在并发方式下指定的并发任务数,默认为 `2*cpu_count-1`,其中 `cpu_count` 为 CPU 核数| + +如按默认参数启动服务:```hub serving start -m clas_system``` + +这样就完成了一个服务化 API 的部署,使用默认端口号 8866。 + + + +### 5.2 配置文件启动 + +该方式仅支持使用 CPU 或 GPU 预测。启动命令: + +```hub serving start -c config.json``` + +其中,`config.json` 格式如下: + +```json +{ + "modules_info": { + "clas_system": { + "init_args": { + "version": "1.0.0", + "use_gpu": true, + "enable_mkldnn": false + }, + "predict_args": { + } + } + }, + "port": 8866, + "use_multiprocess": false, + "workers": 2 +} +``` + +**参数说明**: +* `init_args` 中的可配参数与 `module.py` 中的 `_initialize` 函数接口一致。其中, + - 当 `use_gpu` 为 `true` 时,表示使用 GPU 启动服务。 + - 当 `enable_mkldnn` 为 `true` 时,表示使用 MKL-DNN 加速。 +* `predict_args` 中的可配参数与 `module.py` 中的 `predict` 函数接口一致。 + +**注意**: +* 使用配置文件启动服务时,将使用配置文件中的参数设置,其他命令行参数将被忽略; +* 如果使用 GPU 预测(即,`use_gpu` 置为 `true`),则需要在启动服务之前,设置 `CUDA_VISIBLE_DEVICES` 环境变量来指定所使用的 GPU 卡号,如:`export CUDA_VISIBLE_DEVICES=0`; +* **`use_gpu` 不可与 `use_multiprocess` 同时为 `true`**; +* **`use_gpu` 与 `enable_mkldnn` 同时为 `true` 时,将忽略 `enable_mkldnn`,而使用 GPU**。 + +如使用 GPU 3 号卡启动服务: + +```shell +cd PaddleClas/deploy +export CUDA_VISIBLE_DEVICES=3 +hub serving start -c hubserving/clas/config.json +``` + + +## 6. 发送预测请求 + +配置好服务端后,可使用以下命令发送预测请求,获取预测结果: + +```shell +cd PaddleClas/deploy +python hubserving/test_hubserving.py server_url image_path +``` + +**脚本参数说明**: +* **server_url**:服务地址,格式为 +`http://[ip_address]:[port]/predict/[module_name]` +* **image_path**:测试图像路径,可以是单张图片路径,也可以是图像集合目录路径。 +* **batch_size**:[**可选**] 以 `batch_size` 大小为单位进行预测,默认为 `1`。 +* **resize_short**:[**可选**] 预处理时,按短边调整大小,默认为 `256`。 +* **crop_size**:[**可选**] 预处理时,居中裁剪的大小,默认为 `224`。 +* **normalize**:[**可选**] 预处理时,是否进行 `normalize`,默认为 `True`。 +* **to_chw**:[**可选**] 预处理时,是否调整为 `CHW` 顺序,默认为 `True`。 + +**注意**:如果使用 `Transformer` 系列模型,如 `DeiT_***_384`, `ViT_***_384` 等,请注意模型的输入数据尺寸,需要指定`--resize_short=384 --crop_size=384`。 + +访问示例: + +```shell +python hubserving/test_hubserving.py --server_url http://127.0.0.1:8866/predict/clas_system --image_file ./hubserving/ILSVRC2012_val_00006666.JPEG --batch_size 8 +``` + +**返回结果格式说明**: +返回结果为列表(list),包含 top-k 个分类结果,以及对应的得分,还有此图片预测耗时,具体如下: +``` +list: 返回结果 +└─ list: 第一张图片结果 + └─ list: 前 k 个分类结果,依 score 递减排序 + └─ list: 前 k 个分类结果对应的 score,依 score 递减排序 + └─ float: 该图分类耗时,单位秒 +``` + + + +## 7. 自定义修改服务模块 + +如果需要修改服务逻辑,需要进行以下操作: + +1. 停止服务 +```hub serving stop --port/-p XXXX``` + +2. 到相应的 `module.py` 和 `params.py` 等文件中根据实际需求修改代码。`module.py` 修改后需要重新安装(`hub install hubserving/clas/`)并部署。在进行部署前,可通过 `python hubserving/clas/module.py` 测试已安装服务模块。 + +3. 卸载旧服务包 +```hub uninstall clas_system``` + +4. 安装修改后的新服务包 +```hub install hubserving/clas/``` + +5.重新启动服务 +```hub serving start -m clas_system``` + +**注意**: +常用参数可在 `PaddleClas/deploy/hubserving/clas/params.py` 中修改: + * 更换模型,需要修改模型文件路径参数: + ```python + "inference_model_dir": + ``` + * 更改后处理时返回的 `top-k` 结果数量: + ```python + 'topk': + ``` + * 更改后处理时的 lable 与 class id 对应映射文件: + ```python + 'class_id_map_file': + ``` + +为了避免不必要的延时以及能够以 batch_size 进行预测,数据预处理逻辑(包括 `resize`、`crop` 等操作)均在客户端完成,因此需要在 `PaddleClas/deploy/hubserving/test_hubserving.py#L35-L52` 中修改。 diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_lite_deploy.md b/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_lite_deploy.md new file mode 100644 index 0000000..25cf5a2 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_lite_deploy.md @@ -0,0 +1,281 @@ +# PaddleLite 推理部署 +--- + +本教程将介绍基于[Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite)在移动端部署 PaddleClas 分类模型的详细步骤。识别模型的部署将在近期支持,敬请期待。 + +Paddle Lite 是飞桨轻量化推理引擎,为手机、IOT 端提供高效推理能力,并广泛整合跨平台硬件,为端侧部署及应用落地问题提供轻量化的部署方案。 + +如果希望直接测试速度,可以参考[Paddle-Lite 移动端 benchmark 测试教程](../others/paddle_mobile_inference.md)。 + +--- + +## 目录 +- [1. 准备环境](#1) + - [1.1 准备交叉编译环境](#1.1) + - [1.2 准备预测库](#1.2) +- [2. 开始运行](#2) + - [2.1 模型优化](#2.1) + - [2.1.1 pip 安装 paddlelite 并进行转换](#2.1.1) + - [2.1.2 源码编译 Paddle-Lite 生成 opt 工具](#2.1.2) + - [2.1.3 转换示例](#2.1.3) + - [2.2 与手机联调](#2.2) +- [3. FAQ](#3) + + +## 1. 准备环境 + +Paddle Lite 目前支持以下平台部署: +* 电脑(编译 Paddle Lite) +* 安卓手机(armv7 或 armv8) + + +### 1.1 准备交叉编译环境 + +交叉编译环境用于编译 Paddle Lite 和 PaddleClas 的 C++ demo。 +支持多种开发环境,关于 Docker、Linux、macOS、Windows 等不同开发环境的编译流程请参考[文档](https://paddle-lite.readthedocs.io/zh/latest/source_compile/compile_env.html)。 + + +### 1.2 准备预测库 + +预测库有两种获取方式: +1. [建议]直接下载,预测库下载链接如下: + |平台|预测库下载链接| + |-|-| + |Android|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv7.gcc.c++_static.with_extra.with_cv.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/Android/gcc/inference_lite_lib.android.armv8.gcc.c++_static.with_extra.with_cv.tar.gz)| + |iOS|[arm7](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv7.with_cv.with_extra.tiny_publish.tar.gz) / [arm8](https://paddlelite-data.bj.bcebos.com/Release/2.8-rc/iOS/inference_lite_lib.ios.armv8.with_cv.with_extra.tiny_publish.tar.gz)| + + **注**: + 1. 如果是从 Paddle-Lite [官方文档](https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#android-toolchain-gcc)下载的预测库, + 注意选择 `with_extra=ON,with_cv=ON` 的下载链接。 + 2. 如果使用量化的模型部署在端侧,建议使用 Paddle-Lite develop 分支编译预测库。 + +2. 编译 Paddle-Lite 得到预测库,Paddle-Lite 的编译方式如下: + +```shell +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +# 如果使用编译方式,建议使用 develop 分支编译预测库 +git checkout develop +./lite/tools/build_android.sh --arch=armv8 --with_cv=ON --with_extra=ON +``` +**注意**:编译 Paddle-Lite 获得预测库时,需要打开`--with_cv=ON --with_extra=ON` 两个选项,`--arch` 表示 `arm` 版本,这里指定为 armv8,更多编译命令介绍请参考[Linux x86 环境下编译适用于 Android 的库](https://paddle-lite.readthedocs.io/zh/latest/source_compile/linux_x86_compile_android.html),关于其他平台的编译操作,具体请参考[PaddleLite](https://paddle-lite.readthedocs.io/zh/latest/)中`源码编译`部分。 + +直接下载预测库并解压后,可以得到 `inference_lite_lib.android.armv8/`文件夹,通过编译 Paddle-Lite 得到的预测库位于 `Paddle-Lite/build.lite.android.armv8.gcc/inference_lite_lib.android.armv8/`文件夹下。 +预测库的文件目录如下: + +``` +inference_lite_lib.android.armv8/ +|-- cxx C++ 预测库和头文件 +| |-- include C++ 头文件 +| | |-- paddle_api.h +| | |-- paddle_image_preprocess.h +| | |-- paddle_lite_factory_helper.h +| | |-- paddle_place.h +| | |-- paddle_use_kernels.h +| | |-- paddle_use_ops.h +| | `-- paddle_use_passes.h +| `-- lib C++预测库 +| |-- libpaddle_api_light_bundled.a C++静态库 +| `-- libpaddle_light_api_shared.so C++动态库 +|-- java Java 预测库 +| |-- jar +| | `-- PaddlePredictor.jar +| |-- so +| | `-- libpaddle_lite_jni.so +| `-- src +|-- demo C++和Java示例代码 +| |-- cxx C++ 预测库demo +| `-- java Java 预测库demo +``` + + +## 2. 开始运行 + + +### 2.1 模型优化 + +Paddle-Lite 提供了多种策略来自动优化原始的模型,其中包括量化、子图融合、混合精度、Kernel 优选等方法,使用 Paddle-Lite 的 `opt` 工具可以自动对 inference 模型进行优化,目前支持两种优化方式,优化后的模型更轻量,模型运行速度更快。在进行模型优化前,需要先准备 `opt` 优化工具,有以下两种方式。 + +**注意**:如果已经准备好了 `.nb` 结尾的模型文件,可以跳过此步骤。 + + +#### 2.1.1 [建议]pip 安装 paddlelite 并进行转换 + +Python 下安装 `paddlelite`,目前最高支持 `Python3.7`。 +**注意**:`paddlelite` whl 包版本必须和预测库版本对应。 + +```shell +pip install paddlelite==2.8 +``` + +之后使用 `paddle_lite_opt` 工具可以进行 inference 模型的转换。`paddle_lite_opt` 的部分参数如下 + +|选项|说明| +|-|-| +|--model_dir|待优化的 PaddlePaddle 模型(非 combined 形式)的路径| +|--model_file|待优化的 PaddlePaddle 模型(combined 形式)的网络结构文件路径| +|--param_file|待优化的 PaddlePaddle 模型(combined 形式)的权重文件路径| +|--optimize_out_type|输出模型类型,目前支持两种类型:protobuf 和 naive_buffer,其中 naive_buffer 是一种更轻量级的序列化/反序列化实现。若您需要在 mobile 端执行模型预测,请将此选项设置为 naive_buffer。默认为 protobuf| +|--optimize_out|优化模型的输出路径| +|--valid_targets|指定模型可执行的 backend,默认为 arm。目前可支持 x86、arm、opencl、npu、xpu,可以同时指定多个 backend(以空格分隔),Model Optimize Tool 将会自动选择最佳方式。如果需要支持华为 NPU(Kirin 810/990 Soc 搭载的达芬奇架构 NPU),应当设置为 npu, arm| +|--record_tailoring_info|当使用 根据模型裁剪库文件 功能时,则设置该选项为 true,以记录优化后模型含有的 kernel 和 OP 信息,默认为 false| + +`--model_file` 表示 inference 模型的 model 文件地址,`--param_file` 表示 inference 模型的 param 文件地址;`optimize_out` 用于指定输出文件的名称(不需要添加 `.nb` 的后缀)。直接在命令行中运行 `paddle_lite_opt`,也可以查看所有参数及其说明。 + + +#### 2.1.2 源码编译 Paddle-Lite 生成 opt 工具 + +模型优化需要 Paddle-Lite 的 `opt` 可执行文件,可以通过编译 Paddle-Lite 源码获得,编译步骤如下: + +```shell +# 如果准备环境时已经 clone 了 Paddle-Lite,则不用重新 clone Paddle-Lite +git clone https://github.com/PaddlePaddle/Paddle-Lite.git +cd Paddle-Lite +git checkout develop +# 启动编译 +./lite/tools/build.sh build_optimize_tool +``` + +编译完成后,`opt` 文件位于 `build.opt/lite/api/` 下,可通过如下方式查看 `opt` 的运行选项和使用方式: + +```shell +cd build.opt/lite/api/ +./opt +``` + +`opt` 的使用方式与参数与上面的 `paddle_lite_opt` 完全一致。 + + +#### 2.1.3 转换示例 + +下面以 PaddleClas 的 `MobileNetV3_large_x1_0` 模型为例,介绍使用 `paddle_lite_opt` 完成预训练模型到 inference 模型,再到 Paddle-Lite 优化模型的转换。 + +```shell +# 进入 PaddleClas 根目录 +cd PaddleClas_root_path + +# 下载并解压 inference 模型 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/MobileNetV3_large_x1_0_infer.tar +tar -xf MobileNetV3_large_x1_0_infer.tar + +# 将 inference 模型转化为 Paddle-Lite 优化模型 +paddle_lite_opt --model_file=./MobileNetV3_large_x1_0_infer/inference.pdmodel --param_file=./MobileNetV3_large_x1_0_infer/inference.pdiparams --optimize_out=./MobileNetV3_large_x1_0 +``` + +最终在当前文件夹下生成 `MobileNetV3_large_x1_0.nb` 的文件。 + +**注意**:`--optimize_out` 参数为优化后模型的保存路径,无需加后缀 `.nb`;`--model_file` 参数为模型结构信息文件的路径,`--param_file` 参数为模型权重信息文件的路径,请注意文件名。 + + +### 2.2 与手机联调 + +首先需要进行一些准备工作。 +1. 准备一台 arm8 的安卓手机,如果编译的预测库和 opt 文件是 armv7,则需要 arm7 的手机,并修改 Makefile 中 `ARM_ABI = arm7`。 +2. 电脑上安装 ADB 工具,用于调试。 ADB 安装方式如下: + + * MAC 电脑安装 ADB: + ```shell + brew cask install android-platform-tools + ``` + * Linux 安装 ADB + ```shell + sudo apt update + sudo apt install -y wget adb + ``` + * Window 安装 ADB + win 上安装需要去谷歌的安卓平台下载 ADB 软件包进行安装:[链接](https://developer.android.com/studio) + +3. 手机连接电脑后,开启手机 `USB 调试` 选项,选择 `文件传输` 模式,在电脑终端中输入: + +```shell +adb devices +``` +如果有 device 输出,则表示安装成功,如下所示: +``` +List of devices attached +744be294 device +``` + +4. 准备优化后的模型、预测库文件、测试图像和类别映射文件。 + +```shell +cd PaddleClas_root_path +cd deploy/lite/ + +# 运行 prepare.sh +# prepare.sh 会将预测库文件、测试图像和使用的字典文件放置在预测库中的 demo/cxx/clas 文件夹下 +sh prepare.sh /{lite prediction library path}/inference_lite_lib.android.armv8 + +# 进入 lite demo 的工作目录 +cd /{lite prediction library path}/inference_lite_lib.android.armv8/ +cd demo/cxx/clas/ + +# 将 C++ 预测动态库 so 文件复制到 debug 文件夹中 +cp ../../../cxx/lib/libpaddle_light_api_shared.so ./debug/ +``` + +`prepare.sh` 以 `PaddleClas/deploy/lite/imgs/tabby_cat.jpg` 作为测试图像,将测试图像复制到 `demo/cxx/clas/debug/` 文件夹下。 +将 `paddle_lite_opt` 工具优化后的模型文件放置到 `/{lite prediction library path}/inference_lite_lib.android.armv8/demo/cxx/clas/debug/` 文件夹下。本例中,使用 [2.1.3 转换示例](#2.1.3) 生成的 `MobileNetV3_large_x1_0.nb` 模型文件。 + +执行完成后,clas 文件夹下将有如下文件格式: + +``` +demo/cxx/clas/ +|-- debug/ +| |--MobileNetV3_large_x1_0.nb 优化后的分类器模型文件 +| |--tabby_cat.jpg 待测试图像 +| |--imagenet1k_label_list.txt 类别映射文件 +| |--libpaddle_light_api_shared.so C++预测库文件 +| |--config.txt 分类预测超参数配置 +|-- config.txt 分类预测超参数配置 +|-- image_classfication.cpp 图像分类代码文件 +|-- Makefile 编译文件 +``` + +#### 注意: +* 上述文件中,`imagenet1k_label_list.txt` 是 ImageNet1k 数据集的类别映射文件,如果使用自定义的类别,需要更换该类别映射文件。 + +* `config.txt` 包含了分类器的超参数,如下: + +```shell +clas_model_file ./MobileNetV3_large_x1_0.nb # 模型文件地址 +label_path ./imagenet1k_label_list.txt # 类别映射文本文件 +resize_short_size 256 # resize 之后的短边边长 +crop_size 224 # 裁剪后用于预测的边长 +visualize 0 # 是否进行可视化,如果选择的话,会在当前文件夹下生成名为 clas_result.png 的图像文件。 +``` + +5. 启动调试,上述步骤完成后就可以使用 ADB 将文件夹 `debug/` push 到手机上运行,步骤如下: + +```shell +# 执行编译,得到可执行文件 clas_system +make -j + +# 将编译得到的可执行文件移动到 debug 文件夹中 +mv clas_system ./debug/ + +# 将上述 debug 文件夹 push 到手机上 +adb push debug /data/local/tmp/ + +adb shell +cd /data/local/tmp/debug +export LD_LIBRARY_PATH=/data/local/tmp/debug:$LD_LIBRARY_PATH + +# clas_system 可执行文件的使用方式为: +# ./clas_system 配置文件路径 测试图像路径 +./clas_system ./config.txt ./tabby_cat.jpg +``` + +如果对代码做了修改,则需要重新编译并 push 到手机上。 + +运行效果如下: + +![](../../images/inference_deployment/lite_demo_result.png) + + +## 3. FAQ +Q1:如果想更换模型怎么办,需要重新按照流程走一遍吗? +A1:如果已经走通了上述步骤,更换模型只需要替换 `.nb` 模型文件即可,同时要注意修改下配置文件中的 `.nb` 文件路径以及类别映射文件(如有必要)。 + +Q2:换一个图测试怎么做? +A2:替换 debug 下的测试图像为你想要测试的图像,使用 ADB 再次 push 到手机上即可。 diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_serving_deploy.md b/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_serving_deploy.md new file mode 100644 index 0000000..18faeb3 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/paddle_serving_deploy.md @@ -0,0 +1,294 @@ +# 模型服务化部署 +-------- +## 目录 +- [1. 简介](#1) +- [2. Serving 安装](#2) +- [3. 图像分类服务部署](#3) + - [3.1 模型转换](#3.1) + - [3.2 服务部署和请求](#3.2) + - [3.2.1 Python Serving](#3.2.1) + - [3.2.2 C++ Serving](#3.2.2) +- [4. 图像识别服务部署](#4) + - [4.1 模型转换](#4.1) + - [4.2 服务部署和请求](#4.2) + - [4.2.1 Python Serving](#4.2.1) + - [4.2.2 C++ Serving](#4.2.2) +- [5. FAQ](#5) + + +## 1. 简介 +[Paddle Serving](https://github.com/PaddlePaddle/Serving) 旨在帮助深度学习开发者轻松部署在线预测服务,支持一键部署工业级的服务能力、客户端和服务端之间高并发和高效通信、并支持多种编程语言开发客户端。 + +该部分以 HTTP 预测服务部署为例,介绍怎样在 PaddleClas 中使用 PaddleServing 部署模型服务。目前只支持 Linux 平台部署,暂不支持 Windows 平台。 + + +## 2. Serving 安装 +Serving 官网推荐使用 docker 安装并部署 Serving 环境。首先需要拉取 docker 环境并创建基于 Serving 的 docker。 + +```shell +# 启动GPU docker +docker pull paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel +nvidia-docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel bash +nvidia-docker exec -it test bash + +# 启动CPU docker +docker pull paddlepaddle/serving:0.7.0-devel +docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-devel bash +docker exec -it test bash +``` + +进入 docker 后,需要安装 Serving 相关的 python 包。 +```shell +pip3 install paddle-serving-client==0.7.0 +pip3 install paddle-serving-app==0.7.0 +pip3 install faiss-cpu==1.7.1post2 + +#若为CPU部署环境: +pip3 install paddle-serving-server==0.7.0 # CPU +pip3 install paddlepaddle==2.2.0 # CPU + +#若为GPU部署环境 +pip3 install paddle-serving-server-gpu==0.7.0.post102 # GPU with CUDA10.2 + TensorRT6 +pip3 install paddlepaddle-gpu==2.2.0 # GPU with CUDA10.2 + +#其他GPU环境需要确认环境再选择执行哪一条 +pip3 install paddle-serving-server-gpu==0.7.0.post101 # GPU with CUDA10.1 + TensorRT6 +pip3 install paddle-serving-server-gpu==0.7.0.post112 # GPU with CUDA11.2 + TensorRT8 +``` + +* 如果安装速度太慢,可以通过 `-i https://pypi.tuna.tsinghua.edu.cn/simple` 更换源,加速安装过程。 +* 其他环境配置安装请参考: [使用Docker安装Paddle Serving](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Install_CN.md) + + + +## 3. 图像分类服务部署 + +### 3.1 模型转换 +使用 PaddleServing 做服务化部署时,需要将保存的 inference 模型转换为 Serving 模型。下面以经典的 ResNet50_vd 模型为例,介绍如何部署图像分类服务。 +- 进入工作目录: +```shell +cd deploy/paddleserving +``` +- 下载 ResNet50_vd 的 inference 模型: +```shell +# 下载并解压 ResNet50_vd 模型 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar +``` +- 用 paddle_serving_client 把下载的 inference 模型转换成易于 Server 部署的模型格式: +``` +# 转换 ResNet50_vd 模型 +python3 -m paddle_serving_client.convert --dirname ./ResNet50_vd_infer/ \ + --model_filename inference.pdmodel \ + --params_filename inference.pdiparams \ + --serving_server ./ResNet50_vd_serving/ \ + --serving_client ./ResNet50_vd_client/ +``` +ResNet50_vd 推理模型转换完成后,会在当前文件夹多出 `ResNet50_vd_serving` 和 `ResNet50_vd_client` 的文件夹,具备如下格式: +``` +|- ResNet50_vd_serving/ + |- inference.pdiparams + |- inference.pdmodel + |- serving_server_conf.prototxt + |- serving_server_conf.stream.prototxt +|- ResNet50_vd_client + |- serving_client_conf.prototxt + |- serving_client_conf.stream.prototxt +``` +得到模型文件之后,需要分别修改 `ResNet50_vd_serving` 和 `ResNet50_vd_client` 下文件 `serving_server_conf.prototxt` 中的 alias 名字:将 `fetch_var` 中的 `alias_name` 改为 `prediction` + +**备注**: Serving 为了兼容不同模型的部署,提供了输入输出重命名的功能。这样,不同的模型在推理部署时,只需要修改配置文件的 alias_name 即可,无需修改代码即可完成推理部署。 +修改后的 serving_server_conf.prototxt 如下所示: +``` +feed_var { + name: "inputs" + alias_name: "inputs" + is_lod_tensor: false + feed_type: 1 + shape: 3 + shape: 224 + shape: 224 +} +fetch_var { + name: "save_infer_model/scale_0.tmp_1" + alias_name: "prediction" + is_lod_tensor: false + fetch_type: 1 + shape: 1000 +} +``` + +### 3.2 服务部署和请求 +paddleserving 目录包含了启动 pipeline 服务、C++ serving服务和发送预测请求的代码,包括: +```shell +__init__.py +config.yml # 启动pipeline服务的配置文件 +pipeline_http_client.py # http方式发送pipeline预测请求的脚本 +pipeline_rpc_client.py # rpc方式发送pipeline预测请求的脚本 +classification_web_service.py # 启动pipeline服务端的脚本 +run_cpp_serving.sh # 启动C++ Serving部署的脚本 +test_cpp_serving_client.py # rpc方式发送C++ serving预测请求的脚本 +``` + +#### 3.2.1 Python Serving +- 启动服务: +```shell +# 启动服务,运行日志保存在 log.txt +python3 classification_web_service.py &>log.txt & +``` + +- 发送请求: +```shell +# 发送服务请求 +python3 pipeline_http_client.py +``` +成功运行后,模型预测的结果会打印在 cmd 窗口中,结果如下: +``` +{'err_no': 0, 'err_msg': '', 'key': ['label', 'prob'], 'value': ["['daisy']", '[0.9341402053833008]'], 'tensors': []} +``` + + +#### 3.2.2 C++ Serving +- 启动服务: +```shell +# 启动服务, 服务在后台运行,运行日志保存在 nohup.txt +sh run_cpp_serving.sh +``` + +- 发送请求: +```shell +# 发送服务请求 +python3 test_cpp_serving_client.py +``` +成功运行后,模型预测的结果会打印在 cmd 窗口中,结果如下: +``` +prediction: daisy, probability: 0.9341399073600769 +``` + + +## 4.图像识别服务部署 +使用 PaddleServing 做服务化部署时,需要将保存的 inference 模型转换为 Serving 模型。 下面以 PP-ShiTu 中的超轻量图像识别模型为例,介绍图像识别服务的部署。 + +## 4.1 模型转换 +- 下载通用检测 inference 模型和通用识别 inference 模型 +``` +cd deploy +# 下载并解压通用识别模型 +wget -P models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar +cd models +tar -xf general_PPLCNet_x2_5_lite_v1.0_infer.tar +# 下载并解压通用检测模型 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar +tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar +``` +- 转换识别 inference 模型为 Serving 模型: +``` +# 转换识别模型 +python3 -m paddle_serving_client.convert --dirname ./general_PPLCNet_x2_5_lite_v1.0_infer/ \ + --model_filename inference.pdmodel \ + --params_filename inference.pdiparams \ + --serving_server ./general_PPLCNet_x2_5_lite_v1.0_serving/ \ + --serving_client ./general_PPLCNet_x2_5_lite_v1.0_client/ +``` +识别推理模型转换完成后,会在当前文件夹多出 `general_PPLCNet_x2_5_lite_v1.0_serving/` 和 `general_PPLCNet_x2_5_lite_v1.0_client/` 的文件夹。分别修改 `general_PPLCNet_x2_5_lite_v1.0_serving/` 和 `general_PPLCNet_x2_5_lite_v1.0_client/` 目录下的 serving_server_conf.prototxt 中的 alias 名字: 将 `fetch_var` 中的 `alias_name` 改为 `features`。 +修改后的 serving_server_conf.prototxt 内容如下: +``` +feed_var { + name: "x" + alias_name: "x" + is_lod_tensor: false + feed_type: 1 + shape: 3 + shape: 224 + shape: 224 +} +fetch_var { + name: "save_infer_model/scale_0.tmp_1" + alias_name: "features" + is_lod_tensor: false + fetch_type: 1 + shape: 512 +} +``` +- 转换通用检测 inference 模型为 Serving 模型: +``` +# 转换通用检测模型 +python3 -m paddle_serving_client.convert --dirname ./picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer/ \ + --model_filename inference.pdmodel \ + --params_filename inference.pdiparams \ + --serving_server ./picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/ \ + --serving_client ./picodet_PPLCNet_x2_5_mainbody_lite_v1.0_client/ +``` +检测 inference 模型转换完成后,会在当前文件夹多出 `picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/` 和 `picodet_PPLCNet_x2_5_mainbody_lite_v1.0_client/` 的文件夹。 + +**注意:** 此处不需要修改 `picodet_PPLCNet_x2_5_mainbody_lite_v1.0_serving/` 目录下的 serving_server_conf.prototxt 中的 alias 名字。 + +- 下载并解压已经构建后的检索库 index +``` +cd ../ +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar && tar -xf drink_dataset_v1.0.tar +``` + +## 4.2 服务部署和请求 +**注意:** 识别服务涉及到多个模型,出于性能考虑采用 PipeLine 部署方式。Pipeline 部署方式当前不支持 windows 平台。 +- 进入到工作目录 +```shell +cd ./deploy/paddleserving/recognition +``` +paddleserving 目录包含启动 Python Pipeline 服务、C++ Serving 服务和发送预测请求的代码,包括: +``` +__init__.py +config.yml # 启动python pipeline服务的配置文件 +pipeline_http_client.py # http方式发送pipeline预测请求的脚本 +pipeline_rpc_client.py # rpc方式发送pipeline预测请求的脚本 +recognition_web_service.py # 启动pipeline服务端的脚本 +run_cpp_serving.sh # 启动C++ Pipeline Serving部署的脚本 +test_cpp_serving_client.py # rpc方式发送C++ Pipeline serving预测请求的脚本 +``` + + +#### 4.2.1 Python Serving +- 启动服务: +``` +# 启动服务,运行日志保存在 log.txt +python3 recognition_web_service.py &>log.txt & +``` + +- 发送请求: +``` +python3 pipeline_http_client.py +``` +成功运行后,模型预测的结果会打印在 cmd 窗口中,结果如下: +``` +{'err_no': 0, 'err_msg': '', 'key': ['result'], 'value': ["[{'bbox': [345, 95, 524, 576], 'rec_docs': '红牛-强化型', 'rec_scores': 0.79903316}]"], 'tensors': []} +``` + + +#### 4.2.2 C++ Serving +- 启动服务: +```shell +# 启动服务: 此处会在后台同时启动主体检测和特征提取服务,端口号分别为9293和9294; +# 运行日志分别保存在 log_mainbody_detection.txt 和 log_feature_extraction.txt中 +sh run_cpp_serving.sh +``` + +- 发送请求: +```shell +# 发送服务请求 +python3 test_cpp_serving_client.py +``` +成功运行后,模型预测的结果会打印在 cmd 窗口中,结果如下所示: +``` +[{'bbox': [345, 95, 524, 586], 'rec_docs': '红牛-强化型', 'rec_scores': 0.8016462}] +``` + + +## 5.FAQ +**Q1**: 发送请求后没有结果返回或者提示输出解码报错 + +**A1**: 启动服务和发送请求时不要设置代理,可以在启动服务前和发送请求前关闭代理,关闭代理的命令是: +``` +unset https_proxy +unset http_proxy +``` + +更多的服务部署类型,如 `RPC 预测服务` 等,可以参考 Serving 的[github 官网](https://github.com/PaddlePaddle/Serving/tree/v0.7.0/examples) diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/python_deploy.md b/src/PaddleClas/docs/zh_CN/inference_deployment/python_deploy.md new file mode 100644 index 0000000..39843df --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/python_deploy.md @@ -0,0 +1,96 @@ +# Python 预测推理 + +--- + +首先请参考文档[安装 PaddlePaddle](../installation/install_paddle.md)和文档[安装 PaddleClas](../installation/install_paddleclas.md)配置运行环境。 + +## 目录 + +- [1. 图像分类推理](#1) +- [2. 主体检测模型推理](#2) +- [3. 特征提取模型推理](#3) +- [4. 主体检测、特征提取和向量检索串联](#4) + + +## 1. 图像分类推理 + +首先请参考文档[模型导出](./export_model.md)准备 inference 模型,然后进入 PaddleClas 的 `deploy` 目录下: + +```shell +cd /path/to/PaddleClas/deploy +``` + +使用以下命令进行预测: + +```shell +python python/predict_cls.py -c configs/inference_cls.yaml +``` + +在配置文件 `configs/inference_cls.yaml` 中有以下字段用于配置预测参数: +* `Global.infer_imgs`:待预测的图片文件路径; +* `Global.inference_model_dir`:inference 模型文件所在目录,该目录下需要有文件 `inference.pdmodel` 和 `inference.pdiparams` 两个文件; +* `Global.use_tensorrt`:是否使用 TesorRT 预测引擎,默认为 `False`; +* `Global.use_gpu`:是否使用 GPU 预测,默认为 `True`; +* `Global.enable_mkldnn`:是否启用 `MKL-DNN` 加速库,默认为 `False`。注意 `enable_mkldnn` 与 `use_gpu` 同时为 `True` 时,将忽略 `enable_mkldnn`,而使用 GPU 预测; +* `Global.use_fp16`:是否启用 `FP16`,默认为 `False`; +* `PreProcess`:用于数据预处理配置; +* `PostProcess`:由于后处理配置; +* `PostProcess.Topk.class_id_map_file`:数据集 label 的映射文件,默认为 `./utils/imagenet1k_label_list.txt`,该文件为 PaddleClas 所使用的 ImageNet 数据集 label 映射文件。 + +**注意**: +* 如果使用 VisionTransformer 系列模型,如 `DeiT_***_384`, `ViT_***_384` 等,请注意模型的输入数据尺寸,部分模型需要修改参数: `PreProcess.resize_short=384`, `PreProcess.resize=384`。 +* 如果你希望提升评测模型速度,使用 GPU 评测时,建议开启 TensorRT 加速预测,使用 CPU 评测时,建议开启 MKL-DNN 加速预测。 + + +## 2. 主体检测模型推理 + +进入 PaddleClas 的 `deploy` 目录下: + +```shell +cd /path/to/PaddleClas/deploy +``` + +准备 PaddleClas 提供的主体检测 inference 模型: + +```shell +mkdir -p models +# 下载通用检测 inference 模型并解压 +wget -P ./models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar +tar -xf ./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar -C ./models/ +``` + +使用以下命令进行预测: + +```shell +python python/predict_det.py -c configs/inference_det.yaml +``` + +在配置文件 `configs/inference_det.yaml` 中有以下字段用于配置预测参数: +* `Global.infer_imgs`:待预测的图片文件路径; +* `Global.use_gpu`: 是否使用 GPU 预测,默认为 `True`。 + + + +## 3. 特征提取模型推理 + +下面以商品特征提取为例,介绍特征提取模型推理。首先进入 PaddleClas 的 `deploy` 目录下: + +```shell +cd /path/to/PaddleClas/deploy +``` + +准备 PaddleClas 提供的商品特征提取 inference 模型: + +```shell +mkdir -p models +# 下载商品特征提取 inference 模型并解压 +wget -P ./models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_aliproduct_v1.0_infer.tar +tar -xf ./models/product_ResNet50_vd_aliproduct_v1.0_infer.tar -C ./models/ +``` + +上述预测命令可以得到一个 512 维的特征向量,直接输出在在命令行中。 + + +## 4. 主体检测、特征提取和向量检索串联 + +主体检测、特征提取和向量检索的串联预测,可以参考图像识别[快速体验](../quick_start/quick_start_recognition.md)。 diff --git a/src/PaddleClas/docs/zh_CN/inference_deployment/whl_deploy.md b/src/PaddleClas/docs/zh_CN/inference_deployment/whl_deploy.md new file mode 100644 index 0000000..14582ac --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/inference_deployment/whl_deploy.md @@ -0,0 +1,256 @@ +# PaddleClas Whl 使用说明 + +PaddleClas 支持 Python Whl 包方式进行预测,目前 Whl 包方式仅支持图像分类,暂不支持主体检测、特征提取及向量检索。 + +--- + +## 目录 + +- [1. 安装 paddleclas](#1) +- [2. 快速开始](#2) +- [3. 参数解释](#3) +- [4. 使用示例](#4) + - [4.1 查看帮助信息](#4.1) + - [4.2 使用 PaddleClas 提供的预训练模型进行预测](#4.2) + - [4.3 使用本地模型文件预测](#4.3) + - [4.4 批量预测](#4.4) + - [4.5 对网络图片进行预测](#4.5) + - [4.6 对 `NumPy.ndarray` 格式数据进行预测](#4.6) + - [4.7 保存预测结果](#4.7) + - [4.8 指定 label name](#4.8) + + + +## 1. 安装 paddleclas + +* pip 安装 + +```bash +pip3 install paddleclas==2.2.1 +``` + +* 本地构建并安装 + +```bash +python3 setup.py bdist_wheel +pip3 install dist/* +``` + + +## 2. 快速开始 +* 使用 `ResNet50` 模型,以下图(`PaddleClas/docs/images/inference_deployment/whl_demo.jpg`)为例进行说明。 + +![](../../images/inference_deployment/whl_demo.jpg) + + +* 在 Python 代码中使用 +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs='docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +**注意**:`PaddleClas.predict()` 为可迭代对象(`generator`),因此需要使用 `next()` 函数或 `for` 循环对其迭代调用。每次调用将以 `batch_size` 为单位进行一次预测,并返回预测结果。返回结果示例如下: + +``` +>>> result +[{'class_ids': [8, 7, 136, 80, 84], 'scores': [0.79368, 0.16329, 0.01853, 0.00959, 0.00239], 'label_names': ['hen', 'cock', 'European gallinule, Porphyrio porphyrio', 'black grouse', 'peacock']}] +``` + +* 在命令行中使用 +```bash +paddleclas --model_name=ResNet50 --infer_imgs="docs/images/inference_deployment/whl_demo.jpg" +``` + +``` +>>> result +filename: docs/images/inference_deployment/whl_demo.jpg, top-5, class_ids: [8, 7, 136, 80, 84], scores: [0.79368, 0.16329, 0.01853, 0.00959, 0.00239], label_names: ['hen', 'cock', 'European gallinule, Porphyrio porphyrio', 'black grouse', 'peacock'] +Predict complete! +``` + + +## 3. 参数解释 +以下参数可在命令行方式使用中通过参数指定,或在 Python 代码中实例化 PaddleClas 对象时作为构造函数的参数使用。 +* model_name(str): 模型名称,使用 PaddleClas 提供的基于 ImageNet1k 的预训练模型。 +* inference_model_dir(str): 本地模型文件目录,当未指定 `model_name` 时该参数有效。该目录下需包含 `inference.pdmodel` 和 `inference.pdiparams` 两个模型文件。 +* infer_imgs(str): 待预测图片文件路径,或包含图片文件的目录,或网络图片的 URL。 +* use_gpu(bool): 是否使用 GPU,默认为 `True`。 +* gpu_mem(int): 使用的 GPU 显存大小,当 `use_gpu` 为 `True` 时有效,默认为 8000。 +* use_tensorrt(bool): 是否开启 TensorRT 预测,可提升 GPU 预测性能,需要使用带 TensorRT 的预测库,默认为 `False`。 +* enable_mkldnn(bool): 是否开启 MKLDNN,当 `use_gpu` 为 `False` 时有效,默认 `False`。 +* cpu_num_threads(int): CPU 预测时的线程数,当 `use_gpu` 为 `False` 且 `enable_mkldnn` 为 `True` 时有效,默认值为 `10`。 +* batch_size(int): 预测时每个 batch 的样本数量,默认为 `1`。 +* resize_short(int): 按图像较短边进行等比例缩放,默认为 `256`。 +* crop_size(int): 将图像裁剪到指定大小,默认为 `224`。 +* topk(int): 打印(返回)预测结果的前 `topk` 个类别和对应的分类概率,默认为 `5`。 +* class_id_map_file(str): `class id` 与 `label` 的映射关系文件。默认使用 `ImageNet1K` 数据集的映射关系。 +* save_dir(str): 将预测结果作为预标注数据保存的路径,默认为 `None`,即不保存。 + +**注意**: 如果使用 `Transformer` 系列模型,如 `DeiT_***_384`, `ViT_***_384` 等,请注意模型的输入数据尺寸,需要设置参数 `resize_short=384`, `crop_size=384`,如下所示。 + +* 命令行中 +```bash +from paddleclas import PaddleClas, get_default_confg +paddleclas --model_name=ViT_base_patch16_384 --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' --resize_short=384 --crop_size=384 +``` + +* Python 代码中 +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ViT_base_patch16_384', resize_short=384, crop_size=384) +``` + + +## 4. 使用示例 + +PaddleClas 提供两种使用方式: +1. Python 代码中使用; +2. 命令行中使用。 + + +### 4.1 查看帮助信息 + +* CLI +```bash +paddleclas -h +``` + + +### 4.2 使用 PaddleClas 提供的预训练模型进行预测 +可以使用 PaddleClas 提供的预训练模型来预测,并通过参数 `model_name` 指定。此时 PaddleClas 会根据 `model_name` 自动下载指定模型,并保存在目录`~/.paddleclas/`下。 + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs = 'docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' +``` + + +### 4.3 使用本地模型文件预测 +可以使用本地的模型文件进行预测,通过参数 `inference_model_dir` 指定模型文件目录即可。需要注意,模型文件目录下必须包含 `inference.pdmodel` 和 `inference.pdiparams` 两个文件。 + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(inference_model_dir='./inference/') +infer_imgs = 'docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --inference_model_dir='./inference/' --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' +``` + + +### 4.4 批量预测 +当参数 `infer_imgs` 为包含图片文件的目录时,可以对图片进行批量预测,只需通过参数 `batch_size` 指定 batch 大小。 + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50', batch_size=2) +infer_imgs = 'docs/images/' +result=clas.predict(infer_imgs) +for r in result: + print(r) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/' --batch_size 2 +``` + + +### 4.5 对网络图片进行预测 +可以对网络图片进行预测,只需通过参数 `infer_imgs` 指定图片 `url`。此时图片会下载并保存在`~/.paddleclas/images/`目录下。 + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs = 'https://raw.githubusercontent.com/paddlepaddle/paddleclas/release/2.2/docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='https://raw.githubusercontent.com/paddlepaddle/paddleclas/release/2.2/docs/images/inference_deployment/whl_demo.jpg' +``` + + +### 4.6 对 `NumPy.ndarray` 格式数据进行预测 +在 Python 中,可以对 `Numpy.ndarray` 格式的图像数据进行预测,只需通过参数 `infer_imgs` 指定即可。注意,PaddleClas 所提供的模型仅支持 3 通道图像数据,且通道顺序为 `RGB`。 + +* python +```python +import cv2 +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50') +infer_imgs = cv2.imread("docs/images/inference_deployment/whl_demo.jpg")[:, :, ::-1] +result=clas.predict(infer_imgs) +print(next(result)) +``` + + +### 4.7 保存预测结果 +可以指定参数 `pre_label_out_dir='./output_pre_label/'`,将图片按其 top1 预测结果保存到 `pre_label_out_dir` 目录下对应类别的文件夹中。 + +* python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50', save_dir='./output_pre_label/') +infer_imgs = 'docs/images/whl/' # it can be infer_imgs folder path which contains all of images you want to predict. +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/whl/' --save_dir='./output_pre_label/' +``` + + +### 4.8 指定 label name +可以通过参数 `class_id_map_file` 指定 `class id` 与 `lable` 的对应关系。PaddleClas 默认使用 ImageNet1K 的 label_name(`ppcls/utils/imagenet1k_label_list.txt`)。 + +`class_id_map_file` 文件内容格式应为: + +``` +class_idclass_name<\n> +``` + +例如: + +``` +0 tench, Tinca tinca +1 goldfish, Carassius auratus +2 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias +...... +``` + +* Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='ResNet50', class_id_map_file='./ppcls/utils/imagenet1k_label_list.txt') +infer_imgs = 'docs/images/inference_deployment/whl_demo.jpg' +result=clas.predict(infer_imgs) +print(next(result)) +``` + +* CLI +```bash +paddleclas --model_name='ResNet50' --infer_imgs='docs/images/inference_deployment/whl_demo.jpg' --class_id_map_file='./ppcls/utils/imagenet1k_label_list.txt' +``` diff --git a/src/PaddleClas/docs/zh_CN/installation/index.rst b/src/PaddleClas/docs/zh_CN/installation/index.rst new file mode 100644 index 0000000..752d050 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/installation/index.rst @@ -0,0 +1,8 @@ +安装 +================================ + +.. toctree:: + :maxdepth: 2 + + install_paddle.md + install_paddleclas.md diff --git a/src/PaddleClas/docs/zh_CN/installation/install_paddle.md b/src/PaddleClas/docs/zh_CN/installation/install_paddle.md new file mode 100644 index 0000000..995d287 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/installation/install_paddle.md @@ -0,0 +1,101 @@ +# 安装 PaddlePaddle + +--- +## 目录 + +- [1. 环境要求](#1) +- [2.(建议)使用 Docker 环境](#2) +- [3. 通过 pip 安装 PaddlePaddle](#3) +- [4. 验证安装](#4) + +目前,**PaddleClas** 要求 **PaddlePaddle** 版本 `>=2.0`。建议使用我们提供的 Docker 运行 PaddleClas,有关 Docker、nvidia-docker 的相关使用教程可以参考[链接](https://www.runoob.com/Docker/Docker-tutorial.html)。如果不使用 Docker,可以直接跳过 [2.(建议)使用 Docker 环境](#2) 部分内容,从 [3. 通过 pip 安装 PaddlePaddle](#3) 部分开始。 + + + +## 1. 环境要求 + +**版本要求**: +- python 3.x +- CUDA >= 10.1(如果使用 `paddlepaddle-gpu`) +- cuDNN >= 7.6.4(如果使用 `paddlepaddle-gpu`) +- nccl >= 2.1.2(如果使用分布式训练/评估) +- gcc >= 8.2 + +**建议**: +* 当 CUDA 版本为 10.1 时,显卡驱动版本 `>= 418.39`; +* 当 CUDA 版本为 10.2 时,显卡驱动版本 `>= 440.33`; +* 更多 CUDA 版本与要求的显卡驱动版本可以参考[链接](https://docs.nvidia.com/deploy/cuda-compatibility/index.html)。 + + + +## 2.(建议)使用 Docker 环境 + +* 切换到工作目录下 + +```shell +cd /home/Projects +``` + +* 创建 docker 容器 + +下述命令会创建一个名为 ppcls 的 Docker 容器,并将当前工作目录映射到容器内的 `/paddle` 目录。 + +```shell +# 对于 GPU 用户 +sudo nvidia-docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0-gpu-cuda10.2-cudnn7 /bin/bash + +# 对于 CPU 用户 +sudo docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0 /bin/bash +``` + +**注意**: +* 首次使用该镜像时,下述命令会自动下载该镜像文件,下载需要一定的时间,请耐心等待; +* 上述命令会创建一个名为 ppcls 的 Docker 容器,之后再次使用该容器时无需再次运行该命令; +* 参数 `--shm-size=8G` 将设置容器的共享内存为 8 G,如机器环境允许,建议将该参数设置较大,如 `64G`; +* 您也可以访问 [DockerHub](https://hub.Docker.com/r/paddlepaddle/paddle/tags/) 获取与您机器适配的镜像; +* 退出/进入 docker 容器: + * 在进入 Docker 容器后,可使用组合键 `Ctrl + P + Q` 退出当前容器,同时不关闭该容器; + * 如需再次进入容器,可使用下述命令: + + ```shell + sudo Docker exec -it ppcls /bin/bash + ``` + + + +## 3. 通过 pip 安装 PaddlePaddle + +可运行下面的命令,通过 pip 安装最新版本 PaddlePaddle: + +```bash +# 对于 CPU 用户 +pip install paddlepaddle --upgrade -i https://mirror.baidu.com/pypi/simple + +# 对于 GPU 用户 +pip install paddlepaddle-gpu --upgrade -i https://mirror.baidu.com/pypi/simple +``` + +**注意:** +* 如果先安装了 CPU 版本的 PaddlePaddle,之后想切换到 GPU 版本,那么需要使用 pip 先卸载 CPU 版本的 PaddlePaddle,再安装 GPU 版本的 PaddlePaddle,否则容易导致 PaddlePaddle 冲突。 +* 您也可以从源码编译安装 PaddlePaddle,请参照 [PaddlePaddle 安装文档](http://www.paddlepaddle.org.cn/install/quick) 中的说明进行操作。 + + +## 4. 验证安装 + +使用以下命令可以验证 PaddlePaddle 是否安装成功。 + +```python +import paddle +paddle.utils.run_check() +``` + +查看 PaddlePaddle 版本的命令如下: + +```bash +python -c "import paddle; print(paddle.__version__)" +``` + +**注意**: +- 从源码编译的 PaddlePaddle 版本号为 `0.0.0`,请确保使用 PaddlePaddle 2.0 及之后的源码进行编译; +- PaddleClas 基于 PaddlePaddle 高性能的分布式训练能力,若您从源码编译,请确保打开编译选项 `WITH_DISTRIBUTE=ON`。具体编译选项参考 [编译选项表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#bianyixuanxiangbiao); +- 在 Docker 中运行时,为保证 Docker 容器有足够的共享内存用于 Paddle 的数据读取加速,在创建 Docker 容器时,请设置参数 `--shm-size=8g`,条件允许的话可以设置为更大的值。 diff --git a/src/PaddleClas/docs/zh_CN/installation/install_paddleclas.md b/src/PaddleClas/docs/zh_CN/installation/install_paddleclas.md new file mode 100644 index 0000000..0f70bf2 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/installation/install_paddleclas.md @@ -0,0 +1,32 @@ +# 安装 PaddleClas + +--- +## 目录 + +* [1. 克隆 PaddleClas](#1) +* [2. 安装 Python 依赖库](#2) + + + +## 1. 克隆 PaddleClas + +从 GitHub 下载: + +```shell +git clone https://github.com/PaddlePaddle/PaddleClas.git -b release/2.3 +``` + +如果访问 GitHub 网速较慢,可以从 Gitee 下载,命令如下: + +```shell +git clone https://gitee.com/paddlepaddle/PaddleClas.git -b release/2.3 +``` + + +## 2. 安装 Python 依赖库 + +PaddleClas 的 Python 依赖库在 `requirements.txt` 中给出,可通过如下命令安装: + +```shell +pip install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple +``` diff --git a/src/PaddleClas/docs/zh_CN/introduction/function_intro.md b/src/PaddleClas/docs/zh_CN/introduction/function_intro.md new file mode 100644 index 0000000..63afc75 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/function_intro.md @@ -0,0 +1,20 @@ +## PaddleClas 功能特性 + +飞桨图像识别套件 PaddleClas 是飞桨为工业界和学术界所准备的一个图像识别任务的工具集,助力使用者训练出更好的视觉模型和应用落地。具体地,它包含以下几个核心特性。 + + +- 实用的图像识别系统:集成了目标检测、特征学习、图像检索等模块,广泛适用于各类图像识别任务。 +提供商品识别、车辆识别、 logo 识别和动漫人物识别等 4 个场景应用示例。 + +- 丰富的预训练模型库:提供了 36 个系列共 175 个 ImageNet 预训练模型,其中 7 个精选系列模型支持结构快速修改。 + +- 全面易用的特征学习组件:集成 arcmargin, triplet loss 等 12 度量学习方法,通过配置文件即可随意组合切换。 + +- SSLD 知识蒸馏: 14 个分类预训练模型,精度普遍提升 3% 以上;其中 ResNet50_vd 模型在 ImageNet-1k 数据集上的 Top-1 精度达到了 84.0%,Res2Net200_vd 预训练模型 Top-1 精度高达 85.1% 。 + +- 数据增广:支持 AutoAugment 、 Cutout 、 Cutmix 等 8 种数据增广算法详细介绍、代码复现和在统一实验环境下的效果评估。 + + +![](../../images/recognition.gif) + +更多关于图像识别快速体验、算法详解、模型训练评估与预测部署方法,请参考[首页 README 文档教程](../../../README_ch.md)。 diff --git a/src/PaddleClas/docs/zh_CN/introduction/index.rst b/src/PaddleClas/docs/zh_CN/introduction/index.rst new file mode 100644 index 0000000..c33c689 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/index.rst @@ -0,0 +1,8 @@ +介绍 +================================ + +.. toctree:: + :maxdepth: 2 + + function_intro.md + more_demo/index diff --git a/src/PaddleClas/docs/zh_CN/introduction/more_demo/cartoon.md b/src/PaddleClas/docs/zh_CN/introduction/more_demo/cartoon.md new file mode 100644 index 0000000..825da49 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/more_demo/cartoon.md @@ -0,0 +1,53 @@ +## 动漫人物图片识别效果图 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/zh_CN/introduction/more_demo/index.rst b/src/PaddleClas/docs/zh_CN/introduction/more_demo/index.rst new file mode 100644 index 0000000..448e9fe --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/more_demo/index.rst @@ -0,0 +1,11 @@ +介绍 +================================ + +.. toctree:: + :maxdepth: 2 + + cartoon.md + logo.md + more_demo.md + product.md + vehicle.md diff --git a/src/PaddleClas/docs/zh_CN/introduction/more_demo/logo.md b/src/PaddleClas/docs/zh_CN/introduction/more_demo/logo.md new file mode 100644 index 0000000..cbed4a6 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/more_demo/logo.md @@ -0,0 +1,65 @@ +## 商标图片识别效果图 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/zh_CN/introduction/more_demo/more_demo.md b/src/PaddleClas/docs/zh_CN/introduction/more_demo/more_demo.md new file mode 100644 index 0000000..97732e3 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/more_demo/more_demo.md @@ -0,0 +1,40 @@ +## 识别效果展示 +- 商品识别 +
+
+
+
+
+ +[更多效果图](product.md) + + +- 动漫人物识别 + +
+
+
+ +[更多效果图](cartoon.md) + + +- logo识别 + +
+
+
+
+
+
+ + +[更多效果图](logo.md) + + +- 车辆识别 + +
+
+
+ +[更多效果图](vehicle.md) diff --git a/src/PaddleClas/docs/zh_CN/introduction/more_demo/product.md b/src/PaddleClas/docs/zh_CN/introduction/more_demo/product.md new file mode 100644 index 0000000..df211f0 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/more_demo/product.md @@ -0,0 +1,179 @@ +## 商品图片识别效果图 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/zh_CN/introduction/more_demo/vehicle.md b/src/PaddleClas/docs/zh_CN/introduction/more_demo/vehicle.md new file mode 100644 index 0000000..975c98b --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/introduction/more_demo/vehicle.md @@ -0,0 +1,33 @@ +## 车辆图片识别效果图 + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/PaddleClas/docs/zh_CN/make.bat b/src/PaddleClas/docs/zh_CN/make.bat new file mode 100644 index 0000000..ed767fc --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/make.bat @@ -0,0 +1,37 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) + +set SOURCEDIR=source +set BUILDDIR=build + + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/src/PaddleClas/docs/zh_CN/models/DLA.md b/src/PaddleClas/docs/zh_CN/models/DLA.md new file mode 100644 index 0000000..3612b9e --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/DLA.md @@ -0,0 +1,45 @@ +# DLA 系列 +---- +## 目录 +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) + + + +## 1. 概述 + +DLA(Deep Layer Aggregation)。 视觉识别需要丰富的表示形式,其范围从低到高,范围从小到大,分辨率从精细到粗糙。即使卷积网络中的要素深度很深,仅靠隔离层还是不够的:将这些表示法进行复合和聚合可改善对内容和位置的推断。尽管已合并了残差连接以组合各层,但是这些连接本身是“浅”的,并且只能通过简单的一步操作来融合。作者通过更深层的聚合来增强标准体系结构,以更好地融合各层的信息。Deep Layer Aggregation 结构迭代地和分层地合并了特征层次结构,以使网络具有更高的准确性和更少的参数。跨体系结构和任务的实验表明,与现有的分支和合并方案相比,Deep Layer Aggregation 可提高识别和分辨率。[论文地址](https://arxiv.org/abs/1707.06484)。 + + + +## 2. 精度、FLOPS 和参数量 + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:-----------------:|:----------:|:---------:|:---------:|:---------:| +| DLA34 | 15.8 | 3.1 | 76.03 | 92.98 | +| DLA46_c | 1.3 | 0.5 | 63.21 | 85.30 | +| DLA46x_c | 1.1 | 0.5 | 64.36 | 86.01 | +| DLA60 | 22.0 | 4.2 | 76.10 | 92.92 | +| DLA60x | 17.4 | 3.5 | 77.53 | 93.78 | +| DLA60x_c | 1.3 | 0.6 | 66.45 | 87.54 | +| DLA102 | 33.3 | 7.2 | 78.93 | 94.52 | +| DLA102x | 26.4 | 5.9 | 78.10 | 94.00 | +| DLA102x2 | 41.4 | 9.3 | 78.85 | 94.45 | +| DLA169 | 53.5 | 11.6 | 78.09 | 94.09 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| 模型 | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| -------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| DLA102 | 224 | 256 | 4.95 | 8.08 | 12.40 | +| DLA102x2 | 224 | 256 | 19.58 | 23.97 | 31.37 | +| DLA102x | 224 | 256 | 11.12 | 15.60 | 20.37 | +| DLA169 | 224 | 256 | 7.70 | 12.25 | 18.90 | +| DLA34 | 224 | 256 | 1.83 | 3.37 | 5.98 | +| DLA46_c | 224 | 256 | 1.06 | 2.08 | 3.23 | +| DLA60 | 224 | 256 | 2.78 | 5.36 | 8.29 | +| DLA60x_c | 224 | 256 | 1.79 | 3.68 | 5.19 | +| DLA60x | 224 | 256 | 5.98 | 9.24 | 12.52 | \ No newline at end of file diff --git a/src/PaddleClas/docs/zh_CN/models/DPN_DenseNet.md b/src/PaddleClas/docs/zh_CN/models/DPN_DenseNet.md new file mode 100644 index 0000000..3a8a002 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/DPN_DenseNet.md @@ -0,0 +1,79 @@ +# DPN 与 DenseNet 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 +DenseNet 是 2017 年 CVPR best paper 提出的一种新的网络结构,该网络设计了一种新的跨层连接的 block,即 dense-block。相比 ResNet 中的 bottleneck,dense-block 设计了一个更激进的密集连接机制,即互相连接所有的层,每个层都会接受其前面所有层作为其额外的输入。DenseNet 将所有的 dense-block 堆叠,组合成了一个密集连接型网络。密集的连接方式使得 DenseNe 更容易进行梯度的反向传播,使得网络更容易训练。 +DPN 的全称是 Dual Path Networks,即双通道网络。该网络是由 DenseNet 和 ResNeXt 结合的一个网络,其证明了 DenseNet 能从靠前的层级中提取到新的特征,而 ResNeXt 本质上是对之前层级中已提取特征的复用。作者进一步分析发现,ResNeXt 对特征有高复用率,但冗余度低,DenseNet 能创造新特征,但冗余度高。结合二者结构的优势,作者设计了 DPN 网络。最终 DPN 网络在同样 FLOPS 和参数量下,取得了比 ResNeXt 与 DenseNet 更好的结果。 + +该系列模型的 FLOPS、参数量以及 T4 GPU 上的预测耗时如下图所示。 + +![](../../images/models/T4_benchmark/t4.fp32.bs4.DPN.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.DPN.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.DPN.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.DPN.png) + +目前 PaddleClas 开源的这两类模型的预训练模型一共有 10 个,其指标如上图所示,可以看到,在相同的 FLOPS 和参数量下,相比 DenseNet,DPN 拥有更高的精度。但是由于 DPN 有更多的分支,所以其推理速度要慢于 DenseNet。由于 DenseNet264 的网络层数最深,所以该网络是 DenseNet 系列模型中参数量最大的网络,DenseNet161 的网络的宽度最大,导致其是该系列中网络中计算量最大、精度最高的网络。从推理速度来看,计算量大且精度高的的 DenseNet161 比 DenseNet264 具有更快的速度,所以其比 DenseNet264 具有更大的优势。 + +对于 DPN 系列网络,模型的 FLOPS 和参数量越大,模型的精度越高。其中,由于 DPN107 的网络宽度最大,所以其是该系列网络中参数量与计算量最大的网络。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| DenseNet121 | 0.757 | 0.926 | 0.750 | | 5.690 | 7.980 | +| DenseNet161 | 0.786 | 0.941 | 0.778 | | 15.490 | 28.680 | +| DenseNet169 | 0.768 | 0.933 | 0.764 | | 6.740 | 14.150 | +| DenseNet201 | 0.776 | 0.937 | 0.775 | | 8.610 | 20.010 | +| DenseNet264 | 0.780 | 0.939 | 0.779 | | 11.540 | 33.370 | +| DPN68 | 0.768 | 0.934 | 0.764 | 0.931 | 4.030 | 10.780 | +| DPN92 | 0.799 | 0.948 | 0.793 | 0.946 | 12.540 | 36.290 | +| DPN98 | 0.806 | 0.951 | 0.799 | 0.949 | 22.220 | 58.460 | +| DPN107 | 0.809 | 0.953 | 0.802 | 0.951 | 35.060 | 82.970 | +| DPN131 | 0.807 | 0.951 | 0.801 | 0.949 | 30.510 | 75.360 | + + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------|-----------|-------------------|-------------------|-------------------|-------------------| +| DenseNet121 | 224 | 256 | 3.40 | 6.94 | 9.17 | +| DenseNet161 | 224 | 256 | 7.06 | 14.37 | 19.55 | +| DenseNet169 | 224 | 256 | 5.00 | 10.29 | 12.84 | +| DenseNet201 | 224 | 256 | 6.38 | 13.72 | 17.17 | +| DenseNet264 | 224 | 256 | 9.34 | 20.95 | 25.41 | +| DPN68 | 224 | 256 | 8.18 | 11.40 | 14.82 | +| DPN92 | 224 | 256 | 12.48 | 20.04 | 25.10 | +| DPN98 | 224 | 256 | 14.70 | 25.55 | 35.12 | +| DPN107 | 224 | 256 | 19.46 | 35.62 | 50.22 | +| DPN131 | 224 | 256 | 19.64 | 34.60 | 47.42 | + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| DenseNet121 | 224 | 256 | 4.16436 | 7.2126 | 10.50221 | 4.40447 | 9.32623 | 15.25175 | +| DenseNet161 | 224 | 256 | 9.27249 | 14.25326 | 20.19849 | 10.39152 | 22.15555 | 35.78443 | +| DenseNet169 | 224 | 256 | 6.11395 | 10.28747 | 13.68717 | 6.43598 | 12.98832 | 20.41964 | +| DenseNet201 | 224 | 256 | 7.9617 | 13.4171 | 17.41949 | 8.20652 | 17.45838 | 27.06309 | +| DenseNet264 | 224 | 256 | 11.70074 | 19.69375 | 24.79545 | 12.14722 | 26.27707 | 40.01905 | +| DPN68 | 224 | 256 | 11.7827 | 13.12652 | 16.19213 | 11.64915 | 12.82807 | 18.57113 | +| DPN92 | 224 | 256 | 18.56026 | 20.35983 | 29.89544 | 18.15746 | 23.87545 | 38.68821 | +| DPN98 | 224 | 256 | 21.70508 | 24.7755 | 40.93595 | 21.18196 | 33.23925 | 62.77751 | +| DPN107 | 224 | 256 | 27.84462 | 34.83217 | 60.67903 | 27.62046 | 52.65353 | 100.11721 | +| DPN131 | 224 | 256 | 28.58941 | 33.01078 | 55.65146 | 28.33119 | 46.19439 | 89.24904 | diff --git a/src/PaddleClas/docs/zh_CN/models/ESNet.md b/src/PaddleClas/docs/zh_CN/models/ESNet.md new file mode 100644 index 0000000..cff1354 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/ESNet.md @@ -0,0 +1,25 @@ +# ESNet 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPs 和参数量](#2) + + + +## 1. 概述 + +ESNet(Enhanced ShuffleNet)是百度自研的一个轻量级网络,该网络在 ShuffleNetV2 的基础上融合了 MobileNetV3、GhostNet、PPLCNet 的优点,组合成了一个在 ARM 设备上速度更快、精度更高的网络,由于其出色的表现,所以在 PaddleDetection 推出的 [PP-PicoDet](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.3/configs/picodet) 使用了该模型做 backbone,配合更强的目标检测算法,最终的指标一举刷新了目标检测模型在 ARM 设备上的 SOTA 指标。 + + + +## 2.精度、FLOPs 和参数量 + +| Models | Top1 | Top5 | FLOPs
(M) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:| +| ESNet_x0_25 | 62.48 | 83.46 | 30.9 | 2.83 | +| ESNet_x0_5 | 68.82 | 88.04 | 67.3 | 3.25 | +| ESNet_x0_75 | 72.24 | 90.45 | 123.7 | 3.87 | +| ESNet_x1_0 | 73.92 | 91.40 | 197.3 | 4.64 | + +关于 Inference speed 等信息,敬请期待。 diff --git a/src/PaddleClas/docs/zh_CN/models/EfficientNet_and_ResNeXt101_wsl.md b/src/PaddleClas/docs/zh_CN/models/EfficientNet_and_ResNeXt101_wsl.md new file mode 100644 index 0000000..dfe68ac --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/EfficientNet_and_ResNeXt101_wsl.md @@ -0,0 +1,90 @@ +# EfficientNet 与 ResNeXt101_wsl 系列 +----- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + +## 1. 概述 +EfficientNet 是 Google 于 2019 年发布的一个基于 NAS 的轻量级网络,其中 EfficientNetB7 刷新了当时 ImageNet-1k 的分类准确率。在该文章中,作者指出,传统的提升神经网络性能的方法主要是从网络的宽度、网络的深度、以及输入图片的分辨率入手,但是作者通过实验发现,平衡这三个维度对精度和效率的提升至关重要,于是,作者通过一系列的实验中总结出了如何同时平衡这三个维度的放缩,与此同时,基于这种放缩方法,作者在 EfficientNet_B0 的基础上,构建了 EfficientNet 系列中 B1-B7 共 7 个网络,并在同样 FLOPS 与参数量的情况下,精度达到了 state-of-the-art 的效果。 + +ResNeXt 是 facebook 于 2016 年提出的一种对 ResNet 的改进版网络。在 2019 年,facebook 通过弱监督学习研究了该系列网络在 ImageNet 上的精度上限,为了区别之前的 ResNeXt 网络,该系列网络的后缀为 wsl,其中 wsl 是弱监督学习(weakly-supervised-learning)的简称。为了能有更强的特征提取能力,研究者将其网络宽度进一步放大,其中最大的 ResNeXt101_32x48d_wsl 拥有 8 亿个参数,将其在 9.4 亿的弱标签图片下训练并在 ImageNet-1k 上做 finetune,最终在 ImageNet-1k 的 top-1 达到了 85.4%,这也是迄今为止在 ImageNet-1k 的数据集上以 224x224 的分辨率下精度最高的网络。Fix-ResNeXt 中,作者使用了更大的图像分辨率,针对训练图片和验证图片数据预处理不一致的情况下做了专门的 Fix 策略,并使得 ResNeXt101_32x48d_wsl 拥有了更高的精度,由于其用到了 Fix 策略,故命名为 Fix-ResNeXt101_32x48d_wsl。 + + +该系列模型的 FLOPS、参数量以及 T4 GPU 上的预测耗时如下图所示。 + +![](../../images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.EfficientNet.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs1.EfficientNet.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs1.EfficientNet.png) + +目前 PaddleClas 开源的这两类模型的预训练模型一共有 14 个。从上图中可以看出 EfficientNet 系列网络优势非常明显,ResNeXt101_wsl 系列模型由于用到了更多的数据,最终的精度也更高。EfficientNet_B0_Small 是去掉了 SE_block 的 EfficientNet_B0,其具有更快的推理速度。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ResNeXt101_
32x8d_wsl | 0.826 | 0.967 | 0.822 | 0.964 | 29.140 | 78.440 | +| ResNeXt101_
32x16d_wsl | 0.842 | 0.973 | 0.842 | 0.972 | 57.550 | 152.660 | +| ResNeXt101_
32x32d_wsl | 0.850 | 0.976 | 0.851 | 0.975 | 115.170 | 303.110 | +| ResNeXt101_
32x48d_wsl | 0.854 | 0.977 | 0.854 | 0.976 | 173.580 | 456.200 | +| Fix_ResNeXt101_
32x48d_wsl | 0.863 | 0.980 | 0.864 | 0.980 | 354.230 | 456.200 | +| EfficientNetB0 | 0.774 | 0.933 | 0.773 | 0.935 | 0.720 | 5.100 | +| EfficientNetB1 | 0.792 | 0.944 | 0.792 | 0.945 | 1.270 | 7.520 | +| EfficientNetB2 | 0.799 | 0.947 | 0.803 | 0.950 | 1.850 | 8.810 | +| EfficientNetB3 | 0.812 | 0.954 | 0.817 | 0.956 | 3.430 | 11.840 | +| EfficientNetB4 | 0.829 | 0.962 | 0.830 | 0.963 | 8.290 | 18.760 | +| EfficientNetB5 | 0.836 | 0.967 | 0.837 | 0.967 | 19.510 | 29.610 | +| EfficientNetB6 | 0.840 | 0.969 | 0.842 | 0.968 | 36.270 | 42.000 | +| EfficientNetB7 | 0.843 | 0.969 | 0.844 | 0.971 | 72.350 | 64.920 | +| EfficientNetB0_
small | 0.758 | 0.926 | | | 0.720 | 4.650 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------------------------|-----------|-------------------|-------------------------------|-------------------------------|-------------------------------| +| ResNeXt101_
32x8d_wsl | 224 | 256 | 13.55 | 23.39 | 36.18 | +| ResNeXt101_
32x16d_wsl | 224 | 256 | 21.96 | 38.35 | 63.29 | +| ResNeXt101_
32x32d_wsl | 224 | 256 | 37.28 | 76.50 | 121.56 | +| ResNeXt101_
32x48d_wsl | 224 | 256 | 55.07 | 124.39 | 205.01 | +| Fix_ResNeXt101_
32x48d_wsl | 320 | 320 | 55.01 | 122.63 | 204.66 | +| EfficientNetB0 | 224 | 256 | 1.96 | 3.71 | 5.56 | +| EfficientNetB1 | 240 | 272 | 2.88 | 5.40 | 7.63 | +| EfficientNetB2 | 260 | 292 | 3.26 | 6.20 | 9.17 | +| EfficientNetB3 | 300 | 332 | 4.52 | 8.85 | 13.54 | +| EfficientNetB4 | 380 | 412 | 6.78 | 15.47 | 24.95 | +| EfficientNetB5 | 456 | 488 | 10.97 | 27.24 | 45.93 | +| EfficientNetB6 | 528 | 560 | 17.09 | 43.32 | 76.90 | +| EfficientNetB7 | 600 | 632 | 25.91 | 71.23 | 128.20 | +| EfficientNetB0_
small | 224 | 256 | 1.24 | 2.59 | 3.92 | + + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|---------------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| ResNeXt101_
32x8d_wsl | 224 | 256 | 18.19374 | 21.93529 | 34.67802 | 18.52528 | 34.25319 | 67.2283 | +| ResNeXt101_
32x16d_wsl | 224 | 256 | 18.52609 | 36.8288 | 62.79947 | 25.60395 | 71.88384 | 137.62327 | +| ResNeXt101_
32x32d_wsl | 224 | 256 | 33.51391 | 70.09682 | 125.81884 | 54.87396 | 160.04337 | 316.17718 | +| ResNeXt101_
32x48d_wsl | 224 | 256 | 50.97681 | 137.60926 | 190.82628 | 99.01698256 | 315.91261 | 551.83695 | +| Fix_ResNeXt101_
32x48d_wsl | 320 | 320 | 78.62869 | 191.76039 | 317.15436 | 160.0838242 | 595.99296 | 1151.47384 | +| EfficientNetB0 | 224 | 256 | 3.40122 | 5.95851 | 9.10801 | 3.442 | 6.11476 | 9.3304 | +| EfficientNetB1 | 240 | 272 | 5.25172 | 9.10233 | 14.11319 | 5.3322 | 9.41795 | 14.60388 | +| EfficientNetB2 | 260 | 292 | 5.91052 | 10.5898 | 17.38106 | 6.29351 | 10.95702 | 17.75308 | +| EfficientNetB3 | 300 | 332 | 7.69582 | 16.02548 | 27.4447 | 7.67749 | 16.53288 | 28.5939 | +| EfficientNetB4 | 380 | 412 | 11.55585 | 29.44261 | 53.97363 | 12.15894 | 30.94567 | 57.38511 | +| EfficientNetB5 | 456 | 488 | 19.63083 | 56.52299 | - | 20.48571 | 61.60252 | - | +| EfficientNetB6 | 528 | 560 | 30.05911 | - | - | 32.62402 | - | - | +| EfficientNetB7 | 600 | 632 | 47.86087 | - | - | 53.93823 | - | - | +| EfficientNetB0_small | 224 | 256 | 2.39166 | 4.36748 | 6.96002 | 2.3076 | 4.71886 | 7.21888 | diff --git a/src/PaddleClas/docs/zh_CN/models/HRNet.md b/src/PaddleClas/docs/zh_CN/models/HRNet.md new file mode 100644 index 0000000..179c946 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/HRNet.md @@ -0,0 +1,73 @@ +# HRNet 系列 +----- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 +HRNet 是 2019 年由微软亚洲研究院提出的一种全新的神经网络,不同于以往的卷积神经网络,该网络在网络深层仍然可以保持高分辨率,因此预测的关键点热图更准确,在空间上也更精确。此外,该网络在对分辨率敏感的其他视觉任务中,如检测、分割等,表现尤为优异。 + +该系列模型的 FLOPS、参数量以及 T4 GPU 上的预测耗时如下图所示。 + +![](../../images/models/T4_benchmark/t4.fp32.bs4.HRNet.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.HRNet.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.HRNet.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.HRNet.png) + +目前 PaddleClas 开源的这类模型的预训练模型一共有 7 个,其指标如图所示,其中 HRNet_W48_C 指标精度异常的原因可能是因为网络训练的正常波动。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| HRNet_W18_C | 0.769 | 0.934 | 0.768 | 0.934 | 4.140 | 21.290 | +| HRNet_W18_C_ssld | 0.816 | 0.958 | 0.768 | 0.934 | 4.140 | 21.290 | +| HRNet_W30_C | 0.780 | 0.940 | 0.782 | 0.942 | 16.230 | 37.710 | +| HRNet_W32_C | 0.783 | 0.942 | 0.785 | 0.942 | 17.860 | 41.230 | +| HRNet_W40_C | 0.788 | 0.945 | 0.789 | 0.945 | 25.410 | 57.550 | +| HRNet_W44_C | 0.790 | 0.945 | 0.789 | 0.944 | 29.790 | 67.060 | +| HRNet_W48_C | 0.790 | 0.944 | 0.793 | 0.945 | 34.580 | 77.470 | +| HRNet_W48_C_ssld | 0.836 | 0.968 | 0.793 | 0.945 | 34.580 | 77.470 | +| HRNet_W64_C | 0.793 | 0.946 | 0.795 | 0.946 | 57.830 | 128.060 | +| SE_HRNet_W64_C_ssld | 0.847 | 0.973 | | | 57.830 | 128.970 | + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------|-----------|-------------------|-------------------|-------------------|-------------------| +| HRNet_W18_C | 224 | 256 | 6.66 | 8.94 | 11.95 | +| HRNet_W18_C_ssld | 224 | 256 | 6.66 | 8.92 | 11.93 | +| HRNet_W30_C | 224 | 256 | 8.61 | 11.40 | 15.23 | +| HRNet_W32_C | 224 | 256 | 8.54 | 11.58 | 15.57 | +| HRNet_W40_C | 224 | 256 | 9.83 | 15.02 | 20.92 | +| HRNet_W44_C | 224 | 256 | 10.62 | 16.18 | 25.92 | +| HRNet_W48_C | 224 | 256 | 11.07 | 17.06 | 27.28 | +| HRNet_W48_C_ssld | 224 | 256 | 11.09 | 17.04 | 27.28 | +| HRNet_W64_C | 224 | 256 | 13.82 | 21.15 | 35.51 | + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| HRNet_W18_C | 224 | 256 | 6.79093 | 11.50986 | 17.67244 | 7.40636 | 13.29752 | 23.33445 | +| HRNet_W18_C_ssld | 224 | 256 | 6.79093 | 11.50986 | 17.67244 | 7.40636 | 13.29752 | 23.33445 | +| HRNet_W30_C | 224 | 256 | 8.98077 | 14.08082 | 21.23527 | 9.57594 | 17.35485 | 32.6933 | +| HRNet_W32_C | 224 | 256 | 8.82415 | 14.21462 | 21.19804 | 9.49807 | 17.72921 | 32.96305 | +| HRNet_W40_C | 224 | 256 | 11.4229 | 19.1595 | 30.47984 | 12.12202 | 25.68184 | 48.90623 | +| HRNet_W44_C | 224 | 256 | 12.25778 | 22.75456 | 32.61275 | 13.19858 | 32.25202 | 59.09871 | +| HRNet_W48_C | 224 | 256 | 12.65015 | 23.12886 | 33.37859 | 13.70761 | 34.43572 | 63.01219 | +| HRNet_W48_C_ssld | 224 | 256 | 12.65015 | 23.12886 | 33.37859 | 13.70761 | 34.43572 | 63.01219 | +| HRNet_W64_C | 224 | 256 | 15.10428 | 27.68901 | 40.4198 | 17.57527 | 47.9533 | 97.11228 | +| SE_HRNet_W64_C_ssld | 224 | 256 | 32.33651 | 69.31189 | 116.07245 | 31.69770 | 94.99546 | 174.45766 | diff --git a/src/PaddleClas/docs/zh_CN/models/HarDNet.md b/src/PaddleClas/docs/zh_CN/models/HarDNet.md new file mode 100644 index 0000000..3f75fad --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/HarDNet.md @@ -0,0 +1,35 @@ +# HarDNet 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) + + +## 1. 概述 + +HarDNet(Harmonic DenseNet)是 2019 年由国立清华大学提出的一种全新的神经网络,在低 MAC 和内存流量的条件下实现了高效率。与 FC-DenseNet-103,DenseNet-264,ResNet-50,ResNet-152 和 SSD-VGG 相比,新网络的推理时间减少了 35%,36%,30%,32% 和 45%。我们使用了包括 Nvidia Profiler 和 ARM Scale-Sim 在内的工具来测量内存流量,并验证推理延迟确实与内存流量消耗成正比,并且所提议的网络消耗的内存流量很低。[论文地址](https://arxiv.org/abs/1909.00948)。 + + + +## 2. 精度、FLOPS 和参数量 + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:---------------------:|:----------:|:---------:|:---------:|:---------:| +| HarDNet68 | 17.6 | 4.3 | 75.46 | 92.65 | +| HarDNet85 | 36.7 | 9.1 | 77.44 | 93.55 | +| HarDNet39_ds | 3.5 | 0.4 | 71.33 | 89.98 | +| HarDNet68_ds | 4.2 | 0.8 | 73.62 | 91.52 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| ------------ | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| HarDNet68 | 224 | 256 | 3.58 | 8.53 | 11.58 | +| HarDNet85 | 224 | 256 | 6.24 | 14.85 | 20.57 | +| HarDNet39_ds | 224 | 256 | 1.40 | 2.30 | 3.33 | +| HarDNet68_ds | 224 | 256 | 2.26 | 3.34 | 5.06 | + diff --git a/src/PaddleClas/docs/zh_CN/models/Inception.md b/src/PaddleClas/docs/zh_CN/models/Inception.md new file mode 100644 index 0000000..bed40b3 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/Inception.md @@ -0,0 +1,80 @@ +# Inception 系列 +----- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 + +GoogLeNet 是 2014 年由 Google 设计的一种新的神经网络结构,其与 VGG 网络并列成为当年 ImageNet 挑战赛的双雄。GoogLeNet 首次引入 Inception 结构,在网络中堆叠该结构使得网络层数达到了 22 层,这也是卷积网络首次超过 20 层的标志。由于在 Inception 结构中使用了 1x1 的卷积用于通道数降维,并且使用了 Global-pooling 代替传统的多 fc 层加工特征的方式,最终的 GoogLeNet 网络的 FLOPS 和参数量远小于 VGG 网络,成为当时神经网络设计的一道亮丽风景线。 + +InceptionV3 是 Google 对 InceptionV2 的一种改进。首先,InceptionV3 对 Inception 模块进行了优化,同时设计和使用了更多种类的 Inception 模块,与此同时,InceptionV3 中的部分 Inception 模块将较大的方形二维卷积拆成两个较小的非对称卷积,这样可以大幅度节省参数量。 + +Xception 是 Google 继 Inception 后提出的对 InceptionV3 的另一种改进。在 Xception 中,作者使用了深度可分离卷积代替了传统的卷积操作,该操作大大节省了网络的 FLOPS 和参数量,但是精度反而有所提升。在 DeeplabV3+ 中,作者将 Xception 做了进一步的改进,同时增加了 Xception 的层数,设计出了 Xception65 和 Xception71 的网络。 + +InceptionV4 是 2016 年由 Google 设计的新的神经网络,当时残差结构风靡一时,但是作者认为仅使用 Inception 结构也可以达到很高的性能。InceptionV4 使用了更多的 Inception module,在 ImageNet 上的精度再创新高。 + + +该系列模型的 FLOPS、参数量以及 T4 GPU 上的预测耗时如下图所示。 + +![](../../images/models/T4_benchmark/t4.fp32.bs4.Inception.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.Inception.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.Inception.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.Inception.png) + +上图反映了 Xception 系列和 InceptionV4 的精度和其他指标的关系。其中 Xception_deeplab 与论文结构保持一致,Xception 是 PaddleClas 的改进模型,在预测速度基本不变的情况下,精度提升约 0.6%。关于该改进模型的详细介绍正在持续更新中,敬请期待。 + + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| GoogLeNet | 0.707 | 0.897 | 0.698 | | 2.880 | 8.460 | +| Xception41 | 0.793 | 0.945 | 0.790 | 0.945 | 16.740 | 22.690 | +| Xception41
_deeplab | 0.796 | 0.944 | | | 18.160 | 26.730 | +| Xception65 | 0.810 | 0.955 | | | 25.950 | 35.480 | +| Xception65
_deeplab | 0.803 | 0.945 | | | 27.370 | 39.520 | +| Xception71 | 0.811 | 0.955 | | | 31.770 | 37.280 | +| InceptionV3 | 0.791 | 0.946 | 0.788 | 0.944 | 11.460 | 23.830 | +| InceptionV4 | 0.808 | 0.953 | 0.800 | 0.950 | 24.570 | 42.680 | + + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|------------------------|-----------|-------------------|------------------------|------------------------|------------------------| +| GoogLeNet | 224 | 256 | 1.41 | 3.25 | 5.00 | +| Xception41 | 299 | 320 | 3.58 | 8.76 | 16.61 | +| Xception41_
deeplab | 299 | 320 | 3.81 | 9.16 | 17.20 | +| Xception65 | 299 | 320 | 5.45 | 12.78 | 24.53 | +| Xception65_
deeplab | 299 | 320 | 5.65 | 13.08 | 24.61 | +| Xception71 | 299 | 320 | 6.19 | 15.34 | 29.21 | +| InceptionV4 | 299 | 320 | 8.93 | 15.17 | 21.56 | + + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|--------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| GoogLeNet | 299 | 320 | 1.75451 | 3.39931 | 4.71909 | 1.88038 | 4.48882 | 6.94035 | +| Xception41 | 299 | 320 | 2.91192 | 7.86878 | 15.53685 | 4.96939 | 17.01361 | 32.67831 | +| Xception41_
deeplab | 299 | 320 | 2.85934 | 7.2075 | 14.01406 | 5.33541 | 17.55938 | 33.76232 | +| Xception65 | 299 | 320 | 4.30126 | 11.58371 | 23.22213 | 7.26158 | 25.88778 | 53.45426 | +| Xception65_
deeplab | 299 | 320 | 4.06803 | 9.72694 | 19.477 | 7.60208 | 26.03699 | 54.74724 | +| Xception71 | 299 | 320 | 4.80889 | 13.5624 | 27.18822 | 8.72457 | 31.55549 | 69.31018 | +| InceptionV3 | 299 | 320 | 3.67502 | 6.36071 | 9.82645 | 6.64054 | 13.53630 | 22.17355 | +| InceptionV4 | 299 | 320 | 9.50821 | 13.72104 | 20.27447 | 12.99342 | 25.23416 | 43.56121 | diff --git a/src/PaddleClas/docs/zh_CN/models/LeViT.md b/src/PaddleClas/docs/zh_CN/models/LeViT.md new file mode 100644 index 0000000..5f0e480 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/LeViT.md @@ -0,0 +1,27 @@ +# LeViT + +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) + + + +## 1. 概述 +LeViT 是一种快速推理的、用于图像分类任务的混合神经网络。其设计之初考虑了网络模型在不同的硬件平台上的性能,因此能够更好地反映普遍应用的真实场景。通过大量实验,作者找到了卷积神经网络与 Transformer 体系更好的结合方式,并且提出了 attention-based 方法,用于整合 Transformer 中的位置信息编码。[论文地址](https://arxiv.org/abs/2104.01136)。 + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(M) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| LeViT-128S | 0.7598 | 0.9269 | 0.766 | 0.929 | 305 | 7.8 | +| LeViT-128 | 0.7810 | 0.9371 | 0.786 | 0.940 | 406 | 9.2 | +| LeViT-192 | 0.7934 | 0.9446 | 0.800 | 0.947 | 658 | 11 | +| LeViT-256 | 0.8085 | 0.9497 | 0.816 | 0.954 | 1120 | 19 | +| LeViT-384 | 0.8191 | 0.9551 | 0.826 | 0.960 | 2353 | 39 | + + +**注**:与 Reference 的精度差异源于数据预处理不同及未使用蒸馏的 head 作为输出。 diff --git a/src/PaddleClas/docs/zh_CN/models/MixNet.md b/src/PaddleClas/docs/zh_CN/models/MixNet.md new file mode 100644 index 0000000..eaf45d3 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/MixNet.md @@ -0,0 +1,40 @@ +# MixNet 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) + + + +## 1. 概述 + +MixNet 是谷歌出的一篇关于轻量级网络的文章,主要工作就在于探索不同大小的卷积核的组合。作者发现目前网络有以下两个问题: + +- 小的卷积核感受野小,参数少,但是准确率不高 +- 大的卷积核感受野大,准确率相对略高,但是参数也相对增加了很多 + +为了解决上面两个问题,文中提出一种新的混合深度分离卷积(MDConv)(mixed depthwise convolution),将不同的核大小混合在一个卷积运算中,并且基于 AutoML 的搜索空间,提出了一系列的网络叫做 MixNets,在 ImageNet 上取得了较好的效果。[论文地址](https://arxiv.org/pdf/1907.09595.pdf) + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1| FLOPS
(M) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|----| +| MixNet_S | 76.28 | 92.99 | 75.8 | 252.977 | 4.167 | +| MixNet_M | 77.67 | 93.64 | 77.0 | 357.119 | 5.065 | +| MixNet_L | 78.60 | 94.37 | 78.9 | 579.017 | 7.384 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| -------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| MixNet_S | 224 | 256 | 2.31 | 3.63 | 5.20 | +| MixNet_M | 224 | 256 | 2.84 | 4.60 | 6.62 | +| MixNet_L | 224 | 256 | 3.16 | 5.55 | 8.03 | + +关于 Inference speed 等信息,敬请期待。 diff --git a/src/PaddleClas/docs/zh_CN/models/Mobile.md b/src/PaddleClas/docs/zh_CN/models/Mobile.md new file mode 100644 index 0000000..c4cede5 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/Mobile.md @@ -0,0 +1,207 @@ +# 移动端系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 SD855 的预测速度和存储大小](#3) +* [4. 基于 V100 GPU 的预测速度](#4) +* [5. 基于 T4 GPU 的预测速度](#5) + + + +## 1. 概述 +MobileNetV1 是 Google 于 2017 年发布的用于移动设备或嵌入式设备中的网络。该网络将传统的卷积操作替换深度可分离卷积,即 Depthwise 卷积和 Pointwise 卷积的组合,相比传统的卷积操作,该组合可以大大节省参数量和计算量。与此同时,MobileNetV1 也可以用于目标检测、图像分割等其他视觉任务中。 + +MobileNetV2 是 Google 继 MobileNetV1 提出的一种轻量级网络。相比 MobileNetV1,MobileNetV2 提出了 Linear bottlenecks 与 Inverted residual block 作为网络基本结构,通过大量地堆叠这些基本模块,构成了 MobileNetV2 的网络结构。最终,在 FLOPS 只有 MobileNetV1 的一半的情况下取得了更高的分类精度。 + +ShuffleNet 系列网络是旷视提出的轻量化网络结构,到目前为止,该系列网络一共有两种典型的结构,即 ShuffleNetV1 与 ShuffleNetV2。ShuffleNet 中的 Channel Shuffle 操作可以将组间的信息进行交换,并且可以实现端到端的训练。在 ShuffleNetV2 的论文中,作者提出了设计轻量级网络的四大准则,并且根据四大准则与 ShuffleNetV1 的不足,设计了 ShuffleNetV2 网络。 + +MobileNetV3 是 Google 于 2019 年提出的一种基于 NAS 的新的轻量级网络,为了进一步提升效果,将 relu 和 sigmoid 激活函数分别替换为 hard_swish 与 hard_sigmoid 激活函数,同时引入了一些专门减小网络计算量的改进策略。 + +GhostNet 是华为于 2020 年提出的一种全新的轻量化网络结构,通过引入 ghost module,大大减缓了传统深度网络中特征的冗余计算问题,使得网络的参数量和计算量大大降低。 + +![](../../images/models/mobile_arm_top1.png) + +![](../../images/models/mobile_arm_storage.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.mobile_trt.params.png) + + +目前 PaddleClas 开源的的移动端系列的预训练模型一共有 35 个,其指标如图所示。从图片可以看出,越新的轻量级模型往往有更优的表现,MobileNetV3 代表了目前主流的轻量级神经网络结构。在 MobileNetV3 中,作者为了获得更高的精度,在 global-avg-pooling 后使用了 1x1 的卷积。该操作大幅提升了参数量但对计算量影响不大,所以如果从存储角度评价模型的优异程度,MobileNetV3 优势不是很大,但由于其更小的计算量,使得其有更快的推理速度。此外,我们模型库中的 ssld 蒸馏模型表现优异,从各个考量角度下,都刷新了当前轻量级模型的精度。由于 MobileNetV3 模型结构复杂,分支较多,对 GPU 并不友好,GPU 预测速度不如 MobileNetV1。GhostNet 于 2020 年提出,通过引入 ghost 的网络设计理念,大大降低了计算量和参数量,同时在精度上也超过前期最高的 MobileNetV3 网络结构。 + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 0.514 | 0.755 | 0.506 | | 0.070 | 0.460 | +| MobileNetV1_x0_5 | 0.635 | 0.847 | 0.637 | | 0.280 | 1.310 | +| MobileNetV1_x0_75 | 0.688 | 0.882 | 0.684 | | 0.630 | 2.550 | +| MobileNetV1 | 0.710 | 0.897 | 0.706 | | 1.110 | 4.190 | +| MobileNetV1_ssld | 0.779 | 0.939 | | | 1.110 | 4.190 | +| MobileNetV2_x0_25 | 0.532 | 0.765 | | | 0.050 | 1.500 | +| MobileNetV2_x0_5 | 0.650 | 0.857 | 0.654 | 0.864 | 0.170 | 1.930 | +| MobileNetV2_x0_75 | 0.698 | 0.890 | 0.698 | 0.896 | 0.350 | 2.580 | +| MobileNetV2 | 0.722 | 0.907 | 0.718 | 0.910 | 0.600 | 3.440 | +| MobileNetV2_x1_5 | 0.741 | 0.917 | | | 1.320 | 6.760 | +| MobileNetV2_x2_0 | 0.752 | 0.926 | | | 2.320 | 11.130 | +| MobileNetV2_ssld | 0.7674 | 0.9339 | | | 0.600 | 3.440 | +| MobileNetV3_large_
x1_25 | 0.764 | 0.930 | 0.766 | | 0.714 | 7.440 | +| MobileNetV3_large_
x1_0 | 0.753 | 0.923 | 0.752 | | 0.450 | 5.470 | +| MobileNetV3_large_
x0_75 | 0.731 | 0.911 | 0.733 | | 0.296 | 3.910 | +| MobileNetV3_large_
x0_5 | 0.692 | 0.885 | 0.688 | | 0.138 | 2.670 | +| MobileNetV3_large_
x0_35 | 0.643 | 0.855 | 0.642 | | 0.077 | 2.100 | +| MobileNetV3_small_
x1_25 | 0.707 | 0.895 | 0.704 | | 0.195 | 3.620 | +| MobileNetV3_small_
x1_0 | 0.682 | 0.881 | 0.675 | | 0.123 | 2.940 | +| MobileNetV3_small_
x0_75 | 0.660 | 0.863 | 0.654 | | 0.088 | 2.370 | +| MobileNetV3_small_
x0_5 | 0.592 | 0.815 | 0.580 | | 0.043 | 1.900 | +| MobileNetV3_small_
x0_35 | 0.530 | 0.764 | 0.498 | | 0.026 | 1.660 | +| MobileNetV3_small_
x0_35_ssld | 0.556 | 0.777 | 0.498 | | 0.026 | 1.660 | +| MobileNetV3_large_
x1_0_ssld | 0.790 | 0.945 | | | 0.450 | 5.470 | +| MobileNetV3_large_
x1_0_ssld_int8 | 0.761 | | | | | | +| MobileNetV3_small_
x1_0_ssld | 0.713 | 0.901 | | | 0.123 | 2.940 | +| ShuffleNetV2 | 0.688 | 0.885 | 0.694 | | 0.280 | 2.260 | +| ShuffleNetV2_x0_25 | 0.499 | 0.738 | | | 0.030 | 0.600 | +| ShuffleNetV2_x0_33 | 0.537 | 0.771 | | | 0.040 | 0.640 | +| ShuffleNetV2_x0_5 | 0.603 | 0.823 | 0.603 | | 0.080 | 1.360 | +| ShuffleNetV2_x1_5 | 0.716 | 0.902 | 0.726 | | 0.580 | 3.470 | +| ShuffleNetV2_x2_0 | 0.732 | 0.912 | 0.749 | | 1.120 | 7.320 | +| ShuffleNetV2_swish | 0.700 | 0.892 | | | 0.290 | 2.260 | +| GhostNet_x0_5 | 0.668 | 0.869 | 0.662 | 0.866 | 0.082 | 2.600 | +| GhostNet_x1_0 | 0.740 | 0.916 | 0.739 | 0.914 | 0.294 | 5.200 | +| GhostNet_x1_3 | 0.757 | 0.925 | 0.757 | 0.927 | 0.440 | 7.300 | +| GhostNet_x1_3_ssld | 0.794 | 0.945 | 0.757 | 0.927 | 0.440 | 7.300 | + + + +## 3. 基于 SD855 的预测速度和存储大小 + +| Models | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | Storage Size(M) | +|:--:|----|----|----|----| +| MobileNetV1_x0_25 | 2.88 | 1.82 | 1.26 | 1.900 | +| MobileNetV1_x0_5 | 8.74 | 5.26 | 3.09 | 5.200 | +| MobileNetV1_x0_75 | 17.84 | 10.61 | 6.21 | 10.000 | +| MobileNetV1 | 30.24 | 17.86 | 10.30 | 16.000 | +| MobileNetV1_ssld | 30.19 | 17.85 | 10.23 | 16.000 | +| MobileNetV2_x0_25 | 3.46 | 2.51 | 2.03 | 6.100 | +| MobileNetV2_x0_5 | 7.69 | 4.92 | 3.57 | 7.800 | +| MobileNetV2_x0_75 | 13.69 | 8.60 | 5.82 | 10.000 | +| MobileNetV2 | 20.74 | 12.71 | 8.10 | 14.000 | +| MobileNetV2_x1_5 | 40.79 | 24.49 | 15.50 | 26.000 | +| MobileNetV2_x2_0 | 67.50 | 40.03 | 25.55 | 43.000 | +| MobileNetV2_ssld | 20.71 | 12.70 | 8.06 | 14.000 | +| MobileNetV3_large_x1_25 | 24.52 | 14.76 | 9.89 | 29.000 | +| MobileNetV3_large_x1_0 | 16.55 | 10.09 | 6.84 | 21.000 | +| MobileNetV3_large_x0_75 | 11.53 | 7.06 | 4.94 | 16.000 | +| MobileNetV3_large_x0_5 | 6.50 | 4.22 | 3.15 | 11.000 | +| MobileNetV3_large_x0_35 | 4.43 | 3.11 | 2.41 | 8.600 | +| MobileNetV3_small_x1_25 | 7.88 | 4.91 | 3.45 | 14.000 | +| MobileNetV3_small_x1_0 | 5.63 | 3.65 | 2.60 | 12.000 | +| MobileNetV3_small_x0_75 | 4.50 | 2.96 | 2.19 | 9.600 | +| MobileNetV3_small_x0_5 | 2.89 | 2.04 | 1.62 | 7.800 | +| MobileNetV3_small_x0_35 | 2.23 | 1.66 | 1.43 | 6.900 | +| MobileNetV3_small_x0_35_ssld | | | | 6.900 | +| MobileNetV3_large_x1_0_ssld | 16.56 | 10.10 | 6.86 | 21.000 | +| MobileNetV3_large_x1_0_ssld_int8 | | | | 10.000 | +| MobileNetV3_small_x1_0_ssld | 5.64 | 3.67 | 2.61 | 12.000 | +| ShuffleNetV2 | 9.72 | 5.97 | 4.13 | 9.000 | +| ShuffleNetV2_x0_25 | 1.94 | 1.53 | 1.43 | 2.700 | +| ShuffleNetV2_x0_33 | 2.23 | 1.70 | 1.79 | 2.800 | +| ShuffleNetV2_x0_5 | 3.67 | 2.63 | 2.06 | 5.600 | +| ShuffleNetV2_x1_5 | 17.21 | 10.56 | 6.81 | 14.000 | +| ShuffleNetV2_x2_0 | 31.21 | 18.98 | 11.65 | 28.000 | +| ShuffleNetV2_swish | 31.21 | 9.06 | 5.74 | 9.100 | +| GhostNet_x0_5 | 5.28 | 3.95 | 3.29 | 10.000 | +| GhostNet_x1_0 | 12.89 | 8.66 | 6.72 | 20.000 | +| GhostNet_x1_3 | 19.16 | 12.25 | 9.40 | 29.000 | +| GhostNet_x1_3_ssld | 19.16 | 17.85 | 10.18 | 29.000 | + + + +## 4. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| -------------------------------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| MobileNetV1_x0_25 | 224 | 256 | 0.47 | 0.93 | 1.39 | +| MobileNetV1_x0_5 | 224 | 256 | 0.48 | 1.09 | 1.69 | +| MobileNetV1_x0_75 | 224 | 256 | 0.55 | 1.34 | 2.03 | +| MobileNetV1 | 224 | 256 | 0.64 | 1.57 | 2.48 | +| MobileNetV1_ssld | 224 | 256 | 0.66 | 1.59 | 2.58 | +| MobileNetV2_x0_25 | 224 | 256 | 0.83 | 1.17 | 1.78 | +| MobileNetV2_x0_5 | 224 | 256 | 0.84 | 1.45 | 2.04 | +| MobileNetV2_x0_75 | 224 | 256 | 0.96 | 1.62 | 2.53 | +| MobileNetV2 | 224 | 256 | 1.02 | 1.93 | 2.89 | +| MobileNetV2_x1_5 | 224 | 256 | 1.32 | 2.58 | 4.14 | +| MobileNetV2_x2_0 | 224 | 256 | 1.57 | 3.13 | 4.76 | +| MobileNetV2_ssld | 224 | 256 | 1.01 | 1.97 | 2.84 | +| MobileNetV3_large_x1_25 | 224 | 256 | 1.75 | 2.87 | 4.23 | +| MobileNetV3_large_x1_0 | 224 | 256 | 1.37 | 2.67 | 3.46 | +| MobileNetV3_large_x0_75 | 224 | 256 | 1.37 | 2.23 | 3.17 | +| MobileNetV3_large_x0_5 | 224 | 256 | 1.10 | 1.85 | 2.69 | +| MobileNetV3_large_x0_35 | 224 | 256 | 1.01 | 1.44 | 1.92 | +| MobileNetV3_small_x1_25 | 224 | 256 | 1.20 | 2.04 | 2.64 | +| MobileNetV3_small_x1_0 | 224 | 256 | 1.03 | 1.76 | 2.50 | +| MobileNetV3_small_x0_75 | 224 | 256 | 1.04 | 1.71 | 2.37 | +| MobileNetV3_small_x0_5 | 224 | 256 | 1.01 | 1.49 | 2.01 | +| MobileNetV3_small_x0_35 | 224 | 256 | 1.01 | 1.44 | 1.92 | +| MobileNetV3_small_x0_35_ssld | 224 | 256 | | | | +| MobileNetV3_large_x1_0_ssld | 224 | 256 | 1.35 | 2.47 | 3.72 | +| MobileNetV3_large_x1_0_ssld_int8 | 224 | 256 | | | | +| MobileNetV3_small_x1_0_ssld | 224 | 256 | 1.06 | 1.89 | 2.48 | +| ShuffleNetV2 | 224 | 256 | 1.05 | 1.76 | 2.37 | +| ShuffleNetV2_x0_25 | 224 | 256 | 0.92 | 1.27 | 1.73 | +| ShuffleNetV2_x0_33 | 224 | 256 | 0.91 | 1.29 | 1.81 | +| ShuffleNetV2_x0_5 | 224 | 256 | 0.89 | 1.43 | 1.94 | +| ShuffleNetV2_x1_5 | 224 | 256 | 0.93 | 1.99 | 2.85 | +| ShuffleNetV2_x2_0 | 224 | 256 | 1.45 | 2.70 | 3.35 | +| ShuffleNetV2_swish | 224 | 256 | 1.43 | 1.93 | 2.69 | +| GhostNet_x0_5 | 224 | 256 | 1.66 | 2.24 | 2.73 | +| GhostNet_x1_0 | 224 | 256 | 1.69 | 2.73 | 3.81 | +| GhostNet_x1_3 | 224 | 256 | 1.84 | 2.88 | 3.94 | +| GhostNet_x1_3_ssld | 224 | 256 | 1.85 | 3.17 | 4.29 | + + + +## 5. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------| +| MobileNetV1_x0_25 | 224 | 256 | 0.47 | 0.93 | 1.39 | +| MobileNetV1_x0_5 | 224 | 256 | 0.48 | 1.09 | 1.69 | +| MobileNetV1_x0_75 | 224 | 256 | 0.55 | 1.34 | 2.03 | +| MobileNetV1 | 224 | 256 | 0.64 | 1.57 | 2.48 | +| MobileNetV1_ssld | 224 | 256 | 0.66 | 1.59 | 2.58 | +| MobileNetV2_x0_25 | 224 | 256 | 0.83 | 1.17 | 1.78 | +| MobileNetV2_x0_5 | 224 | 256 | 0.84 | 1.45 | 2.04 | +| MobileNetV2_x0_75 | 224 | 256 | 0.96 | 1.62 | 2.53 | +| MobileNetV2 | 224 | 256 | 1.02 | 1.93 | 2.89 | +| MobileNetV2_x1_5 | 224 | 256 | 1.32 | 2.58 | 4.14 | +| MobileNetV2_x2_0 | 224 | 256 | 1.57 | 3.13 | 4.76 | +| MobileNetV2_ssld | 224 | 256 | 1.01 | 1.97 | 2.84 | +| MobileNetV3_small_x0_35 | 224 | 256 | 1.01 | 1.44 | 1.92 | +| MobileNetV3_small_x0_5 | 224 | 256 | 1.01 | 1.49 | 2.01 | +| MobileNetV3_small_x0_75 | 224 | 256 | 1.04 | 1.71 | 2.37 | +| MobileNetV3_small_x1_0 | 224 | 256 | 1.03 | 1.76 | 2.50 | +| MobileNetV3_small_x1_25 | 224 | 256 | 1.20 | 2.04 | 2.64 | +| MobileNetV3_large_x0_35 | 224 | 256 | 1.10 | 1.74 | 2.34 | +| MobileNetV3_large_x0_5 | 224 | 256 | 1.10 | 1.85 | 2.69 | +| MobileNetV3_large_x0_75 | 224 | 256 | 1.37 | 2.23 | 3.17 | +| MobileNetV3_large_x1_0 | 224 | 256 | 1.37 | 2.67 | 3.46 | +| MobileNetV3_large_x1_25 | 224 | 256 | 1.75 | 2.87 | 4.23 | +| MobileNetV3_small_x1_0_ssld | 224 | 256 | 1.06 | 1.89 | 2.48 | +| MobileNetV3_large_x1_0_ssld | 224 | 256 | 1.35 | 2.47 | 3.72 | +| ShuffleNetV2_swish | 224 | 256 | 1.43 | 1.93 | 2.69 | +| ShuffleNetV2_x0_25 | 224 | 256 | 0.92 | 1.27 | 1.73 | +| ShuffleNetV2_x0_33 | 224 | 256 | 0.91 | 1.29 | 1.81 | +| ShuffleNetV2_x0_5 | 224 | 256 | 0.89 | 1.43 | 1.94 | +| ShuffleNetV2_x1_0 | 224 | 256 | 1.05 | 1.76 | 2.37 | +| ShuffleNetV2_x1_5 | 224 | 256 | 0.93 | 1.99 | 2.85 | +| ShuffleNetV2_x2_0 | 224 | 256 | 1.45 | 2.70 | 3.35 | +| GhostNet_x0_5 | 224 | 256 | 1.66 | 2.24 | 2.73 | +| GhostNet_x1_0 | 224 | 256 | 1.69 | 2.73 | 3.81 | +| GhostNet_x1_3 | 224 | 256 | 1.84 | 2.88 | 3.94 | +| GhostNet_x1_3_ssld | 224 | 256 | 1.85 | 3.17 | 4.29 | diff --git a/src/PaddleClas/docs/zh_CN/models/Others.md b/src/PaddleClas/docs/zh_CN/models/Others.md new file mode 100644 index 0000000..ff43c44 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/Others.md @@ -0,0 +1,64 @@ +# 其他模型 +----- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 +2012 年,Alex 等人提出的 AlexNet 网络在 ImageNet 大赛上以远超第二名的成绩夺冠,卷积神经网络乃至深度学习引起了广泛的关注。AlexNet 使用 relu 作为 CNN 的激活函数,解决了 sigmoid 在网络较深时的梯度弥散问题。训练时使用 Dropout 随机丢掉一部分神经元,避免了模型过拟合。网络中使用重叠的最大池化代替了此前 CNN 中普遍使用的平均池化,避免了平均池化的模糊效果,提升了特征的丰富性。从某种意义上说,AlexNet 引爆了神经网络的研究与应用热潮。 + +SqueezeNet 在 ImageNet-1k 上实现了与 AlexNet 相同的精度,但只用了 1/50 的参数量。该网络的核心是 Fire 模块,Fire 模块通过使用 1x1 的卷积实现通道降维,从而大大节省了参数量。作者通过大量堆叠 Fire 模块组成了 SqueezeNet。 + +VGG 由牛津大学计算机视觉组和 DeepMind 公司研究员一起研发的卷积神经网络。该网络探索了卷积神经网络的深度和其性能之间的关系,通过反复的堆叠 3x3 的小型卷积核和 2x2 的最大池化层,成功的构建了多层卷积神经网络并取得了不错的收敛精度。最终,VGG 获得了 ILSVRC 2014 比赛分类项目的亚军和定位项目的冠军。 + +DarkNet53 是 YOLO 作者在论文设计的用于目标检测的 backbone,该网络基本由 1x1 与 3x3 卷积构成,共 53 层,取名为 DarkNet53。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| AlexNet | 0.567 | 0.792 | 0.5720 | | 1.370 | 61.090 | +| SqueezeNet1_0 | 0.596 | 0.817 | 0.575 | | 1.550 | 1.240 | +| SqueezeNet1_1 | 0.601 | 0.819 | | | 0.690 | 1.230 | +| VGG11 | 0.693 | 0.891 | | | 15.090 | 132.850 | +| VGG13 | 0.700 | 0.894 | | | 22.480 | 133.030 | +| VGG16 | 0.720 | 0.907 | 0.715 | 0.901 | 30.810 | 138.340 | +| VGG19 | 0.726 | 0.909 | | | 39.130 | 143.650 | +| DarkNet53 | 0.780 | 0.941 | 0.772 | 0.938 | 18.580 | 41.600 | + + + +## 3. 基于 V100 GPU 的预测速度 + + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|---------------------------|-----------|-------------------|-------------------|-------------------|-------------------| +| AlexNet | 224 | 256 | 0.81 | 1.50 | 2.33 | +| SqueezeNet1_0 | 224 | 256 | 0.68 | 1.64 | 2.62 | +| SqueezeNet1_1 | 224 | 256 | 0.62 | 1.30 | 2.09 | +| VGG11 | 224 | 256 | 1.72 | 4.15 | 7.24 | +| VGG13 | 224 | 256 | 2.02 | 5.28 | 9.54 | +| VGG16 | 224 | 256 | 2.48 | 6.79 | 12.33 | +| VGG19 | 224 | 256 | 2.93 | 8.28 | 15.21 | +| DarkNet53 | 256 | 256 | 2.79 | 6.42 | 10.89 | + + + +## 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| AlexNet | 224 | 256 | 1.06447 | 1.70435 | 2.38402 | 1.44993 | 2.46696 | 3.72085 | +| SqueezeNet1_0 | 224 | 256 | 0.97162 | 2.06719 | 3.67499 | 0.96736 | 2.53221 | 4.54047 | +| SqueezeNet1_1 | 224 | 256 | 0.81378 | 1.62919 | 2.68044 | 0.76032 | 1.877 | 3.15298 | +| VGG11 | 224 | 256 | 2.24408 | 4.67794 | 7.6568 | 3.90412 | 9.51147 | 17.14168 | +| VGG13 | 224 | 256 | 2.58589 | 5.82708 | 10.03591 | 4.64684 | 12.61558 | 23.70015 | +| VGG16 | 224 | 256 | 3.13237 | 7.19257 | 12.50913 | 5.61769 | 16.40064 | 32.03939 | +| VGG19 | 224 | 256 | 3.69987 | 8.59168 | 15.07866 | 6.65221 | 20.4334 | 41.55902 | +| DarkNet53 | 256 | 256 | 3.18101 | 5.88419 | 10.14964 | 4.10829 | 12.1714 | 22.15266 | diff --git a/src/PaddleClas/docs/zh_CN/models/PP-LCNet.md b/src/PaddleClas/docs/zh_CN/models/PP-LCNet.md new file mode 100644 index 0000000..156f30e --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/PP-LCNet.md @@ -0,0 +1,204 @@ +# PP-LCNet 系列 +--- + +## 目录 + +- [1. 摘要](#1) +- [2. 介绍](#2) +- [3. 方法](#3) + - [3.1 更好的激活函数](#3.1) + - [3.2 合适的位置添加 SE 模块](#3.2) + - [3.3 合适的位置添加更大的卷积核](#3.3) + - [3.4 GAP 后使用更大的 1x1 卷积层](#3.4) +- [4. 实验部分](#4) + - [4.1 图像分类](#4.1) + - [4.2 目标检测](#4.2) + - [4.3 语义分割](#4.3) +- [5. 基于 V100 GPU 的预测速度](#5) +- [6. 基于 SD855 的预测速度](#6) +- [7. 总结](#7) +- [8. 引用](#8) + + + +## 1. 摘要 + +在计算机视觉领域中,骨干网络的好坏直接影响到整个视觉任务的结果。在之前的一些工作中,相关的研究者普遍将 FLOPs 或者 Params 作为优化目的,但是在工业界真实落地的场景中,推理速度才是考量模型好坏的重要指标,然而,推理速度和准确性很难兼得。考虑到工业界有很多基于 Intel CPU 的应用,所以我们本次的工作旨在使骨干网络更好的适应 Intel CPU,从而得到一个速度更快、准确率更高的轻量级骨干网络,与此同时,目标检测、语义分割等下游视觉任务的性能也同样得到提升。 + + +## 2. 介绍 + +近年来,有很多轻量级的骨干网络问世,尤其最近两年,各种 NAS 搜索出的网络层出不穷,这些网络要么主打 FLOPs 或者 Params 上的优势,要么主打 ARM 设备上的推理速度的优势,很少有网络专门针对 Intel CPU 做特定的优化,导致这些网络在 Intel CPU 端的推理速度并不是很完美。基于此,我们针对 Intel CPU 设备以及其加速库 MKLDNN 设计了特定的骨干网络 PP-LCNet,比起其他的轻量级的 SOTA 模型,该骨干网络可以在不增加推理时间的情况下,进一步提升模型的性能,最终大幅度超越现有的 SOTA 模型。与其他模型的对比图如下。 +![](../../images/PP-LCNet/PP-LCNet-Acc.png) + + +## 3. 方法 + +网络结构整体如下图所示。 +![](../../images/PP-LCNet/PP-LCNet.png) +我们经过大量的实验发现,在基于 Intel CPU 设备上,尤其当启用 MKLDNN 加速库后,很多看似不太耗时的操作反而会增加延时,比如 elementwise-add 操作、split-concat 结构等。所以最终我们选用了结构尽可能精简、速度尽可能快的 block 组成我们的 BaseNet(类似 MobileNetV1)。基于 BaseNet,我们通过实验,总结了四条几乎不增加延时但是可以提升模型精度的方法,融合这四条策略,我们组合成了 PP-LCNet。下面对这四条策略一一介绍: + + +### 3.1 更好的激活函数 + +自从卷积神经网络使用了 ReLU 激活函数后,网络性能得到了大幅度提升,近些年 ReLU 激活函数的变体也相继出现,如 Leaky-ReLU、P-ReLU、ELU 等,2017 年,谷歌大脑团队通过搜索的方式得到了 swish 激活函数,该激活函数在轻量级网络上表现优异,在 2019 年,MobileNetV3 的作者将该激活函数进一步优化为 H-Swish,该激活函数去除了指数运算,速度更快,网络精度几乎不受影响。我们也经过很多实验发现该激活函数在轻量级网络上有优异的表现。所以在 PP-LCNet 中,我们选用了该激活函数。 + + +### 3.2 合适的位置添加 SE 模块 + +SE 模块是 SENet 提出的一种通道注意力机制,可以有效提升模型的精度。但是在 Intel CPU 端,该模块同样会带来较大的延时,如何平衡精度和速度是我们要解决的一个问题。虽然在 MobileNetV3 等基于 NAS 搜索的网络中对 SE 模块的位置进行了搜索,但是并没有得出一般的结论,我们通过实验发现,SE 模块越靠近网络的尾部对模型精度的提升越大。下表也展示了我们的一些实验结果: + + +| SE Location | Top-1 Acc(\%) | Latency(ms) | +|-------------------|---------------|-------------| +| 1100000000000 | 61.73 | 2.06 | +| 0000001100000 | 62.17 | 2.03 | +| 0000000000011 | 63.14 | 2.05 | +| 1111111111111 | 64.27 | 3.80 | + + +最终,PP-LCNet 中的 SE 模块的位置选用了表格中第三行的方案。 + + +### 3.3 合适的位置添加更大的卷积核 + +在 MixNet 的论文中,作者分析了卷积核大小对模型性能的影响,结论是在一定范围内大的卷积核可以提升模型的性能,但是超过这个范围会有损模型的性能,所以作者组合了一种 split-concat 范式的 MixConv,这种组合虽然可以提升模型的性能,但是不利于推理。我们通过实验总结了一些更大的卷积核在不同位置的作用,类似 SE 模块的位置,更大的卷积核在网络的中后部作用更明显,下表展示了 5x5 卷积核的位置对精度的影响: + +| large-kernel Location | Top-1 Acc(\%) | Latency(ms) | +|-------------------|---------------|-------------| +| 1111111111111 | 63.22 | 2.08 | +| 1111111000000 | 62.70 | 2.07 | +| 0000001111111 | 63.14 | 2.05 | + + +实验表明,更大的卷积核放在网络的中后部即可达到放在所有位置的精度,与此同时,获得更快的推理速度。PP-LCNet 最终选用了表格中第三行的方案。 + + +### 3.4 GAP 后使用更大的 1x1 卷积层 + +在 GoogLeNet 之后,GAP(Global-Average-Pooling)后往往直接接分类层,但是在轻量级网络中,这样会导致 GAP 后提取的特征没有得到进一步的融合和加工。如果在此后使用一个更大的 1x1 卷积层(等同于 FC 层),GAP 后的特征便不会直接经过分类层,而是先进行了融合,并将融合的特征进行分类。这样可以在不影响模型推理速度的同时大大提升准确率。 +BaseNet 经过以上四个方面的改进,得到了 PP-LCNet。下表进一步说明了每个方案对结果的影响: + +| Activation | SE-block | Large-kernel | last-1x1-conv | Top-1 Acc(\%) | Latency(ms) | +|------------|----------|--------------|---------------|---------------|-------------| +| 0 | 1 | 1 | 1 | 61.93 | 1.94 | +| 1 | 0 | 1 | 1 | 62.51 | 1.87 | +| 1 | 1 | 0 | 1 | 62.44 | 2.01 | +| 1 | 1 | 1 | 0 | 59.91 | 1.85 | +| 1 | 1 | 1 | 1 | 63.14 | 2.05 | + + +## 4. 实验部分 + + +### 4.1 图像分类 + +图像分类我们选用了 ImageNet 数据集,相比目前主流的轻量级网络,PP-LCNet 在相同精度下可以获得更快的推理速度。当使用百度自研的 SSLD 蒸馏策略后,精度进一步提升,在 Intel cpu 端约 5ms 的推理速度下 ImageNet 的 Top-1 Acc 超过了 80%。 + +| Model | Params(M) | FLOPs(M) | Top-1 Acc(\%) | Top-5 Acc(\%) | Latency(ms) | +|-------|-----------|----------|---------------|---------------|-------------| +| PP-LCNet-0.25x | 1.5 | 18 | 51.86 | 75.65 | 1.74 | +| PP-LCNet-0.35x | 1.6 | 29 | 58.09 | 80.83 | 1.92 | +| PP-LCNet-0.5x | 1.9 | 47 | 63.14 | 84.66 | 2.05 | +| PP-LCNet-0.75x | 2.4 | 99 | 68.18 | 88.30 | 2.29 | +| PP-LCNet-1x | 3.0 | 161 | 71.32 | 90.03 | 2.46 | +| PP-LCNet-1.5x | 4.5 | 342 | 73.71 | 91.53 | 3.19 | +| PP-LCNet-2x | 6.5 | 590 | 75.18 | 92.27 | 4.27 | +| PP-LCNet-2.5x | 9.0 | 906 | 76.60 | 93.00 | 5.39 | +| PP-LCNet-0.5x\* | 1.9 | 47 | 66.10 | 86.46 | 2.05 | +| PP-LCNet-1.0x\* | 3.0 | 161 | 74.39 | 92.09 | 2.46 | +| PP-LCNet-2.5x\* | 9.0 | 906 | 80.82 | 95.33 | 5.39 | + +其中\*表示使用 SSLD 蒸馏后的模型。 + +与其他轻量级网络的性能对比: + +| Model | Params(M) | FLOPs(M) | Top-1 Acc(\%) | Top-5 Acc(\%) | Latency(ms) | +|-------|-----------|----------|---------------|---------------|-------------| +| MobileNetV2-0.25x | 1.5 | 34 | 53.21 | 76.52 | 2.47 | +| MobileNetV3-small-0.35x | 1.7 | 15 | 53.03 | 76.37 | 3.02 | +| ShuffleNetV2-0.33x | 0.6 | 24 | 53.73 | 77.05 | 4.30 | +| PP-LCNet-0.25x | 1.5 | 18 | 51.86 | 75.65 | 1.74 | +| MobileNetV2-0.5x | 2.0 | 99 | 65.03 | 85.72 | 2.85 | +| MobileNetV3-large-0.35x | 2.1 | 41 | 64.32 | 85.46 | 3.68 | +| ShuffleNetV2-0.5x | 1.4 | 43 | 60.32 | 82.26 | 4.65 | +| PP-LCNet-0.5x | 1.9 | 47 | 63.14 | 84.66 | 2.05 | +| MobileNetV1-1x | 4.3 | 578 | 70.99 | 89.68 | 3.38 | +| MobileNetV2-1x | 3.5 | 327 | 72.15 | 90.65 | 4.26 | +| MobileNetV3-small-1.25x | 3.6 | 100 | 70.67 | 89.51 | 3.95 | +| PP-LCNet-1x | 3.0 | 161 | 71.32 | 90.03 | 2.46 | + + +### 4.2 目标检测 + +目标检测的方法我们选用了百度自研的 PicoDet,该方法主打轻量级目标检测场景,下表展示了在 COCO 数据集上、backbone 选用 PP-LCNet 与 MobileNetV3 的结果的比较,无论在精度还是速度上,PP-LCNet 的优势都非常明显。 + +| Backbone | mAP(%) | Latency(ms) | +|-------|-----------|----------| +MobileNetV3-large-0.35x | 19.2 | 8.1 | +PP-LCNet-0.5x | 20.3 | 6.0 | +MobileNetV3-large-0.75x | 25.8 | 11.1 | +PP-LCNet-1x | 26.9 | 7.9 | + + +### 4.3 语义分割 + +语义分割的方法我们选用了 DeeplabV3+,下表展示了在 Cityscapes 数据集上、backbone 选用 PP-LCNet 与 MobileNetV3 的比较,在精度和速度方面,PP-LCNet 的优势同样明显。 + +| Backbone | mIoU(%) | Latency(ms) | +|-------|-----------|----------| +|MobileNetV3-large-0.5x | 55.42 | 135 | +|PP-LCNet-0.5x | 58.36 | 82 | +|MobileNetV3-large-0.75x | 64.53 | 151 | +|PP-LCNet-1x | 66.03 | 96 | + + + +## 5. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=1\4
(ms) | FP32
Batch Size=8
(ms) | +| ------------- | --------- | ----------------- | ---------------------------- | -------------------------------- | ------------------------------ | +| PPLCNet_x0_25 | 224 | 256 | 0.72 | 1.17 | 1.71 | +| PPLCNet_x0_35 | 224 | 256 | 0.69 | 1.21 | 1.82 | +| PPLCNet_x0_5 | 224 | 256 | 0.70 | 1.32 | 1.94 | +| PPLCNet_x0_75 | 224 | 256 | 0.71 | 1.49 | 2.19 | +| PPLCNet_x1_0 | 224 | 256 | 0.73 | 1.64 | 2.53 | +| PPLCNet_x1_5 | 224 | 256 | 0.82 | 2.06 | 3.12 | +| PPLCNet_x2_0 | 224 | 256 | 0.94 | 2.58 | 4.08 | + + + +## 6. 基于 SD855 的预测速度 + +| Models | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | +| ------------- | -------------------------------- | --------------------------------- | --------------------------------- | +| PPLCNet_x0_25 | 2.30 | 1.62 | 1.32 | +| PPLCNet_x0_35 | 3.15 | 2.11 | 1.64 | +| PPLCNet_x0_5 | 4.27 | 2.73 | 1.92 | +| PPLCNet_x0_75 | 7.38 | 4.51 | 2.91 | +| PPLCNet_x1_0 | 10.78 | 6.49 | 3.98 | +| PPLCNet_x1_5 | 20.55 | 12.26 | 7.54 | +| PPLCNet_x2_0 | 33.79 | 20.17 | 12.10 | +| PPLCNet_x2_5 | 49.89 | 29.60 | 17.82 | + + + +## 7. 总结 + +PP-LCNet 没有像学术界那样死扣极致的 FLOPs 与 Params,而是着眼于分析如何添加对 Intel CPU 友好的模块来提升模型的性能,这样可以更好的平衡准确率和推理时间,其中的实验结论也很适合其他网络结构设计的研究者,同时也为 NAS 搜索研究者提供了更小的搜索空间和一般结论。最终的 PP-LCNet 在产业界也可以更好的落地和应用。 + + + +## 8. 引用 + +如果你的论文用到了 PP-LCNet 的方法,请添加如下 cite: +``` +@misc{cui2021pplcnet, + title={PP-LCNet: A Lightweight CPU Convolutional Neural Network}, + author={Cheng Cui and Tingquan Gao and Shengyu Wei and Yuning Du and Ruoyu Guo and Shuilong Dong and Bin Lu and Ying Zhou and Xueying Lv and Qiwen Liu and Xiaoguang Hu and Dianhai Yu and Yanjun Ma}, + year={2021}, + eprint={2109.15099}, + archivePrefix={arXiv}, + primaryClass={cs.CV} +} +``` diff --git a/src/PaddleClas/docs/zh_CN/models/PVTV2.md b/src/PaddleClas/docs/zh_CN/models/PVTV2.md new file mode 100644 index 0000000..0819a1d --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/PVTV2.md @@ -0,0 +1,27 @@ +# PVTV2 + +--- + +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) + + + +## 1. 概述 + +PVTV2 是 VisionTransformer 系列模型,该模型基于 PVT(Pyramid Vision Transformer)改进得到,PVT 模型使用 Transformer 结构构建了特征金字塔网络。PVTV2 的主要创新点有:1. 带 overlap 的 Patch embeding;2. 结合卷积神经网络;3. 注意力模块为线性复杂度。[论文地址](https://arxiv.org/pdf/2106.13797.pdf)。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| PVT_V2_B0 | 0.705 | 0.902 | 0.705 | - | 0.53 | 3.7 | +| PVT_V2_B1 | 0.787 | 0.945 | 0.787 | - | 2.0 | 14.0 | +| PVT_V2_B2 | 0.821 | 0.960 | 0.820 | - | 3.9 | 25.4 | +| PVT_V2_B3 | 0.831 | 0.965 | 0.831 | - | 6.7 | 45.2 | +| PVT_V2_B4 | 0.836 | 0.967 | 0.836 | - | 9.8 | 62.6 | +| PVT_V2_B5 | 0.837 | 0.966 | 0.838 | - | 11.4 | 82.0 | +| PVT_V2_B2_Linear | 0.821 | 0.961 | 0.821 | - | 3.8 | 22.6 | diff --git a/src/PaddleClas/docs/zh_CN/models/ReXNet.md b/src/PaddleClas/docs/zh_CN/models/ReXNet.md new file mode 100644 index 0000000..37e93fd --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/ReXNet.md @@ -0,0 +1,40 @@ +# ReXNet 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) + + + +## 1. 概述 + +ReXNet 是 NAVER 集团 ClovaAI 研发中心基于一种网络架构设计新范式而构建的网络。针对现有网络中存在的 `Representational Bottleneck` 问题,作者提出了一组新的设计原则。作者认为传统的网络架构设计范式会产生表达瓶颈,进而影响模型的性能。为研究此问题,作者研究了上万个随机网络生成特征的 `matric rank`,同时进一步研究了网络层中通道配置方案。基于此,作者提出了一组简单而有效的设计原则,以消除表达瓶颈问题。[论文地址](https://arxiv.org/pdf/2007.00992.pdf) + + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1| FLOPS
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|----| +| ReXNet_1_0 | 77.46 | 93.70 | 77.9 | 0.415 | 4.838 | +| ReXNet_1_3 | 79.13 | 94.64 | 79.5 | 0.683 | 7.611 | +| ReXNet_1_5 | 80.06 | 95.12 | 80.3 | 0.900 | 9.791 | +| ReXNet_2_0 | 81.22 | 95.36 | 81.6 | 1.561 | 16.449 | +| ReXNet_3_0 | 82.09 | 96.12 | 82.8 | 3.445 | 34.833 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| ---------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| ReXNet_1_0 | 224 | 256 | 3.08 | 4.15 | 5.49 | +| ReXNet_1_3 | 224 | 256 | 3.54 | 4.87 | 6.54 | +| ReXNet_1_5 | 224 | 256 | 3.68 | 5.31 | 7.38 | +| ReXNet_2_0 | 224 | 256 | 4.30 | 6.54 | 9.19 | +| ReXNet_3_0 | 224 | 256 | 5.74 | 9.49 | 13.62 | + +关于 Inference speed 等信息,敬请期待。 diff --git a/src/PaddleClas/docs/zh_CN/models/RedNet.md b/src/PaddleClas/docs/zh_CN/models/RedNet.md new file mode 100644 index 0000000..2f75060 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/RedNet.md @@ -0,0 +1,35 @@ +# RedNet 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) + + +## 1. 概述 + +在 ResNet 的 Backbone 和 Backbone 的所有 Bottleneck 位置上使用 Involution 替换掉了卷积,但保留了所有的卷积用于通道映射和融合。这些精心重新设计的实体联合起来,形成了一种新的高效 Backbone 网络,称为 RedNet。[论文地址](https://arxiv.org/abs/2103.06255)。 + + +## 2. 精度、FLOPS 和参数量 + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:---------------------:|:----------:|:---------:|:---------:|:---------:| +| RedNet26 | 9.2 | 1.7 | 75.95 | 93.19 | +| RedNet38 | 12.4 | 2.2 | 77.47 | 93.56 | +| RedNet50 | 15.5 | 2.7 | 78.33 | 94.17 | +| RedNet101 | 25.7 | 4.7 | 78.94 | 94.36 | +| RedNet152 | 34.0 | 6.8 | 79.17 | 94.40 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| 模型 | Crop Size | Resize Short Size | time(ms)
bs=1 | time(ms)
bs=4 | time(ms)
bs=8 | +| --------- | --------- | ----------------- | ---------------- | ---------------- | ----------------- | +| RedNet26 | 224 | 256 | 4.45 | 15.16 | 29.03 | +| RedNet38 | 224 | 256 | 6.24 | 21.39 | 41.26 | +| RedNet50 | 224 | 256 | 8.04 | 27.71 | 53.73 | +| RedNet101 | 224 | 256 | 13.07 | 44.12 | 83.28 | +| RedNet152 | 224 | 256 | 18.66 | 63.27 | 119.48 | \ No newline at end of file diff --git a/src/PaddleClas/docs/zh_CN/models/RepVGG.md b/src/PaddleClas/docs/zh_CN/models/RepVGG.md new file mode 100644 index 0000000..1ef9765 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/RepVGG.md @@ -0,0 +1,29 @@ +# RepVGG 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) + + +## 1. 概述 + +RepVGG(Making VGG-style ConvNets Great Again)系列模型是由清华大学(丁贵广团队)、旷视科技(孙剑等人)、港科大和阿伯里斯特威斯大学在 2021 年提出的一个简单但强大的卷积神经网络架构,该架构具有类似于 VGG 的推理时间主体,该主体仅由 3x3 卷积和 ReLU 的堆栈组成,而训练时间模型具有多分支拓扑。训练时间和推理时间架构的这种解耦是通过结构重新参数化(re-parameterization)技术实现的,因此该模型称为 RepVGG。[论文地址](https://arxiv.org/abs/2101.03697)。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1| FLOPS
(G) | +|:--:|:--:|:--:|:--:|:--:| +| RepVGG_A0 | 0.7131 | 0.9016 | 0.7241 | | +| RepVGG_A1 | 0.7380 | 0.9146 | 0.7446 | | +| RepVGG_A2 | 0.7571 | 0.9264 | 0.7648 | | +| RepVGG_B0 | 0.7450 | 0.9213 | 0.7514 | | +| RepVGG_B1 | 0.7773 | 0.9385 | 0.7837 | | +| RepVGG_B2 | 0.7813 | 0.9410 | 0.7878 | | +| RepVGG_B1g2 | 0.7732 | 0.9359 | 0.7778 | | +| RepVGG_B1g4 | 0.7675 | 0.9335 | 0.7758 | | +| RepVGG_B2g4 | 0.7881 | 0.9448 | 0.7938 | | +| RepVGG_B3g4 | 0.7965 | 0.9485 | 0.8021 | | + +关于 Params、FLOPs、Inference speed 等信息,敬请期待。 diff --git a/src/PaddleClas/docs/zh_CN/models/ResNeSt_RegNet.md b/src/PaddleClas/docs/zh_CN/models/ResNeSt_RegNet.md new file mode 100644 index 0000000..967351b --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/ResNeSt_RegNet.md @@ -0,0 +1,46 @@ +# ResNeSt 与 RegNet 系列 +---- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 + +ResNeSt 系列模型是在 2020 年提出的,在原有的 resnet 网络结构上做了改进,通过引入 K 个 Group 和在不同 Group 中加入类似于 SEBlock 的 attention 模块,使得精度相比于基础模型 ResNet 有了大幅度的提高,且参数量和 flops 与基础的 ResNet 基本保持一致。 + +RegNet 是由 facebook 于 2020 年提出,旨在深化设计空间理念的概念,在 AnyNetX 的基础上逐步改进,通过加入共享瓶颈 ratio、共享组宽度、调整网络深度与宽度等策略,最终实现简化设计空间结构、提高设计空间的可解释性、改善设计空间的质量,并保持设计空间的模型多样性的目的。最终设计出的模型在类似的条件下,性能还要优于 EfficientNet,并且在 GPU 上的速度提高了 5 倍。 + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ResNeSt50_fast_1s1x64d | 0.8035 | 0.9528| 0.8035 | -| 8.68 | 26.3 | +| ResNeSt50 | 0.8083 | 0.9542| 0.8113 | -| 10.78 | 27.5 | +| RegNetX_4GF | 0.7850 | 0.9416| 0.7860 | -| 8.0 | 22.1 | + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| ---------------------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| ResNeSt50_fast_1s1x64d | 224 | 256 | 2.73 | 5.33 | 8.24 | +| ResNeSt50 | 224 | 256 | 7.36 | 10.23 | 13.84 | +| RegNetX_4GF | 224 | 256 | 6.46 | 8.48 | 11.45 | + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|--------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| ResNeSt50_fast_1s1x64d | 224 | 256 | 3.46466 | 5.56647 | 9.11848 | 3.45405 | 8.72680 | 15.48710 | +| ResNeSt50 | 224 | 256 | 7.05851 | 8.97676 | 13.34704 | 6.16248 | 12.0633 | 21.49936 | +| RegNetX_4GF | 224 | 256 | 6.69042 | 8.01664 | 11.60608 | 6.46478 | 11.19862 | 16.89089 | diff --git a/src/PaddleClas/docs/zh_CN/models/ResNet_and_vd.md b/src/PaddleClas/docs/zh_CN/models/ResNet_and_vd.md new file mode 100644 index 0000000..3e8e600 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/ResNet_and_vd.md @@ -0,0 +1,108 @@ +# ResNet 及其 Vd 系列 +----- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 + +ResNet 系列模型是在 2015 年提出的,一举在 ILSVRC2015 比赛中取得冠军,top5 错误率为 3.57%。该网络创新性的提出了残差结构,通过堆叠多个残差结构从而构建了 ResNet 网络。实验表明使用残差块可以有效地提升收敛速度和精度。 + +斯坦福大学的 Joyce Xu 将 ResNet 称为「真正重新定义了我们看待神经网络的方式」的三大架构之一。由于 ResNet 卓越的性能,越来越多的来自学术界和工业界学者和工程师对其结构进行了改进,比较出名的有 Wide-ResNet, ResNet-vc,ResNet-vd, Res2Net 等,其中 ResNet-vc 与 ResNet-vd 的参数量和计算量与 ResNet 几乎一致,所以在此我们将其与 ResNet 统一归为 ResNet 系列。 + +本次发布 ResNet 系列的模型包括 ResNet50,ResNet50_vd,ResNet50_vd_ssld,ResNet200_vd 等 14 个预训练模型。在训练层面上,ResNet 的模型采用了训练 ImageNet 的标准训练流程,而其余改进版模型采用了更多的训练策略,如 learning rate 的下降方式采用了 cosine decay,引入了 label smoothing 的标签正则方式,在数据预处理加入了 mixup 的操作,迭代总轮数从 120 个 epoch 增加到 200 个 epoch。 + +其中,ResNet50_vd_v2 与 ResNet50_vd_ssld 采用了知识蒸馏,保证模型结构不变的情况下,进一步提升了模型的精度,具体地,ResNet50_vd_v2 的 teacher 模型是 ResNet152_vd(top1 准确率 80.59%),数据选用的是 ImageNet-1k 的训练集,ResNet50_vd_ssld 的 teacher 模型是 ResNeXt101_32x16d_wsl(top1 准确率 84.2%),数据选用结合了 ImageNet-1k 的训练集和 ImageNet-22k 挖掘的 400 万数据。知识蒸馏的具体方法正在持续更新中。 + +该系列模型的 FLOPS、参数量以及 T4 GPU 上的预测耗时如下图所示。 + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.ResNet.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.ResNet.png) + + +通过上述曲线可以看出,层数越多,准确率越高,但是相应的参数量、计算量和延时都会增加。ResNet50_vd_ssld 通过用更强的 teacher 和更多的数据,将其在 ImageNet-1k 上的验证集 top-1 精度进一步提高,达到了 82.39%,刷新了 ResNet50 系列模型的精度。 + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ResNet18 | 0.710 | 0.899 | 0.696 | 0.891 | 3.660 | 11.690 | +| ResNet18_vd | 0.723 | 0.908 | | | 4.140 | 11.710 | +| ResNet34 | 0.746 | 0.921 | 0.732 | 0.913 | 7.360 | 21.800 | +| ResNet34_vd | 0.760 | 0.930 | | | 7.390 | 21.820 | +| ResNet34_vd_ssld | 0.797 | 0.949 | | | 7.390 | 21.820 | +| ResNet50 | 0.765 | 0.930 | 0.760 | 0.930 | 8.190 | 25.560 | +| ResNet50_vc | 0.784 | 0.940 | | | 8.670 | 25.580 | +| ResNet50_vd | 0.791 | 0.944 | 0.792 | 0.946 | 8.670 | 25.580 | +| ResNet50_vd_v2 | 0.798 | 0.949 | | | 8.670 | 25.580 | +| ResNet101 | 0.776 | 0.936 | 0.776 | 0.938 | 15.520 | 44.550 | +| ResNet101_vd | 0.802 | 0.950 | | | 16.100 | 44.570 | +| ResNet152 | 0.783 | 0.940 | 0.778 | 0.938 | 23.050 | 60.190 | +| ResNet152_vd | 0.806 | 0.953 | | | 23.530 | 60.210 | +| ResNet200_vd | 0.809 | 0.953 | | | 30.530 | 74.740 | +| ResNet50_vd_ssld | 0.824 | 0.961 | | | 8.670 | 25.580 | +| ResNet50_vd_ssld_v2 | 0.830 | 0.964 | | | 8.670 | 25.580 | +| Fix_ResNet50_vd_ssld_v2 | 0.840 | 0.970 | | | 17.696 | 25.580 | +| ResNet101_vd_ssld | 0.837 | 0.967 | | | 16.100 | 44.570 | + +* 注:`ResNet50_vd_ssld_v2` 是在 `ResNet50_vd_ssld` 训练策略的基础上加上 AutoAugment 训练得到,`Fix_ResNet50_vd_ssld_v2` 是固定 `ResNet50_vd_ssld_v2` 除 FC 层外所有的网络参数,在 320x320 的图像输入分辨率下,基于 ImageNet1k 数据集微调得到。 + + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=1\4
(ms) | FP32
Batch Size=8
(ms) | +|------------------|-----------|-------------------|--------------------------|--------------------------|--------------------------| +| ResNet18 | 224 | 256 | 1.22 | 2.19 | 3.63 | +| ResNet18_vd | 224 | 256 | 1.26 | 2.28 | 3.89 | +| ResNet34 | 224 | 256 | 1.97 | 3.25 | 5.70 | +| ResNet34_vd | 224 | 256 | 2.00 | 3.28 | 5.84 | +| ResNet34_vd_ssld | 224 | 256 | 2.00 | 3.26 | 5.85 | +| ResNet50 | 224 | 256 | 2.54 | 4.79 | 7.40 | +| ResNet50_vc | 224 | 256 | 2.57 | 4.83 | 7.52 | +| ResNet50_vd | 224 | 256 | 2.60 | 4.86 | 7.63 | +| ResNet50_vd_v2 | 224 | 256 | 2.59 | 4.86 | 7.59 | +| ResNet101 | 224 | 256 | 4.37 | 8.18 | 12.38 | +| ResNet101_vd | 224 | 256 | 4.43 | 8.25 | 12.60 | +| ResNet152 | 224 | 256 | 6.05 | 11.41 | 17.33 | +| ResNet152_vd | 224 | 256 | 6.11 | 11.51 | 17.59 | +| ResNet200_vd | 224 | 256 | 7.70 | 14.57 | 22.16 | +| ResNet50_vd_ssld | 224 | 256 | 2.59 | 4.87 | 7.62 | +| ResNet101_vd_ssld | 224 | 256 | 4.43 | 8.25 | 12.58 | + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| ResNet18 | 224 | 256 | 1.3568 | 2.5225 | 3.61904 | 1.45606 | 3.56305 | 6.28798 | +| ResNet18_vd | 224 | 256 | 1.39593 | 2.69063 | 3.88267 | 1.54557 | 3.85363 | 6.88121 | +| ResNet34 | 224 | 256 | 2.23092 | 4.10205 | 5.54904 | 2.34957 | 5.89821 | 10.73451 | +| ResNet34_vd | 224 | 256 | 2.23992 | 4.22246 | 5.79534 | 2.43427 | 6.22257 | 11.44906 | +| ResNet34_vd_ssld | 224 | 256 | 2.23992 | 4.22246 | 5.79534 | 2.43427 | 6.22257 | 11.44906 | +| ResNet50 | 224 | 256 | 2.63824 | 4.63802 | 7.02444 | 3.47712 | 7.84421 | 13.90633 | +| ResNet50_vc | 224 | 256 | 2.67064 | 4.72372 | 7.17204 | 3.52346 | 8.10725 | 14.45577 | +| ResNet50_vd | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| ResNet50_vd_v2 | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| ResNet101 | 224 | 256 | 5.04037 | 7.73673 | 10.8936 | 6.07125 | 13.40573 | 24.3597 | +| ResNet101_vd | 224 | 256 | 5.05972 | 7.83685 | 11.34235 | 6.11704 | 13.76222 | 25.11071 | +| ResNet152 | 224 | 256 | 7.28665 | 10.62001 | 14.90317 | 8.50198 | 19.17073 | 35.78384 | +| ResNet152_vd | 224 | 256 | 7.29127 | 10.86137 | 15.32444 | 8.54376 | 19.52157 | 36.64445 | +| ResNet200_vd | 224 | 256 | 9.36026 | 13.5474 | 19.0725 | 10.80619 | 25.01731 | 48.81399 | +| ResNet50_vd_ssld | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| ResNet50_vd_ssld_v2 | 224 | 256 | 2.65164 | 4.84109 | 7.46225 | 3.53131 | 8.09057 | 14.45965 | +| Fix_ResNet50_vd_ssld_v2 | 320 | 320 | 3.42818 | 7.51534 | 13.19370 | 5.07696 | 14.64218 | 27.01453 | +| ResNet101_vd_ssld | 224 | 256 | 5.05972 | 7.83685 | 11.34235 | 6.11704 | 13.76222 | 25.11071 | diff --git a/src/PaddleClas/docs/zh_CN/models/SEResNext_and_Res2Net.md b/src/PaddleClas/docs/zh_CN/models/SEResNext_and_Res2Net.md new file mode 100644 index 0000000..30fac65 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/SEResNext_and_Res2Net.md @@ -0,0 +1,134 @@ +# SEResNeXt 与 Res2Net 系列 + +----- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于 V100 GPU 的预测速度](#3) +* [4. 基于 T4 GPU 的预测速度](#4) + + + +## 1. 概述 +ResNeXt 是 ResNet 的典型变种网络之一,ResNeXt 发表于 2017 年的 CVPR 会议。在此之前,提升模型精度的方法主要集中在将网络变深或者变宽,这样增加了参数量和计算量,推理速度也会相应变慢。ResNeXt 结构提出了通道分组(cardinality)的概念,作者通过实验发现增加通道的组数比增加深度和宽度更有效。其可以在不增加参数复杂度的前提下提高准确率,同时还减少了参数的数量,所以是比较成功的 ResNet 的变种。 + +SENet 是 2017 年 ImageNet 分类比赛的冠军方案,其提出了一个全新的 SE 结构,该结构可以迁移到任何其他网络中,其通过控制 scale 的大小,把每个通道间重要的特征增强,不重要的特征减弱,从而让提取的特征指向性更强。 + +Res2Net 是 2019 年提出的一种全新的对 ResNet 的改进方案,该方案可以和现有其他优秀模块轻松整合,在不增加计算负载量的情况下,在 ImageNet、CIFAR-100 等数据集上的测试性能超过了 ResNet。Res2Net 结构简单,性能优越,进一步探索了 CNN 在更细粒度级别的多尺度表示能力。Res2Net 揭示了一个新的提升模型精度的维度,即 scale,其是除了深度、宽度和基数的现有维度之外另外一个必不可少的更有效的因素。该网络在其他视觉任务如目标检测、图像分割等也有相当不错的表现。 + +该系列模型的 FLOPS、参数量以及 T4 GPU 上的预测耗时如下图所示。 + + +![](../../images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.flops.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.params.png) + +![](../../images/models/T4_benchmark/t4.fp32.bs4.SeResNeXt.png) + +![](../../images/models/T4_benchmark/t4.fp16.bs4.SeResNeXt.png) + + +目前 PaddleClas 开源的这三类的预训练模型一共有 24 个,其指标如图所示,从图中可以看出,在同样 Flops 和 Params 下,改进版的模型往往有更高的精度,但是推理速度往往不如 ResNet 系列。另一方面,Res2Net 表现也较为优秀,相比 ResNeXt 中的 group 操作、SEResNet 中的 SE 结构操作,Res2Net 在相同 Flops、Params 和推理速度下往往精度更佳。 + + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Parameters
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| Res2Net50_26w_4s | 0.793 | 0.946 | 0.780 | 0.936 | 8.520 | 25.700 | +| Res2Net50_vd_26w_4s | 0.798 | 0.949 | | | 8.370 | 25.060 | +| Res2Net50_vd_26w_4s_ssld | 0.831 | 0.966 | | | 8.370 | 25.060 | +| Res2Net50_14w_8s | 0.795 | 0.947 | 0.781 | 0.939 | 9.010 | 25.720 | +| Res2Net101_vd_26w_4s | 0.806 | 0.952 | | | 16.670 | 45.220 | +| Res2Net101_vd_26w_4s_ssld | 0.839 | 0.971 | | | 16.670 | 45.220 | +| Res2Net200_vd_26w_4s | 0.812 | 0.957 | | | 31.490 | 76.210 | +| Res2Net200_vd_26w_4s_ssld | **0.851** | 0.974 | | | 31.490 | 76.210 | +| ResNeXt50_32x4d | 0.778 | 0.938 | 0.778 | | 8.020 | 23.640 | +| ResNeXt50_vd_32x4d | 0.796 | 0.946 | | | 8.500 | 23.660 | +| ResNeXt50_64x4d | 0.784 | 0.941 | | | 15.060 | 42.360 | +| ResNeXt50_vd_64x4d | 0.801 | 0.949 | | | 15.540 | 42.380 | +| ResNeXt101_32x4d | 0.787 | 0.942 | 0.788 | | 15.010 | 41.540 | +| ResNeXt101_vd_32x4d | 0.803 | 0.951 | | | 15.490 | 41.560 | +| ResNeXt101_64x4d | 0.784 | 0.945 | 0.796 | | 29.050 | 78.120 | +| ResNeXt101_vd_64x4d | 0.808 | 0.952 | | | 29.530 | 78.140 | +| ResNeXt152_32x4d | 0.790 | 0.943 | | | 22.010 | 56.280 | +| ResNeXt152_vd_32x4d | 0.807 | 0.952 | | | 22.490 | 56.300 | +| ResNeXt152_64x4d | 0.795 | 0.947 | | | 43.030 | 107.570 | +| ResNeXt152_vd_64x4d | 0.811 | 0.953 | | | 43.520 | 107.590 | +| SE_ResNet18_vd | 0.733 | 0.914 | | | 4.140 | 11.800 | +| SE_ResNet34_vd | 0.765 | 0.932 | | | 7.840 | 21.980 | +| SE_ResNet50_vd | 0.795 | 0.948 | | | 8.670 | 28.090 | +| SE_ResNeXt50_32x4d | 0.784 | 0.940 | 0.789 | 0.945 | 8.020 | 26.160 | +| SE_ResNeXt50_vd_32x4d | 0.802 | 0.949 | | | 10.760 | 26.280 | +| SE_ResNeXt101_32x4d | 0.7939 | 0.9443 | 0.793 | 0.950 | 15.020 | 46.280 | +| SENet154_vd | 0.814 | 0.955 | | | 45.830 | 114.290 | + + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------|-----------|-------------------|-----------------------|-----------------------|-----------------------| +| Res2Net50_26w_4s | 224 | 256 | 3.52 | 6.23 | 9.30 | +| Res2Net50_vd_26w_4s | 224 | 256 | 3.59 | 6.35 | 9.50 | +| Res2Net50_14w_8s | 224 | 256 | 4.39 | 7.21 | 10.38 | +| Res2Net101_vd_26w_4s | 224 | 256 | 6.34 | 11.02 | 16.13 | +| Res2Net200_vd_26w_4s | 224 | 256 | 11.45 | 19.77 | 28.81 | +| ResNeXt50_32x4d | 224 | 256 | 5.07 | 8.49 | 12.02 | +| ResNeXt50_vd_32x4d | 224 | 256 | 5.29 | 8.68 | 12.33 | +| ResNeXt50_64x4d | 224 | 256 | 9.39 | 13.97 | 20.56 | +| ResNeXt50_vd_64x4d | 224 | 256 | 9.75 | 14.14 | 20.84 | +| ResNeXt101_32x4d | 224 | 256 | 11.34 | 16.78 | 22.80 | +| ResNeXt101_vd_32x4d | 224 | 256 | 11.36 | 17.01 | 23.07 | +| ResNeXt101_64x4d | 224 | 256 | 21.57 | 28.08 | 39.49 | +| ResNeXt101_vd_64x4d | 224 | 256 | 21.57 | 28.22 | 39.70 | +| ResNeXt152_32x4d | 224 | 256 | 17.14 | 25.11 | 33.79 | +| ResNeXt152_vd_32x4d | 224 | 256 | 16.99 | 25.29 | 33.85 | +| ResNeXt152_64x4d | 224 | 256 | 33.07 | 42.05 | 59.13 | +| ResNeXt152_vd_64x4d | 224 | 256 | 33.30 | 42.41 | 59.42 | +| SE_ResNet18_vd | 224 | 256 | 1.48 | 2.70 | 4.32 | +| SE_ResNet34_vd | 224 | 256 | 2.42 | 3.69 | 6.29 | +| SE_ResNet50_vd | 224 | 256 | 3.11 | 5.99 | 9.34 | +| SE_ResNeXt50_32x4d | 224 | 256 | 6.39 | 11.01 | 14.94 | +| SE_ResNeXt50_vd_32x4d | 224 | 256 | 7.04 | 11.57 | 16.01 | +| SE_ResNeXt101_32x4d | 224 | 256 | 13.31 | 21.85 | 28.77 | +| SENet154_vd | 224 | 256 | 34.83 | 51.22 | 69.74 | +| Res2Net50_vd_26w_4s_ssld | 224 | 256 | 3.58 | 6.35 | 9.52 | +| Res2Net101_vd_26w_4s_ssld | 224 | 256 | 6.33 | 11.02 | 16.11 | +| Res2Net200_vd_26w_4s_ssld | 224 | 256 | 11.47 | 19.75 | 28.83 | + + + + +## 4. 基于 T4 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +|-----------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| +| Res2Net50_26w_4s | 224 | 256 | 3.56067 | 6.61827 | 11.41566 | 4.47188 | 9.65722 | 17.54535 | +| Res2Net50_vd_26w_4s | 224 | 256 | 3.69221 | 6.94419 | 11.92441 | 4.52712 | 9.93247 | 18.16928 | +| Res2Net50_14w_8s | 224 | 256 | 4.45745 | 7.69847 | 12.30935 | 5.4026 | 10.60273 | 18.01234 | +| Res2Net101_vd_26w_4s | 224 | 256 | 6.53122 | 10.81895 | 18.94395 | 8.08729 | 17.31208 | 31.95762 | +| Res2Net200_vd_26w_4s | 224 | 256 | 11.66671 | 18.93953 | 33.19188 | 14.67806 | 32.35032 | 63.65899 | +| ResNeXt50_32x4d | 224 | 256 | 7.61087 | 8.88918 | 12.99674 | 7.56327 | 10.6134 | 18.46915 | +| ResNeXt50_vd_32x4d | 224 | 256 | 7.69065 | 8.94014 | 13.4088 | 7.62044 | 11.03385 | 19.15339 | +| ResNeXt50_64x4d | 224 | 256 | 13.78688 | 15.84655 | 21.79537 | 13.80962 | 18.4712 | 33.49843 | +| ResNeXt50_vd_64x4d | 224 | 256 | 13.79538 | 15.22201 | 22.27045 | 13.94449 | 18.88759 | 34.28889 | +| ResNeXt101_32x4d | 224 | 256 | 16.59777 | 17.93153 | 21.36541 | 16.21503 | 19.96568 | 33.76831 | +| ResNeXt101_vd_32x4d | 224 | 256 | 16.36909 | 17.45681 | 22.10216 | 16.28103 | 20.25611 | 34.37152 | +| ResNeXt101_64x4d | 224 | 256 | 30.12355 | 32.46823 | 38.41901 | 30.4788 | 36.29801 | 68.85559 | +| ResNeXt101_vd_64x4d | 224 | 256 | 30.34022 | 32.27869 | 38.72523 | 30.40456 | 36.77324 | 69.66021 | +| ResNeXt152_32x4d | 224 | 256 | 25.26417 | 26.57001 | 30.67834 | 24.86299 | 29.36764 | 52.09426 | +| ResNeXt152_vd_32x4d | 224 | 256 | 25.11196 | 26.70515 | 31.72636 | 25.03258 | 30.08987 | 52.64429 | +| ResNeXt152_64x4d | 224 | 256 | 46.58293 | 48.34563 | 56.97961 | 46.7564 | 56.34108 | 106.11736 | +| ResNeXt152_vd_64x4d | 224 | 256 | 47.68447 | 48.91406 | 57.29329 | 47.18638 | 57.16257 | 107.26288 | +| SE_ResNet18_vd | 224 | 256 | 1.61823 | 3.1391 | 4.60282 | 1.7691 | 4.19877 | 7.5331 | +| SE_ResNet34_vd | 224 | 256 | 2.67518 | 5.04694 | 7.18946 | 2.88559 | 7.03291 | 12.73502 | +| SE_ResNet50_vd | 224 | 256 | 3.65394 | 7.568 | 12.52793 | 4.28393 | 10.38846 | 18.33154 | +| SE_ResNeXt50_32x4d | 224 | 256 | 9.06957 | 11.37898 | 18.86282 | 8.74121 | 13.563 | 23.01954 | +| SE_ResNeXt50_vd_32x4d | 224 | 256 | 9.25016 | 11.85045 | 25.57004 | 9.17134 | 14.76192 | 19.914 | +| SE_ResNeXt101_32x4d | 224 | 256 | 19.34455 | 20.6104 | 32.20432 | 18.82604 | 25.31814 | 41.97758 | +| SENet154_vd | 224 | 256 | 49.85733 | 54.37267 | 74.70447 | 53.79794 | 66.31684 | 121.59885 | diff --git a/src/PaddleClas/docs/zh_CN/models/SwinTransformer.md b/src/PaddleClas/docs/zh_CN/models/SwinTransformer.md new file mode 100644 index 0000000..40a8732 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/SwinTransformer.md @@ -0,0 +1,48 @@ +# SwinTransformer +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于V100 GPU 的预测速度](#3) + + + +## 1. 概述 +Swin Transformer 是一种新的视觉 Transformer 网络,可以用作计算机视觉领域的通用骨干网路。SwinTransformer 由移动窗口(shifted windows)表示的层次 Transformer 结构组成。移动窗口将自注意计算限制在非重叠的局部窗口上,同时允许跨窗口连接,从而提高了网络性能。[论文地址](https://arxiv.org/abs/2103.14030)。 + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| SwinTransformer_tiny_patch4_window7_224 | 0.8069 | 0.9534 | 0.812 | 0.955 | 4.5 | 28 | +| SwinTransformer_small_patch4_window7_224 | 0.8275 | 0.9613 | 0.832 | 0.962 | 8.7 | 50 | +| SwinTransformer_base_patch4_window7_224 | 0.8300 | 0.9626 | 0.835 | 0.965 | 15.4 | 88 | +| SwinTransformer_base_patch4_window12_384 | 0.8439 | 0.9693 | 0.845 | 0.970 | 47.1 | 88 | +| SwinTransformer_base_patch4_window7_224[1] | 0.8487 | 0.9746 | 0.852 | 0.975 | 15.4 | 88 | +| SwinTransformer_base_patch4_window12_384[1] | 0.8642 | 0.9807 | 0.864 | 0.980 | 47.1 | 88 | +| SwinTransformer_large_patch4_window7_224[1] | 0.8596 | 0.9783 | 0.863 | 0.979 | 34.5 | 197 | +| SwinTransformer_large_patch4_window12_384[1] | 0.8719 | 0.9823 | 0.873 | 0.982 | 103.9 | 197 | + +[1]:基于 ImageNet22k 数据集预训练,然后在 ImageNet1k 数据集迁移学习得到。 + +**注**:与 Reference 的精度差异源于数据预处理不同。 + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| ------------------------------------------------------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| SwinTransformer_tiny_patch4_window7_224 | 224 | 256 | 6.59 | 9.68 | 16.32 | +| SwinTransformer_small_patch4_window7_224 | 224 | 256 | 12.54 | 17.07 | 28.08 | +| SwinTransformer_base_patch4_window7_224 | 224 | 256 | 13.37 | 23.53 | 39.11 | +| SwinTransformer_base_patch4_window12_384 | 384 | 384 | 19.52 | 64.56 | 123.30 | +| SwinTransformer_base_patch4_window7_224[1] | 224 | 256 | 13.53 | 23.46 | 39.13 | +| SwinTransformer_base_patch4_window12_384[1] | 384 | 384 | 19.65 | 64.72 | 123.42 | +| SwinTransformer_large_patch4_window7_224[1] | 224 | 256 | 15.74 | 38.57 | 71.49 | +| SwinTransformer_large_patch4_window12_384[1] | 384 | 384 | 32.61 | 116.59 | 223.23 | + +[1]:基于 ImageNet22k 数据集预训练,然后在 ImageNet1k 数据集迁移学习得到。 diff --git a/src/PaddleClas/docs/zh_CN/models/TNT.md b/src/PaddleClas/docs/zh_CN/models/TNT.md new file mode 100644 index 0000000..bf5181a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/TNT.md @@ -0,0 +1,20 @@ +# TNT 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) + + + +## 1. 概述 + +TNT(Transformer-iN-Transformer)系列模型由华为诺亚于 2021 年提出,用于对 patch 级别和 pixel 级别的表示进行建模。在每个 TNT 块中,outer transformer block 用于处理 patch 嵌入,inner transformer block 从 pixel 嵌入中提取局部特征。通过线性变换层将 pixel 级特征投影到 patch 嵌入空间,然后加入到 patch 中。通过对 TNT 块的叠加,建立了用于图像识别的 TNT 模型。在 ImageNet 基准测试和下游任务上的实验证明了该 TNT 体系结构的优越性和有效性。例如,在计算量相当的情况下 TNT 能在 ImageNet 上达到 81.3% 的 top-1 精度,比 DeiT 高 1.5%。[论文地址](https://arxiv.org/abs/2103.00112)。 + + + +## 2. 精度、FLOPS 和参数量 + +| Model | Params (M) | FLOPs (G) | Top-1 (%) | Top-5 (%) | +|:---------------------:|:----------:|:---------:|:---------:|:---------:| +| TNT_small | 23.8 | 5.2 | 81.21 | 95.63 | diff --git a/src/PaddleClas/docs/zh_CN/models/Twins.md b/src/PaddleClas/docs/zh_CN/models/Twins.md new file mode 100644 index 0000000..623ebf8 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/Twins.md @@ -0,0 +1,40 @@ +# Twins +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于V100 GPU 的预测速度](#3) + + + +## 1. 概述 +Twins 网络包括 Twins-PCPVT 和 Twins-SVT,其重点对空间注意力机制进行了精心设计,得到了简单却更为有效的方案。由于该体系结构仅涉及矩阵乘法,而目前的深度学习框架中对矩阵乘法有较高的优化程度,因此该体系结构十分高效且易于实现。并且,该体系结构在图像分类、目标检测和语义分割等多种下游视觉任务中都能够取得优异的性能。[论文地址](https://arxiv.org/abs/2104.13840)。 + + + +## 2. 精度、FLOPs 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPs
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| pcpvt_small | 0.8082 | 0.9552 | 0.812 | - | 3.7 | 24.1 | +| pcpvt_base | 0.8242 | 0.9619 | 0.827 | - | 6.4 | 43.8 | +| pcpvt_large | 0.8273 | 0.9650 | 0.831 | - | 9.5 | 60.9 | +| alt_gvt_small | 0.8140 | 0.9546 | 0.817 | - | 2.8 | 24 | +| alt_gvt_base | 0.8294 | 0.9621 | 0.832 | - | 8.3 | 56 | +| alt_gvt_large | 0.8331 | 0.9642 | 0.837 | - | 14.8 | 99.2 | + +**注**:与 Reference 的精度差异源于数据预处理不同。 + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| ------------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| pcpvt_small | 224 | 256 | 7.32 | 10.51 | 15.27 | +| pcpvt_base | 224 | 256 | 12.20 | 16.22 | 23.16 | +| pcpvt_large | 224 | 256 | 16.47 | 22.90 | 32.73 | +| alt_gvt_small | 224 | 256 | 6.94 | 9.01 | 12.27 | +| alt_gvt_base | 224 | 256 | 9.37 | 15.02 | 24.54 | +| alt_gvt_large | 224 | 256 | 11.76 | 22.08 | 35.12 | diff --git a/src/PaddleClas/docs/zh_CN/models/ViT_and_DeiT.md b/src/PaddleClas/docs/zh_CN/models/ViT_and_DeiT.md new file mode 100644 index 0000000..51df939 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/ViT_and_DeiT.md @@ -0,0 +1,70 @@ +# ViT 与 DeiT 系列 +--- +## 目录 + +* [1. 概述](#1) +* [2. 精度、FLOPS 和参数量](#2) +* [3. 基于V100 GPU 的预测速度](#3) + + + +## 1. 概述 + +ViT(Vision Transformer)系列模型是 Google 在 2020 年提出的,该模型仅使用标准的 Transformer 结构,完全抛弃了卷积结构,将图像拆分为多个 patch 后再输入到 Transformer 中,展示了 Transformer 在 CV 领域的潜力。[论文地址](https://arxiv.org/abs/2010.11929)。 + +DeiT(Data-efficient Image Transformers)系列模型是由 FaceBook 在 2020 年底提出的,针对 ViT 模型需要大规模数据集训练的问题进行了改进,最终在 ImageNet 上取得了 83.1%的 Top1 精度。并且使用卷积模型作为教师模型,针对该模型进行知识蒸馏,在 ImageNet 数据集上可以达到 85.2% 的 Top1 精度。[论文地址](https://arxiv.org/abs/2012.12877)。 + + + + +## 2. 精度、FLOPS 和参数量 + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ViT_small_patch16_224 | 0.7769 | 0.9342 | 0.7785 | 0.9342 | 9.41 | 48.60 | +| ViT_base_patch16_224 | 0.8195 | 0.9617 | 0.8178 | 0.9613 | 16.85 | 86.42 | +| ViT_base_patch16_384 | 0.8414 | 0.9717 | 0.8420 | 0.9722 | 49.35 | 86.42 | +| ViT_base_patch32_384 | 0.8176 | 0.9613 | 0.8166 | 0.9613 | 12.66 | 88.19 | +| ViT_large_patch16_224 | 0.8323 | 0.9650 | 0.8306 | 0.9644 | 59.65 | 304.12 | +| ViT_large_patch16_384 | 0.8513 | 0.9736 | 0.8517 | 0.9736 | 174.70 | 304.12 | +| ViT_large_patch32_384 | 0.8153 | 0.9608 | 0.815 | - | 44.24 | 306.48 | + + +| Models | Top1 | Top5 | Reference
top1 | Reference
top5 | FLOPS
(G) | Params
(M) | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| DeiT_tiny_patch16_224 | 0.718 | 0.910 | 0.722 | 0.911 | 1.07 | 5.68 | +| DeiT_small_patch16_224 | 0.796 | 0.949 | 0.799 | 0.950 | 4.24 | 21.97 | +| DeiT_base_patch16_224 | 0.817 | 0.957 | 0.818 | 0.956 | 16.85 | 86.42 | +| DeiT_base_patch16_384 | 0.830 | 0.962 | 0.829 | 0.972 | 49.35 | 86.42 | +| DeiT_tiny_distilled_patch16_224 | 0.741 | 0.918 | 0.745 | 0.919 | 1.08 | 5.87 | +| DeiT_small_distilled_patch16_224 | 0.809 | 0.953 | 0.812 | 0.954 | 4.26 | 22.36 | +| DeiT_base_distilled_patch16_224 | 0.831 | 0.964 | 0.834 | 0.965 | 16.93 | 87.18 | +| DeiT_base_distilled_patch16_384 | 0.851 | 0.973 | 0.852 | 0.972 | 49.43 | 87.18 | + +关于 Params、FLOPs、Inference speed 等信息,敬请期待。 + + + +## 3. 基于 V100 GPU 的预测速度 + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| -------------------------- | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| ViT_small_
patch16_224 | 256 | 224 | 3.71 | 9.05 | 16.72 | +| ViT_base_
patch16_224 | 256 | 224 | 6.12 | 14.84 | 28.51 | +| ViT_base_
patch16_384 | 384 | 384 | 14.15 | 48.38 | 95.06 | +| ViT_base_
patch32_384 | 384 | 384 | 4.94 | 13.43 | 24.08 | +| ViT_large_
patch16_224 | 256 | 224 | 15.53 | 49.50 | 94.09 | +| ViT_large_
patch16_384 | 384 | 384 | 39.51 | 152.46 | 304.06 | +| ViT_large_
patch32_384 | 384 | 384 | 11.44 | 36.09 | 70.63 | + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | +| ------------------------------------ | --------- | ----------------- | ------------------------------ | ------------------------------ | ------------------------------ | +| DeiT_tiny_
patch16_224 | 256 | 224 | 3.61 | 3.94 | 6.10 | +| DeiT_small_
patch16_224 | 256 | 224 | 3.61 | 6.24 | 10.49 | +| DeiT_base_
patch16_224 | 256 | 224 | 6.13 | 14.87 | 28.50 | +| DeiT_base_
patch16_384 | 384 | 384 | 14.12 | 48.80 | 97.60 | +| DeiT_tiny_
distilled_patch16_224 | 256 | 224 | 3.51 | 4.05 | 6.03 | +| DeiT_small_
distilled_patch16_224 | 256 | 224 | 3.70 | 6.20 | 10.53 | +| DeiT_base_
distilled_patch16_224 | 256 | 224 | 6.17 | 14.94 | 28.58 | +| DeiT_base_
distilled_patch16_384 | 384 | 384 | 14.12 | 48.76 | 97.09 | + diff --git a/src/PaddleClas/docs/zh_CN/models/index.rst b/src/PaddleClas/docs/zh_CN/models/index.rst new file mode 100644 index 0000000..7873e3a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models/index.rst @@ -0,0 +1,29 @@ +模型库 +================================ + +.. toctree:: + :maxdepth: 2 + + DPN_DenseNet.md + models_intro.md + RepVGG.md + EfficientNet_and_ResNeXt101_wsl.md + ViT_and_DeiT.md + SwinTransformer.md + Others.md + SEResNext_and_Res2Net.md + ESNet.md + HRNet.md + ReXNet.md + Inception.md + TNT.md + RedNet.md + DLA.md + ResNeSt_RegNet.md + PP-LCNet.md + HarDNet.md + ResNet_and_vd.md + LeViT.md + Mobile.md + MixNet.md + Twins.md diff --git a/src/PaddleClas/docs/zh_CN/models_training/classification.md b/src/PaddleClas/docs/zh_CN/models_training/classification.md new file mode 100644 index 0000000..dd95015 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models_training/classification.md @@ -0,0 +1,345 @@ +# 图像分类 +--- +图像分类是根据图像的语义信息将不同类别图像区分开来,是计算机视觉中重要的基本问题,也是图像检测、图像分割、物体跟踪、行为分析等其他高层视觉任务的基础。图像分类在很多领域有广泛应用,包括安防领域的人脸识别和智能视频分析等,交通领域的交通场景识别,互联网领域基于内容的图像检索和相册自动归类,医学领域的图像识别等。 + +一般来说,图像分类通过手工特征或特征学习方法对整个图像进行全部描述,然后使用分类器判别物体类别,因此如何提取图像的特征至关重要。在深度学习算法之前使用较多的是基于词袋(Bag of Words)模型的物体分类方法。而基于深度学习的图像分类方法,可以通过有监督或无监督的方式学习层次化的特征描述,从而取代了手工设计或选择图像特征的工作。深度学习模型中的卷积神经网络(Convolution Neural Network, CNN)近年来在图像领域取得了惊人的成绩,CNN 直接利用图像像素信息作为输入,最大程度上保留了输入图像的所有信息,通过卷积操作进行特征的提取和高层抽象,模型输出直接是图像识别的结果。这种基于“输入-输出”直接端到端的学习方法取得了非常好的效果,得到了广泛的应用。 + +图像分类是计算机视觉里很基础但又重要的一个领域,其研究成果一直影响着计算机视觉甚至深度学习的发展,图像分类有很多子领域,如多标签分类、细粒度分类等,此处只对单标签图像分类做一个简述。 + +具体图像分类算法介绍详见[文档](../algorithm_introduction/image_classification.md)。 + +## 目录 + +- [1. 数据集介绍](#1) + - [1.1 ImageNet-1k](#1.1) + - [1.2 CIFAR-10/CIFAR-100](#1.2) +- [2. 图像分类的流程](#2) + - [2.1 数据及其预处理](#2.1) + - [2.2 模型准备](#2.2) + - [2.3 模型训练](#2.3) + - [2.4 模型评估](#2.4) +- [3. 使用方法介绍](#3) + - [3.1 基于 CPU /单卡 GPU 上的训练与评估](#3.1) + - [3.1.1 模型训练](#3.1.1) + - [3.1.2 模型微调](#3.1.2) + - [3.1.3 模型恢复训练](#3.1.3) + - [3.1.4 模型评估](#3.1.4) + - [3.2 基于 Linux + 多卡 GPU 的模型训练与评估](#3.2) + - [3.2.1 模型训练](#3.2.1) + - [3.2.2 模型微调](#3.2.2) + - [3.2.3 模型恢复训练](#3.2.3) + - [3.2.4 模型评估](#3.2.4) + - [3.3 使用预训练模型进行模型预测](#3.3) + - [3.4 使用 inference 模型进行模型推理](#3.4) + + + +## 1. 数据集介绍 + + +### 1.1 ImageNet-1k + +ImageNet 项目是一个大型视觉数据库,用于视觉目标识别软件研究。该项目已手动注释了 1400 多万张图像,以指出图片中的对象,并在至少 100 万张图像中提供了边框。ImageNet-1k 是 ImageNet 数据集的子集,其包含 1000 个类别。训练集包含 1281167 个图像数据,验证集包含 50000 个图像数据。2010 年以来,ImageNet 项目每年举办一次图像分类竞赛,即 ImageNet 大规模视觉识别挑战赛(ILSVRC)。挑战赛使用的数据集即为 ImageNet-1k。到目前为止,ImageNet-1k 已经成为计算机视觉领域发展的最重要的数据集之一,其促进了整个计算机视觉的发展,很多计算机视觉下游任务的初始化模型都是基于该数据集训练得到的权重。 + + +### 1.2 CIFAR-10/CIFAR-100 + +CIFAR-10 数据集由 10 个类的 60000 个彩色图像组成,图像分辨率为 32x32,每个类有 6000 个图像,其中训练集 5000 张,验证集 1000 张,10 个不同的类代表飞机、汽车、鸟类、猫、鹿、狗、青蛙、马、轮船和卡车。CIFAR-100 数据集是 CIFAR-10 的扩展,由 100 个类的 60000 个彩色图像组成,图像分辨率为 32x32,每个类有 600 个图像,其中训练集 500 张,验证集 100 张。由于这两个数据集规模较小,因此可以让研究人员快速尝试不同的算法。这两个数据集也是图像分类领域测试模型好坏的常用数据集。 + + +## 2. 图像分类的流程 + +将准备好的训练数据做相应的数据预处理后经过图像分类模型,模型的输出与真实标签做交叉熵损失函数,该损失函数描述了模型的收敛方向,遍历所有的图片数据输入模型,对最终损失函数通过某些优化器做相应的梯度下降,将梯度信息回传到模型中,更新模型的权重,如此循环往复遍历多次数据,即可得到一个图像分类的模型。 + + +### 2.1 数据及其预处理 + +数据的质量及数量往往可以决定一个模型的好坏。在图像分类领域,数据包括图像及标签。在大部分情形下,带有标签的数据比较匮乏,所以数量很难达到使模型饱和的程度,为了可以使模型学习更多的图像特征,图像数据在进入模型之前要经过很多图像变换或者数据增强,来保证输入图像数据的多样性,从而保证模型有更好的泛化能力。PaddleClas 提供了训练 ImageNet-1k 的标准图像变换,也提供了多种数据增强的方法,相关代码可以查看[数据处理](../../../ppcls/data/preprocess),配置文件可以参考[数据增强配置文件](../../../ppcls/configs/ImageNet/DataAugment),相关数据增强算法详见[增强介绍文档](../algorithm_introduction/DataAugmentation.md)。 + + + +### 2.2 模型准备 + +在数据确定后,模型往往决定了最终算法精度的上限,在图像分类领域,经典的模型层出不穷,PaddleClas 提供了 35 个系列共 164 个 ImageNet 预训练模型。具体的精度、速度等指标请参考[骨干网络和预训练模型库](../algorithm_introduction/ImageNet_models.md)。 + + +### 2.3 模型训练 + +在准备好数据、模型后,便可以开始迭代模型并更新模型的参数。经过多次迭代最终可以得到训练好的模型来做图像分类任务。图像分类的训练过程需要很多经验,涉及很多超参数的设置,PaddleClas 提供了一些列的[训练调优方法](./train_strategy.md),可以快速助你获得高精度的模型。 + +同时,PaddleClas 还支持使用VisualDL 可视化训练过程。VisualDL 是飞桨可视化分析工具,以丰富的图表呈现训练参数变化趋势、模型结构、数据样本、高维数据分布等。可帮助用户更清晰直观地理解深度学习模型训练过程及模型结构,进而实现高效的模型优化。更多细节请查看[VisualDL](../others/VisualDL.md)。 + + +### 2.4 模型评估 + +当训练得到一个模型之后,如何确定模型的好坏,需要将模型在验证集上进行评估。评估指标一般是 Top1-Acc 或者 Top5-Acc,该指标越高往往代表模型性能越好。 + + +## 3. 使用方法介绍 + +请参考[安装指南](../installation/install_paddleclas.md)配置运行环境,并根据[快速开始](../quick_start/quick_start_classification_new_user.md)文档准备 flower102 数据集,本章节下面所有的实验均以 flower102 数据集为例。 + +PaddleClas 目前支持的训练/评估环境如下: +```shell +└── CPU/单卡 GPU +    ├── Linux +    └── Windows + +└── 多卡 GPU + └── Linux +``` + + +### 3.1 基于 CPU/单卡 GPU 上的训练与评估 + +在基于 CPU/单卡 GPU 上训练与评估,推荐使用 `tools/train.py` 与 `tools/eval.py` 脚本。关于 Linux 平台多卡 GPU 环境下的训练与评估,请参考 [3.2. 基于 Linux+GPU 的模型训练与评估](#3.2)。 + + + +#### 3.1.1 模型训练 + +准备好配置文件之后,可以使用下面的方式启动训练。 + +``` +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Arch.pretrained=False \ + -o Global.device=gpu +``` + +其中,`-c` 用于指定配置文件的路径,`-o` 用于指定需要修改或者添加的参数,其中 `-o Arch.pretrained=False` 表示不使用预训练模型,`-o Global.device=gpu` 表示使用 GPU 进行训练。如果希望使用 CPU 进行训练,则需要将 `Global.device` 设置为 `cpu`。 + +更详细的训练配置,也可以直接修改模型对应的配置文件。具体配置参数参考[配置文档](config_description.md)。 + +运行上述命令,可以看到输出日志,示例如下: + +* 如果在训练中使用了 mixup 或者 cutmix 的数据增广方式,那么日志中将不会打印 top-1 与 top-k(默认为 5)信息: + ``` + ... + [Train][Epoch 3/20][Avg]CELoss: 6.46287, loss: 6.46287 + ... + [Eval][Epoch 3][Avg]CELoss: 5.94309, loss: 5.94309, top1: 0.01961, top5: 0.07941 + ... + ``` + +* 如果训练过程中没有使用 mixup 或者 cutmix 的数据增广,那么除了上述信息外,日志中也会打印出 top-1 与 top-k(默认为 5)的信息: + + ``` + ... + [Train][Epoch 3/20][Avg]CELoss: 6.12570, loss: 6.12570, top1: 0.01765, top5: 0.06961 + ... + [Eval][Epoch 3][Avg]CELoss: 5.40727, loss: 5.40727, top1: 0.07549, top5: 0.20980 + ... + ``` + +训练期间也可以通过 VisualDL 实时观察 loss 变化,详见 [VisualDL](../others/VisualDL.md)。 + + +#### 3.1.2 模型微调 + +根据自己的数据集路径设置好配置文件后,可以通过加载预训练模型的方式进行微调,如下所示。 + +``` +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Arch.pretrained=True \ + -o Global.device=gpu +``` + +其中 `Arch.pretrained` 设置为 `True` 表示加载 ImageNet 的预训练模型,此外,`Arch.pretrained` 也可以指定具体的模型权重文件的地址,使用时需要换成自己的预训练模型权重文件的路径。 + +我们也提供了大量基于 `ImageNet-1k` 数据集的预训练模型,模型列表及下载地址详见[模型库概览](../algorithm_introduction/ImageNet_models.md)。 + + + +#### 3.1.3 模型恢复训练 + +如果训练任务因为其他原因被终止,也可以加载断点权重文件,继续训练: + +``` +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.checkpoints="./output/MobileNetV3_large_x1_0/epoch_5" \ + -o Global.device=gpu +``` + +其中配置文件不需要做任何修改,只需要在继续训练时设置 `Global.checkpoints` 参数即可,表示加载的断点权重文件路径,使用该参数会同时加载保存的断点权重和学习率、优化器等信息。 + +**注意**: + +* `-o Global.checkpoints` 参数无需包含断点权重文件的后缀名,上述训练命令会在训练过程中生成如下所示的断点权重文件,若想从断点 `5` 继续训练,则 `Global.checkpoints` 参数只需设置为 `"../output/MobileNetV3_large_x1_0/epoch_5"`,PaddleClas 会自动补充后缀名。output 目录下的文件结构如下所示: + + ```shell + output + ├── MobileNetV3_large_x1_0 + │   ├── best_model.pdopt + │   ├── best_model.pdparams + │   ├── best_model.pdstates + │   ├── epoch_1.pdopt + │   ├── epoch_1.pdparams + │   ├── epoch_1.pdstates + . + . + . + ``` + + + +#### 3.1.4 模型评估 + +可以通过以下命令进行模型评估。 + +```bash +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.pretrained_model=./output/MobileNetV3_large_x1_0/best_model +``` + +上述命令将使用 `./configs/quick_start/MobileNetV3_large_x1_0.yaml` 作为配置文件,对上述训练得到的模型 `./output/MobileNetV3_large_x1_0/best_model` 进行评估。你也可以通过更改配置文件中的参数来设置评估,也可以通过 `-o` 参数更新配置,如上所示。 + +可配置的部分评估参数说明如下: +* `Arch.name`:模型名称 +* `Global.pretrained_model`:待评估的模型预训练模型文件路径 + +**注意:** 在加载待评估模型时,需要指定模型文件的路径,但无需包含文件后缀名,PaddleClas 会自动补齐 `.pdparams` 的后缀,如 [3.1.3 模型恢复训练](#3.1.3)。 + + + +### 3.2 基于 Linux + 多卡 GPU 的模型训练与评估 + +如果机器环境为 Linux + GPU,那么推荐使用 `paddle.distributed.launch` 启动模型训练脚本(`tools/train.py`)、评估脚本(`tools/eval.py`),可以更方便地启动多卡训练与评估。 + + + +#### 3.2.1 模型训练 + +参考如下方式启动模型训练,`paddle.distributed.launch` 通过设置 `gpus` 指定 GPU 运行卡号: + +```bash +# PaddleClas 通过 launch 方式启动多卡多进程训练 + +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml +``` + +输出日志信息的格式同上,详见 [3.1.1 模型训练](#3.1.1)。 + + +#### 3.2.2 模型微调 + +根据自己的数据集配置好配置文件之后,可以加载预训练模型进行微调,如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Arch.pretrained=True +``` + +其中 `Arch.pretrained` 为 `True` 或 `False`,当然也可以设置加载预训练权重文件的路径,使用时需要换成自己的预训练模型权重文件路径,也可以直接在配置文件中修改该路径。 + +30 分钟玩转 PaddleClas [尝鲜版](../quick_start/quick_start_classification_new_user.md)与[进阶版](../quick_start/quick_start_classification_professional.md)中包含大量模型微调的示例,可以参考该章节在特定的数据集上进行模型微调。 + + + +#### 3.2.3 模型恢复训练 + +如果训练任务因为其他原因被终止,也可以加载断点权重文件继续训练。 + +``` +export CUDA_VISIBLE_DEVICES=0,1,2,3 + +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.checkpoints="./output/MobileNetV3_large_x1_0/epoch_5" \ + -o Global.device=gpu +``` + +其中配置文件不需要做任何修改,只需要在训练时设置 `Global.checkpoints` 参数即可,该参数表示加载的断点权重文件路径,使用该参数会同时加载保存的模型参数权重和学习率、优化器等信息,详见 [3.1.3 模型恢复训练](#3.1.3)。 + + + +#### 3.2.4 模型评估 + +可以通过以下命令进行模型评估。 + +```bash +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.pretrained_model=./output/MobileNetV3_large_x1_0/best_model +``` + +参数说明详见 [3.1.4 模型评估](#3.1.4)。 + + + +### 3.3 使用预训练模型进行模型预测 + +模型训练完成之后,可以加载训练得到的预训练模型,进行模型预测。在模型库的 `tools/infer/infer.py` 中提供了完整的示例,只需执行下述命令即可完成模型预测: + +```python +python3 tools/infer.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Infer.infer_imgs=dataset/flowers102/jpg/image_00001.jpg \ + -o Global.pretrained_model=./output/MobileNetV3_large_x1_0/best_model +``` + +参数说明: ++ `Infer.infer_imgs`:待预测的图片文件路径或者批量预测时的图片文件夹。 ++ `Global.pretrained_model`:模型权重文件路径,如 `./output/MobileNetV3_large_x1_0/best_model` + + + +### 3.4 使用 inference 模型进行模型推理 + +通过导出 inference 模型,PaddlePaddle 支持使用预测引擎进行预测推理。接下来介绍如何用预测引擎进行推理: +首先,对训练好的模型进行转换: + +```bash +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o Global.pretrained_model=output/MobileNetV3_large_x1_0/best_model +``` + + +其中,`Global.pretrained_model` 用于指定模型文件路径,该路径仍无需包含模型文件后缀名(如 [3.1.3 模型恢复训练](#3.1.3))。 + +上述命令将生成模型结构文件(`inference.pdmodel`)和模型权重文件(`inference.pdiparams`),然后可以使用预测引擎进行推理: + +进入 deploy 目录下: + +```bash +cd deploy +``` + +执行命令进行预测,由于默认 `class_id_map_file` 是 ImageNet 数据集的映射文件,所以此处需要置 None。 + +```bash +python3 python/predict_cls.py \ + -c configs/inference_cls.yaml \ + -o Global.infer_imgs=../dataset/flowers102/jpg/image_00001.jpg \ + -o Global.inference_model_dir=../inference/ \ + -o PostProcess.Topk.class_id_map_file=None + +``` +其中: ++ `Global.infer_imgs`:待预测的图片文件路径。 ++ `Global.inference_model_dir`:inference 模型结构文件路径,如 `../inference/inference.pdmodel` ++ `Global.use_tensorrt`:是否使用 TesorRT 预测引擎,默认值:`False` ++ `Global.use_gpu`:是否使用 GPU 预测,默认值:`True` ++ `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 评测时,建议开启 MKLDNN 加速预测。 diff --git a/src/PaddleClas/docs/zh_CN/models_training/config_description.md b/src/PaddleClas/docs/zh_CN/models_training/config_description.md new file mode 100644 index 0000000..8c51d7a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models_training/config_description.md @@ -0,0 +1,273 @@ +# 配置说明 + +--- + +## 简介 + +本文档介绍了 PaddleClas 配置文件(`ppcls/configs/*.yaml`)中各参数的含义,以便您更快地自定义或修改超参数配置。 + + + +## 配置详解 + +### 目录 + +- [1. 分类模型](#1) + - [1.1 全局配置(Global)](#1.1) + - [1.2 结构(Arch)](#1.2) + - [1.3 损失函数(Loss)](#1.3) + - [1.4 优化器(Optimizer)](#1.4) + - [1.5 数据读取模块(DataLoader)](#1.5) + - [1.5.1 dataset](#1.5.1) + - [1.5.2 sampler](#1.5.2) + - [1.5.3 loader](#1.5.3) + - [1.6 评估指标(Metric)](#1.6) + - [1.7 预测](#1.7) +- [2. 蒸馏模型](#2) + - [2.1 结构(Arch)](#2.1) + - [2.2 损失函数(Loss)](#2.2) + - [2.3 评估指标(Metric)](#2.3) +- [3. 识别模型](#3) + - [3.1 结构(Arch)](#3.1) + - [3.2 评估指标(Metric)](#3.2) + + + +### 1.分类模型 + +此处以 `ResNet50_vd` 在 `ImageNet-1k` 上的训练配置为例,详解各个参数的意义。[配置路径](../../../ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml)。 + + +#### 1.1 全局配置(Global) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| checkpoints | 断点模型路径,用于恢复训练 | null | str | +| pretrained_model | 预训练模型路径 | null | str | +| output_dir | 保存模型路径 | "./output/" | str | +| save_interval | 每隔多少个 epoch 保存模型 | 1 | int | +| eval_during_train| 是否在训练时进行评估 | True | bool | +| eval_interval | 每隔多少个 epoch 进行模型评估 | 1 | int | +| epochs | 训练总 epoch 数 | | int | +| print_batch_step | 每隔多少个 mini-batch 打印输出 | 10 | int | +| use_visualdl | 是否是用 visualdl 可视化训练过程 | False | bool | +| image_shape | 图片大小 | [3, 224, 224] | list, shape: (3,) | +| save_inference_dir | inference 模型的保存路径 | "./inference" | str | +| eval_mode | eval 的模式 | "classification" | "retrieval" | +| to_static | 是否改为静态图模式 | False | True | +| ues_dali | 是否使用 dali 库进行图像预处理 | False | True | + +**注**:`pretrained_model` 也可以填写存放预训练模型的 http 地址。 + + +#### 1.2 结构(Arch) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| name | 模型结构名字 | ResNet50 | PaddleClas 提供的模型结构 | +| class_num | 分类数 | 1000 | int | +| pretrained | 预训练模型 | False | bool, str | + +**注**:此处的 pretrained 可以设置为 `True` 或者 `False`,也可以设置权重的路径。另外当 `Global.pretrained_model` 也设置相应路径时,此处的 `pretrained` 失效。 + + +#### 1.3 损失函数(Loss) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| CELoss | 交叉熵损失函数 | —— | —— | +| CELoss.weight | CELoss 在整个 Loss 中的权重 | 1.0 | float | +| CELoss.epsilon | CELoss 中 label_smooth 的 epsilon 值 | 0.1 | float, 0-1 之间 | + + +#### 1.4 优化器(Optimizer) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| name | 优化器方法名 | "Momentum" | "RmsProp"等其他优化器 | +| momentum | momentum 值 | 0.9 | float | +| lr.name | 学习率下降方式 | "Cosine" | "Linear"、"Piecewise"等其他下降方式 | +| lr.learning_rate | 学习率初始值 | 0.1 | float | +| lr.warmup_epoch | warmup 轮数 | 0 | int,如 5 | +| regularizer.name | 正则化方法名 | "L2" | ["L1", "L2"] | +| regularizer.coeff | 正则化系数 | 0.00007 | float | + +**注**:`lr.name` 不同时,新增的参数可能也不同,如当 `lr.name=Piecewise` 时,需要添加如下参数: + +``` + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] +``` + +添加方法及参数请查看 [learning_rate.py](../../../ppcls/optimizer/learning_rate.py)。 + + +#### 1.5 数据读取模块(DataLoader) + + +##### 1.5.1 dataset + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| name | 读取数据的类的名字 | ImageNetDataset | VeriWild 等其他读取数据类的名字 | +| image_root | 数据集存放的路径 | ./dataset/ILSVRC2012/ | str | +| cls_label_path | 数据集标签 list | ./dataset/ILSVRC2012/train_list.txt | str | +| transform_ops | 单张图片的数据预处理 | —— | —— | +| batch_transform_ops | batch 图片的数据预处理 | —— | —— | + + +transform_ops 中参数的意义: + +| 功能名字 | 参数名字 | 具体含义 | +|:---:|:---:|:---:| +| DecodeImage | to_rgb | 数据转 RGB | +| | channel_first | 按 CHW 排列的图片数据 | +| RandCropImage | size | 随机裁剪 | +| RandFlipImage | | 随机翻转 | +| NormalizeImage | scale | 归一化 scale 值 | +| | mean | 归一化均值 | +| | std | 归一化方差 | +| | order | 归一化顺序 | +| CropImage | size | 裁剪大小 | +| ResizeImage | resize_short | 按短边调整大小 | + +batch_transform_ops 中参数的含义: + +| 功能名字 | 参数名字 | 具体含义 | +|:---:|:---:|:---:| +| MixupOperator | alpha | Mixup 参数值,该值越大增强越强 | + + +##### 1.5.2 sampler + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| name | sampler 类型 | DistributedBatchSampler | DistributedRandomIdentitySampler 等其他 Sampler | +| batch_size | 批大小 | 64 | int | +| drop_last | 是否丢掉最后不够 batch-size 的数据 | False | bool | +| shuffle | 数据是否做 shuffle | True | bool | + + +##### 1.5.3 loader + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| num_workers | 数据读取线程数 | 4 | int | +| use_shared_memory | 是否使用共享内存 | True | bool | + + +#### 1.6 评估指标(Metric) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| TopkAcc | TopkAcc | [1, 5] | list, int | + + +#### 1.7 预测(Infer) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| infer_imgs | 被 infer 的图像的地址 | docs/images/whl/demo.jpg | str | +| batch_size | 批大小 | 10 | int | +| PostProcess.name | 后处理名字 | Topk | str | +| PostProcess.topk | topk 的值 | 5 | int | +| PostProcess.class_id_map_file | class id 和名字的映射文件 | ppcls/utils/imagenet1k_label_list.txt | str | + +**注**:Infer 模块的 `transforms` 的解释参考数据读取模块中的 dataset 中 `transform_ops` 的解释。 + + +### 2.蒸馏模型 + +**注**:此处以 `MobileNetV3_large_x1_0` 在 `ImageNet-1k` 上蒸馏 `MobileNetV3_small_x1_0` 的训练配置为例,详解各个参数的意义。[配置路径](../../../ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml)。这里只介绍与分类模型有区别的参数。 + + +#### 2.1 结构(Arch) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| name | 模型结构名字 | DistillationModel | —— | +| class_num | 分类数 | 1000 | int | +| freeze_params_list | 冻结参数列表 | [True, False] | list | +| models | 模型列表 | [Teacher, Student] | list | +| Teacher.name | 教师模型的名字 | MobileNetV3_large_x1_0 | PaddleClas 中的模型 | +| Teacher.pretrained | 教师模型预训练权重 | True | 布尔值或者预训练权重路径 | +| Teacher.use_ssld | 教师模型预训练权重是否是 ssld 权重 | True | 布尔值 | +| infer_model_name | 被 infer 模型的类型 | Student | Teacher | + +**注**: + +1.list 在 yaml 中体现如下: + +``` + freeze_params_list: + - True + - False +``` +2.Student 的参数情况类似,不再赘述。 + + +#### 2.2 损失函数(Loss) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| DistillationCELoss | 蒸馏的交叉熵损失函数 | —— | —— | +| DistillationCELoss.weight | Loss 权重 | 1.0 | float | +| DistillationCELoss.model_name_pairs | ["Student", "Teacher"] | —— | —— | +| DistillationGTCELoss.weight | 蒸馏的模型与真实 Label 的交叉熵损失函数 | —— | —— | +| DistillationGTCELos.weight | Loss 权重 | 1.0 | float | +| DistillationCELoss.model_names | 与真实 label 作交叉熵的模型名字 | ["Student"] | —— | + + +#### 2.3 评估指标(Metric) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| DistillationTopkAcc | DistillationTopkAcc | 包含 model_key 和 topk 两个参数 | —— | +| DistillationTopkAcc.model_key | 被评估的模型 | "Student" | "Teacher" | +| DistillationTopkAcc.topk | Topk 的值 | [1, 5] | list, int | + +**注**:`DistillationTopkAcc` 与普通 `TopkAcc` 含义相同,只是只用在蒸馏任务中。 + + +### 3. 识别模型 + +**注**:此处以 `ResNet50` 在 `LogoDet-3k` 上的训练配置为例,详解各个参数的意义。[配置路径](../../../ppcls/configs/Logo/ResNet50_ReID.yaml)。这里只介绍与分类模型有区别的参数。 + + +#### 3.1 结构(Arch) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +| :---------------: | :-----------------------: | :--------: | :----------------------------------------------------------: | +| name | 模型结构 | "RecModel" | ["RecModel"] | +| infer_output_key | inference 时的输出值 | “feature” | ["feature", "logits"] | +| infer_add_softmax | infercne 是否添加 softmax | False | [True, False] | +| Backbone.name | Backbone 的名字 | ResNet50_last_stage_stride1 | PaddleClas 提供的其他 backbone | +| Backbone.pretrained | Backbone 预训练模型 | True | 布尔值或者预训练模型路径 | +| BackboneStopLayer.name | Backbone 中的输出层名字 | True | Backbone 中的特征输出层的 `full_name` | +| Neck.name | 网络 Neck 部分名字 | VehicleNeck | 需传入字典结构,Neck 网络层的具体输入参数 | +| Neck.in_channels | 输入 Neck 部分的维度大小 | 2048 | 与 BackboneStopLayer.name 层的大小相同 | +| Neck.out_channels | 输出 Neck 部分的维度大小,即特征维度大小 | 512 | int | +| Head.name | 网络 Head 部分名字 | CircleMargin | Arcmargin 等 | +| Head.embedding_size | 特征维度大小 | 512 | 与 Neck.out_channels 保持一致 | +| Head.class_num | 类别数 | 3000 | int | +| Head.margin | CircleMargin 中的 margin 值 | 0.35 | float | +| Head.scale | CircleMargin 中的 scale 值 | 64 | int | + +**注**: + +1.在 PaddleClas 中,`Neck` 部分是 Backbone 与 embedding 层的连接部分,`Head` 部分是 embedding 层与分类层的连接部分。 + +2.`BackboneStopLayer.name` 的获取方式可以通过将模型可视化后获取,可视化方式可以参考 [Netron](https://github.com/lutzroeder/netron) 或者 [visualdl](https://github.com/PaddlePaddle/VisualDL)。 + +3.调用 `tools/export_model.py` 会将模型的权重转为 inference model,其中 `infer_add_softmax` 参数会控制是否在其后增加 `Softmax` 激活函数,代码中默认为 `True`(分类任务中最后的输出层会接 `Softmax` 激活函数),识别任务中特征层无须接激活函数,此处要设置为 `False`。 + + +#### 3.2 评估指标(Metric) + +| 参数名字 | 具体含义 | 默认值 | 可选值 | +|:---:|:---:|:---:|:---:| +| Recallk| 召回率 | [1, 5] | list, int | +| mAP| 平均检索精度 | None | None | diff --git a/src/PaddleClas/docs/zh_CN/models_training/index.rst b/src/PaddleClas/docs/zh_CN/models_training/index.rst new file mode 100644 index 0000000..41ea472 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models_training/index.rst @@ -0,0 +1,10 @@ +模型训练 +================================ + +.. toctree:: + :maxdepth: 2 + + config_description.md + classification.md + recognition.md + train_strategy.md diff --git a/src/PaddleClas/docs/zh_CN/models_training/recognition.md b/src/PaddleClas/docs/zh_CN/models_training/recognition.md new file mode 100644 index 0000000..6f044d5 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models_training/recognition.md @@ -0,0 +1,337 @@ +# 图像识别 +--- +在 PaddleClas 中,图像识别,是指给定一张查询图像,系统能够识别该查询图像类别。广义上,图像分类也是图像识别的一种。但是与普通图像识别不同的是,图像分类只能判别出模型已经学习的类别,如果需要添加新的类别,分类模型只能重新训练。PaddleClas 中的图像识别,**对于陌生类别,只需要更新相应的检索库**,就能够正确的识别出查询图像的类别,而无需重新训练模型,这大大增加了识别系统的可用性,同时降低了更新模型的需求,方便用户部署应用。 + +对于一张待查询图片,PaddleClas 中的图像识别流程主要分为三部分: + +1. 主体检测:对于给定一个查询图像,主体检测器首先检测出图像的物体,从而去掉无用背景信息,提高识别精度。 +2. 特征提取:对主体检测的各个候选区域,通过特征模型,进行特征提取 +3. 特征检索:将提取的特征与特征库中的向量进行相似度比对,得到其标签信息 + +其中特征库,需要利用已经标注好的图像数据集提前建立。完整的图像识别系统,如下图所示 + +![](../../images/structure.jpg) +体验整体图像识别系统,或查看特征库建立方法,详见[图像识别快速开始文档](../quick_start/quick_start_recognition.md)。其中,图像识别快速开始文档主要讲解整体流程的使用过程。以下内容,主要对上述三个步骤的训练部分进行介绍。 + +首先,请参考[安装指南](../installation/install_paddleclas.md)配置运行环境。 + +## 目录 + +- [1. 主体检测](#1) +- [2. 特征模型训练](#2) + - [2.1. 特征模型数据准备与处理](#2.1) + - [2. 2 特征模型基于单卡 GPU 上的训练与评估](#2.2) + - [2.2.1 特征模型训练](#2.2.2) + - [2.2.2 特征模型恢复训练](#2.2.2) + - [2.2.3 特征模型评估](#2.2.3) + - [2.3 特征模型导出 inference 模型](#2.3) +- [3. 特征检索](#3) +- [4. 基础知识](#4) + + + +## 1. 主体检测 + +主体检测训练过程基于 [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/tree/develop),唯一的区别在于,主体检测任务中,所有的检测框均属于前景,在这里需要将标注文件中,检测框的 `category_id` 修改为 1,同时将整个标注文件中的 `categories` 映射表修改为下面的格式,即整个类别映射表中只包含 `前景` 类别。 + +```json +[{u'id': 1, u'name': u'foreground', u'supercategory': u'foreground'}] +``` + +关于主体检测训练方法可以参考: [PaddleDetection 训练教程](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md#4-%E8%AE%AD%E7%BB%83)。 + +更多关于 PaddleClas 中提供的主体检测的模型介绍与下载请参考:[主体检测教程](../image_recognition_pipeline/mainbody_detection.md)。 + + + +## 2. 特征模型训练 + + + +### 2.1 特征模型数据的准备与处理 + +* 进入 `PaddleClas` 目录。 + +```bash +## linux or mac, $path_to_PaddleClas 表示 PaddleClas 的根目录,用户需要根据自己的真实目录修改 +cd $path_to_PaddleClas +``` + +* 进入 `dataset` 目录,为了快速体验 PaddleClas 图像检索模块,此处使用的数据集为 [CUB_200_2011](http://vision.ucsd.edu/sites/default/files/WelinderEtal10_CUB-200.pdf),其是一个包含 200 类鸟的细粒度鸟类数据集。首先,下载 CUB_200_2011 数据集,下载方式请参考[官网](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html)。 + +```shell +# linux or mac +cd dataset + +# 将下载后的数据拷贝到此目录 +cp {数据存放的路径}/CUB_200_2011.tgz . + +# 解压 +tar -xzvf CUB_200_2011.tgz + +#进入 CUB_200_2011 目录 +cd CUB_200_2011 +``` + +该数据集在用作图像检索任务时,通常将前 100 类当做训练集,后 100 类当做测试集,所以此处需要将下载的数据集做一些后处理,来更好的适应 PaddleClas 的图像检索训练。 + +```shell +#新建 train 和 test 目录 +mkdir train && mkdir test + +#将数据分成训练集和测试集,前 100 类作为训练集,后 100 类作为测试集 +ls images | awk -F "." '{if(int($1)<101)print "mv images/"$0" train/"int($1)}' | sh +ls images | awk -F "." '{if(int($1)>100)print "mv images/"$0" test/"int($1)}' | sh + +#生成 train_list 和 test_list +tree -r -i -f train | grep jpg | awk -F "/" '{print $0" "int($2) " "NR}' > train_list.txt +tree -r -i -f test | grep jpg | awk -F "/" '{print $0" "int($2) " "NR}' > test_list.txt +``` + +至此,现在已经得到 `CUB_200_2011` 的训练集(`train` 目录)、测试集(`test` 目录)、`train_list.txt`、`test_list.txt`。 + +数据处理完毕后,`CUB_200_2011` 中的 `train` 目录下应有如下结构: + +``` +├── 1 +│ ├── Black_Footed_Albatross_0001_796111.jpg +│ ├── Black_Footed_Albatross_0002_55.jpg + ... +├── 10 +│ ├── Red_Winged_Blackbird_0001_3695.jpg +│ ├── Red_Winged_Blackbird_0005_5636.jpg +... +``` + +`train_list.txt` 应为: + +``` +train/99/Ovenbird_0137_92639.jpg 99 1 +train/99/Ovenbird_0136_92859.jpg 99 2 +train/99/Ovenbird_0135_93168.jpg 99 3 +train/99/Ovenbird_0131_92559.jpg 99 4 +train/99/Ovenbird_0130_92452.jpg 99 5 +... +``` +其中,分隔符为空格" ", 三列数据的含义分别是训练数据的路径、训练数据的 label 信息、训练数据的 unique id。 + +测试集格式与训练集格式相同。 + +**注意**: + +* 当 gallery dataset 和 query dataset 相同时,为了去掉检索得到的第一个数据(检索图片本身无须评估),每个数据需要对应一个 unique id,用于后续评测 mAP、recall@1 等指标。关于 gallery dataset 与 query dataset 的解析请参考[图像检索数据集介绍](#图像检索数据集介绍), 关于 mAP、recall@1 等评测指标请参考[图像检索评价指标](#图像检索评价指标)。 + +返回 `PaddleClas` 根目录 + +```shell +# linux or mac +cd ../../ +``` + + + +### 2.2 特征模型 GPU 上的训练与评估 + +在基于单卡 GPU 上训练与评估,推荐使用 `tools/train.py` 与 `tools/eval.py` 脚本。 + +PaddleClas 支持使用 VisualDL 可视化训练过程。VisualDL 是飞桨可视化分析工具,以丰富的图表呈现训练参数变化趋势、模型结构、数据样本、高维数据分布等。可帮助用户更清晰直观地理解深度学习模型训练过程及模型结构,进而实现高效的模型优化。更多细节请查看[VisualDL](../others/VisualDL.md)。 + + + +#### 2.2.1 特征模型训练 + +准备好配置文件之后,可以使用下面的方式启动图像检索任务的训练。PaddleClas 训练图像检索任务的方法是度量学习,关于度量学习的解析请参考[度量学习](#度量学习)。 + +```shell +# 单卡 GPU +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Arch.Backbone.pretrained=True \ + -o Global.device=gpu +# 多卡 GPU +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Arch.Backbone.pretrained=True \ + -o Global.device=gpu +``` + +其中,`-c` 用于指定配置文件的路径,`-o` 用于指定需要修改或者添加的参数,其中 `-o Arch.Backbone.pretrained=True` 表示 Backbone 部分使用预训练模型,此外,`Arch.Backbone.pretrained` 也可以指定具体的模型权重文件的地址,使用时需要换成自己的预训练模型权重文件的路径。`-o Global.device=gpu` 表示使用 GPU 进行训练。如果希望使用 CPU 进行训练,则需要将 `Global.device` 设置为 `cpu`。 + +更详细的训练配置,也可以直接修改模型对应的配置文件。具体配置参数参考[配置文档](config_description.md)。 + +运行上述命令,可以看到输出日志,示例如下: + + ``` + ... + [Train][Epoch 1/50][Avg]CELoss: 6.59110, TripletLossV2: 0.54044, loss: 7.13154 + ... + [Eval][Epoch 1][Avg]recall1: 0.46962, recall5: 0.75608, mAP: 0.21238 + ... + ``` +此处配置文件的 Backbone 是 MobileNetV1,如果想使用其他 Backbone,可以重写参数 `Arch.Backbone.name`,比如命令中增加 `-o Arch.Backbone.name={其他 Backbone}`。此外,由于不同模型 `Neck` 部分的输入维度不同,更换 Backbone 后可能需要改写此处的输入大小,改写方式类似替换 Backbone 的名字。 + +在训练 Loss 部分,此处使用了 [CELoss](../../../ppcls/loss/celoss.py) 和 [TripletLossV2](../../../ppcls/loss/triplet.py),配置文件如下: + +``` +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 +``` + +最终的总 Loss 是所有 Loss 的加权和,其中 weight 定义了特定 Loss 在最终总 Loss 的权重。如果想替换其他 Loss,也可以在配置文件中更改 Loss 字段,目前支持的 Loss 请参考 [Loss](../../../ppcls/loss)。 + + + +#### 2.2.2 特征模型恢复训练 + +如果训练任务因为其他原因被终止,也可以加载断点权重文件,继续训练: + +```shell +# 单卡 +python3 tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.checkpoints="./output/RecModel/epoch_5" \ + -o Global.device=gpu +# 多卡 +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch tools/train.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.checkpoints="./output/RecModel/epoch_5" \ + -o Global.device=gpu +``` + +其中配置文件不需要做任何修改,只需要在继续训练时设置 `Global.checkpoints` 参数即可,表示加载的断点权重文件路径,使用该参数会同时加载保存的断点权重和学习率、优化器等信息。 + +**注意**: + +* `-o Global.checkpoints` 参数无需包含断点权重文件的后缀名,上述训练命令会在训练过程中生成如下所示的断点权重文件,若想从断点 `5` 继续训练,则 `Global.checkpoints` 参数只需设置为 `"./output/RecModel/epoch_5"`,PaddleClas 会自动补充后缀名。 + + ```shell + output/ + └── RecModel + ├── best_model.pdopt + ├── best_model.pdparams + ├── best_model.pdstates + ├── epoch_1.pdopt + ├── epoch_1.pdparams + ├── epoch_1.pdstates + . + . + . + ``` + + + +#### 2.2.3 特征模型评估 + +可以通过以下命令进行模型评估。 + +```bash +# 单卡 +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.pretrained_model=./output/RecModel/best_model +# 多卡 +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch tools/eval.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.pretrained_model=./output/RecModel/best_model +``` + +上述命令将使用 `./configs/quick_start/MobileNetV1_retrieval.yaml` 作为配置文件,对上述训练得到的模型 `./output/RecModel/best_model` 进行评估。你也可以通过更改配置文件中的参数来设置评估,也可以通过 `-o` 参数更新配置,如上所示。 + +可配置的部分评估参数说明如下: +* `Arch.name`:模型名称 +* `Global.pretrained_model`:待评估的模型的预训练模型文件路径,不同于 `Global.Backbone.pretrained`,此处的预训练模型是整个模型的权重,而 `Global.Backbone.pretrained` 只是 Backbone 部分的权重。当需要做模型评估时,需要加载整个模型的权重。 +* `Metric.Eval`:待评估的指标,默认评估 recall@1、recall@5、mAP。当你不准备评测某一项指标时,可以将对应的试标从配置文件中删除;当你想增加某一项评测指标时,也可以参考 [Metric](../../../ppcls/metric/metrics.py) 部分在配置文件 `Metric.Eval` 中添加相关的指标。 + +**注意:** + +* 在加载待评估模型时,需要指定模型文件的路径,但无需包含文件后缀名,PaddleClas 会自动补齐 `.pdparams` 的后缀,如 [2.2.2 特征模型恢复训练](#2.2.2)。 + +* Metric learning 任务一般不评测 TopkAcc。 + + + +### 2.3 特征模型导出 inference 模型 + +通过导出 inference 模型,PaddlePaddle 支持使用预测引擎进行预测推理。对训练好的模型进行转换: + +```bash +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/MobileNetV1_retrieval.yaml \ + -o Global.pretrained_model=output/RecModel/best_model \ + -o Global.save_inference_dir=./inference +``` + +其中,`Global.pretrained_model` 用于指定模型文件路径,该路径仍无需包含模型文件后缀名(如[2.2.2 特征模型恢复训练](#2.2.2))。当执行后,会在当前目录下生成 `./inference` 目录,目录下包含 `inference.pdiparams`、`inference.pdiparams.info`、`inference.pdmodel` 文件。`Global.save_inference_dir` 可以指定导出 inference 模型的路径。此处保存的 inference 模型在 embedding 特征层做了截断,即模型最终的输出为 n 维 embedding 特征。 + +上述命令将生成模型结构文件(`inference.pdmodel`)和模型权重文件(`inference.pdiparams`),然后可以使用预测引擎进行推理。使用 inference 模型推理的流程可以参考[基于 Python 预测引擎预测推理](../inference_deployment/python_deploy.md)。 + + + +## 3. 特征检索 + +PaddleClas 图像检索部分目前支持的环境如下: + +```shell +└── CPU/单卡 GPU + ├── Linux + ├── MacOS + └── Windows +``` + +此部分使用了 [Faiss](https://github.com/facebookresearch/faiss) 作为检索库,其是一个高效的特征检索及聚类的库。此库中集成了多种相似度检索算法,以满足不同的检索场景。在 PaddleClas 中,支持三种检索算法: + +- **HNSW32**: 一种图索引方法。检索精度较高,速度较快。但是特征库只支持添加图像功能,不支持删除图像特征功能。(默认方法) +- **IVF**:倒排索引检索方法。速度较快,但是精度略低。特征库支持增加、删除图像特功能。 +- **FLAT**: 暴力检索算法。精度最高,但是数据量大时,检索速度较慢。特征库支持增加、删除图像特征功能。 + +详细介绍请参考 [Faiss](https://github.com/facebookresearch/faiss) 官方文档。 + +具体安装方法如下: + +```python +pip install faiss-cpu==1.7.1post2 +``` + +若使用时,不能正常引用,则 `uninstall` 之后,重新 `install`,尤其是 `windows` 下。 + + + +## 4. 基础知识 + +图像检索指的是给定一个包含特定实例(例如特定目标、场景、物品等)的查询图像,图像检索旨在从数据库图像中找到包含相同实例的图像。不同于图像分类,图像检索解决的是一个开集问题,训练集中可能不包含被识别的图像的类别。图像检索的整体流程为:首先将图像中表示为一个合适的特征向量,其次,对这些图像的特征向量用欧式距离或余弦距离进行最近邻搜索以找到底库中相似的图像,最后,可以使用一些后处理技术对检索结果进行微调,确定被识别图像的类别等信息。所以,决定一个图像检索算法性能的关键在于图像对应的特征向量的好坏。 + + +- 度量学习(Metric Learning) + +度量学习研究如何在一个特定的任务上学习一个距离函数,使得该距离函数能够帮助基于近邻的算法(kNN、k-means 等)取得较好的性能。深度度量学习(Deep Metric Learning)是度量学习的一种方法,它的目标是学习一个从原始特征到低维稠密的向量空间(嵌入空间,embedding space)的映射,使得同类对象在嵌入空间上使用常用的距离函数(欧氏距离、cosine 距离等)计算的距离比较近,而不同类的对象之间的距离则比较远。深度度量学习在计算机视觉领域取得了非常多的成功的应用,比如人脸识别、商品识别、图像检索、行人重识别等。更详细的介绍请参考[此文档](../algorithm_introduction/metric_learning.md)。 + + + +- 图像检索数据集介绍 + + - 训练集合(train dataset):用来训练模型,使模型能够学习该集合的图像特征。 + - 底库数据集合(gallery dataset):用来提供图像检索任务中的底库数据,该集合可与训练集或测试集相同,也可以不同,当与训练集相同时,测试集的类别体系应与训练集的类别体系相同。 + - 测试集合(query dataset):用来测试模型的好坏,通常要对测试集的每一张测试图片进行特征提取,之后和底库数据的特征进行距离匹配,得到识别结果,后根据识别结果计算整个测试集的指标。 + + +- 图像检索评价指标 + + + - 召回率(recall):表示预测为正例且标签为正例的个数 / 标签为正例的个数 + + - recall@1:检索的 top-1 中预测正例且标签为正例的个数 / 标签为正例的个数 + - recall@5:检索的 top-5 中所有预测正例且标签为正例的个数 / 标签为正例的个数 + + + - 平均检索精度(mAP) + + - AP: AP 指的是不同召回率上的正确率的平均值 + - mAP: 测试集中所有图片对应的 AP 的平均值 diff --git a/src/PaddleClas/docs/zh_CN/models_training/train_strategy.md b/src/PaddleClas/docs/zh_CN/models_training/train_strategy.md new file mode 100644 index 0000000..db5cf1d --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/models_training/train_strategy.md @@ -0,0 +1,137 @@ +# 训练技巧 + +## 目录 + +- [1. 优化器的选择](#1) +- [2. 学习率以及学习率下降策略的选择](#2) + - [2.1 学习率的概念](#2.1) + - [2.2 学习率下降策略](#2.2) + - [2.3 warmup 策略](#2.3) +- [3. batch_size 的选择](#3) +- [4. weight_decay 的选择](#4) +- [5. label_smoothing 的选择](#5) +- [6.针对小模型更改图片的 crop 面积与拉伸变换程度](#6) +- [7.使用数据增广方式提升精度](#7) +- [8. 通过 train_acc 和 test_acc 确定调优策略](#8) +- [9.通过已有的预训练模型提升自己的数据集的精度](#9) + + + +## 1.优化器的选择 +自深度学习发展以来,就有很多关于优化器的研究者工作,优化器的目的是为了让损失函数尽可能的小,从而找到合适的参数来完成某项任务。目前业界主要用到的优化器有 SGD、RMSProp、Adam、AdaDelt 等,其中由于带 momentum 的 SGD 优化器广泛应用于学术界和工业界,所以我们发布的模型也大都使用该优化器来实现损失函数的梯度下降。带 momentum 的 SGD 优化器有两个劣势,其一是收敛速度慢,其二是初始学习率的设置需要依靠大量的经验,然而如果初始学习率设置得当并且迭代轮数充足,该优化器也会在众多的优化器中脱颖而出,使得其在验证集上获得更高的准确率。一些自适应学习率的优化器如 Adam、RMSProp 等,收敛速度往往比较快,但是最终的收敛精度会稍差一些。如果追求更快的收敛速度,我们推荐使用这些自适应学习率的优化器,如果追求更高的收敛精度,我们推荐使用带 momentum 的 SGD 优化器。 + + + +## 2.学习率以及学习率下降策略的选择 +学习率的选择往往和优化器以及数据和任务有关系。这里主要介绍以 momentum+SGD 作为优化器训练 ImageNet-1k 的学习率以及学习率下降的选择。 + + + +### 2.1 学习率的概念: +学习率是通过损失函数的梯度调整网络权重的超参数的速度。学习率越低,损失函数的变化速度就越慢。虽然使用低学习率可以确保不会错过任何局部极小值,但也意味着将花费更长的时间来进行收敛,特别是在被困在高原区域的情况下。 + + + +### 2.2 学习率下降策略: +在整个训练过程中,我们不能使用同样的学习率来更新权重,否则无法到达最优点,所以需要在训练过程中调整学习率的大小。在训练初始阶段,由于权重处于随机初始化的状态,损失函数相对容易进行梯度下降,所以可以设置一个较大的学习率。在训练后期,由于权重参数已经接近最优值,较大的学习率无法进一步寻找最优值,所以需要设置一个较小的学习率。在训练整个过程中,很多研究者使用的学习率下降方式是 piecewise_decay,即阶梯式下降学习率,如在 ResNet50 标准的训练中,我们设置的初始学习率是 0.1,每 30 epoch 学习率下降到原来的 1/10,一共迭代 120 epoch。除了 piecewise_decay,很多研究者也提出了学习率的其他下降方式,如 polynomial_decay(多项式下降)、exponential_decay(指数下降)、cosine_decay(余弦下降)等,其中 cosine_decay 无需调整超参数,鲁棒性也比较高,所以成为现在提高模型精度首选的学习率下降方式。Cosine_decay 和 piecewise_decay 的学习率变化曲线如下图所示,容易观察到,在整个训练过程中,cosine_decay 都保持着较大的学习率,所以其收敛较为缓慢,但是最终的收敛效果较 peicewise_decay 更好一些。 + +![](../../images/models/lr_decay.jpeg) + +另外,从图中我们也可以看到,cosine_decay 里学习率小的轮数较少,这样会影响到最终的精度,所以为了使得 cosine_decay 发挥更好的效果,建议迭代更多的轮数,如 200 轮。 + + + +### 2.3 warmup 策略 +如果使用较大的 batch_size 训练神经网络时,我们建议您使用 warmup 策略。Warmup 策略顾名思义就是让学习率先预热一下,在训练初期我们不直接使用最大的学习率,而是用一个逐渐增大的学习率去训练网络,当学习率增大到最高点时,再使用学习率下降策略中提到的学习率下降方式衰减学习率的值。实验表明,在 batch_size 较大时,warmup 可以稳定提升模型的精度。在训练 MobileNetV3 等 batch_size 较大的实验中,我们默认将 warmup 中的 epoch 设置为 5,即先用 5 epoch 将学习率从 0 增加到最大值,再去做相应的学习率衰减。 + + + +## 3.batch_size 的选择 +batch_size 是训练神经网络中的一个重要的超参数,该值决定了一次将多少数据送入神经网络参与训练。在论文[1]中,作者通过实验发现,当 batch_size 的值与学习率的值呈线性关系时,收敛精度几乎不受影响。在训练 ImageNet 数据时,大部分的神经网络选择的初始学习率为 0.1,batch_size 是 256,所以根据实际的模型大小和显存情况,可以将学习率设置为 0.1\*k, batch_size 设置为 256\*k。 + + + +## 4.weight_decay 的选择 +过拟合是机器学习中常见的一个名词,简单理解即为模型在训练数据上表现很好,但在测试数据上表现较差,在卷积神经网络中,同样存在过拟合的问题,为了避免过拟合,很多正则方式被提出,其中,weight_decay 是其中一个广泛使用的避免过拟合的方式。Weight_decay 等价于在最终的损失函数后添加 L2 正则化,L2 正则化使得网络的权重倾向于选择更小的值,最终整个网络中的参数值更趋向于 0,模型的泛化性能相应提高。在各大深度学习框架的实现中,该值表达的含义是 L2 正则前的系数,在 paddle 框架中,该值的名称是 l2_decay,所以以下都称其为 l2_decay。该系数越大,表示加入的正则越强,模型越趋于欠拟合状态。在训练 ImageNet 的任务中,大多数的网络将该参数值设置为 1e-4,在一些小的网络如 MobileNet 系列网络中,为了避免网络欠拟合,该值设置为 1e-5~4e-5 之间。当然,该值的设置也和具体的数据集有关系,当任务的数据集较大时,网络本身趋向于欠拟合状态,可以将该值适当减小,当任务的数据集较小时,网络本身趋向于过拟合状态,可以将该值适当增大。下表展示了 MobileNetV1_x0_25 在 ImageNet-1k 上使用不同 l2_decay 的精度情况。由于 MobileNetV1_x0_25 是一个比较小的网络,所以 l2_decay 过大会使网络趋向于欠拟合状态,所以在该网络中,相对 1e-4, 3e-5 是更好的选择。 + +| 模型 | L2_decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV1_x0_25 | 1e-4 | 43.79%/67.61% | 50.41%/74.70% | +| MobileNetV1_x0_25 | 3e-5 | 47.38%/70.83% | 51.45%/75.45% | + +另外,该值的设置也和训练过程中是否使用其他正则化有关系。如果训练过程中的数据预处理比较复杂,相当于训练任务变的更难,可以将该值适当减小,下表展示了在 ImageNet-1k 上, ResNet50 在使用 randaugment 预处理方式后使用不同 l2_decay 的精度。容易观察到,在任务变难后,使用更小的 l2_decay 有助于模型精度的提升。 + +| 模型 | L2_decay | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| ResNet50 | 1e-4 | 75.13%/90.42% | 77.65%/93.79% | +| ResNet50 | 7e-5 | 75.56%/90.55% | 78.04%/93.74% | + +综上所述,l2_decay 可以根据具体的任务和模型去做相应的调整,通常简单的任务或者较大的模型,推荐使用较大的 l2_decay,复杂的任务或者较小的模型,推荐使用较小的 l2_decay。 + + + +## 5.label_smoothing 的选择 +Label_smoothing 是深度学习中的一种正则化方法,其全称是 Label Smoothing Regularization(LSR),即标签平滑正则化。在传统的分类任务计算损失函数时,是将真实的 one hot 标签与神经网络的输出做相应的交叉熵计算,而 label_smoothing 是将真实的 one hot 标签做一个标签平滑的处理,使得网络学习的标签不再是一个 hard label,而是一个有概率值的 soft label,其中在类别对应的位置的概率最大,其他位置概率是一个非常小的数。具体的计算方式参见论文[2]。在 label_smoothing 里,有一个 epsilon 的参数值,该值描述了将标签软化的程度,该值越大,经过 label smoothing 后的标签向量的标签概率值越小,标签越平滑,反之,标签越趋向于 hard label,在训练 ImageNet-1k 的实验里通常将该值设置为 0.1。 +在训练 ImageNet-1k 的实验中,我们发现,ResNet50 大小级别及其以上的模型在使用 label_smooting 后,精度有稳定的提升。下表展示了 ResNet50_vd 在使用 label_smoothing 前后的精度指标。 + +| 模型 | Use_label_smoothing | Test acc1 | +|:--:|:--:|:--:| +| ResNet50_vd | 0 | 77.9% | +| ResNet50_vd | 1 | 78.4% | + +同时,由于 label_smoohing 相当于一种正则方式,在相对较小的模型上,精度提升不明显甚至会有所下降,下表展示了 ResNet18 在 ImageNet-1k 上使用 label_smoothing 前后的精度指标。可以明显看到,在使用 label_smoothing 后,精度有所下降。 + +| 模型 | Use_label_smoohing | Train acc1/acc5 | Test acc1/acc5 | +|:--:|:--:|:--:|:--:| +| ResNet18 | 0 | 69.81%/87.70% | 70.98%/89.92% | +| ResNet18 | 1 | 68.00%/86.56% | 70.81%/89.89% | + +综上所述,较大的模型使用 label_smoohing 可以有效提升模型的精度,较小的模型使用 label_smoohing 可能会降低模型的精度,所以在决定是否使用 label_smoohing 前,需要评估模型的大小和任务的难易程度。 + + + +## 6.针对小模型更改图片的 crop 面积与拉伸变换程度 +在 ImageNet-1k 数据的标准预处理中,random_crop 函数中定义了 scale 和 ratio 两个值,两个值分别确定了图片 crop 的大小和图片的拉伸程度,其中 scale 的默认取值范围是 0.08-1(lower_scale-upper_scale), ratio 的默认取值范围是 3/4-4/3(lower_ratio-upper_ratio)。在非常小的网络训练中,此类数据增强会使得网络欠拟合,导致精度有所下降。为了提升网络的精度,可以使其数据增强变的更弱,即增大图片的 crop 区域或者减弱图片的拉伸变换程度。我们可以分别通过增大 lower_scale 的值或缩小 lower_ratio 与 upper_scale 的差距来实现更弱的图片变换。下表列出了使用不同 lower_scale 训练 MobileNetV2_x0_25 的精度,可以看到,增大图片的 crop 区域面积后训练精度和验证精度均有提升。 + +| 模型 | Scale 取值范围 | Train_acc1/acc5 | Test_acc1/acc5 | +|:--:|:--:|:--:|:--:| +| MobileNetV2_x0_25 | [0.08,1] | 50.36%/72.98% | 52.35%/75.65% | +| MobileNetV2_x0_25 | [0.2,1] | 54.39%/77.08% | 53.18%/76.14% | + + + +## 7. 使用数据增广方式提升精度 + +一般来说,数据集的规模对性能影响至关重要,但是图片的标注往往比较昂贵,所以有标注的图片数量往往比较稀少,在这种情况下,数据的增广尤为重要。在训练 ImageNet-1k 的标准数据增广中,主要使用了 random_crop 与 random_flip 两种数据增广方式,然而,近些年,越来越多的数据增广方式被提出,如 cutout、mixup、cutmix、AutoAugment 等。实验表明,这些数据的增广方式可以有效提升模型的精度,下表列出了 ResNet50 在 8 种不同的数据增广方式的表现,可以看出,相比 baseline,所有的数据增广方式均有收益,其中 cutmix 是目前最有效的数据增广。更多数据增广的介绍请参考[**数据增广章节**](../algorithm_introduction/DataAugmentation.md)。 + +| 模型 | 数据增广方式 | Test top-1 | +|:--:|:--:|:--:| +| ResNet50 | 标准变换 | 77.31% | +| ResNet50 | Auto-Augment | 77.95% | +| ResNet50 | Mixup | 78.28% | +| ResNet50 | Cutmix | 78.39% | +| ResNet50 | Cutout | 78.01% | +| ResNet50 | Gridmask | 77.85% | +| ResNet50 | Random-Augment | 77.70% | +| ResNet50 | Random-Erasing | 77.91% | +| ResNet50 | Hide-and-Seek | 77.43% | + + + +## 8. 通过 train_acc 和 test_acc 确定调优策略 + +在训练网络的过程中,通常会打印每一个 epoch 的训练集准确率和验证集准确率,二者刻画了该模型在两个数据集上的表现。通常来说,训练集的准确率比验证集准确率微高或者二者相当是比较不错的状态。如果发现训练集的准确率比验证集高很多,说明在这个任务上已经过拟合,需要在训练过程中加入更多的正则,如增大 l2_decay 的值,加入更多的数据增广策略,加入 label_smoothing 策略等;如果发现训练集的准确率比验证集低一些,说明在这个任务上可能欠拟合,需要在训练过程中减弱正则效果,如减小 l2_decay 的值,减少数据增广方式,增大图片 crop 区域面积,减弱图片拉伸变换,去除 label_smoothing 等。 + + + +## 9.通过已有的预训练模型提升自己的数据集的精度 + +在现阶段计算机视觉领域中,加载预训练模型来训练自己的任务已成为普遍的做法,相比从随机初始化开始训练,加载预训练模型往往可以提升特定任务的精度。一般来说,业界广泛使用的预训练模型是通过训练 128 万张图片 1000 类的 ImageNet-1k 数据集得到的,该预训练模型的 fc 层权重是一个 k\*1000 的矩阵,其中 k 是 fc 层以前的神经元数,在加载预训练权重时,无需加载 fc 层的权重。在学习率方面,如果您的任务训练的数据集特别小(如小于 1 千张),我们建议你使用较小的初始学习率,如 0.001(batch_size:256,下同),以免较大的学习率破坏预训练权重。如果您的训练数据集规模相对较大(大于 10 万),我们建议你尝试更大的初始学习率,如 0.01 或者更大。 + + +> 如果您觉得此文档对您有帮助,欢迎 star 我们的项目:[https://github.com/PaddlePaddle/PaddleClas](https://github.com/PaddlePaddle/PaddleClas) + +## 参考文献 +[1]P. Goyal, P. Dolla ́r, R. B. Girshick, P. Noordhuis, L. Wesolowski, A. Kyrola, A. Tulloch, Y. Jia, and K. He. Accurate, large minibatch SGD: training imagenet in 1 hour. CoRR, abs/1706.02677, 2017. + +[2]C.Szegedy,V.Vanhoucke,S.Ioffe,J.Shlens,andZ.Wojna. Rethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015. diff --git a/src/PaddleClas/docs/zh_CN/others/VisualDL.md b/src/PaddleClas/docs/zh_CN/others/VisualDL.md new file mode 100644 index 0000000..b1ccb96 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/VisualDL.md @@ -0,0 +1,56 @@ +# 使用 VisualDL 可视化训练过程 + +--- + +## 目录 +* [1. 前言](#1) +* [2. 在 PaddleClas 中使用 VisualDL](#2) + * [2.1 设置 config 文件并启动训练](#2.1) + * [2.2 启动 VisualDL](#2.2) + + + +## 1. 前言 +VisualDL 是飞桨可视化分析工具,以丰富的图表呈现训练参数变化趋势、模型结构、数据样本、高维数据分布等。可帮助用户更清晰直观地理解深度学习模型训练过程及模型结构,进而实现高效的模型优化。更多细节请查看[VisualDL](https://github.com/PaddlePaddle/VisualDL/)。 + + + +## 2. 在 PaddleClas 中使用 VisualDL +现在 PaddleClas 支持在训练阶段使用 VisualDL 查看训练过程中学习率(learning rate)、损失值(loss)以及准确率(accuracy)的变化情况。 + + + +### 2.1 设置 config 文件并启动训练 +在 PaddleClas 中使用 VisualDL,只需在训练配置文件(config 文件)中设置字段 `Global.use_visualdl` 为 `True`: + +```yaml +# config.yaml +Global: +... + use_visualdl: True +... +``` + +PaddleClas 会将 VisualDL 的日志保存在 `Global.output_dir` 字段指定目录下的 `vdl/` 子目录下,然后正常启动训练即可: + +```shell +python3 tools/train.py -c config.yaml +``` + + +### 2.2 启动 VisualDL +在启动训练程序后,可以在新的终端 session 中启动 VisualDL 服务: + +```shell + visualdl --logdir ./output/vdl/ + ``` + +上述命令中,参数`--logdir` 用于指定保存 VisualDL 日志的目录,VisualDL 将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化。也同样可以使用下述参数设定 VisualDL 服务的 ip 及端口号: +* `--host`:设定 IP,默认为 127.0.0.1 +* `--port`:设定端口,默认为 8040 + +更多参数信息,请查看[VisualDL](https://github.com/PaddlePaddle/VisualDL/blob/develop/README_CN.md#2-%E5%90%AF%E5%8A%A8%E9%9D%A2%E6%9D%BF)。 + +在启动 VisualDL 后,即可在浏览器中查看训练过程,输入地址 `127.0.0.1:8840`: + +![](../../images/VisualDL/train_loss.png) diff --git a/src/PaddleClas/docs/zh_CN/others/competition_support.md b/src/PaddleClas/docs/zh_CN/others/competition_support.md new file mode 100644 index 0000000..f20eba4 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/competition_support.md @@ -0,0 +1,19 @@ +### 赛事支持 + +PaddleClas 的建设源于百度实际视觉业务应用的淬炼和视觉前沿能力的探索,助力多个视觉重点赛事取得领先成绩,并且持续推进更多的前沿视觉问题的解决和落地应用。 + +* 2018 年 Kaggle Open Images V4 图像目标检测挑战赛冠军 + +* 2019 年 Kaggle Open Images V5 图像目标检测挑战赛亚军 + * 技术报告可以参考:[https://arxiv.org/pdf/1911.07171.pdf](https://arxiv.org/pdf/1911.07171.pdf) + * 详细文档与开源的模型可以参考:[OIDV5目标检测 github 地址](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.2/static/docs/featured_model/champion_model/OIDV5_BASELINE_MODEL.md) + +* 2019 年 Kaggle 地标检索挑战赛亚军 + * 技术报告可以参考:[https://arxiv.org/abs/1906.03990](https://arxiv.org/abs/1906.03990) + * 详细文档与开源的模型可以参考:[2019地标检索和识别 github 地址](https://github.com/PaddlePaddle/Research/tree/master/CV/landmark) + +* 2019 年 Kaggle 地标识别挑战赛亚军 + * 技术报告可以参考:[https://arxiv.org/abs/1906.03990](https://arxiv.org/abs/1906.03990) + * 详细文档与开源的模型可以参考:[2019地标检索和识别 github 地址](https://github.com/PaddlePaddle/Research/tree/master/CV/landmark) + +* 首届多媒体信息识别技术竞赛中印刷文本 OCR、人脸识别和地标识别三项任务 A 级证书 diff --git a/src/PaddleClas/docs/zh_CN/others/course_link.md b/src/PaddleClas/docs/zh_CN/others/course_link.md new file mode 100644 index 0000000..1776320 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/course_link.md @@ -0,0 +1,34 @@ +# 往期课程链接 +--- + +- [**【AI快车道PaddleClas系列直播课】**](https://aistudio.baidu.com/aistudio/course/introduce/24519) + + - [图像识别系统解析](https://aistudio.baidu.com/aistudio/education/group/info/24519) + - 图像识别全能优势 + - 整体架构及快速落地详解 + - 个性化需求实现方案 + - [商品识别系统全拆解](https://aistudio.baidu.com/aistudio/education/lessonvideo/1495317) + - 小样本多类别场景方案 + - 图像检索技术及快速构建策略 + - 动漫搜索趣味应用 + - [车辆ReID核心技术方案](https://aistudio.baidu.com/aistudio/education/lessonvideo/1496537) + - ReID及跨境头场景应用 + - Metric Learning——更鲁棒的检索特征 + - Logo识别等方向延展 + - [超轻量图像识别系统概览](https://aistudio.baidu.com/aistudio/education/lessonvideo/1890318) + - 图像识别技术选型策略 + - 推理速度提升8倍的秘籍 + - 四大典型行业应用案例 + - [SOTA模型炼丹秘诀](https://aistudio.baidu.com/aistudio/education/lessonvideo/1890323) + - CPU定制模型PP-LCNet优化思路 + - Vison Transformer模型的应用拓展 + - [商品识别产业痛点剖析](https://aistudio.baidu.com/aistudio/education/lessonvideo/1896890) + - 特征提取技术详解 + - 向量快速检索揭秘 + - [手把手教你玩转图像识别](https://aistudio.baidu.com/aistudio/education/lessonvideo/1911507) + - 产业应用十问十答 + - 智能零售下的应用案例 + - 识别系统快速落地方案 + + + diff --git a/src/PaddleClas/docs/zh_CN/others/feature_visiualization.md b/src/PaddleClas/docs/zh_CN/others/feature_visiualization.md new file mode 100644 index 0000000..4406e1a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/feature_visiualization.md @@ -0,0 +1,102 @@ +# 特征图可视化指南 +----- +## 目录 + +* [1. 概述](#1) +* [2. 准备工作](#2) +* [3. 修改模型](#3) +* [4. 结果](#4) + + + +## 1. 概述 + +特征图是输入图片在卷积网络中的特征表达,对特征图的研究可以有利于我们对于模型的理解与设计,所以基于动态图我们使用本工具来可视化特征图。 + + + +## 2. 准备工作 + +首先需要选定研究的模型,本文设定 ResNet50 作为研究模型,将模型组网代码[resnet.py](../../../ppcls/arch/backbone/legendary_models/resnet.py)拷贝到[目录](../../../ppcls/utils/feature_maps_visualization/)下,并下载[ResNet50 预训练模型](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_pretrained.pdparams),或使用以下命令下载。 + +```bash +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_pretrained.pdparams +``` + +其他模型网络结构代码及预训练模型请自行下载:[模型库](../../../ppcls/arch/backbone/),[预训练模型](../models/models_intro.md)。 + + + +## 3. 修改模型 + +找到我们所需要的特征图位置,设置 self.fm 将其 fetch 出来,本文以 resnet50 中的 stem 层之后的特征图为例。 + +在 ResNet50 的 forward 函数中指定要可视化的特征图 + +```python + def forward(self, x): + with paddle.static.amp.fp16_guard(): + if self.data_format == "NHWC": + x = paddle.transpose(x, [0, 2, 3, 1]) + x.stop_gradient = True + x = self.stem(x) + fm = x + x = self.max_pool(x) + x = self.blocks(x) + x = self.avg_pool(x) + x = self.flatten(x) + x = self.fc(x) + return x, fm +``` + +然后修改代码[fm_vis.py](../../../ppcls/utils/feature_maps_visualization/fm_vis.py),引入 `ResNet50`,实例化 `net` 对象: + +```python +from resnet import ResNet50 +net = ResNet50() +``` + +最后执行函数 + +```bash +python tools/feature_maps_visualization/fm_vis.py \ + -i the image you want to test \ + -c channel_num -p pretrained model \ + --show whether to show \ + --interpolation interpolation method\ + --save_path where to save \ + --use_gpu whether to use gpu +``` + +参数说明: ++ `-i`:待预测的图片文件路径,如 `./test.jpeg` ++ `-c`:特征图维度,如 `5` ++ `-p`:权重文件路径,如 `./ResNet50_pretrained` ++ `--interpolation`: 图像插值方式,默认值 1 ++ `--save_path`:保存路径,如:`./tools/` ++ `--use_gpu`:是否使用 GPU 预测,默认值:True + + + +## 4. 结果 + +* 输入图片: + +![](../../images/feature_maps/feature_visualization_input.jpg) + +* 运行下面的特征图可视化脚本 + +``` +python tools/feature_maps_visualization/fm_vis.py \ + -i ./docs/images/feature_maps/feature_visualization_input.jpg \ + -c 5 \ + -p pretrained/ResNet50_pretrained/ \ + --show=True \ + --interpolation=1 \ + --save_path="./output.png" \ + --use_gpu=False +``` + +* 输出特征图保存为 `output.png`,如下所示。 + +![](../../images/feature_maps/feature_visualization_output.jpg) diff --git a/src/PaddleClas/docs/zh_CN/others/index.rst b/src/PaddleClas/docs/zh_CN/others/index.rst new file mode 100644 index 0000000..1141b41 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/index.rst @@ -0,0 +1,20 @@ +其他 +================================ + +.. toctree:: + :maxdepth: 2 + + transfer_learning.md + train_with_DALI.md + VisualDL.md + train_on_xpu.md + feature_visiualization.md + paddle_mobile_inference.md + course_link.md + competition_support.md + update_history.md + versions.md + + + + diff --git a/src/PaddleClas/docs/zh_CN/others/paddle_mobile_inference.md b/src/PaddleClas/docs/zh_CN/others/paddle_mobile_inference.md new file mode 100644 index 0000000..6cdb19a --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/paddle_mobile_inference.md @@ -0,0 +1,137 @@ +# 手机端 benchmark +--- +## 目录 + +* [1. 简介](#1) +* [2. 评估步骤](#2) + * [2.1 导出 inference 模型](#2.1) + * [2.2 benchmark 二进制文件下载](#2.2) + * [2.3 模型速度 benchmark](#2.3) + * [2.4 模型优化与速度评估](#2.4) + + + +## 1. 简介 + +[Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) 是飞桨推出的一套功能完善、易用性强且性能卓越的轻量化推理引擎。 +轻量化体现在使用较少比特数用于表示神经网络的权重和激活,能够大大降低模型的体积,解决终端设备存储空间有限的问题,推理性能也整体优于其他框架。 +[PaddleClas](https://github.com/PaddlePaddle/PaddleClas) 使用 Paddle-Lite 进行了[移动端模型的性能评估](../models/Mobile.md),本部分以 `ImageNet1k` 数据集的 `MobileNetV1` 模型为例,介绍怎样使用 `Paddle-Lite`,在移动端(基于骁龙855的安卓开发平台)对进行模型速度评估。 + + + +## 2. 评估步骤 + + + +### 2.1 导出 inference 模型 + +* 首先需要将训练过程中保存的模型存储为用于预测部署的固化模型,可以使用 `tools/export_model.py` 导出 inference 模型,具体使用方法如下。 + +```shell +python tools/export_model.py \ + -c ./ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml \ + -o Arch.pretrained=./pretrained/MobileNetV1_pretrained/ \ + -o Global.save_inference_dir=./inference/MobileNetV1/ +``` + +在上述命令中,通过参数 `Arch.pretrained` 指定训练过程中保存的模型参数文件,也可以指定参数 `Arch.pretrained=True` 加载 PaddleClas 提供的基于 ImageNet1k 的预训练模型参数,最终在 `inference/MobileNetV1` 文件夹下会保存得到 `inference.pdmodel` 与 `inference.pdiparmas` 文件。 + + + +### 2.2 benchmark 二进制文件下载 + +* 使用 adb(Android Debug Bridge)工具可以连接 Android 手机与 PC 端,并进行开发调试等。安装好 adb,并确保 PC 端和手机连接成功后,使用以下命令可以查看手机的 ARM 版本,并基于此选择合适的预编译库。 + +```shell +adb shell getprop ro.product.cpu.abi +``` + +* 下载 benchmark_bin 文件 + +请根据所用 Android 手机的 ARM 版本选择,ARM 版本为 v8,则使用以下命令下载: + +```shell +wget -c https://paddle-inference-dist.bj.bcebos.com/PaddleLite/benchmark_0/benchmark_bin_v8 +``` + +如果查看的 ARM 版本为 v7,则需要下载 v7 版本的 benchmark_bin 文件,下载命令如下: + +```shell +wget -c https://paddle-inference-dist.bj.bcebos.com/PaddleLite/benchmark_0/benchmark_bin_v7 +``` + + + +### 2.3 模型速度 benchmark + +PC 端和手机连接成功后,使用下面的命令开始模型评估。 + +``` +sh deploy/lite/benchmark/benchmark.sh ./benchmark_bin_v8 ./inference result_armv8.txt true +``` + +其中 `./benchmark_bin_v8` 为 benchmark 二进制文件路径,`./inference` 为所有需要评测的模型的路径,`result_armv8.txt` 为保存的结果文件,最后的参数 `true` 表示在评估之后会首先进行模型优化。最终在当前文件夹下会输出 `result_armv8.txt` 的评估结果文件,具体信息如下。 + +``` +PaddleLite Benchmark +Threads=1 Warmup=10 Repeats=30 +MobileNetV1 min = 30.89100 max = 30.73600 average = 30.79750 + +Threads=2 Warmup=10 Repeats=30 +MobileNetV1 min = 18.26600 max = 18.14000 average = 18.21637 + +Threads=4 Warmup=10 Repeats=30 +MobileNetV1 min = 10.03200 max = 9.94300 average = 9.97627 +``` + +这里给出了不同线程数下的模型预测速度,单位为 FPS,以线程数为 1 为例,MobileNetV1 在骁龙855上的平均速度为 `30.79750FPS`。 + + + +### 2.4 模型优化与速度评估 + + +* 在 2.3 节中提到了在模型评估之前对其进行优化,在这里也可以首先对模型进行优化,再直接加载优化后的模型进行速度评估。 + +* Paddle-Lite 提供了多种策略来自动优化原始的训练模型,其中包括量化、子图融合、混合调度、Kernel 优选等等方法。为了使优化过程更加方便易用,Paddle-Lite 提供了 opt 工具来自动完成优化步骤,输出一个轻量的、最优的可执行模型。可以在[Paddle-Lite 模型优化工具页面](https://paddle-lite.readthedocs.io/zh/latest/user_guides/model_optimize_tool.html)下载。在这里以 `macOS` 开发环境为例,下载[opt_mac](https://paddlelite-data.bj.bcebos.com/model_optimize_tool/opt_mac)模型优化工具,并使用下面的命令对模型进行优化。 + + + +```shell +model_file="../MobileNetV1/inference.pdmodel" +param_file="../MobileNetV1/inference.pdiparams" +opt_models_dir="./opt_models" +mkdir ${opt_models_dir} +./opt_mac --model_file=${model_file} \ + --param_file=${param_file} \ + --valid_targets=arm \ + --optimize_out_type=naive_buffer \ + --prefer_int8_kernel=false \ + --optimize_out=${opt_models_dir}/MobileNetV1 +``` + +其中 `model_file` 与 `param_file` 分别是导出的 inference 模型结构文件与参数文件地址,转换成功后,会在 `opt_models` 文件夹下生成 `MobileNetV1.nb` 文件。 + +使用 benchmark_bin 文件加载优化后的模型进行评估,具体的命令如下。 + +```shell +bash benchmark.sh ./benchmark_bin_v8 ./opt_models result_armv8.txt +``` + +最终 `result_armv8.txt` 中结果如下: + +``` +PaddleLite Benchmark +Threads=1 Warmup=10 Repeats=30 +MobileNetV1_lite min = 30.89500 max = 30.78500 average = 30.84173 + +Threads=2 Warmup=10 Repeats=30 +MobileNetV1_lite min = 18.25300 max = 18.11000 average = 18.18017 + +Threads=4 Warmup=10 Repeats=30 +MobileNetV1_lite min = 10.00600 max = 9.90000 average = 9.96177 +``` + +以线程数为 1 为例,MobileNetV1 在骁龙855上的平均速度为 `30.84173 ms`。 + +更加具体的参数解释与 Paddle-Lite 使用方法可以参考 [Paddle-Lite 文档](https://paddle-lite.readthedocs.io/zh/latest/)。 diff --git a/src/PaddleClas/docs/zh_CN/others/train_on_xpu.md b/src/PaddleClas/docs/zh_CN/others/train_on_xpu.md new file mode 100644 index 0000000..429119b --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/train_on_xpu.md @@ -0,0 +1,81 @@ +# 图像分类昆仑模型介绍(持续更新中) +------ +## 目录 +* [1. 前言](#1) +* [2. 昆仑训练](#2) + * [2.1 ResNet50](#2.1) + * [2.2 MobileNetV3](#2.2) + * [2.3 HRNet](#2.3) + * [2.4 VGG16/19](#2.4) + + + +## 1. 前言 + +* 本文档介绍了目前昆仑支持的模型以及如何在昆仑设备上训练这些模型。支持昆仑的 PaddlePaddle 安装参考 install_kunlun(https://github.com/PaddlePaddle/FluidDoc/blob/develop/doc/paddle/install/install_Kunlun_zh.md) + + + +## 2. 昆仑训练 +* 数据来源和预训练模型参考[quick_start](../quick_start/quick_start_classification_new_user.md)。昆仑训练效果与 CPU/GPU 对齐。 + + + +### 2.1 ResNet50 +* 命令: + +```shell +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/ResNet50_vd_finetune_kunlun.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` + +与 cpu/gpu 训练的区别是加上 -o use_xpu=True, 表示执行在昆仑设备上。 + + + +### 2.2 MobileNetV3 +* 命令: + +```shell +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` + + + +### 2.3 HRNet +* 命令: + +```shell +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/HRNet_W18_C_finetune_kunlun.yaml \ + -o is_distributed=False \ + -o use_xpu=True \ + -o use_gpu=False +``` + + + +### 2.4 VGG16/19 +* 命令: + +```shell +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/VGG16_finetune_kunlun.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` +```shell +python3.7 ppcls/static/train.py \ + -c ppcls/configs/quick_start/kunlun/VGG19_finetune_kunlun.yaml \ + -o use_gpu=False \ + -o use_xpu=True \ + -o is_distributed=False +``` diff --git a/src/PaddleClas/docs/zh_CN/others/train_with_DALI.md b/src/PaddleClas/docs/zh_CN/others/train_with_DALI.md new file mode 100644 index 0000000..34782ea --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/train_with_DALI.md @@ -0,0 +1,72 @@ +# 使用 DALI 加速训练 +---- +## 目录 +* [1. 前言](#1) +* [2. 安装 DALI](#2) +* [3. 使用 DALI](#3) +* [4. 使用 FP16 训练](#4) + + + +## 1. 前言 +[NVIDIA 数据加载库](https://docs.nvidia.com/deeplearning/dali/user-guide/docs/index.html)(The NVIDIA Data Loading Library,DALI)是用于数据加载和预处理的开源库,用于加速深度学习训练、推理过程,它可以直接构建飞桨 Paddle 的 DataLoader 数据读取器。 + +由于深度学习程序在训练阶段依赖大量数据,这些数据需要经过加载、预处理等操作后,才能送入训练程序,而这些操作通常在 CPU 完成,因此限制了训练速度进一步提高,特别是在 batch_size 较大时,数据读取可能成为训练速度的瓶颈。 DALI 可以基于 GPU 的高并行特性实现数据加载及预处理操作,可以进一步提高训练速度。 + + + +## 2.安装 DALI +目前 DALI 仅支持 Linux x64 平台,且 CUDA 版本大于等于 10.2。 + +* 对于 CUDA 10: + + pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda100 + +* 对于 CUDA 11.0: + + pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda110 + +关于更多 DALI 安装的信息,可以参考[DALI 官方](https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html)。 + + + +## 3. 使用 DALI +PaddleClas 支持使用 DALI 对图像预处理进行加速,由于 DALI 仅支持 GPU 训练,因此需要设置 GPU,且 DALI 需要占用 GPU 显存,需要为 DALI 预留显存。使用 DALI 训练只需在训练配置文件中设置字段 `use_dali=True`,或通过以下命令启动训练即可: + +```shell +# 设置用于训练的 GPU 卡号 +export CUDA_VISIBLE_DEVICES="0" + +python ppcls/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50.yaml -o Global.use_dali=True +``` + +也可以使用多卡训练: + +```shell +# 设置用于训练的 GPU 卡号 +export CUDA_VISIBLE_DEVICES="0,1,2,3" + +# 设置用于神经网络训练的显存大小,可根据具体情况设置,一般可设置为 0.8 或 0.7,剩余显存则预留 DALI 使用 +export FLAGS_fraction_of_gpu_memory_to_use=0.80 + +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + ppcls/train.py \ + -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml \ + -o Global.use_dali=True +``` + + + +## 4. 使用 FP16 训练 +在上述基础上,使用 FP16 半精度训练,可以进一步提高速度,可以参考下面的配置与运行命令。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +export FLAGS_fraction_of_gpu_memory_to_use=0.8 + +python -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + ppcls/train.py \ + -c ./ppcls/configs/ImageNet/ResNet/ResNet50_fp16_dygraph.yaml +``` diff --git a/src/PaddleClas/docs/zh_CN/others/transfer_learning.md b/src/PaddleClas/docs/zh_CN/others/transfer_learning.md new file mode 100644 index 0000000..d42bc09 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/transfer_learning.md @@ -0,0 +1,103 @@ +# 图像分类迁移学习 +迁移学习是机器学习领域的一个重要分支,广泛应用于文本、图像等各种领域,此处我们主要介绍的是图像分类领域的迁移学习,也就是我们常说的域迁移,比如将 ImageNet 分类模型迁移到我们自己场景的图像分类任务上,如花卉分类。 + +---------- + +## 目录 + +* [1. 超参搜索](#1) + * [1.1 网格搜索](#1.1) + * [1.2 贝叶斯搜索](#1.2) +* [2. 大规模分类模型](#2) +* [3. 参考文献](#3) + + + +## 1. 超参搜索 + +ImageNet 作为业界常用的图像分类数据被大家广泛使用,已经总结出一系列经验性的超参,使用这些超参往往能够得到不错的训练精度,而这些经验性的参数在迁移到自己的业务中时,有时效果不佳。有两种常用的超参搜索方法可以用于获得更好的模型超参。 + + + +### 1.1 网格搜索 + +网格搜索,即穷举搜索,通过查找搜索空间内所有的点,确定最优值。方法简单有效,但当搜索空间较大时,需要消耗大量的计算资源。 + + + +### 1.2 贝叶斯搜索 + +贝叶斯搜索,即贝叶斯优化,在搜索空间中随机选取超参数点,采用高斯过程,即根据上一个超参数点的结果,更新当前的先验信息,计算前面 n 个超参数点的后验概率分布,得到搜索空间中每一个超参数点的期望均值和方差,其中期望均值越大表示接近最优指标的可能性越大,方差越大表示不确定性越大。通常将选择期望均值大的超参数点称为 `exporitation`,选择方差大的超参数点称为 `exploration`。在贝叶斯优化中通过定义 `acquisition function` 权衡期望均值和方差。贝叶斯搜索认为当前选择的超参数点是处于最大值可能出现的位置。 + +------ + +基于上述两种搜索方案,我们在 8 个开源数据集上将固定一组参数实验以及两种搜索方案做了对比实验,参照[1]的实验方案,我们对 4 个超参数进行搜索,搜索空间及实验结果如下所示: + +- 固定参数: + +``` +初始学习率 lr=0.003,l2 decay=1e-4,label smoothing=False,mixup=False +``` + +- 超参搜索空间: + +``` +初始学习率 lr: [0.1, 0.03, 0.01, 0.003, 0.001, 0.0003, 0.0001] + +L2 decay: [1e-3, 3e-4, 1e-4, 3e-5, 1e-5, 3e-6, 1e-6] + +Label smoothing: [False, True] + +Mixup: [False, True] +``` + +网格搜索的搜索次数为 196 次,而贝叶斯搜索通过设置最大迭代次数(`max_iter`)和是否重复搜索(`de_duplication`)来确定搜索次数。我们设计了系列实验,baseline 为 ImageNet1k 校验集 Top1 Acc 为 79.12% 的 ResNet50_vd 预训练模型,并固定超参,在新数据集上 finetune 得到的模型。下表给出了固定参数、网格搜索以及贝叶斯搜索的精度与搜索次数对比。 + +- 精度与搜索次数对比: + +| 数据集 | 固定参数 | 网格搜索 | 网格搜索次数 | 贝叶斯搜索 | 贝叶斯搜索次数| +| ------------------ | -------- | -------- | -------- | -------- | ---------- | +| Oxford-IIIT-Pets | 93.64% | 94.55% | 196 | 94.04% | 20 | +| Oxford-102-Flowers | 96.08% | 97.69% | 196 | 97.49% | 20 | +| Food101 | 87.07% | 87.52% | 196 | 87.33% | 23 | +| SUN397 | 63.27% | 64.84% | 196 | 64.55% | 20 | +| Caltech101 | 91.71% | 92.54% | 196 | 92.16% | 14 | +| DTD | 76.87% | 77.53% | 196 | 77.47% | 13 | +| Stanford Cars | 85.14% | 92.72% | 196 | 92.72% | 25 | +| FGVC Aircraft | 80.32% | 88.45% | 196 | 88.36% | 20 | + + +- 上述实验验证了贝叶斯搜索相比网格搜索,在减少搜索次数 10 倍左右条件下,精度只下降 0%~0.4%。 +- 当搜索空间进一步扩大时,例如将是否进行 AutoAugment,RandAugment,Cutout,Cutmix 以及 Dropout 这些正则化策略作为选择时,贝叶斯搜索能够在获取较优精度的前提下,有效地降低搜索次数。 + + + +## 2. 大规模分类模型 + +在实际应用中,由于训练数据的匮乏,往往将 ImageNet1k 数据集训练的分类模型作为预训练模型,进行图像分类的迁移学习。为了进一步助力解决实际问题,基于 ResNet50_vd, 百度开源了自研的大规模分类预训练模型,其中训练数据为 10 万个类别,4300 万张图片。10 万类预训练模型的下载地址:[**下载地址**](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_10w_pretrained.pdparams) + +我们在 6 个自有采集的数据集上进行迁移学习实验,采用一组固定参数以及网格搜索方式,其中训练轮数设置为 20 epochs,选用 ResNet50_vd 模型,ImageNet 预训练精度为 79.12%。实验数据集参数以及模型精度的对比结果如下: + +固定参数: + +``` +初始学习率 lr=0.001,l2 decay=1e-4,label smoothing=False,mixup=False +``` + +| 数据集 | 数据统计 | **ImageNet 预训练模型
固定参数 Top-1/参数搜索 Top-1** | **大规模分类预训练模型
固定参数 Top-1/参数搜索 Top-1** | +| --------------- | ----------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------- | +| 花卉 | class:102
train:5789
valid:2396 | 0.7779/0.9883 | 0.9892/0.9954 | +| 手绘简笔画 | Class:18
train:1007
valid:432 | 0.8795/0.9196 | 0.9107/0.9219 | +| 植物叶子 | class:6
train:5256
valid:2278 | 0.8212/0.8482 | 0.8385/0.8659 | +| 集装箱车辆 | Class:115
train:4879
valid:2094 | 0.6230/0.9556 | 0.9524/0.9702 | +| 椅子 | class:5
train:169
valid:78 | 0.8557/0.9688 | 0.9077/0.9792 | +| 地质 | class:4
train:671
valid:296 | 0.5719/0.8094 | 0.6781/0.8219 | + +- 通过上述的实验验证了当使用一组固定参数时,相比于 ImageNet 预训练模型,使用大规模分类模型作为预训练模型在大多数情况下能够提升模型在新的数据集上得效果,通过参数搜索可以进一步提升精度。 + + +## 3. 参考文献 + +[1] Kornblith, Simon, Jonathon Shlens, and Quoc V. Le. "Do better imagenet models transfer better?." *Proceedings of the IEEE conference on computer vision and pattern recognition*. 2019. + +[2] Kolesnikov, Alexander, et al. "Large Scale Learning of General Visual Representations for Transfer." *arXiv preprint arXiv:1912.11370* (2019). diff --git a/src/PaddleClas/docs/zh_CN/others/update_history.md b/src/PaddleClas/docs/zh_CN/others/update_history.md new file mode 100644 index 0000000..55ad1a2 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/update_history.md @@ -0,0 +1,60 @@ +# 更新日志 + +- 2021.11.1 发布[PP-ShiTu技术报告](https://arxiv.org/pdf/2111.00775.pdf),新增饮料识别demo。 +- 2021.10.23 发布轻量级图像识别系统PP-ShiTu,CPU上0.2s即可完成在10w+库的图像识别。[点击这里](../quick_start/quick_start_recognition.md)立即体验。 +- 2021.09.17 发布PP-LCNet系列超轻量骨干网络模型, 在Intel CPU上,单张图像预测速度约5ms,ImageNet-1K数据集上Top1识别准确率达到80.82%,超越ResNet152的模型效果。PP-LCNet的介绍可以参考[论文](https://arxiv.org/pdf/2109.15099.pdf), 或者[PP-LCNet模型介绍](../models/PP-LCNet.md),相关指标和预训练权重可以从 [这里](../algorithm_introduction/ImageNet_models.md)下载。 +- 2021.08.11 更新7个[FAQ](../faq_series/faq_2021_s2.md)。 +- 2021.06.29 添加Swin-transformer系列模型,ImageNet1k数据集上Top1 acc最高精度可达87.2%;支持训练预测评估与whl包部署,预训练模型可以从[这里](../models/models_intro.md)下载。 +- 2021.06.22,23,24 PaddleClas官方研发团队带来技术深入解读三日直播课。课程回放:[https://aistudio.baidu.com/aistudio/course/introduce/24519](https://aistudio.baidu.com/aistudio/course/introduce/24519) +- 2021.06.16 PaddleClas v2.2版本升级,集成Metric learning,向量检索等组件。新增商品识别、动漫人物识别、车辆识别和logo识别等4个图像识别应用。新增LeViT、Twins、TNT、DLA、HarDNet、RedNet系列30个预训练模型。 +- 2021.08.11 更新 7 个[FAQ](../faq_series/faq_2021_s2.md)。 +- 2021.06.29 添加 Swin-transformer 系列模型,ImageNet1k 数据集上 Top1 acc 最高精度可达 87.2%;支持训练预测评估与 whl 包部署,预训练模型可以从[这里](../models/models_intro.md)下载。 +- 2021.06.22,23,24 PaddleClas 官方研发团队带来技术深入解读三日直播课。课程回放:[https://aistudio.baidu.com/aistudio/course/introduce/24519](https://aistudio.baidu.com/aistudio/course/introduce/24519) +- 2021.06.16 PaddleClas v2.2 版本升级,集成 Metric learning,向量检索等组件。新增商品识别、动漫人物识别、车辆识别和 logo 识别等 4 个图像识别应用。新增 LeViT、Twins、TNT、DLA、HarDNet、RedNet 系列 30 个预训练模型。 +- 2021.04.15 + - 添加 `MixNet_L` 和 `ReXNet_3_0` 系列模型,在 ImageNet-1k 上 `MixNet` 模型 Top1 Acc 可达 78.6%,`ReXNet` 模型可达 82.09% +- 2021.01.27 + * 添加 ViT 与 DeiT 模型,在 ImageNet 上,ViT 模型 Top-1 Acc 可达 81.05%,DeiT 模型可达 85.5%。 +- 2021.01.08 + * 添加 whl 包及其使用说明,直接安装 paddleclas whl 包,即可快速完成模型预测。 +- 2020.12.16 + * 添加对 cpp 预测的 tensorRT 支持,预测加速更明显。 +- 2020.12.06 + * 添加 SE_HRNet_W64_C_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.8475。 +- 2020.11.23 + * 添加 GhostNet_x1_3_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.7938。 +- 2020.11.09 + * 添加 InceptionV3 结构和模型,在 ImageNet 上 Top-1 Acc 可达 0.791。 +- 2020.10.20 + * 添加 Res2Net50_vd_26w_4s_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.831;添加 Res2Net101_vd_26w_4s_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.839。 +- 2020.10.12 + * 添加 Paddle-Lite demo。 +- 2020.10.10 + * 添加 cpp inference demo。 + * 添加 FAQ 30 问。 +- 2020.09.17 + * 添加 HRNet_W48_C_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.836;添加 ResNet34_vd_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.797。 + +* 2020.09.07 + * 添加 HRNet_W18_C_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.81162;添加 MobileNetV3_small_x0_35_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 0.5555。 + +* 2020.07.14 + * 添加 Res2Net200_vd_26w_4s_ssld 模型,在 ImageNet 上 Top-1 Acc 可达 85.13%。 + * 添加 Fix_ResNet50_vd_ssld_v2 模型,,在 ImageNet 上 Top-1 Acc 可达 84.0%。 + +* 2020.06.17 + * 添加英文文档。 + +* 2020.06.12 + * 添加对 windows 和 CPU 环境的训练与评估支持。 + +* 2020.05.17 + * 添加混合精度训练。 + +* 2020.05.09 + * 添加 Paddle Serving 使用文档。 + * 添加 Paddle-Lite 使用文档。 + * 添加 T4 GPU 的 FP32/FP16 预测速度 benchmark。 + +* 2020.04.10: + * 第一次提交。 diff --git a/src/PaddleClas/docs/zh_CN/others/versions.md b/src/PaddleClas/docs/zh_CN/others/versions.md new file mode 100644 index 0000000..7399bdc --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/others/versions.md @@ -0,0 +1,58 @@ +# 版本更新信息 +---------- +## 目录 +* [1. v2.3](#1) +* [2. v2.2](#2) + + + +## 1. v2.3 + +- 模型更新 + - 添加轻量化模型预训练权重,包括检测模型、特征模型 + - 发布 PP-LCNet 系列模型,此系列模型是专门在 CPU 上设计运行的自研模型 + - SwinTransformer、Twins、Deit 支持从 scrach 直接训练,达到论文精度 +- 框架基础能力 + - 添加 DeepHash 模块,支持特征模型直接输出二值特征 + - 添加 PKSampler,特征模型不能多机多卡的训练的问题 + - 支持 PaddleSlim:支持分类模型、特征模型的量化、裁剪训练及离线量化功能 + - Legendary models 支持模型中间结果输出 + - 支持多标签分类训练 +- 预测部署 + - 使用 Faiss 替换原有特征检索库,提升平台适配性 + - 支持 PaddleServing:支持分类模型、图像识别流程的部署 + +- 推荐库版本 + - python 版本:3.7 + - PaddlePaddle 版本:2.1.3 + - PaddleSlim 版本:2.2.0 + - PaddleServing 版本:0.6.1 + + + +## 2. v2.2 + +- 模型更新 + - 添加 LeViT、Twins、TNT、DLA、HardNet、RedNet、SwinTransfomer 模型 +- 框架基础能力 + - 将分类模型分为两类 + - legendary models:引入 TheseusLayer 基类,及增加了修改网络功能接口,同时支持网络截断输出功能 + - model zoo:其他普通分类模型 + - 添加 Metric Learning 算法支持 + - 添加多种相关 Loss 算法,及基础网络模块 gears(支持与 backbone、loss 组合)方便使用 + - 同时支持普通分类及 metric learning 相关任务训练 + - 支持静态图训练 + - 分类训练支持 dali 加速 + - 支持 fp16 训练 +- 应用更新 + - 添加商品识别、车辆识别(车辆细粒度分类、车辆 ReID)、logo 识别、动漫人物识别应用具体案例及相关模型 + - 添加图像识别完整 pipeline,包含检测模块、特征提取模块、向量检索模块 +- 预测部署 + - 添加百度自研向量检索模块 Mobius,支持图像识别系统预测部署 + - 图像识别,建立特征库支持 batch_size>1 +- 文档更新 + - 添加图像识别相关文档 + - 修复之前文档 bug +- 推荐库版本 + - python 版本:3.7 + - PaddlePaddle:2.1.2 diff --git a/src/PaddleClas/docs/zh_CN/quick_start/index.rst b/src/PaddleClas/docs/zh_CN/quick_start/index.rst new file mode 100644 index 0000000..50af471 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/quick_start/index.rst @@ -0,0 +1,10 @@ +快速开始 +================================ + +.. toctree:: + :maxdepth: 2 + + quick_start_classification_new_user.md + quick_start_classification_professional.md + quick_start_recognition.md + quick_start_multilabel_classification.md diff --git a/src/PaddleClas/docs/zh_CN/quick_start/quick_start_classification_new_user.md b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_classification_new_user.md new file mode 100644 index 0000000..905f62d --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_classification_new_user.md @@ -0,0 +1,198 @@ +# 30分钟玩转PaddleClas(尝鲜版) + +此教程主要针对初级用户,即深度学习相关理论知识处于入门阶段,具有一定的 Python 基础,能够阅读简单代码的用户。此内容主要包括使用 PaddleClas 进行图像分类网络训练及模型预测。 + +--- +## 目录 +* [1. 基础知识](#1) +* [2. 环境安装与配置](#2) +* [3. 数据的准备与处理](#3) +* [4. 模型训练](#4) + * [4.1 使用CPU进行模型训练](#4.1) + * [4.1.1 不使用预训练模型](#4.1.1) + * [4.1.2 使用预训练模型](#4.1.2) + * [4.2 使用GPU进行模型训练](#4.2) + * [4.2.1 不使用预训练模型](#4.2.1) + * [4.2.2 使用预训练模型进行训练](#4.2.2) +* [5. 模型预测](#5) + + + +## 1. 基础知识 + +图像分类顾名思义就是一个模式分类问题,是计算机视觉中最基础的任务,它的目标是将不同的图像,划分到不同的类别。以下会对整个模型训练过程中需要了解到的一些概念做简单的解释,希望能够对初次体验 PaddleClas 的你有所帮助: + +- train/val/test dataset 分别代表模型的训练集、验证集和测试集: + - 训练集(train dataset):用来训练模型,使模型能够识别不同类型的特征; + - 验证集(val dataset):训练过程中的测试集,方便训练过程中查看模型训练程度; + - 测试集(test dataset):训练模型结束后,用于评价模型结果的测试集。 + +- 预训练模型 + + 使用在某个较大的数据集训练好的预训练模型,即被预置了参数的权重,可以帮助模型在新的数据集上更快收敛。尤其是对一些训练数据比较稀缺的任务,在神经网络参数十分庞大的情况下,仅仅依靠任务自身的训练数据可能无法训练充分,加载预训练模型的方法可以认为是让模型基于一个更好的初始状态进行学习,从而能够达到更好的性能。 + +- 迭代轮数(epoch) + + 模型训练迭代的总轮数,模型对训练集全部样本过一遍即为一个 epoch。当测试错误率和训练错误率相差较小时,可认为当前迭代轮数合适;当测试错误率先变小后变大时,则说明迭代轮数过大,需要减小迭代轮数,否则容易出现过拟合。 + +- 损失函数(Loss Function) + + 训练过程中,衡量模型输出(预测值)与真实值之间的差异 + +- 准确率(Acc):表示预测正确的样本数占总数据的比例 + + - Top1 Acc:预测结果中概率最大的所在分类正确,则判定为正确; + - Top5 Acc:预测结果中概率排名前 5 中有分类正确,则判定为正确; + + + +## 2. 环境安装与配置 + +具体安装步骤可详看[Paddle 安装文档](../installation/install_paddle.md),[PaddleClas 安装文档](../installation/install_paddleclas.md)。 + + + +## 3. 数据的准备与处理 + +进入PaddleClas目录: + +```shell +# linux or mac, $path_to_PaddleClas表示PaddleClas的根目录,用户需要根据自己的真实目录修改 +cd $path_to_PaddleClas +``` + +进入 `dataset/flowers102` 目录,下载并解压 flowers102 数据集: + +```shell +# linux or mac +cd dataset/ +# 如果希望从浏览器中直接下载,可以复制该链接并访问,然后下载解压即可 +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/flowers102.zip +# 解压 +unzip flowers102.zip +``` + +没有安装 `wget` 命令或者在 Windows 中下载的话,需要将地址拷贝到浏览器中下载,并进行解压到目录 `PaddleClas/dataset/` 下面即可。 + +解压完成后,在目录 `PaddleClas/dataset/flowers102` 下有用于训练和测试的三个 `.txt` 文件:`train_list.txt`(训练集,1020张图)、`val_list.txt`(验证集,1020张图)、`train_extra_list.txt`(更大的训练集,7169张图)。文件中每行格式:**图像相对路径** **图像的label_id**(注意:中间有空格),此外还有flowers102数据集 label id 与类别名称的映射文件:`flowers102_label_list.txt`。 + +flowers102数据集的图像文件存放在 `dataset/flowers102/jpg` 目录中,图像示例如下: + +![](../../images/quick_start/Examples-Flower-102.png) + +返回 `PaddleClas` 根目录: + +```shell +# linux or mac +cd ../../ +# windoes直接打开PaddleClas根目录即可 +``` + + +## 4. 模型训练 + + + +### 4.1 使用CPU进行模型训练 + +由于使用CPU来进行模型训练,计算速度较慢,因此,此处以 ShuffleNetV2_x0_25 为例。此模型计算量较小,在 CPU 上计算速度较快。但是也因为模型较小,训练好的模型精度也不会太高。 + + + +#### 4.1.1 不使用预训练模型 + +```shell +# windows在cmd中进入PaddleClas根目录,执行此命令 +python tools/train.py -c ./ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml +``` + +- `-c` 参数是指定训练的配置文件路径,训练的具体超参数可查看`yaml`文件 +- `yaml`文`Global.device` 参数设置为`cpu`,即使用CPU进行训练(若不设置,此参数默认为`True`) +- `yaml`文件中`epochs`参数设置为20,说明对整个数据集进行20个epoch迭代,预计训练20分钟左右(不同CPU,训练时间略有不同),此时训练模型不充分。若提高训练模型精度,请将此参数设大,如**40**,训练时间也会相应延长 + + + +#### 4.1.2 使用预训练模型 + +```shell +python tools/train.py -c ./ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml -o Arch.pretrained=True +``` + +- `-o` 参数可以选择为 `True` 或 `False`,也可以是预训练模型存放路径,当选择为 `True` 时,预训练权重会自动下载到本地。注意:若为预训练模型路径,则不要加上:`.pdparams` + +可以使用将使用与不使用预训练模型训练进行对比,观察 loss 的下降情况。 + + + +### 4.2 使用GPU进行模型训练 + +由于 GPU 训练速度更快,可以使用更复杂模型,因此以 ResNet50_vd 为例。与 ShuffleNetV2_x0_25 相比,此模型计算量较大,训练好的模型精度也会更高。 + +首先要设置环境变量,使用 0 号 GPU 进行训练: + +- 对于 Linux 用户 + + ```shell + export CUDA_VISIBLE_DEVICES=0 + ``` + +- 对于 Windows 用户 + + ```shell + set CUDA_VISIBLE_DEVICES=0 + ``` + + +#### 4.2.1. 不使用预训练模型 + +```shell +python tools/train.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml +``` + +训练完成后,验证集的`Top1 Acc`曲线如下所示,最高准确率为0.2735。训练精度曲线下图所示 + +![](../../images/quick_start/r50_vd_acc.png) + + + +#### 4.2.2 使用预训练模型进行训练 + +基于 ImageNet1k 分类预训练模型进行微调,训练脚本如下所示 + +```shell +python tools/train.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Arch.pretrained=True +``` + +**注**:此训练脚本使用 GPU,如使用 CPU 可按照上文中[4.1 使用CPU进行模型训练](#4.1)所示,进行修改。 + +验证集的 `Top1 Acc` 曲线如下所示,最高准确率为 `0.9402`,加载预训练模型之后,flowers102 数据集精度大幅提升,绝对精度涨幅超过 65%。 + +![](../../images/quick_start/r50_vd_pretrained_acc.png) + + + +## 5. 模型预测 + +训练完成后,可以使用训练好的模型进行预测,以训练的 ResNet50_vd 模型为例,预测代码如下: + +```shell +cd $path_to_PaddleClas +python tools/infer.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Infer.infer_imgs=dataset/flowers102/jpg/image_00001.jpg -o Global.pretrained_model=output/ResNet50_vd/best_model +``` + +`-i` 输入为单张图像路径,运行成功后,示例结果如下: + +`[{'class_ids': [76, 51, 37, 33, 9], 'scores': [0.99998, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00001.jpg', 'label_names': ['passion flower', 'wild pansy', 'great masterwort', 'mexican aster', 'globe thistle']}]` + +当然也可以使用训练的 ShuffleNetV2_x0_25 模型进行预测,代码如下: + +```shell +cd $path_to_PaddleClas +python tools/infer.py -c ./ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml -o Infer.infer_imgs=dataset/flowers102/jpg/image_00001.jpg -o Global.pretrained_model=output/ShuffleNetV2_x0_25/best_model +``` + +`-i` 参数也可以为待测图像文件所在目录(`dataset/flowers102/jpg/`),运行成功后,部分示例结果如下: + +`[{'class_ids': [76, 51, 37, 33, 9], 'scores': [0.99998, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00001.jpg', 'label_names': ['passion flower', 'wild pansy', 'great masterwort', 'mexican aster', 'globe thistle']}, {'class_ids': [76, 51, 37, 33, 32], 'scores': [0.99999, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00002.jpg', 'label_names': ['passion flower', 'wild pansy', 'great masterwort', 'mexican aster', 'love in the mist']}, {'class_ids': [76, 12, 39, 73, 78], 'scores': [0.99998, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00003.jpg', 'label_names': ['passion flower', 'king protea', 'lenten rose', 'rose', 'toad lily']}, {'class_ids': [76, 37, 34, 12, 9], 'scores': [0.86282, 0.11177, 0.00717, 0.00599, 0.00397], 'file_name': 'dataset/flowers102/jpg/image_00004.jpg', 'label_names': ['passion flower', 'great masterwort', 'alpine sea holly', 'king protea', 'globe thistle']}, {'class_ids': [76, 37, 33, 51, 69], 'scores': [0.9999, 1e-05, 1e-05, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00005.jpg', 'label_names': ['passion flower', 'great masterwort', 'mexican aster', 'wild pansy', 'tree poppy']}, {'class_ids': [76, 37, 51, 33, 73], 'scores': [0.99999, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00006.jpg', 'label_names': ['passion flower', 'great masterwort', 'wild pansy', 'mexican aster', 'rose']}, {'class_ids': [76, 37, 12, 91, 30], 'scores': [0.98746, 0.00211, 0.00201, 0.00136, 0.0007], 'file_name': 'dataset/flowers102/jpg/image_00007.jpg', 'label_names': ['passion flower', 'great masterwort', 'king protea', 'bee balm', 'carnation']}, {'class_ids': [76, 37, 81, 77, 72], 'scores': [0.99976, 3e-05, 2e-05, 2e-05, 1e-05], 'file_name': 'dataset/flowers102/jpg/image_00008.jpg', 'label_names': ['passion flower', 'great masterwort', 'clematis', 'lotus', 'water lily']}, {'class_ids': [76, 37, 13, 12, 34], 'scores': [0.99646, 0.00144, 0.00092, 0.00035, 0.00027], 'file_name': 'dataset/flowers102/jpg/image_00009.jpg', 'label_names': ['passion flower', 'great masterwort', 'spear thistle', 'king protea', 'alpine sea holly']}, {'class_ids': [76, 37, 34, 33, 51], 'scores': [0.99999, 0.0, 0.0, 0.0, 0.0], 'file_name': 'dataset/flowers102/jpg/image_00010.jpg', 'label_names': ['passion flower', 'great masterwort', 'alpine sea holly', 'mexican aster', 'wild pansy']}]` + +其中,列表的长度为 batch_size 的大小。 diff --git a/src/PaddleClas/docs/zh_CN/quick_start/quick_start_classification_professional.md b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_classification_professional.md new file mode 100644 index 0000000..5a13041 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_classification_professional.md @@ -0,0 +1,305 @@ +# 30 分钟玩转 PaddleClas(进阶版) + +此处提供了专业用户在 linux 操作系统上使用 PaddleClas 的快速上手教程,主要内容基于 CIFAR-100 数据集,快速体验不同模型的训练、加载不同预训练模型、SSLD 知识蒸馏方案和数据增广的效果。请事先参考[安装指南](../installation/install_paddleclas.md)配置运行环境和克隆 PaddleClas 代码。 + +------ + +## 目录 + +- [1. 数据和模型准备](#1) + - [1.1 数据准备](#1.1) + - [1.1.1 准备 CIFAR100](#1.1.1) +- [2. 模型训练](#2) + - [2.1 单标签训练](#2.1) + - [2.1.1 零基础训练:不加载预训练模型的训练](#2.1.1) + - [2.1.2 迁移学习](#2.1.2) +- [3. 数据增广](#3) + - [3.1 数据增广的尝试-Mixup](#3.1) +- [4. 知识蒸馏](#4) +- [5. 模型评估与推理](#5) + - [5.1 单标签分类模型评估与推理](#5.1) + - [5.1.1 单标签分类模型评估](#5.1.1) + - [5.1.2 单标签分类模型预测](#5.1.2) + - [5.1.3 单标签分类使用 inference 模型进行模型推理](#5.1.3) + + + +## 1. 数据和模型准备 + + + +### 1.1 数据准备 + + +* 进入 PaddleClas 目录。 + +``` +cd path_to_PaddleClas +``` + + + +#### 1.1.1 准备 CIFAR100 + +* 进入 `dataset/` 目录,下载并解压 CIFAR100 数据集。 + +```shell +cd dataset +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/CIFAR100.tar +tar -xf CIFAR100.tar +cd ../ +``` + + + +## 2. 模型训练 + + + +### 2.1 单标签训练 + + + +#### 2.1.1 零基础训练:不加载预训练模型的训练 + +* 基于 ResNet50_vd 模型,训练脚本如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" +``` + +验证集的最高准确率为 0.415 左右。 + + + + +#### 2.1.2 迁移学习 + +* 基于 ImageNet1k 分类预训练模型 ResNet50_vd_pretrained(准确率 79.12%)进行微调,训练脚本如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" \ + -o Arch.pretrained=True +``` + +验证集最高准确率为 0.718 左右,加载预训练模型之后,CIFAR100 数据集精度大幅提升,绝对精度涨幅 30%。 + +* 基于 ImageNet1k 分类预训练模型 ResNet50_vd_ssld_pretrained(准确率 82.39%)进行微调,训练脚本如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" \ + -o Arch.pretrained=True \ + -o Arch.use_ssld=True +``` + +最终 CIFAR100 验证集上精度指标为 0.73,相对于 79.12% 预训练模型的微调结构,新数据集指标可以再次提升 1.2%。 + +* 替换 backbone 为 MobileNetV3_large_x1_0 进行微调,训练脚本如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV3_large_x1_0_CIFAR100_finetune.yaml \ + -o Global.output_dir="output_CIFAR" \ + -o Arch.pretrained=True +``` + +验证集最高准确率为 0.601 左右, 较 ResNet50_vd 低近 12%。 + + + + +## 3. 数据增广 + +PaddleClas 包含了很多数据增广的方法,如 Mixup、Cutout、RandomErasing 等,具体的方法可以参考[数据增广的章节](../algorithm_introduction/DataAugmentation.md)。 + + + +### 3.1 数据增广的尝试-Mixup + +基于[数据增广的章节](../algorithm_introduction/DataAugmentation.md) `3.3 节` 中的训练方法,结合 Mixup 的数据增广方式进行训练,具体的训练脚本如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_mixup_CIFAR100_finetune.yaml \ + -o Global.output_dir="output_CIFAR" + +``` + +最终 CIFAR100 验证集上的精度为 0.73,使用数据增广可以使得模型精度再次提升约 1.2%。 + + + +* **注意** + + * 其他数据增广的配置文件可以参考 `ppcls/configs/ImageNet/DataAugment/` 中的配置文件。 +* 训练 CIFAR100 的迭代轮数较少,因此进行训练时,验证集的精度指标可能会有 1% 左右的波动。 + + + + +## 4. 知识蒸馏 + + +PaddleClas 包含了自研的 SSLD 知识蒸馏方案,具体的内容可以参考[知识蒸馏章节](../algorithm_introduction/knowledge_distillation.md), 本小节将尝试使用知识蒸馏技术对 MobileNetV3_large_x1_0 模型进行训练,使用 `2.1.2 小节` 训练得到的 ResNet50_vd 模型作为蒸馏所用的教师模型,首先将 `2.1.2 小节` 训练得到的 ResNet50_vd 模型保存到指定目录,脚本如下。 + +```shell +mkdir pretrained +cp -r output_CIFAR/ResNet50_vd/best_model.pdparams ./pretrained/ +``` + +配置文件中模型名字、教师模型和学生模型的配置、预训练地址配置以及 freeze_params 配置如下,其中 `freeze_params_list` 中的两个值分别代表教师模型和学生模型是否冻结参数训练。 + +```yaml +Arch: + name: "DistillationModel" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - True + - False + models: + - Teacher: + name: ResNet50_vd + pretrained: "./pretrained/best_model" + - Student: + name: MobileNetV3_large_x1_0 + pretrained: True +``` + +Loss 配置如下,其中训练 Loss 是学生模型的输出和教师模型的输出的交叉熵、验证 Loss 是学生模型的输出和真实标签的交叉熵。 + +```yaml +Loss: + Train: + - DistillationCELoss: + weight: 1.0 + model_name_pairs: + - ["Student", "Teacher"] + Eval: + - DistillationGTCELoss: + weight: 1.0 + model_names: ["Student"] +``` + +最终的训练脚本如下所示。 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/R50_vd_distill_MV3_large_x1_0_CIFAR100.yaml \ + -o Global.output_dir="output_CIFAR" + +``` + +最终 CIFAR100 验证集上的精度为 64.4%,使用教师模型进行知识蒸馏,MobileNetV3 的精度涨幅 4.3%。 + +* **注意** + + * 蒸馏过程中,教师模型使用的预训练模型为 CIFAR100 数据集上的训练结果,学生模型使用的是 ImageNet1k 数据集上精度为 75.32% 的 MobileNetV3_large_x1_0 预训练模型。 + * 该蒸馏过程无须使用真实标签,所以可以使用更多的无标签数据,在使用过程中,可以将无标签数据生成假的 `train_list.txt`,然后与真实的 `train_list.txt` 进行合并, 用户可以根据自己的数据自行体验。 + + + +## 5. 模型评估与推理 + + + +### 5.1 单标签分类模型评估与推理 + + + +#### 5.1.1 单标签分类模型评估。 + +训练好模型之后,可以通过以下命令实现对模型精度的评估。 + +```bash +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.pretrained_model="output_CIFAR/ResNet50_vd/best_model" +``` + + + +#### 5.1.2 单标签分类模型预测 + +模型训练完成之后,可以加载训练得到的预训练模型,进行模型预测。在模型库的 `tools/infer.py` 中提供了完整的示例,只需执行下述命令即可完成模型预测: + +```python +python3 tools/infer.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Infer.infer_imgs=./dataset/CIFAR100/test/0/0001.png \ + -o Global.pretrained_model=output_CIFAR/ResNet50_vd/best_model +``` + + + +#### 5.1.3 单标签分类使用 inference 模型进行模型推理 + +通过导出 inference 模型,PaddlePaddle 支持使用预测引擎进行预测推理。接下来介绍如何用预测引擎进行推理: +首先,对训练好的模型进行转换: + +```bash +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml \ + -o Global.pretrained_model=output_CIFAR/ResNet50_vd/best_model +``` + +* 默认会在 `inference` 文件夹下生成 `inference.pdiparams`、`inference.pdmodel` 和 `inference.pdiparams.info` 文件。 + +使用预测引擎进行推理: + +进入 deploy 目录下: + +```bash +cd deploy +``` + +更改 `inference_cls.yaml` 文件,由于训练 CIFAR100 采用的分辨率是 32x32,所以需要改变相关的分辨率,最终配置文件中的图像预处理如下: + +```yaml +PreProcess: + transform_ops: + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: +``` + +执行命令进行预测,由于默认 `class_id_map_file` 是 ImageNet 数据集的映射文件,所以此处需要置 None。 + +```bash +python3 python/predict_cls.py \ + -c configs/inference_cls.yaml \ + -o Global.infer_imgs=../dataset/CIFAR100/test/0/0001.png \ + -o PostProcess.Topk.class_id_map_file=None +``` diff --git a/src/PaddleClas/docs/zh_CN/quick_start/quick_start_multilabel_classification.md b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_multilabel_classification.md new file mode 100644 index 0000000..888a615 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_multilabel_classification.md @@ -0,0 +1,109 @@ +# 多标签分类 quick start + +基于 [NUS-WIDE-SCENE](https://lms.comp.nus.edu.sg/wp-content/uploads/2019/research/nuswide/NUS-WIDE.html) 数据集,体验多标签分类的训练、评估、预测的过程,该数据集是 NUS-WIDE 数据集的一个子集。请首先安装 PaddlePaddle 和 PaddleClas,具体安装步骤可详看 [Paddle 安装文档](../installation/install_paddle.md),[PaddleClas 安装文档](../installation/install_paddleclas.md)。 + + +## 目录 + +* [1. 数据和模型准备](#1) +* [2. 模型训练](#2) +* [3. 模型评估](#3) +* [4. 模型预测](#4) +* [5. 基于预测引擎预测](#5) + * [5.1 导出 inference model](#5.1) + * [5.2 基于预测引擎预测](#5.2) + + +## 1. 数据和模型准备 + +* 进入 `PaddleClas` 目录。 + +``` +cd path_to_PaddleClas +``` + +* 创建并进入 `dataset/NUS-WIDE-SCENE` 目录,下载并解压 NUS-WIDE-SCENE 数据集。 + +```shell +mkdir dataset/NUS-WIDE-SCENE +cd dataset/NUS-WIDE-SCENE +wget https://paddle-imagenet-models-name.bj.bcebos.com/data/NUS-SCENE-dataset.tar +tar -xf NUS-SCENE-dataset.tar +``` + +* 返回 `PaddleClas` 根目录 + +``` +cd ../../ +``` + + +## 2. 模型训练 + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml +``` + +训练 10 epoch 之后,验证集最好的正确率应该在 0.95 左右。 + + + +## 3. 模型评估 + +```bash +python3 tools/eval.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + + +## 4. 模型预测 + +```bash +python3 tools/infer.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` + +得到类似下面的输出: +``` +[{'class_ids': [6, 13, 17, 23, 26, 30], 'scores': [0.95683, 0.5567, 0.55211, 0.99088, 0.5943, 0.78767], 'file_name': './deploy/images/0517_2715693311.jpg', 'label_names': []}] +``` + + +## 5. 基于预测引擎预测 + + +### 5.1 导出 inference model + +```bash +python3 tools/export_model.py \ + -c ./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml \ + -o Arch.pretrained="./output/MobileNetV1/best_model" +``` +inference model 的路径默认在当前路径下 `./inference` + + +### 5.2 基于预测引擎预测 + +首先进入 `deploy` 目录下: + +```bash +cd ./deploy +``` + +通过预测引擎推理预测: + +``` +python3 python/predict_cls.py \ + -c configs/inference_multilabel_cls.yaml +``` + +得到类似下面的输出: +``` +0517_2715693311.jpg: class id(s): [6, 13, 17, 23, 26, 30], score(s): [0.96, 0.56, 0.55, 0.99, 0.59, 0.79], label_name(s): [] +``` diff --git a/src/PaddleClas/docs/zh_CN/quick_start/quick_start_recognition.md b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_recognition.md new file mode 100644 index 0000000..e2e6b16 --- /dev/null +++ b/src/PaddleClas/docs/zh_CN/quick_start/quick_start_recognition.md @@ -0,0 +1,334 @@ +# 图像识别快速开始 + +本文档包含 3 个部分:环境配置、图像识别体验、未知类别的图像识别体验。 + +如果图像类别已经存在于图像索引库中,那么可以直接参考[图像识别体验](#图像识别体验)章节,完成图像识别过程;如果希望识别未知类别的图像,即图像类别之前不存在于索引库中,那么可以参考[未知类别的图像识别体验](#未知类别的图像识别体验)章节,完成建立索引并识别的过程。 + +## 目录 + +* [1. 环境配置](#环境配置) +* [2. 图像识别体验](#图像识别体验) + * [2.1 下载、解压 inference 模型与 demo 数据](#2.1) + * [2.2 瓶装饮料识别与检索](#瓶装饮料识别与检索) + * [2.2.1 识别单张图像](#识别单张图像) + * [2.2.2 基于文件夹的批量识别](#基于文件夹的批量识别) +* [3. 未知类别的图像识别体验](#未知类别的图像识别体验) + * [3.1 准备新的数据与标签](#准备新的数据与标签) + * [3.2 建立新的索引库](#建立新的索引库) + * [3.3 基于新的索引库的图像识别](#基于新的索引库的图像识别) +* [4. 服务端识别模型列表](#4) + + + +## 1. 环境配置 + +* 安装:请先参考 [Paddle 安装教程](../installation/install_paddle.md) 以及 [PaddleClas 安装教程](../installation/install_paddleclas.md) 配置 PaddleClas 运行环境。 + +* 进入 `deploy` 运行目录。本部分所有内容与命令均需要在 `deploy` 目录下运行,可以通过下面的命令进入 `deploy` 目录。 + + ``` + cd deploy + ``` + + + +## 2. 图像识别体验 + +轻量级通用主体检测模型与轻量级通用识别模型和配置文件下载方式如下表所示。 + + + +| 模型简介 | 推荐场景 | inference 模型 | 预测配置文件 | +| ------------ | ------------- | -------- | ------- | +| 轻量级通用主体检测模型 | 通用场景 |[tar 格式下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.zip) | - | +| 轻量级通用识别模型 | 通用场景 | [tar 格式下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.zip) | [inference_general.yaml](../../../deploy/configs/inference_general.yaml) | +| 轻量级通用识别二值模型 | 检索库很大, 存储受限场景 | [tar 格式下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_binary_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_binary_v1.0_infer.zip)| [inference_general_binary.yaml](../../../deploy/configs/inference_general_binary.yaml) | + +注意:由于部分解压缩软件在解压上述 `tar` 格式文件时存在问题,建议非命令行用户下载 `zip` 格式文件并解压。`tar` 格式文件建议使用命令 `tar xf xxx.tar` 解压。 + +本章节 demo 数据下载地址如下: [瓶装饮料数据下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar)。 + + +如果希望体验服务端主体检测和各垂类方向的识别模型,可以参考[第4章](#4)。 + +**注意** + +1. windows 环境下如果没有安装 wget, 可以按照下面的步骤安装 wget 与 tar 命令,也可以在下载模型时将链接复制到浏览器中下载,并解压放置在相应目录下; linux 或者 macOS 用户可以右键点击,然后复制下载链接,即可通过 `wget` 命令下载。 +2. 如果 macOS 环境下没有安装 `wget` 命令,可以运行下面的命令进行安装。 + +```shell +# 安装 homebrew +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; +# 安装 wget +brew install wget +``` + +4. 如果希望在 windows 环境下安装 wget,可以参考:[链接](https://www.cnblogs.com/jeshy/p/10518062.html);如果希望在 windows 环境中安装 tar 命令,可以参考:[链接](https://www.cnblogs.com/chooperman/p/14190107.html)。 + + +* 可以按照下面的命令下载并解压数据与模型 + +```shell +mkdir models +cd models +# 下载识别 inference 模型并解压 +wget {模型下载链接地址} && tar -xf {压缩包的名称} +cd .. + +# 下载 demo 数据并解压 +wget {数据下载链接地址} && tar -xf {压缩包的名称} +``` + + + +### 2.1 下载、解压 inference 模型与 demo 数据 + +下载 demo 数据集以及轻量级主体检测、识别模型,命令如下。 + +```shell +mkdir models +cd models +# 下载通用检测 inference 模型并解压 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar && tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar +# 下载识别 inference 模型并解压 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar && tar -xf general_PPLCNet_x2_5_lite_v1.0_infer.tar + +cd ../ +# 下载 demo 数据并解压 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar && tar -xf drink_dataset_v1.0.tar +``` + +解压完毕后,`drink_dataset_v1.0/` 文件夹下应有如下文件结构: + +``` +├── drink_dataset_v1.0/ +│ ├── gallery/ +│ ├── index/ +│ ├── test_images/ +├── ... +``` + +其中 `gallery` 文件夹中存放的是用于构建索引库的原始图像,`index` 表示基于原始图像构建得到的索引库信息,`test_images` 文件夹中存放的是用于测试识别效果的图像列表。 + + +`models` 文件夹下应有如下文件结构: + +``` +├── general_PPLCNet_x2_5_lite_v1.0_infer +│ ├── inference.pdiparams +│ ├── inference.pdiparams.info +│ └── inference.pdmodel +├── picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer +│ ├── inference.pdiparams +│ ├── inference.pdiparams.info +│ └── inference.pdmodel +``` + +**注意** + +如果使用服务端通用识别模型,Demo 数据需要重新提取特征、够建索引,方式如下: + +```shell +# 下面是使用下载的服务端商品识别模型进行索引库构建 +python3.7 python/build_gallery.py -c configs/inference_general.yaml -o Global.rec_inference_model_dir=./models/general_PPLCNet_x2_5_lite_v1.0_infer +``` + + + +### 2.2 瓶装饮料识别与检索 + +以瓶装饮料识别 demo 为例,展示识别与检索过程(如果希望尝试其他方向的识别与检索效果,在下载解压好对应的 demo 数据与模型之后,替换对应的配置文件即可完成预测)。 + +注意,此部分使用了 `faiss` 作为检索库,安装方法如下: + +```python +pip install faiss-cpu==1.7.1post2 +``` + +若使用时,不能正常引用,则 `uninstall` 之后,重新 `install`,尤其是 windows 下。 + + + +#### 2.2.1 识别单张图像 + +运行下面的命令,对图像 `./drink_dataset_v1.0/test_images/nongfu_spring.jpeg` 进行识别与检索 + +```shell +# 使用下面的命令使用 GPU 进行预测 +python3.7 python/predict_system.py -c configs/inference_general.yaml +# 使用下面的命令使用 CPU 进行预测 +python3.7 python/predict_system.py -c configs/inference_general.yaml -o Global.use_gpu=False +``` + +待检索图像如下所示。 + +![](../../images/recognition/drink_data_demo/test_images/nongfu_spring.jpeg) + + +最终输出结果如下。 + +``` +[{'bbox': [244, 49, 509, 964], 'rec_docs': '农夫山泉-饮用天然水', 'rec_scores': 0.7585664}] +``` + +其中 `bbox` 表示检测出的主体所在位置,`rec_docs` 表示索引库中与检测框最为相似的类别,`rec_scores` 表示对应的置信度。 + +检测的可视化结果也保存在 `output` 文件夹下,对于本张图像,识别结果可视化如下所示。 + +![](../../images/recognition/drink_data_demo/output/nongfu_spring.jpeg) + + + +#### 2.2.2 基于文件夹的批量识别 + +如果希望预测文件夹内的图像,可以直接修改配置文件中的 `Global.infer_imgs` 字段,也可以通过下面的 `-o` 参数修改对应的配置。 + +```shell +# 使用下面的命令使用 GPU 进行预测,如果希望使用 CPU 预测,可以在命令后面添加 -o Global.use_gpu=False +python3.7 python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs="./drink_dataset_v1.0/test_images/" +``` + +终端中会输出该文件夹内所有图像的识别结果,如下所示。 + +``` +... +[{'bbox': [345, 95, 524, 586], 'rec_docs': '红牛-强化型', 'rec_scores': 0.80164653}] +Inference: 23.43583106994629 ms per batch image +[{'bbox': [233, 0, 372, 436], 'rec_docs': '康师傅矿物质水', 'rec_scores': 0.72513914}] +Inference: 117.95639991760254 ms per batch image +[{'bbox': [138, 40, 573, 1198], 'rec_docs': '乐虎功能饮料', 'rec_scores': 0.7855944}] +Inference: 22.172927856445312 ms per batch image +[{'bbox': [328, 7, 467, 272], 'rec_docs': '脉动', 'rec_scores': 0.5829516}] +Inference: 118.08514595031738 ms per batch image +[{'bbox': [242, 82, 498, 726], 'rec_docs': '味全_每日C', 'rec_scores': 0.75581443}] +Inference: 150.06470680236816 ms per batch image +[{'bbox': [437, 71, 660, 728], 'rec_docs': '元气森林', 'rec_scores': 0.8478892}, {'bbox': [221, 72, 449, 701], 'rec_docs': '元气森林', 'rec_scores': 0.6790612}, {'bbox': [794, 104, 979, 652], 'rec_docs': '元气森林', 'rec_scores': 0.6292581}] +... +``` + +所有图像的识别结果可视化图像也保存在 `output` 文件夹内。 + + +更多地,可以通过修改 `Global.rec_inference_model_dir` 字段来更改识别 inference 模型的路径,通过修改 `IndexProcess.index_dir` 字段来更改索引库索引的路径。 + + + +## 3. 未知类别的图像识别体验 + +对图像 `./drink_dataset_v1.0/test_images/mosilian.jpeg` 进行识别,命令如下 + +```shell +# 使用下面的命令使用 GPU 进行预测,如果希望使用 CPU 预测,可以在命令后面添加 -o Global.use_gpu=False +python3.7 python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs="./drink_dataset_v1.0/test_images/mosilian.jpeg" +``` + +待检索图像如下所示。 + +![](../../images/recognition/drink_data_demo/test_images/mosilian.jpeg) + + +输出结果为空。 + +由于默认的索引库中不包含对应的索引信息,所以这里的识别结果有误,此时我们可以通过构建新的索引库的方式,完成未知类别的图像识别。 + +当索引库中的图像无法覆盖我们实际识别的场景时,即在预测未知类别的图像时,我们需要将对应类别的相似图像添加到索引库中,从而完成对未知类别的图像识别,这一过程是不需要重新训练的。 + + + +### 3.1 准备新的数据与标签 + +首先需要将与待检索图像相似的图像列表拷贝到索引库原始图像的文件夹。这里 PaddleClas 已经将所有的图像数据都放在文件夹 `drink_dataset_v1.0/gallery/` 中。 + +然后需要编辑记录了图像路径和标签信息的文本文件,这里 PaddleClas 将更正后的标签信息文件放在了 `drink_dataset_v1.0/gallery/drink_label_all.txt` 文件中。可以与默认的 `drink_dataset_v1.0/gallery/drink_label.txt` 标签文件进行对比,添加了光明和三元系列牛奶的索引图像。 + + +每一行的文本中,第一个字段表示图像的相对路径,第二个字段表示图像对应的标签信息,中间用 `\t` 键分隔开(注意:有些编辑器会将 `tab` 自动转换为 `空格`,这种情况下会导致文件解析报错)。 + + + +### 3.2 建立新的索引库 + +使用下面的命令构建 `index` 索引,加速识别后的检索过程。 + +```shell +python3.7 python/build_gallery.py -c configs/inference_general.yaml -o IndexProcess.data_file="./drink_dataset_v1.0/gallery/drink_label_all.txt" -o IndexProcess.index_dir="./drink_dataset_v1.0/index_all" +``` + +最终新的索引信息保存在文件夹 `./drink_dataset_v1.0/index_all` 中。具体 `yaml` 请参考[向量检索文档](../image_recognition_pipeline/vector_search.md)。 + + + +### 3.3 基于新的索引库的图像识别 + +使用新的索引库,对上述图像进行识别,运行命令如下。 + +```shell +# 使用下面的命令使用 GPU 进行预测,如果希望使用 CPU 预测,可以在命令后面添加 -o Global.use_gpu=False +python3.7 python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs="././drink_dataset_v1.0/test_images/mosilian.jpeg" -o IndexProcess.index_dir="./drink_dataset_v1.0/index_all" +``` + +输出结果如下。 + +``` +[{'bbox': [396, 553, 508, 621], 'rec_docs': '光明_莫斯利安', 'rec_scores': 0.5921005}] +``` + +最终识别结果为`光明_莫斯利安`,识别正确,识别结果可视化如下所示。 + +![](../../images/recognition/drink_data_demo/output/mosilian.jpeg) + + + +## 4. 服务端识别模型列表 + +目前,我们更推荐您使用[轻量级通用主体检测模型与轻量级通用识别模型](#轻量级通用主体检测模型与轻量级通用识别模型),以获得更好的测试结果。但是如果您希望体验服务端识别模型,服务器端通用主体检测模型与各方向识别模型、测试数据下载地址以及对应的配置文件地址如下。 + +| 模型简介 | 推荐场景 | inference 模型 | 预测配置文件 | +| ------------ | ------------- | -------- | ------- | +| 通用主体检测模型 | 通用场景 |[模型下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar) | - | +| Logo 识别模型 | Logo 场景 | [模型下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/logo_rec_ResNet50_Logo3K_v1.0_infer.tar) | [inference_logo.yaml](../../../deploy/configs/inference_logo.yaml) | +| 动漫人物识别模型 | 动漫人物场景 | [模型下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/cartoon_rec_ResNet50_iCartoon_v1.0_infer.tar) | [inference_cartoon.yaml](../../../deploy/configs/inference_cartoon.yaml) | +| 车辆细分类模型 | 车辆场景 | [模型下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/vehicle_cls_ResNet50_CompCars_v1.0_infer.tar) | [inference_vehicle.yaml](../../../deploy/configs/inference_vehicle.yaml) | +| 商品识别模型 | 商品场景 | [模型下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_aliproduct_v1.0_infer.tar) | [inference_product.yaml](../../../deploy/configs/inference_product.yaml) | +| 车辆 ReID 模型 | 车辆 ReID 场景 | [模型下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/vehicle_reid_ResNet50_VERIWild_v1.0_infer.tar) | [inference_vehicle.yaml](../../../deploy/configs/inference_vehicle.yaml) | + +```shell +cd PaddleClas/deploy/ +mkdir -p models +``` + +```shell +cd ./models +# 下载通用主体检测模型并解压 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar && tar -xf ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar +# 下载识别模型并解压 +wget {识别模型下载链接地址} && tar -xf {压缩包的名称} +``` + +使用如下命令下载各方向识别模型的测试数据: + +```shell +# 回到 deploy 目录下 +cd .. +# 下载测试数据并解压 +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.1.tar && tar -xf recognition_demo_data_en_v1.1.tar +``` + +解压完毕后,`recognition_demo_data_v1.1` 文件夹下应有如下文件结构: + +``` +├── recognition_demo_data_v1.1 +│ ├── gallery_cartoon +│ ├── gallery_logo +│ ├── gallery_product +│ ├── gallery_vehicle +│ ├── test_cartoon +│ ├── test_logo +│ ├── test_product +│ └── test_vehicle +├── ... +``` + +按照上述步骤下载模型和测试数据后,您可以进行相关方向识别模型的测试。 + +* 更多关于主体检测的介绍可以参考:[主体检测教程文档](../image_recognition_pipeline/mainbody_detection.md);关于特征提取的介绍可以参考:[特征提取教程文档](../image_recognition_pipeline/feature_extraction.md);关于向量检索的介绍可以参考:[向量检索教程文档](../image_recognition_pipeline/vector_search.md)。 diff --git a/src/PaddleClas/hubconf.py b/src/PaddleClas/hubconf.py new file mode 100644 index 0000000..b7f7674 --- /dev/null +++ b/src/PaddleClas/hubconf.py @@ -0,0 +1,788 @@ +# Copyright (c) 2021 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. + +dependencies = ['paddle'] + +import paddle +import os +import sys + + +class _SysPathG(object): + """ + _SysPathG used to add/clean path for sys.path. Making sure minimal pkgs dependents by skiping parent dirs. + + __enter__ + add path into sys.path + __exit__ + clean user's sys.path to avoid unexpect behaviors + """ + + def __init__(self, path): + self.path = path + + def __enter__(self, ): + sys.path.insert(0, self.path) + + def __exit__(self, type, value, traceback): + _p = sys.path.pop(0) + assert _p == self.path, 'Make sure sys.path cleaning {} correctly.'.format( + self.path) + + +with _SysPathG(os.path.dirname(os.path.abspath(__file__)), ): + import ppcls + import ppcls.arch.backbone as backbone + + def ppclas_init(): + if ppcls.utils.logger._logger is None: + ppcls.utils.logger.init_logger() + + ppclas_init() + + def _load_pretrained_parameters(model, name): + url = 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/{}_pretrained.pdparams'.format( + name) + path = paddle.utils.download.get_weights_path_from_url(url) + model.set_state_dict(paddle.load(path)) + return model + + def alexnet(pretrained=False, **kwargs): + """ + AlexNet + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `AlexNet` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.AlexNet(**kwargs) + + return model + + def vgg11(pretrained=False, **kwargs): + """ + VGG11 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False` + Returns: + model: nn.Layer. Specific `VGG11` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.VGG11(**kwargs) + + return model + + def vgg13(pretrained=False, **kwargs): + """ + VGG13 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False` + Returns: + model: nn.Layer. Specific `VGG13` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.VGG13(**kwargs) + + return model + + def vgg16(pretrained=False, **kwargs): + """ + VGG16 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False` + Returns: + model: nn.Layer. Specific `VGG16` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.VGG16(**kwargs) + + return model + + def vgg19(pretrained=False, **kwargs): + """ + VGG19 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False` + Returns: + model: nn.Layer. Specific `VGG19` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.VGG19(**kwargs) + + return model + + def resnet18(pretrained=False, **kwargs): + """ + ResNet18 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + input_image_channel: int=3. The number of input image channels + data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC') + Returns: + model: nn.Layer. Specific `ResNet18` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNet18(**kwargs) + + return model + + def resnet34(pretrained=False, **kwargs): + """ + ResNet34 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + input_image_channel: int=3. The number of input image channels + data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC') + Returns: + model: nn.Layer. Specific `ResNet34` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNet34(**kwargs) + + return model + + def resnet50(pretrained=False, **kwargs): + """ + ResNet50 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + input_image_channel: int=3. The number of input image channels + data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC') + Returns: + model: nn.Layer. Specific `ResNet50` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNet50(**kwargs) + + return model + + def resnet101(pretrained=False, **kwargs): + """ + ResNet101 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + input_image_channel: int=3. The number of input image channels + data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC') + Returns: + model: nn.Layer. Specific `ResNet101` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNet101(**kwargs) + + return model + + def resnet152(pretrained=False, **kwargs): + """ + ResNet152 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + input_image_channel: int=3. The number of input image channels + data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC') + Returns: + model: nn.Layer. Specific `ResNet152` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNet152(**kwargs) + + return model + + def squeezenet1_0(pretrained=False, **kwargs): + """ + SqueezeNet1_0 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `SqueezeNet1_0` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.SqueezeNet1_0(**kwargs) + + return model + + def squeezenet1_1(pretrained=False, **kwargs): + """ + SqueezeNet1_1 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `SqueezeNet1_1` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.SqueezeNet1_1(**kwargs) + + return model + + def densenet121(pretrained=False, **kwargs): + """ + DenseNet121 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + dropout: float=0. Probability of setting units to zero. + bn_size: int=4. The number of channals per group + Returns: + model: nn.Layer. Specific `DenseNet121` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.DenseNet121(**kwargs) + + return model + + def densenet161(pretrained=False, **kwargs): + """ + DenseNet161 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + dropout: float=0. Probability of setting units to zero. + bn_size: int=4. The number of channals per group + Returns: + model: nn.Layer. Specific `DenseNet161` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.DenseNet161(**kwargs) + + return model + + def densenet169(pretrained=False, **kwargs): + """ + DenseNet169 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + dropout: float=0. Probability of setting units to zero. + bn_size: int=4. The number of channals per group + Returns: + model: nn.Layer. Specific `DenseNet169` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.DenseNet169(**kwargs) + + return model + + def densenet201(pretrained=False, **kwargs): + """ + DenseNet201 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + dropout: float=0. Probability of setting units to zero. + bn_size: int=4. The number of channals per group + Returns: + model: nn.Layer. Specific `DenseNet201` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.DenseNet201(**kwargs) + + return model + + def densenet264(pretrained=False, **kwargs): + """ + DenseNet264 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + dropout: float=0. Probability of setting units to zero. + bn_size: int=4. The number of channals per group + Returns: + model: nn.Layer. Specific `DenseNet264` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.DenseNet264(**kwargs) + + return model + + def inceptionv3(pretrained=False, **kwargs): + """ + InceptionV3 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `InceptionV3` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.InceptionV3(**kwargs) + + return model + + def inceptionv4(pretrained=False, **kwargs): + """ + InceptionV4 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `InceptionV4` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.InceptionV4(**kwargs) + + return model + + def googlenet(pretrained=False, **kwargs): + """ + GoogLeNet + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `GoogLeNet` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.GoogLeNet(**kwargs) + + return model + + def shufflenetv2_x0_25(pretrained=False, **kwargs): + """ + ShuffleNetV2_x0_25 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ShuffleNetV2_x0_25` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ShuffleNetV2_x0_25(**kwargs) + + return model + + def mobilenetv1(pretrained=False, **kwargs): + """ + MobileNetV1 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV1` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV1(**kwargs) + + return model + + def mobilenetv1_x0_25(pretrained=False, **kwargs): + """ + MobileNetV1_x0_25 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV1_x0_25` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV1_x0_25(**kwargs) + + return model + + def mobilenetv1_x0_5(pretrained=False, **kwargs): + """ + MobileNetV1_x0_5 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV1_x0_5` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV1_x0_5(**kwargs) + + return model + + def mobilenetv1_x0_75(pretrained=False, **kwargs): + """ + MobileNetV1_x0_75 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV1_x0_75` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV1_x0_75(**kwargs) + + return model + + def mobilenetv2_x0_25(pretrained=False, **kwargs): + """ + MobileNetV2_x0_25 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV2_x0_25` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV2_x0_25(**kwargs) + + return model + + def mobilenetv2_x0_5(pretrained=False, **kwargs): + """ + MobileNetV2_x0_5 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV2_x0_5` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV2_x0_5(**kwargs) + + return model + + def mobilenetv2_x0_75(pretrained=False, **kwargs): + """ + MobileNetV2_x0_75 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV2_x0_75` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV2_x0_75(**kwargs) + + return model + + def mobilenetv2_x1_5(pretrained=False, **kwargs): + """ + MobileNetV2_x1_5 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV2_x1_5` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV2_x1_5(**kwargs) + + return model + + def mobilenetv2_x2_0(pretrained=False, **kwargs): + """ + MobileNetV2_x2_0 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV2_x2_0` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV2_x2_0(**kwargs) + + return model + + def mobilenetv3_large_x0_35(pretrained=False, **kwargs): + """ + MobileNetV3_large_x0_35 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x0_35` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_large_x0_35(**kwargs) + + return model + + def mobilenetv3_large_x0_5(pretrained=False, **kwargs): + """ + MobileNetV3_large_x0_5 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x0_5` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_large_x0_5(**kwargs) + + return model + + def mobilenetv3_large_x0_75(pretrained=False, **kwargs): + """ + MobileNetV3_large_x0_75 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x0_75` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_large_x0_75(**kwargs) + + return model + + def mobilenetv3_large_x1_0(pretrained=False, **kwargs): + """ + MobileNetV3_large_x1_0 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x1_0` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_large_x1_0(**kwargs) + + return model + + def mobilenetv3_large_x1_25(pretrained=False, **kwargs): + """ + MobileNetV3_large_x1_25 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x1_25` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_large_x1_25(**kwargs) + + return model + + def mobilenetv3_small_x0_35(pretrained=False, **kwargs): + """ + MobileNetV3_small_x0_35 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x0_35` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_small_x0_35(**kwargs) + + return model + + def mobilenetv3_small_x0_5(pretrained=False, **kwargs): + """ + MobileNetV3_small_x0_5 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x0_5` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_small_x0_5(**kwargs) + + return model + + def mobilenetv3_small_x0_75(pretrained=False, **kwargs): + """ + MobileNetV3_small_x0_75 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x0_75` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_small_x0_75(**kwargs) + + return model + + def mobilenetv3_small_x1_0(pretrained=False, **kwargs): + """ + MobileNetV3_small_x1_0 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x1_0` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_small_x1_0(**kwargs) + + return model + + def mobilenetv3_small_x1_25(pretrained=False, **kwargs): + """ + MobileNetV3_small_x1_25 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x1_25` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.MobileNetV3_small_x1_25(**kwargs) + + return model + + def resnext101_32x4d(pretrained=False, **kwargs): + """ + ResNeXt101_32x4d + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt101_32x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNeXt101_32x4d(**kwargs) + + return model + + def resnext101_64x4d(pretrained=False, **kwargs): + """ + ResNeXt101_64x4d + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt101_64x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNeXt101_64x4d(**kwargs) + + return model + + def resnext152_32x4d(pretrained=False, **kwargs): + """ + ResNeXt152_32x4d + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt152_32x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNeXt152_32x4d(**kwargs) + + return model + + def resnext152_64x4d(pretrained=False, **kwargs): + """ + ResNeXt152_64x4d + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt152_64x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNeXt152_64x4d(**kwargs) + + return model + + def resnext50_32x4d(pretrained=False, **kwargs): + """ + ResNeXt50_32x4d + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt50_32x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNeXt50_32x4d(**kwargs) + + return model + + def resnext50_64x4d(pretrained=False, **kwargs): + """ + ResNeXt50_64x4d + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt50_64x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.ResNeXt50_64x4d(**kwargs) + + return model + + def darknet53(pretrained=False, **kwargs): + """ + DarkNet53 + Args: + pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise. + kwargs: + class_dim: int=1000. Output dim of last fc layer. + Returns: + model: nn.Layer. Specific `ResNeXt50_64x4d` model depends on args. + """ + kwargs.update({'pretrained': pretrained}) + model = backbone.DarkNet53(**kwargs) + + return model diff --git a/src/PaddleClas/output/ResNet50_vd/infer.log b/src/PaddleClas/output/ResNet50_vd/infer.log new file mode 100644 index 0000000..2a4db87 --- /dev/null +++ b/src/PaddleClas/output/ResNet50_vd/infer.log @@ -0,0 +1,124 @@ +[2022/04/18 10:25:05] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:25:05] root INFO: Arch : +[2022/04/18 10:25:05] root INFO: class_num : 102 +[2022/04/18 10:25:05] root INFO: name : ResNet50_vd +[2022/04/18 10:25:05] root INFO: DataLoader : +[2022/04/18 10:25:05] root INFO: Eval : +[2022/04/18 10:25:05] root INFO: dataset : +[2022/04/18 10:25:05] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:25:05] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:25:05] root INFO: name : ImageNetDataset +[2022/04/18 10:25:05] root INFO: transform_ops : +[2022/04/18 10:25:05] root INFO: DecodeImage : +[2022/04/18 10:25:05] root INFO: channel_first : False +[2022/04/18 10:25:05] root INFO: to_rgb : True +[2022/04/18 10:25:05] root INFO: ResizeImage : +[2022/04/18 10:25:05] root INFO: resize_short : 256 +[2022/04/18 10:25:05] root INFO: CropImage : +[2022/04/18 10:25:05] root INFO: size : 224 +[2022/04/18 10:25:05] root INFO: NormalizeImage : +[2022/04/18 10:25:05] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:25:05] root INFO: order : +[2022/04/18 10:25:05] root INFO: scale : 1.0/255.0 +[2022/04/18 10:25:05] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:25:05] root INFO: loader : +[2022/04/18 10:25:05] root INFO: num_workers : 4 +[2022/04/18 10:25:05] root INFO: use_shared_memory : True +[2022/04/18 10:25:05] root INFO: sampler : +[2022/04/18 10:25:05] root INFO: batch_size : 64 +[2022/04/18 10:25:05] root INFO: drop_last : False +[2022/04/18 10:25:05] root INFO: name : DistributedBatchSampler +[2022/04/18 10:25:05] root INFO: shuffle : False +[2022/04/18 10:25:05] root INFO: Train : +[2022/04/18 10:25:05] root INFO: dataset : +[2022/04/18 10:25:05] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:25:05] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:25:05] root INFO: name : ImageNetDataset +[2022/04/18 10:25:05] root INFO: transform_ops : +[2022/04/18 10:25:05] root INFO: DecodeImage : +[2022/04/18 10:25:05] root INFO: channel_first : False +[2022/04/18 10:25:05] root INFO: to_rgb : True +[2022/04/18 10:25:05] root INFO: RandCropImage : +[2022/04/18 10:25:05] root INFO: size : 224 +[2022/04/18 10:25:05] root INFO: RandFlipImage : +[2022/04/18 10:25:05] root INFO: flip_code : 1 +[2022/04/18 10:25:05] root INFO: NormalizeImage : +[2022/04/18 10:25:05] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:25:05] root INFO: order : +[2022/04/18 10:25:05] root INFO: scale : 1.0/255.0 +[2022/04/18 10:25:05] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:25:05] root INFO: loader : +[2022/04/18 10:25:05] root INFO: num_workers : 4 +[2022/04/18 10:25:05] root INFO: use_shared_memory : True +[2022/04/18 10:25:05] root INFO: sampler : +[2022/04/18 10:25:05] root INFO: batch_size : 32 +[2022/04/18 10:25:05] root INFO: drop_last : False +[2022/04/18 10:25:05] root INFO: name : DistributedBatchSampler +[2022/04/18 10:25:05] root INFO: shuffle : True +[2022/04/18 10:25:05] root INFO: Global : +[2022/04/18 10:25:05] root INFO: checkpoints : None +[2022/04/18 10:25:05] root INFO: device : gpu +[2022/04/18 10:25:05] root INFO: epochs : 20 +[2022/04/18 10:25:05] root INFO: eval_during_train : True +[2022/04/18 10:25:05] root INFO: eval_interval : 1 +[2022/04/18 10:25:05] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:25:05] root INFO: output_dir : ./output/ +[2022/04/18 10:25:05] root INFO: pretrained_model : output/ResNet50_vd/best_model +[2022/04/18 10:25:05] root INFO: print_batch_step : 10 +[2022/04/18 10:25:05] root INFO: save_inference_dir : ./inference +[2022/04/18 10:25:05] root INFO: save_interval : 1 +[2022/04/18 10:25:05] root INFO: use_visualdl : False +[2022/04/18 10:25:05] root INFO: Infer : +[2022/04/18 10:25:05] root INFO: PostProcess : +[2022/04/18 10:25:05] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:25:05] root INFO: name : Topk +[2022/04/18 10:25:05] root INFO: topk : 5 +[2022/04/18 10:25:05] root INFO: batch_size : 10 +[2022/04/18 10:25:05] root INFO: infer_imgs : dataset/flowers102/jpg/image_00001.jpg +[2022/04/18 10:25:05] root INFO: transforms : +[2022/04/18 10:25:05] root INFO: DecodeImage : +[2022/04/18 10:25:05] root INFO: channel_first : False +[2022/04/18 10:25:05] root INFO: to_rgb : True +[2022/04/18 10:25:05] root INFO: ResizeImage : +[2022/04/18 10:25:05] root INFO: resize_short : 256 +[2022/04/18 10:25:05] root INFO: CropImage : +[2022/04/18 10:25:05] root INFO: size : 224 +[2022/04/18 10:25:05] root INFO: NormalizeImage : +[2022/04/18 10:25:05] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:25:05] root INFO: order : +[2022/04/18 10:25:05] root INFO: scale : 1.0/255.0 +[2022/04/18 10:25:05] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:25:05] root INFO: ToCHWImage : None +[2022/04/18 10:25:05] root INFO: Loss : +[2022/04/18 10:25:05] root INFO: Eval : +[2022/04/18 10:25:05] root INFO: CELoss : +[2022/04/18 10:25:05] root INFO: weight : 1.0 +[2022/04/18 10:25:05] root INFO: Train : +[2022/04/18 10:25:05] root INFO: CELoss : +[2022/04/18 10:25:05] root INFO: weight : 1.0 +[2022/04/18 10:25:05] root INFO: Metric : +[2022/04/18 10:25:05] root INFO: Eval : +[2022/04/18 10:25:05] root INFO: TopkAcc : +[2022/04/18 10:25:05] root INFO: topk : [1, 5] +[2022/04/18 10:25:05] root INFO: Train : +[2022/04/18 10:25:05] root INFO: TopkAcc : +[2022/04/18 10:25:05] root INFO: topk : [1, 5] +[2022/04/18 10:25:05] root INFO: Optimizer : +[2022/04/18 10:25:05] root INFO: lr : +[2022/04/18 10:25:05] root INFO: learning_rate : 0.0125 +[2022/04/18 10:25:05] root INFO: name : Cosine +[2022/04/18 10:25:05] root INFO: warmup_epoch : 5 +[2022/04/18 10:25:05] root INFO: momentum : 0.9 +[2022/04/18 10:25:05] root INFO: name : Momentum +[2022/04/18 10:25:05] root INFO: regularizer : +[2022/04/18 10:25:05] root INFO: coeff : 1e-05 +[2022/04/18 10:25:05] root INFO: name : L2 diff --git a/src/PaddleClas/output/ResNet50_vd/train.log b/src/PaddleClas/output/ResNet50_vd/train.log new file mode 100644 index 0000000..1fc4907 --- /dev/null +++ b/src/PaddleClas/output/ResNet50_vd/train.log @@ -0,0 +1,380 @@ +[2022/04/18 10:10:57] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:10:57] root INFO: Arch : +[2022/04/18 10:10:57] root INFO: class_num : 102 +[2022/04/18 10:10:57] root INFO: name : ResNet50_vd +[2022/04/18 10:10:57] root INFO: DataLoader : +[2022/04/18 10:10:57] root INFO: Eval : +[2022/04/18 10:10:57] root INFO: dataset : +[2022/04/18 10:10:57] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:10:57] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:10:57] root INFO: name : ImageNetDataset +[2022/04/18 10:10:57] root INFO: transform_ops : +[2022/04/18 10:10:58] root INFO: DecodeImage : +[2022/04/18 10:10:58] root INFO: channel_first : False +[2022/04/18 10:10:58] root INFO: to_rgb : True +[2022/04/18 10:10:58] root INFO: ResizeImage : +[2022/04/18 10:10:58] root INFO: resize_short : 256 +[2022/04/18 10:10:58] root INFO: CropImage : +[2022/04/18 10:10:58] root INFO: size : 224 +[2022/04/18 10:10:58] root INFO: NormalizeImage : +[2022/04/18 10:10:58] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:58] root INFO: order : +[2022/04/18 10:10:58] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:58] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:58] root INFO: loader : +[2022/04/18 10:10:58] root INFO: num_workers : 4 +[2022/04/18 10:10:58] root INFO: use_shared_memory : True +[2022/04/18 10:10:58] root INFO: sampler : +[2022/04/18 10:10:58] root INFO: batch_size : 64 +[2022/04/18 10:10:58] root INFO: drop_last : False +[2022/04/18 10:10:58] root INFO: name : DistributedBatchSampler +[2022/04/18 10:10:58] root INFO: shuffle : False +[2022/04/18 10:10:58] root INFO: Train : +[2022/04/18 10:10:58] root INFO: dataset : +[2022/04/18 10:10:58] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:10:58] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:10:58] root INFO: name : ImageNetDataset +[2022/04/18 10:10:58] root INFO: transform_ops : +[2022/04/18 10:10:58] root INFO: DecodeImage : +[2022/04/18 10:10:58] root INFO: channel_first : False +[2022/04/18 10:10:58] root INFO: to_rgb : True +[2022/04/18 10:10:58] root INFO: RandCropImage : +[2022/04/18 10:10:58] root INFO: size : 224 +[2022/04/18 10:10:58] root INFO: RandFlipImage : +[2022/04/18 10:10:58] root INFO: flip_code : 1 +[2022/04/18 10:10:58] root INFO: NormalizeImage : +[2022/04/18 10:10:58] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:58] root INFO: order : +[2022/04/18 10:10:58] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:58] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:58] root INFO: loader : +[2022/04/18 10:10:58] root INFO: num_workers : 4 +[2022/04/18 10:10:58] root INFO: use_shared_memory : True +[2022/04/18 10:10:58] root INFO: sampler : +[2022/04/18 10:10:58] root INFO: batch_size : 32 +[2022/04/18 10:10:58] root INFO: drop_last : False +[2022/04/18 10:10:58] root INFO: name : DistributedBatchSampler +[2022/04/18 10:10:58] root INFO: shuffle : True +[2022/04/18 10:10:58] root INFO: Global : +[2022/04/18 10:10:58] root INFO: checkpoints : None +[2022/04/18 10:10:58] root INFO: device : gpu +[2022/04/18 10:10:58] root INFO: epochs : 20 +[2022/04/18 10:10:58] root INFO: eval_during_train : True +[2022/04/18 10:10:58] root INFO: eval_interval : 1 +[2022/04/18 10:10:58] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:10:58] root INFO: output_dir : ./output/ +[2022/04/18 10:10:58] root INFO: pretrained_model : None +[2022/04/18 10:10:58] root INFO: print_batch_step : 10 +[2022/04/18 10:10:58] root INFO: save_inference_dir : ./inference +[2022/04/18 10:10:58] root INFO: save_interval : 1 +[2022/04/18 10:10:58] root INFO: use_visualdl : False +[2022/04/18 10:10:58] root INFO: Infer : +[2022/04/18 10:10:58] root INFO: PostProcess : +[2022/04/18 10:10:58] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:10:58] root INFO: name : Topk +[2022/04/18 10:10:58] root INFO: topk : 5 +[2022/04/18 10:10:58] root INFO: batch_size : 10 +[2022/04/18 10:10:58] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:10:58] root INFO: transforms : +[2022/04/18 10:10:58] root INFO: DecodeImage : +[2022/04/18 10:10:58] root INFO: channel_first : False +[2022/04/18 10:10:58] root INFO: to_rgb : True +[2022/04/18 10:10:58] root INFO: ResizeImage : +[2022/04/18 10:10:58] root INFO: resize_short : 256 +[2022/04/18 10:10:58] root INFO: CropImage : +[2022/04/18 10:10:58] root INFO: size : 224 +[2022/04/18 10:10:58] root INFO: NormalizeImage : +[2022/04/18 10:10:58] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:58] root INFO: order : +[2022/04/18 10:10:58] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:58] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:58] root INFO: ToCHWImage : None +[2022/04/18 10:10:58] root INFO: Loss : +[2022/04/18 10:10:58] root INFO: Eval : +[2022/04/18 10:10:58] root INFO: CELoss : +[2022/04/18 10:10:58] root INFO: weight : 1.0 +[2022/04/18 10:10:58] root INFO: Train : +[2022/04/18 10:10:58] root INFO: CELoss : +[2022/04/18 10:10:58] root INFO: weight : 1.0 +[2022/04/18 10:10:58] root INFO: Metric : +[2022/04/18 10:10:58] root INFO: Eval : +[2022/04/18 10:10:58] root INFO: TopkAcc : +[2022/04/18 10:10:58] root INFO: topk : [1, 5] +[2022/04/18 10:10:58] root INFO: Train : +[2022/04/18 10:10:58] root INFO: TopkAcc : +[2022/04/18 10:10:58] root INFO: topk : [1, 5] +[2022/04/18 10:10:58] root INFO: Optimizer : +[2022/04/18 10:10:58] root INFO: lr : +[2022/04/18 10:10:58] root INFO: learning_rate : 0.0125 +[2022/04/18 10:10:58] root INFO: name : Cosine +[2022/04/18 10:10:58] root INFO: warmup_epoch : 5 +[2022/04/18 10:10:58] root INFO: momentum : 0.9 +[2022/04/18 10:10:58] root INFO: name : Momentum +[2022/04/18 10:10:58] root INFO: regularizer : +[2022/04/18 10:10:58] root INFO: coeff : 1e-05 +[2022/04/18 10:10:58] root INFO: name : L2 +[2022/04/18 10:10:58] root INFO: profiler_options : None +[2022/04/18 10:11:26] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:11:26] root INFO: Arch : +[2022/04/18 10:11:26] root INFO: class_num : 102 +[2022/04/18 10:11:26] root INFO: name : ResNet50_vd +[2022/04/18 10:11:26] root INFO: pretrained : True +[2022/04/18 10:11:26] root INFO: DataLoader : +[2022/04/18 10:11:26] root INFO: Eval : +[2022/04/18 10:11:26] root INFO: dataset : +[2022/04/18 10:11:26] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:11:26] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:11:26] root INFO: name : ImageNetDataset +[2022/04/18 10:11:26] root INFO: transform_ops : +[2022/04/18 10:11:26] root INFO: DecodeImage : +[2022/04/18 10:11:26] root INFO: channel_first : False +[2022/04/18 10:11:26] root INFO: to_rgb : True +[2022/04/18 10:11:26] root INFO: ResizeImage : +[2022/04/18 10:11:26] root INFO: resize_short : 256 +[2022/04/18 10:11:26] root INFO: CropImage : +[2022/04/18 10:11:26] root INFO: size : 224 +[2022/04/18 10:11:26] root INFO: NormalizeImage : +[2022/04/18 10:11:26] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:11:26] root INFO: order : +[2022/04/18 10:11:26] root INFO: scale : 1.0/255.0 +[2022/04/18 10:11:26] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:11:26] root INFO: loader : +[2022/04/18 10:11:26] root INFO: num_workers : 4 +[2022/04/18 10:11:26] root INFO: use_shared_memory : True +[2022/04/18 10:11:26] root INFO: sampler : +[2022/04/18 10:11:26] root INFO: batch_size : 64 +[2022/04/18 10:11:26] root INFO: drop_last : False +[2022/04/18 10:11:26] root INFO: name : DistributedBatchSampler +[2022/04/18 10:11:26] root INFO: shuffle : False +[2022/04/18 10:11:26] root INFO: Train : +[2022/04/18 10:11:26] root INFO: dataset : +[2022/04/18 10:11:26] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:11:26] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:11:26] root INFO: name : ImageNetDataset +[2022/04/18 10:11:26] root INFO: transform_ops : +[2022/04/18 10:11:26] root INFO: DecodeImage : +[2022/04/18 10:11:26] root INFO: channel_first : False +[2022/04/18 10:11:26] root INFO: to_rgb : True +[2022/04/18 10:11:26] root INFO: RandCropImage : +[2022/04/18 10:11:26] root INFO: size : 224 +[2022/04/18 10:11:26] root INFO: RandFlipImage : +[2022/04/18 10:11:26] root INFO: flip_code : 1 +[2022/04/18 10:11:26] root INFO: NormalizeImage : +[2022/04/18 10:11:26] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:11:26] root INFO: order : +[2022/04/18 10:11:26] root INFO: scale : 1.0/255.0 +[2022/04/18 10:11:26] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:11:26] root INFO: loader : +[2022/04/18 10:11:26] root INFO: num_workers : 4 +[2022/04/18 10:11:26] root INFO: use_shared_memory : True +[2022/04/18 10:11:26] root INFO: sampler : +[2022/04/18 10:11:26] root INFO: batch_size : 32 +[2022/04/18 10:11:26] root INFO: drop_last : False +[2022/04/18 10:11:26] root INFO: name : DistributedBatchSampler +[2022/04/18 10:11:26] root INFO: shuffle : True +[2022/04/18 10:11:26] root INFO: Global : +[2022/04/18 10:11:26] root INFO: checkpoints : None +[2022/04/18 10:11:26] root INFO: device : gpu +[2022/04/18 10:11:26] root INFO: epochs : 20 +[2022/04/18 10:11:26] root INFO: eval_during_train : True +[2022/04/18 10:11:26] root INFO: eval_interval : 1 +[2022/04/18 10:11:26] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:11:26] root INFO: output_dir : ./output/ +[2022/04/18 10:11:26] root INFO: pretrained_model : None +[2022/04/18 10:11:26] root INFO: print_batch_step : 10 +[2022/04/18 10:11:26] root INFO: save_inference_dir : ./inference +[2022/04/18 10:11:26] root INFO: save_interval : 1 +[2022/04/18 10:11:26] root INFO: use_visualdl : False +[2022/04/18 10:11:26] root INFO: Infer : +[2022/04/18 10:11:26] root INFO: PostProcess : +[2022/04/18 10:11:26] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:11:26] root INFO: name : Topk +[2022/04/18 10:11:26] root INFO: topk : 5 +[2022/04/18 10:11:26] root INFO: batch_size : 10 +[2022/04/18 10:11:26] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:11:26] root INFO: transforms : +[2022/04/18 10:11:26] root INFO: DecodeImage : +[2022/04/18 10:11:26] root INFO: channel_first : False +[2022/04/18 10:11:26] root INFO: to_rgb : True +[2022/04/18 10:11:26] root INFO: ResizeImage : +[2022/04/18 10:11:26] root INFO: resize_short : 256 +[2022/04/18 10:11:26] root INFO: CropImage : +[2022/04/18 10:11:26] root INFO: size : 224 +[2022/04/18 10:11:26] root INFO: NormalizeImage : +[2022/04/18 10:11:26] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:11:26] root INFO: order : +[2022/04/18 10:11:26] root INFO: scale : 1.0/255.0 +[2022/04/18 10:11:26] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:11:26] root INFO: ToCHWImage : None +[2022/04/18 10:11:26] root INFO: Loss : +[2022/04/18 10:11:26] root INFO: Eval : +[2022/04/18 10:11:26] root INFO: CELoss : +[2022/04/18 10:11:26] root INFO: weight : 1.0 +[2022/04/18 10:11:26] root INFO: Train : +[2022/04/18 10:11:26] root INFO: CELoss : +[2022/04/18 10:11:26] root INFO: weight : 1.0 +[2022/04/18 10:11:26] root INFO: Metric : +[2022/04/18 10:11:26] root INFO: Eval : +[2022/04/18 10:11:26] root INFO: TopkAcc : +[2022/04/18 10:11:26] root INFO: topk : [1, 5] +[2022/04/18 10:11:26] root INFO: Train : +[2022/04/18 10:11:26] root INFO: TopkAcc : +[2022/04/18 10:11:26] root INFO: topk : [1, 5] +[2022/04/18 10:11:26] root INFO: Optimizer : +[2022/04/18 10:11:26] root INFO: lr : +[2022/04/18 10:11:26] root INFO: learning_rate : 0.0125 +[2022/04/18 10:11:26] root INFO: name : Cosine +[2022/04/18 10:11:26] root INFO: warmup_epoch : 5 +[2022/04/18 10:11:26] root INFO: momentum : 0.9 +[2022/04/18 10:11:26] root INFO: name : Momentum +[2022/04/18 10:11:26] root INFO: regularizer : +[2022/04/18 10:11:26] root INFO: coeff : 1e-05 +[2022/04/18 10:11:26] root INFO: name : L2 +[2022/04/18 10:11:26] root INFO: profiler_options : None +[2022/04/18 14:59:29] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 14:59:29] root INFO: Arch : +[2022/04/18 14:59:29] root INFO: class_num : 100 +[2022/04/18 14:59:29] root INFO: name : ResNet50_vd +[2022/04/18 14:59:29] root INFO: DataLoader : +[2022/04/18 14:59:29] root INFO: Eval : +[2022/04/18 14:59:29] root INFO: dataset : +[2022/04/18 14:59:29] root INFO: cls_label_path : ./dataset/CIFAR100/test_list.txt +[2022/04/18 14:59:29] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 14:59:29] root INFO: name : ImageNetDataset +[2022/04/18 14:59:29] root INFO: transform_ops : +[2022/04/18 14:59:29] root INFO: DecodeImage : +[2022/04/18 14:59:29] root INFO: channel_first : False +[2022/04/18 14:59:29] root INFO: to_rgb : True +[2022/04/18 14:59:29] root INFO: ResizeImage : +[2022/04/18 14:59:29] root INFO: resize_short : 36 +[2022/04/18 14:59:29] root INFO: CropImage : +[2022/04/18 14:59:29] root INFO: size : 32 +[2022/04/18 14:59:29] root INFO: NormalizeImage : +[2022/04/18 14:59:29] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 14:59:29] root INFO: order : +[2022/04/18 14:59:29] root INFO: scale : 1.0/255.0 +[2022/04/18 14:59:29] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 14:59:29] root INFO: loader : +[2022/04/18 14:59:29] root INFO: num_workers : 4 +[2022/04/18 14:59:29] root INFO: use_shared_memory : True +[2022/04/18 14:59:29] root INFO: sampler : +[2022/04/18 14:59:29] root INFO: batch_size : 64 +[2022/04/18 14:59:29] root INFO: drop_last : False +[2022/04/18 14:59:29] root INFO: name : DistributedBatchSampler +[2022/04/18 14:59:29] root INFO: shuffle : False +[2022/04/18 14:59:29] root INFO: Train : +[2022/04/18 14:59:29] root INFO: dataset : +[2022/04/18 14:59:29] root INFO: cls_label_path : ./dataset/CIFAR100/train_list.txt +[2022/04/18 14:59:29] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 14:59:29] root INFO: name : ImageNetDataset +[2022/04/18 14:59:29] root INFO: transform_ops : +[2022/04/18 14:59:29] root INFO: DecodeImage : +[2022/04/18 14:59:29] root INFO: channel_first : False +[2022/04/18 14:59:29] root INFO: to_rgb : True +[2022/04/18 14:59:29] root INFO: RandCropImage : +[2022/04/18 14:59:29] root INFO: size : 32 +[2022/04/18 14:59:29] root INFO: RandFlipImage : +[2022/04/18 14:59:29] root INFO: flip_code : 1 +[2022/04/18 14:59:29] root INFO: NormalizeImage : +[2022/04/18 14:59:29] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 14:59:29] root INFO: order : +[2022/04/18 14:59:29] root INFO: scale : 1.0/255.0 +[2022/04/18 14:59:29] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 14:59:29] root INFO: loader : +[2022/04/18 14:59:29] root INFO: num_workers : 4 +[2022/04/18 14:59:29] root INFO: use_shared_memory : True +[2022/04/18 14:59:29] root INFO: sampler : +[2022/04/18 14:59:29] root INFO: batch_size : 64 +[2022/04/18 14:59:29] root INFO: drop_last : False +[2022/04/18 14:59:29] root INFO: name : DistributedBatchSampler +[2022/04/18 14:59:29] root INFO: shuffle : True +[2022/04/18 14:59:29] root INFO: Global : +[2022/04/18 14:59:29] root INFO: checkpoints : None +[2022/04/18 14:59:29] root INFO: device : cpu +[2022/04/18 14:59:29] root INFO: epochs : 100 +[2022/04/18 14:59:29] root INFO: eval_during_train : True +[2022/04/18 14:59:29] root INFO: eval_interval : 1 +[2022/04/18 14:59:29] root INFO: image_shape : [3, 32, 32] +[2022/04/18 14:59:29] root INFO: output_dir : ./output/ +[2022/04/18 14:59:29] root INFO: pretrained_model : None +[2022/04/18 14:59:29] root INFO: print_batch_step : 10 +[2022/04/18 14:59:29] root INFO: save_inference_dir : ./inference +[2022/04/18 14:59:29] root INFO: save_interval : 1 +[2022/04/18 14:59:29] root INFO: use_visualdl : False +[2022/04/18 14:59:29] root INFO: Infer : +[2022/04/18 14:59:29] root INFO: PostProcess : +[2022/04/18 14:59:29] root INFO: name : Topk +[2022/04/18 14:59:29] root INFO: topk : 5 +[2022/04/18 14:59:29] root INFO: batch_size : 10 +[2022/04/18 14:59:29] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 14:59:29] root INFO: transforms : +[2022/04/18 14:59:29] root INFO: DecodeImage : +[2022/04/18 14:59:29] root INFO: channel_first : False +[2022/04/18 14:59:29] root INFO: to_rgb : True +[2022/04/18 14:59:29] root INFO: ResizeImage : +[2022/04/18 14:59:29] root INFO: resize_short : 36 +[2022/04/18 14:59:29] root INFO: CropImage : +[2022/04/18 14:59:29] root INFO: size : 32 +[2022/04/18 14:59:29] root INFO: NormalizeImage : +[2022/04/18 14:59:29] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 14:59:29] root INFO: order : +[2022/04/18 14:59:29] root INFO: scale : 1.0/255.0 +[2022/04/18 14:59:29] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 14:59:29] root INFO: ToCHWImage : None +[2022/04/18 14:59:29] root INFO: Loss : +[2022/04/18 14:59:29] root INFO: Eval : +[2022/04/18 14:59:29] root INFO: CELoss : +[2022/04/18 14:59:29] root INFO: weight : 1.0 +[2022/04/18 14:59:29] root INFO: Train : +[2022/04/18 14:59:29] root INFO: CELoss : +[2022/04/18 14:59:29] root INFO: weight : 1.0 +[2022/04/18 14:59:29] root INFO: Metric : +[2022/04/18 14:59:29] root INFO: Eval : +[2022/04/18 14:59:29] root INFO: TopkAcc : +[2022/04/18 14:59:29] root INFO: topk : [1, 5] +[2022/04/18 14:59:29] root INFO: Train : +[2022/04/18 14:59:29] root INFO: TopkAcc : +[2022/04/18 14:59:29] root INFO: topk : [1, 5] +[2022/04/18 14:59:29] root INFO: Optimizer : +[2022/04/18 14:59:29] root INFO: lr : +[2022/04/18 14:59:29] root INFO: learning_rate : 0.04 +[2022/04/18 14:59:29] root INFO: name : Cosine +[2022/04/18 14:59:29] root INFO: momentum : 0.9 +[2022/04/18 14:59:29] root INFO: name : Momentum +[2022/04/18 14:59:29] root INFO: regularizer : +[2022/04/18 14:59:29] root INFO: coeff : 0.0001 +[2022/04/18 14:59:29] root INFO: name : L2 +[2022/04/18 14:59:29] root INFO: output_dir : output_CIFAR +[2022/04/18 14:59:29] root INFO: profiler_options : None +[2022/04/18 14:59:29] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 14:59:42] root WARNING: The training strategy in config files provided by PaddleClas is based on 4 gpus. But the number of gpus is 1 in current training. Please modify the stategy (learning rate, batch size and so on) if use config files in PaddleClas to train. +[2022/04/18 14:59:45] root INFO: [Train][Epoch 1/100][Iter: 0/782]lr: 0.04000, top1: 0.00000, top5: 0.00000, CELoss: 5.06183, loss: 5.06183, batch_cost: 3.24200s, reader_cost: 0.06900, ips: 19.74091 images/sec, eta: 2 days, 22:25:24 +[2022/04/18 15:00:17] root INFO: [Train][Epoch 1/100][Iter: 10/782]lr: 0.04000, top1: 0.00568, top5: 0.04261, CELoss: 8.25212, loss: 8.25212, batch_cost: 3.30698s, reader_cost: 0.00026, ips: 19.35302 images/sec, eta: 2 days, 23:49:32 +[2022/04/18 15:00:50] root INFO: [Train][Epoch 1/100][Iter: 20/782]lr: 0.04000, top1: 0.00818, top5: 0.04539, CELoss: 8.45065, loss: 8.45065, batch_cost: 3.28671s, reader_cost: 0.00010, ips: 19.47239 images/sec, eta: 2 days, 23:22:34 diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdopt new file mode 100644 index 0000000..09e27e8 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdparams new file mode 100644 index 0000000..6758e33 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdstates new file mode 100644 index 0000000..e9570e6 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/best_model.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdopt new file mode 100644 index 0000000..75cc7be Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdparams new file mode 100644 index 0000000..6e1f30e Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdstates new file mode 100644 index 0000000..8fcacdd Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_1.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdopt new file mode 100644 index 0000000..0178570 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdparams new file mode 100644 index 0000000..ec2ac01 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdstates new file mode 100644 index 0000000..6f79548 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_10.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdopt new file mode 100644 index 0000000..09e27e8 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdparams new file mode 100644 index 0000000..6758e33 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdstates new file mode 100644 index 0000000..e9570e6 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_11.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdopt new file mode 100644 index 0000000..730fe89 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdparams new file mode 100644 index 0000000..aff0ae9 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdstates new file mode 100644 index 0000000..2d8fd78 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_12.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdopt new file mode 100644 index 0000000..19afdbb Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdparams new file mode 100644 index 0000000..d09dbce Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdstates new file mode 100644 index 0000000..82f77c9 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_13.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdopt new file mode 100644 index 0000000..d60f005 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdparams new file mode 100644 index 0000000..3522c94 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdstates new file mode 100644 index 0000000..063cc5b Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_14.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdopt new file mode 100644 index 0000000..c28e9a8 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdparams new file mode 100644 index 0000000..a69d18e Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdstates new file mode 100644 index 0000000..fb8d131 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_15.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdopt new file mode 100644 index 0000000..56cf0e5 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdparams new file mode 100644 index 0000000..87c4bbd Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdstates new file mode 100644 index 0000000..2140441 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_16.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdopt new file mode 100644 index 0000000..79523c6 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdparams new file mode 100644 index 0000000..095cdba Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdstates new file mode 100644 index 0000000..b9957e7 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_17.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdopt new file mode 100644 index 0000000..3eca271 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdparams new file mode 100644 index 0000000..6112fd8 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdstates new file mode 100644 index 0000000..5613ff6 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_18.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdopt new file mode 100644 index 0000000..e6e9d71 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdparams new file mode 100644 index 0000000..e2c1fe6 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdstates new file mode 100644 index 0000000..a4cf257 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_19.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdopt new file mode 100644 index 0000000..84d7c65 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdparams new file mode 100644 index 0000000..1cb95fe Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdstates new file mode 100644 index 0000000..fcd4c7d Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_2.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdopt new file mode 100644 index 0000000..34723e3 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdparams new file mode 100644 index 0000000..1642e22 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdstates new file mode 100644 index 0000000..80a0d80 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_20.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdopt new file mode 100644 index 0000000..3e465c9 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdparams new file mode 100644 index 0000000..0e67441 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdstates new file mode 100644 index 0000000..33f8acd Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_3.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdopt new file mode 100644 index 0000000..89b4c36 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdparams new file mode 100644 index 0000000..b4c4e62 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdstates new file mode 100644 index 0000000..e7b9810 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_4.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdopt new file mode 100644 index 0000000..5bbdaf5 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdparams new file mode 100644 index 0000000..93e2814 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdstates new file mode 100644 index 0000000..e128df0 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_5.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdopt new file mode 100644 index 0000000..d6380fa Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdparams new file mode 100644 index 0000000..36ce58f Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdstates new file mode 100644 index 0000000..70cd892 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_6.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdopt new file mode 100644 index 0000000..943c25e Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdparams new file mode 100644 index 0000000..d763f08 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdstates new file mode 100644 index 0000000..782379c Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_7.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdopt new file mode 100644 index 0000000..03395f7 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdparams new file mode 100644 index 0000000..fd31025 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdstates new file mode 100644 index 0000000..4eb02df Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_8.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdopt new file mode 100644 index 0000000..345829b Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdparams new file mode 100644 index 0000000..5a75a93 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdstates new file mode 100644 index 0000000..7fcee30 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/epoch_9.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/infer.log b/src/PaddleClas/output/ShuffleNetV2_x0_25/infer.log new file mode 100644 index 0000000..5a92c42 --- /dev/null +++ b/src/PaddleClas/output/ShuffleNetV2_x0_25/infer.log @@ -0,0 +1,125 @@ +[2022/04/18 10:43:55] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:43:55] root INFO: Arch : +[2022/04/18 10:43:55] root INFO: class_num : 102 +[2022/04/18 10:43:55] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:43:55] root INFO: DataLoader : +[2022/04/18 10:43:55] root INFO: Eval : +[2022/04/18 10:43:55] root INFO: dataset : +[2022/04/18 10:43:55] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:43:55] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:43:55] root INFO: name : ImageNetDataset +[2022/04/18 10:43:55] root INFO: transform_ops : +[2022/04/18 10:43:55] root INFO: DecodeImage : +[2022/04/18 10:43:55] root INFO: channel_first : False +[2022/04/18 10:43:55] root INFO: to_rgb : True +[2022/04/18 10:43:55] root INFO: ResizeImage : +[2022/04/18 10:43:55] root INFO: resize_short : 256 +[2022/04/18 10:43:55] root INFO: CropImage : +[2022/04/18 10:43:55] root INFO: size : 224 +[2022/04/18 10:43:55] root INFO: NormalizeImage : +[2022/04/18 10:43:55] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:43:55] root INFO: order : +[2022/04/18 10:43:55] root INFO: scale : 1.0/255.0 +[2022/04/18 10:43:55] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:43:55] root INFO: loader : +[2022/04/18 10:43:55] root INFO: num_workers : 4 +[2022/04/18 10:43:55] root INFO: use_shared_memory : True +[2022/04/18 10:43:55] root INFO: sampler : +[2022/04/18 10:43:55] root INFO: batch_size : 64 +[2022/04/18 10:43:55] root INFO: drop_last : False +[2022/04/18 10:43:55] root INFO: name : DistributedBatchSampler +[2022/04/18 10:43:55] root INFO: shuffle : False +[2022/04/18 10:43:55] root INFO: Train : +[2022/04/18 10:43:55] root INFO: dataset : +[2022/04/18 10:43:55] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:43:55] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:43:55] root INFO: name : ImageNetDataset +[2022/04/18 10:43:55] root INFO: transform_ops : +[2022/04/18 10:43:55] root INFO: DecodeImage : +[2022/04/18 10:43:55] root INFO: channel_first : False +[2022/04/18 10:43:55] root INFO: to_rgb : True +[2022/04/18 10:43:55] root INFO: RandCropImage : +[2022/04/18 10:43:55] root INFO: size : 224 +[2022/04/18 10:43:55] root INFO: RandFlipImage : +[2022/04/18 10:43:55] root INFO: flip_code : 1 +[2022/04/18 10:43:55] root INFO: NormalizeImage : +[2022/04/18 10:43:55] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:43:55] root INFO: order : +[2022/04/18 10:43:55] root INFO: scale : 1.0/255.0 +[2022/04/18 10:43:55] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:43:55] root INFO: loader : +[2022/04/18 10:43:55] root INFO: num_workers : 4 +[2022/04/18 10:43:55] root INFO: use_shared_memory : True +[2022/04/18 10:43:55] root INFO: sampler : +[2022/04/18 10:43:55] root INFO: batch_size : 256 +[2022/04/18 10:43:55] root INFO: drop_last : False +[2022/04/18 10:43:55] root INFO: name : DistributedBatchSampler +[2022/04/18 10:43:55] root INFO: shuffle : True +[2022/04/18 10:43:55] root INFO: Global : +[2022/04/18 10:43:55] root INFO: checkpoints : None +[2022/04/18 10:43:55] root INFO: device : cpu +[2022/04/18 10:43:55] root INFO: epochs : 20 +[2022/04/18 10:43:55] root INFO: eval_during_train : True +[2022/04/18 10:43:55] root INFO: eval_interval : 1 +[2022/04/18 10:43:55] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:43:55] root INFO: output_dir : ./output/ +[2022/04/18 10:43:55] root INFO: pretrained_model : output/ShuffleNetV2_x0_25/best_model +[2022/04/18 10:43:55] root INFO: print_batch_step : 10 +[2022/04/18 10:43:55] root INFO: save_inference_dir : ./inference +[2022/04/18 10:43:55] root INFO: save_interval : 1 +[2022/04/18 10:43:55] root INFO: use_visualdl : False +[2022/04/18 10:43:55] root INFO: Infer : +[2022/04/18 10:43:55] root INFO: PostProcess : +[2022/04/18 10:43:55] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:43:55] root INFO: name : Topk +[2022/04/18 10:43:55] root INFO: topk : 5 +[2022/04/18 10:43:55] root INFO: batch_size : 10 +[2022/04/18 10:43:55] root INFO: infer_imgs : dataset/flowers102/jpg/image_00001.jpg +[2022/04/18 10:43:55] root INFO: transforms : +[2022/04/18 10:43:55] root INFO: DecodeImage : +[2022/04/18 10:43:55] root INFO: channel_first : False +[2022/04/18 10:43:55] root INFO: to_rgb : True +[2022/04/18 10:43:55] root INFO: ResizeImage : +[2022/04/18 10:43:55] root INFO: resize_short : 256 +[2022/04/18 10:43:55] root INFO: CropImage : +[2022/04/18 10:43:55] root INFO: size : 224 +[2022/04/18 10:43:55] root INFO: NormalizeImage : +[2022/04/18 10:43:55] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:43:55] root INFO: order : +[2022/04/18 10:43:55] root INFO: scale : 1.0/255.0 +[2022/04/18 10:43:55] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:43:55] root INFO: ToCHWImage : None +[2022/04/18 10:43:55] root INFO: Loss : +[2022/04/18 10:43:55] root INFO: Eval : +[2022/04/18 10:43:55] root INFO: CELoss : +[2022/04/18 10:43:55] root INFO: weight : 1.0 +[2022/04/18 10:43:55] root INFO: Train : +[2022/04/18 10:43:55] root INFO: CELoss : +[2022/04/18 10:43:55] root INFO: weight : 1.0 +[2022/04/18 10:43:55] root INFO: Metric : +[2022/04/18 10:43:55] root INFO: Eval : +[2022/04/18 10:43:55] root INFO: TopkAcc : +[2022/04/18 10:43:55] root INFO: topk : [1, 5] +[2022/04/18 10:43:55] root INFO: Train : +[2022/04/18 10:43:55] root INFO: TopkAcc : +[2022/04/18 10:43:55] root INFO: topk : [1, 5] +[2022/04/18 10:43:55] root INFO: Optimizer : +[2022/04/18 10:43:55] root INFO: lr : +[2022/04/18 10:43:55] root INFO: learning_rate : 0.0125 +[2022/04/18 10:43:55] root INFO: name : Cosine +[2022/04/18 10:43:55] root INFO: warmup_epoch : 5 +[2022/04/18 10:43:55] root INFO: momentum : 0.9 +[2022/04/18 10:43:55] root INFO: name : Momentum +[2022/04/18 10:43:55] root INFO: regularizer : +[2022/04/18 10:43:55] root INFO: coeff : 1e-05 +[2022/04/18 10:43:55] root INFO: name : L2 +[2022/04/18 10:43:55] root INFO: train with paddle 2.2.2 and device CPUPlace diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdopt b/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdopt new file mode 100644 index 0000000..34723e3 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdopt differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdparams b/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdparams new file mode 100644 index 0000000..1642e22 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdparams differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdstates b/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdstates new file mode 100644 index 0000000..80a0d80 Binary files /dev/null and b/src/PaddleClas/output/ShuffleNetV2_x0_25/latest.pdstates differ diff --git a/src/PaddleClas/output/ShuffleNetV2_x0_25/train.log b/src/PaddleClas/output/ShuffleNetV2_x0_25/train.log new file mode 100644 index 0000000..769385f --- /dev/null +++ b/src/PaddleClas/output/ShuffleNetV2_x0_25/train.log @@ -0,0 +1,1427 @@ +[2022/04/18 10:08:38] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:08:38] root INFO: Arch : +[2022/04/18 10:08:38] root INFO: class_num : 102 +[2022/04/18 10:08:38] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:08:38] root INFO: DataLoader : +[2022/04/18 10:08:38] root INFO: Eval : +[2022/04/18 10:08:38] root INFO: dataset : +[2022/04/18 10:08:38] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:08:38] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:08:38] root INFO: name : ImageNetDataset +[2022/04/18 10:08:38] root INFO: transform_ops : +[2022/04/18 10:08:38] root INFO: DecodeImage : +[2022/04/18 10:08:38] root INFO: channel_first : False +[2022/04/18 10:08:38] root INFO: to_rgb : True +[2022/04/18 10:08:38] root INFO: ResizeImage : +[2022/04/18 10:08:38] root INFO: resize_short : 256 +[2022/04/18 10:08:38] root INFO: CropImage : +[2022/04/18 10:08:38] root INFO: size : 224 +[2022/04/18 10:08:38] root INFO: NormalizeImage : +[2022/04/18 10:08:38] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:08:38] root INFO: order : +[2022/04/18 10:08:38] root INFO: scale : 1.0/255.0 +[2022/04/18 10:08:38] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:08:38] root INFO: loader : +[2022/04/18 10:08:38] root INFO: num_workers : 4 +[2022/04/18 10:08:38] root INFO: use_shared_memory : True +[2022/04/18 10:08:38] root INFO: sampler : +[2022/04/18 10:08:38] root INFO: batch_size : 64 +[2022/04/18 10:08:38] root INFO: drop_last : False +[2022/04/18 10:08:38] root INFO: name : DistributedBatchSampler +[2022/04/18 10:08:38] root INFO: shuffle : False +[2022/04/18 10:08:38] root INFO: Train : +[2022/04/18 10:08:38] root INFO: dataset : +[2022/04/18 10:08:38] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:08:38] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:08:38] root INFO: name : ImageNetDataset +[2022/04/18 10:08:38] root INFO: transform_ops : +[2022/04/18 10:08:38] root INFO: DecodeImage : +[2022/04/18 10:08:38] root INFO: channel_first : False +[2022/04/18 10:08:38] root INFO: to_rgb : True +[2022/04/18 10:08:38] root INFO: RandCropImage : +[2022/04/18 10:08:38] root INFO: size : 224 +[2022/04/18 10:08:38] root INFO: RandFlipImage : +[2022/04/18 10:08:38] root INFO: flip_code : 1 +[2022/04/18 10:08:38] root INFO: NormalizeImage : +[2022/04/18 10:08:38] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:08:38] root INFO: order : +[2022/04/18 10:08:38] root INFO: scale : 1.0/255.0 +[2022/04/18 10:08:38] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:08:38] root INFO: loader : +[2022/04/18 10:08:38] root INFO: num_workers : 4 +[2022/04/18 10:08:38] root INFO: use_shared_memory : True +[2022/04/18 10:08:38] root INFO: sampler : +[2022/04/18 10:08:38] root INFO: batch_size : 256 +[2022/04/18 10:08:38] root INFO: drop_last : False +[2022/04/18 10:08:38] root INFO: name : DistributedBatchSampler +[2022/04/18 10:08:38] root INFO: shuffle : True +[2022/04/18 10:08:38] root INFO: Global : +[2022/04/18 10:08:38] root INFO: checkpoints : None +[2022/04/18 10:08:38] root INFO: device : cpu +[2022/04/18 10:08:38] root INFO: epochs : 20 +[2022/04/18 10:08:38] root INFO: eval_during_train : True +[2022/04/18 10:08:38] root INFO: eval_interval : 1 +[2022/04/18 10:08:38] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:08:38] root INFO: output_dir : ./output/ +[2022/04/18 10:08:38] root INFO: pretrained_model : None +[2022/04/18 10:08:38] root INFO: print_batch_step : 10 +[2022/04/18 10:08:38] root INFO: save_inference_dir : ./inference +[2022/04/18 10:08:38] root INFO: save_interval : 1 +[2022/04/18 10:08:38] root INFO: use_visualdl : False +[2022/04/18 10:08:38] root INFO: Infer : +[2022/04/18 10:08:38] root INFO: PostProcess : +[2022/04/18 10:08:38] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:08:38] root INFO: name : Topk +[2022/04/18 10:08:38] root INFO: topk : 5 +[2022/04/18 10:08:38] root INFO: batch_size : 10 +[2022/04/18 10:08:38] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:08:38] root INFO: transforms : +[2022/04/18 10:08:38] root INFO: DecodeImage : +[2022/04/18 10:08:38] root INFO: channel_first : False +[2022/04/18 10:08:38] root INFO: to_rgb : True +[2022/04/18 10:08:38] root INFO: ResizeImage : +[2022/04/18 10:08:38] root INFO: resize_short : 256 +[2022/04/18 10:08:38] root INFO: CropImage : +[2022/04/18 10:08:38] root INFO: size : 224 +[2022/04/18 10:08:38] root INFO: NormalizeImage : +[2022/04/18 10:08:38] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:08:38] root INFO: order : +[2022/04/18 10:08:38] root INFO: scale : 1.0/255.0 +[2022/04/18 10:08:38] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:08:38] root INFO: ToCHWImage : None +[2022/04/18 10:08:38] root INFO: Loss : +[2022/04/18 10:08:38] root INFO: Eval : +[2022/04/18 10:08:38] root INFO: CELoss : +[2022/04/18 10:08:38] root INFO: weight : 1.0 +[2022/04/18 10:08:38] root INFO: Train : +[2022/04/18 10:08:38] root INFO: CELoss : +[2022/04/18 10:08:38] root INFO: weight : 1.0 +[2022/04/18 10:08:38] root INFO: Metric : +[2022/04/18 10:08:38] root INFO: Eval : +[2022/04/18 10:08:38] root INFO: TopkAcc : +[2022/04/18 10:08:38] root INFO: topk : [1, 5] +[2022/04/18 10:08:38] root INFO: Train : +[2022/04/18 10:08:38] root INFO: TopkAcc : +[2022/04/18 10:08:38] root INFO: topk : [1, 5] +[2022/04/18 10:08:38] root INFO: Optimizer : +[2022/04/18 10:08:38] root INFO: lr : +[2022/04/18 10:08:38] root INFO: learning_rate : 0.0125 +[2022/04/18 10:08:38] root INFO: name : Cosine +[2022/04/18 10:08:38] root INFO: warmup_epoch : 5 +[2022/04/18 10:08:38] root INFO: momentum : 0.9 +[2022/04/18 10:08:38] root INFO: name : Momentum +[2022/04/18 10:08:38] root INFO: regularizer : +[2022/04/18 10:08:38] root INFO: coeff : 1e-05 +[2022/04/18 10:08:38] root INFO: name : L2 +[2022/04/18 10:08:38] root INFO: profiler_options : None +[2022/04/18 10:08:38] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:10:05] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:10:05] root INFO: Arch : +[2022/04/18 10:10:05] root INFO: class_num : 102 +[2022/04/18 10:10:05] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:10:05] root INFO: pretrained : True +[2022/04/18 10:10:05] root INFO: DataLoader : +[2022/04/18 10:10:05] root INFO: Eval : +[2022/04/18 10:10:05] root INFO: dataset : +[2022/04/18 10:10:05] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:10:05] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:10:05] root INFO: name : ImageNetDataset +[2022/04/18 10:10:05] root INFO: transform_ops : +[2022/04/18 10:10:05] root INFO: DecodeImage : +[2022/04/18 10:10:05] root INFO: channel_first : False +[2022/04/18 10:10:05] root INFO: to_rgb : True +[2022/04/18 10:10:05] root INFO: ResizeImage : +[2022/04/18 10:10:05] root INFO: resize_short : 256 +[2022/04/18 10:10:05] root INFO: CropImage : +[2022/04/18 10:10:05] root INFO: size : 224 +[2022/04/18 10:10:05] root INFO: NormalizeImage : +[2022/04/18 10:10:05] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:05] root INFO: order : +[2022/04/18 10:10:05] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:05] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:05] root INFO: loader : +[2022/04/18 10:10:05] root INFO: num_workers : 4 +[2022/04/18 10:10:05] root INFO: use_shared_memory : True +[2022/04/18 10:10:05] root INFO: sampler : +[2022/04/18 10:10:05] root INFO: batch_size : 64 +[2022/04/18 10:10:05] root INFO: drop_last : False +[2022/04/18 10:10:05] root INFO: name : DistributedBatchSampler +[2022/04/18 10:10:05] root INFO: shuffle : False +[2022/04/18 10:10:05] root INFO: Train : +[2022/04/18 10:10:05] root INFO: dataset : +[2022/04/18 10:10:05] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:10:05] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:10:05] root INFO: name : ImageNetDataset +[2022/04/18 10:10:05] root INFO: transform_ops : +[2022/04/18 10:10:05] root INFO: DecodeImage : +[2022/04/18 10:10:05] root INFO: channel_first : False +[2022/04/18 10:10:05] root INFO: to_rgb : True +[2022/04/18 10:10:05] root INFO: RandCropImage : +[2022/04/18 10:10:05] root INFO: size : 224 +[2022/04/18 10:10:05] root INFO: RandFlipImage : +[2022/04/18 10:10:05] root INFO: flip_code : 1 +[2022/04/18 10:10:05] root INFO: NormalizeImage : +[2022/04/18 10:10:05] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:05] root INFO: order : +[2022/04/18 10:10:05] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:05] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:05] root INFO: loader : +[2022/04/18 10:10:05] root INFO: num_workers : 4 +[2022/04/18 10:10:05] root INFO: use_shared_memory : True +[2022/04/18 10:10:05] root INFO: sampler : +[2022/04/18 10:10:05] root INFO: batch_size : 256 +[2022/04/18 10:10:05] root INFO: drop_last : False +[2022/04/18 10:10:05] root INFO: name : DistributedBatchSampler +[2022/04/18 10:10:05] root INFO: shuffle : True +[2022/04/18 10:10:05] root INFO: Global : +[2022/04/18 10:10:05] root INFO: checkpoints : None +[2022/04/18 10:10:05] root INFO: device : cpu +[2022/04/18 10:10:05] root INFO: epochs : 20 +[2022/04/18 10:10:05] root INFO: eval_during_train : True +[2022/04/18 10:10:05] root INFO: eval_interval : 1 +[2022/04/18 10:10:05] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:10:05] root INFO: output_dir : ./output/ +[2022/04/18 10:10:05] root INFO: pretrained_model : None +[2022/04/18 10:10:05] root INFO: print_batch_step : 10 +[2022/04/18 10:10:05] root INFO: save_inference_dir : ./inference +[2022/04/18 10:10:05] root INFO: save_interval : 1 +[2022/04/18 10:10:05] root INFO: use_visualdl : False +[2022/04/18 10:10:05] root INFO: Infer : +[2022/04/18 10:10:05] root INFO: PostProcess : +[2022/04/18 10:10:05] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:10:05] root INFO: name : Topk +[2022/04/18 10:10:05] root INFO: topk : 5 +[2022/04/18 10:10:05] root INFO: batch_size : 10 +[2022/04/18 10:10:05] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:10:05] root INFO: transforms : +[2022/04/18 10:10:05] root INFO: DecodeImage : +[2022/04/18 10:10:05] root INFO: channel_first : False +[2022/04/18 10:10:05] root INFO: to_rgb : True +[2022/04/18 10:10:05] root INFO: ResizeImage : +[2022/04/18 10:10:05] root INFO: resize_short : 256 +[2022/04/18 10:10:05] root INFO: CropImage : +[2022/04/18 10:10:05] root INFO: size : 224 +[2022/04/18 10:10:05] root INFO: NormalizeImage : +[2022/04/18 10:10:05] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:05] root INFO: order : +[2022/04/18 10:10:05] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:05] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:05] root INFO: ToCHWImage : None +[2022/04/18 10:10:05] root INFO: Loss : +[2022/04/18 10:10:05] root INFO: Eval : +[2022/04/18 10:10:05] root INFO: CELoss : +[2022/04/18 10:10:05] root INFO: weight : 1.0 +[2022/04/18 10:10:05] root INFO: Train : +[2022/04/18 10:10:05] root INFO: CELoss : +[2022/04/18 10:10:05] root INFO: weight : 1.0 +[2022/04/18 10:10:05] root INFO: Metric : +[2022/04/18 10:10:05] root INFO: Eval : +[2022/04/18 10:10:05] root INFO: TopkAcc : +[2022/04/18 10:10:05] root INFO: topk : [1, 5] +[2022/04/18 10:10:05] root INFO: Train : +[2022/04/18 10:10:05] root INFO: TopkAcc : +[2022/04/18 10:10:05] root INFO: topk : [1, 5] +[2022/04/18 10:10:05] root INFO: Optimizer : +[2022/04/18 10:10:05] root INFO: lr : +[2022/04/18 10:10:05] root INFO: learning_rate : 0.0125 +[2022/04/18 10:10:05] root INFO: name : Cosine +[2022/04/18 10:10:05] root INFO: warmup_epoch : 5 +[2022/04/18 10:10:05] root INFO: momentum : 0.9 +[2022/04/18 10:10:05] root INFO: name : Momentum +[2022/04/18 10:10:05] root INFO: regularizer : +[2022/04/18 10:10:05] root INFO: coeff : 1e-05 +[2022/04/18 10:10:05] root INFO: name : L2 +[2022/04/18 10:10:05] root INFO: profiler_options : None +[2022/04/18 10:10:05] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:10:31] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:10:31] root INFO: Arch : +[2022/04/18 10:10:31] root INFO: class_num : 102 +[2022/04/18 10:10:31] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:10:31] root INFO: pretrained : True +[2022/04/18 10:10:31] root INFO: DataLoader : +[2022/04/18 10:10:31] root INFO: Eval : +[2022/04/18 10:10:31] root INFO: dataset : +[2022/04/18 10:10:31] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:10:31] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:10:31] root INFO: name : ImageNetDataset +[2022/04/18 10:10:31] root INFO: transform_ops : +[2022/04/18 10:10:31] root INFO: DecodeImage : +[2022/04/18 10:10:31] root INFO: channel_first : False +[2022/04/18 10:10:31] root INFO: to_rgb : True +[2022/04/18 10:10:31] root INFO: ResizeImage : +[2022/04/18 10:10:31] root INFO: resize_short : 256 +[2022/04/18 10:10:31] root INFO: CropImage : +[2022/04/18 10:10:31] root INFO: size : 224 +[2022/04/18 10:10:31] root INFO: NormalizeImage : +[2022/04/18 10:10:31] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:31] root INFO: order : +[2022/04/18 10:10:31] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:31] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:31] root INFO: loader : +[2022/04/18 10:10:31] root INFO: num_workers : 4 +[2022/04/18 10:10:31] root INFO: use_shared_memory : True +[2022/04/18 10:10:31] root INFO: sampler : +[2022/04/18 10:10:31] root INFO: batch_size : 64 +[2022/04/18 10:10:31] root INFO: drop_last : False +[2022/04/18 10:10:31] root INFO: name : DistributedBatchSampler +[2022/04/18 10:10:31] root INFO: shuffle : False +[2022/04/18 10:10:31] root INFO: Train : +[2022/04/18 10:10:31] root INFO: dataset : +[2022/04/18 10:10:31] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:10:31] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:10:31] root INFO: name : ImageNetDataset +[2022/04/18 10:10:31] root INFO: transform_ops : +[2022/04/18 10:10:31] root INFO: DecodeImage : +[2022/04/18 10:10:31] root INFO: channel_first : False +[2022/04/18 10:10:31] root INFO: to_rgb : True +[2022/04/18 10:10:31] root INFO: RandCropImage : +[2022/04/18 10:10:31] root INFO: size : 224 +[2022/04/18 10:10:31] root INFO: RandFlipImage : +[2022/04/18 10:10:31] root INFO: flip_code : 1 +[2022/04/18 10:10:31] root INFO: NormalizeImage : +[2022/04/18 10:10:31] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:31] root INFO: order : +[2022/04/18 10:10:31] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:31] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:31] root INFO: loader : +[2022/04/18 10:10:31] root INFO: num_workers : 4 +[2022/04/18 10:10:31] root INFO: use_shared_memory : True +[2022/04/18 10:10:31] root INFO: sampler : +[2022/04/18 10:10:31] root INFO: batch_size : 256 +[2022/04/18 10:10:31] root INFO: drop_last : False +[2022/04/18 10:10:31] root INFO: name : DistributedBatchSampler +[2022/04/18 10:10:31] root INFO: shuffle : True +[2022/04/18 10:10:31] root INFO: Global : +[2022/04/18 10:10:31] root INFO: checkpoints : None +[2022/04/18 10:10:31] root INFO: device : cpu +[2022/04/18 10:10:31] root INFO: epochs : 20 +[2022/04/18 10:10:31] root INFO: eval_during_train : True +[2022/04/18 10:10:31] root INFO: eval_interval : 1 +[2022/04/18 10:10:31] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:10:31] root INFO: output_dir : ./output/ +[2022/04/18 10:10:31] root INFO: pretrained_model : None +[2022/04/18 10:10:31] root INFO: print_batch_step : 10 +[2022/04/18 10:10:31] root INFO: save_inference_dir : ./inference +[2022/04/18 10:10:31] root INFO: save_interval : 1 +[2022/04/18 10:10:31] root INFO: use_visualdl : False +[2022/04/18 10:10:31] root INFO: Infer : +[2022/04/18 10:10:31] root INFO: PostProcess : +[2022/04/18 10:10:31] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:10:31] root INFO: name : Topk +[2022/04/18 10:10:31] root INFO: topk : 5 +[2022/04/18 10:10:31] root INFO: batch_size : 10 +[2022/04/18 10:10:31] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:10:31] root INFO: transforms : +[2022/04/18 10:10:31] root INFO: DecodeImage : +[2022/04/18 10:10:31] root INFO: channel_first : False +[2022/04/18 10:10:31] root INFO: to_rgb : True +[2022/04/18 10:10:31] root INFO: ResizeImage : +[2022/04/18 10:10:31] root INFO: resize_short : 256 +[2022/04/18 10:10:31] root INFO: CropImage : +[2022/04/18 10:10:31] root INFO: size : 224 +[2022/04/18 10:10:31] root INFO: NormalizeImage : +[2022/04/18 10:10:31] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:10:31] root INFO: order : +[2022/04/18 10:10:31] root INFO: scale : 1.0/255.0 +[2022/04/18 10:10:31] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:10:31] root INFO: ToCHWImage : None +[2022/04/18 10:10:31] root INFO: Loss : +[2022/04/18 10:10:31] root INFO: Eval : +[2022/04/18 10:10:31] root INFO: CELoss : +[2022/04/18 10:10:31] root INFO: weight : 1.0 +[2022/04/18 10:10:31] root INFO: Train : +[2022/04/18 10:10:31] root INFO: CELoss : +[2022/04/18 10:10:31] root INFO: weight : 1.0 +[2022/04/18 10:10:31] root INFO: Metric : +[2022/04/18 10:10:31] root INFO: Eval : +[2022/04/18 10:10:31] root INFO: TopkAcc : +[2022/04/18 10:10:31] root INFO: topk : [1, 5] +[2022/04/18 10:10:31] root INFO: Train : +[2022/04/18 10:10:31] root INFO: TopkAcc : +[2022/04/18 10:10:31] root INFO: topk : [1, 5] +[2022/04/18 10:10:31] root INFO: Optimizer : +[2022/04/18 10:10:31] root INFO: lr : +[2022/04/18 10:10:31] root INFO: learning_rate : 0.0125 +[2022/04/18 10:10:31] root INFO: name : Cosine +[2022/04/18 10:10:31] root INFO: warmup_epoch : 5 +[2022/04/18 10:10:31] root INFO: momentum : 0.9 +[2022/04/18 10:10:31] root INFO: name : Momentum +[2022/04/18 10:10:31] root INFO: regularizer : +[2022/04/18 10:10:31] root INFO: coeff : 1e-05 +[2022/04/18 10:10:31] root INFO: name : L2 +[2022/04/18 10:10:31] root INFO: profiler_options : None +[2022/04/18 10:10:31] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:17:07] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:17:07] root INFO: Arch : +[2022/04/18 10:17:07] root INFO: class_num : 102 +[2022/04/18 10:17:07] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:17:07] root INFO: DataLoader : +[2022/04/18 10:17:07] root INFO: Eval : +[2022/04/18 10:17:07] root INFO: dataset : +[2022/04/18 10:17:07] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:17:07] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:17:07] root INFO: name : ImageNetDataset +[2022/04/18 10:17:07] root INFO: transform_ops : +[2022/04/18 10:17:07] root INFO: DecodeImage : +[2022/04/18 10:17:07] root INFO: channel_first : False +[2022/04/18 10:17:07] root INFO: to_rgb : True +[2022/04/18 10:17:07] root INFO: ResizeImage : +[2022/04/18 10:17:07] root INFO: resize_short : 256 +[2022/04/18 10:17:07] root INFO: CropImage : +[2022/04/18 10:17:07] root INFO: size : 224 +[2022/04/18 10:17:07] root INFO: NormalizeImage : +[2022/04/18 10:17:07] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:17:07] root INFO: order : +[2022/04/18 10:17:07] root INFO: scale : 1.0/255.0 +[2022/04/18 10:17:07] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:17:07] root INFO: loader : +[2022/04/18 10:17:07] root INFO: num_workers : 4 +[2022/04/18 10:17:07] root INFO: use_shared_memory : True +[2022/04/18 10:17:07] root INFO: sampler : +[2022/04/18 10:17:07] root INFO: batch_size : 64 +[2022/04/18 10:17:07] root INFO: drop_last : False +[2022/04/18 10:17:07] root INFO: name : DistributedBatchSampler +[2022/04/18 10:17:07] root INFO: shuffle : False +[2022/04/18 10:17:07] root INFO: Train : +[2022/04/18 10:17:07] root INFO: dataset : +[2022/04/18 10:17:07] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:17:07] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:17:07] root INFO: name : ImageNetDataset +[2022/04/18 10:17:07] root INFO: transform_ops : +[2022/04/18 10:17:07] root INFO: DecodeImage : +[2022/04/18 10:17:07] root INFO: channel_first : False +[2022/04/18 10:17:07] root INFO: to_rgb : True +[2022/04/18 10:17:07] root INFO: RandCropImage : +[2022/04/18 10:17:07] root INFO: size : 224 +[2022/04/18 10:17:07] root INFO: RandFlipImage : +[2022/04/18 10:17:07] root INFO: flip_code : 1 +[2022/04/18 10:17:07] root INFO: NormalizeImage : +[2022/04/18 10:17:07] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:17:07] root INFO: order : +[2022/04/18 10:17:07] root INFO: scale : 1.0/255.0 +[2022/04/18 10:17:07] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:17:07] root INFO: loader : +[2022/04/18 10:17:07] root INFO: num_workers : 4 +[2022/04/18 10:17:07] root INFO: use_shared_memory : True +[2022/04/18 10:17:07] root INFO: sampler : +[2022/04/18 10:17:07] root INFO: batch_size : 256 +[2022/04/18 10:17:07] root INFO: drop_last : False +[2022/04/18 10:17:07] root INFO: name : DistributedBatchSampler +[2022/04/18 10:17:07] root INFO: shuffle : True +[2022/04/18 10:17:07] root INFO: Global : +[2022/04/18 10:17:07] root INFO: checkpoints : None +[2022/04/18 10:17:07] root INFO: device : cpu +[2022/04/18 10:17:07] root INFO: epochs : 20 +[2022/04/18 10:17:07] root INFO: eval_during_train : True +[2022/04/18 10:17:07] root INFO: eval_interval : 1 +[2022/04/18 10:17:07] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:17:07] root INFO: output_dir : ./output/ +[2022/04/18 10:17:07] root INFO: pretrained_model : None +[2022/04/18 10:17:07] root INFO: print_batch_step : 10 +[2022/04/18 10:17:07] root INFO: save_inference_dir : ./inference +[2022/04/18 10:17:07] root INFO: save_interval : 1 +[2022/04/18 10:17:07] root INFO: use_visualdl : False +[2022/04/18 10:17:07] root INFO: Infer : +[2022/04/18 10:17:07] root INFO: PostProcess : +[2022/04/18 10:17:07] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:17:07] root INFO: name : Topk +[2022/04/18 10:17:07] root INFO: topk : 5 +[2022/04/18 10:17:07] root INFO: batch_size : 10 +[2022/04/18 10:17:07] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:17:07] root INFO: transforms : +[2022/04/18 10:17:07] root INFO: DecodeImage : +[2022/04/18 10:17:07] root INFO: channel_first : False +[2022/04/18 10:17:07] root INFO: to_rgb : True +[2022/04/18 10:17:07] root INFO: ResizeImage : +[2022/04/18 10:17:07] root INFO: resize_short : 256 +[2022/04/18 10:17:07] root INFO: CropImage : +[2022/04/18 10:17:07] root INFO: size : 224 +[2022/04/18 10:17:07] root INFO: NormalizeImage : +[2022/04/18 10:17:07] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:17:07] root INFO: order : +[2022/04/18 10:17:07] root INFO: scale : 1.0/255.0 +[2022/04/18 10:17:07] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:17:07] root INFO: ToCHWImage : None +[2022/04/18 10:17:07] root INFO: Loss : +[2022/04/18 10:17:07] root INFO: Eval : +[2022/04/18 10:17:07] root INFO: CELoss : +[2022/04/18 10:17:07] root INFO: weight : 1.0 +[2022/04/18 10:17:07] root INFO: Train : +[2022/04/18 10:17:07] root INFO: CELoss : +[2022/04/18 10:17:07] root INFO: weight : 1.0 +[2022/04/18 10:17:07] root INFO: Metric : +[2022/04/18 10:17:07] root INFO: Eval : +[2022/04/18 10:17:07] root INFO: TopkAcc : +[2022/04/18 10:17:07] root INFO: topk : [1, 5] +[2022/04/18 10:17:07] root INFO: Train : +[2022/04/18 10:17:07] root INFO: TopkAcc : +[2022/04/18 10:17:07] root INFO: topk : [1, 5] +[2022/04/18 10:17:07] root INFO: Optimizer : +[2022/04/18 10:17:07] root INFO: lr : +[2022/04/18 10:17:07] root INFO: learning_rate : 0.0125 +[2022/04/18 10:17:07] root INFO: name : Cosine +[2022/04/18 10:17:07] root INFO: warmup_epoch : 5 +[2022/04/18 10:17:07] root INFO: momentum : 0.9 +[2022/04/18 10:17:07] root INFO: name : Momentum +[2022/04/18 10:17:07] root INFO: regularizer : +[2022/04/18 10:17:07] root INFO: coeff : 1e-05 +[2022/04/18 10:17:07] root INFO: name : L2 +[2022/04/18 10:17:07] root INFO: profiler_options : None +[2022/04/18 10:17:07] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:18:29] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:18:29] root INFO: Arch : +[2022/04/18 10:18:29] root INFO: class_num : 102 +[2022/04/18 10:18:29] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:18:29] root INFO: DataLoader : +[2022/04/18 10:18:29] root INFO: Eval : +[2022/04/18 10:18:29] root INFO: dataset : +[2022/04/18 10:18:29] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:18:29] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:18:29] root INFO: name : ImageNetDataset +[2022/04/18 10:18:29] root INFO: transform_ops : +[2022/04/18 10:18:29] root INFO: DecodeImage : +[2022/04/18 10:18:29] root INFO: channel_first : False +[2022/04/18 10:18:29] root INFO: to_rgb : True +[2022/04/18 10:18:29] root INFO: ResizeImage : +[2022/04/18 10:18:29] root INFO: resize_short : 256 +[2022/04/18 10:18:29] root INFO: CropImage : +[2022/04/18 10:18:29] root INFO: size : 224 +[2022/04/18 10:18:29] root INFO: NormalizeImage : +[2022/04/18 10:18:29] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:18:29] root INFO: order : +[2022/04/18 10:18:29] root INFO: scale : 1.0/255.0 +[2022/04/18 10:18:29] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:18:29] root INFO: loader : +[2022/04/18 10:18:29] root INFO: num_workers : 4 +[2022/04/18 10:18:29] root INFO: use_shared_memory : True +[2022/04/18 10:18:29] root INFO: sampler : +[2022/04/18 10:18:29] root INFO: batch_size : 64 +[2022/04/18 10:18:29] root INFO: drop_last : False +[2022/04/18 10:18:29] root INFO: name : DistributedBatchSampler +[2022/04/18 10:18:29] root INFO: shuffle : False +[2022/04/18 10:18:29] root INFO: Train : +[2022/04/18 10:18:29] root INFO: dataset : +[2022/04/18 10:18:29] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:18:29] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:18:29] root INFO: name : ImageNetDataset +[2022/04/18 10:18:29] root INFO: transform_ops : +[2022/04/18 10:18:29] root INFO: DecodeImage : +[2022/04/18 10:18:29] root INFO: channel_first : False +[2022/04/18 10:18:29] root INFO: to_rgb : True +[2022/04/18 10:18:29] root INFO: RandCropImage : +[2022/04/18 10:18:29] root INFO: size : 224 +[2022/04/18 10:18:29] root INFO: RandFlipImage : +[2022/04/18 10:18:29] root INFO: flip_code : 1 +[2022/04/18 10:18:29] root INFO: NormalizeImage : +[2022/04/18 10:18:29] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:18:29] root INFO: order : +[2022/04/18 10:18:29] root INFO: scale : 1.0/255.0 +[2022/04/18 10:18:29] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:18:29] root INFO: loader : +[2022/04/18 10:18:29] root INFO: num_workers : 4 +[2022/04/18 10:18:29] root INFO: use_shared_memory : True +[2022/04/18 10:18:29] root INFO: sampler : +[2022/04/18 10:18:29] root INFO: batch_size : 256 +[2022/04/18 10:18:29] root INFO: drop_last : False +[2022/04/18 10:18:29] root INFO: name : DistributedBatchSampler +[2022/04/18 10:18:29] root INFO: shuffle : True +[2022/04/18 10:18:29] root INFO: Global : +[2022/04/18 10:18:29] root INFO: checkpoints : None +[2022/04/18 10:18:29] root INFO: device : cpu +[2022/04/18 10:18:29] root INFO: epochs : 20 +[2022/04/18 10:18:29] root INFO: eval_during_train : True +[2022/04/18 10:18:29] root INFO: eval_interval : 1 +[2022/04/18 10:18:29] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:18:29] root INFO: output_dir : ./output/ +[2022/04/18 10:18:29] root INFO: pretrained_model : None +[2022/04/18 10:18:29] root INFO: print_batch_step : 10 +[2022/04/18 10:18:29] root INFO: save_inference_dir : ./inference +[2022/04/18 10:18:29] root INFO: save_interval : 1 +[2022/04/18 10:18:29] root INFO: use_visualdl : False +[2022/04/18 10:18:29] root INFO: Infer : +[2022/04/18 10:18:29] root INFO: PostProcess : +[2022/04/18 10:18:29] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:18:29] root INFO: name : Topk +[2022/04/18 10:18:29] root INFO: topk : 5 +[2022/04/18 10:18:29] root INFO: batch_size : 10 +[2022/04/18 10:18:29] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:18:29] root INFO: transforms : +[2022/04/18 10:18:29] root INFO: DecodeImage : +[2022/04/18 10:18:29] root INFO: channel_first : False +[2022/04/18 10:18:29] root INFO: to_rgb : True +[2022/04/18 10:18:29] root INFO: ResizeImage : +[2022/04/18 10:18:29] root INFO: resize_short : 256 +[2022/04/18 10:18:29] root INFO: CropImage : +[2022/04/18 10:18:29] root INFO: size : 224 +[2022/04/18 10:18:29] root INFO: NormalizeImage : +[2022/04/18 10:18:29] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:18:29] root INFO: order : +[2022/04/18 10:18:29] root INFO: scale : 1.0/255.0 +[2022/04/18 10:18:29] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:18:29] root INFO: ToCHWImage : None +[2022/04/18 10:18:29] root INFO: Loss : +[2022/04/18 10:18:29] root INFO: Eval : +[2022/04/18 10:18:29] root INFO: CELoss : +[2022/04/18 10:18:29] root INFO: weight : 1.0 +[2022/04/18 10:18:29] root INFO: Train : +[2022/04/18 10:18:29] root INFO: CELoss : +[2022/04/18 10:18:29] root INFO: weight : 1.0 +[2022/04/18 10:18:29] root INFO: Metric : +[2022/04/18 10:18:29] root INFO: Eval : +[2022/04/18 10:18:29] root INFO: TopkAcc : +[2022/04/18 10:18:29] root INFO: topk : [1, 5] +[2022/04/18 10:18:29] root INFO: Train : +[2022/04/18 10:18:29] root INFO: TopkAcc : +[2022/04/18 10:18:29] root INFO: topk : [1, 5] +[2022/04/18 10:18:29] root INFO: Optimizer : +[2022/04/18 10:18:29] root INFO: lr : +[2022/04/18 10:18:29] root INFO: learning_rate : 0.0125 +[2022/04/18 10:18:29] root INFO: name : Cosine +[2022/04/18 10:18:29] root INFO: warmup_epoch : 5 +[2022/04/18 10:18:29] root INFO: momentum : 0.9 +[2022/04/18 10:18:29] root INFO: name : Momentum +[2022/04/18 10:18:29] root INFO: regularizer : +[2022/04/18 10:18:29] root INFO: coeff : 1e-05 +[2022/04/18 10:18:29] root INFO: name : L2 +[2022/04/18 10:18:29] root INFO: profiler_options : None +[2022/04/18 10:18:29] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:22:55] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:22:55] root INFO: Arch : +[2022/04/18 10:22:55] root INFO: class_num : 102 +[2022/04/18 10:22:55] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:22:55] root INFO: DataLoader : +[2022/04/18 10:22:55] root INFO: Eval : +[2022/04/18 10:22:55] root INFO: dataset : +[2022/04/18 10:22:55] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:22:55] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:22:55] root INFO: name : ImageNetDataset +[2022/04/18 10:22:55] root INFO: transform_ops : +[2022/04/18 10:22:55] root INFO: DecodeImage : +[2022/04/18 10:22:55] root INFO: channel_first : False +[2022/04/18 10:22:55] root INFO: to_rgb : True +[2022/04/18 10:22:55] root INFO: ResizeImage : +[2022/04/18 10:22:55] root INFO: resize_short : 256 +[2022/04/18 10:22:55] root INFO: CropImage : +[2022/04/18 10:22:55] root INFO: size : 224 +[2022/04/18 10:22:55] root INFO: NormalizeImage : +[2022/04/18 10:22:55] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:22:55] root INFO: order : +[2022/04/18 10:22:55] root INFO: scale : 1.0/255.0 +[2022/04/18 10:22:55] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:22:55] root INFO: loader : +[2022/04/18 10:22:55] root INFO: num_workers : 4 +[2022/04/18 10:22:55] root INFO: use_shared_memory : True +[2022/04/18 10:22:55] root INFO: sampler : +[2022/04/18 10:22:55] root INFO: batch_size : 64 +[2022/04/18 10:22:55] root INFO: drop_last : False +[2022/04/18 10:22:55] root INFO: name : DistributedBatchSampler +[2022/04/18 10:22:55] root INFO: shuffle : False +[2022/04/18 10:22:55] root INFO: Train : +[2022/04/18 10:22:55] root INFO: dataset : +[2022/04/18 10:22:55] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:22:55] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:22:55] root INFO: name : ImageNetDataset +[2022/04/18 10:22:55] root INFO: transform_ops : +[2022/04/18 10:22:55] root INFO: DecodeImage : +[2022/04/18 10:22:55] root INFO: channel_first : False +[2022/04/18 10:22:55] root INFO: to_rgb : True +[2022/04/18 10:22:55] root INFO: RandCropImage : +[2022/04/18 10:22:55] root INFO: size : 224 +[2022/04/18 10:22:55] root INFO: RandFlipImage : +[2022/04/18 10:22:55] root INFO: flip_code : 1 +[2022/04/18 10:22:55] root INFO: NormalizeImage : +[2022/04/18 10:22:55] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:22:55] root INFO: order : +[2022/04/18 10:22:55] root INFO: scale : 1.0/255.0 +[2022/04/18 10:22:55] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:22:55] root INFO: loader : +[2022/04/18 10:22:55] root INFO: num_workers : 4 +[2022/04/18 10:22:55] root INFO: use_shared_memory : True +[2022/04/18 10:22:55] root INFO: sampler : +[2022/04/18 10:22:55] root INFO: batch_size : 256 +[2022/04/18 10:22:55] root INFO: drop_last : False +[2022/04/18 10:22:55] root INFO: name : DistributedBatchSampler +[2022/04/18 10:22:55] root INFO: shuffle : True +[2022/04/18 10:22:55] root INFO: Global : +[2022/04/18 10:22:55] root INFO: checkpoints : None +[2022/04/18 10:22:55] root INFO: device : cpu +[2022/04/18 10:22:55] root INFO: epochs : 20 +[2022/04/18 10:22:55] root INFO: eval_during_train : True +[2022/04/18 10:22:55] root INFO: eval_interval : 1 +[2022/04/18 10:22:55] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:22:55] root INFO: output_dir : ./output/ +[2022/04/18 10:22:55] root INFO: pretrained_model : None +[2022/04/18 10:22:55] root INFO: print_batch_step : 10 +[2022/04/18 10:22:55] root INFO: save_inference_dir : ./inference +[2022/04/18 10:22:55] root INFO: save_interval : 1 +[2022/04/18 10:22:55] root INFO: use_visualdl : False +[2022/04/18 10:22:55] root INFO: Infer : +[2022/04/18 10:22:55] root INFO: PostProcess : +[2022/04/18 10:22:55] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:22:55] root INFO: name : Topk +[2022/04/18 10:22:55] root INFO: topk : 5 +[2022/04/18 10:22:55] root INFO: batch_size : 10 +[2022/04/18 10:22:55] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:22:55] root INFO: transforms : +[2022/04/18 10:22:55] root INFO: DecodeImage : +[2022/04/18 10:22:55] root INFO: channel_first : False +[2022/04/18 10:22:55] root INFO: to_rgb : True +[2022/04/18 10:22:55] root INFO: ResizeImage : +[2022/04/18 10:22:55] root INFO: resize_short : 256 +[2022/04/18 10:22:55] root INFO: CropImage : +[2022/04/18 10:22:55] root INFO: size : 224 +[2022/04/18 10:22:55] root INFO: NormalizeImage : +[2022/04/18 10:22:55] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:22:55] root INFO: order : +[2022/04/18 10:22:55] root INFO: scale : 1.0/255.0 +[2022/04/18 10:22:55] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:22:55] root INFO: ToCHWImage : None +[2022/04/18 10:22:55] root INFO: Loss : +[2022/04/18 10:22:55] root INFO: Eval : +[2022/04/18 10:22:55] root INFO: CELoss : +[2022/04/18 10:22:55] root INFO: weight : 1.0 +[2022/04/18 10:22:55] root INFO: Train : +[2022/04/18 10:22:55] root INFO: CELoss : +[2022/04/18 10:22:55] root INFO: weight : 1.0 +[2022/04/18 10:22:55] root INFO: Metric : +[2022/04/18 10:22:55] root INFO: Eval : +[2022/04/18 10:22:55] root INFO: TopkAcc : +[2022/04/18 10:22:55] root INFO: topk : [1, 5] +[2022/04/18 10:22:55] root INFO: Train : +[2022/04/18 10:22:55] root INFO: TopkAcc : +[2022/04/18 10:22:55] root INFO: topk : [1, 5] +[2022/04/18 10:22:55] root INFO: Optimizer : +[2022/04/18 10:22:55] root INFO: lr : +[2022/04/18 10:22:55] root INFO: learning_rate : 0.0125 +[2022/04/18 10:22:55] root INFO: name : Cosine +[2022/04/18 10:22:55] root INFO: warmup_epoch : 5 +[2022/04/18 10:22:55] root INFO: momentum : 0.9 +[2022/04/18 10:22:55] root INFO: name : Momentum +[2022/04/18 10:22:55] root INFO: regularizer : +[2022/04/18 10:22:55] root INFO: coeff : 1e-05 +[2022/04/18 10:22:55] root INFO: name : L2 +[2022/04/18 10:22:55] root INFO: profiler_options : None +[2022/04/18 10:22:55] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:23:40] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:23:40] root INFO: Arch : +[2022/04/18 10:23:40] root INFO: class_num : 102 +[2022/04/18 10:23:40] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:23:40] root INFO: DataLoader : +[2022/04/18 10:23:40] root INFO: Eval : +[2022/04/18 10:23:40] root INFO: dataset : +[2022/04/18 10:23:40] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:23:40] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:23:40] root INFO: name : ImageNetDataset +[2022/04/18 10:23:40] root INFO: transform_ops : +[2022/04/18 10:23:40] root INFO: DecodeImage : +[2022/04/18 10:23:40] root INFO: channel_first : False +[2022/04/18 10:23:40] root INFO: to_rgb : True +[2022/04/18 10:23:40] root INFO: ResizeImage : +[2022/04/18 10:23:40] root INFO: resize_short : 256 +[2022/04/18 10:23:40] root INFO: CropImage : +[2022/04/18 10:23:40] root INFO: size : 224 +[2022/04/18 10:23:40] root INFO: NormalizeImage : +[2022/04/18 10:23:40] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:23:40] root INFO: order : +[2022/04/18 10:23:40] root INFO: scale : 1.0/255.0 +[2022/04/18 10:23:40] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:23:40] root INFO: loader : +[2022/04/18 10:23:40] root INFO: num_workers : 4 +[2022/04/18 10:23:40] root INFO: use_shared_memory : True +[2022/04/18 10:23:40] root INFO: sampler : +[2022/04/18 10:23:40] root INFO: batch_size : 64 +[2022/04/18 10:23:40] root INFO: drop_last : False +[2022/04/18 10:23:40] root INFO: name : DistributedBatchSampler +[2022/04/18 10:23:40] root INFO: shuffle : False +[2022/04/18 10:23:40] root INFO: Train : +[2022/04/18 10:23:40] root INFO: dataset : +[2022/04/18 10:23:40] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:23:40] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:23:40] root INFO: name : ImageNetDataset +[2022/04/18 10:23:40] root INFO: transform_ops : +[2022/04/18 10:23:40] root INFO: DecodeImage : +[2022/04/18 10:23:40] root INFO: channel_first : False +[2022/04/18 10:23:40] root INFO: to_rgb : True +[2022/04/18 10:23:40] root INFO: RandCropImage : +[2022/04/18 10:23:40] root INFO: size : 224 +[2022/04/18 10:23:40] root INFO: RandFlipImage : +[2022/04/18 10:23:40] root INFO: flip_code : 1 +[2022/04/18 10:23:40] root INFO: NormalizeImage : +[2022/04/18 10:23:40] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:23:40] root INFO: order : +[2022/04/18 10:23:40] root INFO: scale : 1.0/255.0 +[2022/04/18 10:23:40] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:23:40] root INFO: loader : +[2022/04/18 10:23:40] root INFO: num_workers : 4 +[2022/04/18 10:23:40] root INFO: use_shared_memory : True +[2022/04/18 10:23:40] root INFO: sampler : +[2022/04/18 10:23:40] root INFO: batch_size : 256 +[2022/04/18 10:23:40] root INFO: drop_last : False +[2022/04/18 10:23:40] root INFO: name : DistributedBatchSampler +[2022/04/18 10:23:40] root INFO: shuffle : True +[2022/04/18 10:23:40] root INFO: Global : +[2022/04/18 10:23:40] root INFO: checkpoints : None +[2022/04/18 10:23:40] root INFO: device : cpu +[2022/04/18 10:23:40] root INFO: epochs : 20 +[2022/04/18 10:23:40] root INFO: eval_during_train : True +[2022/04/18 10:23:40] root INFO: eval_interval : 1 +[2022/04/18 10:23:40] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:23:41] root INFO: output_dir : ./output/ +[2022/04/18 10:23:41] root INFO: pretrained_model : None +[2022/04/18 10:23:41] root INFO: print_batch_step : 10 +[2022/04/18 10:23:41] root INFO: save_inference_dir : ./inference +[2022/04/18 10:23:41] root INFO: save_interval : 1 +[2022/04/18 10:23:41] root INFO: use_visualdl : False +[2022/04/18 10:23:41] root INFO: Infer : +[2022/04/18 10:23:41] root INFO: PostProcess : +[2022/04/18 10:23:41] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:23:41] root INFO: name : Topk +[2022/04/18 10:23:41] root INFO: topk : 5 +[2022/04/18 10:23:41] root INFO: batch_size : 10 +[2022/04/18 10:23:41] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:23:41] root INFO: transforms : +[2022/04/18 10:23:41] root INFO: DecodeImage : +[2022/04/18 10:23:41] root INFO: channel_first : False +[2022/04/18 10:23:41] root INFO: to_rgb : True +[2022/04/18 10:23:41] root INFO: ResizeImage : +[2022/04/18 10:23:41] root INFO: resize_short : 256 +[2022/04/18 10:23:41] root INFO: CropImage : +[2022/04/18 10:23:41] root INFO: size : 224 +[2022/04/18 10:23:41] root INFO: NormalizeImage : +[2022/04/18 10:23:41] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:23:41] root INFO: order : +[2022/04/18 10:23:41] root INFO: scale : 1.0/255.0 +[2022/04/18 10:23:41] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:23:41] root INFO: ToCHWImage : None +[2022/04/18 10:23:41] root INFO: Loss : +[2022/04/18 10:23:41] root INFO: Eval : +[2022/04/18 10:23:41] root INFO: CELoss : +[2022/04/18 10:23:41] root INFO: weight : 1.0 +[2022/04/18 10:23:41] root INFO: Train : +[2022/04/18 10:23:41] root INFO: CELoss : +[2022/04/18 10:23:41] root INFO: weight : 1.0 +[2022/04/18 10:23:41] root INFO: Metric : +[2022/04/18 10:23:41] root INFO: Eval : +[2022/04/18 10:23:41] root INFO: TopkAcc : +[2022/04/18 10:23:41] root INFO: topk : [1, 5] +[2022/04/18 10:23:41] root INFO: Train : +[2022/04/18 10:23:41] root INFO: TopkAcc : +[2022/04/18 10:23:41] root INFO: topk : [1, 5] +[2022/04/18 10:23:41] root INFO: Optimizer : +[2022/04/18 10:23:41] root INFO: lr : +[2022/04/18 10:23:41] root INFO: learning_rate : 0.0125 +[2022/04/18 10:23:41] root INFO: name : Cosine +[2022/04/18 10:23:41] root INFO: warmup_epoch : 5 +[2022/04/18 10:23:41] root INFO: momentum : 0.9 +[2022/04/18 10:23:41] root INFO: name : Momentum +[2022/04/18 10:23:41] root INFO: regularizer : +[2022/04/18 10:23:41] root INFO: coeff : 1e-05 +[2022/04/18 10:23:41] root INFO: name : L2 +[2022/04/18 10:23:41] root INFO: profiler_options : None +[2022/04/18 10:23:41] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:25:40] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:25:40] root INFO: Arch : +[2022/04/18 10:25:40] root INFO: class_num : 102 +[2022/04/18 10:25:40] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:25:40] root INFO: pretrained : True +[2022/04/18 10:25:40] root INFO: DataLoader : +[2022/04/18 10:25:40] root INFO: Eval : +[2022/04/18 10:25:40] root INFO: dataset : +[2022/04/18 10:25:40] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:25:40] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:25:40] root INFO: name : ImageNetDataset +[2022/04/18 10:25:40] root INFO: transform_ops : +[2022/04/18 10:25:40] root INFO: DecodeImage : +[2022/04/18 10:25:40] root INFO: channel_first : False +[2022/04/18 10:25:40] root INFO: to_rgb : True +[2022/04/18 10:25:40] root INFO: ResizeImage : +[2022/04/18 10:25:40] root INFO: resize_short : 256 +[2022/04/18 10:25:40] root INFO: CropImage : +[2022/04/18 10:25:40] root INFO: size : 224 +[2022/04/18 10:25:40] root INFO: NormalizeImage : +[2022/04/18 10:25:40] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:25:40] root INFO: order : +[2022/04/18 10:25:40] root INFO: scale : 1.0/255.0 +[2022/04/18 10:25:40] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:25:40] root INFO: loader : +[2022/04/18 10:25:40] root INFO: num_workers : 4 +[2022/04/18 10:25:40] root INFO: use_shared_memory : True +[2022/04/18 10:25:40] root INFO: sampler : +[2022/04/18 10:25:40] root INFO: batch_size : 64 +[2022/04/18 10:25:40] root INFO: drop_last : False +[2022/04/18 10:25:40] root INFO: name : DistributedBatchSampler +[2022/04/18 10:25:40] root INFO: shuffle : False +[2022/04/18 10:25:40] root INFO: Train : +[2022/04/18 10:25:40] root INFO: dataset : +[2022/04/18 10:25:40] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:25:40] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:25:40] root INFO: name : ImageNetDataset +[2022/04/18 10:25:40] root INFO: transform_ops : +[2022/04/18 10:25:40] root INFO: DecodeImage : +[2022/04/18 10:25:40] root INFO: channel_first : False +[2022/04/18 10:25:40] root INFO: to_rgb : True +[2022/04/18 10:25:40] root INFO: RandCropImage : +[2022/04/18 10:25:40] root INFO: size : 224 +[2022/04/18 10:25:40] root INFO: RandFlipImage : +[2022/04/18 10:25:40] root INFO: flip_code : 1 +[2022/04/18 10:25:40] root INFO: NormalizeImage : +[2022/04/18 10:25:40] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:25:40] root INFO: order : +[2022/04/18 10:25:40] root INFO: scale : 1.0/255.0 +[2022/04/18 10:25:40] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:25:40] root INFO: loader : +[2022/04/18 10:25:40] root INFO: num_workers : 4 +[2022/04/18 10:25:40] root INFO: use_shared_memory : True +[2022/04/18 10:25:40] root INFO: sampler : +[2022/04/18 10:25:40] root INFO: batch_size : 256 +[2022/04/18 10:25:40] root INFO: drop_last : False +[2022/04/18 10:25:40] root INFO: name : DistributedBatchSampler +[2022/04/18 10:25:40] root INFO: shuffle : True +[2022/04/18 10:25:40] root INFO: Global : +[2022/04/18 10:25:40] root INFO: checkpoints : None +[2022/04/18 10:25:40] root INFO: device : cpu +[2022/04/18 10:25:40] root INFO: epochs : 20 +[2022/04/18 10:25:40] root INFO: eval_during_train : True +[2022/04/18 10:25:40] root INFO: eval_interval : 1 +[2022/04/18 10:25:40] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:25:40] root INFO: output_dir : ./output/ +[2022/04/18 10:25:40] root INFO: pretrained_model : None +[2022/04/18 10:25:40] root INFO: print_batch_step : 10 +[2022/04/18 10:25:40] root INFO: save_inference_dir : ./inference +[2022/04/18 10:25:40] root INFO: save_interval : 1 +[2022/04/18 10:25:40] root INFO: use_visualdl : False +[2022/04/18 10:25:40] root INFO: Infer : +[2022/04/18 10:25:40] root INFO: PostProcess : +[2022/04/18 10:25:40] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:25:40] root INFO: name : Topk +[2022/04/18 10:25:40] root INFO: topk : 5 +[2022/04/18 10:25:40] root INFO: batch_size : 10 +[2022/04/18 10:25:40] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:25:40] root INFO: transforms : +[2022/04/18 10:25:40] root INFO: DecodeImage : +[2022/04/18 10:25:40] root INFO: channel_first : False +[2022/04/18 10:25:40] root INFO: to_rgb : True +[2022/04/18 10:25:40] root INFO: ResizeImage : +[2022/04/18 10:25:40] root INFO: resize_short : 256 +[2022/04/18 10:25:40] root INFO: CropImage : +[2022/04/18 10:25:40] root INFO: size : 224 +[2022/04/18 10:25:40] root INFO: NormalizeImage : +[2022/04/18 10:25:40] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:25:40] root INFO: order : +[2022/04/18 10:25:40] root INFO: scale : 1.0/255.0 +[2022/04/18 10:25:40] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:25:40] root INFO: ToCHWImage : None +[2022/04/18 10:25:40] root INFO: Loss : +[2022/04/18 10:25:40] root INFO: Eval : +[2022/04/18 10:25:40] root INFO: CELoss : +[2022/04/18 10:25:40] root INFO: weight : 1.0 +[2022/04/18 10:25:40] root INFO: Train : +[2022/04/18 10:25:40] root INFO: CELoss : +[2022/04/18 10:25:40] root INFO: weight : 1.0 +[2022/04/18 10:25:40] root INFO: Metric : +[2022/04/18 10:25:40] root INFO: Eval : +[2022/04/18 10:25:40] root INFO: TopkAcc : +[2022/04/18 10:25:40] root INFO: topk : [1, 5] +[2022/04/18 10:25:40] root INFO: Train : +[2022/04/18 10:25:40] root INFO: TopkAcc : +[2022/04/18 10:25:40] root INFO: topk : [1, 5] +[2022/04/18 10:25:40] root INFO: Optimizer : +[2022/04/18 10:25:40] root INFO: lr : +[2022/04/18 10:25:40] root INFO: learning_rate : 0.0125 +[2022/04/18 10:25:40] root INFO: name : Cosine +[2022/04/18 10:25:40] root INFO: warmup_epoch : 5 +[2022/04/18 10:25:40] root INFO: momentum : 0.9 +[2022/04/18 10:25:40] root INFO: name : Momentum +[2022/04/18 10:25:40] root INFO: regularizer : +[2022/04/18 10:25:40] root INFO: coeff : 1e-05 +[2022/04/18 10:25:40] root INFO: name : L2 +[2022/04/18 10:25:40] root INFO: profiler_options : None +[2022/04/18 10:25:40] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:27:41] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:27:41] root INFO: Arch : +[2022/04/18 10:27:41] root INFO: class_num : 102 +[2022/04/18 10:27:41] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:27:41] root INFO: DataLoader : +[2022/04/18 10:27:41] root INFO: Eval : +[2022/04/18 10:27:41] root INFO: dataset : +[2022/04/18 10:27:41] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:27:41] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:27:41] root INFO: name : ImageNetDataset +[2022/04/18 10:27:41] root INFO: transform_ops : +[2022/04/18 10:27:41] root INFO: DecodeImage : +[2022/04/18 10:27:41] root INFO: channel_first : False +[2022/04/18 10:27:41] root INFO: to_rgb : True +[2022/04/18 10:27:41] root INFO: ResizeImage : +[2022/04/18 10:27:41] root INFO: resize_short : 256 +[2022/04/18 10:27:41] root INFO: CropImage : +[2022/04/18 10:27:41] root INFO: size : 224 +[2022/04/18 10:27:41] root INFO: NormalizeImage : +[2022/04/18 10:27:41] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:27:41] root INFO: order : +[2022/04/18 10:27:41] root INFO: scale : 1.0/255.0 +[2022/04/18 10:27:41] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:27:41] root INFO: loader : +[2022/04/18 10:27:41] root INFO: num_workers : 4 +[2022/04/18 10:27:41] root INFO: use_shared_memory : True +[2022/04/18 10:27:41] root INFO: sampler : +[2022/04/18 10:27:41] root INFO: batch_size : 64 +[2022/04/18 10:27:41] root INFO: drop_last : False +[2022/04/18 10:27:41] root INFO: name : DistributedBatchSampler +[2022/04/18 10:27:41] root INFO: shuffle : False +[2022/04/18 10:27:41] root INFO: Train : +[2022/04/18 10:27:41] root INFO: dataset : +[2022/04/18 10:27:41] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:27:41] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:27:41] root INFO: name : ImageNetDataset +[2022/04/18 10:27:41] root INFO: transform_ops : +[2022/04/18 10:27:41] root INFO: DecodeImage : +[2022/04/18 10:27:41] root INFO: channel_first : False +[2022/04/18 10:27:41] root INFO: to_rgb : True +[2022/04/18 10:27:41] root INFO: RandCropImage : +[2022/04/18 10:27:41] root INFO: size : 224 +[2022/04/18 10:27:41] root INFO: RandFlipImage : +[2022/04/18 10:27:41] root INFO: flip_code : 1 +[2022/04/18 10:27:41] root INFO: NormalizeImage : +[2022/04/18 10:27:41] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:27:41] root INFO: order : +[2022/04/18 10:27:41] root INFO: scale : 1.0/255.0 +[2022/04/18 10:27:41] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:27:41] root INFO: loader : +[2022/04/18 10:27:41] root INFO: num_workers : 4 +[2022/04/18 10:27:41] root INFO: use_shared_memory : True +[2022/04/18 10:27:41] root INFO: sampler : +[2022/04/18 10:27:41] root INFO: batch_size : 256 +[2022/04/18 10:27:41] root INFO: drop_last : False +[2022/04/18 10:27:41] root INFO: name : DistributedBatchSampler +[2022/04/18 10:27:41] root INFO: shuffle : True +[2022/04/18 10:27:41] root INFO: Global : +[2022/04/18 10:27:41] root INFO: checkpoints : None +[2022/04/18 10:27:41] root INFO: device : cpu +[2022/04/18 10:27:41] root INFO: epochs : 20 +[2022/04/18 10:27:41] root INFO: eval_during_train : True +[2022/04/18 10:27:41] root INFO: eval_interval : 1 +[2022/04/18 10:27:41] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:27:41] root INFO: output_dir : ./output/ +[2022/04/18 10:27:41] root INFO: pretrained_model : None +[2022/04/18 10:27:41] root INFO: print_batch_step : 10 +[2022/04/18 10:27:41] root INFO: save_inference_dir : ./inference +[2022/04/18 10:27:41] root INFO: save_interval : 1 +[2022/04/18 10:27:41] root INFO: use_visualdl : False +[2022/04/18 10:27:41] root INFO: Infer : +[2022/04/18 10:27:41] root INFO: PostProcess : +[2022/04/18 10:27:41] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:27:41] root INFO: name : Topk +[2022/04/18 10:27:41] root INFO: topk : 5 +[2022/04/18 10:27:41] root INFO: batch_size : 10 +[2022/04/18 10:27:41] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:27:41] root INFO: transforms : +[2022/04/18 10:27:41] root INFO: DecodeImage : +[2022/04/18 10:27:41] root INFO: channel_first : False +[2022/04/18 10:27:41] root INFO: to_rgb : True +[2022/04/18 10:27:41] root INFO: ResizeImage : +[2022/04/18 10:27:41] root INFO: resize_short : 256 +[2022/04/18 10:27:41] root INFO: CropImage : +[2022/04/18 10:27:41] root INFO: size : 224 +[2022/04/18 10:27:41] root INFO: NormalizeImage : +[2022/04/18 10:27:41] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:27:41] root INFO: order : +[2022/04/18 10:27:41] root INFO: scale : 1.0/255.0 +[2022/04/18 10:27:41] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:27:41] root INFO: ToCHWImage : None +[2022/04/18 10:27:41] root INFO: Loss : +[2022/04/18 10:27:41] root INFO: Eval : +[2022/04/18 10:27:41] root INFO: CELoss : +[2022/04/18 10:27:41] root INFO: weight : 1.0 +[2022/04/18 10:27:41] root INFO: Train : +[2022/04/18 10:27:41] root INFO: CELoss : +[2022/04/18 10:27:41] root INFO: weight : 1.0 +[2022/04/18 10:27:41] root INFO: Metric : +[2022/04/18 10:27:41] root INFO: Eval : +[2022/04/18 10:27:41] root INFO: TopkAcc : +[2022/04/18 10:27:41] root INFO: topk : [1, 5] +[2022/04/18 10:27:41] root INFO: Train : +[2022/04/18 10:27:41] root INFO: TopkAcc : +[2022/04/18 10:27:41] root INFO: topk : [1, 5] +[2022/04/18 10:27:41] root INFO: Optimizer : +[2022/04/18 10:27:41] root INFO: lr : +[2022/04/18 10:27:41] root INFO: learning_rate : 0.0125 +[2022/04/18 10:27:41] root INFO: name : Cosine +[2022/04/18 10:27:41] root INFO: warmup_epoch : 5 +[2022/04/18 10:27:41] root INFO: momentum : 0.9 +[2022/04/18 10:27:41] root INFO: name : Momentum +[2022/04/18 10:27:41] root INFO: regularizer : +[2022/04/18 10:27:41] root INFO: coeff : 1e-05 +[2022/04/18 10:27:41] root INFO: name : L2 +[2022/04/18 10:27:41] root INFO: profiler_options : None +[2022/04/18 10:27:41] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:29:50] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 10:29:50] root INFO: Arch : +[2022/04/18 10:29:50] root INFO: class_num : 102 +[2022/04/18 10:29:50] root INFO: name : ShuffleNetV2_x0_25 +[2022/04/18 10:29:50] root INFO: DataLoader : +[2022/04/18 10:29:50] root INFO: Eval : +[2022/04/18 10:29:50] root INFO: dataset : +[2022/04/18 10:29:50] root INFO: cls_label_path : ./dataset/flowers102/val_list.txt +[2022/04/18 10:29:50] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:29:50] root INFO: name : ImageNetDataset +[2022/04/18 10:29:50] root INFO: transform_ops : +[2022/04/18 10:29:50] root INFO: DecodeImage : +[2022/04/18 10:29:50] root INFO: channel_first : False +[2022/04/18 10:29:50] root INFO: to_rgb : True +[2022/04/18 10:29:50] root INFO: ResizeImage : +[2022/04/18 10:29:50] root INFO: resize_short : 256 +[2022/04/18 10:29:50] root INFO: CropImage : +[2022/04/18 10:29:50] root INFO: size : 224 +[2022/04/18 10:29:50] root INFO: NormalizeImage : +[2022/04/18 10:29:50] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:29:50] root INFO: order : +[2022/04/18 10:29:50] root INFO: scale : 1.0/255.0 +[2022/04/18 10:29:50] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:29:50] root INFO: loader : +[2022/04/18 10:29:50] root INFO: num_workers : 4 +[2022/04/18 10:29:50] root INFO: use_shared_memory : True +[2022/04/18 10:29:50] root INFO: sampler : +[2022/04/18 10:29:50] root INFO: batch_size : 64 +[2022/04/18 10:29:50] root INFO: drop_last : False +[2022/04/18 10:29:50] root INFO: name : DistributedBatchSampler +[2022/04/18 10:29:50] root INFO: shuffle : False +[2022/04/18 10:29:50] root INFO: Train : +[2022/04/18 10:29:50] root INFO: dataset : +[2022/04/18 10:29:50] root INFO: cls_label_path : ./dataset/flowers102/train_list.txt +[2022/04/18 10:29:50] root INFO: image_root : ./dataset/flowers102/ +[2022/04/18 10:29:50] root INFO: name : ImageNetDataset +[2022/04/18 10:29:50] root INFO: transform_ops : +[2022/04/18 10:29:50] root INFO: DecodeImage : +[2022/04/18 10:29:50] root INFO: channel_first : False +[2022/04/18 10:29:50] root INFO: to_rgb : True +[2022/04/18 10:29:50] root INFO: RandCropImage : +[2022/04/18 10:29:50] root INFO: size : 224 +[2022/04/18 10:29:50] root INFO: RandFlipImage : +[2022/04/18 10:29:50] root INFO: flip_code : 1 +[2022/04/18 10:29:50] root INFO: NormalizeImage : +[2022/04/18 10:29:50] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:29:50] root INFO: order : +[2022/04/18 10:29:50] root INFO: scale : 1.0/255.0 +[2022/04/18 10:29:50] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:29:50] root INFO: loader : +[2022/04/18 10:29:50] root INFO: num_workers : 4 +[2022/04/18 10:29:50] root INFO: use_shared_memory : True +[2022/04/18 10:29:50] root INFO: sampler : +[2022/04/18 10:29:50] root INFO: batch_size : 256 +[2022/04/18 10:29:50] root INFO: drop_last : False +[2022/04/18 10:29:50] root INFO: name : DistributedBatchSampler +[2022/04/18 10:29:50] root INFO: shuffle : True +[2022/04/18 10:29:50] root INFO: Global : +[2022/04/18 10:29:50] root INFO: checkpoints : None +[2022/04/18 10:29:50] root INFO: device : cpu +[2022/04/18 10:29:50] root INFO: epochs : 20 +[2022/04/18 10:29:50] root INFO: eval_during_train : True +[2022/04/18 10:29:50] root INFO: eval_interval : 1 +[2022/04/18 10:29:50] root INFO: image_shape : [3, 224, 224] +[2022/04/18 10:29:50] root INFO: output_dir : ./output/ +[2022/04/18 10:29:50] root INFO: pretrained_model : None +[2022/04/18 10:29:50] root INFO: print_batch_step : 10 +[2022/04/18 10:29:50] root INFO: save_inference_dir : ./inference +[2022/04/18 10:29:50] root INFO: save_interval : 1 +[2022/04/18 10:29:50] root INFO: use_visualdl : False +[2022/04/18 10:29:50] root INFO: Infer : +[2022/04/18 10:29:50] root INFO: PostProcess : +[2022/04/18 10:29:50] root INFO: class_id_map_file : ./dataset/flowers102/flowers102_label_list.txt +[2022/04/18 10:29:50] root INFO: name : Topk +[2022/04/18 10:29:50] root INFO: topk : 5 +[2022/04/18 10:29:50] root INFO: batch_size : 10 +[2022/04/18 10:29:50] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 10:29:50] root INFO: transforms : +[2022/04/18 10:29:50] root INFO: DecodeImage : +[2022/04/18 10:29:50] root INFO: channel_first : False +[2022/04/18 10:29:50] root INFO: to_rgb : True +[2022/04/18 10:29:50] root INFO: ResizeImage : +[2022/04/18 10:29:50] root INFO: resize_short : 256 +[2022/04/18 10:29:50] root INFO: CropImage : +[2022/04/18 10:29:50] root INFO: size : 224 +[2022/04/18 10:29:50] root INFO: NormalizeImage : +[2022/04/18 10:29:50] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 10:29:50] root INFO: order : +[2022/04/18 10:29:50] root INFO: scale : 1.0/255.0 +[2022/04/18 10:29:50] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 10:29:50] root INFO: ToCHWImage : None +[2022/04/18 10:29:50] root INFO: Loss : +[2022/04/18 10:29:50] root INFO: Eval : +[2022/04/18 10:29:50] root INFO: CELoss : +[2022/04/18 10:29:50] root INFO: weight : 1.0 +[2022/04/18 10:29:50] root INFO: Train : +[2022/04/18 10:29:50] root INFO: CELoss : +[2022/04/18 10:29:50] root INFO: weight : 1.0 +[2022/04/18 10:29:50] root INFO: Metric : +[2022/04/18 10:29:50] root INFO: Eval : +[2022/04/18 10:29:50] root INFO: TopkAcc : +[2022/04/18 10:29:50] root INFO: topk : [1, 5] +[2022/04/18 10:29:50] root INFO: Train : +[2022/04/18 10:29:50] root INFO: TopkAcc : +[2022/04/18 10:29:50] root INFO: topk : [1, 5] +[2022/04/18 10:29:50] root INFO: Optimizer : +[2022/04/18 10:29:50] root INFO: lr : +[2022/04/18 10:29:50] root INFO: learning_rate : 0.0125 +[2022/04/18 10:29:50] root INFO: name : Cosine +[2022/04/18 10:29:50] root INFO: warmup_epoch : 5 +[2022/04/18 10:29:50] root INFO: momentum : 0.9 +[2022/04/18 10:29:50] root INFO: name : Momentum +[2022/04/18 10:29:50] root INFO: regularizer : +[2022/04/18 10:29:50] root INFO: coeff : 1e-05 +[2022/04/18 10:29:50] root INFO: name : L2 +[2022/04/18 10:29:50] root INFO: profiler_options : None +[2022/04/18 10:29:50] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 10:29:50] root WARNING: The training strategy in config files provided by PaddleClas is based on 4 gpus. But the number of gpus is 1 in current training. Please modify the stategy (learning rate, batch size and so on) if use config files in PaddleClas to train. +[2022/04/18 10:30:01] root INFO: [Train][Epoch 1/20][Iter: 0/4]lr: 0.00063, top1: 0.01562, top5: 0.04688, CELoss: 4.72476, loss: 4.72476, batch_cost: 11.32137s, reader_cost: 1.80961, ips: 22.61211 images/sec, eta: 0:15:05 +[2022/04/18 10:30:12] root INFO: [Train][Epoch 1/20][Avg]top1: 0.01823, top5: 0.05859, CELoss: 4.74742, loss: 4.74742 +[2022/04/18 10:30:12] root INFO: [Eval][Epoch 1][Iter: 0/16]CELoss: 7.71317, loss: 7.71317, top1: 0.00000, top5: 0.00000, batch_cost: 0.87117s, reader_cost: 0.50988, ips: 73.46428 images/sec +[2022/04/18 10:30:18] root INFO: [Eval][Epoch 1][Iter: 10/16]CELoss: 9.23040, loss: 9.23040, top1: 0.00000, top5: 0.06250, batch_cost: 0.52336s, reader_cost: 0.16568, ips: 122.28759 images/sec +[2022/04/18 10:30:20] root INFO: [Eval][Epoch 1][Avg]CELoss: 8.66056, loss: 8.66056, top1: 0.01042, top5: 0.05208 +[2022/04/18 10:30:20] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\best_model +[2022/04/18 10:30:20] root INFO: [Eval][Epoch 1][best metric: 0.010416666666666666] +[2022/04/18 10:30:20] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_1 +[2022/04/18 10:30:20] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:30:27] root INFO: [Train][Epoch 2/20][Iter: 0/4]lr: 0.00250, top1: 0.01562, top5: 0.06641, CELoss: 4.73765, loss: 4.73765, batch_cost: 7.19691s, reader_cost: 0.89064, ips: 35.57083 images/sec, eta: 0:09:06 +[2022/04/18 10:30:38] root INFO: [Train][Epoch 2/20][Avg]top1: 0.01823, top5: 0.05469, CELoss: 4.75268, loss: 4.75268 +[2022/04/18 10:30:39] root INFO: [Eval][Epoch 2][Iter: 0/16]CELoss: 4.73498, loss: 4.73498, top1: 0.01562, top5: 0.07812, batch_cost: 0.80981s, reader_cost: 0.44976, ips: 79.03089 images/sec +[2022/04/18 10:30:44] root INFO: [Eval][Epoch 2][Iter: 10/16]CELoss: 4.71561, loss: 4.71561, top1: 0.04688, top5: 0.20312, batch_cost: 0.50151s, reader_cost: 0.13841, ips: 127.61419 images/sec +[2022/04/18 10:30:46] root INFO: [Eval][Epoch 2][Avg]CELoss: 4.86986, loss: 4.86986, top1: 0.01354, top5: 0.05729 +[2022/04/18 10:30:46] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\best_model +[2022/04/18 10:30:46] root INFO: [Eval][Epoch 2][best metric: 0.013541666666666667] +[2022/04/18 10:30:46] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_2 +[2022/04/18 10:30:46] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:30:53] root INFO: [Train][Epoch 3/20][Iter: 0/4]lr: 0.00438, top1: 0.02344, top5: 0.07031, CELoss: 4.72546, loss: 4.72546, batch_cost: 6.63502s, reader_cost: 0.73936, ips: 38.58317 images/sec, eta: 0:07:57 +[2022/04/18 10:31:03] root INFO: [Train][Epoch 3/20][Avg]top1: 0.01693, top5: 0.06380, CELoss: 4.74237, loss: 4.74237 +[2022/04/18 10:31:04] root INFO: [Eval][Epoch 3][Iter: 0/16]CELoss: 4.63404, loss: 4.63404, top1: 0.00000, top5: 0.12500, batch_cost: 0.82113s, reader_cost: 0.44998, ips: 77.94178 images/sec +[2022/04/18 10:31:09] root INFO: [Eval][Epoch 3][Iter: 10/16]CELoss: 4.44187, loss: 4.44187, top1: 0.14062, top5: 0.39062, batch_cost: 0.50167s, reader_cost: 0.13407, ips: 127.57276 images/sec +[2022/04/18 10:31:11] root INFO: [Eval][Epoch 3][Avg]CELoss: 4.66967, loss: 4.66967, top1: 0.01042, top5: 0.05104 +[2022/04/18 10:31:11] root INFO: [Eval][Epoch 3][best metric: 0.013541666666666667] +[2022/04/18 10:31:11] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_3 +[2022/04/18 10:31:11] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:31:20] root INFO: [Train][Epoch 4/20][Iter: 0/4]lr: 0.00625, top1: 0.01172, top5: 0.05078, CELoss: 4.74420, loss: 4.74420, batch_cost: 6.52034s, reader_cost: 0.68773, ips: 39.26178 images/sec, eta: 0:07:23 +[2022/04/18 10:31:31] root INFO: [Train][Epoch 4/20][Avg]top1: 0.01432, top5: 0.05729, CELoss: 4.73518, loss: 4.73518 +[2022/04/18 10:31:32] root INFO: [Eval][Epoch 4][Iter: 0/16]CELoss: 4.60896, loss: 4.60896, top1: 0.04688, top5: 0.12500, batch_cost: 0.92905s, reader_cost: 0.51022, ips: 68.88763 images/sec +[2022/04/18 10:31:38] root INFO: [Eval][Epoch 4][Iter: 10/16]CELoss: 4.42349, loss: 4.42349, top1: 0.01562, top5: 0.34375, batch_cost: 0.58857s, reader_cost: 0.15611, ips: 108.73772 images/sec +[2022/04/18 10:31:40] root INFO: [Eval][Epoch 4][Avg]CELoss: 4.65612, loss: 4.65612, top1: 0.00833, top5: 0.05208 +[2022/04/18 10:31:40] root INFO: [Eval][Epoch 4][best metric: 0.013541666666666667] +[2022/04/18 10:31:40] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_4 +[2022/04/18 10:31:40] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:31:49] root INFO: [Train][Epoch 5/20][Iter: 0/4]lr: 0.00813, top1: 0.03125, top5: 0.08203, CELoss: 4.62534, loss: 4.62534, batch_cost: 6.55339s, reader_cost: 0.65519, ips: 39.06375 images/sec, eta: 0:06:59 +[2022/04/18 10:32:02] root INFO: [Train][Epoch 5/20][Avg]top1: 0.01562, top5: 0.05729, CELoss: 4.68708, loss: 4.68708 +[2022/04/18 10:32:02] root INFO: [Eval][Epoch 5][Iter: 0/16]CELoss: 4.60583, loss: 4.60583, top1: 0.04688, top5: 0.12500, batch_cost: 0.98133s, reader_cost: 0.50026, ips: 65.21790 images/sec +[2022/04/18 10:32:09] root INFO: [Eval][Epoch 5][Iter: 10/16]CELoss: 4.42307, loss: 4.42307, top1: 0.03125, top5: 0.40625, batch_cost: 0.65791s, reader_cost: 0.18276, ips: 97.27800 images/sec +[2022/04/18 10:32:11] root INFO: [Eval][Epoch 5][Avg]CELoss: 4.64909, loss: 4.64909, top1: 0.01146, top5: 0.06250 +[2022/04/18 10:32:11] root INFO: [Eval][Epoch 5][best metric: 0.013541666666666667] +[2022/04/18 10:32:11] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_5 +[2022/04/18 10:32:11] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:32:20] root INFO: [Train][Epoch 6/20][Iter: 0/4]lr: 0.01000, top1: 0.01172, top5: 0.04297, CELoss: 4.68610, loss: 4.68610, batch_cost: 6.63889s, reader_cost: 0.63984, ips: 38.56064 images/sec, eta: 0:06:38 +[2022/04/18 10:32:31] root INFO: [Train][Epoch 6/20][Avg]top1: 0.01172, top5: 0.06250, CELoss: 4.68376, loss: 4.68376 +[2022/04/18 10:32:32] root INFO: [Eval][Epoch 6][Iter: 0/16]CELoss: 4.61412, loss: 4.61412, top1: 0.03125, top5: 0.06250, batch_cost: 0.86996s, reader_cost: 0.43996, ips: 73.56664 images/sec +[2022/04/18 10:32:38] root INFO: [Eval][Epoch 6][Iter: 10/16]CELoss: 4.44697, loss: 4.44697, top1: 0.03125, top5: 0.34375, batch_cost: 0.57997s, reader_cost: 0.15333, ips: 110.34973 images/sec +[2022/04/18 10:32:40] root INFO: [Eval][Epoch 6][Avg]CELoss: 4.64477, loss: 4.64477, top1: 0.00937, top5: 0.05000 +[2022/04/18 10:32:40] root INFO: [Eval][Epoch 6][best metric: 0.013541666666666667] +[2022/04/18 10:32:40] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_6 +[2022/04/18 10:32:40] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:32:48] root INFO: [Train][Epoch 7/20][Iter: 0/4]lr: 0.01188, top1: 0.01562, top5: 0.07031, CELoss: 4.65131, loss: 4.65131, batch_cost: 6.59630s, reader_cost: 0.62655, ips: 38.80962 images/sec, eta: 0:06:09 +[2022/04/18 10:32:58] root INFO: [Train][Epoch 7/20][Avg]top1: 0.01172, top5: 0.06510, CELoss: 4.65130, loss: 4.65130 +[2022/04/18 10:32:59] root INFO: [Eval][Epoch 7][Iter: 0/16]CELoss: 4.61308, loss: 4.61308, top1: 0.03125, top5: 0.03125, batch_cost: 0.87047s, reader_cost: 0.46899, ips: 73.52333 images/sec +[2022/04/18 10:33:05] root INFO: [Eval][Epoch 7][Iter: 10/16]CELoss: 4.49343, loss: 4.49343, top1: 0.07812, top5: 0.23438, batch_cost: 0.55668s, reader_cost: 0.14980, ips: 114.96690 images/sec +[2022/04/18 10:33:07] root INFO: [Eval][Epoch 7][Avg]CELoss: 4.63089, loss: 4.63089, top1: 0.01354, top5: 0.05625 +[2022/04/18 10:33:07] root INFO: [Eval][Epoch 7][best metric: 0.013541666666666667] +[2022/04/18 10:33:07] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_7 +[2022/04/18 10:33:07] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:33:16] root INFO: [Train][Epoch 8/20][Iter: 0/4]lr: 0.01247, top1: 0.00781, top5: 0.05469, CELoss: 4.64280, loss: 4.64280, batch_cost: 6.53036s, reader_cost: 0.61650, ips: 39.20150 images/sec, eta: 0:05:39 +[2022/04/18 10:33:25] root INFO: [Train][Epoch 8/20][Avg]top1: 0.01042, top5: 0.04557, CELoss: 4.64303, loss: 4.64303 +[2022/04/18 10:33:26] root INFO: [Eval][Epoch 8][Iter: 0/16]CELoss: 4.62822, loss: 4.62822, top1: 0.00000, top5: 0.01562, batch_cost: 0.84976s, reader_cost: 0.44264, ips: 75.31527 images/sec +[2022/04/18 10:33:32] root INFO: [Eval][Epoch 8][Iter: 10/16]CELoss: 4.52708, loss: 4.52708, top1: 0.03125, top5: 0.14062, batch_cost: 0.55012s, reader_cost: 0.15373, ips: 116.33885 images/sec +[2022/04/18 10:33:34] root INFO: [Eval][Epoch 8][Avg]CELoss: 4.62241, loss: 4.62241, top1: 0.00833, top5: 0.05521 +[2022/04/18 10:33:34] root INFO: [Eval][Epoch 8][best metric: 0.013541666666666667] +[2022/04/18 10:33:34] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_8 +[2022/04/18 10:33:34] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:33:42] root INFO: [Train][Epoch 9/20][Iter: 0/4]lr: 0.01229, top1: 0.02734, top5: 0.08203, CELoss: 4.62807, loss: 4.62807, batch_cost: 6.46556s, reader_cost: 0.60792, ips: 39.59440 images/sec, eta: 0:05:10 +[2022/04/18 10:33:52] root INFO: [Train][Epoch 9/20][Avg]top1: 0.01172, top5: 0.06250, CELoss: 4.61966, loss: 4.61966 +[2022/04/18 10:33:53] root INFO: [Eval][Epoch 9][Iter: 0/16]CELoss: 4.65428, loss: 4.65428, top1: 0.00000, top5: 0.00000, batch_cost: 0.81872s, reader_cost: 0.44007, ips: 78.17127 images/sec +[2022/04/18 10:33:59] root INFO: [Eval][Epoch 9][Iter: 10/16]CELoss: 4.58036, loss: 4.58036, top1: 0.04688, top5: 0.09375, batch_cost: 0.55475s, reader_cost: 0.15056, ips: 115.36788 images/sec +[2022/04/18 10:34:01] root INFO: [Eval][Epoch 9][Avg]CELoss: 4.61833, loss: 4.61833, top1: 0.01354, top5: 0.05417 +[2022/04/18 10:34:01] root INFO: [Eval][Epoch 9][best metric: 0.013541666666666667] +[2022/04/18 10:34:01] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_9 +[2022/04/18 10:34:01] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:34:09] root INFO: [Train][Epoch 10/20][Iter: 0/4]lr: 0.01196, top1: 0.01953, top5: 0.05469, CELoss: 4.60297, loss: 4.60297, batch_cost: 6.43565s, reader_cost: 0.61064, ips: 39.77840 images/sec, eta: 0:04:43 +[2022/04/18 10:34:19] root INFO: [Train][Epoch 10/20][Avg]top1: 0.01953, top5: 0.07422, CELoss: 4.60467, loss: 4.60467 +[2022/04/18 10:34:20] root INFO: [Eval][Epoch 10][Iter: 0/16]CELoss: 4.66085, loss: 4.66085, top1: 0.00000, top5: 0.06250, batch_cost: 0.82531s, reader_cost: 0.44567, ips: 77.54660 images/sec +[2022/04/18 10:34:26] root INFO: [Eval][Epoch 10][Iter: 10/16]CELoss: 4.61584, loss: 4.61584, top1: 0.00000, top5: 0.03125, batch_cost: 0.54999s, reader_cost: 0.15064, ips: 116.36524 images/sec +[2022/04/18 10:34:28] root INFO: [Eval][Epoch 10][Avg]CELoss: 4.61231, loss: 4.61231, top1: 0.00729, top5: 0.05417 +[2022/04/18 10:34:28] root INFO: [Eval][Epoch 10][best metric: 0.013541666666666667] +[2022/04/18 10:34:28] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_10 +[2022/04/18 10:34:28] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:34:36] root INFO: [Train][Epoch 11/20][Iter: 0/4]lr: 0.01149, top1: 0.00781, top5: 0.03906, CELoss: 4.62249, loss: 4.62249, batch_cost: 6.38626s, reader_cost: 0.60446, ips: 40.08603 images/sec, eta: 0:04:15 +[2022/04/18 10:34:46] root INFO: [Train][Epoch 11/20][Avg]top1: 0.01042, top5: 0.06120, CELoss: 4.61070, loss: 4.61070 +[2022/04/18 10:34:47] root INFO: [Eval][Epoch 11][Iter: 0/16]CELoss: 4.64748, loss: 4.64748, top1: 0.00000, top5: 0.03125, batch_cost: 0.86118s, reader_cost: 0.44960, ips: 74.31663 images/sec +[2022/04/18 10:34:53] root INFO: [Eval][Epoch 11][Iter: 10/16]CELoss: 4.61273, loss: 4.61273, top1: 0.00000, top5: 0.04688, batch_cost: 0.58394s, reader_cost: 0.16238, ips: 109.59963 images/sec +[2022/04/18 10:34:55] root INFO: [Eval][Epoch 11][Avg]CELoss: 4.60653, loss: 4.60653, top1: 0.01562, top5: 0.06667 +[2022/04/18 10:34:55] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\best_model +[2022/04/18 10:34:55] root INFO: [Eval][Epoch 11][best metric: 0.015625] +[2022/04/18 10:34:55] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_11 +[2022/04/18 10:34:55] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:35:03] root INFO: [Train][Epoch 12/20][Iter: 0/4]lr: 0.01089, top1: 0.00781, top5: 0.05859, CELoss: 4.60968, loss: 4.60968, batch_cost: 6.35985s, reader_cost: 0.60053, ips: 40.25252 images/sec, eta: 0:03:48 +[2022/04/18 10:35:13] root INFO: [Train][Epoch 12/20][Avg]top1: 0.00781, top5: 0.06901, CELoss: 4.60008, loss: 4.60008 +[2022/04/18 10:35:14] root INFO: [Eval][Epoch 12][Iter: 0/16]CELoss: 4.66432, loss: 4.66432, top1: 0.00000, top5: 0.01562, batch_cost: 0.84842s, reader_cost: 0.44881, ips: 75.43432 images/sec +[2022/04/18 10:35:19] root INFO: [Eval][Epoch 12][Iter: 10/16]CELoss: 4.60226, loss: 4.60226, top1: 0.01562, top5: 0.03125, batch_cost: 0.54736s, reader_cost: 0.14973, ips: 116.92520 images/sec +[2022/04/18 10:35:22] root INFO: [Eval][Epoch 12][Avg]CELoss: 4.59884, loss: 4.59884, top1: 0.01250, top5: 0.05937 +[2022/04/18 10:35:22] root INFO: [Eval][Epoch 12][best metric: 0.015625] +[2022/04/18 10:35:22] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_12 +[2022/04/18 10:35:22] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:35:30] root INFO: [Train][Epoch 13/20][Iter: 0/4]lr: 0.01018, top1: 0.00781, top5: 0.07031, CELoss: 4.58294, loss: 4.58294, batch_cost: 6.33882s, reader_cost: 0.59699, ips: 40.38606 images/sec, eta: 0:03:22 +[2022/04/18 10:35:40] root INFO: [Train][Epoch 13/20][Avg]top1: 0.00781, top5: 0.07292, CELoss: 4.59903, loss: 4.59903 +[2022/04/18 10:35:41] root INFO: [Eval][Epoch 13][Iter: 0/16]CELoss: 4.67737, loss: 4.67737, top1: 0.00000, top5: 0.00000, batch_cost: 0.81981s, reader_cost: 0.44846, ips: 78.06683 images/sec +[2022/04/18 10:35:46] root INFO: [Eval][Epoch 13][Iter: 10/16]CELoss: 4.60637, loss: 4.60637, top1: 0.00000, top5: 0.06250, batch_cost: 0.53856s, reader_cost: 0.15151, ips: 118.83628 images/sec +[2022/04/18 10:35:49] root INFO: [Eval][Epoch 13][Avg]CELoss: 4.59937, loss: 4.59937, top1: 0.01146, top5: 0.05729 +[2022/04/18 10:35:49] root INFO: [Eval][Epoch 13][best metric: 0.015625] +[2022/04/18 10:35:49] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_13 +[2022/04/18 10:35:49] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:35:57] root INFO: [Train][Epoch 14/20][Iter: 0/4]lr: 0.00938, top1: 0.01953, top5: 0.08203, CELoss: 4.57910, loss: 4.57910, batch_cost: 6.31182s, reader_cost: 0.59390, ips: 40.55886 images/sec, eta: 0:02:56 +[2022/04/18 10:36:07] root INFO: [Train][Epoch 14/20][Avg]top1: 0.01172, top5: 0.07552, CELoss: 4.58491, loss: 4.58491 +[2022/04/18 10:36:07] root INFO: [Eval][Epoch 14][Iter: 0/16]CELoss: 4.67771, loss: 4.67771, top1: 0.00000, top5: 0.01562, batch_cost: 0.81435s, reader_cost: 0.45404, ips: 78.59002 images/sec +[2022/04/18 10:36:13] root INFO: [Eval][Epoch 14][Iter: 10/16]CELoss: 4.63535, loss: 4.63535, top1: 0.00000, top5: 0.04688, batch_cost: 0.55286s, reader_cost: 0.14929, ips: 115.76124 images/sec +[2022/04/18 10:36:15] root INFO: [Eval][Epoch 14][Avg]CELoss: 4.59307, loss: 4.59307, top1: 0.01250, top5: 0.05625 +[2022/04/18 10:36:15] root INFO: [Eval][Epoch 14][best metric: 0.015625] +[2022/04/18 10:36:15] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_14 +[2022/04/18 10:36:15] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:36:23] root INFO: [Train][Epoch 15/20][Iter: 0/4]lr: 0.00849, top1: 0.01953, top5: 0.10547, CELoss: 4.57969, loss: 4.57969, batch_cost: 6.29119s, reader_cost: 0.59107, ips: 40.69185 images/sec, eta: 0:02:30 +[2022/04/18 10:36:34] root INFO: [Train][Epoch 15/20][Avg]top1: 0.01693, top5: 0.08594, CELoss: 4.58005, loss: 4.58005 +[2022/04/18 10:36:34] root INFO: [Eval][Epoch 15][Iter: 0/16]CELoss: 4.68616, loss: 4.68616, top1: 0.00000, top5: 0.00000, batch_cost: 0.83016s, reader_cost: 0.45301, ips: 77.09354 images/sec +[2022/04/18 10:36:41] root INFO: [Eval][Epoch 15][Iter: 10/16]CELoss: 4.65745, loss: 4.65745, top1: 0.00000, top5: 0.06250, batch_cost: 0.66344s, reader_cost: 0.16827, ips: 96.46697 images/sec +[2022/04/18 10:36:43] root INFO: [Eval][Epoch 15][Avg]CELoss: 4.59027, loss: 4.59027, top1: 0.01146, top5: 0.05625 +[2022/04/18 10:36:43] root INFO: [Eval][Epoch 15][best metric: 0.015625] +[2022/04/18 10:36:43] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_15 +[2022/04/18 10:36:43] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:36:52] root INFO: [Train][Epoch 16/20][Iter: 0/4]lr: 0.00755, top1: 0.01562, top5: 0.07812, CELoss: 4.56924, loss: 4.56924, batch_cost: 6.29722s, reader_cost: 0.59081, ips: 40.65288 images/sec, eta: 0:02:05 +[2022/04/18 10:37:02] root INFO: [Train][Epoch 16/20][Avg]top1: 0.01432, top5: 0.06641, CELoss: 4.56814, loss: 4.56814 +[2022/04/18 10:37:03] root INFO: [Eval][Epoch 16][Iter: 0/16]CELoss: 4.68624, loss: 4.68624, top1: 0.00000, top5: 0.00000, batch_cost: 0.88268s, reader_cost: 0.45880, ips: 72.50629 images/sec +[2022/04/18 10:37:09] root INFO: [Eval][Epoch 16][Iter: 10/16]CELoss: 4.65055, loss: 4.65055, top1: 0.00000, top5: 0.04688, batch_cost: 0.56403s, reader_cost: 0.15235, ips: 113.46999 images/sec +[2022/04/18 10:37:11] root INFO: [Eval][Epoch 16][Avg]CELoss: 4.58911, loss: 4.58911, top1: 0.00937, top5: 0.05000 +[2022/04/18 10:37:11] root INFO: [Eval][Epoch 16][best metric: 0.015625] +[2022/04/18 10:37:11] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_16 +[2022/04/18 10:37:11] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:37:20] root INFO: [Train][Epoch 17/20][Iter: 0/4]lr: 0.00658, top1: 0.00781, top5: 0.08594, CELoss: 4.57454, loss: 4.57454, batch_cost: 6.29410s, reader_cost: 0.58915, ips: 40.67300 images/sec, eta: 0:01:40 +[2022/04/18 10:37:30] root INFO: [Train][Epoch 17/20][Avg]top1: 0.01172, top5: 0.07161, CELoss: 4.57665, loss: 4.57665 +[2022/04/18 10:37:31] root INFO: [Eval][Epoch 17][Iter: 0/16]CELoss: 4.67491, loss: 4.67491, top1: 0.00000, top5: 0.00000, batch_cost: 0.87708s, reader_cost: 0.45714, ips: 72.96934 images/sec +[2022/04/18 10:37:37] root INFO: [Eval][Epoch 17][Iter: 10/16]CELoss: 4.64649, loss: 4.64649, top1: 0.04688, top5: 0.07812, batch_cost: 0.54974s, reader_cost: 0.15248, ips: 116.41848 images/sec +[2022/04/18 10:37:39] root INFO: [Eval][Epoch 17][Avg]CELoss: 4.58624, loss: 4.58624, top1: 0.01354, top5: 0.06042 +[2022/04/18 10:37:39] root INFO: [Eval][Epoch 17][best metric: 0.015625] +[2022/04/18 10:37:39] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_17 +[2022/04/18 10:37:39] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:37:48] root INFO: [Train][Epoch 18/20][Iter: 0/4]lr: 0.00560, top1: 0.01953, top5: 0.07422, CELoss: 4.58180, loss: 4.58180, batch_cost: 6.30441s, reader_cost: 0.59464, ips: 40.60648 images/sec, eta: 0:01:15 +[2022/04/18 10:37:58] root INFO: [Train][Epoch 18/20][Avg]top1: 0.01172, top5: 0.08073, CELoss: 4.56663, loss: 4.56663 +[2022/04/18 10:37:59] root INFO: [Eval][Epoch 18][Iter: 0/16]CELoss: 4.67365, loss: 4.67365, top1: 0.00000, top5: 0.00000, batch_cost: 0.88373s, reader_cost: 0.47119, ips: 72.42037 images/sec +[2022/04/18 10:38:05] root INFO: [Eval][Epoch 18][Iter: 10/16]CELoss: 4.62118, loss: 4.62118, top1: 0.04688, top5: 0.09375, batch_cost: 0.55812s, reader_cost: 0.15676, ips: 114.67145 images/sec +[2022/04/18 10:38:07] root INFO: [Eval][Epoch 18][Avg]CELoss: 4.58644, loss: 4.58644, top1: 0.01250, top5: 0.06042 +[2022/04/18 10:38:07] root INFO: [Eval][Epoch 18][best metric: 0.015625] +[2022/04/18 10:38:07] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_18 +[2022/04/18 10:38:07] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:38:15] root INFO: [Train][Epoch 19/20][Iter: 0/4]lr: 0.00463, top1: 0.02344, top5: 0.07422, CELoss: 4.55407, loss: 4.55407, batch_cost: 6.29300s, reader_cost: 0.59351, ips: 40.68010 images/sec, eta: 0:00:50 +[2022/04/18 10:38:26] root INFO: [Train][Epoch 19/20][Avg]top1: 0.01432, top5: 0.07422, CELoss: 4.56636, loss: 4.56636 +[2022/04/18 10:38:26] root INFO: [Eval][Epoch 19][Iter: 0/16]CELoss: 4.67197, loss: 4.67197, top1: 0.00000, top5: 0.00000, batch_cost: 0.84170s, reader_cost: 0.45035, ips: 76.03652 images/sec +[2022/04/18 10:38:32] root INFO: [Eval][Epoch 19][Iter: 10/16]CELoss: 4.63389, loss: 4.63389, top1: 0.04688, top5: 0.06250, batch_cost: 0.55268s, reader_cost: 0.15200, ips: 115.80008 images/sec +[2022/04/18 10:38:35] root INFO: [Eval][Epoch 19][Avg]CELoss: 4.58614, loss: 4.58614, top1: 0.00937, top5: 0.06042 +[2022/04/18 10:38:35] root INFO: [Eval][Epoch 19][best metric: 0.015625] +[2022/04/18 10:38:35] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_19 +[2022/04/18 10:38:35] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest +[2022/04/18 10:38:44] root INFO: [Train][Epoch 20/20][Iter: 0/4]lr: 0.00371, top1: 0.00781, top5: 0.05469, CELoss: 4.57822, loss: 4.57822, batch_cost: 6.30198s, reader_cost: 0.59387, ips: 40.62213 images/sec, eta: 0:00:25 +[2022/04/18 10:38:55] root INFO: [Train][Epoch 20/20][Avg]top1: 0.01823, top5: 0.07422, CELoss: 4.56660, loss: 4.56660 +[2022/04/18 10:38:56] root INFO: [Eval][Epoch 20][Iter: 0/16]CELoss: 4.68744, loss: 4.68744, top1: 0.00000, top5: 0.00000, batch_cost: 1.02800s, reader_cost: 0.47287, ips: 62.25709 images/sec +[2022/04/18 10:39:02] root INFO: [Eval][Epoch 20][Iter: 10/16]CELoss: 4.63357, loss: 4.63357, top1: 0.00000, top5: 0.09375, batch_cost: 0.63272s, reader_cost: 0.16321, ips: 101.15126 images/sec +[2022/04/18 10:39:05] root INFO: [Eval][Epoch 20][Avg]CELoss: 4.58696, loss: 4.58696, top1: 0.00833, top5: 0.06563 +[2022/04/18 10:39:05] root INFO: [Eval][Epoch 20][best metric: 0.015625] +[2022/04/18 10:39:05] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\epoch_20 +[2022/04/18 10:39:05] root INFO: Already save model in ./output/ShuffleNetV2_x0_25\latest diff --git a/src/PaddleClas/output_CIFAR/ResNet50_vd/train.log b/src/PaddleClas/output_CIFAR/ResNet50_vd/train.log new file mode 100644 index 0000000..f74f09b --- /dev/null +++ b/src/PaddleClas/output_CIFAR/ResNet50_vd/train.log @@ -0,0 +1,497 @@ +[2022/04/18 12:43:50] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 12:43:50] root INFO: Arch : +[2022/04/18 12:43:50] root INFO: class_num : 100 +[2022/04/18 12:43:50] root INFO: name : ResNet50_vd +[2022/04/18 12:43:50] root INFO: DataLoader : +[2022/04/18 12:43:50] root INFO: Eval : +[2022/04/18 12:43:50] root INFO: dataset : +[2022/04/18 12:43:50] root INFO: cls_label_path : ./dataset/CIFAR100/test_list.txt +[2022/04/18 12:43:50] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:43:50] root INFO: name : ImageNetDataset +[2022/04/18 12:43:50] root INFO: transform_ops : +[2022/04/18 12:43:50] root INFO: DecodeImage : +[2022/04/18 12:43:50] root INFO: channel_first : False +[2022/04/18 12:43:50] root INFO: to_rgb : True +[2022/04/18 12:43:50] root INFO: ResizeImage : +[2022/04/18 12:43:50] root INFO: resize_short : 36 +[2022/04/18 12:43:50] root INFO: CropImage : +[2022/04/18 12:43:50] root INFO: size : 32 +[2022/04/18 12:43:50] root INFO: NormalizeImage : +[2022/04/18 12:43:50] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:43:50] root INFO: order : +[2022/04/18 12:43:50] root INFO: scale : 1.0/255.0 +[2022/04/18 12:43:50] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:43:50] root INFO: loader : +[2022/04/18 12:43:50] root INFO: num_workers : 4 +[2022/04/18 12:43:50] root INFO: use_shared_memory : True +[2022/04/18 12:43:50] root INFO: sampler : +[2022/04/18 12:43:50] root INFO: batch_size : 64 +[2022/04/18 12:43:50] root INFO: drop_last : False +[2022/04/18 12:43:50] root INFO: name : DistributedBatchSampler +[2022/04/18 12:43:50] root INFO: shuffle : False +[2022/04/18 12:43:50] root INFO: Train : +[2022/04/18 12:43:50] root INFO: dataset : +[2022/04/18 12:43:50] root INFO: cls_label_path : ./dataset/CIFAR100/train_list.txt +[2022/04/18 12:43:50] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:43:50] root INFO: name : ImageNetDataset +[2022/04/18 12:43:50] root INFO: transform_ops : +[2022/04/18 12:43:50] root INFO: DecodeImage : +[2022/04/18 12:43:50] root INFO: channel_first : False +[2022/04/18 12:43:50] root INFO: to_rgb : True +[2022/04/18 12:43:50] root INFO: RandCropImage : +[2022/04/18 12:43:50] root INFO: size : 32 +[2022/04/18 12:43:50] root INFO: RandFlipImage : +[2022/04/18 12:43:50] root INFO: flip_code : 1 +[2022/04/18 12:43:50] root INFO: NormalizeImage : +[2022/04/18 12:43:50] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:43:50] root INFO: order : +[2022/04/18 12:43:50] root INFO: scale : 1.0/255.0 +[2022/04/18 12:43:50] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:43:50] root INFO: loader : +[2022/04/18 12:43:50] root INFO: num_workers : 4 +[2022/04/18 12:43:50] root INFO: use_shared_memory : True +[2022/04/18 12:43:50] root INFO: sampler : +[2022/04/18 12:43:50] root INFO: batch_size : 64 +[2022/04/18 12:43:50] root INFO: drop_last : False +[2022/04/18 12:43:50] root INFO: name : DistributedBatchSampler +[2022/04/18 12:43:50] root INFO: shuffle : True +[2022/04/18 12:43:50] root INFO: Global : +[2022/04/18 12:43:50] root INFO: checkpoints : None +[2022/04/18 12:43:50] root INFO: device : gpu +[2022/04/18 12:43:50] root INFO: epochs : 100 +[2022/04/18 12:43:50] root INFO: eval_during_train : True +[2022/04/18 12:43:50] root INFO: eval_interval : 1 +[2022/04/18 12:43:50] root INFO: image_shape : [3, 32, 32] +[2022/04/18 12:43:50] root INFO: output_dir : output_CIFAR +[2022/04/18 12:43:50] root INFO: pretrained_model : None +[2022/04/18 12:43:50] root INFO: print_batch_step : 10 +[2022/04/18 12:43:50] root INFO: save_inference_dir : ./inference +[2022/04/18 12:43:50] root INFO: save_interval : 1 +[2022/04/18 12:43:50] root INFO: use_visualdl : False +[2022/04/18 12:43:50] root INFO: Infer : +[2022/04/18 12:43:50] root INFO: PostProcess : +[2022/04/18 12:43:50] root INFO: name : Topk +[2022/04/18 12:43:50] root INFO: topk : 5 +[2022/04/18 12:43:50] root INFO: batch_size : 10 +[2022/04/18 12:43:50] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 12:43:50] root INFO: transforms : +[2022/04/18 12:43:50] root INFO: DecodeImage : +[2022/04/18 12:43:50] root INFO: channel_first : False +[2022/04/18 12:43:50] root INFO: to_rgb : True +[2022/04/18 12:43:50] root INFO: ResizeImage : +[2022/04/18 12:43:50] root INFO: resize_short : 36 +[2022/04/18 12:43:50] root INFO: CropImage : +[2022/04/18 12:43:50] root INFO: size : 32 +[2022/04/18 12:43:50] root INFO: NormalizeImage : +[2022/04/18 12:43:50] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:43:50] root INFO: order : +[2022/04/18 12:43:50] root INFO: scale : 1.0/255.0 +[2022/04/18 12:43:50] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:43:50] root INFO: ToCHWImage : None +[2022/04/18 12:43:50] root INFO: Loss : +[2022/04/18 12:43:50] root INFO: Eval : +[2022/04/18 12:43:50] root INFO: CELoss : +[2022/04/18 12:43:50] root INFO: weight : 1.0 +[2022/04/18 12:43:50] root INFO: Train : +[2022/04/18 12:43:50] root INFO: CELoss : +[2022/04/18 12:43:50] root INFO: weight : 1.0 +[2022/04/18 12:43:50] root INFO: Metric : +[2022/04/18 12:43:50] root INFO: Eval : +[2022/04/18 12:43:50] root INFO: TopkAcc : +[2022/04/18 12:43:50] root INFO: topk : [1, 5] +[2022/04/18 12:43:50] root INFO: Train : +[2022/04/18 12:43:50] root INFO: TopkAcc : +[2022/04/18 12:43:50] root INFO: topk : [1, 5] +[2022/04/18 12:43:50] root INFO: Optimizer : +[2022/04/18 12:43:50] root INFO: lr : +[2022/04/18 12:43:50] root INFO: learning_rate : 0.04 +[2022/04/18 12:43:50] root INFO: name : Cosine +[2022/04/18 12:43:50] root INFO: momentum : 0.9 +[2022/04/18 12:43:50] root INFO: name : Momentum +[2022/04/18 12:43:50] root INFO: regularizer : +[2022/04/18 12:43:50] root INFO: coeff : 0.0001 +[2022/04/18 12:43:50] root INFO: name : L2 +[2022/04/18 12:43:50] root INFO: profiler_options : None +[2022/04/18 12:47:26] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 12:47:26] root INFO: Arch : +[2022/04/18 12:47:26] root INFO: class_num : 100 +[2022/04/18 12:47:26] root INFO: name : ResNet50_vd +[2022/04/18 12:47:26] root INFO: DataLoader : +[2022/04/18 12:47:26] root INFO: Eval : +[2022/04/18 12:47:26] root INFO: dataset : +[2022/04/18 12:47:26] root INFO: cls_label_path : ./dataset/CIFAR100/test_list.txt +[2022/04/18 12:47:26] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:47:26] root INFO: name : ImageNetDataset +[2022/04/18 12:47:26] root INFO: transform_ops : +[2022/04/18 12:47:26] root INFO: DecodeImage : +[2022/04/18 12:47:26] root INFO: channel_first : False +[2022/04/18 12:47:26] root INFO: to_rgb : True +[2022/04/18 12:47:26] root INFO: ResizeImage : +[2022/04/18 12:47:26] root INFO: resize_short : 36 +[2022/04/18 12:47:26] root INFO: CropImage : +[2022/04/18 12:47:26] root INFO: size : 32 +[2022/04/18 12:47:26] root INFO: NormalizeImage : +[2022/04/18 12:47:26] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:47:26] root INFO: order : +[2022/04/18 12:47:26] root INFO: scale : 1.0/255.0 +[2022/04/18 12:47:26] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:47:26] root INFO: loader : +[2022/04/18 12:47:26] root INFO: num_workers : 4 +[2022/04/18 12:47:26] root INFO: use_shared_memory : True +[2022/04/18 12:47:26] root INFO: sampler : +[2022/04/18 12:47:26] root INFO: batch_size : 64 +[2022/04/18 12:47:26] root INFO: drop_last : False +[2022/04/18 12:47:26] root INFO: name : DistributedBatchSampler +[2022/04/18 12:47:26] root INFO: shuffle : False +[2022/04/18 12:47:26] root INFO: Train : +[2022/04/18 12:47:26] root INFO: dataset : +[2022/04/18 12:47:26] root INFO: cls_label_path : ./dataset/CIFAR100/train_list.txt +[2022/04/18 12:47:26] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:47:26] root INFO: name : ImageNetDataset +[2022/04/18 12:47:26] root INFO: transform_ops : +[2022/04/18 12:47:26] root INFO: DecodeImage : +[2022/04/18 12:47:26] root INFO: channel_first : False +[2022/04/18 12:47:26] root INFO: to_rgb : True +[2022/04/18 12:47:26] root INFO: RandCropImage : +[2022/04/18 12:47:26] root INFO: size : 32 +[2022/04/18 12:47:26] root INFO: RandFlipImage : +[2022/04/18 12:47:26] root INFO: flip_code : 1 +[2022/04/18 12:47:26] root INFO: NormalizeImage : +[2022/04/18 12:47:26] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:47:26] root INFO: order : +[2022/04/18 12:47:26] root INFO: scale : 1.0/255.0 +[2022/04/18 12:47:26] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:47:26] root INFO: loader : +[2022/04/18 12:47:26] root INFO: num_workers : 4 +[2022/04/18 12:47:26] root INFO: use_shared_memory : True +[2022/04/18 12:47:26] root INFO: sampler : +[2022/04/18 12:47:26] root INFO: batch_size : 64 +[2022/04/18 12:47:26] root INFO: drop_last : False +[2022/04/18 12:47:26] root INFO: name : DistributedBatchSampler +[2022/04/18 12:47:26] root INFO: shuffle : True +[2022/04/18 12:47:26] root INFO: Global : +[2022/04/18 12:47:26] root INFO: checkpoints : None +[2022/04/18 12:47:26] root INFO: device : gpu +[2022/04/18 12:47:26] root INFO: epochs : 100 +[2022/04/18 12:47:26] root INFO: eval_during_train : True +[2022/04/18 12:47:26] root INFO: eval_interval : 1 +[2022/04/18 12:47:26] root INFO: image_shape : [3, 32, 32] +[2022/04/18 12:47:26] root INFO: output_dir : output_CIFAR +[2022/04/18 12:47:26] root INFO: pretrained_model : None +[2022/04/18 12:47:26] root INFO: print_batch_step : 10 +[2022/04/18 12:47:26] root INFO: save_inference_dir : ./inference +[2022/04/18 12:47:26] root INFO: save_interval : 1 +[2022/04/18 12:47:26] root INFO: use_gpu : False +[2022/04/18 12:47:26] root INFO: use_visualdl : False +[2022/04/18 12:47:26] root INFO: Infer : +[2022/04/18 12:47:26] root INFO: PostProcess : +[2022/04/18 12:47:26] root INFO: name : Topk +[2022/04/18 12:47:26] root INFO: topk : 5 +[2022/04/18 12:47:26] root INFO: batch_size : 10 +[2022/04/18 12:47:26] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 12:47:26] root INFO: transforms : +[2022/04/18 12:47:26] root INFO: DecodeImage : +[2022/04/18 12:47:26] root INFO: channel_first : False +[2022/04/18 12:47:26] root INFO: to_rgb : True +[2022/04/18 12:47:26] root INFO: ResizeImage : +[2022/04/18 12:47:26] root INFO: resize_short : 36 +[2022/04/18 12:47:26] root INFO: CropImage : +[2022/04/18 12:47:26] root INFO: size : 32 +[2022/04/18 12:47:26] root INFO: NormalizeImage : +[2022/04/18 12:47:26] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:47:26] root INFO: order : +[2022/04/18 12:47:26] root INFO: scale : 1.0/255.0 +[2022/04/18 12:47:26] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:47:26] root INFO: ToCHWImage : None +[2022/04/18 12:47:26] root INFO: Loss : +[2022/04/18 12:47:26] root INFO: Eval : +[2022/04/18 12:47:26] root INFO: CELoss : +[2022/04/18 12:47:26] root INFO: weight : 1.0 +[2022/04/18 12:47:26] root INFO: Train : +[2022/04/18 12:47:26] root INFO: CELoss : +[2022/04/18 12:47:26] root INFO: weight : 1.0 +[2022/04/18 12:47:26] root INFO: Metric : +[2022/04/18 12:47:26] root INFO: Eval : +[2022/04/18 12:47:26] root INFO: TopkAcc : +[2022/04/18 12:47:26] root INFO: topk : [1, 5] +[2022/04/18 12:47:26] root INFO: Train : +[2022/04/18 12:47:26] root INFO: TopkAcc : +[2022/04/18 12:47:26] root INFO: topk : [1, 5] +[2022/04/18 12:47:26] root INFO: Optimizer : +[2022/04/18 12:47:26] root INFO: lr : +[2022/04/18 12:47:26] root INFO: learning_rate : 0.04 +[2022/04/18 12:47:26] root INFO: name : Cosine +[2022/04/18 12:47:26] root INFO: momentum : 0.9 +[2022/04/18 12:47:26] root INFO: name : Momentum +[2022/04/18 12:47:26] root INFO: regularizer : +[2022/04/18 12:47:26] root INFO: coeff : 0.0001 +[2022/04/18 12:47:26] root INFO: name : L2 +[2022/04/18 12:47:26] root INFO: profiler_options : None +[2022/04/18 12:49:17] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 12:49:17] root INFO: Arch : +[2022/04/18 12:49:17] root INFO: class_num : 100 +[2022/04/18 12:49:17] root INFO: name : ResNet50_vd +[2022/04/18 12:49:17] root INFO: DataLoader : +[2022/04/18 12:49:17] root INFO: Eval : +[2022/04/18 12:49:17] root INFO: dataset : +[2022/04/18 12:49:17] root INFO: cls_label_path : ./dataset/CIFAR100/test_list.txt +[2022/04/18 12:49:17] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:49:17] root INFO: name : ImageNetDataset +[2022/04/18 12:49:17] root INFO: transform_ops : +[2022/04/18 12:49:17] root INFO: DecodeImage : +[2022/04/18 12:49:17] root INFO: channel_first : False +[2022/04/18 12:49:17] root INFO: to_rgb : True +[2022/04/18 12:49:17] root INFO: ResizeImage : +[2022/04/18 12:49:17] root INFO: resize_short : 36 +[2022/04/18 12:49:17] root INFO: CropImage : +[2022/04/18 12:49:17] root INFO: size : 32 +[2022/04/18 12:49:17] root INFO: NormalizeImage : +[2022/04/18 12:49:17] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:49:17] root INFO: order : +[2022/04/18 12:49:17] root INFO: scale : 1.0/255.0 +[2022/04/18 12:49:17] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:49:17] root INFO: loader : +[2022/04/18 12:49:17] root INFO: num_workers : 4 +[2022/04/18 12:49:17] root INFO: use_shared_memory : True +[2022/04/18 12:49:17] root INFO: sampler : +[2022/04/18 12:49:17] root INFO: batch_size : 64 +[2022/04/18 12:49:17] root INFO: drop_last : False +[2022/04/18 12:49:17] root INFO: name : DistributedBatchSampler +[2022/04/18 12:49:17] root INFO: shuffle : False +[2022/04/18 12:49:17] root INFO: Train : +[2022/04/18 12:49:17] root INFO: dataset : +[2022/04/18 12:49:17] root INFO: cls_label_path : ./dataset/CIFAR100/train_list.txt +[2022/04/18 12:49:17] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:49:17] root INFO: name : ImageNetDataset +[2022/04/18 12:49:17] root INFO: transform_ops : +[2022/04/18 12:49:17] root INFO: DecodeImage : +[2022/04/18 12:49:17] root INFO: channel_first : False +[2022/04/18 12:49:17] root INFO: to_rgb : True +[2022/04/18 12:49:17] root INFO: RandCropImage : +[2022/04/18 12:49:17] root INFO: size : 32 +[2022/04/18 12:49:17] root INFO: RandFlipImage : +[2022/04/18 12:49:17] root INFO: flip_code : 1 +[2022/04/18 12:49:17] root INFO: NormalizeImage : +[2022/04/18 12:49:17] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:49:17] root INFO: order : +[2022/04/18 12:49:17] root INFO: scale : 1.0/255.0 +[2022/04/18 12:49:17] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:49:17] root INFO: loader : +[2022/04/18 12:49:17] root INFO: num_workers : 4 +[2022/04/18 12:49:17] root INFO: use_shared_memory : True +[2022/04/18 12:49:18] root INFO: sampler : +[2022/04/18 12:49:18] root INFO: batch_size : 64 +[2022/04/18 12:49:18] root INFO: drop_last : False +[2022/04/18 12:49:18] root INFO: name : DistributedBatchSampler +[2022/04/18 12:49:18] root INFO: shuffle : True +[2022/04/18 12:49:18] root INFO: Global : +[2022/04/18 12:49:18] root INFO: checkpoints : None +[2022/04/18 12:49:18] root INFO: device : cpu +[2022/04/18 12:49:18] root INFO: epochs : 100 +[2022/04/18 12:49:18] root INFO: eval_during_train : True +[2022/04/18 12:49:18] root INFO: eval_interval : 1 +[2022/04/18 12:49:18] root INFO: image_shape : [3, 32, 32] +[2022/04/18 12:49:18] root INFO: output_dir : output_CIFAR +[2022/04/18 12:49:18] root INFO: pretrained_model : None +[2022/04/18 12:49:18] root INFO: print_batch_step : 10 +[2022/04/18 12:49:18] root INFO: save_inference_dir : ./inference +[2022/04/18 12:49:18] root INFO: save_interval : 1 +[2022/04/18 12:49:18] root INFO: use_visualdl : False +[2022/04/18 12:49:18] root INFO: Infer : +[2022/04/18 12:49:18] root INFO: PostProcess : +[2022/04/18 12:49:18] root INFO: name : Topk +[2022/04/18 12:49:18] root INFO: topk : 5 +[2022/04/18 12:49:18] root INFO: batch_size : 10 +[2022/04/18 12:49:18] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 12:49:18] root INFO: transforms : +[2022/04/18 12:49:18] root INFO: DecodeImage : +[2022/04/18 12:49:18] root INFO: channel_first : False +[2022/04/18 12:49:18] root INFO: to_rgb : True +[2022/04/18 12:49:18] root INFO: ResizeImage : +[2022/04/18 12:49:18] root INFO: resize_short : 36 +[2022/04/18 12:49:18] root INFO: CropImage : +[2022/04/18 12:49:18] root INFO: size : 32 +[2022/04/18 12:49:18] root INFO: NormalizeImage : +[2022/04/18 12:49:18] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:49:18] root INFO: order : +[2022/04/18 12:49:18] root INFO: scale : 1.0/255.0 +[2022/04/18 12:49:18] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:49:18] root INFO: ToCHWImage : None +[2022/04/18 12:49:18] root INFO: Loss : +[2022/04/18 12:49:18] root INFO: Eval : +[2022/04/18 12:49:18] root INFO: CELoss : +[2022/04/18 12:49:18] root INFO: weight : 1.0 +[2022/04/18 12:49:18] root INFO: Train : +[2022/04/18 12:49:18] root INFO: CELoss : +[2022/04/18 12:49:18] root INFO: weight : 1.0 +[2022/04/18 12:49:18] root INFO: Metric : +[2022/04/18 12:49:18] root INFO: Eval : +[2022/04/18 12:49:18] root INFO: TopkAcc : +[2022/04/18 12:49:18] root INFO: topk : [1, 5] +[2022/04/18 12:49:18] root INFO: Train : +[2022/04/18 12:49:18] root INFO: TopkAcc : +[2022/04/18 12:49:18] root INFO: topk : [1, 5] +[2022/04/18 12:49:18] root INFO: Optimizer : +[2022/04/18 12:49:18] root INFO: lr : +[2022/04/18 12:49:18] root INFO: learning_rate : 0.04 +[2022/04/18 12:49:18] root INFO: name : Cosine +[2022/04/18 12:49:18] root INFO: momentum : 0.9 +[2022/04/18 12:49:18] root INFO: name : Momentum +[2022/04/18 12:49:18] root INFO: regularizer : +[2022/04/18 12:49:18] root INFO: coeff : 0.0001 +[2022/04/18 12:49:18] root INFO: name : L2 +[2022/04/18 12:49:18] root INFO: profiler_options : None +[2022/04/18 12:49:18] root INFO: train with paddle 2.2.2 and device CPUPlace +[2022/04/18 12:49:26] root WARNING: The training strategy in config files provided by PaddleClas is based on 4 gpus. But the number of gpus is 1 in current training. Please modify the stategy (learning rate, batch size and so on) if use config files in PaddleClas to train. +[2022/04/18 12:49:28] root INFO: [Train][Epoch 1/100][Iter: 0/782]lr: 0.04000, top1: 0.00000, top5: 0.00000, CELoss: 5.06183, loss: 5.06183, batch_cost: 2.00989s, reader_cost: 0.05953, ips: 31.84257 images/sec, eta: 1 day, 19:39:33 +[2022/04/18 12:49:45] root INFO: [Train][Epoch 1/100][Iter: 10/782]lr: 0.04000, top1: 0.00568, top5: 0.04261, CELoss: 8.25212, loss: 8.25212, batch_cost: 1.73383s, reader_cost: 0.00000, ips: 36.91248 images/sec, eta: 1 day, 13:39:28 +[2022/04/18 12:50:44] root INFO: +=========================================================== +== PaddleClas is powered by PaddlePaddle ! == +=========================================================== +== == +== For more info please go to the following website. == +== == +== https://github.com/PaddlePaddle/PaddleClas == +=========================================================== + +[2022/04/18 12:50:44] root INFO: Arch : +[2022/04/18 12:50:44] root INFO: class_num : 100 +[2022/04/18 12:50:44] root INFO: name : ResNet50_vd +[2022/04/18 12:50:44] root INFO: DataLoader : +[2022/04/18 12:50:44] root INFO: Eval : +[2022/04/18 12:50:44] root INFO: dataset : +[2022/04/18 12:50:44] root INFO: cls_label_path : ./dataset/CIFAR100/test_list.txt +[2022/04/18 12:50:44] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:50:44] root INFO: name : ImageNetDataset +[2022/04/18 12:50:44] root INFO: transform_ops : +[2022/04/18 12:50:44] root INFO: DecodeImage : +[2022/04/18 12:50:44] root INFO: channel_first : False +[2022/04/18 12:50:44] root INFO: to_rgb : True +[2022/04/18 12:50:44] root INFO: ResizeImage : +[2022/04/18 12:50:44] root INFO: resize_short : 36 +[2022/04/18 12:50:44] root INFO: CropImage : +[2022/04/18 12:50:44] root INFO: size : 32 +[2022/04/18 12:50:44] root INFO: NormalizeImage : +[2022/04/18 12:50:44] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:50:44] root INFO: order : +[2022/04/18 12:50:44] root INFO: scale : 1.0/255.0 +[2022/04/18 12:50:44] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:50:44] root INFO: loader : +[2022/04/18 12:50:44] root INFO: num_workers : 4 +[2022/04/18 12:50:44] root INFO: use_shared_memory : True +[2022/04/18 12:50:44] root INFO: sampler : +[2022/04/18 12:50:44] root INFO: batch_size : 64 +[2022/04/18 12:50:44] root INFO: drop_last : False +[2022/04/18 12:50:44] root INFO: name : DistributedBatchSampler +[2022/04/18 12:50:44] root INFO: shuffle : False +[2022/04/18 12:50:44] root INFO: Train : +[2022/04/18 12:50:44] root INFO: dataset : +[2022/04/18 12:50:44] root INFO: cls_label_path : ./dataset/CIFAR100/train_list.txt +[2022/04/18 12:50:44] root INFO: image_root : ./dataset/CIFAR100/ +[2022/04/18 12:50:44] root INFO: name : ImageNetDataset +[2022/04/18 12:50:44] root INFO: transform_ops : +[2022/04/18 12:50:44] root INFO: DecodeImage : +[2022/04/18 12:50:44] root INFO: channel_first : False +[2022/04/18 12:50:44] root INFO: to_rgb : True +[2022/04/18 12:50:44] root INFO: RandCropImage : +[2022/04/18 12:50:44] root INFO: size : 32 +[2022/04/18 12:50:44] root INFO: RandFlipImage : +[2022/04/18 12:50:44] root INFO: flip_code : 1 +[2022/04/18 12:50:44] root INFO: NormalizeImage : +[2022/04/18 12:50:44] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:50:44] root INFO: order : +[2022/04/18 12:50:44] root INFO: scale : 1.0/255.0 +[2022/04/18 12:50:44] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:50:44] root INFO: loader : +[2022/04/18 12:50:44] root INFO: num_workers : 4 +[2022/04/18 12:50:44] root INFO: use_shared_memory : True +[2022/04/18 12:50:44] root INFO: sampler : +[2022/04/18 12:50:44] root INFO: batch_size : 64 +[2022/04/18 12:50:44] root INFO: drop_last : False +[2022/04/18 12:50:44] root INFO: name : DistributedBatchSampler +[2022/04/18 12:50:44] root INFO: shuffle : True +[2022/04/18 12:50:44] root INFO: Global : +[2022/04/18 12:50:44] root INFO: checkpoints : None +[2022/04/18 12:50:44] root INFO: device : gpu +[2022/04/18 12:50:44] root INFO: epochs : 100 +[2022/04/18 12:50:44] root INFO: eval_during_train : True +[2022/04/18 12:50:44] root INFO: eval_interval : 1 +[2022/04/18 12:50:44] root INFO: image_shape : [3, 32, 32] +[2022/04/18 12:50:44] root INFO: output_dir : output_CIFAR +[2022/04/18 12:50:44] root INFO: pretrained_model : None +[2022/04/18 12:50:44] root INFO: print_batch_step : 10 +[2022/04/18 12:50:44] root INFO: save_inference_dir : ./inference +[2022/04/18 12:50:44] root INFO: save_interval : 1 +[2022/04/18 12:50:44] root INFO: use_visualdl : False +[2022/04/18 12:50:44] root INFO: Infer : +[2022/04/18 12:50:44] root INFO: PostProcess : +[2022/04/18 12:50:44] root INFO: name : Topk +[2022/04/18 12:50:44] root INFO: topk : 5 +[2022/04/18 12:50:44] root INFO: batch_size : 10 +[2022/04/18 12:50:44] root INFO: infer_imgs : docs/images/inference_deployment/whl_demo.jpg +[2022/04/18 12:50:44] root INFO: transforms : +[2022/04/18 12:50:44] root INFO: DecodeImage : +[2022/04/18 12:50:44] root INFO: channel_first : False +[2022/04/18 12:50:44] root INFO: to_rgb : True +[2022/04/18 12:50:44] root INFO: ResizeImage : +[2022/04/18 12:50:44] root INFO: resize_short : 36 +[2022/04/18 12:50:44] root INFO: CropImage : +[2022/04/18 12:50:44] root INFO: size : 32 +[2022/04/18 12:50:44] root INFO: NormalizeImage : +[2022/04/18 12:50:44] root INFO: mean : [0.485, 0.456, 0.406] +[2022/04/18 12:50:44] root INFO: order : +[2022/04/18 12:50:44] root INFO: scale : 1.0/255.0 +[2022/04/18 12:50:44] root INFO: std : [0.229, 0.224, 0.225] +[2022/04/18 12:50:44] root INFO: ToCHWImage : None +[2022/04/18 12:50:44] root INFO: Loss : +[2022/04/18 12:50:44] root INFO: Eval : +[2022/04/18 12:50:44] root INFO: CELoss : +[2022/04/18 12:50:44] root INFO: weight : 1.0 +[2022/04/18 12:50:44] root INFO: Train : +[2022/04/18 12:50:44] root INFO: CELoss : +[2022/04/18 12:50:44] root INFO: weight : 1.0 +[2022/04/18 12:50:44] root INFO: Metric : +[2022/04/18 12:50:44] root INFO: Eval : +[2022/04/18 12:50:44] root INFO: TopkAcc : +[2022/04/18 12:50:44] root INFO: topk : [1, 5] +[2022/04/18 12:50:44] root INFO: Train : +[2022/04/18 12:50:44] root INFO: TopkAcc : +[2022/04/18 12:50:44] root INFO: topk : [1, 5] +[2022/04/18 12:50:44] root INFO: Optimizer : +[2022/04/18 12:50:44] root INFO: lr : +[2022/04/18 12:50:44] root INFO: learning_rate : 0.04 +[2022/04/18 12:50:44] root INFO: name : Cosine +[2022/04/18 12:50:44] root INFO: momentum : 0.9 +[2022/04/18 12:50:44] root INFO: name : Momentum +[2022/04/18 12:50:44] root INFO: regularizer : +[2022/04/18 12:50:44] root INFO: coeff : 0.0001 +[2022/04/18 12:50:44] root INFO: name : L2 +[2022/04/18 12:50:44] root INFO: profiler_options : None diff --git a/src/PaddleClas/paddleclas.py b/src/PaddleClas/paddleclas.py new file mode 100644 index 0000000..bfad193 --- /dev/null +++ b/src/PaddleClas/paddleclas.py @@ -0,0 +1,572 @@ +# Copyright (c) 2021 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. + +import os +import sys +__dir__ = os.path.dirname(__file__) +sys.path.append(os.path.join(__dir__, "")) +sys.path.append(os.path.join(__dir__, "deploy")) + +from typing import Union, Generator +import argparse +import shutil +import textwrap +import tarfile +import requests +import warnings +from functools import partial +from difflib import SequenceMatcher + +import cv2 +import numpy as np +from tqdm import tqdm +from prettytable import PrettyTable + +from deploy.python.predict_cls import ClsPredictor +from deploy.utils.get_image_list import get_image_list +from deploy.utils import config + +from ppcls.arch.backbone import * +from ppcls.utils.logger import init_logger + +# for building model with loading pretrained weights from backbone +init_logger() + +__all__ = ["PaddleClas"] + +BASE_DIR = os.path.expanduser("~/.paddleclas/") +BASE_INFERENCE_MODEL_DIR = os.path.join(BASE_DIR, "inference_model") +BASE_IMAGES_DIR = os.path.join(BASE_DIR, "images") +BASE_DOWNLOAD_URL = "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/{}_infer.tar" +MODEL_SERIES = { + "AlexNet": ["AlexNet"], + "DarkNet": ["DarkNet53"], + "DeiT": [ + "DeiT_base_distilled_patch16_224", "DeiT_base_distilled_patch16_384", + "DeiT_base_patch16_224", "DeiT_base_patch16_384", + "DeiT_small_distilled_patch16_224", "DeiT_small_patch16_224", + "DeiT_tiny_distilled_patch16_224", "DeiT_tiny_patch16_224" + ], + "DenseNet": [ + "DenseNet121", "DenseNet161", "DenseNet169", "DenseNet201", + "DenseNet264" + ], + "DLA": [ + "DLA46_c", "DLA60x_c", "DLA34", "DLA60", "DLA60x", "DLA102", "DLA102x", + "DLA102x2", "DLA169" + ], + "DPN": ["DPN68", "DPN92", "DPN98", "DPN107", "DPN131"], + "EfficientNet": [ + "EfficientNetB0", "EfficientNetB0_small", "EfficientNetB1", + "EfficientNetB2", "EfficientNetB3", "EfficientNetB4", "EfficientNetB5", + "EfficientNetB6", "EfficientNetB7" + ], + "ESNet": ["ESNet_x0_25", "ESNet_x0_5", "ESNet_x0_75", "ESNet_x1_0"], + "GhostNet": + ["GhostNet_x0_5", "GhostNet_x1_0", "GhostNet_x1_3", "GhostNet_x1_3_ssld"], + "HarDNet": ["HarDNet39_ds", "HarDNet68_ds", "HarDNet68", "HarDNet85"], + "HRNet": [ + "HRNet_W18_C", "HRNet_W30_C", "HRNet_W32_C", "HRNet_W40_C", + "HRNet_W44_C", "HRNet_W48_C", "HRNet_W64_C", "HRNet_W18_C_ssld", + "HRNet_W48_C_ssld" + ], + "Inception": ["GoogLeNet", "InceptionV3", "InceptionV4"], + "MixNet": ["MixNet_S", "MixNet_M", "MixNet_L"], + "MobileNetV1": [ + "MobileNetV1_x0_25", "MobileNetV1_x0_5", "MobileNetV1_x0_75", + "MobileNetV1", "MobileNetV1_ssld" + ], + "MobileNetV2": [ + "MobileNetV2_x0_25", "MobileNetV2_x0_5", "MobileNetV2_x0_75", + "MobileNetV2", "MobileNetV2_x1_5", "MobileNetV2_x2_0", + "MobileNetV2_ssld" + ], + "MobileNetV3": [ + "MobileNetV3_small_x0_35", "MobileNetV3_small_x0_5", + "MobileNetV3_small_x0_75", "MobileNetV3_small_x1_0", + "MobileNetV3_small_x1_25", "MobileNetV3_large_x0_35", + "MobileNetV3_large_x0_5", "MobileNetV3_large_x0_75", + "MobileNetV3_large_x1_0", "MobileNetV3_large_x1_25", + "MobileNetV3_small_x1_0_ssld", "MobileNetV3_large_x1_0_ssld" + ], + "PPLCNet": [ + "PPLCNet_x0_25", "PPLCNet_x0_35", "PPLCNet_x0_5", "PPLCNet_x0_75", + "PPLCNet_x1_0", "PPLCNet_x1_5", "PPLCNet_x2_0", "PPLCNet_x2_5" + ], + "RedNet": ["RedNet26", "RedNet38", "RedNet50", "RedNet101", "RedNet152"], + "RegNet": ["RegNetX_4GF"], + "Res2Net": [ + "Res2Net50_14w_8s", "Res2Net50_26w_4s", "Res2Net50_vd_26w_4s", + "Res2Net200_vd_26w_4s", "Res2Net101_vd_26w_4s", + "Res2Net50_vd_26w_4s_ssld", "Res2Net101_vd_26w_4s_ssld", + "Res2Net200_vd_26w_4s_ssld" + ], + "ResNeSt": ["ResNeSt50", "ResNeSt50_fast_1s1x64d"], + "ResNet": [ + "ResNet18", "ResNet18_vd", "ResNet34", "ResNet34_vd", "ResNet50", + "ResNet50_vc", "ResNet50_vd", "ResNet50_vd_v2", "ResNet101", + "ResNet101_vd", "ResNet152", "ResNet152_vd", "ResNet200_vd", + "ResNet34_vd_ssld", "ResNet50_vd_ssld", "ResNet50_vd_ssld_v2", + "ResNet101_vd_ssld", "Fix_ResNet50_vd_ssld_v2", "ResNet50_ACNet_deploy" + ], + "ResNeXt": [ + "ResNeXt50_32x4d", "ResNeXt50_vd_32x4d", "ResNeXt50_64x4d", + "ResNeXt50_vd_64x4d", "ResNeXt101_32x4d", "ResNeXt101_vd_32x4d", + "ResNeXt101_32x8d_wsl", "ResNeXt101_32x16d_wsl", + "ResNeXt101_32x32d_wsl", "ResNeXt101_32x48d_wsl", + "Fix_ResNeXt101_32x48d_wsl", "ResNeXt101_64x4d", "ResNeXt101_vd_64x4d", + "ResNeXt152_32x4d", "ResNeXt152_vd_32x4d", "ResNeXt152_64x4d", + "ResNeXt152_vd_64x4d" + ], + "ReXNet": + ["ReXNet_1_0", "ReXNet_1_3", "ReXNet_1_5", "ReXNet_2_0", "ReXNet_3_0"], + "SENet": [ + "SENet154_vd", "SE_HRNet_W64_C_ssld", "SE_ResNet18_vd", + "SE_ResNet34_vd", "SE_ResNet50_vd", "SE_ResNeXt50_32x4d", + "SE_ResNeXt50_vd_32x4d", "SE_ResNeXt101_32x4d" + ], + "ShuffleNetV2": [ + "ShuffleNetV2_swish", "ShuffleNetV2_x0_25", "ShuffleNetV2_x0_33", + "ShuffleNetV2_x0_5", "ShuffleNetV2_x1_0", "ShuffleNetV2_x1_5", + "ShuffleNetV2_x2_0" + ], + "SqueezeNet": ["SqueezeNet1_0", "SqueezeNet1_1"], + "SwinTransformer": [ + "SwinTransformer_large_patch4_window7_224_22kto1k", + "SwinTransformer_large_patch4_window12_384_22kto1k", + "SwinTransformer_base_patch4_window7_224_22kto1k", + "SwinTransformer_base_patch4_window12_384_22kto1k", + "SwinTransformer_base_patch4_window12_384", + "SwinTransformer_base_patch4_window7_224", + "SwinTransformer_small_patch4_window7_224", + "SwinTransformer_tiny_patch4_window7_224" + ], + "Twins": [ + "pcpvt_small", "pcpvt_base", "pcpvt_large", "alt_gvt_small", + "alt_gvt_base", "alt_gvt_large" + ], + "VGG": ["VGG11", "VGG13", "VGG16", "VGG19"], + "VisionTransformer": [ + "ViT_base_patch16_224", "ViT_base_patch16_384", "ViT_base_patch32_384", + "ViT_large_patch16_224", "ViT_large_patch16_384", + "ViT_large_patch32_384", "ViT_small_patch16_224" + ], + "Xception": [ + "Xception41", "Xception41_deeplab", "Xception65", "Xception65_deeplab", + "Xception71" + ] +} + + +class ImageTypeError(Exception): + """ImageTypeError. + """ + + def __init__(self, message=""): + super().__init__(message) + + +class InputModelError(Exception): + """InputModelError. + """ + + def __init__(self, message=""): + super().__init__(message) + + +def init_config(model_name, + inference_model_dir, + use_gpu=True, + batch_size=1, + topk=5, + **kwargs): + imagenet1k_map_path = os.path.join( + os.path.abspath(__dir__), "ppcls/utils/imagenet1k_label_list.txt") + cfg = { + "Global": { + "infer_imgs": kwargs["infer_imgs"] + if "infer_imgs" in kwargs else False, + "model_name": model_name, + "inference_model_dir": inference_model_dir, + "batch_size": batch_size, + "use_gpu": use_gpu, + "enable_mkldnn": kwargs["enable_mkldnn"] + if "enable_mkldnn" in kwargs else False, + "cpu_num_threads": kwargs["cpu_num_threads"] + if "cpu_num_threads" in kwargs else 1, + "enable_benchmark": False, + "use_fp16": kwargs["use_fp16"] if "use_fp16" in kwargs else False, + "ir_optim": True, + "use_tensorrt": kwargs["use_tensorrt"] + if "use_tensorrt" in kwargs else False, + "gpu_mem": kwargs["gpu_mem"] if "gpu_mem" in kwargs else 8000, + "enable_profile": False + }, + "PreProcess": { + "transform_ops": [{ + "ResizeImage": { + "resize_short": kwargs["resize_short"] + if "resize_short" in kwargs else 256 + } + }, { + "CropImage": { + "size": kwargs["crop_size"] + if "crop_size" in kwargs else 224 + } + }, { + "NormalizeImage": { + "scale": 0.00392157, + "mean": [0.485, 0.456, 0.406], + "std": [0.229, 0.224, 0.225], + "order": '' + } + }, { + "ToCHWImage": None + }] + }, + "PostProcess": { + "main_indicator": "Topk", + "Topk": { + "topk": topk, + "class_id_map_file": imagenet1k_map_path + } + } + } + if "save_dir" in kwargs: + if kwargs["save_dir"] is not None: + cfg["PostProcess"]["SavePreLabel"] = { + "save_dir": kwargs["save_dir"] + } + if "class_id_map_file" in kwargs: + if kwargs["class_id_map_file"] is not None: + cfg["PostProcess"]["Topk"]["class_id_map_file"] = kwargs[ + "class_id_map_file"] + + cfg = config.AttrDict(cfg) + config.create_attr_dict(cfg) + return cfg + + +def args_cfg(): + def str2bool(v): + return v.lower() in ("true", "t", "1") + + parser = argparse.ArgumentParser() + parser.add_argument( + "--infer_imgs", + type=str, + required=True, + help="The image(s) to be predicted.") + parser.add_argument( + "--model_name", type=str, help="The model name to be used.") + parser.add_argument( + "--inference_model_dir", + type=str, + help="The directory of model files. Valid when model_name not specifed." + ) + parser.add_argument( + "--use_gpu", type=str, default=True, help="Whether use GPU.") + parser.add_argument("--gpu_mem", type=int, default=8000, help="") + parser.add_argument( + "--enable_mkldnn", + type=str2bool, + default=False, + help="Whether use MKLDNN. Valid when use_gpu is False") + parser.add_argument("--cpu_num_threads", type=int, default=1, help="") + parser.add_argument( + "--use_tensorrt", type=str2bool, default=False, help="") + parser.add_argument("--use_fp16", type=str2bool, default=False, help="") + parser.add_argument( + "--batch_size", type=int, default=1, help="Batch size. Default by 1.") + parser.add_argument( + "--topk", + type=int, + default=5, + help="Return topk score(s) and corresponding results. Default by 5.") + parser.add_argument( + "--class_id_map_file", + type=str, + help="The path of file that map class_id and label.") + parser.add_argument( + "--save_dir", + type=str, + help="The directory to save prediction results as pre-label.") + parser.add_argument( + "--resize_short", + type=int, + default=256, + help="Resize according to short size.") + parser.add_argument( + "--crop_size", type=int, default=224, help="Centor crop size.") + + args = parser.parse_args() + return vars(args) + + +def print_info(): + """Print list of supported models in formatted. + """ + 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=width) + table.add_row([series, names]) + width = len(str(table).split("\n")[0]) + print("{}".format("-" * width)) + print("Models supported by PaddleClas".center(width)) + print(table) + print("Powered by PaddlePaddle!".rjust(width)) + print("{}".format("-" * width)) + + +def get_model_names(): + """Get the model names list. + """ + model_names = [] + for series in MODEL_SERIES: + model_names += (MODEL_SERIES[series]) + return model_names + + +def similar_architectures(name="", names=[], thresh=0.1, topk=10): + """Find the most similar topk model names. + """ + scores = [] + for idx, n in enumerate(names): + if n.startswith("__"): + continue + score = SequenceMatcher(None, n.lower(), name.lower()).quick_ratio() + if score > thresh: + scores.append((idx, score)) + scores.sort(key=lambda x: x[1], reverse=True) + similar_names = [names[s[0]] for s in scores[:min(topk, len(scores))]] + return similar_names + + +def download_with_progressbar(url, save_path): + """Download from url with progressbar. + """ + if os.path.isfile(save_path): + os.remove(save_path) + response = requests.get(url, stream=True) + total_size_in_bytes = int(response.headers.get("content-length", 0)) + block_size = 1024 # 1 Kibibyte + progress_bar = tqdm(total=total_size_in_bytes, unit="iB", unit_scale=True) + with open(save_path, "wb") as file: + for data in response.iter_content(block_size): + progress_bar.update(len(data)) + file.write(data) + progress_bar.close() + if total_size_in_bytes == 0 or progress_bar.n != total_size_in_bytes or not os.path.isfile( + save_path): + raise Exception( + f"Something went wrong while downloading file from {url}") + + +def check_model_file(model_name): + """Check the model files exist and download and untar when no exist. + """ + storage_directory = partial(os.path.join, BASE_INFERENCE_MODEL_DIR, + model_name) + url = BASE_DOWNLOAD_URL.format(model_name) + + tar_file_name_list = [ + "inference.pdiparams", "inference.pdiparams.info", "inference.pdmodel" + ] + model_file_path = storage_directory("inference.pdmodel") + params_file_path = storage_directory("inference.pdiparams") + if not os.path.exists(model_file_path) or not os.path.exists( + params_file_path): + tmp_path = storage_directory(url.split("/")[-1]) + print(f"download {url} to {tmp_path}") + os.makedirs(storage_directory(), exist_ok=True) + download_with_progressbar(url, tmp_path) + with tarfile.open(tmp_path, "r") as tarObj: + for member in tarObj.getmembers(): + filename = None + for tar_file_name in tar_file_name_list: + if tar_file_name in member.name: + filename = tar_file_name + if filename is None: + continue + file = tarObj.extractfile(member) + with open(storage_directory(filename), "wb") as f: + f.write(file.read()) + os.remove(tmp_path) + if not os.path.exists(model_file_path) or not os.path.exists( + params_file_path): + raise Exception( + f"Something went wrong while praparing the model[{model_name}] files!" + ) + + return storage_directory() + + +class PaddleClas(object): + """PaddleClas. + """ + + print_info() + + def __init__(self, + model_name: str=None, + inference_model_dir: str=None, + use_gpu: bool=True, + batch_size: int=1, + topk: int=5, + **kwargs): + """Init PaddleClas with config. + + Args: + model_name (str, optional): The model name supported by PaddleClas. If specified, override config. Defaults to None. + inference_model_dir (str, optional): The directory that contained model file and params file to be used. If specified, override config. Defaults to None. + use_gpu (bool, optional): Whether use GPU. If specified, override config. Defaults to True. + batch_size (int, optional): The batch size to pridict. If specified, override config. Defaults to 1. + topk (int, optional): Return the top k prediction results with the highest score. Defaults to 5. + """ + super().__init__() + self._config = init_config(model_name, inference_model_dir, use_gpu, + batch_size, topk, **kwargs) + self._check_input_model() + self.cls_predictor = ClsPredictor(self._config) + + def get_config(self): + """Get the config. + """ + return self._config + + def _check_input_model(self): + """Check input model name or model files. + """ + candidate_model_names = get_model_names() + input_model_name = self._config.Global.get("model_name", None) + inference_model_dir = self._config.Global.get("inference_model_dir", + None) + if input_model_name is not None: + similar_names = similar_architectures(input_model_name, + candidate_model_names) + similar_names_str = ", ".join(similar_names) + if input_model_name not in candidate_model_names: + err = f"{input_model_name} is not provided by PaddleClas. \nMaybe you want: [{similar_names_str}]. \nIf you want to use your own model, please specify inference_model_dir!" + raise InputModelError(err) + self._config.Global.inference_model_dir = check_model_file( + input_model_name) + return + elif inference_model_dir is not None: + model_file_path = os.path.join(inference_model_dir, + "inference.pdmodel") + params_file_path = os.path.join(inference_model_dir, + "inference.pdiparams") + if not os.path.isfile(model_file_path) or not os.path.isfile( + params_file_path): + err = f"There is no model file or params file in this directory: {inference_model_dir}" + raise InputModelError(err) + return + else: + err = f"Please specify the model name supported by PaddleClas or directory contained model files(inference.pdmodel, inference.pdiparams)." + raise InputModelError(err) + return + + def predict(self, input_data: Union[str, np.array], + print_pred: bool=False) -> Generator[list, None, None]: + """Predict input_data. + + Args: + input_data (Union[str, np.array]): + When the type is str, it is the path of image, or the directory containing images, or the URL of image from Internet. + When the type is np.array, it is the image data whose channel order is RGB. + print_pred (bool, optional): Whether print the prediction result. Defaults to False. + + Raises: + ImageTypeError: Illegal input_data. + + Yields: + Generator[list, None, None]: + The prediction result(s) of input_data by batch_size. For every one image, + prediction result(s) is zipped as a dict, that includs topk "class_ids", "scores" and "label_names". + The format of batch prediction result(s) is as follow: [{"class_ids": [...], "scores": [...], "label_names": [...]}, ...] + """ + + if isinstance(input_data, np.ndarray): + yield self.cls_predictor.predict(input_data) + elif isinstance(input_data, str): + if input_data.startswith("http") or input_data.startswith("https"): + image_storage_dir = partial(os.path.join, BASE_IMAGES_DIR) + if not os.path.exists(image_storage_dir()): + os.makedirs(image_storage_dir()) + image_save_path = image_storage_dir("tmp.jpg") + download_with_progressbar(input_data, image_save_path) + input_data = image_save_path + warnings.warn( + f"Image to be predicted from Internet: {input_data}, has been saved to: {image_save_path}" + ) + image_list = get_image_list(input_data) + + batch_size = self._config.Global.get("batch_size", 1) + topk = self._config.PostProcess.Topk.get('topk', 1) + + img_list = [] + img_path_list = [] + cnt = 0 + for idx, img_path in enumerate(image_list): + img = cv2.imread(img_path) + if img is None: + warnings.warn( + f"Image file failed to read and has been skipped. The path: {img_path}" + ) + continue + img = img[:, :, ::-1] + img_list.append(img) + img_path_list.append(img_path) + cnt += 1 + + if cnt % batch_size == 0 or (idx + 1) == len(image_list): + preds = self.cls_predictor.predict(img_list) + + if print_pred and preds: + for idx, pred in enumerate(preds): + pred_str = ", ".join( + [f"{k}: {pred[k]}" for k in pred]) + print( + f"filename: {img_path_list[idx]}, top-{topk}, {pred_str}" + ) + + img_list = [] + img_path_list = [] + yield preds + else: + err = "Please input legal image! The type of image supported by PaddleClas are: NumPy.ndarray and string of local path or Ineternet URL" + raise ImageTypeError(err) + return + + +# for CLI +def main(): + """Function API used for commad line. + """ + cfg = args_cfg() + clas_engine = PaddleClas(**cfg) + res = clas_engine.predict(cfg["infer_imgs"], print_pred=True) + for _ in res: + pass + print("Predict complete!") + return + + +if __name__ == "__main__": + main() diff --git a/src/PaddleClas/ppcls/__init__.py b/src/PaddleClas/ppcls/__init__.py new file mode 100644 index 0000000..d6cdb6f --- /dev/null +++ b/src/PaddleClas/ppcls/__init__.py @@ -0,0 +1,20 @@ +# 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 optimizer + +from .arch import * +from .optimizer import * +from .data import * +from .utils import * diff --git a/src/PaddleClas/ppcls/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..d088393 Binary files /dev/null and b/src/PaddleClas/ppcls/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/__init__.py b/src/PaddleClas/ppcls/arch/__init__.py new file mode 100644 index 0000000..2d5e29d --- /dev/null +++ b/src/PaddleClas/ppcls/arch/__init__.py @@ -0,0 +1,134 @@ +#copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +#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. + +import copy +import importlib + +import paddle.nn as nn +from paddle.jit import to_static +from paddle.static import InputSpec + +from . import backbone, gears +from .backbone import * +from .gears import build_gear +from .utils import * +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils import logger +from ppcls.utils.save_load import load_dygraph_pretrain +from ppcls.arch.slim import prune_model, quantize_model + +__all__ = ["build_model", "RecModel", "DistillationModel"] + + +def build_model(config): + arch_config = copy.deepcopy(config["Arch"]) + model_type = arch_config.pop("name") + mod = importlib.import_module(__name__) + arch = getattr(mod, model_type)(**arch_config) + if isinstance(arch, TheseusLayer): + prune_model(config, arch) + quantize_model(config, arch) + return arch + + +def apply_to_static(config, model): + support_to_static = config['Global'].get('to_static', False) + + if support_to_static: + specs = None + if 'image_shape' in config['Global']: + specs = [InputSpec([None] + config['Global']['image_shape'])] + model = to_static(model, input_spec=specs) + logger.info("Successfully to apply @to_static with specs: {}".format( + specs)) + return model + + +class RecModel(TheseusLayer): + def __init__(self, **config): + super().__init__() + backbone_config = config["Backbone"] + backbone_name = backbone_config.pop("name") + self.backbone = eval(backbone_name)(**backbone_config) + if "BackboneStopLayer" in config: + backbone_stop_layer = config["BackboneStopLayer"]["name"] + self.backbone.stop_after(backbone_stop_layer) + + if "Neck" in config: + self.neck = build_gear(config["Neck"]) + else: + self.neck = None + + if "Head" in config: + self.head = build_gear(config["Head"]) + else: + self.head = None + + def forward(self, x, label=None): + out = dict() + x = self.backbone(x) + out["backbone"] = x + if self.neck is not None: + x = self.neck(x) + out["neck"] = x + out["features"] = x + if self.head is not None: + y = self.head(x, label) + out["logits"] = y + return out + + +class DistillationModel(nn.Layer): + def __init__(self, + models=None, + pretrained_list=None, + freeze_params_list=None, + **kargs): + super().__init__() + assert isinstance(models, list) + self.model_list = [] + self.model_name_list = [] + if pretrained_list is not None: + assert len(pretrained_list) == len(models) + + if freeze_params_list is None: + freeze_params_list = [False] * len(models) + assert len(freeze_params_list) == len(models) + for idx, model_config in enumerate(models): + assert len(model_config) == 1 + key = list(model_config.keys())[0] + model_config = model_config[key] + model_name = model_config.pop("name") + model = eval(model_name)(**model_config) + + if freeze_params_list[idx]: + for param in model.parameters(): + param.trainable = False + self.model_list.append(self.add_sublayer(key, model)) + self.model_name_list.append(key) + + if pretrained_list is not None: + for idx, pretrained in enumerate(pretrained_list): + if pretrained is not None: + load_dygraph_pretrain( + self.model_name_list[idx], path=pretrained) + + def forward(self, x, label=None): + result_dict = dict() + for idx, model_name in enumerate(self.model_name_list): + if label is None: + result_dict[model_name] = self.model_list[idx](x) + else: + result_dict[model_name] = self.model_list[idx](x, label) + return result_dict diff --git a/src/PaddleClas/ppcls/arch/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..8585526 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/__pycache__/utils.cpython-39.pyc b/src/PaddleClas/ppcls/arch/__pycache__/utils.cpython-39.pyc new file mode 100644 index 0000000..e1b3292 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/__pycache__/utils.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/__init__.py b/src/PaddleClas/ppcls/arch/backbone/__init__.py new file mode 100644 index 0000000..1bd23a9 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/__init__.py @@ -0,0 +1,83 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import sys +import inspect + +from ppcls.arch.backbone.legendary_models.mobilenet_v1 import MobileNetV1_x0_25, MobileNetV1_x0_5, MobileNetV1_x0_75, MobileNetV1 +from ppcls.arch.backbone.legendary_models.mobilenet_v3 import MobileNetV3_small_x0_35, MobileNetV3_small_x0_5, MobileNetV3_small_x0_75, MobileNetV3_small_x1_0, MobileNetV3_small_x1_25, MobileNetV3_large_x0_35, MobileNetV3_large_x0_5, MobileNetV3_large_x0_75, MobileNetV3_large_x1_0, MobileNetV3_large_x1_25 +from ppcls.arch.backbone.legendary_models.resnet import ResNet18, ResNet18_vd, ResNet34, ResNet34_vd, ResNet50, ResNet50_vd, ResNet101, ResNet101_vd, ResNet152, ResNet152_vd, ResNet200_vd +from ppcls.arch.backbone.legendary_models.vgg import VGG11, VGG13, VGG16, VGG19 +from ppcls.arch.backbone.legendary_models.inception_v3 import InceptionV3 +from ppcls.arch.backbone.legendary_models.hrnet import HRNet_W18_C, HRNet_W30_C, HRNet_W32_C, HRNet_W40_C, HRNet_W44_C, HRNet_W48_C, HRNet_W60_C, HRNet_W64_C, SE_HRNet_W64_C +from ppcls.arch.backbone.legendary_models.pp_lcnet import PPLCNet_x0_25, PPLCNet_x0_35, PPLCNet_x0_5, PPLCNet_x0_75, PPLCNet_x1_0, PPLCNet_x1_5, PPLCNet_x2_0, PPLCNet_x2_5 +from ppcls.arch.backbone.legendary_models.esnet import ESNet_x0_25, ESNet_x0_5, ESNet_x0_75, ESNet_x1_0 + +from ppcls.arch.backbone.model_zoo.resnet_vc import ResNet50_vc +from ppcls.arch.backbone.model_zoo.resnext import ResNeXt50_32x4d, ResNeXt50_64x4d, ResNeXt101_32x4d, ResNeXt101_64x4d, ResNeXt152_32x4d, ResNeXt152_64x4d +from ppcls.arch.backbone.model_zoo.resnext_vd import ResNeXt50_vd_32x4d, ResNeXt50_vd_64x4d, ResNeXt101_vd_32x4d, ResNeXt101_vd_64x4d, ResNeXt152_vd_32x4d, ResNeXt152_vd_64x4d +from ppcls.arch.backbone.model_zoo.res2net import Res2Net50_26w_4s, Res2Net50_14w_8s +from ppcls.arch.backbone.model_zoo.res2net_vd import Res2Net50_vd_26w_4s, Res2Net101_vd_26w_4s, Res2Net200_vd_26w_4s +from ppcls.arch.backbone.model_zoo.se_resnet_vd import SE_ResNet18_vd, SE_ResNet34_vd, SE_ResNet50_vd +from ppcls.arch.backbone.model_zoo.se_resnext_vd import SE_ResNeXt50_vd_32x4d, SE_ResNeXt50_vd_32x4d, SENet154_vd +from ppcls.arch.backbone.model_zoo.se_resnext import SE_ResNeXt50_32x4d, SE_ResNeXt101_32x4d, SE_ResNeXt152_64x4d +from ppcls.arch.backbone.model_zoo.dpn import DPN68, DPN92, DPN98, DPN107, DPN131 +from ppcls.arch.backbone.model_zoo.densenet import DenseNet121, DenseNet161, DenseNet169, DenseNet201, DenseNet264 +from ppcls.arch.backbone.model_zoo.efficientnet import EfficientNetB0, EfficientNetB1, EfficientNetB2, EfficientNetB3, EfficientNetB4, EfficientNetB5, EfficientNetB6, EfficientNetB7, EfficientNetB0_small +from ppcls.arch.backbone.model_zoo.resnest import ResNeSt50_fast_1s1x64d, ResNeSt50, ResNeSt101 +from ppcls.arch.backbone.model_zoo.googlenet import GoogLeNet +from ppcls.arch.backbone.model_zoo.mobilenet_v2 import MobileNetV2_x0_25, MobileNetV2_x0_5, MobileNetV2_x0_75, MobileNetV2, MobileNetV2_x1_5, MobileNetV2_x2_0 +from ppcls.arch.backbone.model_zoo.shufflenet_v2 import ShuffleNetV2_x0_25, ShuffleNetV2_x0_33, ShuffleNetV2_x0_5, ShuffleNetV2_x1_0, ShuffleNetV2_x1_5, ShuffleNetV2_x2_0, ShuffleNetV2_swish +from ppcls.arch.backbone.model_zoo.ghostnet import GhostNet_x0_5, GhostNet_x1_0, GhostNet_x1_3 +from ppcls.arch.backbone.model_zoo.alexnet import AlexNet +from ppcls.arch.backbone.model_zoo.inception_v4 import InceptionV4 +from ppcls.arch.backbone.model_zoo.xception import Xception41, Xception65, Xception71 +from ppcls.arch.backbone.model_zoo.xception_deeplab import Xception41_deeplab, Xception65_deeplab +from ppcls.arch.backbone.model_zoo.resnext101_wsl import ResNeXt101_32x8d_wsl, ResNeXt101_32x16d_wsl, ResNeXt101_32x32d_wsl, ResNeXt101_32x48d_wsl +from ppcls.arch.backbone.model_zoo.squeezenet import SqueezeNet1_0, SqueezeNet1_1 +from ppcls.arch.backbone.model_zoo.darknet import DarkNet53 +from ppcls.arch.backbone.model_zoo.regnet import RegNetX_200MF, RegNetX_4GF, RegNetX_32GF, RegNetY_200MF, RegNetY_4GF, RegNetY_32GF +from ppcls.arch.backbone.model_zoo.vision_transformer import ViT_small_patch16_224, ViT_base_patch16_224, ViT_base_patch16_384, ViT_base_patch32_384, ViT_large_patch16_224, ViT_large_patch16_384, ViT_large_patch32_384 +from ppcls.arch.backbone.model_zoo.distilled_vision_transformer import DeiT_tiny_patch16_224, DeiT_small_patch16_224, DeiT_base_patch16_224, DeiT_tiny_distilled_patch16_224, DeiT_small_distilled_patch16_224, DeiT_base_distilled_patch16_224, DeiT_base_patch16_384, DeiT_base_distilled_patch16_384 +from ppcls.arch.backbone.model_zoo.swin_transformer import SwinTransformer_tiny_patch4_window7_224, SwinTransformer_small_patch4_window7_224, SwinTransformer_base_patch4_window7_224, SwinTransformer_base_patch4_window12_384, SwinTransformer_large_patch4_window7_224, SwinTransformer_large_patch4_window12_384 +from ppcls.arch.backbone.model_zoo.mixnet import MixNet_S, MixNet_M, MixNet_L +from ppcls.arch.backbone.model_zoo.rexnet import ReXNet_1_0, ReXNet_1_3, ReXNet_1_5, ReXNet_2_0, ReXNet_3_0 +from ppcls.arch.backbone.model_zoo.gvt import pcpvt_small, pcpvt_base, pcpvt_large, alt_gvt_small, alt_gvt_base, alt_gvt_large +from ppcls.arch.backbone.model_zoo.levit import LeViT_128S, LeViT_128, LeViT_192, LeViT_256, LeViT_384 +from ppcls.arch.backbone.model_zoo.dla import DLA34, DLA46_c, DLA46x_c, DLA60, DLA60x, DLA60x_c, DLA102, DLA102x, DLA102x2, DLA169 +from ppcls.arch.backbone.model_zoo.rednet import RedNet26, RedNet38, RedNet50, RedNet101, RedNet152 +from ppcls.arch.backbone.model_zoo.tnt import TNT_small +from ppcls.arch.backbone.model_zoo.hardnet import HarDNet68, HarDNet85, HarDNet39_ds, HarDNet68_ds +from ppcls.arch.backbone.model_zoo.cspnet import CSPDarkNet53 +from ppcls.arch.backbone.model_zoo.pvt_v2 import PVT_V2_B0, PVT_V2_B1, PVT_V2_B2_Linear, PVT_V2_B2, PVT_V2_B3, PVT_V2_B4, PVT_V2_B5 +from ppcls.arch.backbone.model_zoo.repvgg import RepVGG_A0, RepVGG_A1, RepVGG_A2, RepVGG_B0, RepVGG_B1, RepVGG_B2, RepVGG_B1g2, RepVGG_B1g4, RepVGG_B2g4, RepVGG_B3g4 +from ppcls.arch.backbone.variant_models.resnet_variant import ResNet50_last_stage_stride1 +from ppcls.arch.backbone.variant_models.vgg_variant import VGG19Sigmoid +from ppcls.arch.backbone.variant_models.pp_lcnet_variant import PPLCNet_x2_5_Tanh + + +# help whl get all the models' api (class type) and components' api (func type) +def get_apis(): + current_func = sys._getframe().f_code.co_name + current_module = sys.modules[__name__] + api = [] + for _, obj in inspect.getmembers(current_module, + inspect.isclass) + inspect.getmembers( + current_module, inspect.isfunction): + api.append(obj.__name__) + api.remove(current_func) + return api + + +__all__ = get_apis() diff --git a/src/PaddleClas/ppcls/arch/backbone/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..ed10327 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/base/__init__.py b/src/PaddleClas/ppcls/arch/backbone/base/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/ppcls/arch/backbone/base/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/base/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..c69b585 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/base/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/base/__pycache__/theseus_layer.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/base/__pycache__/theseus_layer.cpython-39.pyc new file mode 100644 index 0000000..fd599a5 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/base/__pycache__/theseus_layer.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/base/theseus_layer.py b/src/PaddleClas/ppcls/arch/backbone/base/theseus_layer.py new file mode 100644 index 0000000..908d944 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/base/theseus_layer.py @@ -0,0 +1,301 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 typing import Tuple, List, Dict, Union, Callable, Any + +from paddle import nn +from ppcls.utils import logger + + +class Identity(nn.Layer): + def __init__(self): + super(Identity, self).__init__() + + def forward(self, inputs): + return inputs + + +class TheseusLayer(nn.Layer): + def __init__(self, *args, **kwargs): + super(TheseusLayer, self).__init__() + self.res_dict = {} + self.res_name = self.full_name() + self.pruner = None + self.quanter = None + + def _return_dict_hook(self, layer, input, output): + res_dict = {"output": output} + # 'list' is needed to avoid error raised by popping self.res_dict + for res_key in list(self.res_dict): + # clear the res_dict because the forward process may change according to input + res_dict[res_key] = self.res_dict.pop(res_key) + return res_dict + + def init_res(self, + stages_pattern, + return_patterns=None, + return_stages=None): + if return_patterns and return_stages: + msg = f"The 'return_patterns' would be ignored when 'return_stages' is set." + logger.warning(msg) + return_stages = None + + if return_stages is True: + return_patterns = stages_pattern + # return_stages is int or bool + if type(return_stages) is int: + return_stages = [return_stages] + if isinstance(return_stages, list): + if max(return_stages) > len(stages_pattern) or min( + return_stages) < 0: + msg = f"The 'return_stages' set error. Illegal value(s) have been ignored. The stages' pattern list is {stages_pattern}." + logger.warning(msg) + return_stages = [ + val for val in return_stages + if val >= 0 and val < len(stages_pattern) + ] + return_patterns = [stages_pattern[i] for i in return_stages] + + if return_patterns: + self.update_res(return_patterns) + + def replace_sub(self, *args, **kwargs) -> None: + msg = "The function 'replace_sub()' is deprecated, please use 'upgrade_sublayer()' instead." + logger.error(DeprecationWarning(msg)) + raise DeprecationWarning(msg) + + def upgrade_sublayer(self, + layer_name_pattern: Union[str, List[str]], + handle_func: Callable[[nn.Layer, str], nn.Layer] + ) -> Dict[str, nn.Layer]: + """use 'handle_func' to modify the sub-layer(s) specified by 'layer_name_pattern'. + + Args: + layer_name_pattern (Union[str, List[str]]): The name of layer to be modified by 'handle_func'. + handle_func (Callable[[nn.Layer, str], nn.Layer]): The function to modify target layer specified by 'layer_name_pattern'. The formal params are the layer(nn.Layer) and pattern(str) that is (a member of) layer_name_pattern (when layer_name_pattern is List type). And the return is the layer processed. + + Returns: + Dict[str, nn.Layer]: The key is the pattern and corresponding value is the result returned by 'handle_func()'. + + Examples: + + from paddle import nn + import paddleclas + + def rep_func(layer: nn.Layer, pattern: str): + new_layer = nn.Conv2D( + in_channels=layer._in_channels, + out_channels=layer._out_channels, + kernel_size=5, + padding=2 + ) + return new_layer + + net = paddleclas.MobileNetV1() + res = net.replace_sub(layer_name_pattern=["blocks[11].depthwise_conv.conv", "blocks[12].depthwise_conv.conv"], handle_func=rep_func) + print(res) + # {'blocks[11].depthwise_conv.conv': the corresponding new_layer, 'blocks[12].depthwise_conv.conv': the corresponding new_layer} + """ + + if not isinstance(layer_name_pattern, list): + layer_name_pattern = [layer_name_pattern] + + hit_layer_pattern_list = [] + for pattern in layer_name_pattern: + # parse pattern to find target layer and its parent + layer_list = parse_pattern_str(pattern=pattern, parent_layer=self) + if not layer_list: + continue + sub_layer_parent = layer_list[-2]["layer"] if len( + layer_list) > 1 else self + + sub_layer = layer_list[-1]["layer"] + sub_layer_name = layer_list[-1]["name"] + sub_layer_index = layer_list[-1]["index"] + + new_sub_layer = handle_func(sub_layer, pattern) + + if sub_layer_index: + getattr(sub_layer_parent, + sub_layer_name)[sub_layer_index] = new_sub_layer + else: + setattr(sub_layer_parent, sub_layer_name, new_sub_layer) + + hit_layer_pattern_list.append(pattern) + return hit_layer_pattern_list + + def stop_after(self, stop_layer_name: str) -> bool: + """stop forward and backward after 'stop_layer_name'. + + Args: + stop_layer_name (str): The name of layer that stop forward and backward after this layer. + + Returns: + bool: 'True' if successful, 'False' otherwise. + """ + + layer_list = parse_pattern_str(stop_layer_name, self) + if not layer_list: + return False + + parent_layer = self + for layer_dict in layer_list: + name, index = layer_dict["name"], layer_dict["index"] + if not set_identity(parent_layer, name, index): + msg = f"Failed to set the layers that after stop_layer_name('{stop_layer_name}') to IdentityLayer. The error layer's name is '{name}'." + logger.warning(msg) + return False + parent_layer = layer_dict["layer"] + + return True + + def update_res( + self, + return_patterns: Union[str, List[str]]) -> Dict[str, nn.Layer]: + """update the result(s) to be returned. + + Args: + return_patterns (Union[str, List[str]]): The name of layer to return output. + + Returns: + Dict[str, nn.Layer]: The pattern(str) and corresponding layer(nn.Layer) that have been set successfully. + """ + + # clear res_dict that could have been set + self.res_dict = {} + + class Handler(object): + def __init__(self, res_dict): + # res_dict is a reference + self.res_dict = res_dict + + def __call__(self, layer, pattern): + layer.res_dict = self.res_dict + layer.res_name = pattern + if hasattr(layer, "hook_remove_helper"): + layer.hook_remove_helper.remove() + layer.hook_remove_helper = layer.register_forward_post_hook( + save_sub_res_hook) + return layer + + handle_func = Handler(self.res_dict) + + hit_layer_pattern_list = self.upgrade_sublayer( + return_patterns, handle_func=handle_func) + + if hasattr(self, "hook_remove_helper"): + self.hook_remove_helper.remove() + self.hook_remove_helper = self.register_forward_post_hook( + self._return_dict_hook) + + return hit_layer_pattern_list + + +def save_sub_res_hook(layer, input, output): + layer.res_dict[layer.res_name] = output + + +def set_identity(parent_layer: nn.Layer, + layer_name: str, + layer_index: str=None) -> bool: + """set the layer specified by layer_name and layer_index to Indentity. + + Args: + parent_layer (nn.Layer): The parent layer of target layer specified by layer_name and layer_index. + layer_name (str): The name of target layer to be set to Indentity. + layer_index (str, optional): The index of target layer to be set to Indentity in parent_layer. Defaults to None. + + Returns: + bool: True if successfully, False otherwise. + """ + + stop_after = False + for sub_layer_name in parent_layer._sub_layers: + if stop_after: + parent_layer._sub_layers[sub_layer_name] = Identity() + continue + if sub_layer_name == layer_name: + stop_after = True + + if layer_index and stop_after: + stop_after = False + for sub_layer_index in parent_layer._sub_layers[ + layer_name]._sub_layers: + if stop_after: + parent_layer._sub_layers[layer_name][ + sub_layer_index] = Identity() + continue + if layer_index == sub_layer_index: + stop_after = True + + return stop_after + + +def parse_pattern_str(pattern: str, parent_layer: nn.Layer) -> Union[ + None, List[Dict[str, Union[nn.Layer, str, None]]]]: + """parse the string type pattern. + + Args: + pattern (str): The pattern to discribe layer. + parent_layer (nn.Layer): The root layer relative to the pattern. + + Returns: + Union[None, List[Dict[str, Union[nn.Layer, str, None]]]]: None if failed. If successfully, the members are layers parsed in order: + [ + {"layer": first layer, "name": first layer's name parsed, "index": first layer's index parsed if exist}, + {"layer": second layer, "name": second layer's name parsed, "index": second layer's index parsed if exist}, + ... + ] + """ + + pattern_list = pattern.split(".") + if not pattern_list: + msg = f"The pattern('{pattern}') is illegal. Please check and retry." + logger.warning(msg) + return None + + layer_list = [] + while len(pattern_list) > 0: + if '[' in pattern_list[0]: + target_layer_name = pattern_list[0].split('[')[0] + target_layer_index = pattern_list[0].split('[')[1].split(']')[0] + else: + target_layer_name = pattern_list[0] + target_layer_index = None + + target_layer = getattr(parent_layer, target_layer_name, None) + + if target_layer is None: + msg = f"Not found layer named('{target_layer_name}') specifed in pattern('{pattern}')." + logger.warning(msg) + return None + + if target_layer_index and target_layer: + if int(target_layer_index) < 0 or int(target_layer_index) >= len( + target_layer): + msg = f"Not found layer by index('{target_layer_index}') specifed in pattern('{pattern}'). The index should < {len(target_layer)} and > 0." + logger.warning(msg) + return None + + target_layer = target_layer[target_layer_index] + + layer_list.append({ + "layer": target_layer, + "name": target_layer_name, + "index": target_layer_index + }) + + pattern_list = pattern_list[1:] + parent_layer = target_layer + return layer_list diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__init__.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__init__.py new file mode 100644 index 0000000..1f837da --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__init__.py @@ -0,0 +1,6 @@ +from .resnet import ResNet18, ResNet34, ResNet50, ResNet101, ResNet152, ResNet18_vd, ResNet34_vd, ResNet50_vd, ResNet101_vd, ResNet152_vd +from .hrnet import HRNet_W18_C, HRNet_W30_C, HRNet_W32_C, HRNet_W40_C, HRNet_W44_C, HRNet_W48_C, HRNet_W64_C +from .mobilenet_v1 import MobileNetV1_x0_25, MobileNetV1_x0_5, MobileNetV1_x0_75, MobileNetV1 +from .mobilenet_v3 import MobileNetV3_small_x0_35, MobileNetV3_small_x0_5, MobileNetV3_small_x0_75, MobileNetV3_small_x1_0, MobileNetV3_small_x1_25, MobileNetV3_large_x0_35, MobileNetV3_large_x0_5, MobileNetV3_large_x0_75, MobileNetV3_large_x1_0, MobileNetV3_large_x1_25 +from .inception_v3 import InceptionV3 +from .vgg import VGG11, VGG13, VGG16, VGG19 diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..118b131 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/esnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/esnet.cpython-39.pyc new file mode 100644 index 0000000..135d838 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/esnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/hrnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/hrnet.cpython-39.pyc new file mode 100644 index 0000000..d1ee9ed Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/hrnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/inception_v3.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/inception_v3.cpython-39.pyc new file mode 100644 index 0000000..a330df1 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/inception_v3.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/mobilenet_v1.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/mobilenet_v1.cpython-39.pyc new file mode 100644 index 0000000..b5ec613 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/mobilenet_v1.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/mobilenet_v3.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/mobilenet_v3.cpython-39.pyc new file mode 100644 index 0000000..54ad9f4 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/mobilenet_v3.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/pp_lcnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/pp_lcnet.cpython-39.pyc new file mode 100644 index 0000000..8b2be9d Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/pp_lcnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/resnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/resnet.cpython-39.pyc new file mode 100644 index 0000000..3e2cd63 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/resnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/vgg.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/vgg.cpython-39.pyc new file mode 100644 index 0000000..0739199 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/legendary_models/__pycache__/vgg.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/esnet.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/esnet.py new file mode 100644 index 0000000..e05e0ce --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/esnet.py @@ -0,0 +1,369 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function +import math +import paddle +from paddle import ParamAttr, reshape, transpose, concat, split +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D +from paddle.nn.initializer import KaimingNormal +from paddle.regularizer import L2Decay + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ESNet_x0_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_25_pretrained.pdparams", + "ESNet_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_5_pretrained.pdparams", + "ESNet_x0_75": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_75_pretrained.pdparams", + "ESNet_x1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x1_0_pretrained.pdparams", +} + +MODEL_STAGES_PATTERN = {"ESNet": ["blocks[2]", "blocks[9]", "blocks[12]"]} + +__all__ = list(MODEL_URLS.keys()) + + +def channel_shuffle(x, groups): + batch_size, num_channels, height, width = x.shape[0:4] + channels_per_group = num_channels // groups + x = reshape( + x=x, shape=[batch_size, groups, channels_per_group, height, width]) + x = transpose(x=x, perm=[0, 2, 1, 3, 4]) + x = reshape(x=x, shape=[batch_size, num_channels, height, width]) + return x + + +def make_divisible(v, divisor=8, min_value=None): + if min_value is None: + min_value = divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + if new_v < 0.9 * v: + new_v += divisor + return new_v + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + groups=1, + if_act=True): + super().__init__() + self.conv = Conv2D( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=(kernel_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(initializer=KaimingNormal()), + bias_attr=False) + + self.bn = BatchNorm( + out_channels, + param_attr=ParamAttr(regularizer=L2Decay(0.0)), + bias_attr=ParamAttr(regularizer=L2Decay(0.0))) + self.if_act = if_act + self.hardswish = nn.Hardswish() + + def forward(self, x): + x = self.conv(x) + x = self.bn(x) + if self.if_act: + x = self.hardswish(x) + return x + + +class SEModule(TheseusLayer): + def __init__(self, channel, reduction=4): + super().__init__() + self.avg_pool = AdaptiveAvgPool2D(1) + self.conv1 = Conv2D( + in_channels=channel, + out_channels=channel // reduction, + kernel_size=1, + stride=1, + padding=0) + self.relu = nn.ReLU() + self.conv2 = Conv2D( + in_channels=channel // reduction, + out_channels=channel, + kernel_size=1, + stride=1, + padding=0) + self.hardsigmoid = nn.Hardsigmoid() + + def forward(self, x): + identity = x + x = self.avg_pool(x) + x = self.conv1(x) + x = self.relu(x) + x = self.conv2(x) + x = self.hardsigmoid(x) + x = paddle.multiply(x=identity, y=x) + return x + + +class ESBlock1(TheseusLayer): + def __init__(self, in_channels, out_channels): + super().__init__() + self.pw_1_1 = ConvBNLayer( + in_channels=in_channels // 2, + out_channels=out_channels // 2, + kernel_size=1, + stride=1) + self.dw_1 = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=3, + stride=1, + groups=out_channels // 2, + if_act=False) + self.se = SEModule(out_channels) + + self.pw_1_2 = ConvBNLayer( + in_channels=out_channels, + out_channels=out_channels // 2, + kernel_size=1, + stride=1) + + def forward(self, x): + x1, x2 = split( + x, num_or_sections=[x.shape[1] // 2, x.shape[1] // 2], axis=1) + x2 = self.pw_1_1(x2) + x3 = self.dw_1(x2) + x3 = concat([x2, x3], axis=1) + x3 = self.se(x3) + x3 = self.pw_1_2(x3) + x = concat([x1, x3], axis=1) + return channel_shuffle(x, 2) + + +class ESBlock2(TheseusLayer): + def __init__(self, in_channels, out_channels): + super().__init__() + + # branch1 + self.dw_1 = ConvBNLayer( + in_channels=in_channels, + out_channels=in_channels, + kernel_size=3, + stride=2, + groups=in_channels, + if_act=False) + self.pw_1 = ConvBNLayer( + in_channels=in_channels, + out_channels=out_channels // 2, + kernel_size=1, + stride=1) + # branch2 + self.pw_2_1 = ConvBNLayer( + in_channels=in_channels, + out_channels=out_channels // 2, + kernel_size=1) + self.dw_2 = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=3, + stride=2, + groups=out_channels // 2, + if_act=False) + self.se = SEModule(out_channels // 2) + self.pw_2_2 = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=1) + self.concat_dw = ConvBNLayer( + in_channels=out_channels, + out_channels=out_channels, + kernel_size=3, + groups=out_channels) + self.concat_pw = ConvBNLayer( + in_channels=out_channels, out_channels=out_channels, kernel_size=1) + + def forward(self, x): + x1 = self.dw_1(x) + x1 = self.pw_1(x1) + x2 = self.pw_2_1(x) + x2 = self.dw_2(x2) + x2 = self.se(x2) + x2 = self.pw_2_2(x2) + x = concat([x1, x2], axis=1) + x = self.concat_dw(x) + x = self.concat_pw(x) + return x + + +class ESNet(TheseusLayer): + def __init__(self, + stages_pattern, + class_num=1000, + scale=1.0, + dropout_prob=0.2, + class_expand=1280, + return_patterns=None, + return_stages=None): + super().__init__() + self.scale = scale + self.class_num = class_num + self.class_expand = class_expand + stage_repeats = [3, 7, 3] + stage_out_channels = [ + -1, 24, make_divisible(116 * scale), make_divisible(232 * scale), + make_divisible(464 * scale), 1024 + ] + + self.conv1 = ConvBNLayer( + in_channels=3, + out_channels=stage_out_channels[1], + kernel_size=3, + stride=2) + self.max_pool = MaxPool2D(kernel_size=3, stride=2, padding=1) + + block_list = [] + for stage_id, num_repeat in enumerate(stage_repeats): + for i in range(num_repeat): + if i == 0: + block = ESBlock2( + in_channels=stage_out_channels[stage_id + 1], + out_channels=stage_out_channels[stage_id + 2]) + else: + block = ESBlock1( + in_channels=stage_out_channels[stage_id + 2], + out_channels=stage_out_channels[stage_id + 2]) + block_list.append(block) + self.blocks = nn.Sequential(*block_list) + + self.conv2 = ConvBNLayer( + in_channels=stage_out_channels[-2], + out_channels=stage_out_channels[-1], + kernel_size=1) + + self.avg_pool = AdaptiveAvgPool2D(1) + + self.last_conv = Conv2D( + in_channels=stage_out_channels[-1], + out_channels=self.class_expand, + kernel_size=1, + stride=1, + padding=0, + bias_attr=False) + self.hardswish = nn.Hardswish() + self.dropout = Dropout(p=dropout_prob, mode="downscale_in_infer") + self.flatten = nn.Flatten(start_axis=1, stop_axis=-1) + self.fc = Linear(self.class_expand, self.class_num) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + x = self.conv1(x) + x = self.max_pool(x) + x = self.blocks(x) + x = self.conv2(x) + x = self.avg_pool(x) + x = self.last_conv(x) + x = self.hardswish(x) + x = self.dropout(x) + x = self.flatten(x) + x = self.fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ESNet_x0_25(pretrained=False, use_ssld=False, **kwargs): + """ + ESNet_x0_25 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ESNet_x0_25` model depends on args. + """ + model = ESNet( + scale=0.25, stages_pattern=MODEL_STAGES_PATTERN["ESNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ESNet_x0_25"], use_ssld) + return model + + +def ESNet_x0_5(pretrained=False, use_ssld=False, **kwargs): + """ + ESNet_x0_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ESNet_x0_5` model depends on args. + """ + model = ESNet( + scale=0.5, stages_pattern=MODEL_STAGES_PATTERN["ESNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ESNet_x0_5"], use_ssld) + return model + + +def ESNet_x0_75(pretrained=False, use_ssld=False, **kwargs): + """ + ESNet_x0_75 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ESNet_x0_75` model depends on args. + """ + model = ESNet( + scale=0.75, stages_pattern=MODEL_STAGES_PATTERN["ESNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ESNet_x0_75"], use_ssld) + return model + + +def ESNet_x1_0(pretrained=False, use_ssld=False, **kwargs): + """ + ESNet_x1_0 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ESNet_x1_0` model depends on args. + """ + model = ESNet( + scale=1.0, stages_pattern=MODEL_STAGES_PATTERN["ESNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ESNet_x1_0"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/hrnet.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/hrnet.py new file mode 100644 index 0000000..c3f7759 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/hrnet.py @@ -0,0 +1,794 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import math +import paddle +from paddle import nn +from paddle import ParamAttr +from paddle.nn.functional import upsample +from paddle.nn.initializer import Uniform + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer, Identity +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "HRNet_W18_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_pretrained.pdparams", + "HRNet_W30_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W30_C_pretrained.pdparams", + "HRNet_W32_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W32_C_pretrained.pdparams", + "HRNet_W40_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W40_C_pretrained.pdparams", + "HRNet_W44_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W44_C_pretrained.pdparams", + "HRNet_W48_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_pretrained.pdparams", + "HRNet_W64_C": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W64_C_pretrained.pdparams" +} + +MODEL_STAGES_PATTERN = {"HRNet": ["st4"]} + +__all__ = list(MODEL_URLS.keys()) + + +def _create_act(act): + if act == "hardswish": + return nn.Hardswish() + elif act == "relu": + return nn.ReLU() + elif act is None: + return Identity() + else: + raise RuntimeError( + "The activation function is not supported: {}".format(act)) + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act="relu"): + super().__init__() + + self.conv = nn.Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + bias_attr=False) + self.bn = nn.BatchNorm(num_filters, act=None) + self.act = _create_act(act) + + def forward(self, x): + x = self.conv(x) + x = self.bn(x) + x = self.act(x) + return x + + +class BottleneckBlock(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + has_se, + stride=1, + downsample=False): + super().__init__() + + self.has_se = has_se + self.downsample = downsample + + self.conv1 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act="relu") + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + stride=stride, + act="relu") + self.conv3 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 4, + filter_size=1, + act=None) + + if self.downsample: + self.conv_down = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 4, + filter_size=1, + act=None) + + if self.has_se: + self.se = SELayer( + num_channels=num_filters * 4, + num_filters=num_filters * 4, + reduction_ratio=16) + self.relu = nn.ReLU() + + def forward(self, x, res_dict=None): + residual = x + x = self.conv1(x) + x = self.conv2(x) + x = self.conv3(x) + if self.downsample: + residual = self.conv_down(residual) + if self.has_se: + x = self.se(x) + x = paddle.add(x=residual, y=x) + x = self.relu(x) + return x + + +class BasicBlock(nn.Layer): + def __init__(self, num_channels, num_filters, has_se=False): + super().__init__() + + self.has_se = has_se + + self.conv1 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=3, + stride=1, + act="relu") + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + stride=1, + act=None) + + if self.has_se: + self.se = SELayer( + num_channels=num_filters, + num_filters=num_filters, + reduction_ratio=16) + self.relu = nn.ReLU() + + def forward(self, x): + residual = x + x = self.conv1(x) + x = self.conv2(x) + + if self.has_se: + x = self.se(x) + + x = paddle.add(x=residual, y=x) + x = self.relu(x) + return x + + +class SELayer(TheseusLayer): + def __init__(self, num_channels, num_filters, reduction_ratio): + super().__init__() + + self.avg_pool = nn.AdaptiveAvgPool2D(1) + + self._num_channels = num_channels + + med_ch = int(num_channels / reduction_ratio) + stdv = 1.0 / math.sqrt(num_channels * 1.0) + self.fc_squeeze = nn.Linear( + num_channels, + med_ch, + weight_attr=ParamAttr(initializer=Uniform(-stdv, stdv))) + self.relu = nn.ReLU() + stdv = 1.0 / math.sqrt(med_ch * 1.0) + self.fc_excitation = nn.Linear( + med_ch, + num_filters, + weight_attr=ParamAttr(initializer=Uniform(-stdv, stdv))) + self.sigmoid = nn.Sigmoid() + + def forward(self, x, res_dict=None): + residual = x + x = self.avg_pool(x) + x = paddle.squeeze(x, axis=[2, 3]) + x = self.fc_squeeze(x) + x = self.relu(x) + x = self.fc_excitation(x) + x = self.sigmoid(x) + x = paddle.unsqueeze(x, axis=[2, 3]) + x = residual * x + return x + + +class Stage(TheseusLayer): + def __init__(self, num_modules, num_filters, has_se=False): + super().__init__() + + self._num_modules = num_modules + + self.stage_func_list = nn.LayerList() + for i in range(num_modules): + self.stage_func_list.append( + HighResolutionModule( + num_filters=num_filters, has_se=has_se)) + + def forward(self, x, res_dict=None): + x = x + for idx in range(self._num_modules): + x = self.stage_func_list[idx](x) + return x + + +class HighResolutionModule(TheseusLayer): + def __init__(self, num_filters, has_se=False): + super().__init__() + + self.basic_block_list = nn.LayerList() + + for i in range(len(num_filters)): + self.basic_block_list.append( + nn.Sequential(* [ + BasicBlock( + num_channels=num_filters[i], + num_filters=num_filters[i], + has_se=has_se) for j in range(4) + ])) + + self.fuse_func = FuseLayers( + in_channels=num_filters, out_channels=num_filters) + + def forward(self, x, res_dict=None): + out = [] + for idx, xi in enumerate(x): + basic_block_list = self.basic_block_list[idx] + for basic_block_func in basic_block_list: + xi = basic_block_func(xi) + out.append(xi) + out = self.fuse_func(out) + return out + + +class FuseLayers(TheseusLayer): + def __init__(self, in_channels, out_channels): + super().__init__() + + self._actual_ch = len(in_channels) + self._in_channels = in_channels + + self.residual_func_list = nn.LayerList() + self.relu = nn.ReLU() + for i in range(len(in_channels)): + for j in range(len(in_channels)): + if j > i: + self.residual_func_list.append( + ConvBNLayer( + num_channels=in_channels[j], + num_filters=out_channels[i], + filter_size=1, + stride=1, + act=None)) + elif j < i: + pre_num_filters = in_channels[j] + for k in range(i - j): + if k == i - j - 1: + self.residual_func_list.append( + ConvBNLayer( + num_channels=pre_num_filters, + num_filters=out_channels[i], + filter_size=3, + stride=2, + act=None)) + pre_num_filters = out_channels[i] + else: + self.residual_func_list.append( + ConvBNLayer( + num_channels=pre_num_filters, + num_filters=out_channels[j], + filter_size=3, + stride=2, + act="relu")) + pre_num_filters = out_channels[j] + + def forward(self, x, res_dict=None): + out = [] + residual_func_idx = 0 + for i in range(len(self._in_channels)): + residual = x[i] + for j in range(len(self._in_channels)): + if j > i: + xj = self.residual_func_list[residual_func_idx](x[j]) + residual_func_idx += 1 + + xj = upsample(xj, scale_factor=2**(j - i), mode="nearest") + residual = paddle.add(x=residual, y=xj) + elif j < i: + xj = x[j] + for k in range(i - j): + xj = self.residual_func_list[residual_func_idx](xj) + residual_func_idx += 1 + + residual = paddle.add(x=residual, y=xj) + + residual = self.relu(residual) + out.append(residual) + + return out + + +class LastClsOut(TheseusLayer): + def __init__(self, + num_channel_list, + has_se, + num_filters_list=[32, 64, 128, 256]): + super().__init__() + + self.func_list = nn.LayerList() + for idx in range(len(num_channel_list)): + self.func_list.append( + BottleneckBlock( + num_channels=num_channel_list[idx], + num_filters=num_filters_list[idx], + has_se=has_se, + downsample=True)) + + def forward(self, x, res_dict=None): + out = [] + for idx, xi in enumerate(x): + xi = self.func_list[idx](xi) + out.append(xi) + return out + + +class HRNet(TheseusLayer): + """ + HRNet + Args: + width: int=18. Base channel number of HRNet. + has_se: bool=False. If 'True', add se module to HRNet. + class_num: int=1000. Output num of last fc layer. + Returns: + model: nn.Layer. Specific HRNet model depends on args. + """ + + def __init__(self, + stages_pattern, + width=18, + has_se=False, + class_num=1000, + return_patterns=None, + return_stages=None): + super().__init__() + + self.width = width + self.has_se = has_se + self._class_num = class_num + + channels_2 = [self.width, self.width * 2] + channels_3 = [self.width, self.width * 2, self.width * 4] + channels_4 = [ + self.width, self.width * 2, self.width * 4, self.width * 8 + ] + + self.conv_layer1_1 = ConvBNLayer( + num_channels=3, + num_filters=64, + filter_size=3, + stride=2, + act="relu") + + self.conv_layer1_2 = ConvBNLayer( + num_channels=64, + num_filters=64, + filter_size=3, + stride=2, + act="relu") + + self.layer1 = nn.Sequential(* [ + BottleneckBlock( + num_channels=64 if i == 0 else 256, + num_filters=64, + has_se=has_se, + stride=1, + downsample=True if i == 0 else False) for i in range(4) + ]) + + self.conv_tr1_1 = ConvBNLayer( + num_channels=256, num_filters=width, filter_size=3) + self.conv_tr1_2 = ConvBNLayer( + num_channels=256, num_filters=width * 2, filter_size=3, stride=2) + + self.st2 = Stage( + num_modules=1, num_filters=channels_2, has_se=self.has_se) + + self.conv_tr2 = ConvBNLayer( + num_channels=width * 2, + num_filters=width * 4, + filter_size=3, + stride=2) + self.st3 = Stage( + num_modules=4, num_filters=channels_3, has_se=self.has_se) + + self.conv_tr3 = ConvBNLayer( + num_channels=width * 4, + num_filters=width * 8, + filter_size=3, + stride=2) + + self.st4 = Stage( + num_modules=3, num_filters=channels_4, has_se=self.has_se) + + # classification + num_filters_list = [32, 64, 128, 256] + self.last_cls = LastClsOut( + num_channel_list=channels_4, + has_se=self.has_se, + num_filters_list=num_filters_list) + + last_num_filters = [256, 512, 1024] + self.cls_head_conv_list = nn.LayerList() + for idx in range(3): + self.cls_head_conv_list.append( + ConvBNLayer( + num_channels=num_filters_list[idx] * 4, + num_filters=last_num_filters[idx], + filter_size=3, + stride=2)) + + self.conv_last = ConvBNLayer( + num_channels=1024, num_filters=2048, filter_size=1, stride=1) + + self.avg_pool = nn.AdaptiveAvgPool2D(1) + + stdv = 1.0 / math.sqrt(2048 * 1.0) + + self.fc = nn.Linear( + 2048, + class_num, + weight_attr=ParamAttr(initializer=Uniform(-stdv, stdv))) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + x = self.conv_layer1_1(x) + x = self.conv_layer1_2(x) + + x = self.layer1(x) + + tr1_1 = self.conv_tr1_1(x) + tr1_2 = self.conv_tr1_2(x) + x = self.st2([tr1_1, tr1_2]) + + tr2 = self.conv_tr2(x[-1]) + x.append(tr2) + x = self.st3(x) + + tr3 = self.conv_tr3(x[-1]) + x.append(tr3) + x = self.st4(x) + + x = self.last_cls(x) + + y = x[0] + for idx in range(3): + y = paddle.add(x[idx + 1], self.cls_head_conv_list[idx](y)) + + y = self.conv_last(y) + y = self.avg_pool(y) + y = paddle.reshape(y, shape=[-1, y.shape[1]]) + y = self.fc(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def HRNet_W18_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W18_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W18_C` model depends on args. + """ + model = HRNet( + width=18, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W18_C"], use_ssld) + return model + + +def HRNet_W30_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W30_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W30_C` model depends on args. + """ + model = HRNet( + width=30, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W30_C"], use_ssld) + return model + + +def HRNet_W32_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W32_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W32_C` model depends on args. + """ + model = HRNet( + width=32, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W32_C"], use_ssld) + return model + + +def HRNet_W40_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W40_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W40_C` model depends on args. + """ + model = HRNet( + width=40, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W40_C"], use_ssld) + return model + + +def HRNet_W44_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W44_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W44_C` model depends on args. + """ + model = HRNet( + width=44, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W44_C"], use_ssld) + return model + + +def HRNet_W48_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W48_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W48_C` model depends on args. + """ + model = HRNet( + width=48, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W48_C"], use_ssld) + return model + + +def HRNet_W60_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W60_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W60_C` model depends on args. + """ + model = HRNet( + width=60, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W60_C"], use_ssld) + return model + + +def HRNet_W64_C(pretrained=False, use_ssld=False, **kwargs): + """ + HRNet_W64_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `HRNet_W64_C` model depends on args. + """ + model = HRNet( + width=64, stages_pattern=MODEL_STAGES_PATTERN["HRNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HRNet_W64_C"], use_ssld) + return model + + +def SE_HRNet_W18_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W18_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W18_C` model depends on args. + """ + model = HRNet( + width=18, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W18_C"], use_ssld) + return model + + +def SE_HRNet_W30_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W30_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W30_C` model depends on args. + """ + model = HRNet( + width=30, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W30_C"], use_ssld) + return model + + +def SE_HRNet_W32_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W32_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W32_C` model depends on args. + """ + model = HRNet( + width=32, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W32_C"], use_ssld) + return model + + +def SE_HRNet_W40_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W40_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W40_C` model depends on args. + """ + model = HRNet( + width=40, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W40_C"], use_ssld) + return model + + +def SE_HRNet_W44_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W44_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W44_C` model depends on args. + """ + model = HRNet( + width=44, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W44_C"], use_ssld) + return model + + +def SE_HRNet_W48_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W48_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W48_C` model depends on args. + """ + model = HRNet( + width=48, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W48_C"], use_ssld) + return model + + +def SE_HRNet_W60_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W60_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W60_C` model depends on args. + """ + model = HRNet( + width=60, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W60_C"], use_ssld) + return model + + +def SE_HRNet_W64_C(pretrained=False, use_ssld=False, **kwargs): + """ + SE_HRNet_W64_C + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `SE_HRNet_W64_C` model depends on args. + """ + model = HRNet( + width=64, + stages_pattern=MODEL_STAGES_PATTERN["HRNet"], + has_se=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["SE_HRNet_W64_C"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/inception_v3.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/inception_v3.py new file mode 100644 index 0000000..5575f8c --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/inception_v3.py @@ -0,0 +1,557 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function +import math +import paddle +from paddle import ParamAttr +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "InceptionV3": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/InceptionV3_pretrained.pdparams" +} + +MODEL_STAGES_PATTERN = { + "InceptionV3": [ + "inception_block_list[2]", "inception_block_list[3]", + "inception_block_list[7]", "inception_block_list[8]", + "inception_block_list[10]" + ] +} + +__all__ = MODEL_URLS.keys() +''' +InceptionV3 config: dict. + key: inception blocks of InceptionV3. + values: conv num in different blocks. +''' +NET_CONFIG = { + "inception_a": [[192, 256, 288], [32, 64, 64]], + "inception_b": [288], + "inception_c": [[768, 768, 768, 768], [128, 160, 160, 192]], + "inception_d": [768], + "inception_e": [1280, 2048] +} + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + padding=0, + groups=1, + act="relu"): + super().__init__() + self.act = act + self.conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=groups, + bias_attr=False) + self.bn = BatchNorm(num_filters) + self.relu = nn.ReLU() + + def forward(self, x): + x = self.conv(x) + x = self.bn(x) + if self.act: + x = self.relu(x) + return x + + +class InceptionStem(TheseusLayer): + def __init__(self): + super().__init__() + self.conv_1a_3x3 = ConvBNLayer( + num_channels=3, + num_filters=32, + filter_size=3, + stride=2, + act="relu") + self.conv_2a_3x3 = ConvBNLayer( + num_channels=32, + num_filters=32, + filter_size=3, + stride=1, + act="relu") + self.conv_2b_3x3 = ConvBNLayer( + num_channels=32, + num_filters=64, + filter_size=3, + padding=1, + act="relu") + + self.max_pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + self.conv_3b_1x1 = ConvBNLayer( + num_channels=64, num_filters=80, filter_size=1, act="relu") + self.conv_4a_3x3 = ConvBNLayer( + num_channels=80, num_filters=192, filter_size=3, act="relu") + + def forward(self, x): + x = self.conv_1a_3x3(x) + x = self.conv_2a_3x3(x) + x = self.conv_2b_3x3(x) + x = self.max_pool(x) + x = self.conv_3b_1x1(x) + x = self.conv_4a_3x3(x) + x = self.max_pool(x) + return x + + +class InceptionA(TheseusLayer): + def __init__(self, num_channels, pool_features): + super().__init__() + self.branch1x1 = ConvBNLayer( + num_channels=num_channels, + num_filters=64, + filter_size=1, + act="relu") + self.branch5x5_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=48, + filter_size=1, + act="relu") + self.branch5x5_2 = ConvBNLayer( + num_channels=48, + num_filters=64, + filter_size=5, + padding=2, + act="relu") + + self.branch3x3dbl_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=64, + filter_size=1, + act="relu") + self.branch3x3dbl_2 = ConvBNLayer( + num_channels=64, + num_filters=96, + filter_size=3, + padding=1, + act="relu") + self.branch3x3dbl_3 = ConvBNLayer( + num_channels=96, + num_filters=96, + filter_size=3, + padding=1, + act="relu") + self.branch_pool = AvgPool2D( + kernel_size=3, stride=1, padding=1, exclusive=False) + self.branch_pool_conv = ConvBNLayer( + num_channels=num_channels, + num_filters=pool_features, + filter_size=1, + act="relu") + + def forward(self, x): + branch1x1 = self.branch1x1(x) + branch5x5 = self.branch5x5_1(x) + branch5x5 = self.branch5x5_2(branch5x5) + + branch3x3dbl = self.branch3x3dbl_1(x) + branch3x3dbl = self.branch3x3dbl_2(branch3x3dbl) + branch3x3dbl = self.branch3x3dbl_3(branch3x3dbl) + + branch_pool = self.branch_pool(x) + branch_pool = self.branch_pool_conv(branch_pool) + x = paddle.concat( + [branch1x1, branch5x5, branch3x3dbl, branch_pool], axis=1) + return x + + +class InceptionB(TheseusLayer): + def __init__(self, num_channels): + super().__init__() + self.branch3x3 = ConvBNLayer( + num_channels=num_channels, + num_filters=384, + filter_size=3, + stride=2, + act="relu") + self.branch3x3dbl_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=64, + filter_size=1, + act="relu") + self.branch3x3dbl_2 = ConvBNLayer( + num_channels=64, + num_filters=96, + filter_size=3, + padding=1, + act="relu") + self.branch3x3dbl_3 = ConvBNLayer( + num_channels=96, + num_filters=96, + filter_size=3, + stride=2, + act="relu") + self.branch_pool = MaxPool2D(kernel_size=3, stride=2) + + def forward(self, x): + branch3x3 = self.branch3x3(x) + + branch3x3dbl = self.branch3x3dbl_1(x) + branch3x3dbl = self.branch3x3dbl_2(branch3x3dbl) + branch3x3dbl = self.branch3x3dbl_3(branch3x3dbl) + + branch_pool = self.branch_pool(x) + + x = paddle.concat([branch3x3, branch3x3dbl, branch_pool], axis=1) + + return x + + +class InceptionC(TheseusLayer): + def __init__(self, num_channels, channels_7x7): + super().__init__() + self.branch1x1 = ConvBNLayer( + num_channels=num_channels, + num_filters=192, + filter_size=1, + act="relu") + + self.branch7x7_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=channels_7x7, + filter_size=1, + stride=1, + act="relu") + self.branch7x7_2 = ConvBNLayer( + num_channels=channels_7x7, + num_filters=channels_7x7, + filter_size=(1, 7), + stride=1, + padding=(0, 3), + act="relu") + self.branch7x7_3 = ConvBNLayer( + num_channels=channels_7x7, + num_filters=192, + filter_size=(7, 1), + stride=1, + padding=(3, 0), + act="relu") + + self.branch7x7dbl_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=channels_7x7, + filter_size=1, + act="relu") + self.branch7x7dbl_2 = ConvBNLayer( + num_channels=channels_7x7, + num_filters=channels_7x7, + filter_size=(7, 1), + padding=(3, 0), + act="relu") + self.branch7x7dbl_3 = ConvBNLayer( + num_channels=channels_7x7, + num_filters=channels_7x7, + filter_size=(1, 7), + padding=(0, 3), + act="relu") + self.branch7x7dbl_4 = ConvBNLayer( + num_channels=channels_7x7, + num_filters=channels_7x7, + filter_size=(7, 1), + padding=(3, 0), + act="relu") + self.branch7x7dbl_5 = ConvBNLayer( + num_channels=channels_7x7, + num_filters=192, + filter_size=(1, 7), + padding=(0, 3), + act="relu") + + self.branch_pool = AvgPool2D( + kernel_size=3, stride=1, padding=1, exclusive=False) + self.branch_pool_conv = ConvBNLayer( + num_channels=num_channels, + num_filters=192, + filter_size=1, + act="relu") + + def forward(self, x): + branch1x1 = self.branch1x1(x) + + branch7x7 = self.branch7x7_1(x) + branch7x7 = self.branch7x7_2(branch7x7) + branch7x7 = self.branch7x7_3(branch7x7) + + branch7x7dbl = self.branch7x7dbl_1(x) + branch7x7dbl = self.branch7x7dbl_2(branch7x7dbl) + branch7x7dbl = self.branch7x7dbl_3(branch7x7dbl) + branch7x7dbl = self.branch7x7dbl_4(branch7x7dbl) + branch7x7dbl = self.branch7x7dbl_5(branch7x7dbl) + + branch_pool = self.branch_pool(x) + branch_pool = self.branch_pool_conv(branch_pool) + + x = paddle.concat( + [branch1x1, branch7x7, branch7x7dbl, branch_pool], axis=1) + + return x + + +class InceptionD(TheseusLayer): + def __init__(self, num_channels): + super().__init__() + self.branch3x3_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=192, + filter_size=1, + act="relu") + self.branch3x3_2 = ConvBNLayer( + num_channels=192, + num_filters=320, + filter_size=3, + stride=2, + act="relu") + self.branch7x7x3_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=192, + filter_size=1, + act="relu") + self.branch7x7x3_2 = ConvBNLayer( + num_channels=192, + num_filters=192, + filter_size=(1, 7), + padding=(0, 3), + act="relu") + self.branch7x7x3_3 = ConvBNLayer( + num_channels=192, + num_filters=192, + filter_size=(7, 1), + padding=(3, 0), + act="relu") + self.branch7x7x3_4 = ConvBNLayer( + num_channels=192, + num_filters=192, + filter_size=3, + stride=2, + act="relu") + self.branch_pool = MaxPool2D(kernel_size=3, stride=2) + + def forward(self, x): + branch3x3 = self.branch3x3_1(x) + branch3x3 = self.branch3x3_2(branch3x3) + + branch7x7x3 = self.branch7x7x3_1(x) + branch7x7x3 = self.branch7x7x3_2(branch7x7x3) + branch7x7x3 = self.branch7x7x3_3(branch7x7x3) + branch7x7x3 = self.branch7x7x3_4(branch7x7x3) + + branch_pool = self.branch_pool(x) + + x = paddle.concat([branch3x3, branch7x7x3, branch_pool], axis=1) + return x + + +class InceptionE(TheseusLayer): + def __init__(self, num_channels): + super().__init__() + self.branch1x1 = ConvBNLayer( + num_channels=num_channels, + num_filters=320, + filter_size=1, + act="relu") + self.branch3x3_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=384, + filter_size=1, + act="relu") + self.branch3x3_2a = ConvBNLayer( + num_channels=384, + num_filters=384, + filter_size=(1, 3), + padding=(0, 1), + act="relu") + self.branch3x3_2b = ConvBNLayer( + num_channels=384, + num_filters=384, + filter_size=(3, 1), + padding=(1, 0), + act="relu") + + self.branch3x3dbl_1 = ConvBNLayer( + num_channels=num_channels, + num_filters=448, + filter_size=1, + act="relu") + self.branch3x3dbl_2 = ConvBNLayer( + num_channels=448, + num_filters=384, + filter_size=3, + padding=1, + act="relu") + self.branch3x3dbl_3a = ConvBNLayer( + num_channels=384, + num_filters=384, + filter_size=(1, 3), + padding=(0, 1), + act="relu") + self.branch3x3dbl_3b = ConvBNLayer( + num_channels=384, + num_filters=384, + filter_size=(3, 1), + padding=(1, 0), + act="relu") + self.branch_pool = AvgPool2D( + kernel_size=3, stride=1, padding=1, exclusive=False) + self.branch_pool_conv = ConvBNLayer( + num_channels=num_channels, + num_filters=192, + filter_size=1, + act="relu") + + def forward(self, x): + branch1x1 = self.branch1x1(x) + + branch3x3 = self.branch3x3_1(x) + branch3x3 = [ + self.branch3x3_2a(branch3x3), + self.branch3x3_2b(branch3x3), + ] + branch3x3 = paddle.concat(branch3x3, axis=1) + + branch3x3dbl = self.branch3x3dbl_1(x) + branch3x3dbl = self.branch3x3dbl_2(branch3x3dbl) + branch3x3dbl = [ + self.branch3x3dbl_3a(branch3x3dbl), + self.branch3x3dbl_3b(branch3x3dbl), + ] + branch3x3dbl = paddle.concat(branch3x3dbl, axis=1) + + branch_pool = self.branch_pool(x) + branch_pool = self.branch_pool_conv(branch_pool) + + x = paddle.concat( + [branch1x1, branch3x3, branch3x3dbl, branch_pool], axis=1) + return x + + +class Inception_V3(TheseusLayer): + """ + Inception_V3 + Args: + config: dict. config of Inception_V3. + class_num: int=1000. The number of classes. + pretrained: (True or False) or path of pretrained_model. Whether to load the pretrained model. + Returns: + model: nn.Layer. Specific Inception_V3 model depends on args. + """ + + def __init__(self, + config, + stages_pattern, + class_num=1000, + return_patterns=None, + return_stages=None): + super().__init__() + + self.inception_a_list = config["inception_a"] + self.inception_c_list = config["inception_c"] + self.inception_b_list = config["inception_b"] + self.inception_d_list = config["inception_d"] + self.inception_e_list = config["inception_e"] + + self.inception_stem = InceptionStem() + + self.inception_block_list = nn.LayerList() + for i in range(len(self.inception_a_list[0])): + inception_a = InceptionA(self.inception_a_list[0][i], + self.inception_a_list[1][i]) + self.inception_block_list.append(inception_a) + + for i in range(len(self.inception_b_list)): + inception_b = InceptionB(self.inception_b_list[i]) + self.inception_block_list.append(inception_b) + + for i in range(len(self.inception_c_list[0])): + inception_c = InceptionC(self.inception_c_list[0][i], + self.inception_c_list[1][i]) + self.inception_block_list.append(inception_c) + + for i in range(len(self.inception_d_list)): + inception_d = InceptionD(self.inception_d_list[i]) + self.inception_block_list.append(inception_d) + + for i in range(len(self.inception_e_list)): + inception_e = InceptionE(self.inception_e_list[i]) + self.inception_block_list.append(inception_e) + + self.avg_pool = AdaptiveAvgPool2D(1) + self.dropout = Dropout(p=0.2, mode="downscale_in_infer") + stdv = 1.0 / math.sqrt(2048 * 1.0) + self.fc = Linear( + 2048, + class_num, + weight_attr=ParamAttr(initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr()) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + x = self.inception_stem(x) + for inception_block in self.inception_block_list: + x = inception_block(x) + x = self.avg_pool(x) + x = paddle.reshape(x, shape=[-1, 2048]) + x = self.dropout(x) + x = self.fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def InceptionV3(pretrained=False, use_ssld=False, **kwargs): + """ + InceptionV3 + Args: + pretrained: bool=false or str. if `true` load pretrained parameters, `false` otherwise. + if str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `InceptionV3` model + """ + model = Inception_V3( + NET_CONFIG, + stages_pattern=MODEL_STAGES_PATTERN["InceptionV3"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["InceptionV3"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v1.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v1.py new file mode 100644 index 0000000..9767d69 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v1.py @@ -0,0 +1,257 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function + +from paddle import ParamAttr +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear, ReLU, Flatten +from paddle.nn import AdaptiveAvgPool2D +from paddle.nn.initializer import KaimingNormal + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "MobileNetV1_x0_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_25_pretrained.pdparams", + "MobileNetV1_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_5_pretrained.pdparams", + "MobileNetV1_x0_75": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_75_pretrained.pdparams", + "MobileNetV1": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_pretrained.pdparams" +} + +MODEL_STAGES_PATTERN = { + "MobileNetV1": ["blocks[0]", "blocks[2]", "blocks[4]", "blocks[10]"] +} + +__all__ = MODEL_URLS.keys() + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + num_channels, + filter_size, + num_filters, + stride, + padding, + num_groups=1): + super().__init__() + + self.conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=num_groups, + weight_attr=ParamAttr(initializer=KaimingNormal()), + bias_attr=False) + self.bn = BatchNorm(num_filters) + self.relu = ReLU() + + def forward(self, x): + x = self.conv(x) + x = self.bn(x) + x = self.relu(x) + return x + + +class DepthwiseSeparable(TheseusLayer): + def __init__(self, num_channels, num_filters1, num_filters2, num_groups, + stride, scale): + super().__init__() + + self.depthwise_conv = ConvBNLayer( + num_channels=num_channels, + num_filters=int(num_filters1 * scale), + filter_size=3, + stride=stride, + padding=1, + num_groups=int(num_groups * scale)) + + self.pointwise_conv = ConvBNLayer( + num_channels=int(num_filters1 * scale), + filter_size=1, + num_filters=int(num_filters2 * scale), + stride=1, + padding=0) + + def forward(self, x): + x = self.depthwise_conv(x) + x = self.pointwise_conv(x) + return x + + +class MobileNet(TheseusLayer): + """ + MobileNet + Args: + scale: float=1.0. The coefficient that controls the size of network parameters. + class_num: int=1000. The number of classes. + Returns: + model: nn.Layer. Specific MobileNet model depends on args. + """ + + def __init__(self, + stages_pattern, + scale=1.0, + class_num=1000, + return_patterns=None, + return_stages=None): + super().__init__() + self.scale = scale + + self.conv = ConvBNLayer( + num_channels=3, + filter_size=3, + num_filters=int(32 * scale), + stride=2, + padding=1) + + #num_channels, num_filters1, num_filters2, num_groups, stride + self.cfg = [[int(32 * scale), 32, 64, 32, 1], + [int(64 * scale), 64, 128, 64, 2], + [int(128 * scale), 128, 128, 128, 1], + [int(128 * scale), 128, 256, 128, 2], + [int(256 * scale), 256, 256, 256, 1], + [int(256 * scale), 256, 512, 256, 2], + [int(512 * scale), 512, 512, 512, 1], + [int(512 * scale), 512, 512, 512, 1], + [int(512 * scale), 512, 512, 512, 1], + [int(512 * scale), 512, 512, 512, 1], + [int(512 * scale), 512, 512, 512, 1], + [int(512 * scale), 512, 1024, 512, 2], + [int(1024 * scale), 1024, 1024, 1024, 1]] + + self.blocks = nn.Sequential(* [ + DepthwiseSeparable( + num_channels=params[0], + num_filters1=params[1], + num_filters2=params[2], + num_groups=params[3], + stride=params[4], + scale=scale) for params in self.cfg + ]) + + self.avg_pool = AdaptiveAvgPool2D(1) + self.flatten = Flatten(start_axis=1, stop_axis=-1) + + self.fc = Linear( + int(1024 * scale), + class_num, + weight_attr=ParamAttr(initializer=KaimingNormal())) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + x = self.conv(x) + x = self.blocks(x) + x = self.avg_pool(x) + x = self.flatten(x) + x = self.fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def MobileNetV1_x0_25(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV1_x0_25 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV1_x0_25` model depends on args. + """ + model = MobileNet( + scale=0.25, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV1"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV1_x0_25"], + use_ssld) + return model + + +def MobileNetV1_x0_5(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV1_x0_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV1_x0_5` model depends on args. + """ + model = MobileNet( + scale=0.5, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV1"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV1_x0_5"], + use_ssld) + return model + + +def MobileNetV1_x0_75(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV1_x0_75 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV1_x0_75` model depends on args. + """ + model = MobileNet( + scale=0.75, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV1"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV1_x0_75"], + use_ssld) + return model + + +def MobileNetV1(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV1 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV1` model depends on args. + """ + model = MobileNet( + scale=1.0, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV1"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV1"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v3.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v3.py new file mode 100644 index 0000000..836c54c --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v3.py @@ -0,0 +1,586 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function + +import paddle +import paddle.nn as nn +from paddle import ParamAttr +from paddle.nn import AdaptiveAvgPool2D, BatchNorm, Conv2D, Dropout, Linear +from paddle.regularizer import L2Decay +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "MobileNetV3_small_x0_35": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_pretrained.pdparams", + "MobileNetV3_small_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_5_pretrained.pdparams", + "MobileNetV3_small_x0_75": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_75_pretrained.pdparams", + "MobileNetV3_small_x1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_pretrained.pdparams", + "MobileNetV3_small_x1_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_25_pretrained.pdparams", + "MobileNetV3_large_x0_35": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_35_pretrained.pdparams", + "MobileNetV3_large_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_5_pretrained.pdparams", + "MobileNetV3_large_x0_75": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_75_pretrained.pdparams", + "MobileNetV3_large_x1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_pretrained.pdparams", + "MobileNetV3_large_x1_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_25_pretrained.pdparams", +} + +MODEL_STAGES_PATTERN = { + "MobileNetV3_small": + ["blocks[0]", "blocks[2]", "blocks[7]", "blocks[10]"], + "MobileNetV3_large": + ["blocks[0]", "blocks[2]", "blocks[5]", "blocks[11]", "blocks[14]"] +} + +__all__ = MODEL_URLS.keys() + +# "large", "small" is just for MobinetV3_large, MobileNetV3_small respectively. +# The type of "large" or "small" config is a list. Each element(list) represents a depthwise block, which is composed of k, exp, se, act, s. +# k: kernel_size +# exp: middle channel number in depthwise block +# c: output channel number in depthwise block +# se: whether to use SE block +# act: which activation to use +# s: stride in depthwise block +NET_CONFIG = { + "large": [ + # k, exp, c, se, act, s + [3, 16, 16, False, "relu", 1], + [3, 64, 24, False, "relu", 2], + [3, 72, 24, False, "relu", 1], + [5, 72, 40, True, "relu", 2], + [5, 120, 40, True, "relu", 1], + [5, 120, 40, True, "relu", 1], + [3, 240, 80, False, "hardswish", 2], + [3, 200, 80, False, "hardswish", 1], + [3, 184, 80, False, "hardswish", 1], + [3, 184, 80, False, "hardswish", 1], + [3, 480, 112, True, "hardswish", 1], + [3, 672, 112, True, "hardswish", 1], + [5, 672, 160, True, "hardswish", 2], + [5, 960, 160, True, "hardswish", 1], + [5, 960, 160, True, "hardswish", 1], + ], + "small": [ + # k, exp, c, se, act, s + [3, 16, 16, True, "relu", 2], + [3, 72, 24, False, "relu", 2], + [3, 88, 24, False, "relu", 1], + [5, 96, 40, True, "hardswish", 2], + [5, 240, 40, True, "hardswish", 1], + [5, 240, 40, True, "hardswish", 1], + [5, 120, 48, True, "hardswish", 1], + [5, 144, 48, True, "hardswish", 1], + [5, 288, 96, True, "hardswish", 2], + [5, 576, 96, True, "hardswish", 1], + [5, 576, 96, True, "hardswish", 1], + ] +} +# first conv output channel number in MobileNetV3 +STEM_CONV_NUMBER = 16 +# last second conv output channel for "small" +LAST_SECOND_CONV_SMALL = 576 +# last second conv output channel for "large" +LAST_SECOND_CONV_LARGE = 960 +# last conv output channel number for "large" and "small" +LAST_CONV = 1280 + + +def _make_divisible(v, divisor=8, min_value=None): + if min_value is None: + min_value = divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + if new_v < 0.9 * v: + new_v += divisor + return new_v + + +def _create_act(act): + if act == "hardswish": + return nn.Hardswish() + elif act == "relu": + return nn.ReLU() + elif act is None: + return None + else: + raise RuntimeError( + "The activation function is not supported: {}".format(act)) + + +class MobileNetV3(TheseusLayer): + """ + MobileNetV3 + Args: + config: list. MobileNetV3 depthwise blocks config. + scale: float=1.0. The coefficient that controls the size of network parameters. + class_num: int=1000. The number of classes. + inplanes: int=16. The output channel number of first convolution layer. + class_squeeze: int=960. The output channel number of penultimate convolution layer. + class_expand: int=1280. The output channel number of last convolution layer. + dropout_prob: float=0.2. Probability of setting units to zero. + Returns: + model: nn.Layer. Specific MobileNetV3 model depends on args. + """ + + def __init__(self, + config, + stages_pattern, + scale=1.0, + class_num=1000, + inplanes=STEM_CONV_NUMBER, + class_squeeze=LAST_SECOND_CONV_LARGE, + class_expand=LAST_CONV, + dropout_prob=0.2, + return_patterns=None, + return_stages=None): + super().__init__() + + self.cfg = config + self.scale = scale + self.inplanes = inplanes + self.class_squeeze = class_squeeze + self.class_expand = class_expand + self.class_num = class_num + + self.conv = ConvBNLayer( + in_c=3, + out_c=_make_divisible(self.inplanes * self.scale), + filter_size=3, + stride=2, + padding=1, + num_groups=1, + if_act=True, + act="hardswish") + + self.blocks = nn.Sequential(* [ + ResidualUnit( + in_c=_make_divisible(self.inplanes * self.scale if i == 0 else + self.cfg[i - 1][2] * self.scale), + mid_c=_make_divisible(self.scale * exp), + out_c=_make_divisible(self.scale * c), + filter_size=k, + stride=s, + use_se=se, + act=act) for i, (k, exp, c, se, act, s) in enumerate(self.cfg) + ]) + + self.last_second_conv = ConvBNLayer( + in_c=_make_divisible(self.cfg[-1][2] * self.scale), + out_c=_make_divisible(self.scale * self.class_squeeze), + filter_size=1, + stride=1, + padding=0, + num_groups=1, + if_act=True, + act="hardswish") + + self.avg_pool = AdaptiveAvgPool2D(1) + + self.last_conv = Conv2D( + in_channels=_make_divisible(self.scale * self.class_squeeze), + out_channels=self.class_expand, + kernel_size=1, + stride=1, + padding=0, + bias_attr=False) + + self.hardswish = nn.Hardswish() + if dropout_prob is not None: + self.dropout = Dropout(p=dropout_prob, mode="downscale_in_infer") + else: + self.dropout = None + self.flatten = nn.Flatten(start_axis=1, stop_axis=-1) + + self.fc = Linear(self.class_expand, class_num) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + x = self.conv(x) + x = self.blocks(x) + x = self.last_second_conv(x) + x = self.avg_pool(x) + x = self.last_conv(x) + x = self.hardswish(x) + if self.dropout is not None: + x = self.dropout(x) + x = self.flatten(x) + x = self.fc(x) + + return x + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + in_c, + out_c, + filter_size, + stride, + padding, + num_groups=1, + if_act=True, + act=None): + super().__init__() + + self.conv = Conv2D( + in_channels=in_c, + out_channels=out_c, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=num_groups, + bias_attr=False) + self.bn = BatchNorm( + num_channels=out_c, + act=None, + param_attr=ParamAttr(regularizer=L2Decay(0.0)), + bias_attr=ParamAttr(regularizer=L2Decay(0.0))) + self.if_act = if_act + self.act = _create_act(act) + + def forward(self, x): + x = self.conv(x) + x = self.bn(x) + if self.if_act: + x = self.act(x) + return x + + +class ResidualUnit(TheseusLayer): + def __init__(self, + in_c, + mid_c, + out_c, + filter_size, + stride, + use_se, + act=None): + super().__init__() + self.if_shortcut = stride == 1 and in_c == out_c + self.if_se = use_se + + self.expand_conv = ConvBNLayer( + in_c=in_c, + out_c=mid_c, + filter_size=1, + stride=1, + padding=0, + if_act=True, + act=act) + self.bottleneck_conv = ConvBNLayer( + in_c=mid_c, + out_c=mid_c, + filter_size=filter_size, + stride=stride, + padding=int((filter_size - 1) // 2), + num_groups=mid_c, + if_act=True, + act=act) + if self.if_se: + self.mid_se = SEModule(mid_c) + self.linear_conv = ConvBNLayer( + in_c=mid_c, + out_c=out_c, + filter_size=1, + stride=1, + padding=0, + if_act=False, + act=None) + + def forward(self, x): + identity = x + x = self.expand_conv(x) + x = self.bottleneck_conv(x) + if self.if_se: + x = self.mid_se(x) + x = self.linear_conv(x) + if self.if_shortcut: + x = paddle.add(identity, x) + return x + + +# nn.Hardsigmoid can't transfer "slope" and "offset" in nn.functional.hardsigmoid +class Hardsigmoid(TheseusLayer): + def __init__(self, slope=0.2, offset=0.5): + super().__init__() + self.slope = slope + self.offset = offset + + def forward(self, x): + return nn.functional.hardsigmoid( + x, slope=self.slope, offset=self.offset) + + +class SEModule(TheseusLayer): + def __init__(self, channel, reduction=4): + super().__init__() + self.avg_pool = AdaptiveAvgPool2D(1) + self.conv1 = Conv2D( + in_channels=channel, + out_channels=channel // reduction, + kernel_size=1, + stride=1, + padding=0) + self.relu = nn.ReLU() + self.conv2 = Conv2D( + in_channels=channel // reduction, + out_channels=channel, + kernel_size=1, + stride=1, + padding=0) + self.hardsigmoid = Hardsigmoid(slope=0.2, offset=0.5) + + def forward(self, x): + identity = x + x = self.avg_pool(x) + x = self.conv1(x) + x = self.relu(x) + x = self.conv2(x) + x = self.hardsigmoid(x) + return paddle.multiply(x=identity, y=x) + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def MobileNetV3_small_x0_35(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_small_x0_35 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x0_35` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["small"], + scale=0.35, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_small"], + class_squeeze=LAST_SECOND_CONV_SMALL, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_small_x0_35"], + use_ssld) + return model + + +def MobileNetV3_small_x0_5(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_small_x0_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x0_5` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["small"], + scale=0.5, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_small"], + class_squeeze=LAST_SECOND_CONV_SMALL, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_small_x0_5"], + use_ssld) + return model + + +def MobileNetV3_small_x0_75(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_small_x0_75 + Args: + pretrained: bool=false or str. if `true` load pretrained parameters, `false` otherwise. + if str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x0_75` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["small"], + scale=0.75, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_small"], + class_squeeze=LAST_SECOND_CONV_SMALL, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_small_x0_75"], + use_ssld) + return model + + +def MobileNetV3_small_x1_0(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_small_x1_0 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x1_0` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["small"], + scale=1.0, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_small"], + class_squeeze=LAST_SECOND_CONV_SMALL, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_small_x1_0"], + use_ssld) + return model + + +def MobileNetV3_small_x1_25(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_small_x1_25 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_small_x1_25` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["small"], + scale=1.25, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_small"], + class_squeeze=LAST_SECOND_CONV_SMALL, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_small_x1_25"], + use_ssld) + return model + + +def MobileNetV3_large_x0_35(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_large_x0_35 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x0_35` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["large"], + scale=0.35, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_small"], + class_squeeze=LAST_SECOND_CONV_LARGE, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_large_x0_35"], + use_ssld) + return model + + +def MobileNetV3_large_x0_5(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_large_x0_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x0_5` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["large"], + scale=0.5, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_large"], + class_squeeze=LAST_SECOND_CONV_LARGE, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_large_x0_5"], + use_ssld) + return model + + +def MobileNetV3_large_x0_75(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_large_x0_75 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x0_75` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["large"], + scale=0.75, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_large"], + class_squeeze=LAST_SECOND_CONV_LARGE, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_large_x0_75"], + use_ssld) + return model + + +def MobileNetV3_large_x1_0(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_large_x1_0 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x1_0` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["large"], + scale=1.0, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_large"], + class_squeeze=LAST_SECOND_CONV_LARGE, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_large_x1_0"], + use_ssld) + return model + + +def MobileNetV3_large_x1_25(pretrained=False, use_ssld=False, **kwargs): + """ + MobileNetV3_large_x1_25 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `MobileNetV3_large_x1_25` model depends on args. + """ + model = MobileNetV3( + config=NET_CONFIG["large"], + scale=1.25, + stages_pattern=MODEL_STAGES_PATTERN["MobileNetV3_large"], + class_squeeze=LAST_SECOND_CONV_LARGE, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["MobileNetV3_large_x1_25"], + use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/pp_lcnet.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/pp_lcnet.py new file mode 100644 index 0000000..4017462 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/pp_lcnet.py @@ -0,0 +1,419 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function + +import paddle +import paddle.nn as nn +from paddle import ParamAttr +from paddle.nn import AdaptiveAvgPool2D, BatchNorm, Conv2D, Dropout, Linear +from paddle.regularizer import L2Decay +from paddle.nn.initializer import KaimingNormal +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "PPLCNet_x0_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_25_pretrained.pdparams", + "PPLCNet_x0_35": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_35_pretrained.pdparams", + "PPLCNet_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_pretrained.pdparams", + "PPLCNet_x0_75": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_75_pretrained.pdparams", + "PPLCNet_x1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_pretrained.pdparams", + "PPLCNet_x1_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_5_pretrained.pdparams", + "PPLCNet_x2_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_0_pretrained.pdparams", + "PPLCNet_x2_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_pretrained.pdparams" +} + +MODEL_STAGES_PATTERN = { + "PPLCNet": ["blocks2", "blocks3", "blocks4", "blocks5", "blocks6"] +} + +__all__ = list(MODEL_URLS.keys()) + +# Each element(list) represents a depthwise block, which is composed of k, in_c, out_c, s, use_se. +# k: kernel_size +# in_c: input channel number in depthwise block +# out_c: output channel number in depthwise block +# s: stride in depthwise block +# use_se: whether to use SE block + +NET_CONFIG = { + "blocks2": + #k, in_c, out_c, s, use_se + [[3, 16, 32, 1, False]], + "blocks3": [[3, 32, 64, 2, False], [3, 64, 64, 1, False]], + "blocks4": [[3, 64, 128, 2, False], [3, 128, 128, 1, False]], + "blocks5": [[3, 128, 256, 2, False], [5, 256, 256, 1, False], + [5, 256, 256, 1, False], [5, 256, 256, 1, False], + [5, 256, 256, 1, False], [5, 256, 256, 1, False]], + "blocks6": [[5, 256, 512, 2, True], [5, 512, 512, 1, True]] +} + + +def make_divisible(v, divisor=8, min_value=None): + if min_value is None: + min_value = divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + if new_v < 0.9 * v: + new_v += divisor + return new_v + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + num_channels, + filter_size, + num_filters, + stride, + num_groups=1): + super().__init__() + + self.conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=num_groups, + weight_attr=ParamAttr(initializer=KaimingNormal()), + bias_attr=False) + + self.bn = BatchNorm( + num_filters, + param_attr=ParamAttr(regularizer=L2Decay(0.0)), + bias_attr=ParamAttr(regularizer=L2Decay(0.0))) + self.hardswish = nn.Hardswish() + + def forward(self, x): + x = self.conv(x) + x = self.bn(x) + x = self.hardswish(x) + return x + + +class DepthwiseSeparable(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + stride, + dw_size=3, + use_se=False): + super().__init__() + self.use_se = use_se + self.dw_conv = ConvBNLayer( + num_channels=num_channels, + num_filters=num_channels, + filter_size=dw_size, + stride=stride, + num_groups=num_channels) + if use_se: + self.se = SEModule(num_channels) + self.pw_conv = ConvBNLayer( + num_channels=num_channels, + filter_size=1, + num_filters=num_filters, + stride=1) + + def forward(self, x): + x = self.dw_conv(x) + if self.use_se: + x = self.se(x) + x = self.pw_conv(x) + return x + + +class SEModule(TheseusLayer): + def __init__(self, channel, reduction=4): + super().__init__() + self.avg_pool = AdaptiveAvgPool2D(1) + self.conv1 = Conv2D( + in_channels=channel, + out_channels=channel // reduction, + kernel_size=1, + stride=1, + padding=0) + self.relu = nn.ReLU() + self.conv2 = Conv2D( + in_channels=channel // reduction, + out_channels=channel, + kernel_size=1, + stride=1, + padding=0) + self.hardsigmoid = nn.Hardsigmoid() + + def forward(self, x): + identity = x + x = self.avg_pool(x) + x = self.conv1(x) + x = self.relu(x) + x = self.conv2(x) + x = self.hardsigmoid(x) + x = paddle.multiply(x=identity, y=x) + return x + + +class PPLCNet(TheseusLayer): + def __init__(self, + stages_pattern, + scale=1.0, + class_num=1000, + dropout_prob=0.2, + class_expand=1280, + return_patterns=None, + return_stages=None): + super().__init__() + self.scale = scale + self.class_expand = class_expand + + self.conv1 = ConvBNLayer( + num_channels=3, + filter_size=3, + num_filters=make_divisible(16 * scale), + stride=2) + + self.blocks2 = nn.Sequential(* [ + DepthwiseSeparable( + num_channels=make_divisible(in_c * scale), + num_filters=make_divisible(out_c * scale), + dw_size=k, + stride=s, + use_se=se) + for i, (k, in_c, out_c, s, se) in enumerate(NET_CONFIG["blocks2"]) + ]) + + self.blocks3 = nn.Sequential(* [ + DepthwiseSeparable( + num_channels=make_divisible(in_c * scale), + num_filters=make_divisible(out_c * scale), + dw_size=k, + stride=s, + use_se=se) + for i, (k, in_c, out_c, s, se) in enumerate(NET_CONFIG["blocks3"]) + ]) + + self.blocks4 = nn.Sequential(* [ + DepthwiseSeparable( + num_channels=make_divisible(in_c * scale), + num_filters=make_divisible(out_c * scale), + dw_size=k, + stride=s, + use_se=se) + for i, (k, in_c, out_c, s, se) in enumerate(NET_CONFIG["blocks4"]) + ]) + + self.blocks5 = nn.Sequential(* [ + DepthwiseSeparable( + num_channels=make_divisible(in_c * scale), + num_filters=make_divisible(out_c * scale), + dw_size=k, + stride=s, + use_se=se) + for i, (k, in_c, out_c, s, se) in enumerate(NET_CONFIG["blocks5"]) + ]) + + self.blocks6 = nn.Sequential(* [ + DepthwiseSeparable( + num_channels=make_divisible(in_c * scale), + num_filters=make_divisible(out_c * scale), + dw_size=k, + stride=s, + use_se=se) + for i, (k, in_c, out_c, s, se) in enumerate(NET_CONFIG["blocks6"]) + ]) + + self.avg_pool = AdaptiveAvgPool2D(1) + + self.last_conv = Conv2D( + in_channels=make_divisible(NET_CONFIG["blocks6"][-1][2] * scale), + out_channels=self.class_expand, + kernel_size=1, + stride=1, + padding=0, + bias_attr=False) + + self.hardswish = nn.Hardswish() + self.dropout = Dropout(p=dropout_prob, mode="downscale_in_infer") + self.flatten = nn.Flatten(start_axis=1, stop_axis=-1) + + self.fc = Linear(self.class_expand, class_num) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + x = self.conv1(x) + + x = self.blocks2(x) + x = self.blocks3(x) + x = self.blocks4(x) + x = self.blocks5(x) + x = self.blocks6(x) + + x = self.avg_pool(x) + x = self.last_conv(x) + x = self.hardswish(x) + x = self.dropout(x) + x = self.flatten(x) + x = self.fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def PPLCNet_x0_25(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x0_25 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x0_25` model depends on args. + """ + model = PPLCNet( + scale=0.25, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x0_25"], use_ssld) + return model + + +def PPLCNet_x0_35(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x0_35 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x0_35` model depends on args. + """ + model = PPLCNet( + scale=0.35, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x0_35"], use_ssld) + return model + + +def PPLCNet_x0_5(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x0_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x0_5` model depends on args. + """ + model = PPLCNet( + scale=0.5, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x0_5"], use_ssld) + return model + + +def PPLCNet_x0_75(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x0_75 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x0_75` model depends on args. + """ + model = PPLCNet( + scale=0.75, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x0_75"], use_ssld) + return model + + +def PPLCNet_x1_0(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x1_0 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x1_0` model depends on args. + """ + model = PPLCNet( + scale=1.0, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x1_0"], use_ssld) + return model + + +def PPLCNet_x1_5(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x1_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x1_5` model depends on args. + """ + model = PPLCNet( + scale=1.5, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x1_5"], use_ssld) + return model + + +def PPLCNet_x2_0(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x2_0 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x2_0` model depends on args. + """ + model = PPLCNet( + scale=2.0, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x2_0"], use_ssld) + return model + + +def PPLCNet_x2_5(pretrained=False, use_ssld=False, **kwargs): + """ + PPLCNet_x2_5 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `PPLCNet_x2_5` model depends on args. + """ + model = PPLCNet( + scale=2.5, stages_pattern=MODEL_STAGES_PATTERN["PPLCNet"], **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["PPLCNet_x2_5"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/resnet.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/resnet.py new file mode 100644 index 0000000..74c5c5f --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/resnet.py @@ -0,0 +1,591 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNet18": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_pretrained.pdparams", + "ResNet18_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_vd_pretrained.pdparams", + "ResNet34": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_pretrained.pdparams", + "ResNet34_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_pretrained.pdparams", + "ResNet50": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_pretrained.pdparams", + "ResNet50_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams", + "ResNet101": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_pretrained.pdparams", + "ResNet101_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_pretrained.pdparams", + "ResNet152": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_pretrained.pdparams", + "ResNet152_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_vd_pretrained.pdparams", + "ResNet200_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet200_vd_pretrained.pdparams", +} + +MODEL_STAGES_PATTERN = { + "ResNet18": ["blocks[1]", "blocks[3]", "blocks[5]", "blocks[7]"], + "ResNet34": ["blocks[2]", "blocks[6]", "blocks[12]", "blocks[15]"], + "ResNet50": ["blocks[2]", "blocks[6]", "blocks[12]", "blocks[15]"], + "ResNet101": ["blocks[2]", "blocks[6]", "blocks[29]", "blocks[32]"], + "ResNet152": ["blocks[2]", "blocks[10]", "blocks[46]", "blocks[49]"], + "ResNet200": ["blocks[2]", "blocks[14]", "blocks[62]", "blocks[65]"] +} + +__all__ = MODEL_URLS.keys() +''' +ResNet config: dict. + key: depth of ResNet. + values: config's dict of specific model. + keys: + block_type: Two different blocks in ResNet, BasicBlock and BottleneckBlock are optional. + block_depth: The number of blocks in different stages in ResNet. + num_channels: The number of channels to enter the next stage. +''' +NET_CONFIG = { + "18": { + "block_type": "BasicBlock", + "block_depth": [2, 2, 2, 2], + "num_channels": [64, 64, 128, 256] + }, + "34": { + "block_type": "BasicBlock", + "block_depth": [3, 4, 6, 3], + "num_channels": [64, 64, 128, 256] + }, + "50": { + "block_type": "BottleneckBlock", + "block_depth": [3, 4, 6, 3], + "num_channels": [64, 256, 512, 1024] + }, + "101": { + "block_type": "BottleneckBlock", + "block_depth": [3, 4, 23, 3], + "num_channels": [64, 256, 512, 1024] + }, + "152": { + "block_type": "BottleneckBlock", + "block_depth": [3, 8, 36, 3], + "num_channels": [64, 256, 512, 1024] + }, + "200": { + "block_type": "BottleneckBlock", + "block_depth": [3, 12, 48, 3], + "num_channels": [64, 256, 512, 1024] + }, +} + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + is_vd_mode=False, + act=None, + lr_mult=1.0, + data_format="NCHW"): + super().__init__() + self.is_vd_mode = is_vd_mode + self.act = act + self.avg_pool = AvgPool2D( + kernel_size=2, stride=2, padding=0, ceil_mode=True) + self.conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(learning_rate=lr_mult), + bias_attr=False, + data_format=data_format) + self.bn = BatchNorm( + num_filters, + param_attr=ParamAttr(learning_rate=lr_mult), + bias_attr=ParamAttr(learning_rate=lr_mult), + data_layout=data_format) + self.relu = nn.ReLU() + + def forward(self, x): + if self.is_vd_mode: + x = self.avg_pool(x) + x = self.conv(x) + x = self.bn(x) + if self.act: + x = self.relu(x) + return x + + +class BottleneckBlock(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + if_first=False, + lr_mult=1.0, + data_format="NCHW"): + super().__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act="relu", + lr_mult=lr_mult, + data_format=data_format) + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + stride=stride, + act="relu", + lr_mult=lr_mult, + data_format=data_format) + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 4, + filter_size=1, + act=None, + lr_mult=lr_mult, + data_format=data_format) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 4, + filter_size=1, + stride=stride if if_first else 1, + is_vd_mode=False if if_first else True, + lr_mult=lr_mult, + data_format=data_format) + self.relu = nn.ReLU() + self.shortcut = shortcut + + def forward(self, x): + identity = x + x = self.conv0(x) + x = self.conv1(x) + x = self.conv2(x) + + if self.shortcut: + short = identity + else: + short = self.short(identity) + x = paddle.add(x=x, y=short) + x = self.relu(x) + return x + + +class BasicBlock(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + if_first=False, + lr_mult=1.0, + data_format="NCHW"): + super().__init__() + + self.stride = stride + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=3, + stride=stride, + act="relu", + lr_mult=lr_mult, + data_format=data_format) + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + act=None, + lr_mult=lr_mult, + data_format=data_format) + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + stride=stride if if_first else 1, + is_vd_mode=False if if_first else True, + lr_mult=lr_mult, + data_format=data_format) + self.shortcut = shortcut + self.relu = nn.ReLU() + + def forward(self, x): + identity = x + x = self.conv0(x) + x = self.conv1(x) + if self.shortcut: + short = identity + else: + short = self.short(identity) + x = paddle.add(x=x, y=short) + x = self.relu(x) + return x + + +class ResNet(TheseusLayer): + """ + ResNet + Args: + config: dict. config of ResNet. + version: str="vb". Different version of ResNet, version vd can perform better. + class_num: int=1000. The number of classes. + lr_mult_list: list. Control the learning rate of different stages. + Returns: + model: nn.Layer. Specific ResNet model depends on args. + """ + + def __init__(self, + config, + stages_pattern, + version="vb", + class_num=1000, + lr_mult_list=[1.0, 1.0, 1.0, 1.0, 1.0], + data_format="NCHW", + input_image_channel=3, + return_patterns=None, + return_stages=None): + super().__init__() + + self.cfg = config + self.lr_mult_list = lr_mult_list + self.is_vd_mode = version == "vd" + self.class_num = class_num + self.num_filters = [64, 128, 256, 512] + self.block_depth = self.cfg["block_depth"] + self.block_type = self.cfg["block_type"] + self.num_channels = self.cfg["num_channels"] + self.channels_mult = 1 if self.num_channels[-1] == 256 else 4 + + assert isinstance(self.lr_mult_list, ( + list, tuple + )), "lr_mult_list should be in (list, tuple) but got {}".format( + type(self.lr_mult_list)) + assert len(self.lr_mult_list + ) == 5, "lr_mult_list length should be 5 but got {}".format( + len(self.lr_mult_list)) + + self.stem_cfg = { + #num_channels, num_filters, filter_size, stride + "vb": [[input_image_channel, 64, 7, 2]], + "vd": + [[input_image_channel, 32, 3, 2], [32, 32, 3, 1], [32, 64, 3, 1]] + } + + self.stem = nn.Sequential(* [ + ConvBNLayer( + num_channels=in_c, + num_filters=out_c, + filter_size=k, + stride=s, + act="relu", + lr_mult=self.lr_mult_list[0], + data_format=data_format) + for in_c, out_c, k, s in self.stem_cfg[version] + ]) + + self.max_pool = MaxPool2D( + kernel_size=3, stride=2, padding=1, data_format=data_format) + block_list = [] + for block_idx in range(len(self.block_depth)): + shortcut = False + for i in range(self.block_depth[block_idx]): + block_list.append(globals()[self.block_type]( + num_channels=self.num_channels[block_idx] if i == 0 else + self.num_filters[block_idx] * self.channels_mult, + num_filters=self.num_filters[block_idx], + stride=2 if i == 0 and block_idx != 0 else 1, + shortcut=shortcut, + if_first=block_idx == i == 0 if version == "vd" else True, + lr_mult=self.lr_mult_list[block_idx + 1], + data_format=data_format)) + shortcut = True + self.blocks = nn.Sequential(*block_list) + + self.avg_pool = AdaptiveAvgPool2D(1, data_format=data_format) + self.flatten = nn.Flatten() + self.avg_pool_channels = self.num_channels[-1] * 2 + stdv = 1.0 / math.sqrt(self.avg_pool_channels * 1.0) + self.fc = Linear( + self.avg_pool_channels, + self.class_num, + weight_attr=ParamAttr(initializer=Uniform(-stdv, stdv))) + + self.data_format = data_format + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, x): + with paddle.static.amp.fp16_guard(): + if self.data_format == "NHWC": + x = paddle.transpose(x, [0, 2, 3, 1]) + x.stop_gradient = True + x = self.stem(x) + x = self.max_pool(x) + x = self.blocks(x) + x = self.avg_pool(x) + x = self.flatten(x) + x = self.fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNet18(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet18 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet18` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["18"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet18"], + version="vb", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet18"], use_ssld) + return model + + +def ResNet18_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet18_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet18_vd` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["18"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet18"], + version="vd", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet18_vd"], use_ssld) + return model + + +def ResNet34(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet34 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet34` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["34"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet34"], + version="vb", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet34"], use_ssld) + return model + + +def ResNet34_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet34_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet34_vd` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["34"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet34"], + version="vd", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet34_vd"], use_ssld) + return model + + +def ResNet50(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet50 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet50` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["50"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet50"], + version="vb", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet50"], use_ssld) + return model + + +def ResNet50_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet50_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet50_vd` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["50"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet50"], + version="vd", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet50_vd"], use_ssld) + return model + + +def ResNet101(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet101 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet101` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["101"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet101"], + version="vb", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet101"], use_ssld) + return model + + +def ResNet101_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet101_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet101_vd` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["101"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet101"], + version="vd", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet101_vd"], use_ssld) + return model + + +def ResNet152(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet152 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet152` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["152"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet152"], + version="vb", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet152"], use_ssld) + return model + + +def ResNet152_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet152_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet152_vd` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["152"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet152"], + version="vd", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet152_vd"], use_ssld) + return model + + +def ResNet200_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet200_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet200_vd` model depends on args. + """ + model = ResNet( + config=NET_CONFIG["200"], + stages_pattern=MODEL_STAGES_PATTERN["ResNet200"], + version="vd", + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet200_vd"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/legendary_models/vgg.py b/src/PaddleClas/ppcls/arch/backbone/legendary_models/vgg.py new file mode 100644 index 0000000..74d5cfa --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/legendary_models/vgg.py @@ -0,0 +1,259 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function + +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import MaxPool2D + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "VGG11": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG11_pretrained.pdparams", + "VGG13": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG13_pretrained.pdparams", + "VGG16": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG16_pretrained.pdparams", + "VGG19": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG19_pretrained.pdparams", +} + +MODEL_STAGES_PATTERN = { + "VGG": [ + "conv_block_1", "conv_block_2", "conv_block_3", "conv_block_4", + "conv_block_5" + ] +} + +__all__ = MODEL_URLS.keys() + +# VGG config +# key: VGG network depth +# value: conv num in different blocks +NET_CONFIG = { + 11: [1, 1, 2, 2, 2], + 13: [2, 2, 2, 2, 2], + 16: [2, 2, 3, 3, 3], + 19: [2, 2, 4, 4, 4] +} + + +class ConvBlock(TheseusLayer): + def __init__(self, input_channels, output_channels, groups): + super().__init__() + + self.groups = groups + self.conv1 = Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=3, + stride=1, + padding=1, + bias_attr=False) + if groups == 2 or groups == 3 or groups == 4: + self.conv2 = Conv2D( + in_channels=output_channels, + out_channels=output_channels, + kernel_size=3, + stride=1, + padding=1, + bias_attr=False) + if groups == 3 or groups == 4: + self.conv3 = Conv2D( + in_channels=output_channels, + out_channels=output_channels, + kernel_size=3, + stride=1, + padding=1, + bias_attr=False) + if groups == 4: + self.conv4 = Conv2D( + in_channels=output_channels, + out_channels=output_channels, + kernel_size=3, + stride=1, + padding=1, + bias_attr=False) + + self.max_pool = MaxPool2D(kernel_size=2, stride=2, padding=0) + self.relu = nn.ReLU() + + def forward(self, inputs): + x = self.conv1(inputs) + x = self.relu(x) + if self.groups == 2 or self.groups == 3 or self.groups == 4: + x = self.conv2(x) + x = self.relu(x) + if self.groups == 3 or self.groups == 4: + x = self.conv3(x) + x = self.relu(x) + if self.groups == 4: + x = self.conv4(x) + x = self.relu(x) + x = self.max_pool(x) + return x + + +class VGGNet(TheseusLayer): + """ + VGGNet + Args: + config: list. VGGNet config. + stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False` + class_num: int=1000. The number of classes. + Returns: + model: nn.Layer. Specific VGG model depends on args. + """ + + def __init__(self, + config, + stages_pattern, + stop_grad_layers=0, + class_num=1000, + return_patterns=None, + return_stages=None): + super().__init__() + + self.stop_grad_layers = stop_grad_layers + + self.conv_block_1 = ConvBlock(3, 64, config[0]) + self.conv_block_2 = ConvBlock(64, 128, config[1]) + self.conv_block_3 = ConvBlock(128, 256, config[2]) + self.conv_block_4 = ConvBlock(256, 512, config[3]) + self.conv_block_5 = ConvBlock(512, 512, config[4]) + + self.relu = nn.ReLU() + self.flatten = nn.Flatten(start_axis=1, stop_axis=-1) + + for idx, block in enumerate([ + self.conv_block_1, self.conv_block_2, self.conv_block_3, + self.conv_block_4, self.conv_block_5 + ]): + if self.stop_grad_layers >= idx + 1: + for param in block.parameters(): + param.trainable = False + + self.drop = Dropout(p=0.5, mode="downscale_in_infer") + self.fc1 = Linear(7 * 7 * 512, 4096) + self.fc2 = Linear(4096, 4096) + self.fc3 = Linear(4096, class_num) + + super().init_res( + stages_pattern, + return_patterns=return_patterns, + return_stages=return_stages) + + def forward(self, inputs): + x = self.conv_block_1(inputs) + x = self.conv_block_2(x) + x = self.conv_block_3(x) + x = self.conv_block_4(x) + x = self.conv_block_5(x) + x = self.flatten(x) + x = self.fc1(x) + x = self.relu(x) + x = self.drop(x) + x = self.fc2(x) + x = self.relu(x) + x = self.drop(x) + x = self.fc3(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def VGG11(pretrained=False, use_ssld=False, **kwargs): + """ + VGG11 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `VGG11` model depends on args. + """ + model = VGGNet( + config=NET_CONFIG[11], + stages_pattern=MODEL_STAGES_PATTERN["VGG"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["VGG11"], use_ssld) + return model + + +def VGG13(pretrained=False, use_ssld=False, **kwargs): + """ + VGG13 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `VGG13` model depends on args. + """ + model = VGGNet( + config=NET_CONFIG[13], + stages_pattern=MODEL_STAGES_PATTERN["VGG"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["VGG13"], use_ssld) + return model + + +def VGG16(pretrained=False, use_ssld=False, **kwargs): + """ + VGG16 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `VGG16` model depends on args. + """ + model = VGGNet( + config=NET_CONFIG[16], + stages_pattern=MODEL_STAGES_PATTERN["VGG"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["VGG16"], use_ssld) + return model + + +def VGG19(pretrained=False, use_ssld=False, **kwargs): + """ + VGG19 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `VGG19` model depends on args. + """ + model = VGGNet( + config=NET_CONFIG[19], + stages_pattern=MODEL_STAGES_PATTERN["VGG"], + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["VGG19"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__init__.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..63bd229 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/alexnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/alexnet.cpython-39.pyc new file mode 100644 index 0000000..5b84c99 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/alexnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/cspnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/cspnet.cpython-39.pyc new file mode 100644 index 0000000..1d996fd Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/cspnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/darknet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/darknet.cpython-39.pyc new file mode 100644 index 0000000..8323836 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/darknet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/densenet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/densenet.cpython-39.pyc new file mode 100644 index 0000000..7d8af7d Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/densenet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/distilled_vision_transformer.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/distilled_vision_transformer.cpython-39.pyc new file mode 100644 index 0000000..64f04d6 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/distilled_vision_transformer.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/dla.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/dla.cpython-39.pyc new file mode 100644 index 0000000..bb12bae Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/dla.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/dpn.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/dpn.cpython-39.pyc new file mode 100644 index 0000000..73eb68d Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/dpn.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/efficientnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/efficientnet.cpython-39.pyc new file mode 100644 index 0000000..ef17886 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/efficientnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/ghostnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/ghostnet.cpython-39.pyc new file mode 100644 index 0000000..2f81872 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/ghostnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/googlenet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/googlenet.cpython-39.pyc new file mode 100644 index 0000000..0326e19 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/googlenet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/gvt.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/gvt.cpython-39.pyc new file mode 100644 index 0000000..54b1d13 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/gvt.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/hardnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/hardnet.cpython-39.pyc new file mode 100644 index 0000000..5919e76 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/hardnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/inception_v4.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/inception_v4.cpython-39.pyc new file mode 100644 index 0000000..8cb333a Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/inception_v4.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/levit.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/levit.cpython-39.pyc new file mode 100644 index 0000000..bd35a6b Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/levit.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/mixnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/mixnet.cpython-39.pyc new file mode 100644 index 0000000..0607c52 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/mixnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/mobilenet_v2.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/mobilenet_v2.cpython-39.pyc new file mode 100644 index 0000000..b6b5e94 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/mobilenet_v2.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/pvt_v2.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/pvt_v2.cpython-39.pyc new file mode 100644 index 0000000..391ff9b Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/pvt_v2.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/rednet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/rednet.cpython-39.pyc new file mode 100644 index 0000000..019481a Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/rednet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/regnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/regnet.cpython-39.pyc new file mode 100644 index 0000000..7a1a00a Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/regnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/repvgg.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/repvgg.cpython-39.pyc new file mode 100644 index 0000000..f518d93 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/repvgg.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/res2net.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/res2net.cpython-39.pyc new file mode 100644 index 0000000..edb79ea Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/res2net.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/res2net_vd.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/res2net_vd.cpython-39.pyc new file mode 100644 index 0000000..d7f0f91 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/res2net_vd.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnest.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnest.cpython-39.pyc new file mode 100644 index 0000000..1466a3f Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnest.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnet_vc.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnet_vc.cpython-39.pyc new file mode 100644 index 0000000..144f063 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnet_vc.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext.cpython-39.pyc new file mode 100644 index 0000000..9d915d8 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext101_wsl.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext101_wsl.cpython-39.pyc new file mode 100644 index 0000000..85ad8fa Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext101_wsl.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext_vd.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext_vd.cpython-39.pyc new file mode 100644 index 0000000..6a76923 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/resnext_vd.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/rexnet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/rexnet.cpython-39.pyc new file mode 100644 index 0000000..7f387c4 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/rexnet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnet_vd.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnet_vd.cpython-39.pyc new file mode 100644 index 0000000..25a8437 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnet_vd.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnext.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnext.cpython-39.pyc new file mode 100644 index 0000000..ba0e14c Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnext.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnext_vd.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnext_vd.cpython-39.pyc new file mode 100644 index 0000000..fb46ef4 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/se_resnext_vd.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/shufflenet_v2.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/shufflenet_v2.cpython-39.pyc new file mode 100644 index 0000000..f27b598 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/shufflenet_v2.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/squeezenet.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/squeezenet.cpython-39.pyc new file mode 100644 index 0000000..bdd7361 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/squeezenet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/swin_transformer.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/swin_transformer.cpython-39.pyc new file mode 100644 index 0000000..29ace62 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/swin_transformer.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/tnt.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/tnt.cpython-39.pyc new file mode 100644 index 0000000..c340279 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/tnt.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/vision_transformer.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/vision_transformer.cpython-39.pyc new file mode 100644 index 0000000..f0ac12a Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/vision_transformer.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/xception.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/xception.cpython-39.pyc new file mode 100644 index 0000000..336dfb4 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/xception.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/xception_deeplab.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/xception_deeplab.cpython-39.pyc new file mode 100644 index 0000000..f73991b Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/model_zoo/__pycache__/xception_deeplab.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/alexnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/alexnet.py new file mode 100644 index 0000000..b44901a --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/alexnet.py @@ -0,0 +1,168 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout, ReLU +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "AlexNet": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/AlexNet_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvPoolLayer(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter_size, + stride, + padding, + stdv, + groups=1, + act=None, + name=None): + super(ConvPoolLayer, self).__init__() + + self.relu = ReLU() if act == "relu" else None + + self._conv = Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=groups, + weight_attr=ParamAttr( + name=name + "_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr( + name=name + "_offset", initializer=Uniform(-stdv, stdv))) + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + + def forward(self, inputs): + x = self._conv(inputs) + if self.relu is not None: + x = self.relu(x) + x = self._pool(x) + return x + + +class AlexNetDY(nn.Layer): + def __init__(self, class_num=1000): + super(AlexNetDY, self).__init__() + + stdv = 1.0 / math.sqrt(3 * 11 * 11) + self._conv1 = ConvPoolLayer( + 3, 64, 11, 4, 2, stdv, act="relu", name="conv1") + stdv = 1.0 / math.sqrt(64 * 5 * 5) + self._conv2 = ConvPoolLayer( + 64, 192, 5, 1, 2, stdv, act="relu", name="conv2") + stdv = 1.0 / math.sqrt(192 * 3 * 3) + self._conv3 = Conv2D( + 192, + 384, + 3, + stride=1, + padding=1, + weight_attr=ParamAttr( + name="conv3_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr( + name="conv3_offset", initializer=Uniform(-stdv, stdv))) + stdv = 1.0 / math.sqrt(384 * 3 * 3) + self._conv4 = Conv2D( + 384, + 256, + 3, + stride=1, + padding=1, + weight_attr=ParamAttr( + name="conv4_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr( + name="conv4_offset", initializer=Uniform(-stdv, stdv))) + stdv = 1.0 / math.sqrt(256 * 3 * 3) + self._conv5 = ConvPoolLayer( + 256, 256, 3, 1, 1, stdv, act="relu", name="conv5") + stdv = 1.0 / math.sqrt(256 * 6 * 6) + + self._drop1 = Dropout(p=0.5, mode="downscale_in_infer") + self._fc6 = Linear( + in_features=256 * 6 * 6, + out_features=4096, + weight_attr=ParamAttr( + name="fc6_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr( + name="fc6_offset", initializer=Uniform(-stdv, stdv))) + + self._drop2 = Dropout(p=0.5, mode="downscale_in_infer") + self._fc7 = Linear( + in_features=4096, + out_features=4096, + weight_attr=ParamAttr( + name="fc7_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr( + name="fc7_offset", initializer=Uniform(-stdv, stdv))) + self._fc8 = Linear( + in_features=4096, + out_features=class_num, + weight_attr=ParamAttr( + name="fc8_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr( + name="fc8_offset", initializer=Uniform(-stdv, stdv))) + + def forward(self, inputs): + x = self._conv1(inputs) + x = self._conv2(x) + x = self._conv3(x) + x = F.relu(x) + x = self._conv4(x) + x = F.relu(x) + x = self._conv5(x) + x = paddle.flatten(x, start_axis=1, stop_axis=-1) + x = self._drop1(x) + x = self._fc6(x) + x = F.relu(x) + x = self._drop2(x) + x = self._fc7(x) + x = F.relu(x) + x = self._fc8(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def AlexNet(pretrained=False, use_ssld=False, **kwargs): + model = AlexNetDY(**kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["AlexNet"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/cspnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/cspnet.py new file mode 100644 index 0000000..ab5021f --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/cspnet.py @@ -0,0 +1,376 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was heavily based on https://github.com/rwightman/pytorch-image-models + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F +from paddle import ParamAttr + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "CSPDarkNet53": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSPDarkNet53_pretrained.pdparams" +} + +MODEL_CFGS = { + "CSPDarkNet53": dict( + stem=dict( + out_chs=32, kernel_size=3, stride=1, pool=''), + stage=dict( + out_chs=(64, 128, 256, 512, 1024), + depth=(1, 2, 8, 8, 4), + stride=(2, ) * 5, + exp_ratio=(2., ) + (1., ) * 4, + bottle_ratio=(0.5, ) + (1.0, ) * 4, + block_ratio=(1., ) + (0.5, ) * 4, + down_growth=True, )) +} + +__all__ = ['CSPDarkNet53' + ] # model_registry will add each entrypoint fn to this + + +class ConvBnAct(nn.Layer): + def __init__(self, + input_channels, + output_channels, + kernel_size=1, + stride=1, + padding=None, + dilation=1, + groups=1, + act_layer=nn.LeakyReLU, + norm_layer=nn.BatchNorm2D): + super().__init__() + if padding is None: + padding = (kernel_size - 1) // 2 + self.conv = nn.Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + weight_attr=ParamAttr(), + bias_attr=False) + + self.bn = norm_layer(num_features=output_channels) + self.act = act_layer() + + def forward(self, inputs): + x = self.conv(inputs) + x = self.bn(x) + if self.act is not None: + x = self.act(x) + return x + + +def create_stem(in_chans=3, + out_chs=32, + kernel_size=3, + stride=2, + pool='', + act_layer=None, + norm_layer=None): + stem = nn.Sequential() + if not isinstance(out_chs, (tuple, list)): + out_chs = [out_chs] + assert len(out_chs) + in_c = in_chans + for i, out_c in enumerate(out_chs): + conv_name = f'conv{i + 1}' + stem.add_sublayer( + conv_name, + ConvBnAct( + in_c, + out_c, + kernel_size, + stride=stride if i == 0 else 1, + act_layer=act_layer, + norm_layer=norm_layer)) + in_c = out_c + last_conv = conv_name + if pool: + stem.add_sublayer( + 'pool', nn.MaxPool2D( + kernel_size=3, stride=2, padding=1)) + return stem, dict( + num_chs=in_c, reduction=stride, module='.'.join(['stem', last_conv])) + + +class DarkBlock(nn.Layer): + def __init__(self, + in_chs, + out_chs, + dilation=1, + bottle_ratio=0.5, + groups=1, + act_layer=nn.ReLU, + norm_layer=nn.BatchNorm2D, + attn_layer=None, + drop_block=None): + super(DarkBlock, self).__init__() + mid_chs = int(round(out_chs * bottle_ratio)) + ckwargs = dict(act_layer=act_layer, norm_layer=norm_layer) + self.conv1 = ConvBnAct(in_chs, mid_chs, kernel_size=1, **ckwargs) + self.conv2 = ConvBnAct( + mid_chs, + out_chs, + kernel_size=3, + dilation=dilation, + groups=groups, + **ckwargs) + + def forward(self, x): + shortcut = x + x = self.conv1(x) + x = self.conv2(x) + x = x + shortcut + return x + + +class CrossStage(nn.Layer): + def __init__(self, + in_chs, + out_chs, + stride, + dilation, + depth, + block_ratio=1., + bottle_ratio=1., + exp_ratio=1., + groups=1, + first_dilation=None, + down_growth=False, + cross_linear=False, + block_dpr=None, + block_fn=DarkBlock, + **block_kwargs): + super(CrossStage, self).__init__() + first_dilation = first_dilation or dilation + down_chs = out_chs if down_growth else in_chs + exp_chs = int(round(out_chs * exp_ratio)) + block_out_chs = int(round(out_chs * block_ratio)) + conv_kwargs = dict( + act_layer=block_kwargs.get('act_layer'), + norm_layer=block_kwargs.get('norm_layer')) + + if stride != 1 or first_dilation != dilation: + self.conv_down = ConvBnAct( + in_chs, + down_chs, + kernel_size=3, + stride=stride, + dilation=first_dilation, + groups=groups, + **conv_kwargs) + prev_chs = down_chs + else: + self.conv_down = None + prev_chs = in_chs + + self.conv_exp = ConvBnAct( + prev_chs, exp_chs, kernel_size=1, **conv_kwargs) + prev_chs = exp_chs // 2 # output of conv_exp is always split in two + + self.blocks = nn.Sequential() + for i in range(depth): + self.blocks.add_sublayer( + str(i), + block_fn(prev_chs, block_out_chs, dilation, bottle_ratio, + groups, **block_kwargs)) + prev_chs = block_out_chs + + # transition convs + self.conv_transition_b = ConvBnAct( + prev_chs, exp_chs // 2, kernel_size=1, **conv_kwargs) + self.conv_transition = ConvBnAct( + exp_chs, out_chs, kernel_size=1, **conv_kwargs) + + def forward(self, x): + if self.conv_down is not None: + x = self.conv_down(x) + x = self.conv_exp(x) + split = x.shape[1] // 2 + xs, xb = x[:, :split], x[:, split:] + xb = self.blocks(xb) + xb = self.conv_transition_b(xb) + out = self.conv_transition(paddle.concat([xs, xb], axis=1)) + return out + + +class DarkStage(nn.Layer): + def __init__(self, + in_chs, + out_chs, + stride, + dilation, + depth, + block_ratio=1., + bottle_ratio=1., + groups=1, + first_dilation=None, + block_fn=DarkBlock, + block_dpr=None, + **block_kwargs): + super().__init__() + first_dilation = first_dilation or dilation + + self.conv_down = ConvBnAct( + in_chs, + out_chs, + kernel_size=3, + stride=stride, + dilation=first_dilation, + groups=groups, + act_layer=block_kwargs.get('act_layer'), + norm_layer=block_kwargs.get('norm_layer')) + + prev_chs = out_chs + block_out_chs = int(round(out_chs * block_ratio)) + self.blocks = nn.Sequential() + for i in range(depth): + self.blocks.add_sublayer( + str(i), + block_fn(prev_chs, block_out_chs, dilation, bottle_ratio, + groups, **block_kwargs)) + prev_chs = block_out_chs + + def forward(self, x): + x = self.conv_down(x) + x = self.blocks(x) + return x + + +def _cfg_to_stage_args(cfg, curr_stride=2, output_stride=32): + # get per stage args for stage and containing blocks, calculate strides to meet target output_stride + num_stages = len(cfg['depth']) + if 'groups' not in cfg: + cfg['groups'] = (1, ) * num_stages + if 'down_growth' in cfg and not isinstance(cfg['down_growth'], + (list, tuple)): + cfg['down_growth'] = (cfg['down_growth'], ) * num_stages + stage_strides = [] + stage_dilations = [] + stage_first_dilations = [] + dilation = 1 + for cfg_stride in cfg['stride']: + stage_first_dilations.append(dilation) + if curr_stride >= output_stride: + dilation *= cfg_stride + stride = 1 + else: + stride = cfg_stride + curr_stride *= stride + stage_strides.append(stride) + stage_dilations.append(dilation) + cfg['stride'] = stage_strides + cfg['dilation'] = stage_dilations + cfg['first_dilation'] = stage_first_dilations + stage_args = [ + dict(zip(cfg.keys(), values)) for values in zip(*cfg.values()) + ] + return stage_args + + +class CSPNet(nn.Layer): + def __init__(self, + cfg, + in_chans=3, + class_num=1000, + output_stride=32, + global_pool='avg', + drop_rate=0., + act_layer=nn.LeakyReLU, + norm_layer=nn.BatchNorm2D, + zero_init_last_bn=True, + stage_fn=CrossStage, + block_fn=DarkBlock): + super().__init__() + self.class_num = class_num + self.drop_rate = drop_rate + assert output_stride in (8, 16, 32) + layer_args = dict(act_layer=act_layer, norm_layer=norm_layer) + + # Construct the stem + self.stem, stem_feat_info = create_stem(in_chans, **cfg['stem'], + **layer_args) + self.feature_info = [stem_feat_info] + prev_chs = stem_feat_info['num_chs'] + curr_stride = stem_feat_info[ + 'reduction'] # reduction does not include pool + if cfg['stem']['pool']: + curr_stride *= 2 + + # Construct the stages + per_stage_args = _cfg_to_stage_args( + cfg['stage'], curr_stride=curr_stride, output_stride=output_stride) + self.stages = nn.LayerList() + for i, sa in enumerate(per_stage_args): + self.stages.add_sublayer( + str(i), + stage_fn( + prev_chs, **sa, **layer_args, block_fn=block_fn)) + prev_chs = sa['out_chs'] + curr_stride *= sa['stride'] + self.feature_info += [ + dict( + num_chs=prev_chs, + reduction=curr_stride, + module=f'stages.{i}') + ] + + # Construct the head + self.num_features = prev_chs + + self.pool = nn.AdaptiveAvgPool2D(1) + self.flatten = nn.Flatten(1) + self.fc = nn.Linear( + prev_chs, + class_num, + weight_attr=ParamAttr(), + bias_attr=ParamAttr()) + + def forward(self, x): + x = self.stem(x) + for stage in self.stages: + x = stage(x) + x = self.pool(x) + x = self.flatten(x) + x = self.fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def CSPDarkNet53(pretrained=False, use_ssld=False, **kwargs): + model = CSPNet(MODEL_CFGS["CSPDarkNet53"], block_fn=DarkBlock, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["CSPDarkNet53"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/darknet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/darknet.py new file mode 100644 index 0000000..75aafd8 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/darknet.py @@ -0,0 +1,197 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "DarkNet53": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DarkNet53_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter_size, + stride, + padding, + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=filter_size, + stride=stride, + padding=padding, + weight_attr=ParamAttr(name=name + ".conv.weights"), + bias_attr=False) + + bn_name = name + ".bn" + self._bn = BatchNorm( + num_channels=output_channels, + act="relu", + param_attr=ParamAttr(name=bn_name + ".scale"), + bias_attr=ParamAttr(name=bn_name + ".offset"), + moving_mean_name=bn_name + ".mean", + moving_variance_name=bn_name + ".var") + + def forward(self, inputs): + x = self._conv(inputs) + x = self._bn(x) + return x + + +class BasicBlock(nn.Layer): + def __init__(self, input_channels, output_channels, name=None): + super(BasicBlock, self).__init__() + + self._conv1 = ConvBNLayer( + input_channels, output_channels, 1, 1, 0, name=name + ".0") + self._conv2 = ConvBNLayer( + output_channels, output_channels * 2, 3, 1, 1, name=name + ".1") + + def forward(self, inputs): + x = self._conv1(inputs) + x = self._conv2(x) + return paddle.add(x=inputs, y=x) + + +class DarkNet(nn.Layer): + def __init__(self, class_num=1000): + super(DarkNet, self).__init__() + + self.stages = [1, 2, 8, 8, 4] + self._conv1 = ConvBNLayer(3, 32, 3, 1, 1, name="yolo_input") + self._conv2 = ConvBNLayer( + 32, 64, 3, 2, 1, name="yolo_input.downsample") + + self._basic_block_01 = BasicBlock(64, 32, name="stage.0.0") + self._downsample_0 = ConvBNLayer( + 64, 128, 3, 2, 1, name="stage.0.downsample") + + self._basic_block_11 = BasicBlock(128, 64, name="stage.1.0") + self._basic_block_12 = BasicBlock(128, 64, name="stage.1.1") + self._downsample_1 = ConvBNLayer( + 128, 256, 3, 2, 1, name="stage.1.downsample") + + self._basic_block_21 = BasicBlock(256, 128, name="stage.2.0") + self._basic_block_22 = BasicBlock(256, 128, name="stage.2.1") + self._basic_block_23 = BasicBlock(256, 128, name="stage.2.2") + self._basic_block_24 = BasicBlock(256, 128, name="stage.2.3") + self._basic_block_25 = BasicBlock(256, 128, name="stage.2.4") + self._basic_block_26 = BasicBlock(256, 128, name="stage.2.5") + self._basic_block_27 = BasicBlock(256, 128, name="stage.2.6") + self._basic_block_28 = BasicBlock(256, 128, name="stage.2.7") + self._downsample_2 = ConvBNLayer( + 256, 512, 3, 2, 1, name="stage.2.downsample") + + self._basic_block_31 = BasicBlock(512, 256, name="stage.3.0") + self._basic_block_32 = BasicBlock(512, 256, name="stage.3.1") + self._basic_block_33 = BasicBlock(512, 256, name="stage.3.2") + self._basic_block_34 = BasicBlock(512, 256, name="stage.3.3") + self._basic_block_35 = BasicBlock(512, 256, name="stage.3.4") + self._basic_block_36 = BasicBlock(512, 256, name="stage.3.5") + self._basic_block_37 = BasicBlock(512, 256, name="stage.3.6") + self._basic_block_38 = BasicBlock(512, 256, name="stage.3.7") + self._downsample_3 = ConvBNLayer( + 512, 1024, 3, 2, 1, name="stage.3.downsample") + + self._basic_block_41 = BasicBlock(1024, 512, name="stage.4.0") + self._basic_block_42 = BasicBlock(1024, 512, name="stage.4.1") + self._basic_block_43 = BasicBlock(1024, 512, name="stage.4.2") + self._basic_block_44 = BasicBlock(1024, 512, name="stage.4.3") + + self._pool = AdaptiveAvgPool2D(1) + + stdv = 1.0 / math.sqrt(1024.0) + self._out = Linear( + 1024, + class_num, + weight_attr=ParamAttr( + name="fc_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, inputs): + x = self._conv1(inputs) + x = self._conv2(x) + + x = self._basic_block_01(x) + x = self._downsample_0(x) + + x = self._basic_block_11(x) + x = self._basic_block_12(x) + x = self._downsample_1(x) + + x = self._basic_block_21(x) + x = self._basic_block_22(x) + x = self._basic_block_23(x) + x = self._basic_block_24(x) + x = self._basic_block_25(x) + x = self._basic_block_26(x) + x = self._basic_block_27(x) + x = self._basic_block_28(x) + x = self._downsample_2(x) + + x = self._basic_block_31(x) + x = self._basic_block_32(x) + x = self._basic_block_33(x) + x = self._basic_block_34(x) + x = self._basic_block_35(x) + x = self._basic_block_36(x) + x = self._basic_block_37(x) + x = self._basic_block_38(x) + x = self._downsample_3(x) + + x = self._basic_block_41(x) + x = self._basic_block_42(x) + x = self._basic_block_43(x) + x = self._basic_block_44(x) + + x = self._pool(x) + x = paddle.squeeze(x, axis=[2, 3]) + x = self._out(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def DarkNet53(pretrained=False, use_ssld=False, **kwargs): + model = DarkNet(**kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["DarkNet53"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/densenet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/densenet.py new file mode 100644 index 0000000..7e6e202 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/densenet.py @@ -0,0 +1,344 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "DenseNet121": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet121_pretrained.pdparams", + "DenseNet161": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet161_pretrained.pdparams", + "DenseNet169": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet169_pretrained.pdparams", + "DenseNet201": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet201_pretrained.pdparams", + "DenseNet264": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet264_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class BNACConvLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + pad=0, + groups=1, + act="relu", + name=None): + super(BNACConvLayer, self).__init__() + + self._batch_norm = BatchNorm( + num_channels, + act=act, + param_attr=ParamAttr(name=name + '_bn_scale'), + bias_attr=ParamAttr(name + '_bn_offset'), + moving_mean_name=name + '_bn_mean', + moving_variance_name=name + '_bn_variance') + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=pad, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + + def forward(self, input): + y = self._batch_norm(input) + y = self._conv(y) + return y + + +class DenseLayer(nn.Layer): + def __init__(self, num_channels, growth_rate, bn_size, dropout, name=None): + super(DenseLayer, self).__init__() + self.dropout = dropout + + self.bn_ac_func1 = BNACConvLayer( + num_channels=num_channels, + num_filters=bn_size * growth_rate, + filter_size=1, + pad=0, + stride=1, + name=name + "_x1") + + self.bn_ac_func2 = BNACConvLayer( + num_channels=bn_size * growth_rate, + num_filters=growth_rate, + filter_size=3, + pad=1, + stride=1, + name=name + "_x2") + + if dropout: + self.dropout_func = Dropout(p=dropout, mode="downscale_in_infer") + + def forward(self, input): + conv = self.bn_ac_func1(input) + conv = self.bn_ac_func2(conv) + if self.dropout: + conv = self.dropout_func(conv) + conv = paddle.concat([input, conv], axis=1) + return conv + + +class DenseBlock(nn.Layer): + def __init__(self, + num_channels, + num_layers, + bn_size, + growth_rate, + dropout, + name=None): + super(DenseBlock, self).__init__() + self.dropout = dropout + + self.dense_layer_func = [] + + pre_channel = num_channels + for layer in range(num_layers): + self.dense_layer_func.append( + self.add_sublayer( + "{}_{}".format(name, layer + 1), + DenseLayer( + num_channels=pre_channel, + growth_rate=growth_rate, + bn_size=bn_size, + dropout=dropout, + name=name + '_' + str(layer + 1)))) + pre_channel = pre_channel + growth_rate + + def forward(self, input): + conv = input + for func in self.dense_layer_func: + conv = func(conv) + return conv + + +class TransitionLayer(nn.Layer): + def __init__(self, num_channels, num_output_features, name=None): + super(TransitionLayer, self).__init__() + + self.conv_ac_func = BNACConvLayer( + num_channels=num_channels, + num_filters=num_output_features, + filter_size=1, + pad=0, + stride=1, + name=name) + + self.pool2d_avg = AvgPool2D(kernel_size=2, stride=2, padding=0) + + def forward(self, input): + y = self.conv_ac_func(input) + y = self.pool2d_avg(y) + return y + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + pad=0, + groups=1, + act="relu", + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=pad, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=name + '_bn_scale'), + bias_attr=ParamAttr(name + '_bn_offset'), + moving_mean_name=name + '_bn_mean', + moving_variance_name=name + '_bn_variance') + + def forward(self, input): + y = self._conv(input) + y = self._batch_norm(y) + return y + + +class DenseNet(nn.Layer): + def __init__(self, layers=60, bn_size=4, dropout=0, class_num=1000): + super(DenseNet, self).__init__() + + supported_layers = [121, 161, 169, 201, 264] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + densenet_spec = { + 121: (64, 32, [6, 12, 24, 16]), + 161: (96, 48, [6, 12, 36, 24]), + 169: (64, 32, [6, 12, 32, 32]), + 201: (64, 32, [6, 12, 48, 32]), + 264: (64, 32, [6, 12, 64, 48]) + } + num_init_features, growth_rate, block_config = densenet_spec[layers] + + self.conv1_func = ConvBNLayer( + num_channels=3, + num_filters=num_init_features, + filter_size=7, + stride=2, + pad=3, + act='relu', + name="conv1") + + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_config = block_config + + self.dense_block_func_list = [] + self.transition_func_list = [] + pre_num_channels = num_init_features + num_features = num_init_features + for i, num_layers in enumerate(block_config): + self.dense_block_func_list.append( + self.add_sublayer( + "db_conv_{}".format(i + 2), + DenseBlock( + num_channels=pre_num_channels, + num_layers=num_layers, + bn_size=bn_size, + growth_rate=growth_rate, + dropout=dropout, + name='conv' + str(i + 2)))) + + num_features = num_features + num_layers * growth_rate + pre_num_channels = num_features + + if i != len(block_config) - 1: + self.transition_func_list.append( + self.add_sublayer( + "tr_conv{}_blk".format(i + 2), + TransitionLayer( + num_channels=pre_num_channels, + num_output_features=num_features // 2, + name='conv' + str(i + 2) + "_blk"))) + pre_num_channels = num_features // 2 + num_features = num_features // 2 + + self.batch_norm = BatchNorm( + num_features, + act="relu", + param_attr=ParamAttr(name='conv5_blk_bn_scale'), + bias_attr=ParamAttr(name='conv5_blk_bn_offset'), + moving_mean_name='conv5_blk_bn_mean', + moving_variance_name='conv5_blk_bn_variance') + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + stdv = 1.0 / math.sqrt(num_features * 1.0) + + self.out = Linear( + num_features, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, input): + conv = self.conv1_func(input) + conv = self.pool2d_max(conv) + + for i, num_layers in enumerate(self.block_config): + conv = self.dense_block_func_list[i](conv) + if i != len(self.block_config) - 1: + conv = self.transition_func_list[i](conv) + + conv = self.batch_norm(conv) + y = self.pool2d_avg(conv) + y = paddle.flatten(y, start_axis=1, stop_axis=-1) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def DenseNet121(pretrained=False, use_ssld=False, **kwargs): + model = DenseNet(layers=121, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["DenseNet121"], use_ssld=use_ssld) + return model + + +def DenseNet161(pretrained=False, use_ssld=False, **kwargs): + model = DenseNet(layers=161, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["DenseNet161"], use_ssld=use_ssld) + return model + + +def DenseNet169(pretrained=False, use_ssld=False, **kwargs): + model = DenseNet(layers=169, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["DenseNet169"], use_ssld=use_ssld) + return model + + +def DenseNet201(pretrained=False, use_ssld=False, **kwargs): + model = DenseNet(layers=201, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["DenseNet201"], use_ssld=use_ssld) + return model + + +def DenseNet264(pretrained=False, use_ssld=False, **kwargs): + model = DenseNet(layers=264, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["DenseNet264"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/distilled_vision_transformer.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/distilled_vision_transformer.py new file mode 100644 index 0000000..676a289 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/distilled_vision_transformer.py @@ -0,0 +1,272 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was heavily based on https://github.com/facebookresearch/deit + +import paddle +import paddle.nn as nn +from .vision_transformer import VisionTransformer, Identity, trunc_normal_, zeros_ + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "DeiT_tiny_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_patch16_224_pretrained.pdparams", + "DeiT_small_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_patch16_224_pretrained.pdparams", + "DeiT_base_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_224_pretrained.pdparams", + "DeiT_tiny_distilled_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_distilled_patch16_224_pretrained.pdparams", + "DeiT_small_distilled_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_distilled_patch16_224_pretrained.pdparams", + "DeiT_base_distilled_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_distilled_patch16_224_pretrained.pdparams", + "DeiT_base_patch16_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_384_pretrained.pdparams", + "DeiT_base_distilled_patch16_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_distilled_patch16_384_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class DistilledVisionTransformer(VisionTransformer): + def __init__(self, + img_size=224, + patch_size=16, + class_num=1000, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=False, + norm_layer='nn.LayerNorm', + epsilon=1e-5, + **kwargs): + super().__init__( + img_size=img_size, + patch_size=patch_size, + class_num=class_num, + embed_dim=embed_dim, + depth=depth, + num_heads=num_heads, + mlp_ratio=mlp_ratio, + qkv_bias=qkv_bias, + norm_layer=norm_layer, + epsilon=epsilon, + **kwargs) + self.pos_embed = self.create_parameter( + shape=(1, self.patch_embed.num_patches + 2, self.embed_dim), + default_initializer=zeros_) + self.add_parameter("pos_embed", self.pos_embed) + + self.dist_token = self.create_parameter( + shape=(1, 1, self.embed_dim), default_initializer=zeros_) + self.add_parameter("cls_token", self.cls_token) + + self.head_dist = nn.Linear( + self.embed_dim, + self.class_num) if self.class_num > 0 else Identity() + + trunc_normal_(self.dist_token) + trunc_normal_(self.pos_embed) + self.head_dist.apply(self._init_weights) + + def forward_features(self, x): + B = paddle.shape(x)[0] + x = self.patch_embed(x) + + cls_tokens = self.cls_token.expand((B, -1, -1)) + dist_token = self.dist_token.expand((B, -1, -1)) + x = paddle.concat((cls_tokens, dist_token, x), axis=1) + + x = x + self.pos_embed + x = self.pos_drop(x) + + for blk in self.blocks: + x = blk(x) + + x = self.norm(x) + return x[:, 0], x[:, 1] + + def forward(self, x): + x, x_dist = self.forward_features(x) + x = self.head(x) + x_dist = self.head_dist(x_dist) + return (x + x_dist) / 2 + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def DeiT_tiny_patch16_224(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + patch_size=16, + embed_dim=192, + depth=12, + num_heads=3, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_tiny_patch16_224"], + use_ssld=use_ssld) + return model + + +def DeiT_small_patch16_224(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + patch_size=16, + embed_dim=384, + depth=12, + num_heads=6, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_small_patch16_224"], + use_ssld=use_ssld) + return model + + +def DeiT_base_patch16_224(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + patch_size=16, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_base_patch16_224"], + use_ssld=use_ssld) + return model + + +def DeiT_tiny_distilled_patch16_224(pretrained=False, use_ssld=False, + **kwargs): + model = DistilledVisionTransformer( + patch_size=16, + embed_dim=192, + depth=12, + num_heads=3, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_tiny_distilled_patch16_224"], + use_ssld=use_ssld) + return model + + +def DeiT_small_distilled_patch16_224(pretrained=False, + use_ssld=False, + **kwargs): + model = DistilledVisionTransformer( + patch_size=16, + embed_dim=384, + depth=12, + num_heads=6, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_small_distilled_patch16_224"], + use_ssld=use_ssld) + return model + + +def DeiT_base_distilled_patch16_224(pretrained=False, use_ssld=False, + **kwargs): + model = DistilledVisionTransformer( + patch_size=16, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_base_distilled_patch16_224"], + use_ssld=use_ssld) + return model + + +def DeiT_base_patch16_384(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + img_size=384, + patch_size=16, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_base_patch16_384"], + use_ssld=use_ssld) + return model + + +def DeiT_base_distilled_patch16_384(pretrained=False, use_ssld=False, + **kwargs): + model = DistilledVisionTransformer( + img_size=384, + patch_size=16, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["DeiT_base_distilled_patch16_384"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/dla.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/dla.py new file mode 100644 index 0000000..b1c00b2 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/dla.py @@ -0,0 +1,528 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/ucbdrive/dla + +import math + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from paddle.nn.initializer import Normal, Constant + +from ppcls.arch.backbone.base.theseus_layer import Identity +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "DLA34": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA34_pretrained.pdparams", + "DLA46_c": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA46_c_pretrained.pdparams", + "DLA46x_c": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA46x_c_pretrained.pdparams", + "DLA60": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60_pretrained.pdparams", + "DLA60x": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_pretrained.pdparams", + "DLA60x_c": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_c_pretrained.pdparams", + "DLA102": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102_pretrained.pdparams", + "DLA102x": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x_pretrained.pdparams", + "DLA102x2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x2_pretrained.pdparams", + "DLA169": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA169_pretrained.pdparams" +} + +__all__ = MODEL_URLS.keys() + +zeros_ = Constant(value=0.) +ones_ = Constant(value=1.) + + +class DlaBasic(nn.Layer): + def __init__(self, inplanes, planes, stride=1, dilation=1, **cargs): + super(DlaBasic, self).__init__() + self.conv1 = nn.Conv2D( + inplanes, + planes, + kernel_size=3, + stride=stride, + padding=dilation, + bias_attr=False, + dilation=dilation) + self.bn1 = nn.BatchNorm2D(planes) + self.relu = nn.ReLU() + self.conv2 = nn.Conv2D( + planes, + planes, + kernel_size=3, + stride=1, + padding=dilation, + bias_attr=False, + dilation=dilation) + self.bn2 = nn.BatchNorm2D(planes) + self.stride = stride + + def forward(self, x, residual=None): + if residual is None: + residual = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + out += residual + out = self.relu(out) + + return out + + +class DlaBottleneck(nn.Layer): + expansion = 2 + + def __init__(self, + inplanes, + outplanes, + stride=1, + dilation=1, + cardinality=1, + base_width=64): + super(DlaBottleneck, self).__init__() + self.stride = stride + mid_planes = int( + math.floor(outplanes * (base_width / 64)) * cardinality) + mid_planes = mid_planes // self.expansion + + self.conv1 = nn.Conv2D( + inplanes, mid_planes, kernel_size=1, bias_attr=False) + self.bn1 = nn.BatchNorm2D(mid_planes) + self.conv2 = nn.Conv2D( + mid_planes, + mid_planes, + kernel_size=3, + stride=stride, + padding=dilation, + bias_attr=False, + dilation=dilation, + groups=cardinality) + self.bn2 = nn.BatchNorm2D(mid_planes) + self.conv3 = nn.Conv2D( + mid_planes, outplanes, kernel_size=1, bias_attr=False) + self.bn3 = nn.BatchNorm2D(outplanes) + self.relu = nn.ReLU() + + def forward(self, x, residual=None): + if residual is None: + residual = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + out = self.conv3(out) + out = self.bn3(out) + + out += residual + out = self.relu(out) + + return out + + +class DlaRoot(nn.Layer): + def __init__(self, in_channels, out_channels, kernel_size, residual): + super(DlaRoot, self).__init__() + self.conv = nn.Conv2D( + in_channels, + out_channels, + 1, + stride=1, + bias_attr=False, + padding=(kernel_size - 1) // 2) + self.bn = nn.BatchNorm2D(out_channels) + self.relu = nn.ReLU() + self.residual = residual + + def forward(self, *x): + children = x + x = self.conv(paddle.concat(x, 1)) + x = self.bn(x) + if self.residual: + x += children[0] + x = self.relu(x) + + return x + + +class DlaTree(nn.Layer): + def __init__(self, + levels, + block, + in_channels, + out_channels, + stride=1, + dilation=1, + cardinality=1, + base_width=64, + level_root=False, + root_dim=0, + root_kernel_size=1, + root_residual=False): + super(DlaTree, self).__init__() + if root_dim == 0: + root_dim = 2 * out_channels + if level_root: + root_dim += in_channels + + self.downsample = nn.MaxPool2D( + stride, stride=stride) if stride > 1 else Identity() + self.project = Identity() + cargs = dict( + dilation=dilation, cardinality=cardinality, base_width=base_width) + + if levels == 1: + self.tree1 = block(in_channels, out_channels, stride, **cargs) + self.tree2 = block(out_channels, out_channels, 1, **cargs) + if in_channels != out_channels: + self.project = nn.Sequential( + nn.Conv2D( + in_channels, + out_channels, + kernel_size=1, + stride=1, + bias_attr=False), + nn.BatchNorm2D(out_channels)) + else: + cargs.update( + dict( + root_kernel_size=root_kernel_size, + root_residual=root_residual)) + self.tree1 = DlaTree( + levels - 1, + block, + in_channels, + out_channels, + stride, + root_dim=0, + **cargs) + self.tree2 = DlaTree( + levels - 1, + block, + out_channels, + out_channels, + root_dim=root_dim + out_channels, + **cargs) + + if levels == 1: + self.root = DlaRoot(root_dim, out_channels, root_kernel_size, + root_residual) + + self.level_root = level_root + self.root_dim = root_dim + self.levels = levels + + def forward(self, x, residual=None, children=None): + children = [] if children is None else children + bottom = self.downsample(x) + residual = self.project(bottom) + + if self.level_root: + children.append(bottom) + x1 = self.tree1(x, residual) + + if self.levels == 1: + x2 = self.tree2(x1) + x = self.root(x2, x1, *children) + else: + children.append(x1) + x = self.tree2(x1, children=children) + return x + + +class DLA(nn.Layer): + def __init__(self, + levels, + channels, + in_chans=3, + cardinality=1, + base_width=64, + block=DlaBottleneck, + residual_root=False, + drop_rate=0.0, + class_num=1000, + with_pool=True): + super(DLA, self).__init__() + self.channels = channels + self.class_num = class_num + self.with_pool = with_pool + self.cardinality = cardinality + self.base_width = base_width + self.drop_rate = drop_rate + + self.base_layer = nn.Sequential( + nn.Conv2D( + in_chans, + channels[0], + kernel_size=7, + stride=1, + padding=3, + bias_attr=False), + nn.BatchNorm2D(channels[0]), + nn.ReLU()) + + self.level0 = self._make_conv_level(channels[0], channels[0], + levels[0]) + self.level1 = self._make_conv_level( + channels[0], channels[1], levels[1], stride=2) + + cargs = dict( + cardinality=cardinality, + base_width=base_width, + root_residual=residual_root) + + self.level2 = DlaTree( + levels[2], + block, + channels[1], + channels[2], + 2, + level_root=False, + **cargs) + self.level3 = DlaTree( + levels[3], + block, + channels[2], + channels[3], + 2, + level_root=True, + **cargs) + self.level4 = DlaTree( + levels[4], + block, + channels[3], + channels[4], + 2, + level_root=True, + **cargs) + self.level5 = DlaTree( + levels[5], + block, + channels[4], + channels[5], + 2, + level_root=True, + **cargs) + + self.feature_info = [ + # rare to have a meaningful stride 1 level + dict( + num_chs=channels[0], reduction=1, module='level0'), + dict( + num_chs=channels[1], reduction=2, module='level1'), + dict( + num_chs=channels[2], reduction=4, module='level2'), + dict( + num_chs=channels[3], reduction=8, module='level3'), + dict( + num_chs=channels[4], reduction=16, module='level4'), + dict( + num_chs=channels[5], reduction=32, module='level5'), + ] + + self.num_features = channels[-1] + + if with_pool: + self.global_pool = nn.AdaptiveAvgPool2D(1) + + if class_num > 0: + self.fc = nn.Conv2D(self.num_features, class_num, 1) + + for m in self.sublayers(): + if isinstance(m, nn.Conv2D): + n = m._kernel_size[0] * m._kernel_size[1] * m._out_channels + normal_ = Normal(mean=0.0, std=math.sqrt(2. / n)) + normal_(m.weight) + elif isinstance(m, nn.BatchNorm2D): + ones_(m.weight) + zeros_(m.bias) + + def _make_conv_level(self, inplanes, planes, convs, stride=1, dilation=1): + modules = [] + for i in range(convs): + modules.extend([ + nn.Conv2D( + inplanes, + planes, + kernel_size=3, + stride=stride if i == 0 else 1, + padding=dilation, + bias_attr=False, + dilation=dilation), nn.BatchNorm2D(planes), nn.ReLU() + ]) + inplanes = planes + return nn.Sequential(*modules) + + def forward_features(self, x): + x = self.base_layer(x) + + x = self.level0(x) + x = self.level1(x) + x = self.level2(x) + x = self.level3(x) + x = self.level4(x) + x = self.level5(x) + + return x + + def forward(self, x): + x = self.forward_features(x) + + if self.with_pool: + x = self.global_pool(x) + + if self.drop_rate > 0.: + x = F.dropout(x, p=self.drop_rate, training=self.training) + + if self.class_num > 0: + x = self.fc(x) + x = x.flatten(1) + + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def DLA34(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 2, 2, 1), + channels=(16, 32, 64, 128, 256, 512), + block=DlaBasic, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA34"]) + return model + + +def DLA46_c(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 2, 2, 1), + channels=(16, 32, 64, 64, 128, 256), + block=DlaBottleneck, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA46_c"]) + return model + + +def DLA46x_c(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 2, 2, 1), + channels=(16, 32, 64, 64, 128, 256), + block=DlaBottleneck, + cardinality=32, + base_width=4, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA46x_c"]) + return model + + +def DLA60(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 2, 3, 1), + channels=(16, 32, 128, 256, 512, 1024), + block=DlaBottleneck, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA60"]) + return model + + +def DLA60x(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 2, 3, 1), + channels=(16, 32, 128, 256, 512, 1024), + block=DlaBottleneck, + cardinality=32, + base_width=4, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA60x"]) + return model + + +def DLA60x_c(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 2, 3, 1), + channels=(16, 32, 64, 64, 128, 256), + block=DlaBottleneck, + cardinality=32, + base_width=4, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA60x_c"]) + return model + + +def DLA102(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 3, 4, 1), + channels=(16, 32, 128, 256, 512, 1024), + block=DlaBottleneck, + residual_root=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA102"]) + return model + + +def DLA102x(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 3, 4, 1), + channels=(16, 32, 128, 256, 512, 1024), + block=DlaBottleneck, + cardinality=32, + base_width=4, + residual_root=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA102x"]) + return model + + +def DLA102x2(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 1, 3, 4, 1), + channels=(16, 32, 128, 256, 512, 1024), + block=DlaBottleneck, + cardinality=64, + base_width=4, + residual_root=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA102x2"]) + return model + + +def DLA169(pretrained=False, **kwargs): + model = DLA(levels=(1, 1, 2, 3, 5, 1), + channels=(16, 32, 128, 256, 512, 1024), + block=DlaBottleneck, + residual_root=True, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DLA169"]) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/dpn.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/dpn.py new file mode 100644 index 0000000..55953ed --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/dpn.py @@ -0,0 +1,451 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import sys +import paddle +from paddle import ParamAttr +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "DPN68": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN68_pretrained.pdparams", + "DPN92": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN92_pretrained.pdparams", + "DPN98": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN98_pretrained.pdparams", + "DPN107": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN107_pretrained.pdparams", + "DPN131": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN131_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + pad=0, + groups=1, + act="relu", + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=pad, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=name + '_bn_scale'), + bias_attr=ParamAttr(name + '_bn_offset'), + moving_mean_name=name + '_bn_mean', + moving_variance_name=name + '_bn_variance') + + def forward(self, input): + y = self._conv(input) + y = self._batch_norm(y) + return y + + +class BNACConvLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + pad=0, + groups=1, + act="relu", + name=None): + super(BNACConvLayer, self).__init__() + self.num_channels = num_channels + + self._batch_norm = BatchNorm( + num_channels, + act=act, + param_attr=ParamAttr(name=name + '_bn_scale'), + bias_attr=ParamAttr(name + '_bn_offset'), + moving_mean_name=name + '_bn_mean', + moving_variance_name=name + '_bn_variance') + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=pad, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + + def forward(self, input): + y = self._batch_norm(input) + y = self._conv(y) + return y + + +class DualPathFactory(nn.Layer): + def __init__(self, + num_channels, + num_1x1_a, + num_3x3_b, + num_1x1_c, + inc, + G, + _type='normal', + name=None): + super(DualPathFactory, self).__init__() + + self.num_1x1_c = num_1x1_c + self.inc = inc + self.name = name + + kw = 3 + kh = 3 + pw = (kw - 1) // 2 + ph = (kh - 1) // 2 + + # type + if _type == 'proj': + key_stride = 1 + self.has_proj = True + elif _type == 'down': + key_stride = 2 + self.has_proj = True + elif _type == 'normal': + key_stride = 1 + self.has_proj = False + else: + print("not implemented now!!!") + sys.exit(1) + + data_in_ch = sum(num_channels) if isinstance(num_channels, + list) else num_channels + + if self.has_proj: + self.c1x1_w_func = BNACConvLayer( + num_channels=data_in_ch, + num_filters=num_1x1_c + 2 * inc, + filter_size=(1, 1), + pad=(0, 0), + stride=(key_stride, key_stride), + name=name + "_match") + + self.c1x1_a_func = BNACConvLayer( + num_channels=data_in_ch, + num_filters=num_1x1_a, + filter_size=(1, 1), + pad=(0, 0), + name=name + "_conv1") + + self.c3x3_b_func = BNACConvLayer( + num_channels=num_1x1_a, + num_filters=num_3x3_b, + filter_size=(kw, kh), + pad=(pw, ph), + stride=(key_stride, key_stride), + groups=G, + name=name + "_conv2") + + self.c1x1_c_func = BNACConvLayer( + num_channels=num_3x3_b, + num_filters=num_1x1_c + inc, + filter_size=(1, 1), + pad=(0, 0), + name=name + "_conv3") + + def forward(self, input): + # PROJ + if isinstance(input, list): + data_in = paddle.concat([input[0], input[1]], axis=1) + else: + data_in = input + + if self.has_proj: + c1x1_w = self.c1x1_w_func(data_in) + data_o1, data_o2 = paddle.split( + c1x1_w, num_or_sections=[self.num_1x1_c, 2 * self.inc], axis=1) + else: + data_o1 = input[0] + data_o2 = input[1] + + c1x1_a = self.c1x1_a_func(data_in) + c3x3_b = self.c3x3_b_func(c1x1_a) + c1x1_c = self.c1x1_c_func(c3x3_b) + + c1x1_c1, c1x1_c2 = paddle.split( + c1x1_c, num_or_sections=[self.num_1x1_c, self.inc], axis=1) + + # OUTPUTS + summ = paddle.add(x=data_o1, y=c1x1_c1) + dense = paddle.concat([data_o2, c1x1_c2], axis=1) + # tensor, channels + return [summ, dense] + + +class DPN(nn.Layer): + def __init__(self, layers=68, class_num=1000): + super(DPN, self).__init__() + + self._class_num = class_num + + args = self.get_net_args(layers) + bws = args['bw'] + inc_sec = args['inc_sec'] + rs = args['r'] + k_r = args['k_r'] + k_sec = args['k_sec'] + G = args['G'] + init_num_filter = args['init_num_filter'] + init_filter_size = args['init_filter_size'] + init_padding = args['init_padding'] + + self.k_sec = k_sec + + self.conv1_x_1_func = ConvBNLayer( + num_channels=3, + num_filters=init_num_filter, + filter_size=init_filter_size, + stride=2, + pad=init_padding, + act='relu', + name="conv1") + + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + num_channel_dpn = init_num_filter + + self.dpn_func_list = [] + #conv2 - conv5 + match_list, num = [], 0 + for gc in range(4): + bw = bws[gc] + inc = inc_sec[gc] + R = (k_r * bw) // rs[gc] + if gc == 0: + _type1 = 'proj' + _type2 = 'normal' + match = 1 + else: + _type1 = 'down' + _type2 = 'normal' + match = match + k_sec[gc - 1] + match_list.append(match) + self.dpn_func_list.append( + self.add_sublayer( + "dpn{}".format(match), + DualPathFactory( + num_channels=num_channel_dpn, + num_1x1_a=R, + num_3x3_b=R, + num_1x1_c=bw, + inc=inc, + G=G, + _type=_type1, + name="dpn" + str(match)))) + num_channel_dpn = [bw, 3 * inc] + + for i_ly in range(2, k_sec[gc] + 1): + num += 1 + if num in match_list: + num += 1 + self.dpn_func_list.append( + self.add_sublayer( + "dpn{}".format(num), + DualPathFactory( + num_channels=num_channel_dpn, + num_1x1_a=R, + num_3x3_b=R, + num_1x1_c=bw, + inc=inc, + G=G, + _type=_type2, + name="dpn" + str(num)))) + + num_channel_dpn = [ + num_channel_dpn[0], num_channel_dpn[1] + inc + ] + + out_channel = sum(num_channel_dpn) + + self.conv5_x_x_bn = BatchNorm( + num_channels=sum(num_channel_dpn), + act="relu", + param_attr=ParamAttr(name='final_concat_bn_scale'), + bias_attr=ParamAttr('final_concat_bn_offset'), + moving_mean_name='final_concat_bn_mean', + moving_variance_name='final_concat_bn_variance') + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + stdv = 0.01 + + self.out = Linear( + out_channel, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, input): + conv1_x_1 = self.conv1_x_1_func(input) + convX_x_x = self.pool2d_max(conv1_x_1) + + dpn_idx = 0 + for gc in range(4): + convX_x_x = self.dpn_func_list[dpn_idx](convX_x_x) + dpn_idx += 1 + for i_ly in range(2, self.k_sec[gc] + 1): + convX_x_x = self.dpn_func_list[dpn_idx](convX_x_x) + dpn_idx += 1 + + conv5_x_x = paddle.concat(convX_x_x, axis=1) + conv5_x_x = self.conv5_x_x_bn(conv5_x_x) + + y = self.pool2d_avg(conv5_x_x) + y = paddle.flatten(y, start_axis=1, stop_axis=-1) + y = self.out(y) + return y + + def get_net_args(self, layers): + if layers == 68: + k_r = 128 + G = 32 + k_sec = [3, 4, 12, 3] + inc_sec = [16, 32, 32, 64] + bw = [64, 128, 256, 512] + r = [64, 64, 64, 64] + init_num_filter = 10 + init_filter_size = 3 + init_padding = 1 + elif layers == 92: + k_r = 96 + G = 32 + k_sec = [3, 4, 20, 3] + inc_sec = [16, 32, 24, 128] + bw = [256, 512, 1024, 2048] + r = [256, 256, 256, 256] + init_num_filter = 64 + init_filter_size = 7 + init_padding = 3 + elif layers == 98: + k_r = 160 + G = 40 + k_sec = [3, 6, 20, 3] + inc_sec = [16, 32, 32, 128] + bw = [256, 512, 1024, 2048] + r = [256, 256, 256, 256] + init_num_filter = 96 + init_filter_size = 7 + init_padding = 3 + elif layers == 107: + k_r = 200 + G = 50 + k_sec = [4, 8, 20, 3] + inc_sec = [20, 64, 64, 128] + bw = [256, 512, 1024, 2048] + r = [256, 256, 256, 256] + init_num_filter = 128 + init_filter_size = 7 + init_padding = 3 + elif layers == 131: + k_r = 160 + G = 40 + k_sec = [4, 8, 28, 3] + inc_sec = [16, 32, 32, 128] + bw = [256, 512, 1024, 2048] + r = [256, 256, 256, 256] + init_num_filter = 128 + init_filter_size = 7 + init_padding = 3 + else: + raise NotImplementedError + net_arg = { + 'k_r': k_r, + 'G': G, + 'k_sec': k_sec, + 'inc_sec': inc_sec, + 'bw': bw, + 'r': r + } + net_arg['init_num_filter'] = init_num_filter + net_arg['init_filter_size'] = init_filter_size + net_arg['init_padding'] = init_padding + + return net_arg + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def DPN68(pretrained=False, use_ssld=False, **kwargs): + model = DPN(layers=68, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DPN68"]) + return model + + +def DPN92(pretrained=False, use_ssld=False, **kwargs): + model = DPN(layers=92, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DPN92"]) + return model + + +def DPN98(pretrained=False, use_ssld=False, **kwargs): + model = DPN(layers=98, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DPN98"]) + return model + + +def DPN107(pretrained=False, use_ssld=False, **kwargs): + model = DPN(layers=107, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DPN107"]) + return model + + +def DPN131(pretrained=False, use_ssld=False, **kwargs): + model = DPN(layers=131, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["DPN131"]) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/efficientnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/efficientnet.py new file mode 100644 index 0000000..bd0cffa --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/efficientnet.py @@ -0,0 +1,976 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/lukemelas/EfficientNet-PyTorch + +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +import math +import collections +import re +import copy + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "EfficientNetB0_small": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_small_pretrained.pdparams", + "EfficientNetB0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_pretrained.pdparams", + "EfficientNetB1": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB1_pretrained.pdparams", + "EfficientNetB2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB2_pretrained.pdparams", + "EfficientNetB3": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB3_pretrained.pdparams", + "EfficientNetB4": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB4_pretrained.pdparams", + "EfficientNetB5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB5_pretrained.pdparams", + "EfficientNetB6": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB6_pretrained.pdparams", + "EfficientNetB7": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB7_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + +GlobalParams = collections.namedtuple('GlobalParams', [ + 'batch_norm_momentum', + 'batch_norm_epsilon', + 'dropout_rate', + 'num_classes', + 'width_coefficient', + 'depth_coefficient', + 'depth_divisor', + 'min_depth', + 'drop_connect_rate', +]) + +BlockArgs = collections.namedtuple('BlockArgs', [ + 'kernel_size', 'num_repeat', 'input_filters', 'output_filters', + 'expand_ratio', 'id_skip', 'stride', 'se_ratio' +]) + +GlobalParams.__new__.__defaults__ = (None, ) * len(GlobalParams._fields) +BlockArgs.__new__.__defaults__ = (None, ) * len(BlockArgs._fields) + + +def efficientnet_params(model_name): + """ Map EfficientNet model name to parameter coefficients. """ + params_dict = { + # Coefficients: width,depth,resolution,dropout + 'efficientnet-b0': (1.0, 1.0, 224, 0.2), + 'efficientnet-b1': (1.0, 1.1, 240, 0.2), + 'efficientnet-b2': (1.1, 1.2, 260, 0.3), + 'efficientnet-b3': (1.2, 1.4, 300, 0.3), + 'efficientnet-b4': (1.4, 1.8, 380, 0.4), + 'efficientnet-b5': (1.6, 2.2, 456, 0.4), + 'efficientnet-b6': (1.8, 2.6, 528, 0.5), + 'efficientnet-b7': (2.0, 3.1, 600, 0.5), + } + return params_dict[model_name] + + +def efficientnet(width_coefficient=None, + depth_coefficient=None, + dropout_rate=0.2, + drop_connect_rate=0.2): + """ Get block arguments according to parameter and coefficients. """ + blocks_args = [ + 'r1_k3_s11_e1_i32_o16_se0.25', + 'r2_k3_s22_e6_i16_o24_se0.25', + 'r2_k5_s22_e6_i24_o40_se0.25', + 'r3_k3_s22_e6_i40_o80_se0.25', + 'r3_k5_s11_e6_i80_o112_se0.25', + 'r4_k5_s22_e6_i112_o192_se0.25', + 'r1_k3_s11_e6_i192_o320_se0.25', + ] + blocks_args = BlockDecoder.decode(blocks_args) + + global_params = GlobalParams( + batch_norm_momentum=0.99, + batch_norm_epsilon=1e-3, + dropout_rate=dropout_rate, + drop_connect_rate=drop_connect_rate, + num_classes=1000, + width_coefficient=width_coefficient, + depth_coefficient=depth_coefficient, + depth_divisor=8, + min_depth=None) + + return blocks_args, global_params + + +def get_model_params(model_name, override_params): + """ Get the block args and global params for a given model """ + if model_name.startswith('efficientnet'): + w, d, _, p = efficientnet_params(model_name) + blocks_args, global_params = efficientnet( + width_coefficient=w, depth_coefficient=d, dropout_rate=p) + else: + raise NotImplementedError('model name is not pre-defined: %s' % + model_name) + if override_params: + global_params = global_params._replace(**override_params) + return blocks_args, global_params + + +def round_filters(filters, global_params): + """ Calculate and round number of filters based on depth multiplier. """ + multiplier = global_params.width_coefficient + if not multiplier: + return filters + divisor = global_params.depth_divisor + min_depth = global_params.min_depth + filters *= multiplier + min_depth = min_depth or divisor + new_filters = max(min_depth, + int(filters + divisor / 2) // divisor * divisor) + if new_filters < 0.9 * filters: # prevent rounding by more than 10% + new_filters += divisor + return int(new_filters) + + +def round_repeats(repeats, global_params): + """ Round number of filters based on depth multiplier. """ + multiplier = global_params.depth_coefficient + if not multiplier: + return repeats + return int(math.ceil(multiplier * repeats)) + + +class BlockDecoder(object): + """ + Block Decoder, straight from the official TensorFlow repository. + """ + + @staticmethod + def _decode_block_string(block_string): + """ Gets a block through a string notation of arguments. """ + assert isinstance(block_string, str) + + ops = block_string.split('_') + options = {} + for op in ops: + splits = re.split(r'(\d.*)', op) + if len(splits) >= 2: + key, value = splits[:2] + options[key] = value + + # Check stride + cond_1 = ('s' in options and len(options['s']) == 1) + cond_2 = ((len(options['s']) == 2) and + (options['s'][0] == options['s'][1])) + assert (cond_1 or cond_2) + + return BlockArgs( + kernel_size=int(options['k']), + num_repeat=int(options['r']), + input_filters=int(options['i']), + output_filters=int(options['o']), + expand_ratio=int(options['e']), + id_skip=('noskip' not in block_string), + se_ratio=float(options['se']) if 'se' in options else None, + stride=[int(options['s'][0])]) + + @staticmethod + def _encode_block_string(block): + """Encodes a block to a string.""" + args = [ + 'r%d' % block.num_repeat, 'k%d' % block.kernel_size, 's%d%d' % + (block.strides[0], block.strides[1]), 'e%s' % block.expand_ratio, + 'i%d' % block.input_filters, 'o%d' % block.output_filters + ] + if 0 < block.se_ratio <= 1: + args.append('se%s' % block.se_ratio) + if block.id_skip is False: + args.append('noskip') + return '_'.join(args) + + @staticmethod + def decode(string_list): + """ + Decode a list of string notations to specify blocks in the network. + + string_list: list of strings, each string is a notation of block + return + list of BlockArgs namedtuples of block args + """ + assert isinstance(string_list, list) + blocks_args = [] + for block_string in string_list: + blocks_args.append(BlockDecoder._decode_block_string(block_string)) + return blocks_args + + @staticmethod + def encode(blocks_args): + """ + Encodes a list of BlockArgs to a list of strings. + + :param blocks_args: a list of BlockArgs namedtuples of block args + :return: a list of strings, each string is a notation of block + """ + block_strings = [] + for block in blocks_args: + block_strings.append(BlockDecoder._encode_block_string(block)) + return block_strings + + +def initial_type(name, use_bias=False): + param_attr = ParamAttr(name=name + "_weights") + if use_bias: + bias_attr = ParamAttr(name=name + "_offset") + else: + bias_attr = False + return param_attr, bias_attr + + +def init_batch_norm_layer(name="batch_norm"): + param_attr = ParamAttr(name=name + "_scale") + bias_attr = ParamAttr(name=name + "_offset") + return param_attr, bias_attr + + +def init_fc_layer(name="fc"): + param_attr = ParamAttr(name=name + "_weights") + bias_attr = ParamAttr(name=name + "_offset") + return param_attr, bias_attr + + +def cal_padding(img_size, stride, filter_size, dilation=1): + """Calculate padding size.""" + if img_size % stride == 0: + out_size = max(filter_size - stride, 0) + else: + out_size = max(filter_size - (img_size % stride), 0) + return out_size // 2, out_size - out_size // 2 + + +inp_shape = { + "b0_small": [224, 112, 112, 56, 28, 14, 14, 7], + "b0": [224, 112, 112, 56, 28, 14, 14, 7], + "b1": [240, 120, 120, 60, 30, 15, 15, 8], + "b2": [260, 130, 130, 65, 33, 17, 17, 9], + "b3": [300, 150, 150, 75, 38, 19, 19, 10], + "b4": [380, 190, 190, 95, 48, 24, 24, 12], + "b5": [456, 228, 228, 114, 57, 29, 29, 15], + "b6": [528, 264, 264, 132, 66, 33, 33, 17], + "b7": [600, 300, 300, 150, 75, 38, 38, 19] +} + + +def _drop_connect(inputs, prob, is_test): + if is_test: + output = inputs + else: + keep_prob = 1.0 - prob + inputs_shape = paddle.shape(inputs) + random_tensor = keep_prob + paddle.rand( + shape=[inputs_shape[0], 1, 1, 1]) + binary_tensor = paddle.floor(random_tensor) + output = paddle.multiply(inputs, binary_tensor) / keep_prob + return output + + +class Conv2ds(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter_size, + stride=1, + padding=0, + groups=None, + name="conv2d", + act=None, + use_bias=False, + padding_type=None, + model_name=None, + cur_stage=None): + super(Conv2ds, self).__init__() + assert act in [None, "swish", "sigmoid"] + self.act = act + + param_attr, bias_attr = initial_type(name=name, use_bias=use_bias) + + def get_padding(filter_size, stride=1, dilation=1): + padding = ((stride - 1) + dilation * (filter_size - 1)) // 2 + return padding + + inps = 1 if model_name == None and cur_stage == None else inp_shape[ + model_name][cur_stage] + self.need_crop = False + if padding_type == "SAME": + top_padding, bottom_padding = cal_padding(inps, stride, + filter_size) + left_padding, right_padding = cal_padding(inps, stride, + filter_size) + height_padding = bottom_padding + width_padding = right_padding + if top_padding != bottom_padding or left_padding != right_padding: + height_padding = top_padding + stride + width_padding = left_padding + stride + self.need_crop = True + padding = [height_padding, width_padding] + elif padding_type == "VALID": + height_padding = 0 + width_padding = 0 + padding = [height_padding, width_padding] + elif padding_type == "DYNAMIC": + padding = get_padding(filter_size, stride) + else: + padding = padding_type + + groups = 1 if groups is None else groups + self._conv = Conv2D( + input_channels, + output_channels, + filter_size, + groups=groups, + stride=stride, + # act=act, + padding=padding, + weight_attr=param_attr, + bias_attr=bias_attr) + + def forward(self, inputs): + x = self._conv(inputs) + if self.act == "swish": + x = F.swish(x) + elif self.act == "sigmoid": + x = F.sigmoid(x) + + if self.need_crop: + x = x[:, :, 1:, 1:] + return x + + +class ConvBNLayer(nn.Layer): + def __init__(self, + input_channels, + filter_size, + output_channels, + stride=1, + num_groups=1, + padding_type="SAME", + conv_act=None, + bn_act="swish", + use_bn=True, + use_bias=False, + name=None, + conv_name=None, + bn_name=None, + model_name=None, + cur_stage=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2ds( + input_channels=input_channels, + output_channels=output_channels, + filter_size=filter_size, + stride=stride, + groups=num_groups, + act=conv_act, + padding_type=padding_type, + name=conv_name, + use_bias=use_bias, + model_name=model_name, + cur_stage=cur_stage) + self.use_bn = use_bn + if use_bn is True: + bn_name = name + bn_name + param_attr, bias_attr = init_batch_norm_layer(bn_name) + + self._bn = BatchNorm( + num_channels=output_channels, + act=bn_act, + momentum=0.99, + epsilon=0.001, + moving_mean_name=bn_name + "_mean", + moving_variance_name=bn_name + "_variance", + param_attr=param_attr, + bias_attr=bias_attr) + + def forward(self, inputs): + if self.use_bn: + x = self._conv(inputs) + x = self._bn(x) + return x + else: + return self._conv(inputs) + + +class ExpandConvNorm(nn.Layer): + def __init__(self, + input_channels, + block_args, + padding_type, + name=None, + model_name=None, + cur_stage=None): + super(ExpandConvNorm, self).__init__() + + self.oup = block_args.input_filters * block_args.expand_ratio + self.expand_ratio = block_args.expand_ratio + + if self.expand_ratio != 1: + self._conv = ConvBNLayer( + input_channels, + 1, + self.oup, + bn_act=None, + padding_type=padding_type, + name=name, + conv_name=name + "_expand_conv", + bn_name="_bn0", + model_name=model_name, + cur_stage=cur_stage) + + def forward(self, inputs): + if self.expand_ratio != 1: + return self._conv(inputs) + else: + return inputs + + +class DepthwiseConvNorm(nn.Layer): + def __init__(self, + input_channels, + block_args, + padding_type, + name=None, + model_name=None, + cur_stage=None): + super(DepthwiseConvNorm, self).__init__() + + self.k = block_args.kernel_size + self.s = block_args.stride + if isinstance(self.s, list) or isinstance(self.s, tuple): + self.s = self.s[0] + oup = block_args.input_filters * block_args.expand_ratio + + self._conv = ConvBNLayer( + input_channels, + self.k, + oup, + self.s, + num_groups=input_channels, + bn_act=None, + padding_type=padding_type, + name=name, + conv_name=name + "_depthwise_conv", + bn_name="_bn1", + model_name=model_name, + cur_stage=cur_stage) + + def forward(self, inputs): + return self._conv(inputs) + + +class ProjectConvNorm(nn.Layer): + def __init__(self, + input_channels, + block_args, + padding_type, + name=None, + model_name=None, + cur_stage=None): + super(ProjectConvNorm, self).__init__() + + final_oup = block_args.output_filters + + self._conv = ConvBNLayer( + input_channels, + 1, + final_oup, + bn_act=None, + padding_type=padding_type, + name=name, + conv_name=name + "_project_conv", + bn_name="_bn2", + model_name=model_name, + cur_stage=cur_stage) + + def forward(self, inputs): + return self._conv(inputs) + + +class SEBlock(nn.Layer): + def __init__(self, + input_channels, + num_squeezed_channels, + oup, + padding_type, + name=None, + model_name=None, + cur_stage=None): + super(SEBlock, self).__init__() + + self._pool = AdaptiveAvgPool2D(1) + self._conv1 = Conv2ds( + input_channels, + num_squeezed_channels, + 1, + use_bias=True, + padding_type=padding_type, + act="swish", + name=name + "_se_reduce") + + self._conv2 = Conv2ds( + num_squeezed_channels, + oup, + 1, + act="sigmoid", + use_bias=True, + padding_type=padding_type, + name=name + "_se_expand") + + def forward(self, inputs): + x = self._pool(inputs) + x = self._conv1(x) + x = self._conv2(x) + out = paddle.multiply(inputs, x) + return out + + +class MbConvBlock(nn.Layer): + def __init__(self, + input_channels, + block_args, + padding_type, + use_se, + name=None, + drop_connect_rate=None, + model_name=None, + cur_stage=None): + super(MbConvBlock, self).__init__() + + oup = block_args.input_filters * block_args.expand_ratio + self.block_args = block_args + self.has_se = use_se and (block_args.se_ratio is not None) and ( + 0 < block_args.se_ratio <= 1) + self.id_skip = block_args.id_skip + self.expand_ratio = block_args.expand_ratio + self.drop_connect_rate = drop_connect_rate + + if self.expand_ratio != 1: + self._ecn = ExpandConvNorm( + input_channels, + block_args, + padding_type=padding_type, + name=name, + model_name=model_name, + cur_stage=cur_stage) + + self._dcn = DepthwiseConvNorm( + input_channels * block_args.expand_ratio, + block_args, + padding_type=padding_type, + name=name, + model_name=model_name, + cur_stage=cur_stage) + + if self.has_se: + num_squeezed_channels = max( + 1, int(block_args.input_filters * block_args.se_ratio)) + self._se = SEBlock( + input_channels * block_args.expand_ratio, + num_squeezed_channels, + oup, + padding_type=padding_type, + name=name, + model_name=model_name, + cur_stage=cur_stage) + + self._pcn = ProjectConvNorm( + input_channels * block_args.expand_ratio, + block_args, + padding_type=padding_type, + name=name, + model_name=model_name, + cur_stage=cur_stage) + + def forward(self, inputs): + x = inputs + if self.expand_ratio != 1: + x = self._ecn(x) + x = F.swish(x) + + x = self._dcn(x) + x = F.swish(x) + if self.has_se: + x = self._se(x) + x = self._pcn(x) + + if self.id_skip and \ + self.block_args.stride == 1 and \ + self.block_args.input_filters == self.block_args.output_filters: + if self.drop_connect_rate: + x = _drop_connect(x, self.drop_connect_rate, not self.training) + x = paddle.add(x, inputs) + return x + + +class ConvStemNorm(nn.Layer): + def __init__(self, + input_channels, + padding_type, + _global_params, + name=None, + model_name=None, + cur_stage=None): + super(ConvStemNorm, self).__init__() + + output_channels = round_filters(32, _global_params) + self._conv = ConvBNLayer( + input_channels, + filter_size=3, + output_channels=output_channels, + stride=2, + bn_act=None, + padding_type=padding_type, + name="", + conv_name="_conv_stem", + bn_name="_bn0", + model_name=model_name, + cur_stage=cur_stage) + + def forward(self, inputs): + return self._conv(inputs) + + +class ExtractFeatures(nn.Layer): + def __init__(self, + input_channels, + _block_args, + _global_params, + padding_type, + use_se, + model_name=None): + super(ExtractFeatures, self).__init__() + + self._global_params = _global_params + + self._conv_stem = ConvStemNorm( + input_channels, + padding_type=padding_type, + _global_params=_global_params, + model_name=model_name, + cur_stage=0) + + self.block_args_copy = copy.deepcopy(_block_args) + idx = 0 + block_size = 0 + for block_arg in self.block_args_copy: + block_arg = block_arg._replace( + input_filters=round_filters(block_arg.input_filters, + _global_params), + output_filters=round_filters(block_arg.output_filters, + _global_params), + num_repeat=round_repeats(block_arg.num_repeat, _global_params)) + block_size += 1 + for _ in range(block_arg.num_repeat - 1): + block_size += 1 + + self.conv_seq = [] + cur_stage = 1 + for block_args in _block_args: + block_args = block_args._replace( + input_filters=round_filters(block_args.input_filters, + _global_params), + output_filters=round_filters(block_args.output_filters, + _global_params), + num_repeat=round_repeats(block_args.num_repeat, + _global_params)) + + drop_connect_rate = self._global_params.drop_connect_rate + if drop_connect_rate: + drop_connect_rate *= float(idx) / block_size + + _mc_block = self.add_sublayer( + "_blocks." + str(idx) + ".", + MbConvBlock( + block_args.input_filters, + block_args=block_args, + padding_type=padding_type, + use_se=use_se, + name="_blocks." + str(idx) + ".", + drop_connect_rate=drop_connect_rate, + model_name=model_name, + cur_stage=cur_stage)) + self.conv_seq.append(_mc_block) + idx += 1 + if block_args.num_repeat > 1: + block_args = block_args._replace( + input_filters=block_args.output_filters, stride=1) + for _ in range(block_args.num_repeat - 1): + drop_connect_rate = self._global_params.drop_connect_rate + if drop_connect_rate: + drop_connect_rate *= float(idx) / block_size + _mc_block = self.add_sublayer( + "block." + str(idx) + ".", + MbConvBlock( + block_args.input_filters, + block_args, + padding_type=padding_type, + use_se=use_se, + name="_blocks." + str(idx) + ".", + drop_connect_rate=drop_connect_rate, + model_name=model_name, + cur_stage=cur_stage)) + self.conv_seq.append(_mc_block) + idx += 1 + cur_stage += 1 + + def forward(self, inputs): + x = self._conv_stem(inputs) + x = F.swish(x) + for _mc_block in self.conv_seq: + x = _mc_block(x) + return x + + +class EfficientNet(nn.Layer): + def __init__(self, + name="b0", + padding_type="SAME", + override_params=None, + use_se=True, + class_num=1000): + super(EfficientNet, self).__init__() + + model_name = 'efficientnet-' + name + self.name = name + self._block_args, self._global_params = get_model_params( + model_name, override_params) + self.padding_type = padding_type + self.use_se = use_se + + self._ef = ExtractFeatures( + 3, + self._block_args, + self._global_params, + self.padding_type, + self.use_se, + model_name=self.name) + + output_channels = round_filters(1280, self._global_params) + if name == "b0_small" or name == "b0" or name == "b1": + oup = 320 + elif name == "b2": + oup = 352 + elif name == "b3": + oup = 384 + elif name == "b4": + oup = 448 + elif name == "b5": + oup = 512 + elif name == "b6": + oup = 576 + elif name == "b7": + oup = 640 + self._conv = ConvBNLayer( + oup, + 1, + output_channels, + bn_act="swish", + padding_type=self.padding_type, + name="", + conv_name="_conv_head", + bn_name="_bn1", + model_name=self.name, + cur_stage=7) + self._pool = AdaptiveAvgPool2D(1) + + if self._global_params.dropout_rate: + self._drop = Dropout( + p=self._global_params.dropout_rate, mode="upscale_in_train") + + param_attr, bias_attr = init_fc_layer("_fc") + self._fc = Linear( + output_channels, + class_num, + weight_attr=param_attr, + bias_attr=bias_attr) + + def forward(self, inputs): + x = self._ef(inputs) + x = self._conv(x) + x = self._pool(x) + if self._global_params.dropout_rate: + x = self._drop(x) + x = paddle.squeeze(x, axis=[2, 3]) + x = self._fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def EfficientNetB0_small(padding_type='DYNAMIC', + override_params=None, + use_se=False, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b0', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB0_small"]) + return model + + +def EfficientNetB0(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b0', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB0"]) + return model + + +def EfficientNetB1(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b1', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB1"]) + return model + + +def EfficientNetB2(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b2', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB2"]) + return model + + +def EfficientNetB3(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b3', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB3"]) + return model + + +def EfficientNetB4(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b4', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB4"]) + return model + + +def EfficientNetB5(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b5', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB5"]) + return model + + +def EfficientNetB6(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b6', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB6"]) + return model + + +def EfficientNetB7(padding_type='SAME', + override_params=None, + use_se=True, + pretrained=False, + use_ssld=False, + **kwargs): + model = EfficientNet( + name='b7', + padding_type=padding_type, + override_params=override_params, + use_se=use_se, + **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB7"]) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/ghostnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/ghostnet.py new file mode 100644 index 0000000..4d338c1 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/ghostnet.py @@ -0,0 +1,363 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/huawei-noah/CV-Backbones/tree/master/ghostnet_pytorch + +import math +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, AdaptiveAvgPool2D, Linear +from paddle.regularizer import L2Decay +from paddle.nn.initializer import Uniform, KaimingNormal + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "GhostNet_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x0_5_pretrained.pdparams", + "GhostNet_x1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_0_pretrained.pdparams", + "GhostNet_x1_3": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + groups=1, + act="relu", + name=None): + super(ConvBNLayer, self).__init__() + self._conv = Conv2D( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=(kernel_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr( + initializer=KaimingNormal(), name=name + "_weights"), + bias_attr=False) + bn_name = name + "_bn" + + self._batch_norm = BatchNorm( + num_channels=out_channels, + act=act, + param_attr=ParamAttr( + name=bn_name + "_scale", regularizer=L2Decay(0.0)), + bias_attr=ParamAttr( + name=bn_name + "_offset", regularizer=L2Decay(0.0)), + moving_mean_name=bn_name + "_mean", + moving_variance_name=bn_name + "_variance") + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class SEBlock(nn.Layer): + def __init__(self, num_channels, reduction_ratio=4, name=None): + super(SEBlock, self).__init__() + self.pool2d_gap = AdaptiveAvgPool2D(1) + self._num_channels = num_channels + stdv = 1.0 / math.sqrt(num_channels * 1.0) + med_ch = num_channels // reduction_ratio + self.squeeze = Linear( + num_channels, + med_ch, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_1_weights"), + bias_attr=ParamAttr(name=name + "_1_offset")) + stdv = 1.0 / math.sqrt(med_ch * 1.0) + self.excitation = Linear( + med_ch, + num_channels, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_2_weights"), + bias_attr=ParamAttr(name=name + "_2_offset")) + + def forward(self, inputs): + pool = self.pool2d_gap(inputs) + pool = paddle.squeeze(pool, axis=[2, 3]) + squeeze = self.squeeze(pool) + squeeze = F.relu(squeeze) + excitation = self.excitation(squeeze) + excitation = paddle.clip(x=excitation, min=0, max=1) + excitation = paddle.unsqueeze(excitation, axis=[2, 3]) + out = paddle.multiply(inputs, excitation) + return out + + +class GhostModule(nn.Layer): + def __init__(self, + in_channels, + output_channels, + kernel_size=1, + ratio=2, + dw_size=3, + stride=1, + relu=True, + name=None): + super(GhostModule, self).__init__() + init_channels = int(math.ceil(output_channels / ratio)) + new_channels = int(init_channels * (ratio - 1)) + self.primary_conv = ConvBNLayer( + in_channels=in_channels, + out_channels=init_channels, + kernel_size=kernel_size, + stride=stride, + groups=1, + act="relu" if relu else None, + name=name + "_primary_conv") + self.cheap_operation = ConvBNLayer( + in_channels=init_channels, + out_channels=new_channels, + kernel_size=dw_size, + stride=1, + groups=init_channels, + act="relu" if relu else None, + name=name + "_cheap_operation") + + def forward(self, inputs): + x = self.primary_conv(inputs) + y = self.cheap_operation(x) + out = paddle.concat([x, y], axis=1) + return out + + +class GhostBottleneck(nn.Layer): + def __init__(self, + in_channels, + hidden_dim, + output_channels, + kernel_size, + stride, + use_se, + name=None): + super(GhostBottleneck, self).__init__() + self._stride = stride + self._use_se = use_se + self._num_channels = in_channels + self._output_channels = output_channels + self.ghost_module_1 = GhostModule( + in_channels=in_channels, + output_channels=hidden_dim, + kernel_size=1, + stride=1, + relu=True, + name=name + "_ghost_module_1") + if stride == 2: + self.depthwise_conv = ConvBNLayer( + in_channels=hidden_dim, + out_channels=hidden_dim, + kernel_size=kernel_size, + stride=stride, + groups=hidden_dim, + act=None, + name=name + + "_depthwise_depthwise" # looks strange due to an old typo, will be fixed later. + ) + if use_se: + self.se_block = SEBlock(num_channels=hidden_dim, name=name + "_se") + self.ghost_module_2 = GhostModule( + in_channels=hidden_dim, + output_channels=output_channels, + kernel_size=1, + relu=False, + name=name + "_ghost_module_2") + if stride != 1 or in_channels != output_channels: + self.shortcut_depthwise = ConvBNLayer( + in_channels=in_channels, + out_channels=in_channels, + kernel_size=kernel_size, + stride=stride, + groups=in_channels, + act=None, + name=name + + "_shortcut_depthwise_depthwise" # looks strange due to an old typo, will be fixed later. + ) + self.shortcut_conv = ConvBNLayer( + in_channels=in_channels, + out_channels=output_channels, + kernel_size=1, + stride=1, + groups=1, + act=None, + name=name + "_shortcut_conv") + + def forward(self, inputs): + x = self.ghost_module_1(inputs) + if self._stride == 2: + x = self.depthwise_conv(x) + if self._use_se: + x = self.se_block(x) + x = self.ghost_module_2(x) + if self._stride == 1 and self._num_channels == self._output_channels: + shortcut = inputs + else: + shortcut = self.shortcut_depthwise(inputs) + shortcut = self.shortcut_conv(shortcut) + return paddle.add(x=x, y=shortcut) + + +class GhostNet(nn.Layer): + def __init__(self, scale, class_num=1000): + super(GhostNet, self).__init__() + self.cfgs = [ + # k, t, c, SE, s + [3, 16, 16, 0, 1], + [3, 48, 24, 0, 2], + [3, 72, 24, 0, 1], + [5, 72, 40, 1, 2], + [5, 120, 40, 1, 1], + [3, 240, 80, 0, 2], + [3, 200, 80, 0, 1], + [3, 184, 80, 0, 1], + [3, 184, 80, 0, 1], + [3, 480, 112, 1, 1], + [3, 672, 112, 1, 1], + [5, 672, 160, 1, 2], + [5, 960, 160, 0, 1], + [5, 960, 160, 1, 1], + [5, 960, 160, 0, 1], + [5, 960, 160, 1, 1] + ] + self.scale = scale + output_channels = int(self._make_divisible(16 * self.scale, 4)) + self.conv1 = ConvBNLayer( + in_channels=3, + out_channels=output_channels, + kernel_size=3, + stride=2, + groups=1, + act="relu", + name="conv1") + # build inverted residual blocks + idx = 0 + self.ghost_bottleneck_list = [] + for k, exp_size, c, use_se, s in self.cfgs: + in_channels = output_channels + output_channels = int(self._make_divisible(c * self.scale, 4)) + hidden_dim = int(self._make_divisible(exp_size * self.scale, 4)) + ghost_bottleneck = self.add_sublayer( + name="_ghostbottleneck_" + str(idx), + sublayer=GhostBottleneck( + in_channels=in_channels, + hidden_dim=hidden_dim, + output_channels=output_channels, + kernel_size=k, + stride=s, + use_se=use_se, + name="_ghostbottleneck_" + str(idx))) + self.ghost_bottleneck_list.append(ghost_bottleneck) + idx += 1 + # build last several layers + in_channels = output_channels + output_channels = int(self._make_divisible(exp_size * self.scale, 4)) + self.conv_last = ConvBNLayer( + in_channels=in_channels, + out_channels=output_channels, + kernel_size=1, + stride=1, + groups=1, + act="relu", + name="conv_last") + self.pool2d_gap = AdaptiveAvgPool2D(1) + in_channels = output_channels + self._fc0_output_channels = 1280 + self.fc_0 = ConvBNLayer( + in_channels=in_channels, + out_channels=self._fc0_output_channels, + kernel_size=1, + stride=1, + act="relu", + name="fc_0") + self.dropout = nn.Dropout(p=0.2) + stdv = 1.0 / math.sqrt(self._fc0_output_channels * 1.0) + self.fc_1 = Linear( + self._fc0_output_channels, + class_num, + weight_attr=ParamAttr( + name="fc_1_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr(name="fc_1_offset")) + + def forward(self, inputs): + x = self.conv1(inputs) + for ghost_bottleneck in self.ghost_bottleneck_list: + x = ghost_bottleneck(x) + x = self.conv_last(x) + x = self.pool2d_gap(x) + x = self.fc_0(x) + x = self.dropout(x) + x = paddle.reshape(x, shape=[-1, self._fc0_output_channels]) + x = self.fc_1(x) + return x + + def _make_divisible(self, v, divisor, min_value=None): + """ + This function is taken from the original tf repo. + It ensures that all layers have a channel number that is divisible by 8 + It can be seen here: + https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py + """ + if min_value is None: + min_value = divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + # Make sure that round down does not go down by more than 10%. + if new_v < 0.9 * v: + new_v += divisor + return new_v + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def GhostNet_x0_5(pretrained=False, use_ssld=False, **kwargs): + model = GhostNet(scale=0.5, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["GhostNet_x0_5"], use_ssld=use_ssld) + return model + + +def GhostNet_x1_0(pretrained=False, use_ssld=False, **kwargs): + model = GhostNet(scale=1.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["GhostNet_x1_0"], use_ssld=use_ssld) + return model + + +def GhostNet_x1_3(pretrained=False, use_ssld=False, **kwargs): + model = GhostNet(scale=1.3, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["GhostNet_x1_3"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/googlenet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/googlenet.py new file mode 100644 index 0000000..2252842 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/googlenet.py @@ -0,0 +1,229 @@ +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "GoogLeNet": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GoogLeNet_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +def xavier(channels, filter_size, name): + stdv = (3.0 / (filter_size**2 * channels))**0.5 + param_attr = ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_weights") + return param_attr + + +class ConvLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act=None, + name=None): + super(ConvLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + + def forward(self, inputs): + y = self._conv(inputs) + return y + + +class Inception(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter1, + filter3R, + filter3, + filter5R, + filter5, + proj, + name=None): + super(Inception, self).__init__() + + self._conv1 = ConvLayer( + input_channels, filter1, 1, name="inception_" + name + "_1x1") + self._conv3r = ConvLayer( + input_channels, + filter3R, + 1, + name="inception_" + name + "_3x3_reduce") + self._conv3 = ConvLayer( + filter3R, filter3, 3, name="inception_" + name + "_3x3") + self._conv5r = ConvLayer( + input_channels, + filter5R, + 1, + name="inception_" + name + "_5x5_reduce") + self._conv5 = ConvLayer( + filter5R, filter5, 5, name="inception_" + name + "_5x5") + self._pool = MaxPool2D(kernel_size=3, stride=1, padding=1) + + self._convprj = ConvLayer( + input_channels, proj, 1, name="inception_" + name + "_3x3_proj") + + def forward(self, inputs): + conv1 = self._conv1(inputs) + + conv3r = self._conv3r(inputs) + conv3 = self._conv3(conv3r) + + conv5r = self._conv5r(inputs) + conv5 = self._conv5(conv5r) + + pool = self._pool(inputs) + convprj = self._convprj(pool) + + cat = paddle.concat([conv1, conv3, conv5, convprj], axis=1) + cat = F.relu(cat) + return cat + + +class GoogLeNetDY(nn.Layer): + def __init__(self, class_num=1000): + super(GoogLeNetDY, self).__init__() + self._conv = ConvLayer(3, 64, 7, 2, name="conv1") + self._pool = MaxPool2D(kernel_size=3, stride=2) + self._conv_1 = ConvLayer(64, 64, 1, name="conv2_1x1") + self._conv_2 = ConvLayer(64, 192, 3, name="conv2_3x3") + + self._ince3a = Inception( + 192, 192, 64, 96, 128, 16, 32, 32, name="ince3a") + self._ince3b = Inception( + 256, 256, 128, 128, 192, 32, 96, 64, name="ince3b") + + self._ince4a = Inception( + 480, 480, 192, 96, 208, 16, 48, 64, name="ince4a") + self._ince4b = Inception( + 512, 512, 160, 112, 224, 24, 64, 64, name="ince4b") + self._ince4c = Inception( + 512, 512, 128, 128, 256, 24, 64, 64, name="ince4c") + self._ince4d = Inception( + 512, 512, 112, 144, 288, 32, 64, 64, name="ince4d") + self._ince4e = Inception( + 528, 528, 256, 160, 320, 32, 128, 128, name="ince4e") + + self._ince5a = Inception( + 832, 832, 256, 160, 320, 32, 128, 128, name="ince5a") + self._ince5b = Inception( + 832, 832, 384, 192, 384, 48, 128, 128, name="ince5b") + + self._pool_5 = AdaptiveAvgPool2D(1) + + self._drop = Dropout(p=0.4, mode="downscale_in_infer") + self._fc_out = Linear( + 1024, + class_num, + weight_attr=xavier(1024, 1, "out"), + bias_attr=ParamAttr(name="out_offset")) + self._pool_o1 = AvgPool2D(kernel_size=5, stride=3) + self._conv_o1 = ConvLayer(512, 128, 1, name="conv_o1") + self._fc_o1 = Linear( + 1152, + 1024, + weight_attr=xavier(2048, 1, "fc_o1"), + bias_attr=ParamAttr(name="fc_o1_offset")) + self._drop_o1 = Dropout(p=0.7, mode="downscale_in_infer") + self._out1 = Linear( + 1024, + class_num, + weight_attr=xavier(1024, 1, "out1"), + bias_attr=ParamAttr(name="out1_offset")) + self._pool_o2 = AvgPool2D(kernel_size=5, stride=3) + self._conv_o2 = ConvLayer(528, 128, 1, name="conv_o2") + self._fc_o2 = Linear( + 1152, + 1024, + weight_attr=xavier(2048, 1, "fc_o2"), + bias_attr=ParamAttr(name="fc_o2_offset")) + self._drop_o2 = Dropout(p=0.7, mode="downscale_in_infer") + self._out2 = Linear( + 1024, + class_num, + weight_attr=xavier(1024, 1, "out2"), + bias_attr=ParamAttr(name="out2_offset")) + + def forward(self, inputs): + x = self._conv(inputs) + x = self._pool(x) + x = self._conv_1(x) + x = self._conv_2(x) + x = self._pool(x) + + x = self._ince3a(x) + x = self._ince3b(x) + x = self._pool(x) + + ince4a = self._ince4a(x) + x = self._ince4b(ince4a) + x = self._ince4c(x) + ince4d = self._ince4d(x) + x = self._ince4e(ince4d) + x = self._pool(x) + + x = self._ince5a(x) + ince5b = self._ince5b(x) + + x = self._pool_5(ince5b) + x = self._drop(x) + x = paddle.squeeze(x, axis=[2, 3]) + out = self._fc_out(x) + + x = self._pool_o1(ince4a) + x = self._conv_o1(x) + x = paddle.flatten(x, start_axis=1, stop_axis=-1) + x = self._fc_o1(x) + x = F.relu(x) + x = self._drop_o1(x) + out1 = self._out1(x) + + x = self._pool_o2(ince4d) + x = self._conv_o2(x) + x = paddle.flatten(x, start_axis=1, stop_axis=-1) + x = self._fc_o2(x) + x = self._drop_o2(x) + out2 = self._out2(x) + return [out, out1, out2] + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def GoogLeNet(pretrained=False, use_ssld=False, **kwargs): + model = GoogLeNetDY(**kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["GoogLeNet"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/gvt.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/gvt.py new file mode 100644 index 0000000..2af7ccf --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/gvt.py @@ -0,0 +1,693 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/Meituan-AutoML/Twins + +from functools import partial + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.regularizer import L2Decay + +from .vision_transformer import trunc_normal_, normal_, zeros_, ones_, to_2tuple, DropPath, Identity, Mlp +from .vision_transformer import Block as ViTBlock + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "pcpvt_small": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_small_pretrained.pdparams", + "pcpvt_base": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_base_pretrained.pdparams", + "pcpvt_large": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_large_pretrained.pdparams", + "alt_gvt_small": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_small_pretrained.pdparams", + "alt_gvt_base": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_base_pretrained.pdparams", + "alt_gvt_large": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_large_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class GroupAttention(nn.Layer): + """LSA: self attention within a group. + """ + + def __init__(self, + dim, + num_heads=8, + qkv_bias=False, + qk_scale=None, + attn_drop=0., + proj_drop=0., + ws=1): + super().__init__() + if ws == 1: + raise Exception("ws {ws} should not be 1") + if dim % num_heads != 0: + raise Exception( + "dim {dim} should be divided by num_heads {num_heads}.") + + self.dim = dim + self.num_heads = num_heads + head_dim = dim // num_heads + self.scale = qk_scale or head_dim**-0.5 + + self.qkv = nn.Linear(dim, dim * 3, bias_attr=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + self.ws = ws + + def forward(self, x, H, W): + B, N, C = x.shape + h_group, w_group = H // self.ws, W // self.ws + total_groups = h_group * w_group + x = x.reshape([B, h_group, self.ws, w_group, self.ws, C]).transpose( + [0, 1, 3, 2, 4, 5]) + qkv = self.qkv(x).reshape([ + B, total_groups, self.ws**2, 3, self.num_heads, C // self.num_heads + ]).transpose([3, 0, 1, 4, 2, 5]) + q, k, v = qkv[0], qkv[1], qkv[2] + attn = paddle.matmul(q, k.transpose([0, 1, 2, 4, 3])) * self.scale + + attn = nn.Softmax(axis=-1)(attn) + attn = self.attn_drop(attn) + attn = paddle.matmul(attn, v).transpose([0, 1, 3, 2, 4]).reshape( + [B, h_group, w_group, self.ws, self.ws, C]) + + x = attn.transpose([0, 1, 3, 2, 4, 5]).reshape([B, N, C]) + x = self.proj(x) + x = self.proj_drop(x) + return x + + +class Attention(nn.Layer): + """GSA: using a key to summarize the information for a group to be efficient. + """ + + def __init__(self, + dim, + num_heads=8, + qkv_bias=False, + qk_scale=None, + attn_drop=0., + proj_drop=0., + sr_ratio=1): + super().__init__() + assert dim % num_heads == 0, f"dim {dim} should be divided by num_heads {num_heads}." + + self.dim = dim + self.num_heads = num_heads + head_dim = dim // num_heads + self.scale = qk_scale or head_dim**-0.5 + + self.q = nn.Linear(dim, dim, bias_attr=qkv_bias) + self.kv = nn.Linear(dim, dim * 2, bias_attr=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + + self.sr_ratio = sr_ratio + if sr_ratio > 1: + self.sr = nn.Conv2D( + dim, dim, kernel_size=sr_ratio, stride=sr_ratio) + self.norm = nn.LayerNorm(dim) + + def forward(self, x, H, W): + B, N, C = x.shape + q = self.q(x).reshape( + [B, N, self.num_heads, C // self.num_heads]).transpose( + [0, 2, 1, 3]) + + if self.sr_ratio > 1: + x_ = x.transpose([0, 2, 1]).reshape([B, C, H, W]) + tmp_n = H * W // self.sr_ratio**2 + x_ = self.sr(x_).reshape([B, C, tmp_n]).transpose([0, 2, 1]) + x_ = self.norm(x_) + kv = self.kv(x_).reshape( + [B, tmp_n, 2, self.num_heads, C // self.num_heads]).transpose( + [2, 0, 3, 1, 4]) + else: + kv = self.kv(x).reshape( + [B, N, 2, self.num_heads, C // self.num_heads]).transpose( + [2, 0, 3, 1, 4]) + k, v = kv[0], kv[1] + + attn = paddle.matmul(q, k.transpose([0, 1, 3, 2])) * self.scale + attn = nn.Softmax(axis=-1)(attn) + attn = self.attn_drop(attn) + + x = paddle.matmul(attn, v).transpose([0, 2, 1, 3]).reshape([B, N, C]) + x = self.proj(x) + x = self.proj_drop(x) + return x + + +class Block(nn.Layer): + def __init__(self, + dim, + num_heads, + mlp_ratio=4., + qkv_bias=False, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer=nn.LayerNorm, + sr_ratio=1): + super().__init__() + self.norm1 = norm_layer(dim) + self.attn = Attention( + dim, + num_heads=num_heads, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + attn_drop=attn_drop, + proj_drop=drop, + sr_ratio=sr_ratio) + self.drop_path = DropPath(drop_path) if drop_path > 0. else Identity() + self.norm2 = norm_layer(dim) + mlp_hidden_dim = int(dim * mlp_ratio) + self.mlp = Mlp(in_features=dim, + hidden_features=mlp_hidden_dim, + act_layer=act_layer, + drop=drop) + + def forward(self, x, H, W): + x = x + self.drop_path(self.attn(self.norm1(x), H, W)) + x = x + self.drop_path(self.mlp(self.norm2(x))) + return x + + +class SBlock(ViTBlock): + def __init__(self, + dim, + num_heads, + mlp_ratio=4., + qkv_bias=False, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer=nn.LayerNorm, + sr_ratio=1): + super().__init__(dim, num_heads, mlp_ratio, qkv_bias, qk_scale, drop, + attn_drop, drop_path, act_layer, norm_layer) + + def forward(self, x, H, W): + return super().forward(x) + + +class GroupBlock(ViTBlock): + def __init__(self, + dim, + num_heads, + mlp_ratio=4., + qkv_bias=False, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer=nn.LayerNorm, + sr_ratio=1, + ws=1): + super().__init__(dim, num_heads, mlp_ratio, qkv_bias, qk_scale, drop, + attn_drop, drop_path, act_layer, norm_layer) + del self.attn + if ws == 1: + self.attn = Attention(dim, num_heads, qkv_bias, qk_scale, + attn_drop, drop, sr_ratio) + else: + self.attn = GroupAttention(dim, num_heads, qkv_bias, qk_scale, + attn_drop, drop, ws) + + def forward(self, x, H, W): + x = x + self.drop_path(self.attn(self.norm1(x), H, W)) + x = x + self.drop_path(self.mlp(self.norm2(x))) + return x + + +class PatchEmbed(nn.Layer): + """ Image to Patch Embedding. + """ + + def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768): + super().__init__() + if img_size % patch_size != 0: + raise Exception( + f"img_size {img_size} should be divided by patch_size {patch_size}." + ) + + img_size = to_2tuple(img_size) + patch_size = to_2tuple(patch_size) + + self.img_size = img_size + self.patch_size = patch_size + self.H, self.W = img_size[0] // patch_size[0], img_size[ + 1] // patch_size[1] + self.num_patches = self.H * self.W + self.proj = nn.Conv2D( + in_chans, embed_dim, kernel_size=patch_size, stride=patch_size) + self.norm = nn.LayerNorm(embed_dim) + + def forward(self, x): + B, C, H, W = x.shape + x = self.proj(x).flatten(2).transpose([0, 2, 1]) + x = self.norm(x) + H, W = H // self.patch_size[0], W // self.patch_size[1] + return x, (H, W) + + +# borrow from PVT https://github.com/whai362/PVT.git +class PyramidVisionTransformer(nn.Layer): + def __init__(self, + img_size=224, + patch_size=16, + in_chans=3, + class_num=1000, + embed_dims=[64, 128, 256, 512], + num_heads=[1, 2, 4, 8], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=False, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer=nn.LayerNorm, + depths=[3, 4, 6, 3], + sr_ratios=[8, 4, 2, 1], + block_cls=Block): + super().__init__() + self.class_num = class_num + self.depths = depths + + # patch_embed + self.patch_embeds = nn.LayerList() + self.pos_embeds = nn.ParameterList() + self.pos_drops = nn.LayerList() + self.blocks = nn.LayerList() + + for i in range(len(depths)): + if i == 0: + self.patch_embeds.append( + PatchEmbed(img_size, patch_size, in_chans, embed_dims[i])) + else: + self.patch_embeds.append( + PatchEmbed(img_size // patch_size // 2**(i - 1), 2, + embed_dims[i - 1], embed_dims[i])) + patch_num = self.patch_embeds[i].num_patches + 1 if i == len( + embed_dims) - 1 else self.patch_embeds[i].num_patches + self.pos_embeds.append( + self.create_parameter( + shape=[1, patch_num, embed_dims[i]], + default_initializer=zeros_)) + self.pos_drops.append(nn.Dropout(p=drop_rate)) + + dpr = [ + x.numpy()[0] + for x in paddle.linspace(0, drop_path_rate, sum(depths)) + ] # stochastic depth decay rule + + cur = 0 + for k in range(len(depths)): + _block = nn.LayerList([ + block_cls( + dim=embed_dims[k], + num_heads=num_heads[k], + mlp_ratio=mlp_ratios[k], + qkv_bias=qkv_bias, + qk_scale=qk_scale, + drop=drop_rate, + attn_drop=attn_drop_rate, + drop_path=dpr[cur + i], + norm_layer=norm_layer, + sr_ratio=sr_ratios[k]) for i in range(depths[k]) + ]) + self.blocks.append(_block) + cur += depths[k] + + self.norm = norm_layer(embed_dims[-1]) + + # cls_token + self.cls_token = self.create_parameter( + shape=[1, 1, embed_dims[-1]], + default_initializer=zeros_, + attr=paddle.ParamAttr(regularizer=L2Decay(0.0))) + + # classification head + self.head = nn.Linear(embed_dims[-1], + class_num) if class_num > 0 else Identity() + + # init weights + for pos_emb in self.pos_embeds: + trunc_normal_(pos_emb) + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight) + if isinstance(m, nn.Linear) and m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.LayerNorm): + zeros_(m.bias) + ones_(m.weight) + + def forward_features(self, x): + B = x.shape[0] + for i in range(len(self.depths)): + x, (H, W) = self.patch_embeds[i](x) + if i == len(self.depths) - 1: + cls_tokens = self.cls_token.expand([B, -1, -1]) + x = paddle.concat([cls_tokens, x], dim=1) + x = x + self.pos_embeds[i] + x = self.pos_drops[i](x) + for blk in self.blocks[i]: + x = blk(x, H, W) + if i < len(self.depths) - 1: + x = x.reshape([B, H, W, -1]).transpose( + [0, 3, 1, 2]).contiguous() + x = self.norm(x) + return x[:, 0] + + def forward(self, x): + x = self.forward_features(x) + x = self.head(x) + return x + + +# PEG from https://arxiv.org/abs/2102.10882 +class PosCNN(nn.Layer): + def __init__(self, in_chans, embed_dim=768, s=1): + super().__init__() + self.proj = nn.Sequential( + nn.Conv2D( + in_chans, + embed_dim, + 3, + s, + 1, + bias_attr=paddle.ParamAttr(regularizer=L2Decay(0.0)), + groups=embed_dim, + weight_attr=paddle.ParamAttr(regularizer=L2Decay(0.0)), )) + self.s = s + + def forward(self, x, H, W): + B, N, C = x.shape + feat_token = x + cnn_feat = feat_token.transpose([0, 2, 1]).reshape([B, C, H, W]) + if self.s == 1: + x = self.proj(cnn_feat) + cnn_feat + else: + x = self.proj(cnn_feat) + x = x.flatten(2).transpose([0, 2, 1]) + return x + + +class CPVTV2(PyramidVisionTransformer): + """ + Use useful results from CPVT. PEG and GAP. + Therefore, cls token is no longer required. + PEG is used to encode the absolute position on the fly, which greatly affects the performance when input resolution + changes during the training (such as segmentation, detection) + """ + + def __init__(self, + img_size=224, + patch_size=4, + in_chans=3, + class_num=1000, + embed_dims=[64, 128, 256, 512], + num_heads=[1, 2, 4, 8], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=False, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer=nn.LayerNorm, + depths=[3, 4, 6, 3], + sr_ratios=[8, 4, 2, 1], + block_cls=Block): + super().__init__(img_size, patch_size, in_chans, class_num, embed_dims, + num_heads, mlp_ratios, qkv_bias, qk_scale, drop_rate, + attn_drop_rate, drop_path_rate, norm_layer, depths, + sr_ratios, block_cls) + del self.pos_embeds + del self.cls_token + self.pos_block = nn.LayerList( + [PosCNN(embed_dim, embed_dim) for embed_dim in embed_dims]) + self.apply(self._init_weights) + + def _init_weights(self, m): + import math + if isinstance(m, nn.Linear): + trunc_normal_(m.weight) + if isinstance(m, nn.Linear) and m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.LayerNorm): + zeros_(m.bias) + ones_(m.weight) + elif isinstance(m, nn.Conv2D): + fan_out = m._kernel_size[0] * m._kernel_size[1] * m._out_channels + fan_out //= m._groups + normal_(0, math.sqrt(2.0 / fan_out))(m.weight) + if m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.BatchNorm2D): + m.weight.data.fill_(1.0) + m.bias.data.zero_() + + def forward_features(self, x): + B = x.shape[0] + + for i in range(len(self.depths)): + x, (H, W) = self.patch_embeds[i](x) + x = self.pos_drops[i](x) + + for j, blk in enumerate(self.blocks[i]): + x = blk(x, H, W) + if j == 0: + x = self.pos_block[i](x, H, W) # PEG here + + if i < len(self.depths) - 1: + x = x.reshape([B, H, W, x.shape[-1]]).transpose([0, 3, 1, 2]) + + x = self.norm(x) + return x.mean(axis=1) # GAP here + + +class PCPVT(CPVTV2): + def __init__(self, + img_size=224, + patch_size=4, + in_chans=3, + class_num=1000, + embed_dims=[64, 128, 256], + num_heads=[1, 2, 4], + mlp_ratios=[4, 4, 4], + qkv_bias=False, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer=nn.LayerNorm, + depths=[4, 4, 4], + sr_ratios=[4, 2, 1], + block_cls=SBlock): + super().__init__(img_size, patch_size, in_chans, class_num, embed_dims, + num_heads, mlp_ratios, qkv_bias, qk_scale, drop_rate, + attn_drop_rate, drop_path_rate, norm_layer, depths, + sr_ratios, block_cls) + + +class ALTGVT(PCPVT): + """ + alias Twins-SVT + """ + + def __init__(self, + img_size=224, + patch_size=4, + in_chans=3, + class_num=1000, + embed_dims=[64, 128, 256], + num_heads=[1, 2, 4], + mlp_ratios=[4, 4, 4], + qkv_bias=False, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer=nn.LayerNorm, + depths=[4, 4, 4], + sr_ratios=[4, 2, 1], + block_cls=GroupBlock, + wss=[7, 7, 7]): + super().__init__(img_size, patch_size, in_chans, class_num, embed_dims, + num_heads, mlp_ratios, qkv_bias, qk_scale, drop_rate, + attn_drop_rate, drop_path_rate, norm_layer, depths, + sr_ratios, block_cls) + del self.blocks + self.wss = wss + # transformer encoder + dpr = [ + x.numpy()[0] + for x in paddle.linspace(0, drop_path_rate, sum(depths)) + ] # stochastic depth decay rule + cur = 0 + self.blocks = nn.LayerList() + for k in range(len(depths)): + _block = nn.LayerList([ + block_cls( + dim=embed_dims[k], + num_heads=num_heads[k], + mlp_ratio=mlp_ratios[k], + qkv_bias=qkv_bias, + qk_scale=qk_scale, + drop=drop_rate, + attn_drop=attn_drop_rate, + drop_path=dpr[cur + i], + norm_layer=norm_layer, + sr_ratio=sr_ratios[k], + ws=1 if i % 2 == 1 else wss[k]) for i in range(depths[k]) + ]) + self.blocks.append(_block) + cur += depths[k] + self.apply(self._init_weights) + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def pcpvt_small(pretrained=False, use_ssld=False, **kwargs): + model = CPVTV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 4, 6, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["pcpvt_small"], use_ssld=use_ssld) + return model + + +def pcpvt_base(pretrained=False, use_ssld=False, **kwargs): + model = CPVTV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 4, 18, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["pcpvt_base"], use_ssld=use_ssld) + return model + + +def pcpvt_large(pretrained=False, use_ssld=False, **kwargs): + model = CPVTV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 8, 27, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["pcpvt_large"], use_ssld=use_ssld) + return model + + +def alt_gvt_small(pretrained=False, use_ssld=False, **kwargs): + model = ALTGVT( + patch_size=4, + embed_dims=[64, 128, 256, 512], + num_heads=[2, 4, 8, 16], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[2, 2, 10, 4], + wss=[7, 7, 7, 7], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["alt_gvt_small"], use_ssld=use_ssld) + return model + + +def alt_gvt_base(pretrained=False, use_ssld=False, **kwargs): + model = ALTGVT( + patch_size=4, + embed_dims=[96, 192, 384, 768], + num_heads=[3, 6, 12, 24], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[2, 2, 18, 2], + wss=[7, 7, 7, 7], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["alt_gvt_base"], use_ssld=use_ssld) + return model + + +def alt_gvt_large(pretrained=False, use_ssld=False, **kwargs): + model = ALTGVT( + patch_size=4, + embed_dims=[128, 256, 512, 1024], + num_heads=[4, 8, 16, 32], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[2, 2, 18, 2], + wss=[7, 7, 7, 7], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["alt_gvt_large"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/hardnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/hardnet.py new file mode 100644 index 0000000..fffd3a4 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/hardnet.py @@ -0,0 +1,293 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/PingoLH/Pytorch-HarDNet + +import paddle +import paddle.nn as nn + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + 'HarDNet39_ds': + 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet39_ds_pretrained.pdparams', + 'HarDNet68_ds': + 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_ds_pretrained.pdparams', + 'HarDNet68': + 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_pretrained.pdparams', + 'HarDNet85': + 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet85_pretrained.pdparams' +} + +__all__ = MODEL_URLS.keys() + + +def ConvLayer(in_channels, + out_channels, + kernel_size=3, + stride=1, + bias_attr=False): + layer = nn.Sequential( + ('conv', nn.Conv2D( + in_channels, + out_channels, + kernel_size=kernel_size, + stride=stride, + padding=kernel_size // 2, + groups=1, + bias_attr=bias_attr)), ('norm', nn.BatchNorm2D(out_channels)), + ('relu', nn.ReLU6())) + return layer + + +def DWConvLayer(in_channels, + out_channels, + kernel_size=3, + stride=1, + bias_attr=False): + layer = nn.Sequential( + ('dwconv', nn.Conv2D( + in_channels, + out_channels, + kernel_size=kernel_size, + stride=stride, + padding=1, + groups=out_channels, + bias_attr=bias_attr)), ('norm', nn.BatchNorm2D(out_channels))) + return layer + + +def CombConvLayer(in_channels, out_channels, kernel_size=1, stride=1): + layer = nn.Sequential( + ('layer1', ConvLayer( + in_channels, out_channels, kernel_size=kernel_size)), + ('layer2', DWConvLayer( + out_channels, out_channels, stride=stride))) + return layer + + +class HarDBlock(nn.Layer): + def __init__(self, + in_channels, + growth_rate, + grmul, + n_layers, + keepBase=False, + residual_out=False, + dwconv=False): + super().__init__() + self.keepBase = keepBase + self.links = [] + layers_ = [] + self.out_channels = 0 # if upsample else in_channels + for i in range(n_layers): + outch, inch, link = self.get_link(i + 1, in_channels, growth_rate, + grmul) + self.links.append(link) + if dwconv: + layers_.append(CombConvLayer(inch, outch)) + else: + layers_.append(ConvLayer(inch, outch)) + + if (i % 2 == 0) or (i == n_layers - 1): + self.out_channels += outch + # print("Blk out =",self.out_channels) + self.layers = nn.LayerList(layers_) + + def get_link(self, layer, base_ch, growth_rate, grmul): + if layer == 0: + return base_ch, 0, [] + out_channels = growth_rate + + link = [] + for i in range(10): + dv = 2**i + if layer % dv == 0: + k = layer - dv + link.append(k) + if i > 0: + out_channels *= grmul + + out_channels = int(int(out_channels + 1) / 2) * 2 + in_channels = 0 + + for i in link: + ch, _, _ = self.get_link(i, base_ch, growth_rate, grmul) + in_channels += ch + + return out_channels, in_channels, link + + def forward(self, x): + layers_ = [x] + + for layer in range(len(self.layers)): + link = self.links[layer] + tin = [] + for i in link: + tin.append(layers_[i]) + if len(tin) > 1: + x = paddle.concat(tin, 1) + else: + x = tin[0] + out = self.layers[layer](x) + layers_.append(out) + + t = len(layers_) + out_ = [] + for i in range(t): + if (i == 0 and self.keepBase) or (i == t - 1) or (i % 2 == 1): + out_.append(layers_[i]) + out = paddle.concat(out_, 1) + + return out + + +class HarDNet(nn.Layer): + def __init__(self, + depth_wise=False, + arch=85, + class_num=1000, + with_pool=True): + super().__init__() + first_ch = [32, 64] + second_kernel = 3 + max_pool = True + grmul = 1.7 + drop_rate = 0.1 + + # HarDNet68 + ch_list = [128, 256, 320, 640, 1024] + gr = [14, 16, 20, 40, 160] + n_layers = [8, 16, 16, 16, 4] + downSamp = [1, 0, 1, 1, 0] + + if arch == 85: + # HarDNet85 + first_ch = [48, 96] + ch_list = [192, 256, 320, 480, 720, 1280] + gr = [24, 24, 28, 36, 48, 256] + n_layers = [8, 16, 16, 16, 16, 4] + downSamp = [1, 0, 1, 0, 1, 0] + drop_rate = 0.2 + + elif arch == 39: + # HarDNet39 + first_ch = [24, 48] + ch_list = [96, 320, 640, 1024] + grmul = 1.6 + gr = [16, 20, 64, 160] + n_layers = [4, 16, 8, 4] + downSamp = [1, 1, 1, 0] + + if depth_wise: + second_kernel = 1 + max_pool = False + drop_rate = 0.05 + + blks = len(n_layers) + self.base = nn.LayerList([]) + + # First Layer: Standard Conv3x3, Stride=2 + self.base.append( + ConvLayer( + in_channels=3, + out_channels=first_ch[0], + kernel_size=3, + stride=2, + bias_attr=False)) + + # Second Layer + self.base.append( + ConvLayer( + first_ch[0], first_ch[1], kernel_size=second_kernel)) + + # Maxpooling or DWConv3x3 downsampling + if max_pool: + self.base.append(nn.MaxPool2D(kernel_size=3, stride=2, padding=1)) + else: + self.base.append(DWConvLayer(first_ch[1], first_ch[1], stride=2)) + + # Build all HarDNet blocks + ch = first_ch[1] + for i in range(blks): + blk = HarDBlock(ch, gr[i], grmul, n_layers[i], dwconv=depth_wise) + ch = blk.out_channels + self.base.append(blk) + + if i == blks - 1 and arch == 85: + self.base.append(nn.Dropout(0.1)) + + self.base.append(ConvLayer(ch, ch_list[i], kernel_size=1)) + ch = ch_list[i] + if downSamp[i] == 1: + if max_pool: + self.base.append(nn.MaxPool2D(kernel_size=2, stride=2)) + else: + self.base.append(DWConvLayer(ch, ch, stride=2)) + + ch = ch_list[blks - 1] + + layers = [] + + if with_pool: + layers.append(nn.AdaptiveAvgPool2D((1, 1))) + + if class_num > 0: + layers.append(nn.Flatten()) + layers.append(nn.Dropout(drop_rate)) + layers.append(nn.Linear(ch, class_num)) + + self.base.append(nn.Sequential(*layers)) + + def forward(self, x): + for layer in self.base: + x = layer(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def HarDNet39_ds(pretrained=False, **kwargs): + model = HarDNet(arch=39, depth_wise=True, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HarDNet39_ds"]) + return model + + +def HarDNet68_ds(pretrained=False, **kwargs): + model = HarDNet(arch=68, depth_wise=True, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HarDNet68_ds"]) + return model + + +def HarDNet68(pretrained=False, **kwargs): + model = HarDNet(arch=68, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HarDNet68"]) + return model + + +def HarDNet85(pretrained=False, **kwargs): + model = HarDNet(arch=85, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["HarDNet85"]) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/inception_v4.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/inception_v4.py new file mode 100644 index 0000000..e0460d4 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/inception_v4.py @@ -0,0 +1,477 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "InceptionV4": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/InceptionV4_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + padding=0, + groups=1, + act='relu', + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + bn_name = name + "_bn" + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + "_scale"), + bias_attr=ParamAttr(name=bn_name + "_offset"), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class InceptionStem(nn.Layer): + def __init__(self): + super(InceptionStem, self).__init__() + self._conv_1 = ConvBNLayer( + 3, 32, 3, stride=2, act="relu", name="conv1_3x3_s2") + self._conv_2 = ConvBNLayer(32, 32, 3, act="relu", name="conv2_3x3_s1") + self._conv_3 = ConvBNLayer( + 32, 64, 3, padding=1, act="relu", name="conv3_3x3_s1") + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + self._conv2 = ConvBNLayer( + 64, 96, 3, stride=2, act="relu", name="inception_stem1_3x3_s2") + self._conv1_1 = ConvBNLayer( + 160, 64, 1, act="relu", name="inception_stem2_3x3_reduce") + self._conv1_2 = ConvBNLayer( + 64, 96, 3, act="relu", name="inception_stem2_3x3") + self._conv2_1 = ConvBNLayer( + 160, 64, 1, act="relu", name="inception_stem2_1x7_reduce") + self._conv2_2 = ConvBNLayer( + 64, + 64, (7, 1), + padding=(3, 0), + act="relu", + name="inception_stem2_1x7") + self._conv2_3 = ConvBNLayer( + 64, + 64, (1, 7), + padding=(0, 3), + act="relu", + name="inception_stem2_7x1") + self._conv2_4 = ConvBNLayer( + 64, 96, 3, act="relu", name="inception_stem2_3x3_2") + self._conv3 = ConvBNLayer( + 192, 192, 3, stride=2, act="relu", name="inception_stem3_3x3_s2") + + def forward(self, inputs): + conv = self._conv_1(inputs) + conv = self._conv_2(conv) + conv = self._conv_3(conv) + + pool1 = self._pool(conv) + conv2 = self._conv2(conv) + concat = paddle.concat([pool1, conv2], axis=1) + + conv1 = self._conv1_1(concat) + conv1 = self._conv1_2(conv1) + + conv2 = self._conv2_1(concat) + conv2 = self._conv2_2(conv2) + conv2 = self._conv2_3(conv2) + conv2 = self._conv2_4(conv2) + + concat = paddle.concat([conv1, conv2], axis=1) + + conv1 = self._conv3(concat) + pool1 = self._pool(concat) + + concat = paddle.concat([conv1, pool1], axis=1) + return concat + + +class InceptionA(nn.Layer): + def __init__(self, name): + super(InceptionA, self).__init__() + self._pool = AvgPool2D(kernel_size=3, stride=1, padding=1) + self._conv1 = ConvBNLayer( + 384, 96, 1, act="relu", name="inception_a" + name + "_1x1") + self._conv2 = ConvBNLayer( + 384, 96, 1, act="relu", name="inception_a" + name + "_1x1_2") + self._conv3_1 = ConvBNLayer( + 384, 64, 1, act="relu", name="inception_a" + name + "_3x3_reduce") + self._conv3_2 = ConvBNLayer( + 64, + 96, + 3, + padding=1, + act="relu", + name="inception_a" + name + "_3x3") + self._conv4_1 = ConvBNLayer( + 384, + 64, + 1, + act="relu", + name="inception_a" + name + "_3x3_2_reduce") + self._conv4_2 = ConvBNLayer( + 64, + 96, + 3, + padding=1, + act="relu", + name="inception_a" + name + "_3x3_2") + self._conv4_3 = ConvBNLayer( + 96, + 96, + 3, + padding=1, + act="relu", + name="inception_a" + name + "_3x3_3") + + def forward(self, inputs): + pool1 = self._pool(inputs) + conv1 = self._conv1(pool1) + + conv2 = self._conv2(inputs) + + conv3 = self._conv3_1(inputs) + conv3 = self._conv3_2(conv3) + + conv4 = self._conv4_1(inputs) + conv4 = self._conv4_2(conv4) + conv4 = self._conv4_3(conv4) + + concat = paddle.concat([conv1, conv2, conv3, conv4], axis=1) + return concat + + +class ReductionA(nn.Layer): + def __init__(self): + super(ReductionA, self).__init__() + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + self._conv2 = ConvBNLayer( + 384, 384, 3, stride=2, act="relu", name="reduction_a_3x3") + self._conv3_1 = ConvBNLayer( + 384, 192, 1, act="relu", name="reduction_a_3x3_2_reduce") + self._conv3_2 = ConvBNLayer( + 192, 224, 3, padding=1, act="relu", name="reduction_a_3x3_2") + self._conv3_3 = ConvBNLayer( + 224, 256, 3, stride=2, act="relu", name="reduction_a_3x3_3") + + def forward(self, inputs): + pool1 = self._pool(inputs) + conv2 = self._conv2(inputs) + conv3 = self._conv3_1(inputs) + conv3 = self._conv3_2(conv3) + conv3 = self._conv3_3(conv3) + concat = paddle.concat([pool1, conv2, conv3], axis=1) + return concat + + +class InceptionB(nn.Layer): + def __init__(self, name=None): + super(InceptionB, self).__init__() + self._pool = AvgPool2D(kernel_size=3, stride=1, padding=1) + self._conv1 = ConvBNLayer( + 1024, 128, 1, act="relu", name="inception_b" + name + "_1x1") + self._conv2 = ConvBNLayer( + 1024, 384, 1, act="relu", name="inception_b" + name + "_1x1_2") + self._conv3_1 = ConvBNLayer( + 1024, + 192, + 1, + act="relu", + name="inception_b" + name + "_1x7_reduce") + self._conv3_2 = ConvBNLayer( + 192, + 224, (1, 7), + padding=(0, 3), + act="relu", + name="inception_b" + name + "_1x7") + self._conv3_3 = ConvBNLayer( + 224, + 256, (7, 1), + padding=(3, 0), + act="relu", + name="inception_b" + name + "_7x1") + self._conv4_1 = ConvBNLayer( + 1024, + 192, + 1, + act="relu", + name="inception_b" + name + "_7x1_2_reduce") + self._conv4_2 = ConvBNLayer( + 192, + 192, (1, 7), + padding=(0, 3), + act="relu", + name="inception_b" + name + "_1x7_2") + self._conv4_3 = ConvBNLayer( + 192, + 224, (7, 1), + padding=(3, 0), + act="relu", + name="inception_b" + name + "_7x1_2") + self._conv4_4 = ConvBNLayer( + 224, + 224, (1, 7), + padding=(0, 3), + act="relu", + name="inception_b" + name + "_1x7_3") + self._conv4_5 = ConvBNLayer( + 224, + 256, (7, 1), + padding=(3, 0), + act="relu", + name="inception_b" + name + "_7x1_3") + + def forward(self, inputs): + pool1 = self._pool(inputs) + conv1 = self._conv1(pool1) + + conv2 = self._conv2(inputs) + + conv3 = self._conv3_1(inputs) + conv3 = self._conv3_2(conv3) + conv3 = self._conv3_3(conv3) + + conv4 = self._conv4_1(inputs) + conv4 = self._conv4_2(conv4) + conv4 = self._conv4_3(conv4) + conv4 = self._conv4_4(conv4) + conv4 = self._conv4_5(conv4) + + concat = paddle.concat([conv1, conv2, conv3, conv4], axis=1) + return concat + + +class ReductionB(nn.Layer): + def __init__(self): + super(ReductionB, self).__init__() + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + self._conv2_1 = ConvBNLayer( + 1024, 192, 1, act="relu", name="reduction_b_3x3_reduce") + self._conv2_2 = ConvBNLayer( + 192, 192, 3, stride=2, act="relu", name="reduction_b_3x3") + self._conv3_1 = ConvBNLayer( + 1024, 256, 1, act="relu", name="reduction_b_1x7_reduce") + self._conv3_2 = ConvBNLayer( + 256, + 256, (1, 7), + padding=(0, 3), + act="relu", + name="reduction_b_1x7") + self._conv3_3 = ConvBNLayer( + 256, + 320, (7, 1), + padding=(3, 0), + act="relu", + name="reduction_b_7x1") + self._conv3_4 = ConvBNLayer( + 320, 320, 3, stride=2, act="relu", name="reduction_b_3x3_2") + + def forward(self, inputs): + pool1 = self._pool(inputs) + + conv2 = self._conv2_1(inputs) + conv2 = self._conv2_2(conv2) + + conv3 = self._conv3_1(inputs) + conv3 = self._conv3_2(conv3) + conv3 = self._conv3_3(conv3) + conv3 = self._conv3_4(conv3) + + concat = paddle.concat([pool1, conv2, conv3], axis=1) + + return concat + + +class InceptionC(nn.Layer): + def __init__(self, name=None): + super(InceptionC, self).__init__() + self._pool = AvgPool2D(kernel_size=3, stride=1, padding=1) + self._conv1 = ConvBNLayer( + 1536, 256, 1, act="relu", name="inception_c" + name + "_1x1") + self._conv2 = ConvBNLayer( + 1536, 256, 1, act="relu", name="inception_c" + name + "_1x1_2") + self._conv3_0 = ConvBNLayer( + 1536, 384, 1, act="relu", name="inception_c" + name + "_1x1_3") + self._conv3_1 = ConvBNLayer( + 384, + 256, (1, 3), + padding=(0, 1), + act="relu", + name="inception_c" + name + "_1x3") + self._conv3_2 = ConvBNLayer( + 384, + 256, (3, 1), + padding=(1, 0), + act="relu", + name="inception_c" + name + "_3x1") + self._conv4_0 = ConvBNLayer( + 1536, 384, 1, act="relu", name="inception_c" + name + "_1x1_4") + self._conv4_00 = ConvBNLayer( + 384, + 448, (1, 3), + padding=(0, 1), + act="relu", + name="inception_c" + name + "_1x3_2") + self._conv4_000 = ConvBNLayer( + 448, + 512, (3, 1), + padding=(1, 0), + act="relu", + name="inception_c" + name + "_3x1_2") + self._conv4_1 = ConvBNLayer( + 512, + 256, (1, 3), + padding=(0, 1), + act="relu", + name="inception_c" + name + "_1x3_3") + self._conv4_2 = ConvBNLayer( + 512, + 256, (3, 1), + padding=(1, 0), + act="relu", + name="inception_c" + name + "_3x1_3") + + def forward(self, inputs): + pool1 = self._pool(inputs) + conv1 = self._conv1(pool1) + + conv2 = self._conv2(inputs) + + conv3 = self._conv3_0(inputs) + conv3_1 = self._conv3_1(conv3) + conv3_2 = self._conv3_2(conv3) + + conv4 = self._conv4_0(inputs) + conv4 = self._conv4_00(conv4) + conv4 = self._conv4_000(conv4) + conv4_1 = self._conv4_1(conv4) + conv4_2 = self._conv4_2(conv4) + + concat = paddle.concat( + [conv1, conv2, conv3_1, conv3_2, conv4_1, conv4_2], axis=1) + + return concat + + +class InceptionV4DY(nn.Layer): + def __init__(self, class_num=1000): + super(InceptionV4DY, self).__init__() + self._inception_stem = InceptionStem() + + self._inceptionA_1 = InceptionA(name="1") + self._inceptionA_2 = InceptionA(name="2") + self._inceptionA_3 = InceptionA(name="3") + self._inceptionA_4 = InceptionA(name="4") + self._reductionA = ReductionA() + + self._inceptionB_1 = InceptionB(name="1") + self._inceptionB_2 = InceptionB(name="2") + self._inceptionB_3 = InceptionB(name="3") + self._inceptionB_4 = InceptionB(name="4") + self._inceptionB_5 = InceptionB(name="5") + self._inceptionB_6 = InceptionB(name="6") + self._inceptionB_7 = InceptionB(name="7") + self._reductionB = ReductionB() + + self._inceptionC_1 = InceptionC(name="1") + self._inceptionC_2 = InceptionC(name="2") + self._inceptionC_3 = InceptionC(name="3") + + self.avg_pool = AdaptiveAvgPool2D(1) + self._drop = Dropout(p=0.2, mode="downscale_in_infer") + stdv = 1.0 / math.sqrt(1536 * 1.0) + self.out = Linear( + 1536, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="final_fc_weights"), + bias_attr=ParamAttr(name="final_fc_offset")) + + def forward(self, inputs): + x = self._inception_stem(inputs) + + x = self._inceptionA_1(x) + x = self._inceptionA_2(x) + x = self._inceptionA_3(x) + x = self._inceptionA_4(x) + x = self._reductionA(x) + + x = self._inceptionB_1(x) + x = self._inceptionB_2(x) + x = self._inceptionB_3(x) + x = self._inceptionB_4(x) + x = self._inceptionB_5(x) + x = self._inceptionB_6(x) + x = self._inceptionB_7(x) + x = self._reductionB(x) + + x = self._inceptionC_1(x) + x = self._inceptionC_2(x) + x = self._inceptionC_3(x) + + x = self.avg_pool(x) + x = paddle.squeeze(x, axis=[2, 3]) + x = self._drop(x) + x = self.out(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def InceptionV4(pretrained=False, use_ssld=False, **kwargs): + model = InceptionV4DY(**kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["InceptionV4"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/levit.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/levit.py new file mode 100644 index 0000000..991f832 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/levit.py @@ -0,0 +1,589 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/facebookresearch/LeViT + +import itertools +import math +import warnings + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn.initializer import TruncatedNormal, Constant +from paddle.regularizer import L2Decay + +from .vision_transformer import trunc_normal_, zeros_, ones_, Identity + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "LeViT_128S": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128S_pretrained.pdparams", + "LeViT_128": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128_pretrained.pdparams", + "LeViT_192": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_192_pretrained.pdparams", + "LeViT_256": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_256_pretrained.pdparams", + "LeViT_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_384_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +def cal_attention_biases(attention_biases, attention_bias_idxs): + gather_list = [] + attention_bias_t = paddle.transpose(attention_biases, (1, 0)) + nums = attention_bias_idxs.shape[0] + for idx in range(nums): + gather = paddle.gather(attention_bias_t, attention_bias_idxs[idx]) + gather_list.append(gather) + shape0, shape1 = attention_bias_idxs.shape + gather = paddle.concat(gather_list) + return paddle.transpose(gather, (1, 0)).reshape((0, shape0, shape1)) + + +class Conv2d_BN(nn.Sequential): + def __init__(self, + a, + b, + ks=1, + stride=1, + pad=0, + dilation=1, + groups=1, + bn_weight_init=1, + resolution=-10000): + super().__init__() + self.add_sublayer( + 'c', + nn.Conv2D( + a, b, ks, stride, pad, dilation, groups, bias_attr=False)) + bn = nn.BatchNorm2D(b) + ones_(bn.weight) + zeros_(bn.bias) + self.add_sublayer('bn', bn) + + +class Linear_BN(nn.Sequential): + def __init__(self, a, b, bn_weight_init=1): + super().__init__() + self.add_sublayer('c', nn.Linear(a, b, bias_attr=False)) + bn = nn.BatchNorm1D(b) + if bn_weight_init == 0: + zeros_(bn.weight) + else: + ones_(bn.weight) + zeros_(bn.bias) + self.add_sublayer('bn', bn) + + def forward(self, x): + l, bn = self._sub_layers.values() + x = l(x) + return paddle.reshape(bn(x.flatten(0, 1)), x.shape) + + +class BN_Linear(nn.Sequential): + def __init__(self, a, b, bias=True, std=0.02): + super().__init__() + self.add_sublayer('bn', nn.BatchNorm1D(a)) + l = nn.Linear(a, b, bias_attr=bias) + trunc_normal_(l.weight) + if bias: + zeros_(l.bias) + self.add_sublayer('l', l) + + +def b16(n, activation, resolution=224): + return nn.Sequential( + Conv2d_BN( + 3, n // 8, 3, 2, 1, resolution=resolution), + activation(), + Conv2d_BN( + n // 8, n // 4, 3, 2, 1, resolution=resolution // 2), + activation(), + Conv2d_BN( + n // 4, n // 2, 3, 2, 1, resolution=resolution // 4), + activation(), + Conv2d_BN( + n // 2, n, 3, 2, 1, resolution=resolution // 8)) + + +class Residual(nn.Layer): + def __init__(self, m, drop): + super().__init__() + self.m = m + self.drop = drop + + def forward(self, x): + if self.training and self.drop > 0: + y = paddle.rand( + shape=[x.shape[0], 1, 1]).__ge__(self.drop).astype("float32") + y = y.divide(paddle.full_like(y, 1 - self.drop)) + return paddle.add(x, y) + else: + return paddle.add(x, self.m(x)) + + +class Attention(nn.Layer): + def __init__(self, + dim, + key_dim, + num_heads=8, + attn_ratio=4, + activation=None, + resolution=14): + super().__init__() + self.num_heads = num_heads + self.scale = key_dim**-0.5 + self.key_dim = key_dim + self.nh_kd = nh_kd = key_dim * num_heads + self.d = int(attn_ratio * key_dim) + self.dh = int(attn_ratio * key_dim) * num_heads + self.attn_ratio = attn_ratio + self.h = self.dh + nh_kd * 2 + self.qkv = Linear_BN(dim, self.h) + self.proj = nn.Sequential( + activation(), Linear_BN( + self.dh, dim, bn_weight_init=0)) + points = list(itertools.product(range(resolution), range(resolution))) + N = len(points) + attention_offsets = {} + idxs = [] + for p1 in points: + for p2 in points: + offset = (abs(p1[0] - p2[0]), abs(p1[1] - p2[1])) + if offset not in attention_offsets: + attention_offsets[offset] = len(attention_offsets) + idxs.append(attention_offsets[offset]) + self.attention_biases = self.create_parameter( + shape=(num_heads, len(attention_offsets)), + default_initializer=zeros_, + attr=paddle.ParamAttr(regularizer=L2Decay(0.0))) + tensor_idxs = paddle.to_tensor(idxs, dtype='int64') + self.register_buffer('attention_bias_idxs', + paddle.reshape(tensor_idxs, [N, N])) + + @paddle.no_grad() + def train(self, mode=True): + if mode: + super().train() + else: + super().eval() + if mode and hasattr(self, 'ab'): + del self.ab + else: + self.ab = cal_attention_biases(self.attention_biases, + self.attention_bias_idxs) + + def forward(self, x): + self.training = True + B, N, C = x.shape + qkv = self.qkv(x) + qkv = paddle.reshape(qkv, + [B, N, self.num_heads, self.h // self.num_heads]) + q, k, v = paddle.split( + qkv, [self.key_dim, self.key_dim, self.d], axis=3) + q = paddle.transpose(q, perm=[0, 2, 1, 3]) + k = paddle.transpose(k, perm=[0, 2, 1, 3]) + v = paddle.transpose(v, perm=[0, 2, 1, 3]) + k_transpose = paddle.transpose(k, perm=[0, 1, 3, 2]) + + if self.training: + attention_biases = cal_attention_biases(self.attention_biases, + self.attention_bias_idxs) + else: + attention_biases = self.ab + attn = (paddle.matmul(q, k_transpose) * self.scale + attention_biases) + attn = F.softmax(attn) + x = paddle.transpose(paddle.matmul(attn, v), perm=[0, 2, 1, 3]) + x = paddle.reshape(x, [B, N, self.dh]) + x = self.proj(x) + return x + + +class Subsample(nn.Layer): + def __init__(self, stride, resolution): + super().__init__() + self.stride = stride + self.resolution = resolution + + def forward(self, x): + B, N, C = x.shape + x = paddle.reshape(x, [B, self.resolution, self.resolution, C]) + end1, end2 = x.shape[1], x.shape[2] + x = x[:, 0:end1:self.stride, 0:end2:self.stride] + x = paddle.reshape(x, [B, -1, C]) + return x + + +class AttentionSubsample(nn.Layer): + def __init__(self, + in_dim, + out_dim, + key_dim, + num_heads=8, + attn_ratio=2, + activation=None, + stride=2, + resolution=14, + resolution_=7): + super().__init__() + self.num_heads = num_heads + self.scale = key_dim**-0.5 + self.key_dim = key_dim + self.nh_kd = nh_kd = key_dim * num_heads + self.d = int(attn_ratio * key_dim) + self.dh = int(attn_ratio * key_dim) * self.num_heads + self.attn_ratio = attn_ratio + self.resolution_ = resolution_ + self.resolution_2 = resolution_**2 + self.training = True + h = self.dh + nh_kd + self.kv = Linear_BN(in_dim, h) + + self.q = nn.Sequential( + Subsample(stride, resolution), Linear_BN(in_dim, nh_kd)) + self.proj = nn.Sequential(activation(), Linear_BN(self.dh, out_dim)) + + self.stride = stride + self.resolution = resolution + points = list(itertools.product(range(resolution), range(resolution))) + points_ = list( + itertools.product(range(resolution_), range(resolution_))) + + N = len(points) + N_ = len(points_) + attention_offsets = {} + idxs = [] + i = 0 + j = 0 + for p1 in points_: + i += 1 + for p2 in points: + j += 1 + size = 1 + offset = (abs(p1[0] * stride - p2[0] + (size - 1) / 2), + abs(p1[1] * stride - p2[1] + (size - 1) / 2)) + if offset not in attention_offsets: + attention_offsets[offset] = len(attention_offsets) + idxs.append(attention_offsets[offset]) + self.attention_biases = self.create_parameter( + shape=(num_heads, len(attention_offsets)), + default_initializer=zeros_, + attr=paddle.ParamAttr(regularizer=L2Decay(0.0))) + + tensor_idxs_ = paddle.to_tensor(idxs, dtype='int64') + self.register_buffer('attention_bias_idxs', + paddle.reshape(tensor_idxs_, [N_, N])) + + @paddle.no_grad() + def train(self, mode=True): + if mode: + super().train() + else: + super().eval() + if mode and hasattr(self, 'ab'): + del self.ab + else: + self.ab = cal_attention_biases(self.attention_biases, + self.attention_bias_idxs) + + def forward(self, x): + self.training = True + B, N, C = x.shape + kv = self.kv(x) + kv = paddle.reshape(kv, [B, N, self.num_heads, -1]) + k, v = paddle.split(kv, [self.key_dim, self.d], axis=3) + k = paddle.transpose(k, perm=[0, 2, 1, 3]) # BHNC + v = paddle.transpose(v, perm=[0, 2, 1, 3]) + q = paddle.reshape( + self.q(x), [B, self.resolution_2, self.num_heads, self.key_dim]) + q = paddle.transpose(q, perm=[0, 2, 1, 3]) + + if self.training: + attention_biases = cal_attention_biases(self.attention_biases, + self.attention_bias_idxs) + else: + attention_biases = self.ab + + attn = (paddle.matmul( + q, paddle.transpose( + k, perm=[0, 1, 3, 2]))) * self.scale + attention_biases + attn = F.softmax(attn) + + x = paddle.reshape( + paddle.transpose( + paddle.matmul(attn, v), perm=[0, 2, 1, 3]), [B, -1, self.dh]) + x = self.proj(x) + return x + + +class LeViT(nn.Layer): + """ Vision Transformer with support for patch or hybrid CNN input stage + """ + + def __init__(self, + img_size=224, + patch_size=16, + in_chans=3, + class_num=1000, + embed_dim=[192], + key_dim=[64], + depth=[12], + num_heads=[3], + attn_ratio=[2], + mlp_ratio=[2], + hybrid_backbone=None, + down_ops=[], + attention_activation=nn.Hardswish, + mlp_activation=nn.Hardswish, + distillation=True, + drop_path=0): + super().__init__() + + self.class_num = class_num + self.num_features = embed_dim[-1] + self.embed_dim = embed_dim + self.distillation = distillation + + self.patch_embed = hybrid_backbone + + self.blocks = [] + down_ops.append(['']) + resolution = img_size // patch_size + for i, (ed, kd, dpth, nh, ar, mr, do) in enumerate( + zip(embed_dim, key_dim, depth, num_heads, attn_ratio, + mlp_ratio, down_ops)): + for _ in range(dpth): + self.blocks.append( + Residual( + Attention( + ed, + kd, + nh, + attn_ratio=ar, + activation=attention_activation, + resolution=resolution, ), + drop_path)) + if mr > 0: + h = int(ed * mr) + self.blocks.append( + Residual( + nn.Sequential( + Linear_BN(ed, h), + mlp_activation(), + Linear_BN( + h, ed, bn_weight_init=0), ), + drop_path)) + if do[0] == 'Subsample': + #('Subsample',key_dim, num_heads, attn_ratio, mlp_ratio, stride) + resolution_ = (resolution - 1) // do[5] + 1 + self.blocks.append( + AttentionSubsample( + *embed_dim[i:i + 2], + key_dim=do[1], + num_heads=do[2], + attn_ratio=do[3], + activation=attention_activation, + stride=do[5], + resolution=resolution, + resolution_=resolution_)) + resolution = resolution_ + if do[4] > 0: # mlp_ratio + h = int(embed_dim[i + 1] * do[4]) + self.blocks.append( + Residual( + nn.Sequential( + Linear_BN(embed_dim[i + 1], h), + mlp_activation(), + Linear_BN( + h, embed_dim[i + 1], bn_weight_init=0), ), + drop_path)) + self.blocks = nn.Sequential(*self.blocks) + + # Classifier head + self.head = BN_Linear(embed_dim[-1], + class_num) if class_num > 0 else Identity() + if distillation: + self.head_dist = BN_Linear( + embed_dim[-1], class_num) if class_num > 0 else Identity() + + def forward(self, x): + x = self.patch_embed(x) + x = x.flatten(2) + x = paddle.transpose(x, perm=[0, 2, 1]) + x = self.blocks(x) + x = x.mean(1) + + x = paddle.reshape(x, [-1, self.embed_dim[-1]]) + if self.distillation: + x = self.head(x), self.head_dist(x) + if not self.training: + x = (x[0] + x[1]) / 2 + else: + x = self.head(x) + return x + + +def model_factory(C, D, X, N, drop_path, class_num, distillation): + embed_dim = [int(x) for x in C.split('_')] + num_heads = [int(x) for x in N.split('_')] + depth = [int(x) for x in X.split('_')] + act = nn.Hardswish + model = LeViT( + patch_size=16, + embed_dim=embed_dim, + num_heads=num_heads, + key_dim=[D] * 3, + depth=depth, + attn_ratio=[2, 2, 2], + mlp_ratio=[2, 2, 2], + down_ops=[ + #('Subsample',key_dim, num_heads, attn_ratio, mlp_ratio, stride) + ['Subsample', D, embed_dim[0] // D, 4, 2, 2], + ['Subsample', D, embed_dim[1] // D, 4, 2, 2], + ], + attention_activation=act, + mlp_activation=act, + hybrid_backbone=b16(embed_dim[0], activation=act), + class_num=class_num, + drop_path=drop_path, + distillation=distillation) + + return model + + +specification = { + 'LeViT_128S': { + 'C': '128_256_384', + 'D': 16, + 'N': '4_6_8', + 'X': '2_3_4', + 'drop_path': 0 + }, + 'LeViT_128': { + 'C': '128_256_384', + 'D': 16, + 'N': '4_8_12', + 'X': '4_4_4', + 'drop_path': 0 + }, + 'LeViT_192': { + 'C': '192_288_384', + 'D': 32, + 'N': '3_5_6', + 'X': '4_4_4', + 'drop_path': 0 + }, + 'LeViT_256': { + 'C': '256_384_512', + 'D': 32, + 'N': '4_6_8', + 'X': '4_4_4', + 'drop_path': 0 + }, + 'LeViT_384': { + 'C': '384_512_768', + 'D': 32, + 'N': '6_9_12', + 'X': '4_4_4', + 'drop_path': 0.1 + }, +} + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def LeViT_128S(pretrained=False, + use_ssld=False, + class_num=1000, + distillation=False, + **kwargs): + model = model_factory( + **specification['LeViT_128S'], + class_num=class_num, + distillation=distillation) + _load_pretrained( + pretrained, model, MODEL_URLS["LeViT_128S"], use_ssld=use_ssld) + return model + + +def LeViT_128(pretrained=False, + use_ssld=False, + class_num=1000, + distillation=False, + **kwargs): + model = model_factory( + **specification['LeViT_128'], + class_num=class_num, + distillation=distillation) + _load_pretrained( + pretrained, model, MODEL_URLS["LeViT_128"], use_ssld=use_ssld) + return model + + +def LeViT_192(pretrained=False, + use_ssld=False, + class_num=1000, + distillation=False, + **kwargs): + model = model_factory( + **specification['LeViT_192'], + class_num=class_num, + distillation=distillation) + _load_pretrained( + pretrained, model, MODEL_URLS["LeViT_192"], use_ssld=use_ssld) + return model + + +def LeViT_256(pretrained=False, + use_ssld=False, + class_num=1000, + distillation=False, + **kwargs): + model = model_factory( + **specification['LeViT_256'], + class_num=class_num, + distillation=distillation) + _load_pretrained( + pretrained, model, MODEL_URLS["LeViT_256"], use_ssld=use_ssld) + return model + + +def LeViT_384(pretrained=False, + use_ssld=False, + class_num=1000, + distillation=False, + **kwargs): + model = model_factory( + **specification['LeViT_384'], + class_num=class_num, + distillation=distillation) + _load_pretrained( + pretrained, model, MODEL_URLS["LeViT_384"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/mixnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/mixnet.py new file mode 100644 index 0000000..c2a1adb --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/mixnet.py @@ -0,0 +1,815 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. +""" + MixNet for ImageNet-1K, implemented in Paddle. + Original paper: 'MixConv: Mixed Depthwise Convolutional Kernels,' + https://arxiv.org/abs/1907.09595. +""" + +import os +from inspect import isfunction +from functools import reduce +import paddle +import paddle.nn as nn + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "MixNet_S": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_S_pretrained.pdparams", + "MixNet_M": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_M_pretrained.pdparams", + "MixNet_L": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_L_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class Identity(nn.Layer): + """ + Identity block. + """ + + def __init__(self): + super(Identity, self).__init__() + + def forward(self, x): + return x + + +def round_channels(channels, divisor=8): + """ + Round weighted channel number (make divisible operation). + + Parameters: + ---------- + channels : int or float + Original number of channels. + divisor : int, default 8 + Alignment value. + + Returns: + ------- + int + Weighted number of channels. + """ + rounded_channels = max( + int(channels + divisor / 2.0) // divisor * divisor, divisor) + if float(rounded_channels) < 0.9 * channels: + rounded_channels += divisor + return rounded_channels + + +def get_activation_layer(activation): + """ + Create activation layer from string/function. + + Parameters: + ---------- + activation : function, or str, or nn.Module + Activation function or name of activation function. + + Returns: + ------- + nn.Module + Activation layer. + """ + assert activation is not None + if isfunction(activation): + return activation() + elif isinstance(activation, str): + if activation == "relu": + return nn.ReLU() + elif activation == "relu6": + return nn.ReLU6() + elif activation == "swish": + return nn.Swish() + elif activation == "hswish": + return nn.Hardswish() + elif activation == "sigmoid": + return nn.Sigmoid() + elif activation == "hsigmoid": + return nn.Hardsigmoid() + elif activation == "identity": + return Identity() + else: + raise NotImplementedError() + else: + assert isinstance(activation, nn.Layer) + return activation + + +class ConvBlock(nn.Layer): + """ + Standard convolution block with Batch normalization and activation. + + Parameters: + ---------- + in_channels : int + Number of input channels. + out_channels : int + Number of output channels. + kernel_size : int or tuple/list of 2 int + Convolution window size. + stride : int or tuple/list of 2 int + Strides of the convolution. + padding : int, or tuple/list of 2 int, or tuple/list of 4 int + Padding value for convolution layer. + dilation : int or tuple/list of 2 int, default 1 + Dilation value for convolution layer. + groups : int, default 1 + Number of groups. + bias : bool, default False + Whether the layer uses a bias vector. + use_bn : bool, default True + Whether to use BatchNorm layer. + bn_eps : float, default 1e-5 + Small float added to variance in Batch norm. + activation : function or str or None, default nn.ReLU() + Activation function or name of activation function. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride, + padding, + dilation=1, + groups=1, + bias=False, + use_bn=True, + bn_eps=1e-5, + activation=nn.ReLU()): + super(ConvBlock, self).__init__() + self.activate = (activation is not None) + self.use_bn = use_bn + self.use_pad = (isinstance(padding, (list, tuple)) and + (len(padding) == 4)) + + if self.use_pad: + self.pad = padding + self.conv = nn.Conv2D( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias_attr=bias, + weight_attr=None) + if self.use_bn: + self.bn = nn.BatchNorm2D(num_features=out_channels, epsilon=bn_eps) + if self.activate: + self.activ = get_activation_layer(activation) + + def forward(self, x): + x = self.conv(x) + if self.use_bn: + x = self.bn(x) + if self.activate: + x = self.activ(x) + return x + + +class SEBlock(nn.Layer): + def __init__(self, + channels, + reduction=16, + mid_channels=None, + round_mid=False, + use_conv=True, + mid_activation=nn.ReLU(), + out_activation=nn.Sigmoid()): + super(SEBlock, self).__init__() + self.use_conv = use_conv + if mid_channels is None: + mid_channels = channels // reduction if not round_mid else round_channels( + float(channels) / reduction) + + self.pool = nn.AdaptiveAvgPool2D(output_size=1) + if use_conv: + self.conv1 = nn.Conv2D( + in_channels=channels, + out_channels=mid_channels, + kernel_size=1, + stride=1, + groups=1, + bias_attr=True, + weight_attr=None) + + else: + self.fc1 = nn.Linear( + in_features=channels, out_features=mid_channels) + self.activ = get_activation_layer(mid_activation) + if use_conv: + self.conv2 = nn.Conv2D( + in_channels=mid_channels, + out_channels=channels, + kernel_size=1, + stride=1, + groups=1, + bias_attr=True, + weight_attr=None) + else: + self.fc2 = nn.Linear( + in_features=mid_channels, out_features=channels) + self.sigmoid = get_activation_layer(out_activation) + + def forward(self, x): + w = self.pool(x) + if not self.use_conv: + w = w.reshape(shape=[w.shape[0], -1]) + w = self.conv1(w) if self.use_conv else self.fc1(w) + w = self.activ(w) + w = self.conv2(w) if self.use_conv else self.fc2(w) + w = self.sigmoid(w) + if not self.use_conv: + w = w.unsqueeze(2).unsqueeze(3) + x = x * w + return x + + +class MixConv(nn.Layer): + """ + Mixed convolution layer from 'MixConv: Mixed Depthwise Convolutional Kernels,' + https://arxiv.org/abs/1907.09595. + + Parameters: + ---------- + in_channels : int + Number of input channels. + out_channels : int + Number of output channels. + kernel_size : int or tuple/list of int, or tuple/list of tuple/list of 2 int + Convolution window size. + stride : int or tuple/list of 2 int + Strides of the convolution. + padding : int or tuple/list of int, or tuple/list of tuple/list of 2 int + Padding value for convolution layer. + dilation : int or tuple/list of 2 int, default 1 + Dilation value for convolution layer. + groups : int, default 1 + Number of groups. + bias : bool, default False + Whether the layer uses a bias vector. + axis : int, default 1 + The axis on which to concatenate the outputs. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride, + padding, + dilation=1, + groups=1, + bias=False, + axis=1): + super(MixConv, self).__init__() + kernel_size = kernel_size if isinstance(kernel_size, + list) else [kernel_size] + padding = padding if isinstance(padding, list) else [padding] + kernel_count = len(kernel_size) + self.splitted_in_channels = self.split_channels(in_channels, + kernel_count) + splitted_out_channels = self.split_channels(out_channels, kernel_count) + for i, kernel_size_i in enumerate(kernel_size): + in_channels_i = self.splitted_in_channels[i] + out_channels_i = splitted_out_channels[i] + padding_i = padding[i] + _ = self.add_sublayer( + name=str(i), + sublayer=nn.Conv2D( + in_channels=in_channels_i, + out_channels=out_channels_i, + kernel_size=kernel_size_i, + stride=stride, + padding=padding_i, + dilation=dilation, + groups=(out_channels_i + if out_channels == groups else groups), + bias_attr=bias, + weight_attr=None)) + self.axis = axis + + def forward(self, x): + xx = paddle.split(x, self.splitted_in_channels, axis=self.axis) + xx = paddle.split(x, self.splitted_in_channels, axis=self.axis) + out = [ + conv_i(x_i) for x_i, conv_i in zip(xx, self._sub_layers.values()) + ] + x = paddle.concat(tuple(out), axis=self.axis) + return x + + @staticmethod + def split_channels(channels, kernel_count): + splitted_channels = [channels // kernel_count] * kernel_count + splitted_channels[0] += channels - sum(splitted_channels) + return splitted_channels + + +class MixConvBlock(nn.Layer): + """ + Mixed convolution block with Batch normalization and activation. + + Parameters: + ---------- + in_channels : int + Number of input channels. + out_channels : int + Number of output channels. + kernel_size : int or tuple/list of int, or tuple/list of tuple/list of 2 int + Convolution window size. + stride : int or tuple/list of 2 int + Strides of the convolution. + padding : int or tuple/list of int, or tuple/list of tuple/list of 2 int + Padding value for convolution layer. + dilation : int or tuple/list of 2 int, default 1 + Dilation value for convolution layer. + groups : int, default 1 + Number of groups. + bias : bool, default False + Whether the layer uses a bias vector. + use_bn : bool, default True + Whether to use BatchNorm layer. + bn_eps : float, default 1e-5 + Small float added to variance in Batch norm. + activation : function or str or None, default nn.ReLU() + Activation function or name of activation function. + activate : bool, default True + Whether activate the convolution block. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride, + padding, + dilation=1, + groups=1, + bias=False, + use_bn=True, + bn_eps=1e-5, + activation=nn.ReLU()): + super(MixConvBlock, self).__init__() + self.activate = (activation is not None) + self.use_bn = use_bn + + self.conv = MixConv( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias=bias) + if self.use_bn: + self.bn = nn.BatchNorm2D(num_features=out_channels, epsilon=bn_eps) + if self.activate: + self.activ = get_activation_layer(activation) + + def forward(self, x): + x = self.conv(x) + if self.use_bn: + x = self.bn(x) + if self.activate: + x = self.activ(x) + return x + + +def mixconv1x1_block(in_channels, + out_channels, + kernel_count, + stride=1, + groups=1, + bias=False, + use_bn=True, + bn_eps=1e-5, + activation=nn.ReLU()): + """ + 1x1 version of the mixed convolution block. + + Parameters: + ---------- + in_channels : int + Number of input channels. + out_channels : int + Number of output channels. + kernel_count : int + Kernel count. + stride : int or tuple/list of 2 int, default 1 + Strides of the convolution. + groups : int, default 1 + Number of groups. + bias : bool, default False + Whether the layer uses a bias vector. + use_bn : bool, default True + Whether to use BatchNorm layer. + bn_eps : float, default 1e-5 + Small float added to variance in Batch norm. + activation : function or str, or None, default nn.ReLU() + Activation function or name of activation function. + """ + return MixConvBlock( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=([1] * kernel_count), + stride=stride, + padding=([0] * kernel_count), + groups=groups, + bias=bias, + use_bn=use_bn, + bn_eps=bn_eps, + activation=activation) + + +class MixUnit(nn.Layer): + """ + MixNet unit. + + Parameters: + ---------- + in_channels : int + Number of input channels. + out_channels : int + Number of output channels. exp_channels : int + Number of middle (expanded) channels. + stride : int or tuple/list of 2 int + Strides of the second convolution layer. + exp_kernel_count : int + Expansion convolution kernel count for each unit. + conv1_kernel_count : int + Conv1 kernel count for each unit. + conv2_kernel_count : int + Conv2 kernel count for each unit. + exp_factor : int + Expansion factor for each unit. + se_factor : int + SE reduction factor for each unit. + activation : str + Activation function or name of activation function. + """ + + def __init__(self, in_channels, out_channels, stride, exp_kernel_count, + conv1_kernel_count, conv2_kernel_count, exp_factor, se_factor, + activation): + super(MixUnit, self).__init__() + assert exp_factor >= 1 + assert se_factor >= 0 + self.residual = (in_channels == out_channels) and (stride == 1) + self.use_se = se_factor > 0 + mid_channels = exp_factor * in_channels + self.use_exp_conv = exp_factor > 1 + + if self.use_exp_conv: + if exp_kernel_count == 1: + self.exp_conv = ConvBlock( + in_channels=in_channels, + out_channels=mid_channels, + kernel_size=1, + stride=1, + padding=0, + groups=1, + bias=False, + use_bn=True, + bn_eps=1e-5, + activation=activation) + else: + self.exp_conv = mixconv1x1_block( + in_channels=in_channels, + out_channels=mid_channels, + kernel_count=exp_kernel_count, + activation=activation) + if conv1_kernel_count == 1: + self.conv1 = ConvBlock( + in_channels=mid_channels, + out_channels=mid_channels, + kernel_size=3, + stride=stride, + padding=1, + dilation=1, + groups=mid_channels, + bias=False, + use_bn=True, + bn_eps=1e-5, + activation=activation) + else: + self.conv1 = MixConvBlock( + in_channels=mid_channels, + out_channels=mid_channels, + kernel_size=[3 + 2 * i for i in range(conv1_kernel_count)], + stride=stride, + padding=[1 + i for i in range(conv1_kernel_count)], + groups=mid_channels, + activation=activation) + if self.use_se: + self.se = SEBlock( + channels=mid_channels, + reduction=(exp_factor * se_factor), + round_mid=False, + mid_activation=activation) + if conv2_kernel_count == 1: + self.conv2 = ConvBlock( + in_channels=mid_channels, + out_channels=out_channels, + activation=None, + kernel_size=1, + stride=1, + padding=0, + groups=1, + bias=False, + use_bn=True, + bn_eps=1e-5) + else: + self.conv2 = mixconv1x1_block( + in_channels=mid_channels, + out_channels=out_channels, + kernel_count=conv2_kernel_count, + activation=None) + + def forward(self, x): + if self.residual: + identity = x + if self.use_exp_conv: + x = self.exp_conv(x) + x = self.conv1(x) + if self.use_se: + x = self.se(x) + x = self.conv2(x) + if self.residual: + x = x + identity + return x + + +class MixInitBlock(nn.Layer): + """ + MixNet specific initial block. + + Parameters: + ---------- + in_channels : int + Number of input channels. + out_channels : int + Number of output channels. + """ + + def __init__(self, in_channels, out_channels): + super(MixInitBlock, self).__init__() + self.conv1 = ConvBlock( + in_channels=in_channels, + out_channels=out_channels, + stride=2, + kernel_size=3, + padding=1) + self.conv2 = MixUnit( + in_channels=out_channels, + out_channels=out_channels, + stride=1, + exp_kernel_count=1, + conv1_kernel_count=1, + conv2_kernel_count=1, + exp_factor=1, + se_factor=0, + activation="relu") + + def forward(self, x): + x = self.conv1(x) + x = self.conv2(x) + return x + + +class MixNet(nn.Layer): + """ + MixNet model from 'MixConv: Mixed Depthwise Convolutional Kernels,' + https://arxiv.org/abs/1907.09595. + + Parameters: + ---------- + channels : list of list of int + Number of output channels for each unit. + init_block_channels : int + Number of output channels for the initial unit. + final_block_channels : int + Number of output channels for the final block of the feature extractor. + exp_kernel_counts : list of list of int + Expansion convolution kernel count for each unit. + conv1_kernel_counts : list of list of int + Conv1 kernel count for each unit. + conv2_kernel_counts : list of list of int + Conv2 kernel count for each unit. + exp_factors : list of list of int + Expansion factor for each unit. + se_factors : list of list of int + SE reduction factor for each unit. + in_channels : int, default 3 + Number of input channels. + in_size : tuple of two ints, default (224, 224) + Spatial size of the expected input image. + class_num : int, default 1000 + Number of classification classes. + """ + + def __init__(self, + channels, + init_block_channels, + final_block_channels, + exp_kernel_counts, + conv1_kernel_counts, + conv2_kernel_counts, + exp_factors, + se_factors, + in_channels=3, + in_size=(224, 224), + class_num=1000): + super(MixNet, self).__init__() + self.in_size = in_size + self.class_num = class_num + + self.features = nn.Sequential() + self.features.add_sublayer( + "init_block", + MixInitBlock( + in_channels=in_channels, out_channels=init_block_channels)) + in_channels = init_block_channels + for i, channels_per_stage in enumerate(channels): + stage = nn.Sequential() + for j, out_channels in enumerate(channels_per_stage): + stride = 2 if ((j == 0) and (i != 3)) or ( + (j == len(channels_per_stage) // 2) and (i == 3)) else 1 + exp_kernel_count = exp_kernel_counts[i][j] + conv1_kernel_count = conv1_kernel_counts[i][j] + conv2_kernel_count = conv2_kernel_counts[i][j] + exp_factor = exp_factors[i][j] + se_factor = se_factors[i][j] + activation = "relu" if i == 0 else "swish" + stage.add_sublayer( + "unit{}".format(j + 1), + MixUnit( + in_channels=in_channels, + out_channels=out_channels, + stride=stride, + exp_kernel_count=exp_kernel_count, + conv1_kernel_count=conv1_kernel_count, + conv2_kernel_count=conv2_kernel_count, + exp_factor=exp_factor, + se_factor=se_factor, + activation=activation)) + in_channels = out_channels + self.features.add_sublayer("stage{}".format(i + 1), stage) + self.features.add_sublayer( + "final_block", + ConvBlock( + in_channels=in_channels, + out_channels=final_block_channels, + kernel_size=1, + stride=1, + padding=0, + groups=1, + bias=False, + use_bn=True, + bn_eps=1e-5, + activation=nn.ReLU())) + in_channels = final_block_channels + self.features.add_sublayer( + "final_pool", nn.AvgPool2D( + kernel_size=7, stride=1)) + + self.output = nn.Linear( + in_features=in_channels, out_features=class_num) + + def forward(self, x): + x = self.features(x) + reshape_dim = reduce(lambda x, y: x * y, x.shape[1:]) + x = x.reshape(shape=[x.shape[0], reshape_dim]) + x = self.output(x) + return x + + +def get_mixnet(version, width_scale, model_name=None, **kwargs): + """ + Create MixNet model with specific parameters. + + Parameters: + ---------- + version : str + Version of MobileNetV3 ('s' or 'm'). + width_scale : float + Scale factor for width of layers. + model_name : str or None, default None + Model name. + """ + + if version == "s": + init_block_channels = 16 + channels = [[24, 24], [40, 40, 40, 40], [80, 80, 80], + [120, 120, 120, 200, 200, 200]] + exp_kernel_counts = [[2, 2], [1, 2, 2, 2], [1, 1, 1], + [2, 2, 2, 1, 1, 1]] + conv1_kernel_counts = [[1, 1], [3, 2, 2, 2], [3, 2, 2], + [3, 4, 4, 5, 4, 4]] + conv2_kernel_counts = [[2, 2], [1, 2, 2, 2], [2, 2, 2], + [2, 2, 2, 1, 2, 2]] + exp_factors = [[6, 3], [6, 6, 6, 6], [6, 6, 6], [6, 3, 3, 6, 6, 6]] + se_factors = [[0, 0], [2, 2, 2, 2], [4, 4, 4], [2, 2, 2, 2, 2, 2]] + elif version == "m": + init_block_channels = 24 + channels = [[32, 32], [40, 40, 40, 40], [80, 80, 80, 80], + [120, 120, 120, 120, 200, 200, 200, 200]] + exp_kernel_counts = [[2, 2], [1, 2, 2, 2], [1, 2, 2, 2], + [1, 2, 2, 2, 1, 1, 1, 1]] + conv1_kernel_counts = [[3, 1], [4, 2, 2, 2], [3, 4, 4, 4], + [1, 4, 4, 4, 4, 4, 4, 4]] + conv2_kernel_counts = [[2, 2], [1, 2, 2, 2], [1, 2, 2, 2], + [1, 2, 2, 2, 1, 2, 2, 2]] + exp_factors = [[6, 3], [6, 6, 6, 6], [6, 6, 6, 6], + [6, 3, 3, 3, 6, 6, 6, 6]] + se_factors = [[0, 0], [2, 2, 2, 2], [4, 4, 4, 4], + [2, 2, 2, 2, 2, 2, 2, 2]] + else: + raise ValueError("Unsupported MixNet version {}".format(version)) + + final_block_channels = 1536 + + if width_scale != 1.0: + channels = [[round_channels(cij * width_scale) for cij in ci] + for ci in channels] + init_block_channels = round_channels(init_block_channels * width_scale) + + net = MixNet( + channels=channels, + init_block_channels=init_block_channels, + final_block_channels=final_block_channels, + exp_kernel_counts=exp_kernel_counts, + conv1_kernel_counts=conv1_kernel_counts, + conv2_kernel_counts=conv2_kernel_counts, + exp_factors=exp_factors, + se_factors=se_factors, + **kwargs) + + return net + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def MixNet_S(pretrained=False, use_ssld=False, **kwargs): + """ + MixNet-S model from 'MixConv: Mixed Depthwise Convolutional Kernels,' + https://arxiv.org/abs/1907.09595. + """ + model = get_mixnet( + version="s", width_scale=1.0, model_name="MixNet_S", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MixNet_S"], use_ssld=use_ssld) + return model + + +def MixNet_M(pretrained=False, use_ssld=False, **kwargs): + """ + MixNet-M model from 'MixConv: Mixed Depthwise Convolutional Kernels,' + https://arxiv.org/abs/1907.09595. + """ + model = get_mixnet( + version="m", width_scale=1.0, model_name="MixNet_M", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MixNet_M"], use_ssld=use_ssld) + return model + + +def MixNet_L(pretrained=False, use_ssld=False, **kwargs): + """ + MixNet-S model from 'MixConv: Mixed Depthwise Convolutional Kernels,' + https://arxiv.org/abs/1907.09595. + """ + model = get_mixnet( + version="m", width_scale=1.3, model_name="MixNet_L", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MixNet_L"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/mobilenet_v2.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/mobilenet_v2.py new file mode 100644 index 0000000..b32c025 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/mobilenet_v2.py @@ -0,0 +1,287 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "MobileNetV2_x0_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_25_pretrained.pdparams", + "MobileNetV2_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_5_pretrained.pdparams", + "MobileNetV2_x0_75": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_75_pretrained.pdparams", + "MobileNetV2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_pretrained.pdparams", + "MobileNetV2_x1_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x1_5_pretrained.pdparams", + "MobileNetV2_x2_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x2_0_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + filter_size, + num_filters, + stride, + padding, + channels=None, + num_groups=1, + name=None, + use_cudnn=True): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=num_groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + + self._batch_norm = BatchNorm( + num_filters, + param_attr=ParamAttr(name=name + "_bn_scale"), + bias_attr=ParamAttr(name=name + "_bn_offset"), + moving_mean_name=name + "_bn_mean", + moving_variance_name=name + "_bn_variance") + + def forward(self, inputs, if_act=True): + y = self._conv(inputs) + y = self._batch_norm(y) + if if_act: + y = F.relu6(y) + return y + + +class InvertedResidualUnit(nn.Layer): + def __init__(self, num_channels, num_in_filter, num_filters, stride, + filter_size, padding, expansion_factor, name): + super(InvertedResidualUnit, self).__init__() + num_expfilter = int(round(num_in_filter * expansion_factor)) + self._expand_conv = ConvBNLayer( + num_channels=num_channels, + num_filters=num_expfilter, + filter_size=1, + stride=1, + padding=0, + num_groups=1, + name=name + "_expand") + + self._bottleneck_conv = ConvBNLayer( + num_channels=num_expfilter, + num_filters=num_expfilter, + filter_size=filter_size, + stride=stride, + padding=padding, + num_groups=num_expfilter, + use_cudnn=False, + name=name + "_dwise") + + self._linear_conv = ConvBNLayer( + num_channels=num_expfilter, + num_filters=num_filters, + filter_size=1, + stride=1, + padding=0, + num_groups=1, + name=name + "_linear") + + def forward(self, inputs, ifshortcut): + y = self._expand_conv(inputs, if_act=True) + y = self._bottleneck_conv(y, if_act=True) + y = self._linear_conv(y, if_act=False) + if ifshortcut: + y = paddle.add(inputs, y) + return y + + +class InvresiBlocks(nn.Layer): + def __init__(self, in_c, t, c, n, s, name): + super(InvresiBlocks, self).__init__() + + self._first_block = InvertedResidualUnit( + num_channels=in_c, + num_in_filter=in_c, + num_filters=c, + stride=s, + filter_size=3, + padding=1, + expansion_factor=t, + name=name + "_1") + + self._block_list = [] + for i in range(1, n): + block = self.add_sublayer( + name + "_" + str(i + 1), + sublayer=InvertedResidualUnit( + num_channels=c, + num_in_filter=c, + num_filters=c, + stride=1, + filter_size=3, + padding=1, + expansion_factor=t, + name=name + "_" + str(i + 1))) + self._block_list.append(block) + + def forward(self, inputs): + y = self._first_block(inputs, ifshortcut=False) + for block in self._block_list: + y = block(y, ifshortcut=True) + return y + + +class MobileNet(nn.Layer): + def __init__(self, class_num=1000, scale=1.0, prefix_name=""): + super(MobileNet, self).__init__() + self.scale = scale + self.class_num = class_num + + bottleneck_params_list = [ + (1, 16, 1, 1), + (6, 24, 2, 2), + (6, 32, 3, 2), + (6, 64, 4, 2), + (6, 96, 3, 1), + (6, 160, 3, 2), + (6, 320, 1, 1), + ] + + self.conv1 = ConvBNLayer( + num_channels=3, + num_filters=int(32 * scale), + filter_size=3, + stride=2, + padding=1, + name=prefix_name + "conv1_1") + + self.block_list = [] + i = 1 + in_c = int(32 * scale) + for layer_setting in bottleneck_params_list: + t, c, n, s = layer_setting + i += 1 + block = self.add_sublayer( + prefix_name + "conv" + str(i), + sublayer=InvresiBlocks( + in_c=in_c, + t=t, + c=int(c * scale), + n=n, + s=s, + name=prefix_name + "conv" + str(i))) + self.block_list.append(block) + in_c = int(c * scale) + + self.out_c = int(1280 * scale) if scale > 1.0 else 1280 + self.conv9 = ConvBNLayer( + num_channels=in_c, + num_filters=self.out_c, + filter_size=1, + stride=1, + padding=0, + name=prefix_name + "conv9") + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.out = Linear( + self.out_c, + class_num, + weight_attr=ParamAttr(name=prefix_name + "fc10_weights"), + bias_attr=ParamAttr(name=prefix_name + "fc10_offset")) + + def forward(self, inputs): + y = self.conv1(inputs, if_act=True) + for block in self.block_list: + y = block(y) + y = self.conv9(y, if_act=True) + y = self.pool2d_avg(y) + y = paddle.flatten(y, start_axis=1, stop_axis=-1) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def MobileNetV2_x0_25(pretrained=False, use_ssld=False, **kwargs): + model = MobileNet(scale=0.25, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MobileNetV2_x0_25"], use_ssld=use_ssld) + return model + + +def MobileNetV2_x0_5(pretrained=False, use_ssld=False, **kwargs): + model = MobileNet(scale=0.5, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MobileNetV2_x0_5"], use_ssld=use_ssld) + return model + + +def MobileNetV2_x0_75(pretrained=False, use_ssld=False, **kwargs): + model = MobileNet(scale=0.75, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MobileNetV2_x0_75"], use_ssld=use_ssld) + return model + + +def MobileNetV2(pretrained=False, use_ssld=False, **kwargs): + model = MobileNet(scale=1.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MobileNetV2"], use_ssld=use_ssld) + return model + + +def MobileNetV2_x1_5(pretrained=False, use_ssld=False, **kwargs): + model = MobileNet(scale=1.5, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MobileNetV2_x1_5"], use_ssld=use_ssld) + return model + + +def MobileNetV2_x2_0(pretrained=False, use_ssld=False, **kwargs): + model = MobileNet(scale=2.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["MobileNetV2_x2_0"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/pvt_v2.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/pvt_v2.py new file mode 100644 index 0000000..e2fdfd4 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/pvt_v2.py @@ -0,0 +1,492 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was heavily based on https://github.com/whai362/PVT + +from functools import partial +import math +import paddle +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn.initializer import TruncatedNormal, Constant + +from .vision_transformer import trunc_normal_, zeros_, ones_, to_2tuple, DropPath, Identity, drop_path + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "PVT_V2_B0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B0_pretrained.pdparams", + "PVT_V2_B1": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B1_pretrained.pdparams", + "PVT_V2_B2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_pretrained.pdparams", + "PVT_V2_B2_Linear": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_Linear_pretrained.pdparams", + "PVT_V2_B3": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B3_pretrained.pdparams", + "PVT_V2_B4": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B4_pretrained.pdparams", + "PVT_V2_B5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B5_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +@paddle.jit.not_to_static +def swapdim(x, dim1, dim2): + a = list(range(len(x.shape))) + a[dim1], a[dim2] = a[dim2], a[dim1] + return x.transpose(a) + + +class Mlp(nn.Layer): + def __init__(self, + in_features, + hidden_features=None, + out_features=None, + act_layer=nn.GELU, + drop=0., + linear=False): + super().__init__() + out_features = out_features or in_features + hidden_features = hidden_features or in_features + self.fc1 = nn.Linear(in_features, hidden_features) + self.dwconv = DWConv(hidden_features) + self.act = act_layer() + self.fc2 = nn.Linear(hidden_features, out_features) + self.drop = nn.Dropout(drop) + self.linear = linear + if self.linear: + self.relu = nn.ReLU() + + def forward(self, x, H, W): + x = self.fc1(x) + if self.linear: + x = self.relu(x) + x = self.dwconv(x, H, W) + x = self.act(x) + x = self.drop(x) + x = self.fc2(x) + x = self.drop(x) + return x + + +class Attention(nn.Layer): + def __init__(self, + dim, + num_heads=8, + qkv_bias=False, + qk_scale=None, + attn_drop=0., + proj_drop=0., + sr_ratio=1, + linear=False): + super().__init__() + assert dim % num_heads == 0 + + self.dim = dim + self.num_heads = num_heads + head_dim = dim // num_heads + self.scale = qk_scale or head_dim**-0.5 + + self.q = nn.Linear(dim, dim, bias_attr=qkv_bias) + self.kv = nn.Linear(dim, dim * 2, bias_attr=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + + self.linear = linear + self.sr_ratio = sr_ratio + if not linear: + if sr_ratio > 1: + self.sr = nn.Conv2D( + dim, dim, kernel_size=sr_ratio, stride=sr_ratio) + self.norm = nn.LayerNorm(dim) + else: + self.pool = nn.AdaptiveAvgPool2D(7) + self.sr = nn.Conv2D(dim, dim, kernel_size=1, stride=1) + self.norm = nn.LayerNorm(dim) + self.act = nn.GELU() + + def forward(self, x, H, W): + B, N, C = x.shape + q = self.q(x).reshape( + [B, N, self.num_heads, C // self.num_heads]).transpose( + [0, 2, 1, 3]) + + if not self.linear: + if self.sr_ratio > 1: + x_ = x.transpose([0, 2, 1]).reshape([B, C, H, W]) + x_ = self.sr(x_) + h_, w_ = x_.shape[-2:] + x_ = x_.reshape([B, C, h_ * w_]).transpose([0, 2, 1]) + x_ = self.norm(x_) + kv = self.kv(x_) + kv = kv.reshape([ + B, kv.shape[2] * kv.shape[1] // 2 // C, 2, self.num_heads, + C // self.num_heads + ]).transpose([2, 0, 3, 1, 4]) + else: + kv = self.kv(x) + kv = kv.reshape([ + B, kv.shape[2] * kv.shape[1] // 2 // C, 2, self.num_heads, + C // self.num_heads + ]).transpose([2, 0, 3, 1, 4]) + else: + x_ = x.transpose([0, 2, 1]).reshape([B, C, H, W]) + x_ = self.sr(self.pool(x_)) + x_ = x_.reshape([B, C, x_.shape[2] * x_.shape[3]]).transpose( + [0, 2, 1]) + x_ = self.norm(x_) + x_ = self.act(x_) + kv = self.kv(x_) + kv = kv.reshape([ + B, kv.shape[2] * kv.shape[1] // 2 // C, 2, self.num_heads, + C // self.num_heads + ]).transpose([2, 0, 3, 1, 4]) + k, v = kv[0], kv[1] + + attn = (q @swapdim(k, -2, -1)) * self.scale + attn = F.softmax(attn, axis=-1) + attn = self.attn_drop(attn) + + x = swapdim((attn @v), 1, 2).reshape([B, N, C]) + x = self.proj(x) + x = self.proj_drop(x) + + return x + + +class Block(nn.Layer): + def __init__(self, + dim, + num_heads, + mlp_ratio=4., + qkv_bias=False, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer=nn.LayerNorm, + sr_ratio=1, + linear=False): + super().__init__() + self.norm1 = norm_layer(dim) + self.attn = Attention( + dim, + num_heads=num_heads, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + attn_drop=attn_drop, + proj_drop=drop, + sr_ratio=sr_ratio, + linear=linear) + self.drop_path = DropPath(drop_path) if drop_path > 0. else Identity() + self.norm2 = norm_layer(dim) + mlp_hidden_dim = int(dim * mlp_ratio) + self.mlp = Mlp(in_features=dim, + hidden_features=mlp_hidden_dim, + act_layer=act_layer, + drop=drop, + linear=linear) + + def forward(self, x, H, W): + x = x + self.drop_path(self.attn(self.norm1(x), H, W)) + x = x + self.drop_path(self.mlp(self.norm2(x), H, W)) + + return x + + +class OverlapPatchEmbed(nn.Layer): + """ Image to Patch Embedding + """ + + def __init__(self, + img_size=224, + patch_size=7, + stride=4, + in_chans=3, + embed_dim=768): + super().__init__() + img_size = to_2tuple(img_size) + patch_size = to_2tuple(patch_size) + + self.img_size = img_size + self.patch_size = patch_size + self.H, self.W = img_size[0] // patch_size[0], img_size[ + 1] // patch_size[1] + self.num_patches = self.H * self.W + self.proj = nn.Conv2D( + in_chans, + embed_dim, + kernel_size=patch_size, + stride=stride, + padding=(patch_size[0] // 2, patch_size[1] // 2)) + self.norm = nn.LayerNorm(embed_dim) + + def forward(self, x): + x = self.proj(x) + _, _, H, W = x.shape + x = x.flatten(2) + x = swapdim(x, 1, 2) + x = self.norm(x) + + return x, H, W + + +class PyramidVisionTransformerV2(nn.Layer): + def __init__(self, + img_size=224, + patch_size=16, + in_chans=3, + class_num=1000, + embed_dims=[64, 128, 256, 512], + num_heads=[1, 2, 4, 8], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=False, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer=nn.LayerNorm, + depths=[3, 4, 6, 3], + sr_ratios=[8, 4, 2, 1], + num_stages=4, + linear=False): + super().__init__() + self.class_num = class_num + self.depths = depths + self.num_stages = num_stages + + dpr = [x for x in paddle.linspace(0, drop_path_rate, sum(depths)) + ] # stochastic depth decay rule + cur = 0 + + for i in range(num_stages): + patch_embed = OverlapPatchEmbed( + img_size=img_size if i == 0 else img_size // (2**(i + 1)), + patch_size=7 if i == 0 else 3, + stride=4 if i == 0 else 2, + in_chans=in_chans if i == 0 else embed_dims[i - 1], + embed_dim=embed_dims[i]) + + block = nn.LayerList([ + Block( + dim=embed_dims[i], + num_heads=num_heads[i], + mlp_ratio=mlp_ratios[i], + qkv_bias=qkv_bias, + qk_scale=qk_scale, + drop=drop_rate, + attn_drop=attn_drop_rate, + drop_path=dpr[cur + j], + norm_layer=norm_layer, + sr_ratio=sr_ratios[i], + linear=linear) for j in range(depths[i]) + ]) + norm = norm_layer(embed_dims[i]) + cur += depths[i] + + setattr(self, f"patch_embed{i + 1}", patch_embed) + setattr(self, f"block{i + 1}", block) + setattr(self, f"norm{i + 1}", norm) + + # classification head + self.head = nn.Linear(embed_dims[3], + class_num) if class_num > 0 else Identity() + + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight) + if isinstance(m, nn.Linear) and m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.LayerNorm): + zeros_(m.bias) + ones_(m.weight) + + def forward_features(self, x): + B = x.shape[0] + + for i in range(self.num_stages): + patch_embed = getattr(self, f"patch_embed{i + 1}") + block = getattr(self, f"block{i + 1}") + norm = getattr(self, f"norm{i + 1}") + x, H, W = patch_embed(x) + for blk in block: + x = blk(x, H, W) + x = norm(x) + if i != self.num_stages - 1: + x = x.reshape([B, H, W, x.shape[2]]).transpose([0, 3, 1, 2]) + + return x.mean(axis=1) + + def forward(self, x): + x = self.forward_features(x) + x = self.head(x) + + return x + + +class DWConv(nn.Layer): + def __init__(self, dim=768): + super().__init__() + self.dwconv = nn.Conv2D(dim, dim, 3, 1, 1, bias_attr=True, groups=dim) + + def forward(self, x, H, W): + B, N, C = x.shape + x = swapdim(x, 1, 2) + x = x.reshape([B, C, H, W]) + x = self.dwconv(x) + x = x.flatten(2) + x = swapdim(x, 1, 2) + + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def PVT_V2_B0(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[32, 64, 160, 256], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[2, 2, 2, 2], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B0"], use_ssld=use_ssld) + return model + + +def PVT_V2_B1(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[2, 2, 2, 2], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B1"], use_ssld=use_ssld) + return model + + +def PVT_V2_B2(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 4, 6, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B2"], use_ssld=use_ssld) + return model + + +def PVT_V2_B3(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 4, 18, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B3"], use_ssld=use_ssld) + return model + + +def PVT_V2_B4(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 8, 27, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B4"], use_ssld=use_ssld) + return model + + +def PVT_V2_B5(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[4, 4, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 6, 40, 3], + sr_ratios=[8, 4, 2, 1], + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B5"], use_ssld=use_ssld) + return model + + +def PVT_V2_B2_Linear(pretrained=False, use_ssld=False, **kwargs): + model = PyramidVisionTransformerV2( + patch_size=4, + embed_dims=[64, 128, 320, 512], + num_heads=[1, 2, 5, 8], + mlp_ratios=[8, 8, 4, 4], + qkv_bias=True, + norm_layer=partial( + nn.LayerNorm, epsilon=1e-6), + depths=[3, 4, 6, 3], + sr_ratios=[8, 4, 2, 1], + linear=True, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["PVT_V2_B2_Linear"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/rednet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/rednet.py new file mode 100644 index 0000000..be84da1 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/rednet.py @@ -0,0 +1,203 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/d-li14/involution + +import paddle +import paddle.nn as nn + +from paddle.vision.models import resnet + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "RedNet26": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet26_pretrained.pdparams", + "RedNet38": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet38_pretrained.pdparams", + "RedNet50": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet50_pretrained.pdparams", + "RedNet101": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet101_pretrained.pdparams", + "RedNet152": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet152_pretrained.pdparams" +} + +__all__ = MODEL_URLS.keys() + + +class Involution(nn.Layer): + def __init__(self, channels, kernel_size, stride): + super(Involution, self).__init__() + self.kernel_size = kernel_size + self.stride = stride + self.channels = channels + reduction_ratio = 4 + self.group_channels = 16 + self.groups = self.channels // self.group_channels + self.conv1 = nn.Sequential( + ('conv', nn.Conv2D( + in_channels=channels, + out_channels=channels // reduction_ratio, + kernel_size=1, + bias_attr=False)), + ('bn', nn.BatchNorm2D(channels // reduction_ratio)), + ('activate', nn.ReLU())) + self.conv2 = nn.Sequential(('conv', nn.Conv2D( + in_channels=channels // reduction_ratio, + out_channels=kernel_size**2 * self.groups, + kernel_size=1, + stride=1))) + if stride > 1: + self.avgpool = nn.AvgPool2D(stride, stride) + + def forward(self, x): + weight = self.conv2( + self.conv1(x if self.stride == 1 else self.avgpool(x))) + b, c, h, w = weight.shape + weight = weight.reshape( + (b, self.groups, self.kernel_size**2, h, w)).unsqueeze(2) + + out = nn.functional.unfold(x, self.kernel_size, self.stride, + (self.kernel_size - 1) // 2, 1) + out = out.reshape( + (b, self.groups, self.group_channels, self.kernel_size**2, h, w)) + out = (weight * out).sum(axis=3).reshape((b, self.channels, h, w)) + return out + + +class BottleneckBlock(resnet.BottleneckBlock): + def __init__(self, + inplanes, + planes, + stride=1, + downsample=None, + groups=1, + base_width=64, + dilation=1, + norm_layer=None): + super(BottleneckBlock, self).__init__(inplanes, planes, stride, + downsample, groups, base_width, + dilation, norm_layer) + width = int(planes * (base_width / 64.)) * groups + self.conv2 = Involution(width, 7, stride) + + +class RedNet(resnet.ResNet): + def __init__(self, block, depth, class_num=1000, with_pool=True): + super(RedNet, self).__init__( + block=block, depth=50, num_classes=class_num, with_pool=with_pool) + layer_cfg = { + 26: [1, 2, 4, 1], + 38: [2, 3, 5, 2], + 50: [3, 4, 6, 3], + 101: [3, 4, 23, 3], + 152: [3, 8, 36, 3] + } + layers = layer_cfg[depth] + + self.conv1 = None + self.bn1 = None + self.relu = None + self.inplanes = 64 + self.class_num = class_num + self.stem = nn.Sequential( + nn.Sequential( + ('conv', nn.Conv2D( + in_channels=3, + out_channels=self.inplanes // 2, + kernel_size=3, + stride=2, + padding=1, + bias_attr=False)), + ('bn', nn.BatchNorm2D(self.inplanes // 2)), + ('activate', nn.ReLU())), + Involution(self.inplanes // 2, 3, 1), + nn.BatchNorm2D(self.inplanes // 2), + nn.ReLU(), + nn.Sequential( + ('conv', nn.Conv2D( + in_channels=self.inplanes // 2, + out_channels=self.inplanes, + kernel_size=3, + stride=1, + padding=1, + bias_attr=False)), ('bn', nn.BatchNorm2D(self.inplanes)), + ('activate', nn.ReLU()))) + + self.layer1 = self._make_layer(block, 64, layers[0]) + self.layer2 = self._make_layer(block, 128, layers[1], stride=2) + self.layer3 = self._make_layer(block, 256, layers[2], stride=2) + self.layer4 = self._make_layer(block, 512, layers[3], stride=2) + + def forward(self, x): + x = self.stem(x) + x = self.maxpool(x) + + x = self.layer1(x) + x = self.layer2(x) + x = self.layer3(x) + x = self.layer4(x) + + if self.with_pool: + x = self.avgpool(x) + + if self.class_num > 0: + x = paddle.flatten(x, 1) + x = self.fc(x) + + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def RedNet26(pretrained=False, **kwargs): + model = RedNet(BottleneckBlock, 26, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["RedNet26"]) + return model + + +def RedNet38(pretrained=False, **kwargs): + model = RedNet(BottleneckBlock, 38, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["RedNet38"]) + return model + + +def RedNet50(pretrained=False, **kwargs): + model = RedNet(BottleneckBlock, 50, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["RedNet50"]) + return model + + +def RedNet101(pretrained=False, **kwargs): + model = RedNet(BottleneckBlock, 101, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["RedNet101"]) + return model + + +def RedNet152(pretrained=False, **kwargs): + model = RedNet(BottleneckBlock, 152, **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["RedNet152"]) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/regnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/regnet.py new file mode 100644 index 0000000..dc381cb --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/regnet.py @@ -0,0 +1,431 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/facebookresearch/pycls + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "RegNetX_200MF": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetX_200MF_pretrained.pdparams", + "RegNetX_4GF": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetX_4GF_pretrained.pdparams", + "RegNetX_32GF": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetX_32GF_pretrained.pdparams", + "RegNetY_200MF": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetY_200MF_pretrained.pdparams", + "RegNetY_4GF": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetY_4GF_pretrained.pdparams", + "RegNetY_32GF": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RegNetY_32GF_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +def quantize_float(f, q): + """Converts a float to closest non-zero int divisible by q.""" + return int(round(f / q) * q) + + +def adjust_ws_gs_comp(ws, bms, gs): + """Adjusts the compatibility of widths and groups.""" + ws_bot = [int(w * b) for w, b in zip(ws, bms)] + gs = [min(g, w_bot) for g, w_bot in zip(gs, ws_bot)] + ws_bot = [quantize_float(w_bot, g) for w_bot, g in zip(ws_bot, gs)] + ws = [int(w_bot / b) for w_bot, b in zip(ws_bot, bms)] + return ws, gs + + +def get_stages_from_blocks(ws, rs): + """Gets ws/ds of network at each stage from per block values.""" + ts = [ + w != wp or r != rp + for w, wp, r, rp in zip(ws + [0], [0] + ws, rs + [0], [0] + rs) + ] + s_ws = [w for w, t in zip(ws, ts[:-1]) if t] + s_ds = np.diff([d for d, t in zip(range(len(ts)), ts) if t]).tolist() + return s_ws, s_ds + + +def generate_regnet(w_a, w_0, w_m, d, q=8): + """Generates per block ws from RegNet parameters.""" + assert w_a >= 0 and w_0 > 0 and w_m > 1 and w_0 % q == 0 + ws_cont = np.arange(d) * w_a + w_0 + ks = np.round(np.log(ws_cont / w_0) / np.log(w_m)) + ws = w_0 * np.power(w_m, ks) + ws = np.round(np.divide(ws, q)) * q + num_stages, max_stage = len(np.unique(ws)), ks.max() + 1 + ws, ws_cont = ws.astype(int).tolist(), ws_cont.tolist() + return ws, num_stages, max_stage, ws_cont + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + padding=0, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=padding, + groups=groups, + weight_attr=ParamAttr(name=name + ".conv2d.output.1.w_0"), + bias_attr=ParamAttr(name=name + ".conv2d.output.1.b_0")) + bn_name = name + "_bn" + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + ".output.1.w_0"), + bias_attr=ParamAttr(bn_name + ".output.1.b_0"), + moving_mean_name=bn_name + "_mean", + moving_variance_name=bn_name + "_variance") + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + bm, + gw, + se_on, + se_r, + shortcut=True, + name=None): + super(BottleneckBlock, self).__init__() + + # Compute the bottleneck width + w_b = int(round(num_filters * bm)) + # Compute the number of groups + num_gs = w_b // gw + self.se_on = se_on + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=w_b, + filter_size=1, + padding=0, + act="relu", + name=name + "_branch2a") + self.conv1 = ConvBNLayer( + num_channels=w_b, + num_filters=w_b, + filter_size=3, + stride=stride, + padding=1, + groups=num_gs, + act="relu", + name=name + "_branch2b") + if se_on: + w_se = int(round(num_channels * se_r)) + self.se_block = SELayer( + num_channels=w_b, + num_filters=w_b, + reduction_ratio=w_se, + name=name + "_branch2se") + self.conv2 = ConvBNLayer( + num_channels=w_b, + num_filters=num_filters, + filter_size=1, + act=None, + name=name + "_branch2c") + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + stride=stride, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + if self.se_on: + conv1 = self.se_block(conv1) + conv2 = self.conv2(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + + y = paddle.add(x=short, y=conv2) + y = F.relu(y) + return y + + +class SELayer(nn.Layer): + def __init__(self, num_channels, num_filters, reduction_ratio, name=None): + super(SELayer, self).__init__() + + self.pool2d_gap = AdaptiveAvgPool2D(1) + + self._num_channels = num_channels + + med_ch = int(num_channels / reduction_ratio) + stdv = 1.0 / math.sqrt(num_channels * 1.0) + self.squeeze = Linear( + num_channels, + med_ch, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_sqz_weights"), + bias_attr=ParamAttr(name=name + "_sqz_offset")) + + stdv = 1.0 / math.sqrt(med_ch * 1.0) + self.excitation = Linear( + med_ch, + num_filters, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_exc_weights"), + bias_attr=ParamAttr(name=name + "_exc_offset")) + + def forward(self, input): + pool = self.pool2d_gap(input) + pool = paddle.reshape(pool, shape=[-1, self._num_channels]) + squeeze = self.squeeze(pool) + squeeze = F.relu(squeeze) + excitation = self.excitation(squeeze) + excitation = F.sigmoid(excitation) + excitation = paddle.reshape( + excitation, shape=[-1, self._num_channels, 1, 1]) + out = input * excitation + return out + + +class RegNet(nn.Layer): + def __init__(self, + w_a, + w_0, + w_m, + d, + group_w, + bot_mul, + q=8, + se_on=False, + class_num=1000): + super(RegNet, self).__init__() + + # Generate RegNet ws per block + b_ws, num_s, max_s, ws_cont = generate_regnet(w_a, w_0, w_m, d, q) + # Convert to per stage format + ws, ds = get_stages_from_blocks(b_ws, b_ws) + # Generate group widths and bot muls + gws = [group_w for _ in range(num_s)] + bms = [bot_mul for _ in range(num_s)] + # Adjust the compatibility of ws and gws + ws, gws = adjust_ws_gs_comp(ws, bms, gws) + # Use the same stride for each stage + ss = [2 for _ in range(num_s)] + # Use SE for RegNetY + se_r = 0.25 + # Construct the model + # Group params by stage + stage_params = list(zip(ds, ws, ss, bms, gws)) + # Construct the stem + stem_type = "simple_stem_in" + stem_w = 32 + block_type = "res_bottleneck_block" + + self.conv = ConvBNLayer( + num_channels=3, + num_filters=stem_w, + filter_size=3, + stride=2, + padding=1, + act="relu", + name="stem_conv") + + self.block_list = [] + for block, (d, w_out, stride, bm, gw) in enumerate(stage_params): + shortcut = False + for i in range(d): + num_channels = stem_w if block == i == 0 else in_channels + # Stride apply to the first block of the stage + b_stride = stride if i == 0 else 1 + conv_name = "s" + str(block + 1) + "_b" + str(i + + 1) # chr(97 + i) + bottleneck_block = self.add_sublayer( + conv_name, + BottleneckBlock( + num_channels=num_channels, + num_filters=w_out, + stride=b_stride, + bm=bm, + gw=gw, + se_on=se_on, + se_r=se_r, + shortcut=shortcut, + name=conv_name)) + in_channels = w_out + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = w_out + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_0.w_0"), + bias_attr=ParamAttr(name="fc_0.b_0")) + + def forward(self, inputs): + y = self.conv(inputs) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def RegNetX_200MF(pretrained=False, use_ssld=False, **kwargs): + model = RegNet( + w_a=36.44, + w_0=24, + w_m=2.49, + d=13, + group_w=8, + bot_mul=1.0, + q=8, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RegNetX_200MF"], use_ssld=use_ssld) + return model + + +def RegNetX_4GF(pretrained=False, use_ssld=False, **kwargs): + model = RegNet( + w_a=38.65, + w_0=96, + w_m=2.43, + d=23, + group_w=40, + bot_mul=1.0, + q=8, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RegNetX_4GF"], use_ssld=use_ssld) + return model + + +def RegNetX_32GF(pretrained=False, use_ssld=False, **kwargs): + model = RegNet( + w_a=69.86, + w_0=320, + w_m=2.0, + d=23, + group_w=168, + bot_mul=1.0, + q=8, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RegNetX_32GF"], use_ssld=use_ssld) + return model + + +def RegNetY_200MF(pretrained=False, use_ssld=False, **kwargs): + model = RegNet( + w_a=36.44, + w_0=24, + w_m=2.49, + d=13, + group_w=8, + bot_mul=1.0, + q=8, + se_on=True, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RegNetX_32GF"], use_ssld=use_ssld) + return model + + +def RegNetY_4GF(pretrained=False, use_ssld=False, **kwargs): + model = RegNet( + w_a=31.41, + w_0=96, + w_m=2.24, + d=22, + group_w=64, + bot_mul=1.0, + q=8, + se_on=True, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RegNetX_32GF"], use_ssld=use_ssld) + return model + + +def RegNetY_32GF(pretrained=False, use_ssld=False, **kwargs): + model = RegNet( + w_a=115.89, + w_0=232, + w_m=2.53, + d=20, + group_w=232, + bot_mul=1.0, + q=8, + se_on=True, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RegNetX_32GF"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/repvgg.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/repvgg.py new file mode 100644 index 0000000..1218be7 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/repvgg.py @@ -0,0 +1,382 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/DingXiaoH/RepVGG + +import paddle.nn as nn +import paddle +import numpy as np + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "RepVGG_A0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A0_pretrained.pdparams", + "RepVGG_A1": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A1_pretrained.pdparams", + "RepVGG_A2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_A2_pretrained.pdparams", + "RepVGG_B0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B0_pretrained.pdparams", + "RepVGG_B1": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1_pretrained.pdparams", + "RepVGG_B2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B2_pretrained.pdparams", + "RepVGG_B1g2": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1g2_pretrained.pdparams", + "RepVGG_B1g4": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B1g4_pretrained.pdparams", + "RepVGG_B2g4": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B2g4_pretrained.pdparams", + "RepVGG_B3g4": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RepVGG_B3g4_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + +optional_groupwise_layers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26] +g2_map = {l: 2 for l in optional_groupwise_layers} +g4_map = {l: 4 for l in optional_groupwise_layers} + + +class ConvBN(nn.Layer): + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride, + padding, + groups=1): + super(ConvBN, self).__init__() + self.conv = nn.Conv2D( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + groups=groups, + bias_attr=False) + self.bn = nn.BatchNorm2D(num_features=out_channels) + + def forward(self, x): + y = self.conv(x) + y = self.bn(y) + return y + + +class RepVGGBlock(nn.Layer): + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + padding_mode='zeros'): + super(RepVGGBlock, self).__init__() + self.is_repped = False + + self.in_channels = in_channels + self.out_channels = out_channels + self.kernel_size = kernel_size + self.stride = stride + self.padding = padding + self.dilation = dilation + self.groups = groups + self.padding_mode = padding_mode + + assert kernel_size == 3 + assert padding == 1 + + padding_11 = padding - kernel_size // 2 + + self.nonlinearity = nn.ReLU() + + self.rbr_identity = nn.BatchNorm2D( + num_features=in_channels + ) if out_channels == in_channels and stride == 1 else None + self.rbr_dense = ConvBN( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + groups=groups) + self.rbr_1x1 = ConvBN( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=1, + stride=stride, + padding=padding_11, + groups=groups) + + def forward(self, inputs): + if not self.training and not self.is_repped: + self.rep() + self.is_repped = True + if self.training and self.is_repped: + self.is_repped = False + + if not self.training: + return self.nonlinearity(self.rbr_reparam(inputs)) + + if self.rbr_identity is None: + id_out = 0 + else: + id_out = self.rbr_identity(inputs) + return self.nonlinearity( + self.rbr_dense(inputs) + self.rbr_1x1(inputs) + id_out) + + def rep(self): + if not hasattr(self, 'rbr_reparam'): + self.rbr_reparam = nn.Conv2D( + in_channels=self.in_channels, + out_channels=self.out_channels, + kernel_size=self.kernel_size, + stride=self.stride, + padding=self.padding, + dilation=self.dilation, + groups=self.groups, + padding_mode=self.padding_mode) + kernel, bias = self.get_equivalent_kernel_bias() + self.rbr_reparam.weight.set_value(kernel) + self.rbr_reparam.bias.set_value(bias) + + def get_equivalent_kernel_bias(self): + kernel3x3, bias3x3 = self._fuse_bn_tensor(self.rbr_dense) + kernel1x1, bias1x1 = self._fuse_bn_tensor(self.rbr_1x1) + kernelid, biasid = self._fuse_bn_tensor(self.rbr_identity) + return kernel3x3 + self._pad_1x1_to_3x3_tensor( + kernel1x1) + kernelid, bias3x3 + bias1x1 + biasid + + def _pad_1x1_to_3x3_tensor(self, kernel1x1): + if kernel1x1 is None: + return 0 + else: + return nn.functional.pad(kernel1x1, [1, 1, 1, 1]) + + def _fuse_bn_tensor(self, branch): + if branch is None: + return 0, 0 + if isinstance(branch, ConvBN): + kernel = branch.conv.weight + running_mean = branch.bn._mean + running_var = branch.bn._variance + gamma = branch.bn.weight + beta = branch.bn.bias + eps = branch.bn._epsilon + else: + assert isinstance(branch, nn.BatchNorm2D) + if not hasattr(self, 'id_tensor'): + input_dim = self.in_channels // self.groups + kernel_value = np.zeros( + (self.in_channels, input_dim, 3, 3), dtype=np.float32) + for i in range(self.in_channels): + kernel_value[i, i % input_dim, 1, 1] = 1 + self.id_tensor = paddle.to_tensor(kernel_value) + kernel = self.id_tensor + running_mean = branch._mean + running_var = branch._variance + gamma = branch.weight + beta = branch.bias + eps = branch._epsilon + std = (running_var + eps).sqrt() + t = (gamma / std).reshape((-1, 1, 1, 1)) + return kernel * t, beta - running_mean * gamma / std + + +class RepVGG(nn.Layer): + def __init__(self, + num_blocks, + width_multiplier=None, + override_groups_map=None, + class_num=1000): + super(RepVGG, self).__init__() + + assert len(width_multiplier) == 4 + self.override_groups_map = override_groups_map or dict() + + assert 0 not in self.override_groups_map + + self.in_planes = min(64, int(64 * width_multiplier[0])) + + self.stage0 = RepVGGBlock( + in_channels=3, + out_channels=self.in_planes, + kernel_size=3, + stride=2, + padding=1) + self.cur_layer_idx = 1 + self.stage1 = self._make_stage( + int(64 * width_multiplier[0]), num_blocks[0], stride=2) + self.stage2 = self._make_stage( + int(128 * width_multiplier[1]), num_blocks[1], stride=2) + self.stage3 = self._make_stage( + int(256 * width_multiplier[2]), num_blocks[2], stride=2) + self.stage4 = self._make_stage( + int(512 * width_multiplier[3]), num_blocks[3], stride=2) + self.gap = nn.AdaptiveAvgPool2D(output_size=1) + self.linear = nn.Linear(int(512 * width_multiplier[3]), class_num) + + def _make_stage(self, planes, num_blocks, stride): + strides = [stride] + [1] * (num_blocks - 1) + blocks = [] + for stride in strides: + cur_groups = self.override_groups_map.get(self.cur_layer_idx, 1) + blocks.append( + RepVGGBlock( + in_channels=self.in_planes, + out_channels=planes, + kernel_size=3, + stride=stride, + padding=1, + groups=cur_groups)) + self.in_planes = planes + self.cur_layer_idx += 1 + return nn.Sequential(*blocks) + + def forward(self, x): + out = self.stage0(x) + out = self.stage1(out) + out = self.stage2(out) + out = self.stage3(out) + out = self.stage4(out) + out = self.gap(out) + out = paddle.flatten(out, start_axis=1) + out = self.linear(out) + return out + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def RepVGG_A0(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[2, 4, 14, 1], + width_multiplier=[0.75, 0.75, 0.75, 2.5], + override_groups_map=None, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_A0"], use_ssld=use_ssld) + return model + + +def RepVGG_A1(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[2, 4, 14, 1], + width_multiplier=[1, 1, 1, 2.5], + override_groups_map=None, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_A1"], use_ssld=use_ssld) + return model + + +def RepVGG_A2(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[2, 4, 14, 1], + width_multiplier=[1.5, 1.5, 1.5, 2.75], + override_groups_map=None, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_A2"], use_ssld=use_ssld) + return model + + +def RepVGG_B0(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[1, 1, 1, 2.5], + override_groups_map=None, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B0"], use_ssld=use_ssld) + return model + + +def RepVGG_B1(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[2, 2, 2, 4], + override_groups_map=None, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B1"], use_ssld=use_ssld) + return model + + +def RepVGG_B1g2(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[2, 2, 2, 4], + override_groups_map=g2_map, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B1g2"], use_ssld=use_ssld) + return model + + +def RepVGG_B1g4(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[2, 2, 2, 4], + override_groups_map=g4_map, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B1g4"], use_ssld=use_ssld) + return model + + +def RepVGG_B2(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[2.5, 2.5, 2.5, 5], + override_groups_map=None, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B2"], use_ssld=use_ssld) + return model + + +def RepVGG_B2g4(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[2.5, 2.5, 2.5, 5], + override_groups_map=g4_map, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B2g4"], use_ssld=use_ssld) + return model + + +def RepVGG_B3g4(pretrained=False, use_ssld=False, **kwargs): + model = RepVGG( + num_blocks=[4, 6, 16, 1], + width_multiplier=[3, 3, 3, 5], + override_groups_map=g4_map, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["RepVGG_B3g4"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/res2net.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/res2net.py new file mode 100644 index 0000000..191cc84 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/res2net.py @@ -0,0 +1,264 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "Res2Net50_26w_4s": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_26w_4s_pretrained.pdparams", + "Res2Net50_14w_8s": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_14w_8s_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__( + self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act=None, + name=None, ): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + if name == "conv1": + bn_name = "bn_" + name + else: + bn_name = "bn" + name[3:] + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels1, + num_channels2, + num_filters, + stride, + scales, + shortcut=True, + if_first=False, + name=None): + super(BottleneckBlock, self).__init__() + self.stride = stride + self.scales = scales + self.conv0 = ConvBNLayer( + num_channels=num_channels1, + num_filters=num_filters, + filter_size=1, + act='relu', + name=name + "_branch2a") + self.conv1_list = [] + for s in range(scales - 1): + conv1 = self.add_sublayer( + name + '_branch2b_' + str(s + 1), + ConvBNLayer( + num_channels=num_filters // scales, + num_filters=num_filters // scales, + filter_size=3, + stride=stride, + act='relu', + name=name + '_branch2b_' + str(s + 1))) + self.conv1_list.append(conv1) + self.pool2d_avg = AvgPool2D(kernel_size=3, stride=stride, padding=1) + + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_channels2, + filter_size=1, + act=None, + name=name + "_branch2c") + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels1, + num_filters=num_channels2, + filter_size=1, + stride=stride, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + xs = paddle.split(y, self.scales, 1) + ys = [] + for s, conv1 in enumerate(self.conv1_list): + if s == 0 or self.stride == 2: + ys.append(conv1(xs[s])) + else: + ys.append(conv1(paddle.add(xs[s], ys[-1]))) + if self.stride == 1: + ys.append(xs[-1]) + else: + ys.append(self.pool2d_avg(xs[-1])) + conv1 = paddle.concat(ys, axis=1) + conv2 = self.conv2(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=conv2) + y = F.relu(y) + return y + + +class Res2Net(nn.Layer): + def __init__(self, layers=50, scales=4, width=26, class_num=1000): + super(Res2Net, self).__init__() + + self.layers = layers + self.scales = scales + self.width = width + basic_width = self.width * self.scales + supported_layers = [50, 101, 152, 200] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + + if layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + elif layers == 200: + depth = [3, 12, 48, 3] + num_channels = [64, 256, 512, 1024] + num_channels2 = [256, 512, 1024, 2048] + num_filters = [basic_width * t for t in [1, 2, 4, 8]] + + self.conv1 = ConvBNLayer( + num_channels=3, + num_filters=64, + filter_size=7, + stride=2, + act='relu', + name="conv1") + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_list = [] + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + if layers in [101, 152] and block == 2: + if i == 0: + conv_name = "res" + str(block + 2) + "a" + else: + conv_name = "res" + str(block + 2) + "b" + str(i) + else: + conv_name = "res" + str(block + 2) + chr(97 + i) + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels1=num_channels[block] + if i == 0 else num_channels2[block], + num_channels2=num_channels2[block], + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + scales=scales, + shortcut=shortcut, + if_first=block == i == 0, + name=conv_name)) + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, inputs): + y = self.conv1(inputs) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def Res2Net50_26w_4s(pretrained=False, use_ssld=False, **kwargs): + model = Res2Net(layers=50, scales=4, width=26, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Res2Net50_26w_4s"], use_ssld=use_ssld) + return model + + +def Res2Net50_14w_8s(pretrained=False, use_ssld=False, **kwargs): + model = Res2Net(layers=50, scales=8, width=14, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Res2Net50_14w_8s"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/res2net_vd.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/res2net_vd.py new file mode 100644 index 0000000..a375679 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/res2net_vd.py @@ -0,0 +1,305 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "Res2Net50_vd_26w_4s": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_vd_26w_4s_pretrained.pdparams", + "Res2Net101_vd_26w_4s": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net101_vd_26w_4s_pretrained.pdparams", + "Res2Net200_vd_26w_4s": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__( + self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + is_vd_mode=False, + act=None, + name=None, ): + super(ConvBNLayer, self).__init__() + + self.is_vd_mode = is_vd_mode + self._pool2d_avg = AvgPool2D( + kernel_size=2, stride=2, padding=0, ceil_mode=True) + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + if name == "conv1": + bn_name = "bn_" + name + else: + bn_name = "bn" + name[3:] + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + if self.is_vd_mode: + inputs = self._pool2d_avg(inputs) + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels1, + num_channels2, + num_filters, + stride, + scales, + shortcut=True, + if_first=False, + name=None): + super(BottleneckBlock, self).__init__() + self.stride = stride + self.scales = scales + self.conv0 = ConvBNLayer( + num_channels=num_channels1, + num_filters=num_filters, + filter_size=1, + act='relu', + name=name + "_branch2a") + self.conv1_list = [] + for s in range(scales - 1): + conv1 = self.add_sublayer( + name + '_branch2b_' + str(s + 1), + ConvBNLayer( + num_channels=num_filters // scales, + num_filters=num_filters // scales, + filter_size=3, + stride=stride, + act='relu', + name=name + '_branch2b_' + str(s + 1))) + self.conv1_list.append(conv1) + self.pool2d_avg = AvgPool2D(kernel_size=3, stride=stride, padding=1) + + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_channels2, + filter_size=1, + act=None, + name=name + "_branch2c") + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels1, + num_filters=num_channels2, + filter_size=1, + stride=1, + is_vd_mode=False if if_first else True, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + xs = paddle.split(y, self.scales, 1) + ys = [] + for s, conv1 in enumerate(self.conv1_list): + if s == 0 or self.stride == 2: + ys.append(conv1(xs[s])) + else: + ys.append(conv1(xs[s] + ys[-1])) + if self.stride == 1: + ys.append(xs[-1]) + else: + ys.append(self.pool2d_avg(xs[-1])) + conv1 = paddle.concat(ys, axis=1) + conv2 = self.conv2(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=conv2) + y = F.relu(y) + return y + + +class Res2Net_vd(nn.Layer): + def __init__(self, layers=50, scales=4, width=26, class_num=1000): + super(Res2Net_vd, self).__init__() + + self.layers = layers + self.scales = scales + self.width = width + basic_width = self.width * self.scales + supported_layers = [50, 101, 152, 200] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + + if layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + elif layers == 200: + depth = [3, 12, 48, 3] + num_channels = [64, 256, 512, 1024] + num_channels2 = [256, 512, 1024, 2048] + num_filters = [basic_width * t for t in [1, 2, 4, 8]] + + self.conv1_1 = ConvBNLayer( + num_channels=3, + num_filters=32, + filter_size=3, + stride=2, + act='relu', + name="conv1_1") + self.conv1_2 = ConvBNLayer( + num_channels=32, + num_filters=32, + filter_size=3, + stride=1, + act='relu', + name="conv1_2") + self.conv1_3 = ConvBNLayer( + num_channels=32, + num_filters=64, + filter_size=3, + stride=1, + act='relu', + name="conv1_3") + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_list = [] + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + if layers in [101, 152, 200] and block == 2: + if i == 0: + conv_name = "res" + str(block + 2) + "a" + else: + conv_name = "res" + str(block + 2) + "b" + str(i) + else: + conv_name = "res" + str(block + 2) + chr(97 + i) + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels1=num_channels[block] + if i == 0 else num_channels2[block], + num_channels2=num_channels2[block], + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + scales=scales, + shortcut=shortcut, + if_first=block == i == 0, + name=conv_name)) + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, inputs): + y = self.conv1_1(inputs) + y = self.conv1_2(y) + y = self.conv1_3(y) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def Res2Net50_vd_26w_4s(pretrained=False, use_ssld=False, **kwargs): + model = Res2Net_vd(layers=50, scales=4, width=26, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["Res2Net50_vd_26w_4s"], + use_ssld=use_ssld) + return model + + +def Res2Net101_vd_26w_4s(pretrained=False, use_ssld=False, **kwargs): + model = Res2Net_vd(layers=101, scales=4, width=26, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["Res2Net101_vd_26w_4s"], + use_ssld=use_ssld) + return model + + +def Res2Net200_vd_26w_4s(pretrained=False, use_ssld=False, **kwargs): + model = Res2Net_vd(layers=200, scales=4, width=26, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["Res2Net200_vd_26w_4s"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnest.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnest.py new file mode 100644 index 0000000..88eee8a --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnest.py @@ -0,0 +1,740 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/zhanghang1989/ResNeSt + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +import math +import paddle.nn as nn +import paddle.nn.functional as F +from paddle import ParamAttr +from paddle.nn.initializer import KaimingNormal +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.regularizer import L2Decay + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNeSt50_fast_1s1x64d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_fast_1s1x64d_pretrained.pdparams", + "ResNeSt50": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_pretrained.pdparams", + "ResNeSt101": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt101_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + dilation=1, + groups=1, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + + bn_decay = 0.0 + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + dilation=dilation, + groups=groups, + weight_attr=ParamAttr(name=name + "_weight"), + bias_attr=False) + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr( + name=name + "_scale", regularizer=L2Decay(bn_decay)), + bias_attr=ParamAttr( + name + "_offset", regularizer=L2Decay(bn_decay)), + moving_mean_name=name + "_mean", + moving_variance_name=name + "_variance") + + def forward(self, x): + x = self._conv(x) + x = self._batch_norm(x) + return x + + +class rSoftmax(nn.Layer): + def __init__(self, radix, cardinality): + super(rSoftmax, self).__init__() + self.radix = radix + self.cardinality = cardinality + + def forward(self, x): + cardinality = self.cardinality + radix = self.radix + + batch, r, h, w = x.shape + if self.radix > 1: + x = paddle.reshape( + x=x, + shape=[ + batch, cardinality, radix, + int(r * h * w / cardinality / radix) + ]) + x = paddle.transpose(x=x, perm=[0, 2, 1, 3]) + x = nn.functional.softmax(x, axis=1) + x = paddle.reshape(x=x, shape=[batch, r * h * w, 1, 1]) + else: + x = nn.functional.sigmoid(x) + return x + + +class SplatConv(nn.Layer): + def __init__(self, + in_channels, + channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True, + radix=2, + reduction_factor=4, + rectify_avg=False, + name=None): + super(SplatConv, self).__init__() + + self.radix = radix + + self.conv1 = ConvBNLayer( + num_channels=in_channels, + num_filters=channels * radix, + filter_size=kernel_size, + stride=stride, + groups=groups * radix, + act="relu", + name=name + "_1_weights") + + self.avg_pool2d = AdaptiveAvgPool2D(1) + + inter_channels = int(max(in_channels * radix // reduction_factor, 32)) + + # to calc gap + self.conv2 = ConvBNLayer( + num_channels=channels, + num_filters=inter_channels, + filter_size=1, + stride=1, + groups=groups, + act="relu", + name=name + "_2_weights") + + # to calc atten + self.conv3 = Conv2D( + in_channels=inter_channels, + out_channels=channels * radix, + kernel_size=1, + stride=1, + padding=0, + groups=groups, + weight_attr=ParamAttr( + name=name + "_weights", initializer=KaimingNormal()), + bias_attr=False) + + self.rsoftmax = rSoftmax(radix=radix, cardinality=groups) + + def forward(self, x): + x = self.conv1(x) + + if self.radix > 1: + splited = paddle.split(x, num_or_sections=self.radix, axis=1) + gap = paddle.add_n(splited) + else: + gap = x + + gap = self.avg_pool2d(gap) + gap = self.conv2(gap) + + atten = self.conv3(gap) + atten = self.rsoftmax(atten) + + if self.radix > 1: + attens = paddle.split(atten, num_or_sections=self.radix, axis=1) + y = paddle.add_n([ + paddle.multiply(split, att) + for (att, split) in zip(attens, splited) + ]) + else: + y = paddle.multiply(x, atten) + + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + inplanes, + planes, + stride=1, + radix=1, + cardinality=1, + bottleneck_width=64, + avd=False, + avd_first=False, + dilation=1, + is_first=False, + rectify_avg=False, + last_gamma=False, + avg_down=False, + name=None): + super(BottleneckBlock, self).__init__() + self.inplanes = inplanes + self.planes = planes + self.stride = stride + self.radix = radix + self.cardinality = cardinality + self.avd = avd + self.avd_first = avd_first + self.dilation = dilation + self.is_first = is_first + self.rectify_avg = rectify_avg + self.last_gamma = last_gamma + self.avg_down = avg_down + + group_width = int(planes * (bottleneck_width / 64.)) * cardinality + + self.conv1 = ConvBNLayer( + num_channels=self.inplanes, + num_filters=group_width, + filter_size=1, + stride=1, + groups=1, + act="relu", + name=name + "_conv1") + + if avd and avd_first and (stride > 1 or is_first): + self.avg_pool2d_1 = AvgPool2D( + kernel_size=3, stride=stride, padding=1) + + if radix >= 1: + self.conv2 = SplatConv( + in_channels=group_width, + channels=group_width, + kernel_size=3, + stride=1, + padding=dilation, + dilation=dilation, + groups=cardinality, + bias=False, + radix=radix, + rectify_avg=rectify_avg, + name=name + "_splat") + else: + self.conv2 = ConvBNLayer( + num_channels=group_width, + num_filters=group_width, + filter_size=3, + stride=1, + dilation=dilation, + groups=cardinality, + act="relu", + name=name + "_conv2") + + if avd and avd_first == False and (stride > 1 or is_first): + self.avg_pool2d_2 = AvgPool2D( + kernel_size=3, stride=stride, padding=1) + + self.conv3 = ConvBNLayer( + num_channels=group_width, + num_filters=planes * 4, + filter_size=1, + stride=1, + groups=1, + act=None, + name=name + "_conv3") + + if stride != 1 or self.inplanes != self.planes * 4: + if avg_down: + if dilation == 1: + self.avg_pool2d_3 = AvgPool2D( + kernel_size=stride, stride=stride, padding=0) + else: + self.avg_pool2d_3 = AvgPool2D( + kernel_size=1, stride=1, padding=0, ceil_mode=True) + + self.conv4 = Conv2D( + in_channels=self.inplanes, + out_channels=planes * 4, + kernel_size=1, + stride=1, + padding=0, + groups=1, + weight_attr=ParamAttr( + name=name + "_weights", initializer=KaimingNormal()), + bias_attr=False) + else: + self.conv4 = Conv2D( + in_channels=self.inplanes, + out_channels=planes * 4, + kernel_size=1, + stride=stride, + padding=0, + groups=1, + weight_attr=ParamAttr( + name=name + "_shortcut_weights", + initializer=KaimingNormal()), + bias_attr=False) + + bn_decay = 0.0 + self._batch_norm = BatchNorm( + planes * 4, + act=None, + param_attr=ParamAttr( + name=name + "_shortcut_scale", + regularizer=L2Decay(bn_decay)), + bias_attr=ParamAttr( + name + "_shortcut_offset", regularizer=L2Decay(bn_decay)), + moving_mean_name=name + "_shortcut_mean", + moving_variance_name=name + "_shortcut_variance") + + def forward(self, x): + short = x + + x = self.conv1(x) + if self.avd and self.avd_first and (self.stride > 1 or self.is_first): + x = self.avg_pool2d_1(x) + + x = self.conv2(x) + + if self.avd and self.avd_first == False and (self.stride > 1 or + self.is_first): + x = self.avg_pool2d_2(x) + + x = self.conv3(x) + + if self.stride != 1 or self.inplanes != self.planes * 4: + if self.avg_down: + short = self.avg_pool2d_3(short) + + short = self.conv4(short) + + short = self._batch_norm(short) + + y = paddle.add(x=short, y=x) + y = F.relu(y) + return y + + +class ResNeStLayer(nn.Layer): + def __init__(self, + inplanes, + planes, + blocks, + radix, + cardinality, + bottleneck_width, + avg_down, + avd, + avd_first, + rectify_avg, + last_gamma, + stride=1, + dilation=1, + is_first=True, + name=None): + super(ResNeStLayer, self).__init__() + self.inplanes = inplanes + self.planes = planes + self.blocks = blocks + self.radix = radix + self.cardinality = cardinality + self.bottleneck_width = bottleneck_width + self.avg_down = avg_down + self.avd = avd + self.avd_first = avd_first + self.rectify_avg = rectify_avg + self.last_gamma = last_gamma + self.is_first = is_first + + if dilation == 1 or dilation == 2: + bottleneck_func = self.add_sublayer( + name + "_bottleneck_0", + BottleneckBlock( + inplanes=self.inplanes, + planes=planes, + stride=stride, + radix=radix, + cardinality=cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + dilation=1, + is_first=is_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + name=name + "_bottleneck_0")) + elif dilation == 4: + bottleneck_func = self.add_sublayer( + name + "_bottleneck_0", + BottleneckBlock( + inplanes=self.inplanes, + planes=planes, + stride=stride, + radix=radix, + cardinality=cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + dilation=2, + is_first=is_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + name=name + "_bottleneck_0")) + else: + raise RuntimeError("=>unknown dilation size") + + self.inplanes = planes * 4 + self.bottleneck_block_list = [bottleneck_func] + for i in range(1, blocks): + curr_name = name + "_bottleneck_" + str(i) + + bottleneck_func = self.add_sublayer( + curr_name, + BottleneckBlock( + inplanes=self.inplanes, + planes=planes, + radix=radix, + cardinality=cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + dilation=dilation, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + name=curr_name)) + self.bottleneck_block_list.append(bottleneck_func) + + def forward(self, x): + for bottleneck_block in self.bottleneck_block_list: + x = bottleneck_block(x) + return x + + +class ResNeSt(nn.Layer): + def __init__(self, + layers, + radix=1, + groups=1, + bottleneck_width=64, + dilated=False, + dilation=1, + deep_stem=False, + stem_width=64, + avg_down=False, + rectify_avg=False, + avd=False, + avd_first=False, + final_drop=0.0, + last_gamma=False, + class_num=1000): + super(ResNeSt, self).__init__() + + self.cardinality = groups + self.bottleneck_width = bottleneck_width + # ResNet-D params + self.inplanes = stem_width * 2 if deep_stem else 64 + self.avg_down = avg_down + self.last_gamma = last_gamma + # ResNeSt params + self.radix = radix + self.avd = avd + self.avd_first = avd_first + + self.deep_stem = deep_stem + self.stem_width = stem_width + self.layers = layers + self.final_drop = final_drop + self.dilated = dilated + self.dilation = dilation + + self.rectify_avg = rectify_avg + + if self.deep_stem: + self.stem = nn.Sequential( + ("conv1", ConvBNLayer( + num_channels=3, + num_filters=stem_width, + filter_size=3, + stride=2, + act="relu", + name="conv1")), ("conv2", ConvBNLayer( + num_channels=stem_width, + num_filters=stem_width, + filter_size=3, + stride=1, + act="relu", + name="conv2")), ("conv3", ConvBNLayer( + num_channels=stem_width, + num_filters=stem_width * 2, + filter_size=3, + stride=1, + act="relu", + name="conv3"))) + else: + self.stem = ConvBNLayer( + num_channels=3, + num_filters=stem_width, + filter_size=7, + stride=2, + act="relu", + name="conv1") + + self.max_pool2d = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.layer1 = ResNeStLayer( + inplanes=self.stem_width * 2 + if self.deep_stem else self.stem_width, + planes=64, + blocks=self.layers[0], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=1, + dilation=1, + is_first=False, + name="layer1") + + # return + + self.layer2 = ResNeStLayer( + inplanes=256, + planes=128, + blocks=self.layers[1], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=2, + name="layer2") + + if self.dilated or self.dilation == 4: + self.layer3 = ResNeStLayer( + inplanes=512, + planes=256, + blocks=self.layers[2], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=1, + dilation=2, + name="layer3") + self.layer4 = ResNeStLayer( + inplanes=1024, + planes=512, + blocks=self.layers[3], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=1, + dilation=4, + name="layer4") + elif self.dilation == 2: + self.layer3 = ResNeStLayer( + inplanes=512, + planes=256, + blocks=self.layers[2], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=2, + dilation=1, + name="layer3") + self.layer4 = ResNeStLayer( + inplanes=1024, + planes=512, + blocks=self.layers[3], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=1, + dilation=2, + name="layer4") + else: + self.layer3 = ResNeStLayer( + inplanes=512, + planes=256, + blocks=self.layers[2], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=2, + name="layer3") + self.layer4 = ResNeStLayer( + inplanes=1024, + planes=512, + blocks=self.layers[3], + radix=radix, + cardinality=self.cardinality, + bottleneck_width=bottleneck_width, + avg_down=self.avg_down, + avd=avd, + avd_first=avd_first, + rectify_avg=rectify_avg, + last_gamma=last_gamma, + stride=2, + name="layer4") + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.out_channels = 2048 + + stdv = 1.0 / math.sqrt(self.out_channels * 1.0) + + self.out = Linear( + self.out_channels, + class_num, + weight_attr=ParamAttr( + initializer=nn.initializer.Uniform(-stdv, stdv), + name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, x): + x = self.stem(x) + x = self.max_pool2d(x) + x = self.layer1(x) + x = self.layer2(x) + + x = self.layer3(x) + + x = self.layer4(x) + x = self.pool2d_avg(x) + x = paddle.reshape(x, shape=[-1, self.out_channels]) + x = self.out(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNeSt50_fast_1s1x64d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeSt( + layers=[3, 4, 6, 3], + radix=1, + groups=1, + bottleneck_width=64, + deep_stem=True, + stem_width=32, + avg_down=True, + avd=True, + avd_first=True, + final_drop=0.0, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeSt50_fast_1s1x64d"], + use_ssld=use_ssld) + return model + + +def ResNeSt50(pretrained=False, use_ssld=False, **kwargs): + model = ResNeSt( + layers=[3, 4, 6, 3], + radix=2, + groups=1, + bottleneck_width=64, + deep_stem=True, + stem_width=32, + avg_down=True, + avd=True, + avd_first=False, + final_drop=0.0, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeSt50"], use_ssld=use_ssld) + return model + + +def ResNeSt101(pretrained=False, use_ssld=False, **kwargs): + model = ResNeSt( + layers=[3, 4, 23, 3], + radix=2, + groups=1, + bottleneck_width=64, + deep_stem=True, + stem_width=64, + avg_down=True, + avd=True, + avd_first=False, + final_drop=0.0, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeSt101"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnet_vc.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnet_vc.py new file mode 100644 index 0000000..6b972dc --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnet_vc.py @@ -0,0 +1,309 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNet50_vc": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vc_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + if name == "conv1": + bn_name = "bn_" + name + else: + bn_name = "bn" + name[3:] + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + name=None): + super(BottleneckBlock, self).__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act='relu', + name=name + "_branch2a") + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + stride=stride, + act='relu', + name=name + "_branch2b") + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 4, + filter_size=1, + act=None, + name=name + "_branch2c") + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 4, + filter_size=1, + stride=stride, + name=name + "_branch1") + + self.shortcut = shortcut + + self._num_channels_out = num_filters * 4 + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + conv2 = self.conv2(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + + y = paddle.add(x=short, y=conv2) + y = F.relu(y) + return y + + +class BasicBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + name=None): + super(BasicBlock, self).__init__() + self.stride = stride + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=3, + stride=stride, + act='relu', + name=name + "_branch2a") + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + act=None, + name=name + "_branch2b") + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + stride=stride, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=conv1) + y = F.relu(y) + return y + + +class ResNet_vc(nn.Layer): + def __init__(self, layers=50, class_num=1000): + super(ResNet_vc, self).__init__() + + self.layers = layers + supported_layers = [18, 34, 50, 101, 152] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + + if layers == 18: + depth = [2, 2, 2, 2] + elif layers == 34 or layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + num_channels = [64, 256, 512, + 1024] if layers >= 50 else [64, 64, 128, 256] + num_filters = [64, 128, 256, 512] + + self.conv1_1 = ConvBNLayer( + num_channels=3, + num_filters=32, + filter_size=3, + stride=2, + act='relu', + name="conv1_1") + self.conv1_2 = ConvBNLayer( + num_channels=32, + num_filters=32, + filter_size=3, + stride=1, + act='relu', + name="conv1_2") + self.conv1_3 = ConvBNLayer( + num_channels=32, + num_filters=64, + filter_size=3, + stride=1, + act='relu', + name="conv1_3") + + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_list = [] + if layers >= 50: + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + if layers in [101, 152] and block == 2: + if i == 0: + conv_name = "res" + str(block + 2) + "a" + else: + conv_name = "res" + str(block + 2) + "b" + str(i) + else: + conv_name = "res" + str(block + 2) + chr(97 + i) + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels=num_channels[block] + if i == 0 else num_filters[block] * 4, + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + shortcut=shortcut, + name=conv_name)) + self.block_list.append(bottleneck_block) + shortcut = True + else: + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + conv_name = "res" + str(block + 2) + chr(97 + i) + basic_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BasicBlock( + num_channels=num_channels[block] + if i == 0 else num_filters[block], + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + shortcut=shortcut, + name=conv_name)) + self.block_list.append(basic_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_0.w_0"), + bias_attr=ParamAttr(name="fc_0.b_0")) + + def forward(self, inputs): + y = self.conv1_1(inputs) + y = self.conv1_2(y) + y = self.conv1_3(y) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNet50_vc(pretrained=False, use_ssld=False, **kwargs): + model = ResNet_vc(layers=50, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNet50_vc"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext.py new file mode 100644 index 0000000..1aef811 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext.py @@ -0,0 +1,298 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNeXt50_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_32x4d_pretrained.pdparams", + "ResNeXt50_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_64x4d_pretrained.pdparams", + "ResNeXt101_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x4d_pretrained.pdparams", + "ResNeXt101_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_64x4d_pretrained.pdparams", + "ResNeXt152_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_32x4d_pretrained.pdparams", + "ResNeXt152_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_64x4d_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act=None, + name=None, + data_format="NCHW"): + super(ConvBNLayer, self).__init__() + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False, + data_format=data_format) + if name == "conv1": + bn_name = "bn_" + name + else: + bn_name = "bn" + name[3:] + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance', + data_layout=data_format) + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + cardinality, + shortcut=True, + name=None, + data_format="NCHW"): + super(BottleneckBlock, self).__init__() + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act='relu', + name=name + "_branch2a", + data_format=data_format) + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + groups=cardinality, + stride=stride, + act='relu', + name=name + "_branch2b", + data_format=data_format) + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 2 if cardinality == 32 else num_filters, + filter_size=1, + act=None, + name=name + "_branch2c", + data_format=data_format) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 2 + if cardinality == 32 else num_filters, + filter_size=1, + stride=stride, + name=name + "_branch1", + data_format=data_format) + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + conv2 = self.conv2(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + + y = paddle.add(x=short, y=conv2) + y = F.relu(y) + return y + + +class ResNeXt(nn.Layer): + def __init__(self, + layers=50, + class_num=1000, + cardinality=32, + input_image_channel=3, + data_format="NCHW"): + super(ResNeXt, self).__init__() + + self.layers = layers + self.data_format = data_format + self.input_image_channel = input_image_channel + self.cardinality = cardinality + supported_layers = [50, 101, 152] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + supported_cardinality = [32, 64] + assert cardinality in supported_cardinality, \ + "supported cardinality is {} but input cardinality is {}" \ + .format(supported_cardinality, cardinality) + if layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + num_channels = [64, 256, 512, 1024] + num_filters = [128, 256, 512, + 1024] if cardinality == 32 else [256, 512, 1024, 2048] + + self.conv = ConvBNLayer( + num_channels=self.input_image_channel, + num_filters=64, + filter_size=7, + stride=2, + act='relu', + name="res_conv1", + data_format=self.data_format) + self.pool2d_max = MaxPool2D( + kernel_size=3, stride=2, padding=1, data_format=self.data_format) + + self.block_list = [] + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + if layers in [101, 152] and block == 2: + if i == 0: + conv_name = "res" + str(block + 2) + "a" + else: + conv_name = "res" + str(block + 2) + "b" + str(i) + else: + conv_name = "res" + str(block + 2) + chr(97 + i) + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels=num_channels[block] if i == 0 else + num_filters[block] * int(64 // self.cardinality), + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + cardinality=self.cardinality, + shortcut=shortcut, + name=conv_name, + data_format=self.data_format)) + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1, data_format=self.data_format) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, inputs): + with paddle.static.amp.fp16_guard(): + if self.data_format == "NHWC": + inputs = paddle.tensor.transpose(inputs, [0, 2, 3, 1]) + inputs.stop_gradient = True + y = self.conv(inputs) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNeXt50_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=50, cardinality=32, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt50_32x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt50_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=50, cardinality=64, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt50_64x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt101_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=101, cardinality=32, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt101_32x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt101_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=101, cardinality=64, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt101_64x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt152_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=152, cardinality=32, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt152_32x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt152_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=152, cardinality=64, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt152_64x4d"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext101_wsl.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext101_wsl.py new file mode 100644 index 0000000..e85e133 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext101_wsl.py @@ -0,0 +1,490 @@ +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNeXt101_32x8d_wsl": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x8d_wsl_pretrained.pdparams", + "ResNeXt101_32x16d_wsl": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x16_wsl_pretrained.pdparams", + "ResNeXt101_32x32d_wsl": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x32d_wsl_pretrained.pdparams", + "ResNeXt101_32x48d_wsl": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x48d_wsl_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter_size, + stride=1, + groups=1, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + if "downsample" in name: + conv_name = name + ".0" + else: + conv_name = name + self._conv = Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=conv_name + ".weight"), + bias_attr=False) + if "downsample" in name: + bn_name = name[:9] + "downsample.1" + else: + if "conv1" == name: + bn_name = "bn" + name[-1] + else: + bn_name = (name[:10] if name[7:9].isdigit() else name[:9] + ) + "bn" + name[-1] + self._bn = BatchNorm( + num_channels=output_channels, + act=act, + param_attr=ParamAttr(name=bn_name + ".weight"), + bias_attr=ParamAttr(name=bn_name + ".bias"), + moving_mean_name=bn_name + ".running_mean", + moving_variance_name=bn_name + ".running_var") + + def forward(self, inputs): + x = self._conv(inputs) + x = self._bn(x) + return x + + +class ShortCut(nn.Layer): + def __init__(self, input_channels, output_channels, stride, name=None): + super(ShortCut, self).__init__() + + self.input_channels = input_channels + self.output_channels = output_channels + self.stride = stride + if input_channels != output_channels or stride != 1: + self._conv = ConvBNLayer( + input_channels, + output_channels, + filter_size=1, + stride=stride, + name=name) + + def forward(self, inputs): + if self.input_channels != self.output_channels or self.stride != 1: + return self._conv(inputs) + return inputs + + +class BottleneckBlock(nn.Layer): + def __init__(self, input_channels, output_channels, stride, cardinality, + width, name): + super(BottleneckBlock, self).__init__() + + self._conv0 = ConvBNLayer( + input_channels, + output_channels, + filter_size=1, + act="relu", + name=name + ".conv1") + self._conv1 = ConvBNLayer( + output_channels, + output_channels, + filter_size=3, + act="relu", + stride=stride, + groups=cardinality, + name=name + ".conv2") + self._conv2 = ConvBNLayer( + output_channels, + output_channels // (width // 8), + filter_size=1, + act=None, + name=name + ".conv3") + self._short = ShortCut( + input_channels, + output_channels // (width // 8), + stride=stride, + name=name + ".downsample") + + def forward(self, inputs): + x = self._conv0(inputs) + x = self._conv1(x) + x = self._conv2(x) + y = self._short(inputs) + y = paddle.add(x, y) + y = F.relu(y) + return y + + +class ResNeXt101WSL(nn.Layer): + def __init__(self, layers=101, cardinality=32, width=48, class_num=1000): + super(ResNeXt101WSL, self).__init__() + + self.class_num = class_num + + self.layers = layers + self.cardinality = cardinality + self.width = width + self.scale = width // 8 + + self.depth = [3, 4, 23, 3] + self.base_width = cardinality * width + num_filters = [self.base_width * i + for i in [1, 2, 4, 8]] # [256, 512, 1024, 2048] + self._conv_stem = ConvBNLayer( + 3, 64, 7, stride=2, act="relu", name="conv1") + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self._conv1_0 = BottleneckBlock( + 64, + num_filters[0], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer1.0") + self._conv1_1 = BottleneckBlock( + num_filters[0] // (width // 8), + num_filters[0], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer1.1") + self._conv1_2 = BottleneckBlock( + num_filters[0] // (width // 8), + num_filters[0], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer1.2") + + self._conv2_0 = BottleneckBlock( + num_filters[0] // (width // 8), + num_filters[1], + stride=2, + cardinality=self.cardinality, + width=self.width, + name="layer2.0") + self._conv2_1 = BottleneckBlock( + num_filters[1] // (width // 8), + num_filters[1], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer2.1") + self._conv2_2 = BottleneckBlock( + num_filters[1] // (width // 8), + num_filters[1], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer2.2") + self._conv2_3 = BottleneckBlock( + num_filters[1] // (width // 8), + num_filters[1], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer2.3") + + self._conv3_0 = BottleneckBlock( + num_filters[1] // (width // 8), + num_filters[2], + stride=2, + cardinality=self.cardinality, + width=self.width, + name="layer3.0") + self._conv3_1 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.1") + self._conv3_2 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.2") + self._conv3_3 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.3") + self._conv3_4 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.4") + self._conv3_5 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.5") + self._conv3_6 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.6") + self._conv3_7 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.7") + self._conv3_8 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.8") + self._conv3_9 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.9") + self._conv3_10 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.10") + self._conv3_11 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.11") + self._conv3_12 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.12") + self._conv3_13 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.13") + self._conv3_14 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.14") + self._conv3_15 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.15") + self._conv3_16 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.16") + self._conv3_17 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.17") + self._conv3_18 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.18") + self._conv3_19 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.19") + self._conv3_20 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.20") + self._conv3_21 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.21") + self._conv3_22 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[2], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer3.22") + + self._conv4_0 = BottleneckBlock( + num_filters[2] // (width // 8), + num_filters[3], + stride=2, + cardinality=self.cardinality, + width=self.width, + name="layer4.0") + self._conv4_1 = BottleneckBlock( + num_filters[3] // (width // 8), + num_filters[3], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer4.1") + self._conv4_2 = BottleneckBlock( + num_filters[3] // (width // 8), + num_filters[3], + stride=1, + cardinality=self.cardinality, + width=self.width, + name="layer4.2") + + self._avg_pool = AdaptiveAvgPool2D(1) + self._out = Linear( + num_filters[3] // (width // 8), + class_num, + weight_attr=ParamAttr(name="fc.weight"), + bias_attr=ParamAttr(name="fc.bias")) + + def forward(self, inputs): + x = self._conv_stem(inputs) + x = self._pool(x) + + x = self._conv1_0(x) + x = self._conv1_1(x) + x = self._conv1_2(x) + + x = self._conv2_0(x) + x = self._conv2_1(x) + x = self._conv2_2(x) + x = self._conv2_3(x) + + x = self._conv3_0(x) + x = self._conv3_1(x) + x = self._conv3_2(x) + x = self._conv3_3(x) + x = self._conv3_4(x) + x = self._conv3_5(x) + x = self._conv3_6(x) + x = self._conv3_7(x) + x = self._conv3_8(x) + x = self._conv3_9(x) + x = self._conv3_10(x) + x = self._conv3_11(x) + x = self._conv3_12(x) + x = self._conv3_13(x) + x = self._conv3_14(x) + x = self._conv3_15(x) + x = self._conv3_16(x) + x = self._conv3_17(x) + x = self._conv3_18(x) + x = self._conv3_19(x) + x = self._conv3_20(x) + x = self._conv3_21(x) + x = self._conv3_22(x) + + x = self._conv4_0(x) + x = self._conv4_1(x) + x = self._conv4_2(x) + + x = self._avg_pool(x) + x = paddle.squeeze(x, axis=[2, 3]) + x = self._out(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNeXt101_32x8d_wsl(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt101WSL(cardinality=32, width=8, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt101_32x8d_wsl"], + use_ssld=use_ssld) + return model + + +def ResNeXt101_32x16d_wsl(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt101WSL(cardinality=32, width=16, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt101_32x16d_wsl"], + use_ssld=use_ssld) + return model + + +def ResNeXt101_32x32d_wsl(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt101WSL(cardinality=32, width=32, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt101_32x32d_wsl"], + use_ssld=use_ssld) + return model + + +def ResNeXt101_32x48d_wsl(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt101WSL(cardinality=32, width=48, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt101_32x48d_wsl"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext_vd.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext_vd.py new file mode 100644 index 0000000..b2bd484 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/resnext_vd.py @@ -0,0 +1,317 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNeXt50_vd_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_32x4d_pretrained.pdparams", + "ResNeXt50_vd_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_64x4d_pretrained.pdparams", + "ResNeXt101_vd_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_32x4d_pretrained.pdparams", + "ResNeXt101_vd_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_64x4d_pretrained.pdparams", + "ResNeXt152_vd_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_32x4d_pretrained.pdparams", + "ResNeXt152_vd_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_64x4d_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__( + self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + is_vd_mode=False, + act=None, + name=None, ): + super(ConvBNLayer, self).__init__() + + self.is_vd_mode = is_vd_mode + self._pool2d_avg = AvgPool2D( + kernel_size=2, stride=2, padding=0, ceil_mode=True) + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + if name == "conv1": + bn_name = "bn_" + name + else: + bn_name = "bn" + name[3:] + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + if self.is_vd_mode: + inputs = self._pool2d_avg(inputs) + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + cardinality, + shortcut=True, + if_first=False, + name=None): + super(BottleneckBlock, self).__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act='relu', + name=name + "_branch2a") + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + groups=cardinality, + stride=stride, + act='relu', + name=name + "_branch2b") + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 2 if cardinality == 32 else num_filters, + filter_size=1, + act=None, + name=name + "_branch2c") + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 2 + if cardinality == 32 else num_filters, + filter_size=1, + stride=1, + is_vd_mode=False if if_first else True, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + conv2 = self.conv2(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + + y = paddle.add(x=short, y=conv2) + y = F.relu(y) + return y + + +class ResNeXt(nn.Layer): + def __init__(self, layers=50, class_num=1000, cardinality=32): + super(ResNeXt, self).__init__() + + self.layers = layers + self.cardinality = cardinality + supported_layers = [50, 101, 152] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + supported_cardinality = [32, 64] + assert cardinality in supported_cardinality, \ + "supported cardinality is {} but input cardinality is {}" \ + .format(supported_cardinality, cardinality) + if layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + num_channels = [64, 256, 512, 1024] + num_filters = [128, 256, 512, + 1024] if cardinality == 32 else [256, 512, 1024, 2048] + + self.conv1_1 = ConvBNLayer( + num_channels=3, + num_filters=32, + filter_size=3, + stride=2, + act='relu', + name="conv1_1") + self.conv1_2 = ConvBNLayer( + num_channels=32, + num_filters=32, + filter_size=3, + stride=1, + act='relu', + name="conv1_2") + self.conv1_3 = ConvBNLayer( + num_channels=32, + num_filters=64, + filter_size=3, + stride=1, + act='relu', + name="conv1_3") + + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_list = [] + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + if layers in [101, 152] and block == 2: + if i == 0: + conv_name = "res" + str(block + 2) + "a" + else: + conv_name = "res" + str(block + 2) + "b" + str(i) + else: + conv_name = "res" + str(block + 2) + chr(97 + i) + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels=num_channels[block] if i == 0 else + num_filters[block] * int(64 // self.cardinality), + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + cardinality=self.cardinality, + shortcut=shortcut, + if_first=block == i == 0, + name=conv_name)) + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc_weights"), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, inputs): + y = self.conv1_1(inputs) + y = self.conv1_2(y) + y = self.conv1_3(y) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNeXt50_vd_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=50, cardinality=32, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt50_vd_32x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt50_vd_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=50, cardinality=64, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ResNeXt50_vd_64x4d"], use_ssld=use_ssld) + return model + + +def ResNeXt101_vd_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=101, cardinality=32, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt101_vd_32x4d"], + use_ssld=use_ssld) + return model + + +def ResNeXt101_vd_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=101, cardinality=64, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt101_vd_64x4d"], + use_ssld=use_ssld) + return model + + +def ResNeXt152_vd_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=152, cardinality=32, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt152_vd_32x4d"], + use_ssld=use_ssld) + return model + + +def ResNeXt152_vd_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=152, cardinality=64, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ResNeXt152_vd_64x4d"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/rexnet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/rexnet.py new file mode 100644 index 0000000..1556a01 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/rexnet.py @@ -0,0 +1,281 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +from math import ceil + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ReXNet_1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_0_pretrained.pdparams", + "ReXNet_1_3": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_3_pretrained.pdparams", + "ReXNet_1_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_5_pretrained.pdparams", + "ReXNet_2_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_2_0_pretrained.pdparams", + "ReXNet_3_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_3_0_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +def conv_bn_act(out, + in_channels, + channels, + kernel=1, + stride=1, + pad=0, + num_group=1, + active=True, + relu6=False): + out.append( + nn.Conv2D( + in_channels, + channels, + kernel, + stride, + pad, + groups=num_group, + bias_attr=False)) + out.append(nn.BatchNorm2D(channels)) + if active: + out.append(nn.ReLU6() if relu6 else nn.ReLU()) + + +def conv_bn_swish(out, + in_channels, + channels, + kernel=1, + stride=1, + pad=0, + num_group=1): + out.append( + nn.Conv2D( + in_channels, + channels, + kernel, + stride, + pad, + groups=num_group, + bias_attr=False)) + out.append(nn.BatchNorm2D(channels)) + out.append(nn.Swish()) + + +class SE(nn.Layer): + def __init__(self, in_channels, channels, se_ratio=12): + super(SE, self).__init__() + self.avg_pool = nn.AdaptiveAvgPool2D(1) + self.fc = nn.Sequential( + nn.Conv2D( + in_channels, channels // se_ratio, kernel_size=1, padding=0), + nn.BatchNorm2D(channels // se_ratio), + nn.ReLU(), + nn.Conv2D( + channels // se_ratio, channels, kernel_size=1, padding=0), + nn.Sigmoid()) + + def forward(self, x): + y = self.avg_pool(x) + y = self.fc(y) + return x * y + + +class LinearBottleneck(nn.Layer): + def __init__(self, + in_channels, + channels, + t, + stride, + use_se=True, + se_ratio=12, + **kwargs): + super(LinearBottleneck, self).__init__(**kwargs) + self.use_shortcut = stride == 1 and in_channels <= channels + self.in_channels = in_channels + self.out_channels = channels + + out = [] + if t != 1: + dw_channels = in_channels * t + conv_bn_swish(out, in_channels=in_channels, channels=dw_channels) + else: + dw_channels = in_channels + + conv_bn_act( + out, + in_channels=dw_channels, + channels=dw_channels, + kernel=3, + stride=stride, + pad=1, + num_group=dw_channels, + active=False) + + if use_se: + out.append(SE(dw_channels, dw_channels, se_ratio)) + + out.append(nn.ReLU6()) + conv_bn_act( + out, + in_channels=dw_channels, + channels=channels, + active=False, + relu6=True) + self.out = nn.Sequential(*out) + + def forward(self, x): + out = self.out(x) + if self.use_shortcut: + out[:, 0:self.in_channels] += x + + return out + + +class ReXNetV1(nn.Layer): + def __init__(self, + input_ch=16, + final_ch=180, + width_mult=1.0, + depth_mult=1.0, + class_num=1000, + use_se=True, + se_ratio=12, + dropout_ratio=0.2, + bn_momentum=0.9): + super(ReXNetV1, self).__init__() + + layers = [1, 2, 2, 3, 3, 5] + strides = [1, 2, 2, 2, 1, 2] + use_ses = [False, False, True, True, True, True] + + layers = [ceil(element * depth_mult) for element in layers] + strides = sum([[element] + [1] * (layers[idx] - 1) + for idx, element in enumerate(strides)], []) + if use_se: + use_ses = sum([[element] * layers[idx] + for idx, element in enumerate(use_ses)], []) + else: + use_ses = [False] * sum(layers[:]) + ts = [1] * layers[0] + [6] * sum(layers[1:]) + + self.depth = sum(layers[:]) * 3 + stem_channel = 32 / width_mult if width_mult < 1.0 else 32 + inplanes = input_ch / width_mult if width_mult < 1.0 else input_ch + + features = [] + in_channels_group = [] + channels_group = [] + + # The following channel configuration is a simple instance to make each layer become an expand layer. + for i in range(self.depth // 3): + if i == 0: + in_channels_group.append(int(round(stem_channel * width_mult))) + channels_group.append(int(round(inplanes * width_mult))) + else: + in_channels_group.append(int(round(inplanes * width_mult))) + inplanes += final_ch / (self.depth // 3 * 1.0) + channels_group.append(int(round(inplanes * width_mult))) + + conv_bn_swish( + features, + 3, + int(round(stem_channel * width_mult)), + kernel=3, + stride=2, + pad=1) + + for block_idx, (in_c, c, t, s, se) in enumerate( + zip(in_channels_group, channels_group, ts, strides, use_ses)): + features.append( + LinearBottleneck( + in_channels=in_c, + channels=c, + t=t, + stride=s, + use_se=se, + se_ratio=se_ratio)) + + pen_channels = int(1280 * width_mult) + conv_bn_swish(features, c, pen_channels) + + features.append(nn.AdaptiveAvgPool2D(1)) + self.features = nn.Sequential(*features) + self.output = nn.Sequential( + nn.Dropout(dropout_ratio), + nn.Conv2D( + pen_channels, class_num, 1, bias_attr=True)) + + def forward(self, x): + x = self.features(x) + x = self.output(x).squeeze(axis=-1).squeeze(axis=-1) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ReXNet_1_0(pretrained=False, use_ssld=False, **kwargs): + model = ReXNetV1(width_mult=1.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ReXNet_1_0"], use_ssld=use_ssld) + return model + + +def ReXNet_1_3(pretrained=False, use_ssld=False, **kwargs): + model = ReXNetV1(width_mult=1.3, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ReXNet_1_3"], use_ssld=use_ssld) + return model + + +def ReXNet_1_5(pretrained=False, use_ssld=False, **kwargs): + model = ReXNetV1(width_mult=1.5, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ReXNet_1_5"], use_ssld=use_ssld) + return model + + +def ReXNet_2_0(pretrained=False, use_ssld=False, **kwargs): + model = ReXNetV1(width_mult=2.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ReXNet_2_0"], use_ssld=use_ssld) + return model + + +def ReXNet_3_0(pretrained=False, use_ssld=False, **kwargs): + model = ReXNetV1(width_mult=3.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ReXNet_3_0"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnet_vd.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnet_vd.py new file mode 100644 index 0000000..205feec --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnet_vd.py @@ -0,0 +1,390 @@ +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "SE_ResNet18_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet18_vd_pretrained.pdparams", + "SE_ResNet34_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet34_vd_pretrained.pdparams", + "SE_ResNet50_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet50_vd_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__( + self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + is_vd_mode=False, + act=None, + name=None, ): + super(ConvBNLayer, self).__init__() + + self.is_vd_mode = is_vd_mode + self._pool2d_avg = AvgPool2D( + kernel_size=2, stride=2, padding=0, ceil_mode=True) + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + if name == "conv1": + bn_name = "bn_" + name + else: + bn_name = "bn" + name[3:] + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + if self.is_vd_mode: + inputs = self._pool2d_avg(inputs) + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + if_first=False, + reduction_ratio=16, + name=None): + super(BottleneckBlock, self).__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act='relu', + name=name + "_branch2a") + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + stride=stride, + act='relu', + name=name + "_branch2b") + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 4, + filter_size=1, + act=None, + name=name + "_branch2c") + self.scale = SELayer( + num_channels=num_filters * 4, + num_filters=num_filters * 4, + reduction_ratio=reduction_ratio, + name='fc_' + name) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 4, + filter_size=1, + stride=1, + is_vd_mode=False if if_first else True, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + conv2 = self.conv2(conv1) + scale = self.scale(conv2) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=scale) + y = F.relu(y) + return y + + +class BasicBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + if_first=False, + reduction_ratio=16, + name=None): + super(BasicBlock, self).__init__() + self.stride = stride + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=3, + stride=stride, + act='relu', + name=name + "_branch2a") + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + act=None, + name=name + "_branch2b") + + self.scale = SELayer( + num_channels=num_filters, + num_filters=num_filters, + reduction_ratio=reduction_ratio, + name='fc_' + name) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + stride=1, + is_vd_mode=False if if_first else True, + name=name + "_branch1") + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + scale = self.scale(conv1) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=scale) + y = F.relu(y) + return y + + +class SELayer(nn.Layer): + def __init__(self, num_channels, num_filters, reduction_ratio, name=None): + super(SELayer, self).__init__() + + self.pool2d_gap = AdaptiveAvgPool2D(1) + + self._num_channels = num_channels + + med_ch = int(num_channels / reduction_ratio) + stdv = 1.0 / math.sqrt(num_channels * 1.0) + self.squeeze = Linear( + num_channels, + med_ch, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_sqz_weights"), + bias_attr=ParamAttr(name=name + '_sqz_offset')) + + stdv = 1.0 / math.sqrt(med_ch * 1.0) + self.excitation = Linear( + med_ch, + num_filters, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_exc_weights"), + bias_attr=ParamAttr(name=name + '_exc_offset')) + + def forward(self, input): + pool = self.pool2d_gap(input) + pool = paddle.squeeze(pool, axis=[2, 3]) + squeeze = self.squeeze(pool) + squeeze = F.relu(squeeze) + excitation = self.excitation(squeeze) + excitation = F.sigmoid(excitation) + excitation = paddle.unsqueeze(excitation, axis=[2, 3]) + out = input * excitation + return out + + +class SE_ResNet_vd(nn.Layer): + def __init__(self, layers=50, class_num=1000): + super(SE_ResNet_vd, self).__init__() + + self.layers = layers + supported_layers = [18, 34, 50, 101, 152, 200] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + + if layers == 18: + depth = [2, 2, 2, 2] + elif layers == 34 or layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + elif layers == 200: + depth = [3, 12, 48, 3] + num_channels = [64, 256, 512, + 1024] if layers >= 50 else [64, 64, 128, 256] + num_filters = [64, 128, 256, 512] + + self.conv1_1 = ConvBNLayer( + num_channels=3, + num_filters=32, + filter_size=3, + stride=2, + act='relu', + name="conv1_1") + self.conv1_2 = ConvBNLayer( + num_channels=32, + num_filters=32, + filter_size=3, + stride=1, + act='relu', + name="conv1_2") + self.conv1_3 = ConvBNLayer( + num_channels=32, + num_filters=64, + filter_size=3, + stride=1, + act='relu', + name="conv1_3") + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_list = [] + if layers >= 50: + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + if layers in [101, 152] and block == 2: + if i == 0: + conv_name = "res" + str(block + 2) + "a" + else: + conv_name = "res" + str(block + 2) + "b" + str(i) + else: + conv_name = "res" + str(block + 2) + chr(97 + i) + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels=num_channels[block] + if i == 0 else num_filters[block] * 4, + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + shortcut=shortcut, + if_first=block == i == 0, + name=conv_name)) + self.block_list.append(bottleneck_block) + shortcut = True + else: + for block in range(len(depth)): + shortcut = False + for i in range(depth[block]): + conv_name = "res" + str(block + 2) + chr(97 + i) + basic_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BasicBlock( + num_channels=num_channels[block] + if i == 0 else num_filters[block], + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + shortcut=shortcut, + if_first=block == i == 0, + name=conv_name)) + self.block_list.append(basic_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc6_weights"), + bias_attr=ParamAttr(name="fc6_offset")) + + def forward(self, inputs): + y = self.conv1_1(inputs) + y = self.conv1_2(y) + y = self.conv1_3(y) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def SE_ResNet18_vd(pretrained=False, use_ssld=False, **kwargs): + model = SE_ResNet_vd(layers=18, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SE_ResNet18_vd"], use_ssld=use_ssld) + return model + + +def SE_ResNet34_vd(pretrained=False, use_ssld=False, **kwargs): + model = SE_ResNet_vd(layers=34, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SE_ResNet34_vd"], use_ssld=use_ssld) + return model + + +def SE_ResNet50_vd(pretrained=False, use_ssld=False, **kwargs): + model = SE_ResNet_vd(layers=50, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SE_ResNet50_vd"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext.py new file mode 100644 index 0000000..8b7149e --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext.py @@ -0,0 +1,364 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "SE_ResNeXt50_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_32x4d_pretrained.pdparams", + "SE_ResNeXt101_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt101_32x4d_pretrained.pdparams", + "SE_ResNeXt152_64x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt152_64x4d_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act=None, + name=None, + data_format='NCHW'): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False, + data_format=data_format) + bn_name = name + '_bn' + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance', + data_layout=data_format) + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + cardinality, + reduction_ratio, + shortcut=True, + if_first=False, + name=None, + data_format="NCHW"): + super(BottleneckBlock, self).__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act='relu', + name='conv' + name + '_x1', + data_format=data_format) + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + groups=cardinality, + stride=stride, + act='relu', + name='conv' + name + '_x2', + data_format=data_format) + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 2 if cardinality == 32 else num_filters, + filter_size=1, + act=None, + name='conv' + name + '_x3', + data_format=data_format) + self.scale = SELayer( + num_channels=num_filters * 2 if cardinality == 32 else num_filters, + num_filters=num_filters * 2 if cardinality == 32 else num_filters, + reduction_ratio=reduction_ratio, + name='fc' + name, + data_format=data_format) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 2 + if cardinality == 32 else num_filters, + filter_size=1, + stride=stride, + name='conv' + name + '_prj', + data_format=data_format) + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + conv2 = self.conv2(conv1) + scale = self.scale(conv2) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=scale) + y = F.relu(y) + return y + + +class SELayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + reduction_ratio, + name=None, + data_format="NCHW"): + super(SELayer, self).__init__() + + self.data_format = data_format + self.pool2d_gap = AdaptiveAvgPool2D(1, data_format=self.data_format) + + self._num_channels = num_channels + + med_ch = int(num_channels / reduction_ratio) + stdv = 1.0 / math.sqrt(num_channels * 1.0) + self.squeeze = Linear( + num_channels, + med_ch, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_sqz_weights"), + bias_attr=ParamAttr(name=name + '_sqz_offset')) + self.relu = nn.ReLU() + stdv = 1.0 / math.sqrt(med_ch * 1.0) + self.excitation = Linear( + med_ch, + num_filters, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_exc_weights"), + bias_attr=ParamAttr(name=name + '_exc_offset')) + self.sigmoid = nn.Sigmoid() + + def forward(self, input): + pool = self.pool2d_gap(input) + if self.data_format == "NHWC": + pool = paddle.squeeze(pool, axis=[1, 2]) + else: + pool = paddle.squeeze(pool, axis=[2, 3]) + squeeze = self.squeeze(pool) + squeeze = self.relu(squeeze) + excitation = self.excitation(squeeze) + excitation = self.sigmoid(excitation) + if self.data_format == "NHWC": + excitation = paddle.unsqueeze(excitation, axis=[1, 2]) + else: + excitation = paddle.unsqueeze(excitation, axis=[2, 3]) + out = input * excitation + return out + + +class ResNeXt(nn.Layer): + def __init__(self, + layers=50, + class_num=1000, + cardinality=32, + input_image_channel=3, + data_format="NCHW"): + super(ResNeXt, self).__init__() + + self.layers = layers + self.cardinality = cardinality + self.reduction_ratio = 16 + self.data_format = data_format + self.input_image_channel = input_image_channel + + supported_layers = [50, 101, 152] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + supported_cardinality = [32, 64] + assert cardinality in supported_cardinality, \ + "supported cardinality is {} but input cardinality is {}" \ + .format(supported_cardinality, cardinality) + if layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + num_channels = [64, 256, 512, 1024] + num_filters = [128, 256, 512, + 1024] if cardinality == 32 else [256, 512, 1024, 2048] + if layers < 152: + self.conv = ConvBNLayer( + num_channels=self.input_image_channel, + num_filters=64, + filter_size=7, + stride=2, + act='relu', + name="conv1", + data_format=self.data_format) + else: + self.conv1_1 = ConvBNLayer( + num_channels=self.input_image_channel, + num_filters=64, + filter_size=3, + stride=2, + act='relu', + name="conv1", + data_format=self.data_format) + self.conv1_2 = ConvBNLayer( + num_channels=64, + num_filters=64, + filter_size=3, + stride=1, + act='relu', + name="conv2", + data_format=self.data_format) + self.conv1_3 = ConvBNLayer( + num_channels=64, + num_filters=128, + filter_size=3, + stride=1, + act='relu', + name="conv3", + data_format=self.data_format) + + self.pool2d_max = MaxPool2D( + kernel_size=3, stride=2, padding=1, data_format=self.data_format) + + self.block_list = [] + n = 1 if layers == 50 or layers == 101 else 3 + for block in range(len(depth)): + n += 1 + shortcut = False + for i in range(depth[block]): + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels=num_channels[block] if i == 0 else + num_filters[block] * int(64 // self.cardinality), + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + cardinality=self.cardinality, + reduction_ratio=self.reduction_ratio, + shortcut=shortcut, + if_first=block == 0, + name=str(n) + '_' + str(i + 1), + data_format=self.data_format)) + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1, data_format=self.data_format) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc6_weights"), + bias_attr=ParamAttr(name="fc6_offset")) + + def forward(self, inputs): + with paddle.static.amp.fp16_guard(): + if self.data_format == "NHWC": + inputs = paddle.tensor.transpose(inputs, [0, 2, 3, 1]) + inputs.stop_gradient = True + if self.layers < 152: + y = self.conv(inputs) + else: + y = self.conv1_1(inputs) + y = self.conv1_2(y) + y = self.conv1_3(y) + y = self.pool2d_max(y) + for i, block in enumerate(self.block_list): + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def SE_ResNeXt50_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=50, cardinality=32, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SE_ResNeXt50_32x4d"], use_ssld=use_ssld) + return model + + +def SE_ResNeXt101_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=101, cardinality=32, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SE_ResNeXt101_32x4d"], + use_ssld=use_ssld) + return model + + +def SE_ResNeXt152_64x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=152, cardinality=64, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SE_ResNeXt152_64x4d"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext_vd.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext_vd.py new file mode 100644 index 0000000..ef63025 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext_vd.py @@ -0,0 +1,309 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform + +import math + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "SE_ResNeXt50_vd_32x4d": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_vd_32x4d_pretrained.pdparams", + "SENet154_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SENet154_vd_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + is_vd_mode=False, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + + self.is_vd_mode = is_vd_mode + self._pool2d_avg = AvgPool2D( + kernel_size=2, stride=2, padding=0, ceil_mode=True) + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + bn_name = name + '_bn' + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + '_scale'), + bias_attr=ParamAttr(bn_name + '_offset'), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + if self.is_vd_mode: + inputs = self._pool2d_avg(inputs) + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class BottleneckBlock(nn.Layer): + def __init__(self, + num_channels, + num_filters, + stride, + cardinality, + reduction_ratio, + shortcut=True, + if_first=False, + name=None): + super(BottleneckBlock, self).__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act='relu', + name='conv' + name + '_x1') + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + groups=cardinality, + stride=stride, + act='relu', + name='conv' + name + '_x2') + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 2 if cardinality == 32 else num_filters, + filter_size=1, + act=None, + name='conv' + name + '_x3') + self.scale = SELayer( + num_channels=num_filters * 2 if cardinality == 32 else num_filters, + num_filters=num_filters * 2 if cardinality == 32 else num_filters, + reduction_ratio=reduction_ratio, + name='fc' + name) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 2 + if cardinality == 32 else num_filters, + filter_size=1, + stride=1, + is_vd_mode=False if if_first else True, + name='conv' + name + '_prj') + + self.shortcut = shortcut + + def forward(self, inputs): + y = self.conv0(inputs) + conv1 = self.conv1(y) + conv2 = self.conv2(conv1) + scale = self.scale(conv2) + + if self.shortcut: + short = inputs + else: + short = self.short(inputs) + y = paddle.add(x=short, y=scale) + y = F.relu(y) + return y + + +class SELayer(nn.Layer): + def __init__(self, num_channels, num_filters, reduction_ratio, name=None): + super(SELayer, self).__init__() + + self.pool2d_gap = AdaptiveAvgPool2D(1) + + self._num_channels = num_channels + + med_ch = int(num_channels / reduction_ratio) + stdv = 1.0 / math.sqrt(num_channels * 1.0) + self.squeeze = Linear( + num_channels, + med_ch, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_sqz_weights"), + bias_attr=ParamAttr(name=name + '_sqz_offset')) + self.relu = nn.ReLU() + stdv = 1.0 / math.sqrt(med_ch * 1.0) + self.excitation = Linear( + med_ch, + num_filters, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name=name + "_exc_weights"), + bias_attr=ParamAttr(name=name + '_exc_offset')) + self.sigmoid = nn.Sigmoid() + + def forward(self, input): + pool = self.pool2d_gap(input) + pool = paddle.squeeze(pool, axis=[2, 3]) + squeeze = self.squeeze(pool) + squeeze = self.relu(squeeze) + excitation = self.excitation(squeeze) + excitation = self.sigmoid(excitation) + excitation = paddle.unsqueeze(excitation, axis=[2, 3]) + out = paddle.multiply(input, excitation) + return out + + +class ResNeXt(nn.Layer): + def __init__(self, layers=50, class_num=1000, cardinality=32): + super(ResNeXt, self).__init__() + + self.layers = layers + self.cardinality = cardinality + self.reduction_ratio = 16 + supported_layers = [50, 101, 152] + assert layers in supported_layers, \ + "supported layers are {} but input layer is {}".format( + supported_layers, layers) + supported_cardinality = [32, 64] + assert cardinality in supported_cardinality, \ + "supported cardinality is {} but input cardinality is {}" \ + .format(supported_cardinality, cardinality) + if layers == 50: + depth = [3, 4, 6, 3] + elif layers == 101: + depth = [3, 4, 23, 3] + elif layers == 152: + depth = [3, 8, 36, 3] + num_channels = [128, 256, 512, 1024] + num_filters = [128, 256, 512, + 1024] if cardinality == 32 else [256, 512, 1024, 2048] + + self.conv1_1 = ConvBNLayer( + num_channels=3, + num_filters=64, + filter_size=3, + stride=2, + act='relu', + name="conv1_1") + self.conv1_2 = ConvBNLayer( + num_channels=64, + num_filters=64, + filter_size=3, + stride=1, + act='relu', + name="conv1_2") + self.conv1_3 = ConvBNLayer( + num_channels=64, + num_filters=128, + filter_size=3, + stride=1, + act='relu', + name="conv1_3") + + self.pool2d_max = MaxPool2D(kernel_size=3, stride=2, padding=1) + + self.block_list = [] + n = 1 if layers == 50 or layers == 101 else 3 + for block in range(len(depth)): + n += 1 + shortcut = False + for i in range(depth[block]): + bottleneck_block = self.add_sublayer( + 'bb_%d_%d' % (block, i), + BottleneckBlock( + num_channels=num_channels[block] if i == 0 else + num_filters[block] * int(64 // self.cardinality), + num_filters=num_filters[block], + stride=2 if i == 0 and block != 0 else 1, + cardinality=self.cardinality, + reduction_ratio=self.reduction_ratio, + shortcut=shortcut, + if_first=block == 0, + name=str(n) + '_' + str(i + 1))) + self.block_list.append(bottleneck_block) + shortcut = True + + self.pool2d_avg = AdaptiveAvgPool2D(1) + + self.pool2d_avg_channels = num_channels[-1] * 2 + + stdv = 1.0 / math.sqrt(self.pool2d_avg_channels * 1.0) + + self.out = Linear( + self.pool2d_avg_channels, + class_num, + weight_attr=ParamAttr( + initializer=Uniform(-stdv, stdv), name="fc6_weights"), + bias_attr=ParamAttr(name="fc6_offset")) + + def forward(self, inputs): + y = self.conv1_1(inputs) + y = self.conv1_2(y) + y = self.conv1_3(y) + y = self.pool2d_max(y) + for block in self.block_list: + y = block(y) + y = self.pool2d_avg(y) + y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels]) + y = self.out(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def SE_ResNeXt50_vd_32x4d(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=50, cardinality=32, **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SE_ResNeXt50_vd_32x4d"], + use_ssld=use_ssld) + return model + + +def SENet154_vd(pretrained=False, use_ssld=False, **kwargs): + model = ResNeXt(layers=152, cardinality=64, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SENet154_vd"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/shufflenet_v2.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/shufflenet_v2.py new file mode 100644 index 0000000..d8bb69f --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/shufflenet_v2.py @@ -0,0 +1,362 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import paddle +from paddle import ParamAttr, reshape, transpose, concat, split +from paddle.nn import Layer, Conv2D, MaxPool2D, AdaptiveAvgPool2D, BatchNorm, Linear +from paddle.nn.initializer import KaimingNormal +from paddle.nn.functional import swish + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ShuffleNetV2_x0_25": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_25_pretrained.pdparams", + "ShuffleNetV2_x0_33": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_33_pretrained.pdparams", + "ShuffleNetV2_x0_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_5_pretrained.pdparams", + "ShuffleNetV2_x1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_0_pretrained.pdparams", + "ShuffleNetV2_x1_5": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_5_pretrained.pdparams", + "ShuffleNetV2_x2_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x2_0_pretrained.pdparams", + "ShuffleNetV2_swish": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_swish_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +def channel_shuffle(x, groups): + batch_size, num_channels, height, width = x.shape[0:4] + channels_per_group = num_channels // groups + + # reshape + x = reshape( + x=x, shape=[batch_size, groups, channels_per_group, height, width]) + + # transpose + x = transpose(x=x, perm=[0, 2, 1, 3, 4]) + + # flatten + x = reshape(x=x, shape=[batch_size, num_channels, height, width]) + return x + + +class ConvBNLayer(Layer): + def __init__( + self, + in_channels, + out_channels, + kernel_size, + stride, + padding, + groups=1, + act=None, + name=None, ): + super(ConvBNLayer, self).__init__() + self._conv = Conv2D( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + groups=groups, + weight_attr=ParamAttr( + initializer=KaimingNormal(), name=name + "_weights"), + bias_attr=False) + + self._batch_norm = BatchNorm( + out_channels, + param_attr=ParamAttr(name=name + "_bn_scale"), + bias_attr=ParamAttr(name=name + "_bn_offset"), + act=act, + moving_mean_name=name + "_bn_mean", + moving_variance_name=name + "_bn_variance") + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class InvertedResidual(Layer): + def __init__(self, + in_channels, + out_channels, + stride, + act="relu", + name=None): + super(InvertedResidual, self).__init__() + self._conv_pw = ConvBNLayer( + in_channels=in_channels // 2, + out_channels=out_channels // 2, + kernel_size=1, + stride=1, + padding=0, + groups=1, + act=act, + name='stage_' + name + '_conv1') + self._conv_dw = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=3, + stride=stride, + padding=1, + groups=out_channels // 2, + act=None, + name='stage_' + name + '_conv2') + self._conv_linear = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=1, + stride=1, + padding=0, + groups=1, + act=act, + name='stage_' + name + '_conv3') + + def forward(self, inputs): + x1, x2 = split( + inputs, + num_or_sections=[inputs.shape[1] // 2, inputs.shape[1] // 2], + axis=1) + x2 = self._conv_pw(x2) + x2 = self._conv_dw(x2) + x2 = self._conv_linear(x2) + out = concat([x1, x2], axis=1) + return channel_shuffle(out, 2) + + +class InvertedResidualDS(Layer): + def __init__(self, + in_channels, + out_channels, + stride, + act="relu", + name=None): + super(InvertedResidualDS, self).__init__() + + # branch1 + self._conv_dw_1 = ConvBNLayer( + in_channels=in_channels, + out_channels=in_channels, + kernel_size=3, + stride=stride, + padding=1, + groups=in_channels, + act=None, + name='stage_' + name + '_conv4') + self._conv_linear_1 = ConvBNLayer( + in_channels=in_channels, + out_channels=out_channels // 2, + kernel_size=1, + stride=1, + padding=0, + groups=1, + act=act, + name='stage_' + name + '_conv5') + # branch2 + self._conv_pw_2 = ConvBNLayer( + in_channels=in_channels, + out_channels=out_channels // 2, + kernel_size=1, + stride=1, + padding=0, + groups=1, + act=act, + name='stage_' + name + '_conv1') + self._conv_dw_2 = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=3, + stride=stride, + padding=1, + groups=out_channels // 2, + act=None, + name='stage_' + name + '_conv2') + self._conv_linear_2 = ConvBNLayer( + in_channels=out_channels // 2, + out_channels=out_channels // 2, + kernel_size=1, + stride=1, + padding=0, + groups=1, + act=act, + name='stage_' + name + '_conv3') + + def forward(self, inputs): + x1 = self._conv_dw_1(inputs) + x1 = self._conv_linear_1(x1) + x2 = self._conv_pw_2(inputs) + x2 = self._conv_dw_2(x2) + x2 = self._conv_linear_2(x2) + out = concat([x1, x2], axis=1) + + return channel_shuffle(out, 2) + + +class ShuffleNet(Layer): + def __init__(self, class_num=1000, scale=1.0, act="relu"): + super(ShuffleNet, self).__init__() + self.scale = scale + self.class_num = class_num + stage_repeats = [4, 8, 4] + + if scale == 0.25: + stage_out_channels = [-1, 24, 24, 48, 96, 512] + elif scale == 0.33: + stage_out_channels = [-1, 24, 32, 64, 128, 512] + elif scale == 0.5: + stage_out_channels = [-1, 24, 48, 96, 192, 1024] + elif scale == 1.0: + stage_out_channels = [-1, 24, 116, 232, 464, 1024] + elif scale == 1.5: + stage_out_channels = [-1, 24, 176, 352, 704, 1024] + elif scale == 2.0: + stage_out_channels = [-1, 24, 224, 488, 976, 2048] + else: + raise NotImplementedError("This scale size:[" + str(scale) + + "] is not implemented!") + # 1. conv1 + self._conv1 = ConvBNLayer( + in_channels=3, + out_channels=stage_out_channels[1], + kernel_size=3, + stride=2, + padding=1, + act=act, + name='stage1_conv') + self._max_pool = MaxPool2D(kernel_size=3, stride=2, padding=1) + + # 2. bottleneck sequences + self._block_list = [] + for stage_id, num_repeat in enumerate(stage_repeats): + for i in range(num_repeat): + if i == 0: + block = self.add_sublayer( + name=str(stage_id + 2) + '_' + str(i + 1), + sublayer=InvertedResidualDS( + in_channels=stage_out_channels[stage_id + 1], + out_channels=stage_out_channels[stage_id + 2], + stride=2, + act=act, + name=str(stage_id + 2) + '_' + str(i + 1))) + else: + block = self.add_sublayer( + name=str(stage_id + 2) + '_' + str(i + 1), + sublayer=InvertedResidual( + in_channels=stage_out_channels[stage_id + 2], + out_channels=stage_out_channels[stage_id + 2], + stride=1, + act=act, + name=str(stage_id + 2) + '_' + str(i + 1))) + self._block_list.append(block) + # 3. last_conv + self._last_conv = ConvBNLayer( + in_channels=stage_out_channels[-2], + out_channels=stage_out_channels[-1], + kernel_size=1, + stride=1, + padding=0, + act=act, + name='conv5') + # 4. pool + self._pool2d_avg = AdaptiveAvgPool2D(1) + self._out_c = stage_out_channels[-1] + # 5. fc + self._fc = Linear( + stage_out_channels[-1], + class_num, + weight_attr=ParamAttr(name='fc6_weights'), + bias_attr=ParamAttr(name='fc6_offset')) + + def forward(self, inputs): + y = self._conv1(inputs) + y = self._max_pool(y) + for inv in self._block_list: + y = inv(y) + y = self._last_conv(y) + y = self._pool2d_avg(y) + y = paddle.flatten(y, start_axis=1, stop_axis=-1) + y = self._fc(y) + return y + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ShuffleNetV2_x0_25(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=0.25, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_x0_25"], use_ssld=use_ssld) + return model + + +def ShuffleNetV2_x0_33(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=0.33, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_x0_33"], use_ssld=use_ssld) + return model + + +def ShuffleNetV2_x0_5(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=0.5, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_x0_5"], use_ssld=use_ssld) + return model + + +def ShuffleNetV2_x1_0(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=1.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_x1_0"], use_ssld=use_ssld) + return model + + +def ShuffleNetV2_x1_5(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=1.5, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_x1_5"], use_ssld=use_ssld) + return model + + +def ShuffleNetV2_x2_0(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=2.0, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_x2_0"], use_ssld=use_ssld) + return model + + +def ShuffleNetV2_swish(pretrained=False, use_ssld=False, **kwargs): + model = ShuffleNet(scale=1.0, act="swish", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["ShuffleNetV2_swish"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/squeezenet.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/squeezenet.py new file mode 100644 index 0000000..647cd2e --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/squeezenet.py @@ -0,0 +1,194 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "SqueezeNet1_0": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_0_pretrained.pdparams", + "SqueezeNet1_1": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_1_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class MakeFireConv(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter_size, + padding=0, + name=None): + super(MakeFireConv, self).__init__() + self._conv = Conv2D( + input_channels, + output_channels, + filter_size, + padding=padding, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=ParamAttr(name=name + "_offset")) + + def forward(self, x): + x = self._conv(x) + x = F.relu(x) + return x + + +class MakeFire(nn.Layer): + def __init__(self, + input_channels, + squeeze_channels, + expand1x1_channels, + expand3x3_channels, + name=None): + super(MakeFire, self).__init__() + self._conv = MakeFireConv( + input_channels, squeeze_channels, 1, name=name + "_squeeze1x1") + self._conv_path1 = MakeFireConv( + squeeze_channels, expand1x1_channels, 1, name=name + "_expand1x1") + self._conv_path2 = MakeFireConv( + squeeze_channels, + expand3x3_channels, + 3, + padding=1, + name=name + "_expand3x3") + + def forward(self, inputs): + x = self._conv(inputs) + x1 = self._conv_path1(x) + x2 = self._conv_path2(x) + return paddle.concat([x1, x2], axis=1) + + +class SqueezeNet(nn.Layer): + def __init__(self, version, class_num=1000): + super(SqueezeNet, self).__init__() + self.version = version + + if self.version == "1.0": + self._conv = Conv2D( + 3, + 96, + 7, + stride=2, + weight_attr=ParamAttr(name="conv1_weights"), + bias_attr=ParamAttr(name="conv1_offset")) + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + self._conv1 = MakeFire(96, 16, 64, 64, name="fire2") + self._conv2 = MakeFire(128, 16, 64, 64, name="fire3") + self._conv3 = MakeFire(128, 32, 128, 128, name="fire4") + + self._conv4 = MakeFire(256, 32, 128, 128, name="fire5") + self._conv5 = MakeFire(256, 48, 192, 192, name="fire6") + self._conv6 = MakeFire(384, 48, 192, 192, name="fire7") + self._conv7 = MakeFire(384, 64, 256, 256, name="fire8") + + self._conv8 = MakeFire(512, 64, 256, 256, name="fire9") + else: + self._conv = Conv2D( + 3, + 64, + 3, + stride=2, + padding=1, + weight_attr=ParamAttr(name="conv1_weights"), + bias_attr=ParamAttr(name="conv1_offset")) + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=0) + self._conv1 = MakeFire(64, 16, 64, 64, name="fire2") + self._conv2 = MakeFire(128, 16, 64, 64, name="fire3") + + self._conv3 = MakeFire(128, 32, 128, 128, name="fire4") + self._conv4 = MakeFire(256, 32, 128, 128, name="fire5") + + self._conv5 = MakeFire(256, 48, 192, 192, name="fire6") + self._conv6 = MakeFire(384, 48, 192, 192, name="fire7") + self._conv7 = MakeFire(384, 64, 256, 256, name="fire8") + self._conv8 = MakeFire(512, 64, 256, 256, name="fire9") + + self._drop = Dropout(p=0.5, mode="downscale_in_infer") + self._conv9 = Conv2D( + 512, + class_num, + 1, + weight_attr=ParamAttr(name="conv10_weights"), + bias_attr=ParamAttr(name="conv10_offset")) + self._avg_pool = AdaptiveAvgPool2D(1) + + def forward(self, inputs): + x = self._conv(inputs) + x = F.relu(x) + x = self._pool(x) + if self.version == "1.0": + x = self._conv1(x) + x = self._conv2(x) + x = self._conv3(x) + x = self._pool(x) + x = self._conv4(x) + x = self._conv5(x) + x = self._conv6(x) + x = self._conv7(x) + x = self._pool(x) + x = self._conv8(x) + else: + x = self._conv1(x) + x = self._conv2(x) + x = self._pool(x) + x = self._conv3(x) + x = self._conv4(x) + x = self._pool(x) + x = self._conv5(x) + x = self._conv6(x) + x = self._conv7(x) + x = self._conv8(x) + x = self._drop(x) + x = self._conv9(x) + x = F.relu(x) + x = self._avg_pool(x) + x = paddle.squeeze(x, axis=[2, 3]) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def SqueezeNet1_0(pretrained=False, use_ssld=False, **kwargs): + model = SqueezeNet(version="1.0", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SqueezeNet1_0"], use_ssld=use_ssld) + return model + + +def SqueezeNet1_1(pretrained=False, use_ssld=False, **kwargs): + model = SqueezeNet(version="1.1", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["SqueezeNet1_1"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/swin_transformer.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/swin_transformer.py new file mode 100644 index 0000000..c783ec6 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/swin_transformer.py @@ -0,0 +1,857 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/microsoft/Swin-Transformer + +import numpy as np +import paddle +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn.initializer import TruncatedNormal, Constant + +from .vision_transformer import trunc_normal_, zeros_, ones_, to_2tuple, DropPath, Identity + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "SwinTransformer_tiny_patch4_window7_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_tiny_patch4_window7_224_pretrained.pdparams", + "SwinTransformer_small_patch4_window7_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_small_patch4_window7_224_pretrained.pdparams", + "SwinTransformer_base_patch4_window7_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window7_224_pretrained.pdparams", + "SwinTransformer_base_patch4_window12_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window12_384_pretrained.pdparams", + "SwinTransformer_large_patch4_window7_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window7_224_22kto1k_pretrained.pdparams", + "SwinTransformer_large_patch4_window12_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window12_384_22kto1k_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + + +class Mlp(nn.Layer): + def __init__(self, + in_features, + hidden_features=None, + out_features=None, + act_layer=nn.GELU, + drop=0.): + super().__init__() + out_features = out_features or in_features + hidden_features = hidden_features or in_features + self.fc1 = nn.Linear(in_features, hidden_features) + self.act = act_layer() + self.fc2 = nn.Linear(hidden_features, out_features) + self.drop = nn.Dropout(drop) + + def forward(self, x): + x = self.fc1(x) + x = self.act(x) + x = self.drop(x) + x = self.fc2(x) + x = self.drop(x) + return x + + +def window_partition(x, window_size): + """ + Args: + x: (B, H, W, C) + window_size (int): window size + + Returns: + windows: (num_windows*B, window_size, window_size, C) + """ + B, H, W, C = x.shape + x = x.reshape( + [B, H // window_size, window_size, W // window_size, window_size, C]) + windows = x.transpose([0, 1, 3, 2, 4, 5]).reshape( + [-1, window_size, window_size, C]) + return windows + + +def window_reverse(windows, window_size, H, W, C): + """ + Args: + windows: (num_windows*B, window_size, window_size, C) + window_size (int): Window size + H (int): Height of image + W (int): Width of image + + Returns: + x: (B, H, W, C) + """ + x = windows.reshape( + [-1, H // window_size, W // window_size, window_size, window_size, C]) + x = x.transpose([0, 1, 3, 2, 4, 5]).reshape([-1, H, W, C]) + return x + + +class WindowAttention(nn.Layer): + r""" Window based multi-head self attention (W-MSA) module with relative position bias. + It supports both of shifted and non-shifted window. + + Args: + dim (int): Number of input channels. + window_size (tuple[int]): The height and width of the window. + num_heads (int): Number of attention heads. + qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set + attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0 + proj_drop (float, optional): Dropout ratio of output. Default: 0.0 + """ + + def __init__(self, + dim, + window_size, + num_heads, + qkv_bias=True, + qk_scale=None, + attn_drop=0., + proj_drop=0.): + super().__init__() + self.dim = dim + self.window_size = window_size # Wh, Ww + self.num_heads = num_heads + head_dim = dim // num_heads + self.scale = qk_scale or head_dim**-0.5 + + # define a parameter table of relative position bias + # 2*Wh-1 * 2*Ww-1, nH + self.relative_position_bias_table = self.create_parameter( + shape=((2 * window_size[0] - 1) * (2 * window_size[1] - 1), + num_heads), + default_initializer=zeros_) + self.add_parameter("relative_position_bias_table", + self.relative_position_bias_table) + + # get pair-wise relative position index for each token inside the window + coords_h = paddle.arange(self.window_size[0]) + coords_w = paddle.arange(self.window_size[1]) + coords = paddle.stack(paddle.meshgrid( + [coords_h, coords_w])) # 2, Wh, Ww + coords_flatten = paddle.flatten(coords, 1) # 2, Wh*Ww + + coords_flatten_1 = coords_flatten.unsqueeze(axis=2) + coords_flatten_2 = coords_flatten.unsqueeze(axis=1) + relative_coords = coords_flatten_1 - coords_flatten_2 + + relative_coords = relative_coords.transpose( + [1, 2, 0]) # Wh*Ww, Wh*Ww, 2 + relative_coords[:, :, 0] += self.window_size[ + 0] - 1 # shift to start from 0 + relative_coords[:, :, 1] += self.window_size[1] - 1 + relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1 + relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww + self.register_buffer("relative_position_index", + relative_position_index) + + self.qkv = nn.Linear(dim, dim * 3, bias_attr=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + + trunc_normal_(self.relative_position_bias_table) + self.softmax = nn.Softmax(axis=-1) + + def forward(self, x, mask=None): + """ + Args: + x: input features with shape of (num_windows*B, N, C) + mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None + """ + B_, N, C = x.shape + qkv = self.qkv(x).reshape( + [B_, N, 3, self.num_heads, C // self.num_heads]).transpose( + [2, 0, 3, 1, 4]) + q, k, v = qkv[0], qkv[1], qkv[2] + + q = q * self.scale + attn = paddle.mm(q, k.transpose([0, 1, 3, 2])) + + index = self.relative_position_index.reshape([-1]) + + relative_position_bias = paddle.index_select( + self.relative_position_bias_table, index) + relative_position_bias = relative_position_bias.reshape([ + self.window_size[0] * self.window_size[1], + self.window_size[0] * self.window_size[1], -1 + ]) # Wh*Ww,Wh*Ww,nH + + relative_position_bias = relative_position_bias.transpose( + [2, 0, 1]) # nH, Wh*Ww, Wh*Ww + attn = attn + relative_position_bias.unsqueeze(0) + + if mask is not None: + nW = mask.shape[0] + attn = attn.reshape([B_ // nW, nW, self.num_heads, N, N + ]) + mask.unsqueeze(1).unsqueeze(0) + attn = attn.reshape([-1, self.num_heads, N, N]) + attn = self.softmax(attn) + else: + attn = self.softmax(attn) + + attn = self.attn_drop(attn) + + # x = (attn @ v).transpose(1, 2).reshape([B_, N, C]) + x = paddle.mm(attn, v).transpose([0, 2, 1, 3]).reshape([B_, N, C]) + x = self.proj(x) + x = self.proj_drop(x) + return x + + def extra_repr(self): + return "dim={}, window_size={}, num_heads={}".format( + self.dim, self.window_size, self.num_heads) + + def flops(self, N): + # calculate flops for 1 window with token length of N + flops = 0 + # qkv = self.qkv(x) + flops += N * self.dim * 3 * self.dim + # attn = (q @ k.transpose(-2, -1)) + flops += self.num_heads * N * (self.dim // self.num_heads) * N + # x = (attn @ v) + flops += self.num_heads * N * N * (self.dim // self.num_heads) + # x = self.proj(x) + flops += N * self.dim * self.dim + return flops + + +class SwinTransformerBlock(nn.Layer): + r""" Swin Transformer Block. + + Args: + dim (int): Number of input channels. + input_resolution (tuple[int]): Input resulotion. + num_heads (int): Number of attention heads. + window_size (int): Window size. + shift_size (int): Shift size for SW-MSA. + mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. + qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set. + drop (float, optional): Dropout rate. Default: 0.0 + attn_drop (float, optional): Attention dropout rate. Default: 0.0 + drop_path (float, optional): Stochastic depth rate. Default: 0.0 + act_layer (nn.Layer, optional): Activation layer. Default: nn.GELU + norm_layer (nn.Layer, optional): Normalization layer. Default: nn.LayerNorm + """ + + def __init__(self, + dim, + input_resolution, + num_heads, + window_size=7, + shift_size=0, + mlp_ratio=4., + qkv_bias=True, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer=nn.LayerNorm): + super().__init__() + self.dim = dim + self.input_resolution = input_resolution + self.num_heads = num_heads + self.window_size = window_size + self.shift_size = shift_size + self.mlp_ratio = mlp_ratio + if min(self.input_resolution) <= self.window_size: + # if window size is larger than input resolution, we don't partition windows + self.shift_size = 0 + self.window_size = min(self.input_resolution) + assert 0 <= self.shift_size < self.window_size, "shift_size must in 0-window_size" + + self.norm1 = norm_layer(dim) + self.attn = WindowAttention( + dim, + window_size=to_2tuple(self.window_size), + num_heads=num_heads, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + attn_drop=attn_drop, + proj_drop=drop) + + self.drop_path = DropPath(drop_path) if drop_path > 0. else Identity() + self.norm2 = norm_layer(dim) + mlp_hidden_dim = int(dim * mlp_ratio) + self.mlp = Mlp(in_features=dim, + hidden_features=mlp_hidden_dim, + act_layer=act_layer, + drop=drop) + + if self.shift_size > 0: + # calculate attention mask for SW-MSA + H, W = self.input_resolution + img_mask = paddle.zeros((1, H, W, 1)) # 1 H W 1 + h_slices = (slice(0, -self.window_size), + slice(-self.window_size, -self.shift_size), + slice(-self.shift_size, None)) + w_slices = (slice(0, -self.window_size), + slice(-self.window_size, -self.shift_size), + slice(-self.shift_size, None)) + cnt = 0 + for h in h_slices: + for w in w_slices: + img_mask[:, h, w, :] = cnt + cnt += 1 + + mask_windows = window_partition( + img_mask, self.window_size) # nW, window_size, window_size, 1 + mask_windows = mask_windows.reshape( + [-1, self.window_size * self.window_size]) + attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2) + + huns = -100.0 * paddle.ones_like(attn_mask) + attn_mask = huns * (attn_mask != 0).astype("float32") + else: + attn_mask = None + + self.register_buffer("attn_mask", attn_mask) + + def forward(self, x): + H, W = self.input_resolution + B, L, C = x.shape + assert L == H * W, "input feature has wrong size" + + shortcut = x + x = self.norm1(x) + x = x.reshape([B, H, W, C]) + + # cyclic shift + if self.shift_size > 0: + shifted_x = paddle.roll( + x, shifts=(-self.shift_size, -self.shift_size), axis=(1, 2)) + else: + shifted_x = x + + # partition windows + x_windows = window_partition( + shifted_x, self.window_size) # nW*B, window_size, window_size, C + x_windows = x_windows.reshape( + [-1, self.window_size * self.window_size, + C]) # nW*B, window_size*window_size, C + + # W-MSA/SW-MSA + attn_windows = self.attn( + x_windows, mask=self.attn_mask) # nW*B, window_size*window_size, C + + # merge windows + attn_windows = attn_windows.reshape( + [-1, self.window_size, self.window_size, C]) + shifted_x = window_reverse(attn_windows, self.window_size, H, W, + C) # B H' W' C + + # reverse cyclic shift + if self.shift_size > 0: + x = paddle.roll( + shifted_x, + shifts=(self.shift_size, self.shift_size), + axis=(1, 2)) + else: + x = shifted_x + x = x.reshape([B, H * W, C]) + + # FFN + x = shortcut + self.drop_path(x) + x = x + self.drop_path(self.mlp(self.norm2(x))) + + return x + + def extra_repr(self): + return "dim={}, input_resolution={}, num_heads={}, window_size={}, shift_size={}, mlp_ratio={}".format( + self.dim, self.input_resolution, self.num_heads, self.window_size, + self.shift_size, self.mlp_ratio) + + def flops(self): + flops = 0 + H, W = self.input_resolution + # norm1 + flops += self.dim * H * W + # W-MSA/SW-MSA + nW = H * W / self.window_size / self.window_size + flops += nW * self.attn.flops(self.window_size * self.window_size) + # mlp + flops += 2 * H * W * self.dim * self.dim * self.mlp_ratio + # norm2 + flops += self.dim * H * W + return flops + + +class PatchMerging(nn.Layer): + r""" Patch Merging Layer. + + Args: + input_resolution (tuple[int]): Resolution of input feature. + dim (int): Number of input channels. + norm_layer (nn.Layer, optional): Normalization layer. Default: nn.LayerNorm + """ + + def __init__(self, input_resolution, dim, norm_layer=nn.LayerNorm): + super().__init__() + self.input_resolution = input_resolution + self.dim = dim + self.reduction = nn.Linear(4 * dim, 2 * dim, bias_attr=False) + self.norm = norm_layer(4 * dim) + + def forward(self, x): + """ + x: B, H*W, C + """ + H, W = self.input_resolution + B, L, C = x.shape + assert L == H * W, "input feature has wrong size" + assert H % 2 == 0 and W % 2 == 0, "x size ({}*{}) are not even.".format( + H, W) + + x = x.reshape([B, H, W, C]) + + x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C + x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C + x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C + x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C + x = paddle.concat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C + x = x.reshape([B, H * W // 4, 4 * C]) # B H/2*W/2 4*C + + x = self.norm(x) + x = self.reduction(x) + + return x + + def extra_repr(self): + return "input_resolution={}, dim={}".format(self.input_resolution, + self.dim) + + def flops(self): + H, W = self.input_resolution + flops = H * W * self.dim + flops += (H // 2) * (W // 2) * 4 * self.dim * 2 * self.dim + return flops + + +class BasicLayer(nn.Layer): + """ A basic Swin Transformer layer for one stage. + + Args: + dim (int): Number of input channels. + input_resolution (tuple[int]): Input resolution. + depth (int): Number of blocks. + num_heads (int): Number of attention heads. + window_size (int): Local window size. + mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. + qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set. + drop (float, optional): Dropout rate. Default: 0.0 + attn_drop (float, optional): Attention dropout rate. Default: 0.0 + drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0 + norm_layer (nn.Layer, optional): Normalization layer. Default: nn.LayerNorm + downsample (nn.Layer | None, optional): Downsample layer at the end of the layer. Default: None + use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False. + """ + + def __init__(self, + dim, + input_resolution, + depth, + num_heads, + window_size, + mlp_ratio=4., + qkv_bias=True, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + norm_layer=nn.LayerNorm, + downsample=None, + use_checkpoint=False): + + super().__init__() + self.dim = dim + self.input_resolution = input_resolution + self.depth = depth + self.use_checkpoint = use_checkpoint + + # build blocks + self.blocks = nn.LayerList([ + SwinTransformerBlock( + dim=dim, + input_resolution=input_resolution, + num_heads=num_heads, + window_size=window_size, + shift_size=0 if (i % 2 == 0) else window_size // 2, + mlp_ratio=mlp_ratio, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + drop=drop, + attn_drop=attn_drop, + drop_path=drop_path[i] + if isinstance(drop_path, list) else drop_path, + norm_layer=norm_layer) for i in range(depth) + ]) + + # patch merging layer + if downsample is not None: + self.downsample = downsample( + input_resolution, dim=dim, norm_layer=norm_layer) + else: + self.downsample = None + + def forward(self, x): + for blk in self.blocks: + x = blk(x) + if self.downsample is not None: + x = self.downsample(x) + return x + + def extra_repr(self): + return "dim={}, input_resolution={}, depth={}".format( + self.dim, self.input_resolution, self.depth) + + def flops(self): + flops = 0 + for blk in self.blocks: + flops += blk.flops() + if self.downsample is not None: + flops += self.downsample.flops() + return flops + + +class PatchEmbed(nn.Layer): + """ Image to Patch Embedding + + Args: + img_size (int): Image size. Default: 224. + patch_size (int): Patch token size. Default: 4. + in_chans (int): Number of input image channels. Default: 3. + embed_dim (int): Number of linear projection output channels. Default: 96. + norm_layer (nn.Layer, optional): Normalization layer. Default: None + """ + + def __init__(self, + img_size=224, + patch_size=4, + in_chans=3, + embed_dim=96, + norm_layer=None): + super().__init__() + img_size = to_2tuple(img_size) + patch_size = to_2tuple(patch_size) + patches_resolution = [ + img_size[0] // patch_size[0], img_size[1] // patch_size[1] + ] + self.img_size = img_size + self.patch_size = patch_size + self.patches_resolution = patches_resolution + self.num_patches = patches_resolution[0] * patches_resolution[1] + + self.in_chans = in_chans + self.embed_dim = embed_dim + + self.proj = nn.Conv2D( + in_chans, embed_dim, kernel_size=patch_size, stride=patch_size) + if norm_layer is not None: + self.norm = norm_layer(embed_dim) + else: + self.norm = None + + def forward(self, x): + B, C, H, W = x.shape + # TODO (littletomatodonkey), uncomment the line will cause failure of jit.save + # assert [H, W] == self.img_size[:2], "Input image size ({H}*{W}) doesn't match model ({}*{}).".format(H, W, self.img_size[0], self.img_size[1]) + x = self.proj(x) + + x = x.flatten(2).transpose([0, 2, 1]) # B Ph*Pw C + if self.norm is not None: + x = self.norm(x) + return x + + def flops(self): + Ho, Wo = self.patches_resolution + flops = Ho * Wo * self.embed_dim * self.in_chans * ( + self.patch_size[0] * self.patch_size[1]) + if self.norm is not None: + flops += Ho * Wo * self.embed_dim + return flops + + +class SwinTransformer(nn.Layer): + """ Swin Transformer + A PaddlePaddle impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows` - + https://arxiv.org/pdf/2103.14030 + + Args: + img_size (int | tuple(int)): Input image size. Default 224 + patch_size (int | tuple(int)): Patch size. Default: 4 + in_chans (int): Number of input image channels. Default: 3 + num_classes (int): Number of classes for classification head. Default: 1000 + embed_dim (int): Patch embedding dimension. Default: 96 + depths (tuple(int)): Depth of each Swin Transformer layer. + num_heads (tuple(int)): Number of attention heads in different layers. + window_size (int): Window size. Default: 7 + mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. Default: 4 + qkv_bias (bool): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float): Override default qk scale of head_dim ** -0.5 if set. Default: None + drop_rate (float): Dropout rate. Default: 0 + attn_drop_rate (float): Attention dropout rate. Default: 0 + drop_path_rate (float): Stochastic depth rate. Default: 0.1 + norm_layer (nn.Layer): Normalization layer. Default: nn.LayerNorm. + ape (bool): If True, add absolute position embedding to the patch embedding. Default: False + patch_norm (bool): If True, add normalization after patch embedding. Default: True + use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False + """ + + def __init__(self, + img_size=224, + patch_size=4, + in_chans=3, + class_num=1000, + embed_dim=96, + depths=[2, 2, 6, 2], + num_heads=[3, 6, 12, 24], + window_size=7, + mlp_ratio=4., + qkv_bias=True, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0.1, + norm_layer=nn.LayerNorm, + ape=False, + patch_norm=True, + use_checkpoint=False, + **kwargs): + super(SwinTransformer, self).__init__() + + self.num_classes = num_classes = class_num + self.num_layers = len(depths) + self.embed_dim = embed_dim + self.ape = ape + self.patch_norm = patch_norm + self.num_features = int(embed_dim * 2**(self.num_layers - 1)) + self.mlp_ratio = mlp_ratio + + # split image into non-overlapping patches + self.patch_embed = PatchEmbed( + img_size=img_size, + patch_size=patch_size, + in_chans=in_chans, + embed_dim=embed_dim, + norm_layer=norm_layer if self.patch_norm else None) + num_patches = self.patch_embed.num_patches + patches_resolution = self.patch_embed.patches_resolution + self.patches_resolution = patches_resolution + + # absolute position embedding + if self.ape: + self.absolute_pos_embed = self.create_parameter( + shape=(1, num_patches, embed_dim), default_initializer=zeros_) + self.add_parameter("absolute_pos_embed", self.absolute_pos_embed) + trunc_normal_(self.absolute_pos_embed) + + self.pos_drop = nn.Dropout(p=drop_rate) + + # stochastic depth + dpr = np.linspace(0, drop_path_rate, + sum(depths)).tolist() # stochastic depth decay rule + + # build layers + self.layers = nn.LayerList() + for i_layer in range(self.num_layers): + layer = BasicLayer( + dim=int(embed_dim * 2**i_layer), + input_resolution=(patches_resolution[0] // (2**i_layer), + patches_resolution[1] // (2**i_layer)), + depth=depths[i_layer], + num_heads=num_heads[i_layer], + window_size=window_size, + mlp_ratio=self.mlp_ratio, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + drop=drop_rate, + attn_drop=attn_drop_rate, + drop_path=dpr[sum(depths[:i_layer]):sum(depths[:i_layer + 1])], + norm_layer=norm_layer, + downsample=PatchMerging + if (i_layer < self.num_layers - 1) else None, + use_checkpoint=use_checkpoint) + self.layers.append(layer) + + self.norm = norm_layer(self.num_features) + self.avgpool = nn.AdaptiveAvgPool1D(1) + self.head = nn.Linear( + self.num_features, + num_classes) if self.num_classes > 0 else nn.Identity() + + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight) + if isinstance(m, nn.Linear) and m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.LayerNorm): + zeros_(m.bias) + ones_(m.weight) + + def forward_features(self, x): + x = self.patch_embed(x) + if self.ape: + x = x + self.absolute_pos_embed + x = self.pos_drop(x) + + for layer in self.layers: + x = layer(x) + + x = self.norm(x) # B L C + x = self.avgpool(x.transpose([0, 2, 1])) # B C 1 + x = paddle.flatten(x, 1) + return x + + def forward(self, x): + x = self.forward_features(x) + x = self.head(x) + return x + + def flops(self): + flops = 0 + flops += self.patch_embed.flops() + for _, layer in enumerate(self.layers): + flops += layer.flops() + flops += self.num_features * self.patches_resolution[ + 0] * self.patches_resolution[1] // (2**self.num_layers) + flops += self.num_features * self.num_classes + return flops + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def SwinTransformer_tiny_patch4_window7_224(pretrained=False, + use_ssld=False, + **kwargs): + model = SwinTransformer( + embed_dim=96, + depths=[2, 2, 6, 2], + num_heads=[3, 6, 12, 24], + window_size=7, + drop_path_rate=0.2, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SwinTransformer_tiny_patch4_window7_224"], + use_ssld=use_ssld) + return model + + +def SwinTransformer_small_patch4_window7_224(pretrained=False, + use_ssld=False, + **kwargs): + model = SwinTransformer( + embed_dim=96, + depths=[2, 2, 18, 2], + num_heads=[3, 6, 12, 24], + window_size=7, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SwinTransformer_small_patch4_window7_224"], + use_ssld=use_ssld) + return model + + +def SwinTransformer_base_patch4_window7_224(pretrained=False, + use_ssld=False, + **kwargs): + model = SwinTransformer( + embed_dim=128, + depths=[2, 2, 18, 2], + num_heads=[4, 8, 16, 32], + window_size=7, + drop_path_rate=0.5, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SwinTransformer_base_patch4_window7_224"], + use_ssld=use_ssld) + return model + + +def SwinTransformer_base_patch4_window12_384(pretrained=False, + use_ssld=False, + **kwargs): + model = SwinTransformer( + img_size=384, + embed_dim=128, + depths=[2, 2, 18, 2], + num_heads=[4, 8, 16, 32], + window_size=12, + drop_path_rate=0.5, # NOTE: do not appear in offical code + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SwinTransformer_base_patch4_window12_384"], + use_ssld=use_ssld) + return model + + +def SwinTransformer_large_patch4_window7_224(pretrained=False, + use_ssld=False, + **kwargs): + model = SwinTransformer( + embed_dim=192, + depths=[2, 2, 18, 2], + num_heads=[6, 12, 24, 48], + window_size=7, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SwinTransformer_large_patch4_window7_224"], + use_ssld=use_ssld) + return model + + +def SwinTransformer_large_patch4_window12_384(pretrained=False, + use_ssld=False, + **kwargs): + model = SwinTransformer( + img_size=384, + embed_dim=192, + depths=[2, 2, 18, 2], + num_heads=[6, 12, 24, 48], + window_size=12, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["SwinTransformer_large_patch4_window12_384"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/tnt.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/tnt.py new file mode 100644 index 0000000..dcffcf4 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/tnt.py @@ -0,0 +1,386 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/huawei-noah/CV-Backbones/tree/master/tnt_pytorch + +import math +import numpy as np + +import paddle +import paddle.nn as nn + +from paddle.nn.initializer import TruncatedNormal, Constant + +from ppcls.arch.backbone.base.theseus_layer import Identity +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "TNT_small": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/TNT_small_pretrained.pdparams" +} + +__all__ = MODEL_URLS.keys() + +trunc_normal_ = TruncatedNormal(std=.02) +zeros_ = Constant(value=0.) +ones_ = Constant(value=1.) + + +def drop_path(x, drop_prob=0., training=False): + """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). + the original name is misleading as 'Drop Connect' is a different form of dropout in a separate paper... + See discussion: https://github.com/tensorflow/tpu/issues/494#issuecomment-532968956 ... + """ + if drop_prob == 0. or not training: + return x + keep_prob = paddle.to_tensor(1 - drop_prob) + shape = (paddle.shape(x)[0], ) + (1, ) * (x.ndim - 1) + random_tensor = paddle.add(keep_prob, paddle.rand(shape, dtype=x.dtype)) + random_tensor = paddle.floor(random_tensor) # binarize + output = x.divide(keep_prob) * random_tensor + return output + + +class DropPath(nn.Layer): + """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). + """ + + def __init__(self, drop_prob=None): + super(DropPath, self).__init__() + self.drop_prob = drop_prob + + def forward(self, x): + return drop_path(x, self.drop_prob, self.training) + + +class Mlp(nn.Layer): + def __init__(self, + in_features, + hidden_features=None, + out_features=None, + act_layer=nn.GELU, + drop=0.): + super().__init__() + out_features = out_features or in_features + hidden_features = hidden_features or in_features + self.fc1 = nn.Linear(in_features, hidden_features) + self.act = act_layer() + self.fc2 = nn.Linear(hidden_features, out_features) + self.drop = nn.Dropout(drop) + + def forward(self, x): + x = self.fc1(x) + x = self.act(x) + x = self.drop(x) + x = self.fc2(x) + x = self.drop(x) + return x + + +class Attention(nn.Layer): + def __init__(self, + dim, + hidden_dim, + num_heads=8, + qkv_bias=False, + attn_drop=0., + proj_drop=0.): + super().__init__() + self.hidden_dim = hidden_dim + self.num_heads = num_heads + head_dim = hidden_dim // num_heads + self.head_dim = head_dim + self.scale = head_dim**-0.5 + + self.qk = nn.Linear(dim, hidden_dim * 2, bias_attr=qkv_bias) + self.v = nn.Linear(dim, dim, bias_attr=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + + def forward(self, x): + B, N, C = x.shape + qk = self.qk(x).reshape( + (B, N, 2, self.num_heads, self.head_dim)).transpose( + (2, 0, 3, 1, 4)) + + q, k = qk[0], qk[1] + v = self.v(x).reshape( + (B, N, self.num_heads, x.shape[-1] // self.num_heads)).transpose( + (0, 2, 1, 3)) + + attn = paddle.matmul(q, k.transpose((0, 1, 3, 2))) * self.scale + attn = nn.functional.softmax(attn, axis=-1) + attn = self.attn_drop(attn) + + x = paddle.matmul(attn, v) + x = x.transpose((0, 2, 1, 3)).reshape( + (B, N, x.shape[-1] * x.shape[-3])) + x = self.proj(x) + x = self.proj_drop(x) + return x + + +class Block(nn.Layer): + def __init__(self, + dim, + in_dim, + num_pixel, + num_heads=12, + in_num_head=4, + mlp_ratio=4., + qkv_bias=False, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer=nn.LayerNorm): + super().__init__() + # Inner transformer + self.norm_in = norm_layer(in_dim) + self.attn_in = Attention( + in_dim, + in_dim, + num_heads=in_num_head, + qkv_bias=qkv_bias, + attn_drop=attn_drop, + proj_drop=drop) + + self.norm_mlp_in = norm_layer(in_dim) + self.mlp_in = Mlp(in_features=in_dim, + hidden_features=int(in_dim * 4), + out_features=in_dim, + act_layer=act_layer, + drop=drop) + + self.norm1_proj = norm_layer(in_dim) + self.proj = nn.Linear(in_dim * num_pixel, dim) + # Outer transformer + self.norm_out = norm_layer(dim) + self.attn_out = Attention( + dim, + dim, + num_heads=num_heads, + qkv_bias=qkv_bias, + attn_drop=attn_drop, + proj_drop=drop) + + self.drop_path = DropPath(drop_path) if drop_path > 0. else Identity() + + self.norm_mlp = norm_layer(dim) + self.mlp = Mlp(in_features=dim, + hidden_features=int(dim * mlp_ratio), + out_features=dim, + act_layer=act_layer, + drop=drop) + + def forward(self, pixel_embed, patch_embed): + # inner + pixel_embed = paddle.add( + pixel_embed, + self.drop_path(self.attn_in(self.norm_in(pixel_embed)))) + pixel_embed = paddle.add( + pixel_embed, + self.drop_path(self.mlp_in(self.norm_mlp_in(pixel_embed)))) + # outer + B, N, C = patch_embed.shape + norm1_proj = self.norm1_proj(pixel_embed) + norm1_proj = norm1_proj.reshape( + (B, N - 1, norm1_proj.shape[1] * norm1_proj.shape[2])) + patch_embed[:, 1:] = paddle.add(patch_embed[:, 1:], + self.proj(norm1_proj)) + patch_embed = paddle.add( + patch_embed, + self.drop_path(self.attn_out(self.norm_out(patch_embed)))) + patch_embed = paddle.add( + patch_embed, self.drop_path(self.mlp(self.norm_mlp(patch_embed)))) + return pixel_embed, patch_embed + + +class PixelEmbed(nn.Layer): + def __init__(self, + img_size=224, + patch_size=16, + in_chans=3, + in_dim=48, + stride=4): + super().__init__() + num_patches = (img_size // patch_size)**2 + self.img_size = img_size + self.num_patches = num_patches + self.in_dim = in_dim + new_patch_size = math.ceil(patch_size / stride) + self.new_patch_size = new_patch_size + + self.proj = nn.Conv2D( + in_chans, self.in_dim, kernel_size=7, padding=3, stride=stride) + + def forward(self, x, pixel_pos): + B, C, H, W = x.shape + assert H == self.img_size and W == self.img_size, f"Input image size ({H}*{W}) doesn't match model ({self.img_size}*{self.img_size})." + + x = self.proj(x) + x = nn.functional.unfold(x, self.new_patch_size, self.new_patch_size) + x = x.transpose((0, 2, 1)).reshape( + (-1, self.in_dim, self.new_patch_size, self.new_patch_size)) + x = x + pixel_pos + x = x.reshape((-1, self.in_dim, self.new_patch_size * + self.new_patch_size)).transpose((0, 2, 1)) + return x + + +class TNT(nn.Layer): + def __init__(self, + img_size=224, + patch_size=16, + in_chans=3, + embed_dim=768, + in_dim=48, + depth=12, + num_heads=12, + in_num_head=4, + mlp_ratio=4., + qkv_bias=False, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer=nn.LayerNorm, + first_stride=4, + class_num=1000): + super().__init__() + self.class_num = class_num + # num_features for consistency with other models + self.num_features = self.embed_dim = embed_dim + + self.pixel_embed = PixelEmbed( + img_size=img_size, + patch_size=patch_size, + in_chans=in_chans, + in_dim=in_dim, + stride=first_stride) + num_patches = self.pixel_embed.num_patches + self.num_patches = num_patches + new_patch_size = self.pixel_embed.new_patch_size + num_pixel = new_patch_size**2 + + self.norm1_proj = norm_layer(num_pixel * in_dim) + self.proj = nn.Linear(num_pixel * in_dim, embed_dim) + self.norm2_proj = norm_layer(embed_dim) + + self.cls_token = self.create_parameter( + shape=(1, 1, embed_dim), default_initializer=zeros_) + self.add_parameter("cls_token", self.cls_token) + + self.patch_pos = self.create_parameter( + shape=(1, num_patches + 1, embed_dim), default_initializer=zeros_) + self.add_parameter("patch_pos", self.patch_pos) + + self.pixel_pos = self.create_parameter( + shape=(1, in_dim, new_patch_size, new_patch_size), + default_initializer=zeros_) + self.add_parameter("pixel_pos", self.pixel_pos) + + self.pos_drop = nn.Dropout(p=drop_rate) + + # stochastic depth decay rule + dpr = np.linspace(0, drop_path_rate, depth) + + blocks = [] + for i in range(depth): + blocks.append( + Block( + dim=embed_dim, + in_dim=in_dim, + num_pixel=num_pixel, + num_heads=num_heads, + in_num_head=in_num_head, + mlp_ratio=mlp_ratio, + qkv_bias=qkv_bias, + drop=drop_rate, + attn_drop=attn_drop_rate, + drop_path=dpr[i], + norm_layer=norm_layer)) + self.blocks = nn.LayerList(blocks) + self.norm = norm_layer(embed_dim) + + if class_num > 0: + self.head = nn.Linear(embed_dim, class_num) + + trunc_normal_(self.cls_token) + trunc_normal_(self.patch_pos) + trunc_normal_(self.pixel_pos) + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight) + if isinstance(m, nn.Linear) and m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.LayerNorm): + zeros_(m.bias) + ones_(m.weight) + + def forward_features(self, x): + B = paddle.shape(x)[0] + pixel_embed = self.pixel_embed(x, self.pixel_pos) + + patch_embed = self.norm2_proj( + self.proj( + self.norm1_proj( + pixel_embed.reshape((-1, self.num_patches, pixel_embed. + shape[-1] * pixel_embed.shape[-2]))))) + patch_embed = paddle.concat( + (self.cls_token.expand((B, -1, -1)), patch_embed), axis=1) + patch_embed = patch_embed + self.patch_pos + patch_embed = self.pos_drop(patch_embed) + + for blk in self.blocks: + pixel_embed, patch_embed = blk(pixel_embed, patch_embed) + + patch_embed = self.norm(patch_embed) + return patch_embed[:, 0] + + def forward(self, x): + x = self.forward_features(x) + + if self.class_num > 0: + x = self.head(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def TNT_small(pretrained=False, use_ssld=False, **kwargs): + model = TNT(patch_size=16, + embed_dim=384, + in_dim=24, + depth=12, + num_heads=6, + in_num_head=4, + qkv_bias=False, + **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["TNT_small"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py new file mode 100644 index 0000000..c71c026 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py @@ -0,0 +1,458 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +# Code was based on https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py + +from collections.abc import Callable + +import numpy as np +import paddle +import paddle.nn as nn +from paddle.nn.initializer import TruncatedNormal, Constant, Normal + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ViT_small_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_small_patch16_224_pretrained.pdparams", + "ViT_base_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams", + "ViT_base_patch16_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_384_pretrained.pdparams", + "ViT_base_patch32_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch32_384_pretrained.pdparams", + "ViT_large_patch16_224": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_224_pretrained.pdparams", + "ViT_large_patch16_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_384_pretrained.pdparams", + "ViT_large_patch32_384": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch32_384_pretrained.pdparams", +} + +__all__ = list(MODEL_URLS.keys()) + +trunc_normal_ = TruncatedNormal(std=.02) +normal_ = Normal +zeros_ = Constant(value=0.) +ones_ = Constant(value=1.) + + +def to_2tuple(x): + return tuple([x] * 2) + + +def drop_path(x, drop_prob=0., training=False): + """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). + the original name is misleading as 'Drop Connect' is a different form of dropout in a separate paper... + See discussion: https://github.com/tensorflow/tpu/issues/494#issuecomment-532968956 ... + """ + if drop_prob == 0. or not training: + return x + keep_prob = paddle.to_tensor(1 - drop_prob) + shape = (paddle.shape(x)[0], ) + (1, ) * (x.ndim - 1) + random_tensor = keep_prob + paddle.rand(shape, dtype=x.dtype) + random_tensor = paddle.floor(random_tensor) # binarize + output = x.divide(keep_prob) * random_tensor + return output + + +class DropPath(nn.Layer): + """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). + """ + + def __init__(self, drop_prob=None): + super(DropPath, self).__init__() + self.drop_prob = drop_prob + + def forward(self, x): + return drop_path(x, self.drop_prob, self.training) + + +class Identity(nn.Layer): + def __init__(self): + super(Identity, self).__init__() + + def forward(self, input): + return input + + +class Mlp(nn.Layer): + def __init__(self, + in_features, + hidden_features=None, + out_features=None, + act_layer=nn.GELU, + drop=0.): + super().__init__() + out_features = out_features or in_features + hidden_features = hidden_features or in_features + self.fc1 = nn.Linear(in_features, hidden_features) + self.act = act_layer() + self.fc2 = nn.Linear(hidden_features, out_features) + self.drop = nn.Dropout(drop) + + def forward(self, x): + x = self.fc1(x) + x = self.act(x) + x = self.drop(x) + x = self.fc2(x) + x = self.drop(x) + return x + + +class Attention(nn.Layer): + def __init__(self, + dim, + num_heads=8, + qkv_bias=False, + qk_scale=None, + attn_drop=0., + proj_drop=0.): + super().__init__() + self.num_heads = num_heads + head_dim = dim // num_heads + self.scale = qk_scale or head_dim**-0.5 + + self.qkv = nn.Linear(dim, dim * 3, bias_attr=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + + def forward(self, x): + # B= paddle.shape(x)[0] + N, C = x.shape[1:] + qkv = self.qkv(x).reshape((-1, N, 3, self.num_heads, C // + self.num_heads)).transpose((2, 0, 3, 1, 4)) + q, k, v = qkv[0], qkv[1], qkv[2] + + attn = (q.matmul(k.transpose((0, 1, 3, 2)))) * self.scale + attn = nn.functional.softmax(attn, axis=-1) + attn = self.attn_drop(attn) + + x = (attn.matmul(v)).transpose((0, 2, 1, 3)).reshape((-1, N, C)) + x = self.proj(x) + x = self.proj_drop(x) + return x + + +class Block(nn.Layer): + def __init__(self, + dim, + num_heads, + mlp_ratio=4., + qkv_bias=False, + qk_scale=None, + drop=0., + attn_drop=0., + drop_path=0., + act_layer=nn.GELU, + norm_layer='nn.LayerNorm', + epsilon=1e-5): + super().__init__() + if isinstance(norm_layer, str): + self.norm1 = eval(norm_layer)(dim, epsilon=epsilon) + elif isinstance(norm_layer, Callable): + self.norm1 = norm_layer(dim) + else: + raise TypeError( + "The norm_layer must be str or paddle.nn.layer.Layer class") + self.attn = Attention( + dim, + num_heads=num_heads, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + attn_drop=attn_drop, + proj_drop=drop) + # NOTE: drop path for stochastic depth, we shall see if this is better than dropout here + self.drop_path = DropPath(drop_path) if drop_path > 0. else Identity() + if isinstance(norm_layer, str): + self.norm2 = eval(norm_layer)(dim, epsilon=epsilon) + elif isinstance(norm_layer, Callable): + self.norm2 = norm_layer(dim) + else: + raise TypeError( + "The norm_layer must be str or paddle.nn.layer.Layer class") + mlp_hidden_dim = int(dim * mlp_ratio) + self.mlp = Mlp(in_features=dim, + hidden_features=mlp_hidden_dim, + act_layer=act_layer, + drop=drop) + + def forward(self, x): + x = x + self.drop_path(self.attn(self.norm1(x))) + x = x + self.drop_path(self.mlp(self.norm2(x))) + return x + + +class PatchEmbed(nn.Layer): + """ Image to Patch Embedding + """ + + def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768): + super().__init__() + img_size = to_2tuple(img_size) + patch_size = to_2tuple(patch_size) + num_patches = (img_size[1] // patch_size[1]) * \ + (img_size[0] // patch_size[0]) + self.img_size = img_size + self.patch_size = patch_size + self.num_patches = num_patches + + self.proj = nn.Conv2D( + in_chans, embed_dim, kernel_size=patch_size, stride=patch_size) + + def forward(self, x): + B, C, H, W = x.shape + assert H == self.img_size[0] and W == self.img_size[1], \ + f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})." + + x = self.proj(x).flatten(2).transpose((0, 2, 1)) + return x + + +class VisionTransformer(nn.Layer): + """ Vision Transformer with support for patch input + """ + + def __init__(self, + img_size=224, + patch_size=16, + in_chans=3, + class_num=1000, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=False, + qk_scale=None, + drop_rate=0., + attn_drop_rate=0., + drop_path_rate=0., + norm_layer='nn.LayerNorm', + epsilon=1e-5, + **kwargs): + super().__init__() + self.class_num = class_num + + self.num_features = self.embed_dim = embed_dim + + self.patch_embed = PatchEmbed( + img_size=img_size, + patch_size=patch_size, + in_chans=in_chans, + embed_dim=embed_dim) + num_patches = self.patch_embed.num_patches + + self.pos_embed = self.create_parameter( + shape=(1, num_patches + 1, embed_dim), default_initializer=zeros_) + self.add_parameter("pos_embed", self.pos_embed) + self.cls_token = self.create_parameter( + shape=(1, 1, embed_dim), default_initializer=zeros_) + self.add_parameter("cls_token", self.cls_token) + self.pos_drop = nn.Dropout(p=drop_rate) + + dpr = np.linspace(0, drop_path_rate, depth) + + self.blocks = nn.LayerList([ + Block( + dim=embed_dim, + num_heads=num_heads, + mlp_ratio=mlp_ratio, + qkv_bias=qkv_bias, + qk_scale=qk_scale, + drop=drop_rate, + attn_drop=attn_drop_rate, + drop_path=dpr[i], + norm_layer=norm_layer, + epsilon=epsilon) for i in range(depth) + ]) + + self.norm = eval(norm_layer)(embed_dim, epsilon=epsilon) + + # Classifier head + self.head = nn.Linear(embed_dim, + class_num) if class_num > 0 else Identity() + + trunc_normal_(self.pos_embed) + trunc_normal_(self.cls_token) + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight) + if isinstance(m, nn.Linear) and m.bias is not None: + zeros_(m.bias) + elif isinstance(m, nn.LayerNorm): + zeros_(m.bias) + ones_(m.weight) + + def forward_features(self, x): + # B = x.shape[0] + B = paddle.shape(x)[0] + x = self.patch_embed(x) + cls_tokens = self.cls_token.expand((B, -1, -1)) + x = paddle.concat((cls_tokens, x), axis=1) + x = x + self.pos_embed + x = self.pos_drop(x) + for blk in self.blocks: + x = blk(x) + x = self.norm(x) + return x[:, 0] + + def forward(self, x): + x = self.forward_features(x) + x = self.head(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ViT_small_patch16_224(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + patch_size=16, + embed_dim=768, + depth=8, + num_heads=8, + mlp_ratio=3, + qk_scale=768**-0.5, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_small_patch16_224"], + use_ssld=use_ssld) + return model + + +def ViT_base_patch16_224(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + patch_size=16, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_base_patch16_224"], + use_ssld=use_ssld) + return model + + +def ViT_base_patch16_384(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + img_size=384, + patch_size=16, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_base_patch16_384"], + use_ssld=use_ssld) + return model + + +def ViT_base_patch32_384(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + img_size=384, + patch_size=32, + embed_dim=768, + depth=12, + num_heads=12, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_base_patch32_384"], + use_ssld=use_ssld) + return model + + +def ViT_large_patch16_224(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + patch_size=16, + embed_dim=1024, + depth=24, + num_heads=16, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_large_patch16_224"], + use_ssld=use_ssld) + return model + + +def ViT_large_patch16_384(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + img_size=384, + patch_size=16, + embed_dim=1024, + depth=24, + num_heads=16, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_large_patch16_384"], + use_ssld=use_ssld) + return model + + +def ViT_large_patch32_384(pretrained=False, use_ssld=False, **kwargs): + model = VisionTransformer( + img_size=384, + patch_size=32, + embed_dim=1024, + depth=24, + num_heads=16, + mlp_ratio=4, + qkv_bias=True, + epsilon=1e-6, + **kwargs) + _load_pretrained( + pretrained, + model, + MODEL_URLS["ViT_large_patch32_384"], + use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/xception.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/xception.py new file mode 100644 index 0000000..2b84378 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/xception.py @@ -0,0 +1,377 @@ +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math +import sys + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "Xception41": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_pretrained.pdparams", + "Xception65": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_pretrained.pdparams", + "Xception71": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception71_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +class ConvBNLayer(nn.Layer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(name=name + "_weights"), + bias_attr=False) + bn_name = "bn_" + name + self._batch_norm = BatchNorm( + num_filters, + act=act, + param_attr=ParamAttr(name=bn_name + "_scale"), + bias_attr=ParamAttr(name=bn_name + "_offset"), + moving_mean_name=bn_name + '_mean', + moving_variance_name=bn_name + '_variance') + + def forward(self, inputs): + y = self._conv(inputs) + y = self._batch_norm(y) + return y + + +class SeparableConv(nn.Layer): + def __init__(self, input_channels, output_channels, stride=1, name=None): + super(SeparableConv, self).__init__() + + self._pointwise_conv = ConvBNLayer( + input_channels, output_channels, 1, name=name + "_sep") + self._depthwise_conv = ConvBNLayer( + output_channels, + output_channels, + 3, + stride=stride, + groups=output_channels, + name=name + "_dw") + + def forward(self, inputs): + x = self._pointwise_conv(inputs) + x = self._depthwise_conv(x) + return x + + +class EntryFlowBottleneckBlock(nn.Layer): + def __init__(self, + input_channels, + output_channels, + stride=2, + name=None, + relu_first=False): + super(EntryFlowBottleneckBlock, self).__init__() + self.relu_first = relu_first + + self._short = Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=1, + stride=stride, + padding=0, + weight_attr=ParamAttr(name + "_branch1_weights"), + bias_attr=False) + self._conv1 = SeparableConv( + input_channels, + output_channels, + stride=1, + name=name + "_branch2a_weights") + self._conv2 = SeparableConv( + output_channels, + output_channels, + stride=1, + name=name + "_branch2b_weights") + self._pool = MaxPool2D(kernel_size=3, stride=stride, padding=1) + + def forward(self, inputs): + conv0 = inputs + short = self._short(inputs) + if self.relu_first: + conv0 = F.relu(conv0) + conv1 = self._conv1(conv0) + conv2 = F.relu(conv1) + conv2 = self._conv2(conv2) + pool = self._pool(conv2) + return paddle.add(x=short, y=pool) + + +class EntryFlow(nn.Layer): + def __init__(self, block_num=3): + super(EntryFlow, self).__init__() + + name = "entry_flow" + self.block_num = block_num + self._conv1 = ConvBNLayer( + 3, 32, 3, stride=2, act="relu", name=name + "_conv1") + self._conv2 = ConvBNLayer(32, 64, 3, act="relu", name=name + "_conv2") + if block_num == 3: + self._conv_0 = EntryFlowBottleneckBlock( + 64, 128, stride=2, name=name + "_0", relu_first=False) + self._conv_1 = EntryFlowBottleneckBlock( + 128, 256, stride=2, name=name + "_1", relu_first=True) + self._conv_2 = EntryFlowBottleneckBlock( + 256, 728, stride=2, name=name + "_2", relu_first=True) + elif block_num == 5: + self._conv_0 = EntryFlowBottleneckBlock( + 64, 128, stride=2, name=name + "_0", relu_first=False) + self._conv_1 = EntryFlowBottleneckBlock( + 128, 256, stride=1, name=name + "_1", relu_first=True) + self._conv_2 = EntryFlowBottleneckBlock( + 256, 256, stride=2, name=name + "_2", relu_first=True) + self._conv_3 = EntryFlowBottleneckBlock( + 256, 728, stride=1, name=name + "_3", relu_first=True) + self._conv_4 = EntryFlowBottleneckBlock( + 728, 728, stride=2, name=name + "_4", relu_first=True) + else: + sys.exit(-1) + + def forward(self, inputs): + x = self._conv1(inputs) + x = self._conv2(x) + + if self.block_num == 3: + x = self._conv_0(x) + x = self._conv_1(x) + x = self._conv_2(x) + elif self.block_num == 5: + x = self._conv_0(x) + x = self._conv_1(x) + x = self._conv_2(x) + x = self._conv_3(x) + x = self._conv_4(x) + return x + + +class MiddleFlowBottleneckBlock(nn.Layer): + def __init__(self, input_channels, output_channels, name): + super(MiddleFlowBottleneckBlock, self).__init__() + + self._conv_0 = SeparableConv( + input_channels, + output_channels, + stride=1, + name=name + "_branch2a_weights") + self._conv_1 = SeparableConv( + output_channels, + output_channels, + stride=1, + name=name + "_branch2b_weights") + self._conv_2 = SeparableConv( + output_channels, + output_channels, + stride=1, + name=name + "_branch2c_weights") + + def forward(self, inputs): + conv0 = F.relu(inputs) + conv0 = self._conv_0(conv0) + conv1 = F.relu(conv0) + conv1 = self._conv_1(conv1) + conv2 = F.relu(conv1) + conv2 = self._conv_2(conv2) + return paddle.add(x=inputs, y=conv2) + + +class MiddleFlow(nn.Layer): + def __init__(self, block_num=8): + super(MiddleFlow, self).__init__() + + self.block_num = block_num + self._conv_0 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_0") + self._conv_1 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_1") + self._conv_2 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_2") + self._conv_3 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_3") + self._conv_4 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_4") + self._conv_5 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_5") + self._conv_6 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_6") + self._conv_7 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_7") + if block_num == 16: + self._conv_8 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_8") + self._conv_9 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_9") + self._conv_10 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_10") + self._conv_11 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_11") + self._conv_12 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_12") + self._conv_13 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_13") + self._conv_14 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_14") + self._conv_15 = MiddleFlowBottleneckBlock( + 728, 728, name="middle_flow_15") + + def forward(self, inputs): + x = self._conv_0(inputs) + x = self._conv_1(x) + x = self._conv_2(x) + x = self._conv_3(x) + x = self._conv_4(x) + x = self._conv_5(x) + x = self._conv_6(x) + x = self._conv_7(x) + if self.block_num == 16: + x = self._conv_8(x) + x = self._conv_9(x) + x = self._conv_10(x) + x = self._conv_11(x) + x = self._conv_12(x) + x = self._conv_13(x) + x = self._conv_14(x) + x = self._conv_15(x) + return x + + +class ExitFlowBottleneckBlock(nn.Layer): + def __init__(self, input_channels, output_channels1, output_channels2, + name): + super(ExitFlowBottleneckBlock, self).__init__() + + self._short = Conv2D( + in_channels=input_channels, + out_channels=output_channels2, + kernel_size=1, + stride=2, + padding=0, + weight_attr=ParamAttr(name + "_branch1_weights"), + bias_attr=False) + self._conv_1 = SeparableConv( + input_channels, + output_channels1, + stride=1, + name=name + "_branch2a_weights") + self._conv_2 = SeparableConv( + output_channels1, + output_channels2, + stride=1, + name=name + "_branch2b_weights") + self._pool = MaxPool2D(kernel_size=3, stride=2, padding=1) + + def forward(self, inputs): + short = self._short(inputs) + conv0 = F.relu(inputs) + conv1 = self._conv_1(conv0) + conv2 = F.relu(conv1) + conv2 = self._conv_2(conv2) + pool = self._pool(conv2) + return paddle.add(x=short, y=pool) + + +class ExitFlow(nn.Layer): + def __init__(self, class_num): + super(ExitFlow, self).__init__() + + name = "exit_flow" + + self._conv_0 = ExitFlowBottleneckBlock( + 728, 728, 1024, name=name + "_1") + self._conv_1 = SeparableConv(1024, 1536, stride=1, name=name + "_2") + self._conv_2 = SeparableConv(1536, 2048, stride=1, name=name + "_3") + self._pool = AdaptiveAvgPool2D(1) + stdv = 1.0 / math.sqrt(2048 * 1.0) + self._out = Linear( + 2048, + class_num, + weight_attr=ParamAttr( + name="fc_weights", initializer=Uniform(-stdv, stdv)), + bias_attr=ParamAttr(name="fc_offset")) + + def forward(self, inputs): + conv0 = self._conv_0(inputs) + conv1 = self._conv_1(conv0) + conv1 = F.relu(conv1) + conv2 = self._conv_2(conv1) + conv2 = F.relu(conv2) + pool = self._pool(conv2) + pool = paddle.flatten(pool, start_axis=1, stop_axis=-1) + out = self._out(pool) + return out + + +class Xception(nn.Layer): + def __init__(self, + entry_flow_block_num=3, + middle_flow_block_num=8, + class_num=1000): + super(Xception, self).__init__() + self.entry_flow_block_num = entry_flow_block_num + self.middle_flow_block_num = middle_flow_block_num + self._entry_flow = EntryFlow(entry_flow_block_num) + self._middle_flow = MiddleFlow(middle_flow_block_num) + self._exit_flow = ExitFlow(class_num) + + def forward(self, inputs): + x = self._entry_flow(inputs) + x = self._middle_flow(x) + x = self._exit_flow(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def Xception41(pretrained=False, use_ssld=False, **kwargs): + model = Xception(entry_flow_block_num=3, middle_flow_block_num=8, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Xception41"], use_ssld=use_ssld) + return model + + +def Xception65(pretrained=False, use_ssld=False, **kwargs): + model = Xception( + entry_flow_block_num=3, middle_flow_block_num=16, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Xception65"], use_ssld=use_ssld) + return model + + +def Xception71(pretrained=False, use_ssld=False, **kwargs): + model = Xception( + entry_flow_block_num=5, middle_flow_block_num=16, **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Xception71"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/model_zoo/xception_deeplab.py b/src/PaddleClas/ppcls/arch/backbone/model_zoo/xception_deeplab.py new file mode 100644 index 0000000..c52769b --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/model_zoo/xception_deeplab.py @@ -0,0 +1,421 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +from paddle import ParamAttr +import paddle.nn as nn +import paddle.nn.functional as F +from paddle.nn import Conv2D, BatchNorm, Linear, Dropout +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D + +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "Xception41_deeplab": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_deeplab_pretrained.pdparams", + "Xception65_deeplab": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_deeplab_pretrained.pdparams" +} + +__all__ = list(MODEL_URLS.keys()) + + +def check_data(data, number): + if type(data) == int: + return [data] * number + assert len(data) == number + return data + + +def check_stride(s, os): + if s <= os: + return True + else: + return False + + +def check_points(count, points): + if points is None: + return False + else: + if isinstance(points, list): + return (True if count in points else False) + else: + return (True if count == points else False) + + +def gen_bottleneck_params(backbone='xception_65'): + if backbone == 'xception_65': + bottleneck_params = { + "entry_flow": (3, [2, 2, 2], [128, 256, 728]), + "middle_flow": (16, 1, 728), + "exit_flow": (2, [2, 1], [[728, 1024, 1024], [1536, 1536, 2048]]) + } + elif backbone == 'xception_41': + bottleneck_params = { + "entry_flow": (3, [2, 2, 2], [128, 256, 728]), + "middle_flow": (8, 1, 728), + "exit_flow": (2, [2, 1], [[728, 1024, 1024], [1536, 1536, 2048]]) + } + elif backbone == 'xception_71': + bottleneck_params = { + "entry_flow": (5, [2, 1, 2, 1, 2], [128, 256, 256, 728, 728]), + "middle_flow": (16, 1, 728), + "exit_flow": (2, [2, 1], [[728, 1024, 1024], [1536, 1536, 2048]]) + } + else: + raise Exception( + "xception backbont only support xception_41/xception_65/xception_71" + ) + return bottleneck_params + + +class ConvBNLayer(nn.Layer): + def __init__(self, + input_channels, + output_channels, + filter_size, + stride=1, + padding=0, + act=None, + name=None): + super(ConvBNLayer, self).__init__() + + self._conv = Conv2D( + in_channels=input_channels, + out_channels=output_channels, + kernel_size=filter_size, + stride=stride, + padding=padding, + weight_attr=ParamAttr(name=name + "/weights"), + bias_attr=False) + self._bn = BatchNorm( + num_channels=output_channels, + act=act, + epsilon=1e-3, + momentum=0.99, + param_attr=ParamAttr(name=name + "/BatchNorm/gamma"), + bias_attr=ParamAttr(name=name + "/BatchNorm/beta"), + moving_mean_name=name + "/BatchNorm/moving_mean", + moving_variance_name=name + "/BatchNorm/moving_variance") + + def forward(self, inputs): + return self._bn(self._conv(inputs)) + + +class Seperate_Conv(nn.Layer): + def __init__(self, + input_channels, + output_channels, + stride, + filter, + dilation=1, + act=None, + name=None): + super(Seperate_Conv, self).__init__() + + self._conv1 = Conv2D( + in_channels=input_channels, + out_channels=input_channels, + kernel_size=filter, + stride=stride, + groups=input_channels, + padding=(filter) // 2 * dilation, + dilation=dilation, + weight_attr=ParamAttr(name=name + "/depthwise/weights"), + bias_attr=False) + self._bn1 = BatchNorm( + input_channels, + act=act, + epsilon=1e-3, + momentum=0.99, + param_attr=ParamAttr(name=name + "/depthwise/BatchNorm/gamma"), + bias_attr=ParamAttr(name=name + "/depthwise/BatchNorm/beta"), + moving_mean_name=name + "/depthwise/BatchNorm/moving_mean", + moving_variance_name=name + "/depthwise/BatchNorm/moving_variance") + self._conv2 = Conv2D( + input_channels, + output_channels, + 1, + stride=1, + groups=1, + padding=0, + weight_attr=ParamAttr(name=name + "/pointwise/weights"), + bias_attr=False) + self._bn2 = BatchNorm( + output_channels, + act=act, + epsilon=1e-3, + momentum=0.99, + param_attr=ParamAttr(name=name + "/pointwise/BatchNorm/gamma"), + bias_attr=ParamAttr(name=name + "/pointwise/BatchNorm/beta"), + moving_mean_name=name + "/pointwise/BatchNorm/moving_mean", + moving_variance_name=name + "/pointwise/BatchNorm/moving_variance") + + def forward(self, inputs): + x = self._conv1(inputs) + x = self._bn1(x) + x = self._conv2(x) + x = self._bn2(x) + return x + + +class Xception_Block(nn.Layer): + def __init__(self, + input_channels, + output_channels, + strides=1, + filter_size=3, + dilation=1, + skip_conv=True, + has_skip=True, + activation_fn_in_separable_conv=False, + name=None): + super(Xception_Block, self).__init__() + + repeat_number = 3 + output_channels = check_data(output_channels, repeat_number) + filter_size = check_data(filter_size, repeat_number) + strides = check_data(strides, repeat_number) + + self.has_skip = has_skip + self.skip_conv = skip_conv + self.activation_fn_in_separable_conv = activation_fn_in_separable_conv + if not activation_fn_in_separable_conv: + self._conv1 = Seperate_Conv( + input_channels, + output_channels[0], + stride=strides[0], + filter=filter_size[0], + dilation=dilation, + name=name + "/separable_conv1") + self._conv2 = Seperate_Conv( + output_channels[0], + output_channels[1], + stride=strides[1], + filter=filter_size[1], + dilation=dilation, + name=name + "/separable_conv2") + self._conv3 = Seperate_Conv( + output_channels[1], + output_channels[2], + stride=strides[2], + filter=filter_size[2], + dilation=dilation, + name=name + "/separable_conv3") + else: + self._conv1 = Seperate_Conv( + input_channels, + output_channels[0], + stride=strides[0], + filter=filter_size[0], + act="relu", + dilation=dilation, + name=name + "/separable_conv1") + self._conv2 = Seperate_Conv( + output_channels[0], + output_channels[1], + stride=strides[1], + filter=filter_size[1], + act="relu", + dilation=dilation, + name=name + "/separable_conv2") + self._conv3 = Seperate_Conv( + output_channels[1], + output_channels[2], + stride=strides[2], + filter=filter_size[2], + act="relu", + dilation=dilation, + name=name + "/separable_conv3") + + if has_skip and skip_conv: + self._short = ConvBNLayer( + input_channels, + output_channels[-1], + 1, + stride=strides[-1], + padding=0, + name=name + "/shortcut") + + def forward(self, inputs): + if not self.activation_fn_in_separable_conv: + x = F.relu(inputs) + x = self._conv1(x) + x = F.relu(x) + x = self._conv2(x) + x = F.relu(x) + x = self._conv3(x) + else: + x = self._conv1(inputs) + x = self._conv2(x) + x = self._conv3(x) + if self.has_skip: + if self.skip_conv: + skip = self._short(inputs) + else: + skip = inputs + return paddle.add(x, skip) + else: + return x + + +class XceptionDeeplab(nn.Layer): + def __init__(self, backbone, class_num=1000): + super(XceptionDeeplab, self).__init__() + + bottleneck_params = gen_bottleneck_params(backbone) + self.backbone = backbone + + self._conv1 = ConvBNLayer( + 3, + 32, + 3, + stride=2, + padding=1, + act="relu", + name=self.backbone + "/entry_flow/conv1") + self._conv2 = ConvBNLayer( + 32, + 64, + 3, + stride=1, + padding=1, + act="relu", + name=self.backbone + "/entry_flow/conv2") + + self.block_num = bottleneck_params["entry_flow"][0] + self.strides = bottleneck_params["entry_flow"][1] + self.chns = bottleneck_params["entry_flow"][2] + self.strides = check_data(self.strides, self.block_num) + self.chns = check_data(self.chns, self.block_num) + + self.entry_flow = [] + self.middle_flow = [] + + self.stride = 2 + self.output_stride = 32 + s = self.stride + + for i in range(self.block_num): + stride = self.strides[i] if check_stride(s * self.strides[i], + self.output_stride) else 1 + xception_block = self.add_sublayer( + self.backbone + "/entry_flow/block" + str(i + 1), + Xception_Block( + input_channels=64 if i == 0 else self.chns[i - 1], + output_channels=self.chns[i], + strides=[1, 1, self.stride], + name=self.backbone + "/entry_flow/block" + str(i + 1))) + self.entry_flow.append(xception_block) + s = s * stride + self.stride = s + + self.block_num = bottleneck_params["middle_flow"][0] + self.strides = bottleneck_params["middle_flow"][1] + self.chns = bottleneck_params["middle_flow"][2] + self.strides = check_data(self.strides, self.block_num) + self.chns = check_data(self.chns, self.block_num) + s = self.stride + + for i in range(self.block_num): + stride = self.strides[i] if check_stride(s * self.strides[i], + self.output_stride) else 1 + xception_block = self.add_sublayer( + self.backbone + "/middle_flow/block" + str(i + 1), + Xception_Block( + input_channels=728, + output_channels=728, + strides=[1, 1, self.strides[i]], + skip_conv=False, + name=self.backbone + "/middle_flow/block" + str(i + 1))) + self.middle_flow.append(xception_block) + s = s * stride + self.stride = s + + self.block_num = bottleneck_params["exit_flow"][0] + self.strides = bottleneck_params["exit_flow"][1] + self.chns = bottleneck_params["exit_flow"][2] + self.strides = check_data(self.strides, self.block_num) + self.chns = check_data(self.chns, self.block_num) + s = self.stride + stride = self.strides[0] if check_stride(s * self.strides[0], + self.output_stride) else 1 + self._exit_flow_1 = Xception_Block( + 728, + self.chns[0], [1, 1, stride], + name=self.backbone + "/exit_flow/block1") + s = s * stride + stride = self.strides[1] if check_stride(s * self.strides[1], + self.output_stride) else 1 + self._exit_flow_2 = Xception_Block( + self.chns[0][-1], + self.chns[1], [1, 1, stride], + dilation=2, + has_skip=False, + activation_fn_in_separable_conv=True, + name=self.backbone + "/exit_flow/block2") + s = s * stride + + self.stride = s + + self._drop = Dropout(p=0.5, mode="downscale_in_infer") + self._pool = AdaptiveAvgPool2D(1) + self._fc = Linear( + self.chns[1][-1], + class_num, + weight_attr=ParamAttr(name="fc_weights"), + bias_attr=ParamAttr(name="fc_bias")) + + def forward(self, inputs): + x = self._conv1(inputs) + x = self._conv2(x) + for ef in self.entry_flow: + x = ef(x) + for mf in self.middle_flow: + x = mf(x) + x = self._exit_flow_1(x) + x = self._exit_flow_2(x) + x = self._drop(x) + x = self._pool(x) + x = paddle.squeeze(x, axis=[2, 3]) + x = self._fc(x) + return x + + +def _load_pretrained(pretrained, model, model_url, use_ssld=False): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def Xception41_deeplab(pretrained=False, use_ssld=False, **kwargs): + model = XceptionDeeplab('xception_41', **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Xception41_deeplab"], use_ssld=use_ssld) + return model + + +def Xception65_deeplab(pretrained=False, use_ssld=False, **kwargs): + model = XceptionDeeplab("xception_65", **kwargs) + _load_pretrained( + pretrained, model, MODEL_URLS["Xception65_deeplab"], use_ssld=use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/__init__.py b/src/PaddleClas/ppcls/arch/backbone/variant_models/__init__.py new file mode 100644 index 0000000..75cf29f --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/variant_models/__init__.py @@ -0,0 +1,3 @@ +from .resnet_variant import ResNet50_last_stage_stride1 +from .vgg_variant import VGG19Sigmoid +from .pp_lcnet_variant import PPLCNet_x2_5_Tanh diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..429ee93 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/pp_lcnet_variant.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/pp_lcnet_variant.cpython-39.pyc new file mode 100644 index 0000000..5f60704 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/pp_lcnet_variant.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/resnet_variant.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/resnet_variant.cpython-39.pyc new file mode 100644 index 0000000..a86f989 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/resnet_variant.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/vgg_variant.cpython-39.pyc b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/vgg_variant.cpython-39.pyc new file mode 100644 index 0000000..06aa183 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/backbone/variant_models/__pycache__/vgg_variant.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/pp_lcnet_variant.py b/src/PaddleClas/ppcls/arch/backbone/variant_models/pp_lcnet_variant.py new file mode 100644 index 0000000..dc9747a --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/variant_models/pp_lcnet_variant.py @@ -0,0 +1,29 @@ +import paddle +from paddle.nn import Sigmoid +from paddle.nn import Tanh +from ppcls.arch.backbone.legendary_models.pp_lcnet import PPLCNet_x2_5 + +__all__ = ["PPLCNet_x2_5_Tanh"] + + +class TanhSuffix(paddle.nn.Layer): + def __init__(self, origin_layer): + super(TanhSuffix, self).__init__() + self.origin_layer = origin_layer + self.tanh = Tanh() + + def forward(self, input, res_dict=None, **kwargs): + x = self.origin_layer(input) + x = self.tanh(x) + return x + + +def PPLCNet_x2_5_Tanh(pretrained=False, use_ssld=False, **kwargs): + def replace_function(origin_layer, pattern): + new_layer = TanhSuffix(origin_layer) + return new_layer + + pattern = "fc" + model = PPLCNet_x2_5(pretrained=pretrained, use_ssld=use_ssld, **kwargs) + model.upgrade_sublayer(pattern, replace_function) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/resnet_variant.py b/src/PaddleClas/ppcls/arch/backbone/variant_models/resnet_variant.py new file mode 100644 index 0000000..0219344 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/variant_models/resnet_variant.py @@ -0,0 +1,23 @@ +from paddle.nn import Conv2D +from ppcls.arch.backbone.legendary_models.resnet import ResNet50, MODEL_URLS, _load_pretrained + +__all__ = ["ResNet50_last_stage_stride1"] + + +def ResNet50_last_stage_stride1(pretrained=False, use_ssld=False, **kwargs): + def replace_function(conv, pattern): + new_conv = Conv2D( + in_channels=conv._in_channels, + out_channels=conv._out_channels, + kernel_size=conv._kernel_size, + stride=1, + padding=conv._padding, + groups=conv._groups, + bias_attr=conv._bias_attr) + return new_conv + + pattern = ["blocks[13].conv1.conv", "blocks[13].short.conv"] + model = ResNet50(pretrained=False, use_ssld=use_ssld, **kwargs) + model.upgrade_sublayer(pattern, replace_function) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet50"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/arch/backbone/variant_models/vgg_variant.py b/src/PaddleClas/ppcls/arch/backbone/variant_models/vgg_variant.py new file mode 100644 index 0000000..c1f75ba --- /dev/null +++ b/src/PaddleClas/ppcls/arch/backbone/variant_models/vgg_variant.py @@ -0,0 +1,28 @@ +import paddle +from paddle.nn import Sigmoid +from ppcls.arch.backbone.legendary_models.vgg import VGG19 + +__all__ = ["VGG19Sigmoid"] + + +class SigmoidSuffix(paddle.nn.Layer): + def __init__(self, origin_layer): + super().__init__() + self.origin_layer = origin_layer + self.sigmoid = Sigmoid() + + def forward(self, input, res_dict=None, **kwargs): + x = self.origin_layer(input) + x = self.sigmoid(x) + return x + + +def VGG19Sigmoid(pretrained=False, use_ssld=False, **kwargs): + def replace_function(origin_layer, pattern): + new_layer = SigmoidSuffix(origin_layer) + return new_layer + + pattern = "fc2" + model = VGG19(pretrained=pretrained, use_ssld=use_ssld, **kwargs) + model.upgrade_sublayer(pattern, replace_function) + return model diff --git a/src/PaddleClas/ppcls/arch/gears/__init__.py b/src/PaddleClas/ppcls/arch/gears/__init__.py new file mode 100644 index 0000000..75ca41d --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/__init__.py @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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 .arcmargin import ArcMargin +from .cosmargin import CosMargin +from .circlemargin import CircleMargin +from .fc import FC +from .vehicle_neck import VehicleNeck + +__all__ = ['build_gear'] + + +def build_gear(config): + support_dict = [ + 'ArcMargin', 'CosMargin', 'CircleMargin', 'FC', 'VehicleNeck' + ] + module_name = config.pop('name') + assert module_name in support_dict, Exception( + 'head only support {}'.format(support_dict)) + module_class = eval(module_name)(**config) + return module_class diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..8e51faa Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/arcmargin.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/arcmargin.cpython-39.pyc new file mode 100644 index 0000000..02443b1 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/arcmargin.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/circlemargin.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/circlemargin.cpython-39.pyc new file mode 100644 index 0000000..f7d1261 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/circlemargin.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/cosmargin.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/cosmargin.cpython-39.pyc new file mode 100644 index 0000000..85a7df3 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/cosmargin.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/fc.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/fc.cpython-39.pyc new file mode 100644 index 0000000..361b877 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/fc.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/identity_head.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/identity_head.cpython-39.pyc new file mode 100644 index 0000000..2a99da9 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/identity_head.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/__pycache__/vehicle_neck.cpython-39.pyc b/src/PaddleClas/ppcls/arch/gears/__pycache__/vehicle_neck.cpython-39.pyc new file mode 100644 index 0000000..ede4fd6 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/gears/__pycache__/vehicle_neck.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/gears/arcmargin.py b/src/PaddleClas/ppcls/arch/gears/arcmargin.py new file mode 100644 index 0000000..22cc76e --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/arcmargin.py @@ -0,0 +1,72 @@ +# Copyright (c) 2021 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. + +import paddle +import paddle.nn as nn +import math + + +class ArcMargin(nn.Layer): + def __init__(self, + embedding_size, + class_num, + margin=0.5, + scale=80.0, + easy_margin=False): + super().__init__() + self.embedding_size = embedding_size + self.class_num = class_num + self.margin = margin + self.scale = scale + self.easy_margin = easy_margin + self.weight = self.create_parameter( + shape=[self.embedding_size, self.class_num], + is_bias=False, + default_initializer=paddle.nn.initializer.XavierNormal()) + + def forward(self, input, label=None): + input_norm = paddle.sqrt( + paddle.sum(paddle.square(input), axis=1, keepdim=True)) + input = paddle.divide(input, input_norm) + + weight_norm = paddle.sqrt( + paddle.sum(paddle.square(self.weight), axis=0, keepdim=True)) + weight = paddle.divide(self.weight, weight_norm) + + cos = paddle.matmul(input, weight) + if not self.training or label is None: + return cos + sin = paddle.sqrt(1.0 - paddle.square(cos) + 1e-6) + cos_m = math.cos(self.margin) + sin_m = math.sin(self.margin) + phi = cos * cos_m - sin * sin_m + + th = math.cos(self.margin) * (-1) + mm = math.sin(self.margin) * self.margin + if self.easy_margin: + phi = self._paddle_where_more_than(cos, 0, phi, cos) + else: + phi = self._paddle_where_more_than(cos, th, phi, cos - mm) + + one_hot = paddle.nn.functional.one_hot(label, self.class_num) + one_hot = paddle.squeeze(one_hot, axis=[1]) + output = paddle.multiply(one_hot, phi) + paddle.multiply( + (1.0 - one_hot), cos) + output = output * self.scale + return output + + def _paddle_where_more_than(self, target, limit, x, y): + mask = paddle.cast(x=(target > limit), dtype='float32') + output = paddle.multiply(mask, x) + paddle.multiply((1.0 - mask), y) + return output diff --git a/src/PaddleClas/ppcls/arch/gears/circlemargin.py b/src/PaddleClas/ppcls/arch/gears/circlemargin.py new file mode 100644 index 0000000..d1bce83 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/circlemargin.py @@ -0,0 +1,59 @@ +# Copyright (c) 2021 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. + +import math +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +class CircleMargin(nn.Layer): + def __init__(self, embedding_size, class_num, margin, scale): + super(CircleMargin, self).__init__() + self.scale = scale + self.margin = margin + self.embedding_size = embedding_size + self.class_num = class_num + + self.weight = self.create_parameter( + shape=[self.embedding_size, self.class_num], + is_bias=False, + default_initializer=paddle.nn.initializer.XavierNormal()) + + def forward(self, input, label): + feat_norm = paddle.sqrt( + paddle.sum(paddle.square(input), axis=1, keepdim=True)) + input = paddle.divide(input, feat_norm) + + weight_norm = paddle.sqrt( + paddle.sum(paddle.square(self.weight), axis=0, keepdim=True)) + weight = paddle.divide(self.weight, weight_norm) + + logits = paddle.matmul(input, weight) + if not self.training or label is None: + return logits + + alpha_p = paddle.clip(-logits.detach() + 1 + self.margin, min=0.) + alpha_n = paddle.clip(logits.detach() + self.margin, min=0.) + delta_p = 1 - self.margin + delta_n = self.margin + + m_hot = F.one_hot(label.reshape([-1]), num_classes=logits.shape[1]) + + logits_p = alpha_p * (logits - delta_p) + logits_n = alpha_n * (logits - delta_n) + pre_logits = logits_p * m_hot + logits_n * (1 - m_hot) + pre_logits = self.scale * pre_logits + + return pre_logits diff --git a/src/PaddleClas/ppcls/arch/gears/cosmargin.py b/src/PaddleClas/ppcls/arch/gears/cosmargin.py new file mode 100644 index 0000000..578b64c --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/cosmargin.py @@ -0,0 +1,55 @@ +# Copyright (c) 2021 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. + +import paddle +import math +import paddle.nn as nn + + +class CosMargin(paddle.nn.Layer): + def __init__(self, embedding_size, class_num, margin=0.35, scale=64.0): + super(CosMargin, self).__init__() + self.scale = scale + self.margin = margin + self.embedding_size = embedding_size + self.class_num = class_num + + self.weight = self.create_parameter( + shape=[self.embedding_size, self.class_num], + is_bias=False, + default_initializer=paddle.nn.initializer.XavierNormal()) + + def forward(self, input, label): + label.stop_gradient = True + + input_norm = paddle.sqrt( + paddle.sum(paddle.square(input), axis=1, keepdim=True)) + input = paddle.divide(input, input_norm) + + weight_norm = paddle.sqrt( + paddle.sum(paddle.square(self.weight), axis=0, keepdim=True)) + weight = paddle.divide(self.weight, weight_norm) + + cos = paddle.matmul(input, weight) + if not self.training or label is None: + return cos + + cos_m = cos - self.margin + + one_hot = paddle.nn.functional.one_hot(label, self.class_num) + one_hot = paddle.squeeze(one_hot, axis=[1]) + output = paddle.multiply(one_hot, cos_m) + paddle.multiply( + (1.0 - one_hot), cos) + output = output * self.scale + return output diff --git a/src/PaddleClas/ppcls/arch/gears/fc.py b/src/PaddleClas/ppcls/arch/gears/fc.py new file mode 100644 index 0000000..b324741 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/fc.py @@ -0,0 +1,35 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import paddle +import paddle.nn as nn + + +class FC(nn.Layer): + def __init__(self, embedding_size, class_num): + super(FC, self).__init__() + self.embedding_size = embedding_size + self.class_num = class_num + weight_attr = paddle.ParamAttr( + initializer=paddle.nn.initializer.XavierNormal()) + self.fc = paddle.nn.Linear( + self.embedding_size, self.class_num, weight_attr=weight_attr) + + def forward(self, input, label=None): + out = self.fc(input) + return out diff --git a/src/PaddleClas/ppcls/arch/gears/identity_head.py b/src/PaddleClas/ppcls/arch/gears/identity_head.py new file mode 100644 index 0000000..7d11e57 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/identity_head.py @@ -0,0 +1,9 @@ +from paddle import nn + + +class IdentityHead(nn.Layer): + def __init__(self): + super(IdentityHead, self).__init__() + + def forward(self, x, label=None): + return {"features": x, "logits": None} diff --git a/src/PaddleClas/ppcls/arch/gears/vehicle_neck.py b/src/PaddleClas/ppcls/arch/gears/vehicle_neck.py new file mode 100644 index 0000000..05f4e33 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/gears/vehicle_neck.py @@ -0,0 +1,52 @@ +# Copyright (c) 2021 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 __future__ import absolute_import, division, print_function + +import paddle +import paddle.nn as nn + + +class VehicleNeck(nn.Layer): + def __init__(self, + in_channels, + out_channels, + kernel_size=1, + stride=1, + padding=0, + dilation=1, + groups=1, + padding_mode='zeros', + weight_attr=None, + bias_attr=None, + data_format='NCHW'): + super().__init__() + self.conv = nn.Conv2D( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + padding_mode=padding_mode, + weight_attr=weight_attr, + bias_attr=weight_attr, + data_format=data_format) + self.flatten = nn.Flatten() + + def forward(self, x): + x = self.conv(x) + x = self.flatten(x) + return x diff --git a/src/PaddleClas/ppcls/arch/slim/__init__.py b/src/PaddleClas/ppcls/arch/slim/__init__.py new file mode 100644 index 0000000..3733059 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/slim/__init__.py @@ -0,0 +1,16 @@ +# Copyright (c) 2021 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 ppcls.arch.slim.prune import prune_model +from ppcls.arch.slim.quant import quantize_model diff --git a/src/PaddleClas/ppcls/arch/slim/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/arch/slim/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..823977a Binary files /dev/null and b/src/PaddleClas/ppcls/arch/slim/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/slim/__pycache__/prune.cpython-39.pyc b/src/PaddleClas/ppcls/arch/slim/__pycache__/prune.cpython-39.pyc new file mode 100644 index 0000000..46a6c65 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/slim/__pycache__/prune.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/slim/__pycache__/quant.cpython-39.pyc b/src/PaddleClas/ppcls/arch/slim/__pycache__/quant.cpython-39.pyc new file mode 100644 index 0000000..70884e9 Binary files /dev/null and b/src/PaddleClas/ppcls/arch/slim/__pycache__/quant.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/arch/slim/prune.py b/src/PaddleClas/ppcls/arch/slim/prune.py new file mode 100644 index 0000000..c0c9d22 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/slim/prune.py @@ -0,0 +1,65 @@ +# Copyright (c) 2021 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 __future__ import absolute_import, division, print_function +import paddle +from ppcls.utils import logger + + +def prune_model(config, model): + if config.get("Slim", False) and config["Slim"].get("prune", False): + import paddleslim + prune_method_name = config["Slim"]["prune"]["name"].lower() + assert prune_method_name in [ + "fpgm", "l1_norm" + ], "The prune methods only support 'fpgm' and 'l1_norm'" + if prune_method_name == "fpgm": + model.pruner = paddleslim.dygraph.FPGMFilterPruner( + model, [1] + config["Global"]["image_shape"]) + else: + model.pruner = paddleslim.dygraph.L1NormFilterPruner( + model, [1] + config["Global"]["image_shape"]) + + # prune model + _prune_model(config, model) + else: + model.pruner = None + + + +def _prune_model(config, model): + from paddleslim.analysis import dygraph_flops as flops + logger.info("FLOPs before pruning: {}GFLOPs".format( + flops(model, [1] + config["Global"]["image_shape"]) / 1e9)) + model.eval() + + params = [] + for sublayer in model.sublayers(): + for param in sublayer.parameters(include_sublayers=False): + if isinstance(sublayer, paddle.nn.Conv2D): + params.append(param.name) + ratios = {} + for param in params: + ratios[param] = config["Slim"]["prune"]["pruned_ratio"] + plan = model.pruner.prune_vars(ratios, [0]) + + logger.info("FLOPs after pruning: {}GFLOPs; pruned ratio: {}".format( + flops(model, [1] + config["Global"]["image_shape"]) / 1e9, + plan.pruned_flops)) + + for param in model.parameters(): + if "conv2d" in param.name: + logger.info("{}\t{}".format(param.name, param.shape)) + + model.train() diff --git a/src/PaddleClas/ppcls/arch/slim/quant.py b/src/PaddleClas/ppcls/arch/slim/quant.py new file mode 100644 index 0000000..b8f59a7 --- /dev/null +++ b/src/PaddleClas/ppcls/arch/slim/quant.py @@ -0,0 +1,55 @@ +# Copyright (c) 2021 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 __future__ import absolute_import, division, print_function +import paddle +from ppcls.utils import logger + +QUANT_CONFIG = { + # weight preprocess type, default is None and no preprocessing is performed. + 'weight_preprocess_type': None, + # activation preprocess type, default is None and no preprocessing is performed. + 'activation_preprocess_type': None, + # weight quantize type, default is 'channel_wise_abs_max' + 'weight_quantize_type': 'channel_wise_abs_max', + # activation quantize type, default is 'moving_average_abs_max' + 'activation_quantize_type': 'moving_average_abs_max', + # weight quantize bit num, default is 8 + 'weight_bits': 8, + # activation quantize bit num, default is 8 + 'activation_bits': 8, + # data type after quantization, such as 'uint8', 'int8', etc. default is 'int8' + 'dtype': 'int8', + # window size for 'range_abs_max' quantization. default is 10000 + 'window_size': 10000, + # The decay coefficient of moving average, default is 0.9 + 'moving_rate': 0.9, + # for dygraph quantization, layers of type in quantizable_layer_type will be quantized + 'quantizable_layer_type': ['Conv2D', 'Linear'], +} + + +def quantize_model(config, model): + if config.get("Slim", False) and config["Slim"].get("quant", False): + from paddleslim.dygraph.quant import QAT + assert config["Slim"]["quant"]["name"].lower( + ) == 'pact', 'Only PACT quantization method is supported now' + QUANT_CONFIG["activation_preprocess_type"] = "PACT" + model.quanter = QAT(config=QUANT_CONFIG) + model.quanter.quantize(model) + logger.info("QAT model summary:") + paddle.summary(model, (1, 3, 224, 224)) + else: + model.quanter = None + return diff --git a/src/PaddleClas/ppcls/arch/utils.py b/src/PaddleClas/ppcls/arch/utils.py new file mode 100644 index 0000000..308475d --- /dev/null +++ b/src/PaddleClas/ppcls/arch/utils.py @@ -0,0 +1,53 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import six +import types +from difflib import SequenceMatcher + +from . import backbone + + +def get_architectures(): + """ + get all of model architectures + """ + names = [] + for k, v in backbone.__dict__.items(): + if isinstance(v, (types.FunctionType, six.class_types)): + names.append(k) + return names + + +def get_blacklist_model_in_static_mode(): + from ppcls.arch.backbone import distilled_vision_transformer + from ppcls.arch.backbone import vision_transformer + blacklist = distilled_vision_transformer.__all__ + vision_transformer.__all__ + return blacklist + + +def similar_architectures(name='', names=[], thresh=0.1, topk=10): + """ + inferred similar architectures + """ + scores = [] + for idx, n in enumerate(names): + if n.startswith('__'): + continue + score = SequenceMatcher(None, n.lower(), name.lower()).quick_ratio() + if score > thresh: + scores.append((idx, score)) + scores.sort(key=lambda x: x[1], reverse=True) + similar_names = [names[s[0]] for s in scores[:min(topk, len(scores))]] + return similar_names diff --git a/src/PaddleClas/ppcls/configs/Cartoonface/ResNet50_icartoon.yaml b/src/PaddleClas/ppcls/configs/Cartoonface/ResNet50_icartoon.yaml new file mode 100644 index 0000000..3d1b993 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Cartoonface/ResNet50_icartoon.yaml @@ -0,0 +1,149 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output/" + device: "gpu" + save_interval: 1 + eval_mode: "retrieval" + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + image_shape: [3, 224, 224] + infer_imgs: + save_inference_dir: "./inference" + feature_normalize: True + +Arch: + name: "RecModel" + Backbone: + name: "ResNet50" + pretrained: True + BackboneStopLayer: + name: "flatten" + output_dim: 2048 + Head: + name: "FC" + class_num: 5013 + embedding_size: 2048 + # margin: 0.5 + # scale: 80 + infer_output_key: "features" + infer_add_softmax: "false" + +Loss: + Train: + - CELoss: + weight: 1.0 + # - TripletLoss: + # margin: 0.1 + # weight: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + +DataLoader: + Train: + dataset: + name: ICartoonDataset + image_root: "./dataset/iCartoonFace" + cls_label_path: "./dataset/iCartoonFace/train_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + #num_instances: 2 + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + + Eval: + Query: + dataset: + name: ICartoonDataset + image_root: "./dataset/iCartoonFace" + cls_label_path: "./dataset/iCartoonFace/query.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + + Gallery: + dataset: + name: ICartoonDataset + image_root: "./dataset/iCartoonFace" + cls_label_path: "./dataset/iCartoonFace/gallery.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - Recallk: + topk: [1] diff --git a/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml new file mode 100644 index 0000000..626dd7c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml @@ -0,0 +1,148 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + use_dali: False + to_static: False + +# model architecture +Arch: + name: RecModel + infer_output_key: features + infer_add_softmax: False + + Backbone: + name: PPLCNet_x2_5 + pretrained: True + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1280 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 + margin: 0.2 + scale: 30 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ + cls_label_path: ./dataset/train_reg_all_data.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_binary.yaml b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_binary.yaml new file mode 100644 index 0000000..728942f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_binary.yaml @@ -0,0 +1,145 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + use_dali: False + to_static: False + + #feature postprocess + feature_normalize: False + feature_binarize: "sign" + +# model architecture +Arch: + name: RecModel + infer_output_key: features + infer_add_softmax: False + + Backbone: + name: PPLCNet_x2_5_Tanh + pretrained: True + use_ssld: True + class_num: 512 + Head: + name: FC + embedding_size: 512 + class_num: 185341 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/all_data + cls_label_path: ./dataset/all_data/train_reg_all_data.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_dml.yaml b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_dml.yaml new file mode 100644 index 0000000..b6c4536 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_dml.yaml @@ -0,0 +1,188 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: true + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + use_dali: False + to_static: False + +# model architecture +Arch: + name: "DistillationModel" + infer_output_key: features + infer_add_softmax: False + is_rec: True + infer_model_name: "Student" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - False + - False + models: + - Teacher: + name: RecModel + infer_output_key: features + infer_add_softmax: False + Backbone: + name: PPLCNet_x2_5 + pretrained: True + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1280 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 + margin: 0.2 + scale: 30 + - Student: + name: RecModel + infer_output_key: features + infer_add_softmax: False + Backbone: + name: PPLCNet_x2_5 + pretrained: True + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1280 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 + margin: 0.2 + scale: 30 + +# loss function config for traing/eval process +Loss: + Train: + - DistillationGTCELoss: + weight: 1.0 + key: "logits" + model_names: ["Student", "Teacher"] + - DistillationDMLLoss: + weight: 1.0 + key: "logits" + model_name_pairs: + - ["Student", "Teacher"] + Eval: + - DistillationGTCELoss: + weight: 1.0 + model_names: ["Student"] + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.02 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ + cls_label_path: ./dataset/train_reg_all_data.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_udml.yaml b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_udml.yaml new file mode 100644 index 0000000..bcaea03 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_udml.yaml @@ -0,0 +1,193 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: true + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + use_dali: False + to_static: False + +# model architecture +Arch: + name: "DistillationModel" + infer_output_key: features + infer_add_softmax: False + is_rec: True + infer_model_name: "Student" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - False + - False + models: + - Teacher: + name: RecModel + infer_output_key: features + infer_add_softmax: False + Backbone: + name: PPLCNet_x2_5 + pretrained: True + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1280 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 + margin: 0.2 + scale: 30 + - Student: + name: RecModel + infer_output_key: features + infer_add_softmax: False + Backbone: + name: PPLCNet_x2_5 + pretrained: True + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1280 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 + margin: 0.2 + scale: 30 + +# loss function config for traing/eval process +Loss: + Train: + - DistillationGTCELoss: + weight: 1.0 + key: "logits" + model_names: ["Student", "Teacher"] + - DistillationDMLLoss: + weight: 1.0 + key: "logits" + model_name_pairs: + - ["Student", "Teacher"] + - DistillationDistanceLoss: + weight: 1.0 + key: "backbone" + model_name_pairs: + - ["Student", "Teacher"] + Eval: + - DistillationGTCELoss: + weight: 1.0 + model_names: ["Student"] + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.02 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ + cls_label_path: ./dataset/train_reg_all_data.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/AlexNet/AlexNet.yaml b/src/PaddleClas/ppcls/configs/ImageNet/AlexNet/AlexNet.yaml new file mode 100644 index 0000000..ea2e073 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/AlexNet/AlexNet.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: AlexNet + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + decay_epochs: [30, 60, 90] + values: [0.01, 0.001, 0.0001, 0.00001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/CSPNet/CSPDarkNet53.yaml b/src/PaddleClas/ppcls/configs/ImageNet/CSPNet/CSPDarkNet53.yaml new file mode 100644 index 0000000..4848cfc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/CSPNet/CSPDarkNet53.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 256, 256] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: CSPDarkNet53 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 256 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 288 + - CropImage: + size: 256 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 288 + - CropImage: + size: 256 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102.yaml new file mode 100644 index 0000000..b6033f7 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA102 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102x.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102x.yaml new file mode 100644 index 0000000..a1e2c09 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102x.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA102x + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102x2.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102x2.yaml new file mode 100644 index 0000000..8bd4c46 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA102x2.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA102x2 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA169.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA169.yaml new file mode 100644 index 0000000..18c244d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA169.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA169 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA34.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA34.yaml new file mode 100644 index 0000000..d9218df --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA34.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA34 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA46_c.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA46_c.yaml new file mode 100644 index 0000000..8d20341 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA46_c.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA46_c + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA46x_c.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA46x_c.yaml new file mode 100644 index 0000000..e7f7d67 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA46x_c.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA46x_c + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60.yaml new file mode 100644 index 0000000..a255f05 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA60 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60x.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60x.yaml new file mode 100644 index 0000000..143b87f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60x.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA60x + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60x_c.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60x_c.yaml new file mode 100644 index 0000000..7792819 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DLA/DLA60x_c.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DLA60x_c + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN107.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN107.yaml new file mode 100644 index 0000000..7df1256 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN107.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DPN107 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN131.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN131.yaml new file mode 100644 index 0000000..88f1b57 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN131.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DPN131 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN68.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN68.yaml new file mode 100644 index 0000000..c1e2808 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN68.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DPN68 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN92.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN92.yaml new file mode 100644 index 0000000..fb5b0ed --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN92.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DPN92 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN98.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN98.yaml new file mode 100644 index 0000000..e394710 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DPN/DPN98.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DPN98 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml new file mode 100644 index 0000000..ec0f822 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 256, 256] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DarkNet53 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 256 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 292 + - CropImage: + size: 256 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 292 + - CropImage: + size: 256 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml new file mode 100644 index 0000000..ab4c29c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml new file mode 100644 index 0000000..d75fede --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml new file mode 100644 index 0000000..2fefb9f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - CutmixOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml new file mode 100644 index 0000000..4bf5306 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - Cutout: + n_holes: 1 + length: 112 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml new file mode 100644 index 0000000..c0016aa --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml @@ -0,0 +1,134 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - GridMask: + d1: 96 + d2: 224 + rotate: 1 + ratio: 0.5 + mode: 0 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml new file mode 100644 index 0000000..12e4ac8 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - HideAndSeek: + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml new file mode 100644 index 0000000..3434cab --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml new file mode 100644 index 0000000..153451e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - RandAugment: + num_layers: 2 + magnitude: 5 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml new file mode 100644 index 0000000..8e89c5c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml @@ -0,0 +1,134 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_distilled_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_distilled_patch16_224.yaml new file mode 100644 index 0000000..979a04a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_distilled_patch16_224.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_base_distilled_patch16_224 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_distilled_patch16_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_distilled_patch16_384.yaml new file mode 100644 index 0000000..859f57d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_distilled_patch16_384.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_base_distilled_patch16_384 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_224.yaml new file mode 100644 index 0000000..3cdd102 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_224.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_base_patch16_224 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_384.yaml new file mode 100644 index 0000000..88a8fba --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_384.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_base_patch16_384 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_small_distilled_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_small_distilled_patch16_224.yaml new file mode 100644 index 0000000..54d962e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_small_distilled_patch16_224.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_small_distilled_patch16_224 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_small_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_small_patch16_224.yaml new file mode 100644 index 0000000..05c3ac1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_small_patch16_224.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_small_patch16_224 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_tiny_distilled_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_tiny_distilled_patch16_224.yaml new file mode 100644 index 0000000..f666176 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_tiny_distilled_patch16_224.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_tiny_distilled_patch16_224 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_tiny_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_tiny_patch16_224.yaml new file mode 100644 index 0000000..647050a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DeiT/DeiT_tiny_patch16_224.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DeiT_tiny_patch16_224 + drop_path_rate : 0.1 + drop_rate : 0.0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token pos_embed dist_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 1e-3 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet121.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet121.yaml new file mode 100644 index 0000000..42c7e78 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet121.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DenseNet121 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet161.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet161.yaml new file mode 100644 index 0000000..3f9bbb6 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet161.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DenseNet161 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet169.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet169.yaml new file mode 100644 index 0000000..3a046fb --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet169.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DenseNet169 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet201.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet201.yaml new file mode 100644 index 0000000..ba62682 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet201.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DenseNet201 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet264.yaml b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet264.yaml new file mode 100644 index 0000000..a0a8193 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/DenseNet/DenseNet264.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: DenseNet264 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml new file mode 100644 index 0000000..a7265b0 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Distillation/mv3_large_x1_0_distill_mv3_small_x1_0.yaml @@ -0,0 +1,157 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + use_dali: false + +# model architecture +Arch: + name: "DistillationModel" + class_num: &class_num 1000 + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - True + - False + models: + - Teacher: + name: MobileNetV3_large_x1_0 + class_num: *class_num + pretrained: True + use_ssld: True + dropout_prob: null + - Student: + name: MobileNetV3_small_x1_0 + class_num: *class_num + pretrained: False + dropout_prob: null + + infer_model_name: "Student" + + +# loss function config for traing/eval process +Loss: + Train: + - DistillationCELoss: + weight: 1.0 + model_name_pairs: + - ["Student", "Teacher"] + Eval: + - DistillationGTCELoss: + weight: 1.0 + model_names: ["Student"] + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.65 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: "./dataset/ILSVRC2012/" + cls_label_path: "./dataset/ILSVRC2012/train_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: "./dataset/ILSVRC2012/" + cls_label_path: "./dataset/ILSVRC2012/val_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + +Infer: + infer_imgs: "docs/images/inference_deployment/whl_demo.jpg" + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: DistillationPostProcess + func: Topk + topk: 5 + class_id_map_file: "ppcls/utils/imagenet1k_label_list.txt" + +Metric: + Train: + - DistillationTopkAcc: + model_key: "Student" + topk: [1, 5] + Eval: + - DistillationTopkAcc: + model_key: "Student" + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_25.yaml new file mode 100644 index 0000000..b34ba07 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_25.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: ESNet_x0_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_5.yaml new file mode 100644 index 0000000..0b82e08 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_5.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: ESNet_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_75.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_75.yaml new file mode 100644 index 0000000..7662397 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x0_75.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: ESNet_x0_75 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x1_0.yaml new file mode 100644 index 0000000..583efd2 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ESNet/ESNet_x1_0.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: ESNet_x1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB0.yaml new file mode 100644 index 0000000..2d5b7d0 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB0.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB1.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB1.yaml new file mode 100644 index 0000000..b23030f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB1.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 240, 240] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB1 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 240 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 272 + - CropImage: + size: 240 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 272 + - CropImage: + size: 240 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB2.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB2.yaml new file mode 100644 index 0000000..de48d03 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB2.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 260, 260] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB2 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 260 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 292 + - CropImage: + size: 260 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 292 + - CropImage: + size: 260 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB3.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB3.yaml new file mode 100644 index 0000000..3f0b559 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB3.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 300, 300] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB3 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 300 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 332 + - CropImage: + size: 300 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 332 + - CropImage: + size: 300 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB4.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB4.yaml new file mode 100644 index 0000000..e3a009a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB4.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 380, 380] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB4 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 380 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 412 + - CropImage: + size: 380 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 412 + - CropImage: + size: 380 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB5.yaml new file mode 100644 index 0000000..795dfa1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB5.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 456, 456] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 456 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 488 + - CropImage: + size: 456 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 488 + - CropImage: + size: 456 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB6.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB6.yaml new file mode 100644 index 0000000..f86dd04 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB6.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 528, 528] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB6 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 528 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 560 + - CropImage: + size: 528 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 560 + - CropImage: + size: 528 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB7.yaml b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB7.yaml new file mode 100644 index 0000000..d57d841 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/EfficientNet/EfficientNetB7.yaml @@ -0,0 +1,133 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 600, 600] + save_inference_dir: ./inference + +# model architecture +Arch: + name: EfficientNetB7 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: RMSProp + momentum: 0.9 + rho: 0.9 + epsilon: 0.001 + lr: + name: Cosine + learning_rate: 0.032 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 600 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 632 + - CropImage: + size: 600 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 632 + - CropImage: + size: 600 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml new file mode 100644 index 0000000..ba44691 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: GhostNet_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml new file mode 100644 index 0000000..a4e6e37 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: GhostNet_x1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml b/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml new file mode 100644 index 0000000..69921be --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: GhostNet_x1_3 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml new file mode 100644 index 0000000..935b0b5 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W18_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W30_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W30_C.yaml new file mode 100644 index 0000000..5f7067c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W30_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W30_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W32_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W32_C.yaml new file mode 100644 index 0000000..fcc6dc1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W32_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W32_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W40_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W40_C.yaml new file mode 100644 index 0000000..a709677 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W40_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W40_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W44_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W44_C.yaml new file mode 100644 index 0000000..f530cc2 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W44_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W44_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W48_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W48_C.yaml new file mode 100644 index 0000000..1c7ffc9 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W48_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W48_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W64_C.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W64_C.yaml new file mode 100644 index 0000000..e72b0b3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HRNet/HRNet_W64_C.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HRNet_W64_C + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet39_ds.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet39_ds.yaml new file mode 100644 index 0000000..2aa8e68 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet39_ds.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HarDNet39_ds + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet68.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet68.yaml new file mode 100644 index 0000000..2f0ef12 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet68.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HarDNet68 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet68_ds.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet68_ds.yaml new file mode 100644 index 0000000..cf8f2ed --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet68_ds.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HarDNet68_ds + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet85.yaml b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet85.yaml new file mode 100644 index 0000000..8512859 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/HarDNet/HarDNet85.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: HarDNet85 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Inception/GoogLeNet.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Inception/GoogLeNet.yaml new file mode 100644 index 0000000..5bc3c9e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Inception/GoogLeNet.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: GoogLeNet + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - GoogLeNetLoss: + weight: 1.0 + Eval: + - GoogLeNetLoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - GoogLeNetTopkAcc: + topk: [1, 5] + Eval: + - GoogLeNetTopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Inception/InceptionV3.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Inception/InceptionV3.yaml new file mode 100644 index 0000000..3749ed8 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Inception/InceptionV3.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: InceptionV3 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Inception/InceptionV4.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Inception/InceptionV4.yaml new file mode 100644 index 0000000..7df00cc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Inception/InceptionV4.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: InceptionV4 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_128.yaml b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_128.yaml new file mode 100644 index 0000000..a1a4f73 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_128.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: LeViT_128 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml new file mode 100644 index 0000000..bfc6eb4 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: LeViT_128S + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_192.yaml b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_192.yaml new file mode 100644 index 0000000..9596e86 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_192.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: LeViT_192 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_256.yaml b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_256.yaml new file mode 100644 index 0000000..fb42700 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_256.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: LeViT_256 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_384.yaml new file mode 100644 index 0000000..8347c4a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/LeViT/LeViT_384.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: LeViT_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_L.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_L.yaml new file mode 100644 index 0000000..54bb18d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_L.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: MixNet_L + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_M.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_M.yaml new file mode 100644 index 0000000..2c2a18d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_M.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: MixNet_M + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_S.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_S.yaml new file mode 100644 index 0000000..e0f5c6a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MixNet/MixNet_S.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: MixNet_S + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml new file mode 100644 index 0000000..281015d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: MobileNetV1 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml new file mode 100644 index 0000000..86324cf --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV1_x0_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml new file mode 100644 index 0000000..1693e78 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV1_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml new file mode 100644 index 0000000..b8b0477 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV1_x0_75 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml new file mode 100644 index 0000000..2fe1f5c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: MobileNetV2 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml new file mode 100644 index 0000000..d9f30fd --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV2_x0_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml new file mode 100644 index 0000000..7abddd4 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV2_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml new file mode 100644 index 0000000..e620d70 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV2_x0_75 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml new file mode 100644 index 0000000..f9d6abc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV2_x1_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml new file mode 100644 index 0000000..fa5bf68 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV2_x2_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml new file mode 100644 index 0000000..0c81ebc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x0_35 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml new file mode 100644 index 0000000..76c7028 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml new file mode 100644 index 0000000..a1e9126 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x0_75 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml new file mode 100644 index 0000000..3e3ad70 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.65 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml new file mode 100644 index 0000000..097c41e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x1_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml new file mode 100644 index 0000000..30ea2eb --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_small_x0_35 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml new file mode 100644 index 0000000..3c13bbb --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_small_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml new file mode 100644 index 0000000..45608df --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_small_x0_75 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml new file mode 100644 index 0000000..02a3949 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_small_x1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml new file mode 100644 index 0000000..eeae690 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_small_x1_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 1.3 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml new file mode 100644 index 0000000..8b0924c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x0_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml new file mode 100644 index 0000000..ed2501e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x0_35 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml new file mode 100644 index 0000000..0f01d58 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_75.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_75.yaml new file mode 100644 index 0000000..7857882 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_75.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x0_75 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml new file mode 100644 index 0000000..f55a044 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_5.yaml new file mode 100644 index 0000000..d654d42 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_5.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x1_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_0.yaml new file mode 100644 index 0000000..50b19aa --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_0.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x2_0 + class_num: 1000 +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml new file mode 100644 index 0000000..4f677e5 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference +# model architecture +Arch: + name: PPLCNet_x2_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.8 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B0.yaml new file mode 100644 index 0000000..6c0854c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B0.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B0 + class_num: 1000 + drop_path_rate: 0.1 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B1.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B1.yaml new file mode 100644 index 0000000..42134c7 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B1.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B1 + class_num: 1000 + drop_path_rate: 0.1 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B2.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B2.yaml new file mode 100644 index 0000000..4d0d5a4 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B2.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B2 + class_num: 1000 + drop_path_rate: 0.1 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B2_Linear.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B2_Linear.yaml new file mode 100644 index 0000000..a5feb26 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B2_Linear.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B2_Linear + class_num: 1000 + drop_path_rate: 0.1 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B3.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B3.yaml new file mode 100644 index 0000000..be300ac --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B3.yaml @@ -0,0 +1,162 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B3 + class_num: 1000 + drop_path_rate: 0.3 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + clip_grad: 1.0 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B4.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B4.yaml new file mode 100644 index 0000000..b6a8953 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B4.yaml @@ -0,0 +1,162 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B4 + class_num: 1000 + drop_path_rate: 0.3 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + clip_grad: 1.0 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B5.yaml new file mode 100644 index 0000000..9d36b28 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/PVTV2/PVT_V2_B5.yaml @@ -0,0 +1,162 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: PVT_V2_B5 + class_num: 1000 + drop_path_rate: 0.3 + drop_rate: 0.0 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + clip_grad: 1.0 + no_weight_decay_name: pos_embed1 pos_embed2 pos_embed3 pos_embed4 cls_token + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 5e-6 + warmup_epoch: 20 + warmup_start_lr: 5e-7 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_0.yaml new file mode 100644 index 0000000..709d72f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_0.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ReXNet_1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_3.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_3.yaml new file mode 100644 index 0000000..18607c6 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_3.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ReXNet_1_3 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_5.yaml new file mode 100644 index 0000000..99dca8b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_1_5.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ReXNet_1_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_2_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_2_0.yaml new file mode 100644 index 0000000..285b8df --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_2_0.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ReXNet_2_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_3_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_3_0.yaml new file mode 100644 index 0000000..a44294e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ReXNet/ReXNet_3_0.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ReXNet_3_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet101.yaml b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet101.yaml new file mode 100644 index 0000000..95ea518 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet101.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: RedNet101 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet152.yaml b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet152.yaml new file mode 100644 index 0000000..7d5cc03 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet152.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: RedNet152 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet26.yaml b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet26.yaml new file mode 100644 index 0000000..089db6f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet26.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: RedNet26 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet38.yaml b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet38.yaml new file mode 100644 index 0000000..c2fb863 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet38.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: RedNet38 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet50.yaml b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet50.yaml new file mode 100644 index 0000000..02e045a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/RedNet/RedNet50.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: RedNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0 + mean: [123.675, 116.28, 103.53] + std: [58.395, 57.12, 57.375] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net101_vd_26w_4s.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net101_vd_26w_4s.yaml new file mode 100644 index 0000000..ed16b03 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net101_vd_26w_4s.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Res2Net101_vd_26w_4s + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net200_vd_26w_4s.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net200_vd_26w_4s.yaml new file mode 100644 index 0000000..af1f438 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net200_vd_26w_4s.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Res2Net200_vd_26w_4s + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_14w_8s.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_14w_8s.yaml new file mode 100644 index 0000000..7824052 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_14w_8s.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Res2Net50_14w_8s + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_26w_4s.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_26w_4s.yaml new file mode 100644 index 0000000..60767ba --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_26w_4s.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Res2Net50_26w_4s + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_vd_26w_4s.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_vd_26w_4s.yaml new file mode 100644 index 0000000..977c144 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Res2Net/Res2Net50_vd_26w_4s.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Res2Net50_vd_26w_4s + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt101.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt101.yaml new file mode 100644 index 0000000..d99e885 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt101.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 256, 256] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeSt101 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 256 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 288 + - CropImage: + size: 256 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 288 + - CropImage: + size: 256 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt50.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt50.yaml new file mode 100644 index 0000000..d822c8b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt50.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeSt50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt50_fast_1s1x64d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt50_fast_1s1x64d.yaml new file mode 100644 index 0000000..eb973af --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeSt/ResNeSt50_fast_1s1x64d.yaml @@ -0,0 +1,131 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeSt50_fast_1s1x64d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml new file mode 100644 index 0000000..e0d0a5b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_64x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_64x4d.yaml new file mode 100644 index 0000000..d68f5f7 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_64x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_64x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.00015 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_32x4d.yaml new file mode 100644 index 0000000..eadd9ee --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_vd_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml new file mode 100644 index 0000000..5c59e5a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_vd_64x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_32x4d.yaml new file mode 100644 index 0000000..8bad3f6 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt152_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_64x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_64x4d.yaml new file mode 100644 index 0000000..104f37a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_64x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt152_64x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.00018 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_32x4d.yaml new file mode 100644 index 0000000..638feef --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt152_vd_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_64x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_64x4d.yaml new file mode 100644 index 0000000..7c05197 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_64x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt152_vd_64x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_32x4d.yaml new file mode 100644 index 0000000..ef78f60 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt50_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_64x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_64x4d.yaml new file mode 100644 index 0000000..b750357 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_64x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt50_64x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_32x4d.yaml new file mode 100644 index 0000000..baf38e3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt50_vd_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_64x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_64x4d.yaml new file mode 100644 index 0000000..dba5f86 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_64x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt50_vd_64x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x16d_wsl.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x16d_wsl.yaml new file mode 100644 index 0000000..71193aa --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x16d_wsl.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_32x16d_wsl + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x32d_wsl.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x32d_wsl.yaml new file mode 100644 index 0000000..346d2ea --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x32d_wsl.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_32x32d_wsl + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x48d_wsl.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x48d_wsl.yaml new file mode 100644 index 0000000..2db3bd6 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x48d_wsl.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_32x48d_wsl + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x8d_wsl.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x8d_wsl.yaml new file mode 100644 index 0000000..bed3cc2 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNeXt101_wsl/ResNeXt101_32x8d_wsl.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNeXt101_32x8d_wsl + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet101.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet101.yaml new file mode 100644 index 0000000..2c98acf --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet101.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ResNet101 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet101_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet101_vd.yaml new file mode 100644 index 0000000..d62b7bc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet101_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet101_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet152.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet152.yaml new file mode 100644 index 0000000..0dbbaf8 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet152.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ResNet152 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet152_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet152_vd.yaml new file mode 100644 index 0000000..735c84b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet152_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet152_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet18.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet18.yaml new file mode 100644 index 0000000..4e0e460 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet18.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet18 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet18_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet18_vd.yaml new file mode 100644 index 0000000..0150633 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet18_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet18_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet200_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet200_vd.yaml new file mode 100644 index 0000000..c9209f1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet200_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet200_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet34.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet34.yaml new file mode 100644 index 0000000..5b90cf0 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet34.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet34 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet34_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet34_vd.yaml new file mode 100644 index 0000000..a894ea4 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet34_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet34_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml new file mode 100644 index 0000000..c2da23f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O1.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O1.yaml new file mode 100644 index 0000000..53e9ae2 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O1.yaml @@ -0,0 +1,147 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + image_channel: &image_channel 4 + # used for static mode and model export + image_shape: [*image_channel, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + use_dali: True + +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + # O1: mixed fp16 + level: O1 + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + input_image_channel: *image_channel + data_format: "NHWC" + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + multi_precision: True + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + channel_num: *image_channel + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + channel_num: *image_channel + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + channel_num: *image_channel + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2.yaml new file mode 100644 index 0000000..6a4425b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2.yaml @@ -0,0 +1,149 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + image_channel: &image_channel 4 + # used for static mode and model export + image_shape: [*image_channel, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + use_dali: True + +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + # O2: pure fp16 + level: O2 + +# model architecture +Arch: + name: ResNet50 + class_num: 1000 + input_image_channel: *image_channel + data_format: "NHWC" + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + multi_precision: True + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + output_fp16: True + channel_num: *image_channel + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + output_fp16: True + channel_num: *image_channel + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + output_fp16: True + channel_num: *image_channel + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml new file mode 100644 index 0000000..be7b2d9 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SENet154_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SENet154_vd.yaml new file mode 100644 index 0000000..6545cbf --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SENet154_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SENet154_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d.yaml new file mode 100644 index 0000000..f97430e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNeXt101_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2.yaml new file mode 100644 index 0000000..da005d3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2.yaml @@ -0,0 +1,143 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_channel: &image_channel 4 + image_shape: [*image_channel, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNeXt101_32x4d + class_num: 1000 + input_image_channel: *image_channel + data_format: "NHWC" + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +# mixed precision training +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + # O2: pure fp16 + level: O2 + +Optimizer: + name: Momentum + momentum: 0.9 + multi_precision: True + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + output_fp16: True + channel_num: *image_channel + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + output_fp16: True + channel_num: *image_channel + sampler: + name: BatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + output_fp16: True + channel_num: *image_channel + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt50_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt50_32x4d.yaml new file mode 100644 index 0000000..b31250b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt50_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNeXt50_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt50_vd_32x4d.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt50_vd_32x4d.yaml new file mode 100644 index 0000000..292b52d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNeXt50_vd_32x4d.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNeXt50_vd_32x4d + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet18_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet18_vd.yaml new file mode 100644 index 0000000..47d1754 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet18_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNet18_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet34_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet34_vd.yaml new file mode 100644 index 0000000..174c181 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet34_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNet34_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet50_vd.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet50_vd.yaml new file mode 100644 index 0000000..f503ea6 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SENet/SE_ResNet50_vd.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SE_ResNet50_vd + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_swish.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_swish.yaml new file mode 100644 index 0000000..e01891e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_swish.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_swish + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.5 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml new file mode 100644 index 0000000..c2e9805 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x0_25 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.5 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml new file mode 100644 index 0000000..dc7a5ef --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x0_33 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.5 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml new file mode 100644 index 0000000..796fb7a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x0_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.5 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml new file mode 100644 index 0000000..809fb2a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.5 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_5.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_5.yaml new file mode 100644 index 0000000..eb3e013 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_5.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x1_5 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.25 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x2_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x2_0.yaml new file mode 100644 index 0000000..730cf43 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x2_0.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 240 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x2_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.25 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_0.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_0.yaml new file mode 100644 index 0000000..28eba49 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_0.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SqueezeNet1_0 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.02 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_1.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_1.yaml new file mode 100644 index 0000000..b61a28c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_1.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: SqueezeNet1_1 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.02 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window12_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window12_384.yaml new file mode 100644 index 0000000..4dd0ac4 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window12_384.yaml @@ -0,0 +1,159 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: SwinTransformer_base_patch4_window12_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: absolute_pos_embed relative_position_bias_table .bias norm + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 20 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window7_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window7_224.yaml new file mode 100644 index 0000000..a42dea1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window7_224.yaml @@ -0,0 +1,159 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: SwinTransformer_base_patch4_window7_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: absolute_pos_embed relative_position_bias_table .bias norm + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 20 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window12_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window12_384.yaml new file mode 100644 index 0000000..36b5e5e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window12_384.yaml @@ -0,0 +1,159 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: SwinTransformer_large_patch4_window12_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: absolute_pos_embed relative_position_bias_table .bias norm + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 20 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 438 + interpolation: bicubic + backend: pil + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window7_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window7_224.yaml new file mode 100644 index 0000000..96a9bef --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window7_224.yaml @@ -0,0 +1,159 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: SwinTransformer_large_patch4_window7_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: absolute_pos_embed relative_position_bias_table .bias norm + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 20 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_small_patch4_window7_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_small_patch4_window7_224.yaml new file mode 100644 index 0000000..ffbbcf0 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_small_patch4_window7_224.yaml @@ -0,0 +1,159 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: SwinTransformer_small_patch4_window7_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: absolute_pos_embed relative_position_bias_table .bias norm + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 20 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml new file mode 100644 index 0000000..066db71 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml @@ -0,0 +1,159 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: SwinTransformer_tiny_patch4_window7_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: absolute_pos_embed relative_position_bias_table .bias norm + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 20 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/TNT/TNT_small.yaml b/src/PaddleClas/ppcls/configs/ImageNet/TNT/TNT_small.yaml new file mode 100644 index 0000000..1eab423 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/TNT/TNT_small.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: TNT_small + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 248 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 248 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_base.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_base.yaml new file mode 100644 index 0000000..74c402e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_base.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: alt_gvt_base + class_num: 1000 + drop_rate: 0.0 + drop_path_rate: 0.3 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token proj.0.weight proj.1.weight proj.2.weight proj.3.weight pos_block + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_large.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_large.yaml new file mode 100644 index 0000000..ca66e9a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_large.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: alt_gvt_large + class_num: 1000 + drop_rate: 0.0 + drop_path_rate: 0.5 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token proj.0.weight proj.1.weight proj.2.weight proj.3.weight pos_block + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_small.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_small.yaml new file mode 100644 index 0000000..9e97c0f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Twins/alt_gvt_small.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: alt_gvt_small + class_num: 1000 + drop_rate: 0.0 + drop_path_rate: 0.2 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token proj.0.weight proj.1.weight proj.2.weight proj.3.weight pos_block + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_base.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_base.yaml new file mode 100644 index 0000000..7831e92 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_base.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: pcpvt_base + class_num: 1000 + drop_rate: 0.0 + drop_path_rate: 0.3 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token proj.0.weight proj.1.weight proj.2.weight proj.3.weight pos_block + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_large.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_large.yaml new file mode 100644 index 0000000..8e160b3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_large.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: pcpvt_large + class_num: 1000 + drop_rate: 0.0 + drop_path_rate: 0.5 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token proj.0.weight proj.1.weight proj.2.weight proj.3.weight pos_block + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_small.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_small.yaml new file mode 100644 index 0000000..582382d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Twins/pcpvt_small.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + # training model under @to_static + to_static: False + +# model architecture +Arch: + name: pcpvt_small + class_num: 1000 + drop_rate: 0.0 + drop_path_rate: 0.2 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: AdamW + beta1: 0.9 + beta2: 0.999 + epsilon: 1e-8 + weight_decay: 0.05 + no_weight_decay_name: norm cls_token proj.0.weight proj.1.weight proj.2.weight proj.3.weight pos_block + one_dim_param_no_weight_decay: True + lr: + name: Cosine + learning_rate: 5e-4 + eta_min: 1e-5 + warmup_epoch: 5 + warmup_start_lr: 1e-6 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + interpolation: bicubic + backend: pil + - RandFlipImage: + flip_code: 1 + - TimmAutoAugment: + config_str: rand-m9-mstd0.5-inc1 + interpolation: bicubic + img_size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.25 + sl: 0.02 + sh: 1.0/3.0 + r1: 0.3 + attempt: 10 + use_log_aspect: True + mode: pixel + batch_transform_ops: + - OpSampler: + MixupOperator: + alpha: 0.8 + prob: 0.5 + CutmixOperator: + alpha: 1.0 + prob: 0.5 + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + interpolation: bicubic + backend: pil + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG11.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG11.yaml new file mode 100644 index 0000000..e55c4d0 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG11.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 90 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: VGG11 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG13.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG13.yaml new file mode 100644 index 0000000..b4a0ee3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG13.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 90 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: VGG13 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.0003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG16.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG16.yaml new file mode 100644 index 0000000..154c468 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG16.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 90 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: VGG16 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.0004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG19.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG19.yaml new file mode 100644 index 0000000..0a7022e --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VGG/VGG19.yaml @@ -0,0 +1,128 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 150 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: VGG19 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.0004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_224.yaml new file mode 100644 index 0000000..6d5857d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_224.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_base_patch16_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_384.yaml new file mode 100644 index 0000000..925d827 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_384.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_base_patch16_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch32_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch32_384.yaml new file mode 100644 index 0000000..fc4747b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch32_384.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_base_patch32_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_224.yaml new file mode 100644 index 0000000..3882c55 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_224.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_large_patch16_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_384.yaml new file mode 100644 index 0000000..3bdb387 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_384.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_large_patch16_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch32_384.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch32_384.yaml new file mode 100644 index 0000000..25212dd --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch32_384.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 384, 384] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_large_patch32_384 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 384 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 384 + - CropImage: + size: 384 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_small_patch16_224.yaml b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_small_patch16_224.yaml new file mode 100644 index 0000000..0a956b4 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/VisionTransformer/ViT_small_patch16_224.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ViT_small_patch16_224 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [30, 60, 90] + values: [0.1, 0.01, 0.001, 0.0001] + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.5, 0.5, 0.5] + std: [0.5, 0.5, 0.5] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception41.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception41.yaml new file mode 100644 index 0000000..45e64a1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception41.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Xception41 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception41_deeplab.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception41_deeplab.yaml new file mode 100644 index 0000000..daf0598 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception41_deeplab.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Xception41_deeplab + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception65.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception65.yaml new file mode 100644 index 0000000..c6bb529 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception65.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Xception65 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception65_deeplab.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception65_deeplab.yaml new file mode 100644 index 0000000..1248a29 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception65_deeplab.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Xception65_deeplab + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.045 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception71.yaml b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception71.yaml new file mode 100644 index 0000000..7f714cc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/ImageNet/Xception/Xception71.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 299, 299] + save_inference_dir: ./inference + +# model architecture +Arch: + name: Xception71 + class_num: 1000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.0225 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 299 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 32 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 320 + - CropImage: + size: 299 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/Logo/ResNet50_ReID.yaml b/src/PaddleClas/ppcls/configs/Logo/ResNet50_ReID.yaml new file mode 100644 index 0000000..0949add --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Logo/ResNet50_ReID.yaml @@ -0,0 +1,151 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + eval_mode: "retrieval" + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "CircleMargin" + margin: 0.35 + scale: 64 + embedding_size: 512 + class_num: 3000 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - PairwiseCosface: + margin: 0.35 + gamma: 64 + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + regularizer: + name: 'L2' + coeff: 0.0001 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: "dataset/LogoDet-3K-crop/train/" + cls_label_path: "dataset/LogoDet-3K-crop/train_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sampler: + name: PKSampler + batch_size: 128 + sample_per_id: 2 + drop_last: True + + loader: + num_workers: 6 + use_shared_memory: True + Eval: + Query: + dataset: + name: ImageNetDataset + image_root: "dataset/LogoDet-3K-crop/val/" + cls_label_path: "dataset/LogoDet-3K-crop/query_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + + Gallery: + dataset: + name: ImageNetDataset + image_root: "dataset/LogoDet-3K-crop/train/" + cls_label_path: "dataset/LogoDet-3K-crop/train_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} + diff --git a/src/PaddleClas/ppcls/configs/Products/MV3_Large_1x_Aliproduct_DLBHC.yaml b/src/PaddleClas/ppcls/configs/Products/MV3_Large_1x_Aliproduct_DLBHC.yaml new file mode 100644 index 0000000..ad77ea9 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Products/MV3_Large_1x_Aliproduct_DLBHC.yaml @@ -0,0 +1,149 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output_dlbhc/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + #eval_mode: "retrieval" + print_batch_step: 10 + use_visualdl: False + + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + + #feature postprocess + feature_normalize: False + feature_binarize: "round" + +# model architecture +Arch: + name: "RecModel" + Backbone: + name: "MobileNetV3_large_x1_0" + pretrained: True + class_num: 512 + Head: + name: "FC" + class_num: 50030 + embedding_size: 512 + + infer_output_key: "features" + infer_add_softmax: "false" + +# loss function config for train/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.1 + decay_epochs: [50, 150] + values: [0.1, 0.01, 0.001] + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 256 + - RandCropImage: + size: 227 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.4914, 0.4822, 0.4465] + std: [0.2023, 0.1994, 0.2010] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 227 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.4914, 0.4822, 0.4465] + std: [0.2023, 0.1994, 0.2010] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 227 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.4914, 0.4822, 0.4465] + std: [0.2023, 0.1994, 0.2010] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] + +# switch to metric below when eval by retrieval +# - Recallk: +# topk: [1] +# - mAP: +# - Precisionk: +# topk: [1] + diff --git a/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml b/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml new file mode 100644 index 0000000..70f8056 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_Aliproduct.yaml @@ -0,0 +1,119 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 10 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: classification + +# model architecture +Arch: + name: RecModel + infer_output_key: features + infer_add_softmax: False + + Backbone: + name: ResNet50_vd + pretrained: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 2048 + class_num: 512 + Head: + name: FC + embedding_size: 512 + class_num: 50030 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.05 + regularizer: + name: 'L2' + coeff: 0.00007 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] + diff --git a/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_Inshop.yaml b/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_Inshop.yaml new file mode 100644 index 0000000..18ddfa3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_Inshop.yaml @@ -0,0 +1,157 @@ +# global configs +Global: + checkpoints: null + pretrained_model: "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/product_ResNet50_vd_Aliproduct_v1.0_pretrained.pdparams" + output_dir: ./output/ + device: gpu + save_interval: 10 + eval_during_train: True + eval_interval: 10 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + +# model architecture +Arch: + name: RecModel + infer_output_key: features + infer_add_softmax: False + + Backbone: + name: ResNet50_vd + pretrained: False + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 2048 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 3997 + margin: 0.15 + scale: 30 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: MultiStepDecay + learning_rate: 0.04 + milestones: [30, 60, 70, 80, 90, 100] + gamma: 0.5 + verbose: False + last_epoch: -1 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/Inshop/ + cls_label_path: ./dataset/Inshop/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + sampler: + name: PKSampler + batch_size: 64 + sample_per_id: 2 + drop_last: True + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: ImageNetDataset + image_root: ./dataset/Inshop/ + cls_label_path: ./dataset/Inshop/query_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: ImageNetDataset + image_root: ./dataset/Inshop/ + cls_label_path: ./dataset/Inshop/gallery_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + diff --git a/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_SOP.yaml b/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_SOP.yaml new file mode 100644 index 0000000..7728a66 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Products/ResNet50_vd_SOP.yaml @@ -0,0 +1,156 @@ +# global configs +Global: + checkpoints: null + pretrained_model: "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/product_ResNet50_vd_Aliproduct_v1.0_pretrained.pdparams" + output_dir: ./output/ + device: gpu + save_interval: 10 + eval_during_train: True + eval_interval: 10 + epochs: 120 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + +# model architecture +Arch: + name: RecModel + Backbone: + name: ResNet50_vd + pretrained: False + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 2048 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 11319 + margin: 0.15 + scale: 30 + infer_output_key: features + infer_add_softmax: False + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: MultiStepDecay + learning_rate: 0.01 + milestones: [30, 60, 70, 80, 90, 100] + gamma: 0.5 + verbose: False + last_epoch: -1 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: VeriWild + image_root: ./dataset/SOP/ + cls_label_path: ./dataset/SOP/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 64 + sample_per_id: 2 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/SOP/ + cls_label_path: ./dataset/SOP/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 32 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/SOP/ + cls_label_path: ./dataset/SOP/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 32 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} diff --git a/src/PaddleClas/ppcls/configs/Vehicle/PPLCNet_2.5x_ReID.yaml b/src/PaddleClas/ppcls/configs/Vehicle/PPLCNet_2.5x_ReID.yaml new file mode 100644 index 0000000..eb9f145 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Vehicle/PPLCNet_2.5x_ReID.yaml @@ -0,0 +1,158 @@ +# global configs +# pretrained_model: https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/vehicle_reid_PPLCNet2.5x_VERIWild_v1.0_pretrained.pdparams +# VeriWild v1 small: recall1: 0.93736, recall5: 0.98427, mAP: 0.82125 +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output_reid/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 160 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + eval_mode: "retrieval" + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "PPLCNet_x2_5" + pretrained: True + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: "FC" + embedding_size: 1280 + class_num: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 30671 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images/" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/train_list_start0.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 128 + sample_per_id: 2 + drop_last: True + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + Eval: + Query: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id_query.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + + Gallery: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} + diff --git a/src/PaddleClas/ppcls/configs/Vehicle/ResNet50.yaml b/src/PaddleClas/ppcls/configs/Vehicle/ResNet50.yaml new file mode 100644 index 0000000..6b61724 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Vehicle/ResNet50.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 160 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 431 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.0005 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "CompCars" + image_root: "./dataset/CompCars/image/" + label_root: "./dataset/CompCars/label/" + bbox_crop: True + cls_label_path: "./dataset/CompCars/train_test_split/classification/train_label.txt" + transform_ops: + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 128 + sample_per_id: 2 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: "CompCars" + image_root: "./dataset/CompCars/image/" + label_root: "./dataset/CompCars/label/" + cls_label_path: "./dataset/CompCars/train_test_split/classification/test_label.txt" + bbox_crop: True + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] + diff --git a/src/PaddleClas/ppcls/configs/Vehicle/ResNet50_ReID.yaml b/src/PaddleClas/ppcls/configs/Vehicle/ResNet50_ReID.yaml new file mode 100644 index 0000000..c13d59a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/Vehicle/ResNet50_ReID.yaml @@ -0,0 +1,155 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 160 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + eval_mode: "retrieval" + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 30671 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images/" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/train_list_start0.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 128 + sample_per_id: 2 + drop_last: True + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + Eval: + Query: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id_query.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + + Gallery: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} + diff --git a/src/PaddleClas/ppcls/configs/quick_start/MobileNetV1_retrieval.yaml b/src/PaddleClas/ppcls/configs/quick_start/MobileNetV1_retrieval.yaml new file mode 100644 index 0000000..f088e1c --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/MobileNetV1_retrieval.yaml @@ -0,0 +1,158 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 5 + eval_during_train: True + eval_interval: 1 + epochs: 50 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + +# model architecture +Arch: + name: RecModel + infer_output_key: features + infer_add_softmax: False + + Backbone: + name: MobileNetV1 + pretrained: False + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1024 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 101 + margin: 0.15 + scale: 30 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - TripletLossV2: + weight: 1.0 + margin: 0.5 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: MultiStepDecay + learning_rate: 0.01 + milestones: [20, 30, 40] + gamma: 0.5 + verbose: False + last_epoch: -1 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: VeriWild + image_root: ./dataset/CUB_200_2011/ + cls_label_path: ./dataset/CUB_200_2011/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + sampler: + name: DistributedRandomIdentitySampler + batch_size: 64 + num_instances: 2 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/CUB_200_2011/ + cls_label_path: ./dataset/CUB_200_2011/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/CUB_200_2011/ + cls_label_path: ./dataset/CUB_200_2011/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} + diff --git a/src/PaddleClas/ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml b/src/PaddleClas/ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml new file mode 100644 index 0000000..d87dc09 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/MobileNetV3_large_x1_0.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 20 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x1_0 + class_num: 102 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.00375 + warmup_epoch: 5 + last_epoch: -1 + regularizer: + name: 'L2' + coeff: 0.000001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 32 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ./dataset/flowers102/flowers102_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/ResNet50_vd.yaml b/src/PaddleClas/ppcls/configs/quick_start/ResNet50_vd.yaml new file mode 100644 index 0000000..90b2c88 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/ResNet50_vd.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 20 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50_vd + class_num: 102 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.0125 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 32 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ./dataset/flowers102/flowers102_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/kunlun/HRNet_W18_C_finetune_kunlun.yaml b/src/PaddleClas/ppcls/configs/quick_start/kunlun/HRNet_W18_C_finetune_kunlun.yaml new file mode 100644 index 0000000..6a461cc --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/kunlun/HRNet_W18_C_finetune_kunlun.yaml @@ -0,0 +1,68 @@ +mode: 'train' +ARCHITECTURE: + name: 'HRNet_W18_C' +pretrained_model: "./pretrained/HRNet_W18_C_pretrained" +model_save_dir: "./output/" +classes_num: 102 +total_images: 1020 +save_interval: 1 +validate: True +valid_interval: 1 +epochs: 10 +topk: 5 +image_shape: [3, 224, 224] + +LEARNING_RATE: + function: 'Cosine' + params: + lr: 0.00375 + +OPTIMIZER: + function: 'Momentum' + params: + momentum: 0.9 + regularizer: + function: 'L2' + factor: 0.000001 + +TRAIN: + batch_size: 20 + num_workers: 0 + file_list: "./dataset/flowers102/train_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1./255. + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +VALID: + batch_size: 20 + num_workers: 0 + file_list: "./dataset/flowers102/val_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: diff --git a/src/PaddleClas/ppcls/configs/quick_start/kunlun/ResNet50_vd_finetune_kunlun.yaml b/src/PaddleClas/ppcls/configs/quick_start/kunlun/ResNet50_vd_finetune_kunlun.yaml new file mode 100644 index 0000000..7fad5ee --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/kunlun/ResNet50_vd_finetune_kunlun.yaml @@ -0,0 +1,69 @@ +mode: 'train' +ARCHITECTURE: + name: 'ResNet50_vd' +pretrained_model: "./pretrained/ResNet50_vd_pretrained" +load_static_weights: true +model_save_dir: "./output/" +classes_num: 102 +total_images: 1020 +save_interval: 1 +validate: True +valid_interval: 1 +epochs: 20 +topk: 5 +image_shape: [3, 224, 224] + +LEARNING_RATE: + function: 'Cosine' + params: + lr: 0.00375 + +OPTIMIZER: + function: 'Momentum' + params: + momentum: 0.9 + regularizer: + function: 'L2' + factor: 0.000001 + +TRAIN: + batch_size: 20 + num_workers: 1 + file_list: "./dataset/flowers102/train_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1./255. + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +VALID: + batch_size: 20 + num_workers: 1 + file_list: "./dataset/flowers102/val_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: diff --git a/src/PaddleClas/ppcls/configs/quick_start/kunlun/VGG16_finetune_kunlun.yaml b/src/PaddleClas/ppcls/configs/quick_start/kunlun/VGG16_finetune_kunlun.yaml new file mode 100644 index 0000000..389a5f3 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/kunlun/VGG16_finetune_kunlun.yaml @@ -0,0 +1,70 @@ +mode: 'train' +ARCHITECTURE: + name: 'VGG16' + params: + stop_grad_layers: 5 +pretrained_model: "./pretrained/VGG16_pretrained" +model_save_dir: "./output/" +classes_num: 102 +total_images: 1020 +save_interval: 1 +validate: True +valid_interval: 1 +epochs: 20 +topk: 5 +image_shape: [3, 224, 224] + +LEARNING_RATE: + function: 'Cosine' + params: + lr: 0.0005 + +OPTIMIZER: + function: 'Momentum' + params: + momentum: 0.9 + regularizer: + function: 'L2' + factor: 0.00001 + +TRAIN: + batch_size: 20 + num_workers: 0 + file_list: "./dataset/flowers102/train_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1./255. + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +VALID: + batch_size: 20 + num_workers: 0 + file_list: "./dataset/flowers102/val_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: diff --git a/src/PaddleClas/ppcls/configs/quick_start/kunlun/VGG19_finetune_kunlun.yaml b/src/PaddleClas/ppcls/configs/quick_start/kunlun/VGG19_finetune_kunlun.yaml new file mode 100644 index 0000000..6ba38b9 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/kunlun/VGG19_finetune_kunlun.yaml @@ -0,0 +1,70 @@ +mode: 'train' +ARCHITECTURE: + name: 'VGG19' + params: + stop_grad_layers: 5 +pretrained_model: "./pretrained/VGG19_pretrained" +model_save_dir: "./output/" +classes_num: 102 +total_images: 1020 +save_interval: 1 +validate: True +valid_interval: 1 +epochs: 20 +topk: 5 +image_shape: [3, 224, 224] + +LEARNING_RATE: + function: 'Cosine' + params: + lr: 0.0005 + +OPTIMIZER: + function: 'Momentum' + params: + momentum: 0.9 + regularizer: + function: 'L2' + factor: 0.00001 + +TRAIN: + batch_size: 20 + num_workers: 0 + file_list: "./dataset/flowers102/train_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1./255. + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + +VALID: + batch_size: 20 + num_workers: 0 + file_list: "./dataset/flowers102/val_list.txt" + data_dir: "./dataset/flowers102/" + shuffle_seed: 0 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: diff --git a/src/PaddleClas/ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml b/src/PaddleClas/ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml new file mode 100644 index 0000000..1246366 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/new_user/ShuffleNetV2_x0_25.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: cpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 20 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ShuffleNetV2_x0_25 + class_num: 102 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.0125 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/flowers102/ + cls_label_path: ./dataset/flowers102/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ./dataset/flowers102/flowers102_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml b/src/PaddleClas/ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml new file mode 100644 index 0000000..6838710 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 10 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + use_multilabel: True +# model architecture +Arch: + name: MobileNetV1 + class_num: 33 + pretrained: True + +# loss function config for traing/eval process +Loss: + Train: + - MultiLabelLoss: + weight: 1.0 + Eval: + - MultiLabelLoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00004 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: MultiLabelDataset + image_root: ./dataset/NUS-WIDE-SCENE/NUS-SCENE-dataset/images/ + cls_label_path: ./dataset/NUS-WIDE-SCENE/NUS-SCENE-dataset/multilabel_train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: MultiLabelDataset + image_root: ./dataset/NUS-WIDE-SCENE/NUS-SCENE-dataset/images/ + cls_label_path: ./dataset/NUS-WIDE-SCENE/NUS-SCENE-dataset/multilabel_test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: ./deploy/images/0517_2715693311.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: MultiLabelTopk + topk: 5 + class_id_map_file: None + +Metric: + Train: + - HammingDistance: + - AccuracyScore: + Eval: + - HammingDistance: + - AccuracyScore: diff --git a/src/PaddleClas/ppcls/configs/quick_start/professional/MobileNetV3_large_x1_0_CIFAR100_finetune.yaml b/src/PaddleClas/ppcls/configs/quick_start/professional/MobileNetV3_large_x1_0_CIFAR100_finetune.yaml new file mode 100644 index 0000000..423a453 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/professional/MobileNetV3_large_x1_0_CIFAR100_finetune.yaml @@ -0,0 +1,127 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 32, 32] + save_inference_dir: ./inference + +# model architecture +Arch: + name: MobileNetV3_large_x1_0 + class_num: 100 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/CIFAR100/ + cls_label_path: ./dataset/CIFAR100/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 32 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/CIFAR100/ + cls_label_path: ./dataset/CIFAR100/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/professional/R50_vd_distill_MV3_large_x1_0_CIFAR100.yaml b/src/PaddleClas/ppcls/configs/quick_start/professional/R50_vd_distill_MV3_large_x1_0_CIFAR100.yaml new file mode 100644 index 0000000..a27068d --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/professional/R50_vd_distill_MV3_large_x1_0_CIFAR100.yaml @@ -0,0 +1,151 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: "./output/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 32, 32] + save_inference_dir: "./inference" + +# model architecture +Arch: + name: "DistillationModel" + # if not null, its lengths should be same as models + pretrained_list: + # if not null, its lengths should be same as models + freeze_params_list: + - True + - False + models: + - Teacher: + name: ResNet50_vd + class_num: 100 + pretrained: "./pretrained/best_model" + - Student: + name: MobileNetV3_large_x1_0 + class_num: 100 + pretrained: True + + infer_model_name: "Student" + + +# loss function config for traing/eval process +Loss: + Train: + - DistillationCELoss: + weight: 1.0 + model_name_pairs: + - ["Student", "Teacher"] + Eval: + - DistillationGTCELoss: + weight: 1.0 + model_names: ["Student"] + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: "./dataset/CIFAR100/" + cls_label_path: "./dataset/CIFAR100/train_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 32 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: "./dataset/CIFAR100/" + cls_label_path: "./dataset/CIFAR100/test_list.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + +Infer: + infer_imgs: "docs/images/inference_deployment/whl_demo.jpg" + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: DistillationPostProcess + func: Topk + topk: 5 + +Metric: + Train: + - DistillationTopkAcc: + model_key: "Student" + topk: [1, 5] + Eval: + - DistillationTopkAcc: + model_key: "Student" + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml b/src/PaddleClas/ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml new file mode 100644 index 0000000..ca0794f --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/professional/ResNet50_vd_CIFAR100.yaml @@ -0,0 +1,127 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: cpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 32, 32] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50_vd + class_num: 100 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/CIFAR100/ + cls_label_path: ./dataset/CIFAR100/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 32 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/CIFAR100/ + cls_label_path: ./dataset/CIFAR100/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/professional/ResNet50_vd_mixup_CIFAR100_finetune.yaml b/src/PaddleClas/ppcls/configs/quick_start/professional/ResNet50_vd_mixup_CIFAR100_finetune.yaml new file mode 100644 index 0000000..d8ff817 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/professional/ResNet50_vd_mixup_CIFAR100_finetune.yaml @@ -0,0 +1,127 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 100 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 32, 32] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50_vd + class_num: 100 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.04 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/CIFAR100/ + cls_label_path: ./dataset/CIFAR100/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 32 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/CIFAR100/ + cls_label_path: ./dataset/CIFAR100/test_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 36 + - CropImage: + size: 32 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/quick_start/professional/VGG19_CIFAR10_DeepHash.yaml b/src/PaddleClas/ppcls/configs/quick_start/professional/VGG19_CIFAR10_DeepHash.yaml new file mode 100644 index 0000000..9722882 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/quick_start/professional/VGG19_CIFAR10_DeepHash.yaml @@ -0,0 +1,147 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + eval_mode: "retrieval" + epochs: 128 + print_batch_step: 10 + use_visualdl: False + + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + + #feature postprocess + feature_normalize: False + feature_binarize: "round" + +# model architecture +Arch: + name: "RecModel" + Backbone: + name: "VGG19Sigmoid" + pretrained: True + class_num: 48 + Head: + name: "FC" + class_num: 10 + embedding_size: 48 + + infer_output_key: "features" + infer_add_softmax: "false" + +# loss function config for train/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Piecewise + learning_rate: 0.01 + decay_epochs: [200] + values: [0.01, 0.001] + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/cifar10/ + cls_label_path: ./dataset/cifar10/cifar10-2/train.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 256 + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.4914, 0.4822, 0.4465] + std: [0.2023, 0.1994, 0.2010] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: ImageNetDataset + image_root: ./dataset/cifar10/ + cls_label_path: ./dataset/cifar10/cifar10-2/test.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.4914, 0.4822, 0.4465] + std: [0.2023, 0.1994, 0.2010] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: ImageNetDataset + image_root: ./dataset/cifar10/ + cls_label_path: ./dataset/cifar10/cifar10-2/database.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.4914, 0.4822, 0.4465] + std: [0.2023, 0.1994, 0.2010] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 512 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - mAP: + - Precisionk: + topk: [1, 5] + diff --git a/src/PaddleClas/ppcls/configs/slim/GeneralRecognition_PPLCNet_x2_5_quantization.yaml b/src/PaddleClas/ppcls/configs/slim/GeneralRecognition_PPLCNet_x2_5_quantization.yaml new file mode 100644 index 0000000..7b21d0b --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/GeneralRecognition_PPLCNet_x2_5_quantization.yaml @@ -0,0 +1,154 @@ +# global configs +Global: + checkpoints: null + pretrained_model: https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/general_PPLCNet_x2_5_pretrained_v1.0.pdparams + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 30 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + eval_mode: retrieval + use_dali: False + to_static: False + +# for quantizaiton or prune model +Slim: + ## for prune + quant: + name: pact + +# model architecture +Arch: + name: RecModel + infer_output_key: features + infer_add_softmax: False + + Backbone: + name: PPLCNet_x2_5 + pretrained: False + use_ssld: True + BackboneStopLayer: + name: "flatten" + Neck: + name: FC + embedding_size: 1280 + class_num: 512 + Head: + name: ArcMargin + embedding_size: 512 + class_num: 185341 + margin: 0.2 + scale: 30 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.002 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ + cls_label_path: ./dataset/train_reg_all_data.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + Query: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + + Gallery: + dataset: + name: VeriWild + image_root: ./dataset/Aliproduct/ + cls_label_path: ./dataset/Aliproduct/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml b/src/PaddleClas/ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml new file mode 100644 index 0000000..6655c3a --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml @@ -0,0 +1,139 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 360 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# for quantization or prune model +Slim: + ## for prune + prune: + name: fpgm + pruned_ratio: 0.3 + +# model architecture +Arch: + name: MobileNetV3_large_x1_0 + class_num: 1000 + pretrained: True + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.65 + warmup_epoch: 5 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml b/src/PaddleClas/ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml new file mode 100644 index 0000000..517c467 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml @@ -0,0 +1,138 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 60 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# for quantalization or prune model +Slim: + ## for quantization + quant: + name: pact + +# model architecture +Arch: + name: MobileNetV3_large_x1_0 + class_num: 1000 + pretrained: True + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.065 + warmup_epoch: 0 + regularizer: + name: 'L2' + coeff: 0.00002 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 256 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/slim/PPLCNet_x1_0_quantization.yaml b/src/PaddleClas/ppcls/configs/slim/PPLCNet_x1_0_quantization.yaml new file mode 100644 index 0000000..40111a0 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/PPLCNet_x1_0_quantization.yaml @@ -0,0 +1,138 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 60 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# for quantalization or prune model +Slim: + ## for quantization + quant: + name: pact + +# model architecture +Arch: + name: PPLCNet_x1_0 + class_num: 1000 + pretrained: True + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.02 + warmup_epoch: 0 + regularizer: + name: 'L2' + coeff: 0.00003 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/slim/ResNet50_vd_prune.yaml b/src/PaddleClas/ppcls/configs/slim/ResNet50_vd_prune.yaml new file mode 100644 index 0000000..7bfc537 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/ResNet50_vd_prune.yaml @@ -0,0 +1,138 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 200 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# for quantization or prune model +Slim: + ## for prune + prune: + name: fpgm + pruned_ratio: 0.3 + +# model architecture +Arch: + name: ResNet50_vd + class_num: 1000 + pretrained: True + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/slim/ResNet50_vd_quantization.yaml b/src/PaddleClas/ppcls/configs/slim/ResNet50_vd_quantization.yaml new file mode 100644 index 0000000..f9db410 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/ResNet50_vd_quantization.yaml @@ -0,0 +1,137 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 30 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# for quantalization or prune model +Slim: + ## for quantization + quant: + name: pact + +# model architecture +Arch: + name: ResNet50_vd + class_num: 1000 + pretrained: True + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + epsilon: 0.1 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.00007 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 4 + use_shared_memory: True + +Infer: + infer_imgs: docs/images/inference_deployment/whl_demo.jpg + batch_size: 10 + transforms: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + resize_short: 256 + - CropImage: + size: 224 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - ToCHWImage: + PostProcess: + name: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_cls_prune.yaml b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_cls_prune.yaml new file mode 100644 index 0000000..1f6fea8 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_cls_prune.yaml @@ -0,0 +1,135 @@ +# global configs +Global: + checkpoints: null + pretrained_model: "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/vehicle_cls_ResNet50_CompCars_v1.2_pretrained.pdparams" + output_dir: "./output_vehicle_cls_prune/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 160 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + +Slim: + prune: + name: fpgm + pruned_ratio: 0.3 + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 431 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.0005 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "CompCars" + image_root: "./dataset/CompCars/image/" + label_root: "./dataset/CompCars/label/" + bbox_crop: True + cls_label_path: "./dataset/CompCars/train_test_split/classification/train_label.txt" + transform_ops: + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 128 + sample_per_id: 2 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: "CompCars" + image_root: "./dataset/CompCars/image/" + label_root: "./dataset/CompCars/label/" + cls_label_path: "./dataset/CompCars/train_test_split/classification/test_label.txt" + bbox_crop: True + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] + diff --git a/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_cls_quantization.yaml b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_cls_quantization.yaml new file mode 100644 index 0000000..026b865 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_cls_quantization.yaml @@ -0,0 +1,134 @@ +# global configs +Global: + checkpoints: null + pretrained_model: "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/vehicle_cls_ResNet50_CompCars_v1.2_pretrained.pdparams" + output_dir: "./output_vehicle_cls_pact/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 80 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + +Slim: + quant: + name: pact + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 431 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.001 + regularizer: + name: 'L2' + coeff: 0.0005 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "CompCars" + image_root: "./dataset/CompCars/image/" + label_root: "./dataset/CompCars/label/" + bbox_crop: True + cls_label_path: "./dataset/CompCars/train_test_split/classification/train_label.txt" + transform_ops: + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 64 + sample_per_id: 2 + drop_last: False + shuffle: True + loader: + num_workers: 8 + use_shared_memory: True + + Eval: + dataset: + name: "CompCars" + image_root: "./dataset/CompCars/image/" + label_root: "./dataset/CompCars/label/" + cls_label_path: "./dataset/CompCars/train_test_split/classification/test_label.txt" + bbox_crop: True + transform_ops: + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 128 + drop_last: False + shuffle: False + loader: + num_workers: 8 + use_shared_memory: True + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] + diff --git a/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_reid_prune.yaml b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_reid_prune.yaml new file mode 100644 index 0000000..63b87f1 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_reid_prune.yaml @@ -0,0 +1,162 @@ +# global configs +Global: + checkpoints: null + pretrained_model: "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/vehicle_reid_ResNet50_VERIWild_v1.1_pretrained.pdparams" + output_dir: "./output_vehicle_reid_prune/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 160 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + eval_mode: "retrieval" + +# for quantizaiton or prune model +Slim: + ## for prune + prune: + name: fpgm + pruned_ratio: 0.3 + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 30671 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.01 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images/" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/train_list_start0.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 128 + sample_per_id: 2 + drop_last: False + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + Eval: + Query: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id_query.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + + Gallery: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} + diff --git a/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_reid_quantization.yaml b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_reid_quantization.yaml new file mode 100644 index 0000000..cca9915 --- /dev/null +++ b/src/PaddleClas/ppcls/configs/slim/ResNet50_vehicle_reid_quantization.yaml @@ -0,0 +1,161 @@ +# global configs +Global: + checkpoints: null + pretrained_model: "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/vehicle_reid_ResNet50_VERIWild_v1.1_pretrained.pdparams" + output_dir: "./output_vehicle_reid_pact/" + device: "gpu" + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 40 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: "./inference" + eval_mode: "retrieval" + +# for quantizaiton or prune model +Slim: + ## for prune + quant: + name: pact + +# model architecture +Arch: + name: "RecModel" + infer_output_key: "features" + infer_add_softmax: False + Backbone: + name: "ResNet50_last_stage_stride1" + pretrained: True + BackboneStopLayer: + name: "avg_pool" + Neck: + name: "VehicleNeck" + in_channels: 2048 + out_channels: 512 + Head: + name: "ArcMargin" + embedding_size: 512 + class_num: 30671 + margin: 0.15 + scale: 32 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + - SupConLoss: + weight: 1.0 + views: 2 + Eval: + - CELoss: + weight: 1.0 + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.001 + regularizer: + name: 'L2' + coeff: 0.0005 + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images/" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/train_list_start0.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AugMix: + prob: 0.5 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - RandomErasing: + EPSILON: 0.5 + sl: 0.02 + sh: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: PKSampler + batch_size: 64 + sample_per_id: 2 + drop_last: False + shuffle: True + loader: + num_workers: 6 + use_shared_memory: True + Eval: + Query: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id_query.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + + Gallery: + dataset: + name: "VeriWild" + image_root: "./dataset/VeRI-Wild/images" + cls_label_path: "./dataset/VeRI-Wild/train_test_split/test_3000_id.txt" + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - ResizeImage: + size: 224 + - NormalizeImage: + scale: 0.00392157 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: False + loader: + num_workers: 6 + use_shared_memory: True + +Metric: + Eval: + - Recallk: + topk: [1, 5] + - mAP: {} + diff --git a/src/PaddleClas/ppcls/data/__init__.py b/src/PaddleClas/ppcls/data/__init__.py new file mode 100644 index 0000000..cffac81 --- /dev/null +++ b/src/PaddleClas/ppcls/data/__init__.py @@ -0,0 +1,144 @@ +# Copyright (c) 2021 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. + +import inspect +import copy +import paddle +import numpy as np +from paddle.io import DistributedBatchSampler, BatchSampler, DataLoader +from ppcls.utils import logger + +from ppcls.data import dataloader +# dataset +from ppcls.data.dataloader.imagenet_dataset import ImageNetDataset +from ppcls.data.dataloader.multilabel_dataset import MultiLabelDataset +from ppcls.data.dataloader.common_dataset import create_operators +from ppcls.data.dataloader.vehicle_dataset import CompCars, VeriWild +from ppcls.data.dataloader.logo_dataset import LogoDataset +from ppcls.data.dataloader.icartoon_dataset import ICartoonDataset +from ppcls.data.dataloader.mix_dataset import MixDataset + +# sampler +from ppcls.data.dataloader.DistributedRandomIdentitySampler import DistributedRandomIdentitySampler +from ppcls.data.dataloader.pk_sampler import PKSampler +from ppcls.data.dataloader.mix_sampler import MixSampler +from ppcls.data import preprocess +from ppcls.data.preprocess import transform + + +def create_operators(params, class_num=None): + """ + create operators based on the config + + Args: + params(list): a dict list, used to create some operators + """ + assert isinstance(params, list), ('operator config should be a list') + ops = [] + for operator in params: + assert isinstance(operator, + dict) and len(operator) == 1, "yaml format error" + op_name = list(operator)[0] + param = {} if operator[op_name] is None else operator[op_name] + op_func = getattr(preprocess, op_name) + if "class_num" in inspect.getfullargspec(op_func).args: + param.update({"class_num": class_num}) + op = op_func(**param) + ops.append(op) + + return ops + + +def build_dataloader(config, mode, device, use_dali=False, seed=None): + assert mode in [ + 'Train', 'Eval', 'Test', 'Gallery', 'Query' + ], "Dataset mode should be Train, Eval, Test, Gallery, Query" + # build dataset + if use_dali: + from ppcls.data.dataloader.dali import dali_dataloader + return dali_dataloader(config, mode, paddle.device.get_device(), seed) + + class_num = config.get("class_num", None) + config_dataset = config[mode]['dataset'] + config_dataset = copy.deepcopy(config_dataset) + dataset_name = config_dataset.pop('name') + if 'batch_transform_ops' in config_dataset: + batch_transform = config_dataset.pop('batch_transform_ops') + else: + batch_transform = None + + dataset = eval(dataset_name)(**config_dataset) + + logger.debug("build dataset({}) success...".format(dataset)) + + # build sampler + config_sampler = config[mode]['sampler'] + if "name" not in config_sampler: + batch_sampler = None + batch_size = config_sampler["batch_size"] + drop_last = config_sampler["drop_last"] + shuffle = config_sampler["shuffle"] + else: + sampler_name = config_sampler.pop("name") + batch_sampler = eval(sampler_name)(dataset, **config_sampler) + + logger.debug("build batch_sampler({}) success...".format(batch_sampler)) + + # build batch operator + def mix_collate_fn(batch): + batch = transform(batch, batch_ops) + # batch each field + slots = [] + for items in batch: + for i, item in enumerate(items): + if len(slots) < len(items): + slots.append([item]) + else: + slots[i].append(item) + return [np.stack(slot, axis=0) for slot in slots] + + if isinstance(batch_transform, list): + batch_ops = create_operators(batch_transform, class_num) + batch_collate_fn = mix_collate_fn + else: + batch_collate_fn = None + + # build dataloader + config_loader = config[mode]['loader'] + num_workers = config_loader["num_workers"] + use_shared_memory = config_loader["use_shared_memory"] + + if batch_sampler is None: + data_loader = DataLoader( + dataset=dataset, + places=device, + num_workers=num_workers, + return_list=True, + use_shared_memory=use_shared_memory, + batch_size=batch_size, + shuffle=shuffle, + drop_last=drop_last, + collate_fn=batch_collate_fn) + else: + data_loader = DataLoader( + dataset=dataset, + places=device, + num_workers=num_workers, + return_list=True, + use_shared_memory=use_shared_memory, + batch_sampler=batch_sampler, + collate_fn=batch_collate_fn) + + logger.debug("build data_loader({}) success...".format(data_loader)) + return data_loader diff --git a/src/PaddleClas/ppcls/data/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..a93f9c4 Binary files /dev/null and b/src/PaddleClas/ppcls/data/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/.imagenet_dataset.py.un~ b/src/PaddleClas/ppcls/data/dataloader/.imagenet_dataset.py.un~ new file mode 100644 index 0000000..f7f916d Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/.imagenet_dataset.py.un~ differ diff --git a/src/PaddleClas/ppcls/data/dataloader/DistributedRandomIdentitySampler.py b/src/PaddleClas/ppcls/data/dataloader/DistributedRandomIdentitySampler.py new file mode 100644 index 0000000..1203803 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/DistributedRandomIdentitySampler.py @@ -0,0 +1,90 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from collections import defaultdict +import numpy as np +import copy +import random +from paddle.io import DistributedBatchSampler, Sampler + + +class DistributedRandomIdentitySampler(DistributedBatchSampler): + """ + Randomly sample N identities, then for each identity, + randomly sample K instances, therefore batch size is N*K. + Args: + - data_source (list): list of (img_path, pid, camid). + - num_instances (int): number of instances per identity in a batch. + - batch_size (int): number of examples in a batch. + """ + + def __init__(self, dataset, batch_size, num_instances, drop_last, **args): + self.dataset = dataset + self.batch_size = batch_size + self.num_instances = num_instances + self.drop_last = drop_last + self.num_pids_per_batch = self.batch_size // self.num_instances + self.index_dic = defaultdict(list) + for index, pid in enumerate(self.dataset.labels): + self.index_dic[pid].append(index) + self.pids = list(self.index_dic.keys()) + # estimate number of examples in an epoch + self.length = 0 + for pid in self.pids: + idxs = self.index_dic[pid] + num = len(idxs) + if num < self.num_instances: + num = self.num_instances + self.length += num - num % self.num_instances + + def __iter__(self): + batch_idxs_dict = defaultdict(list) + for pid in self.pids: + idxs = copy.deepcopy(self.index_dic[pid]) + if len(idxs) < self.num_instances: + idxs = np.random.choice( + idxs, size=self.num_instances, replace=True) + random.shuffle(idxs) + batch_idxs = [] + for idx in idxs: + batch_idxs.append(idx) + if len(batch_idxs) == self.num_instances: + batch_idxs_dict[pid].append(batch_idxs) + batch_idxs = [] + avai_pids = copy.deepcopy(self.pids) + final_idxs = [] + while len(avai_pids) >= self.num_pids_per_batch: + selected_pids = random.sample(avai_pids, self.num_pids_per_batch) + for pid in selected_pids: + batch_idxs = batch_idxs_dict[pid].pop(0) + final_idxs.extend(batch_idxs) + if len(batch_idxs_dict[pid]) == 0: + avai_pids.remove(pid) + _sample_iter = iter(final_idxs) + batch_indices = [] + for idx in _sample_iter: + batch_indices.append(idx) + if len(batch_indices) == self.batch_size: + yield batch_indices + batch_indices = [] + if not self.drop_last and len(batch_indices) > 0: + yield batch_indices + + def __len__(self): + if self.drop_last: + return self.length // self.batch_size + else: + return (self.length + self.batch_size - 1) // self.batch_size diff --git a/src/PaddleClas/ppcls/data/dataloader/__init__.py b/src/PaddleClas/ppcls/data/dataloader/__init__.py new file mode 100644 index 0000000..8f81921 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/__init__.py @@ -0,0 +1,9 @@ +from ppcls.data.dataloader.imagenet_dataset import ImageNetDataset +from ppcls.data.dataloader.multilabel_dataset import MultiLabelDataset +from ppcls.data.dataloader.common_dataset import create_operators +from ppcls.data.dataloader.vehicle_dataset import CompCars, VeriWild +from ppcls.data.dataloader.logo_dataset import LogoDataset +from ppcls.data.dataloader.icartoon_dataset import ICartoonDataset +from ppcls.data.dataloader.mix_dataset import MixDataset +from ppcls.data.dataloader.mix_sampler import MixSampler +from ppcls.data.dataloader.pk_sampler import PKSampler diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/DistributedRandomIdentitySampler.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/DistributedRandomIdentitySampler.cpython-39.pyc new file mode 100644 index 0000000..297a252 Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/DistributedRandomIdentitySampler.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..94af5ef Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/common_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/common_dataset.cpython-39.pyc new file mode 100644 index 0000000..a35db70 Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/common_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/icartoon_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/icartoon_dataset.cpython-39.pyc new file mode 100644 index 0000000..4ce7f8f Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/icartoon_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/imagenet_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/imagenet_dataset.cpython-39.pyc new file mode 100644 index 0000000..669c776 Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/imagenet_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/logo_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/logo_dataset.cpython-39.pyc new file mode 100644 index 0000000..4044dcd Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/logo_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/mix_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/mix_dataset.cpython-39.pyc new file mode 100644 index 0000000..cb07e0a Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/mix_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/mix_sampler.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/mix_sampler.cpython-39.pyc new file mode 100644 index 0000000..06d9c7f Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/mix_sampler.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/multilabel_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/multilabel_dataset.cpython-39.pyc new file mode 100644 index 0000000..7d7b90f Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/multilabel_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/pk_sampler.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/pk_sampler.cpython-39.pyc new file mode 100644 index 0000000..70d4598 Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/pk_sampler.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/__pycache__/vehicle_dataset.cpython-39.pyc b/src/PaddleClas/ppcls/data/dataloader/__pycache__/vehicle_dataset.cpython-39.pyc new file mode 100644 index 0000000..fbc8c11 Binary files /dev/null and b/src/PaddleClas/ppcls/data/dataloader/__pycache__/vehicle_dataset.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/dataloader/common_dataset.py b/src/PaddleClas/ppcls/data/dataloader/common_dataset.py new file mode 100644 index 0000000..b7b03d8 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/common_dataset.py @@ -0,0 +1,84 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import numpy as np + +from paddle.io import Dataset +import cv2 + +from ppcls.data import preprocess +from ppcls.data.preprocess import transform +from ppcls.utils import logger + + +def create_operators(params): + """ + create operators based on the config + Args: + params(list): a dict list, used to create some operators + """ + assert isinstance(params, list), ('operator config should be a list') + ops = [] + for operator in params: + assert isinstance(operator, + dict) and len(operator) == 1, "yaml format error" + op_name = list(operator)[0] + param = {} if operator[op_name] is None else operator[op_name] + op = getattr(preprocess, op_name)(**param) + ops.append(op) + + return ops + + +class CommonDataset(Dataset): + def __init__( + self, + image_root, + cls_label_path, + transform_ops=None, ): + self._img_root = image_root + self._cls_path = cls_label_path + if transform_ops: + self._transform_ops = create_operators(transform_ops) + + self.images = [] + self.labels = [] + self._load_anno() + + def _load_anno(self): + pass + + def __getitem__(self, idx): + try: + with open(self.images[idx], 'rb') as f: + img = f.read() + if self._transform_ops: + img = transform(img, self._transform_ops) + img = img.transpose((2, 0, 1)) + return (img, self.labels[idx]) + + except Exception as ex: + logger.error("Exception occured when parse line: {} with msg: {}". + format(self.images[idx], ex)) + rnd_idx = np.random.randint(self.__len__()) + return self.__getitem__(rnd_idx) + + def __len__(self): + return len(self.images) + + @property + def class_num(self): + return len(set(self.labels)) diff --git a/src/PaddleClas/ppcls/data/dataloader/dali.py b/src/PaddleClas/ppcls/data/dataloader/dali.py new file mode 100644 index 0000000..a15c231 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/dali.py @@ -0,0 +1,319 @@ +# Copyright (c) 2021 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 __future__ import division + +import copy +import os + +import numpy as np +import nvidia.dali.ops as ops +import nvidia.dali.types as types +import paddle +from nvidia.dali import fn +from nvidia.dali.pipeline import Pipeline +from nvidia.dali.plugin.base_iterator import LastBatchPolicy +from nvidia.dali.plugin.paddle import DALIGenericIterator + + +class HybridTrainPipe(Pipeline): + def __init__(self, + file_root, + file_list, + batch_size, + resize_shorter, + crop, + min_area, + lower, + upper, + interp, + mean, + std, + device_id, + shard_id=0, + num_shards=1, + random_shuffle=True, + num_threads=4, + seed=42, + pad_output=False, + output_dtype=types.FLOAT, + dataset='Train'): + super(HybridTrainPipe, self).__init__( + batch_size, num_threads, device_id, seed=seed) + self.input = ops.readers.File( + file_root=file_root, + file_list=file_list, + shard_id=shard_id, + num_shards=num_shards, + random_shuffle=random_shuffle) + # set internal nvJPEG buffers size to handle full-sized ImageNet images + # without additional reallocations + device_memory_padding = 211025920 + host_memory_padding = 140544512 + self.decode = ops.decoders.ImageRandomCrop( + device='mixed', + output_type=types.DALIImageType.RGB, + device_memory_padding=device_memory_padding, + host_memory_padding=host_memory_padding, + random_aspect_ratio=[lower, upper], + random_area=[min_area, 1.0], + num_attempts=100) + self.res = ops.Resize( + device='gpu', resize_x=crop, resize_y=crop, interp_type=interp) + self.cmnp = ops.CropMirrorNormalize( + device="gpu", + dtype=output_dtype, + output_layout='CHW', + crop=(crop, crop), + mean=mean, + std=std, + pad_output=pad_output) + self.coin = ops.random.CoinFlip(probability=0.5) + self.to_int64 = ops.Cast(dtype=types.DALIDataType.INT64, device="gpu") + + def define_graph(self): + rng = self.coin() + jpegs, labels = self.input(name="Reader") + images = self.decode(jpegs) + images = self.res(images) + output = self.cmnp(images.gpu(), mirror=rng) + return [output, self.to_int64(labels.gpu())] + + def __len__(self): + return self.epoch_size("Reader") + + +class HybridValPipe(Pipeline): + def __init__(self, + file_root, + file_list, + batch_size, + resize_shorter, + crop, + interp, + mean, + std, + device_id, + shard_id=0, + num_shards=1, + random_shuffle=False, + num_threads=4, + seed=42, + pad_output=False, + output_dtype=types.FLOAT): + super(HybridValPipe, self).__init__( + batch_size, num_threads, device_id, seed=seed) + self.input = ops.readers.File( + file_root=file_root, + file_list=file_list, + shard_id=shard_id, + num_shards=num_shards, + random_shuffle=random_shuffle) + self.decode = ops.decoders.Image(device="mixed") + self.res = ops.Resize( + device="gpu", resize_shorter=resize_shorter, interp_type=interp) + self.cmnp = ops.CropMirrorNormalize( + device="gpu", + dtype=output_dtype, + output_layout='CHW', + crop=(crop, crop), + mean=mean, + std=std, + pad_output=pad_output) + self.to_int64 = ops.Cast(dtype=types.DALIDataType.INT64, device="gpu") + + def define_graph(self): + jpegs, labels = self.input(name="Reader") + images = self.decode(jpegs) + images = self.res(images) + output = self.cmnp(images) + return [output, self.to_int64(labels.gpu())] + + def __len__(self): + return self.epoch_size("Reader") + + +def dali_dataloader(config, mode, device, seed=None): + assert "gpu" in device, "gpu training is required for DALI" + device_id = int(device.split(':')[1]) + config_dataloader = config[mode] + seed = 42 if seed is None else seed + ops = [ + list(x.keys())[0] + for x in config_dataloader["dataset"]["transform_ops"] + ] + support_ops_train = [ + "DecodeImage", "NormalizeImage", "RandFlipImage", "RandCropImage" + ] + support_ops_eval = [ + "DecodeImage", "ResizeImage", "CropImage", "NormalizeImage" + ] + + if mode.lower() == 'train': + assert set(ops) == set( + support_ops_train + ), "The supported trasform_ops for train_dataset in dali is : {}".format( + ",".join(support_ops_train)) + else: + assert set(ops) == set( + support_ops_eval + ), "The supported trasform_ops for eval_dataset in dali is : {}".format( + ",".join(support_ops_eval)) + + normalize_ops = [ + op for op in config_dataloader["dataset"]["transform_ops"] + if "NormalizeImage" in op + ][0]["NormalizeImage"] + channel_num = normalize_ops.get("channel_num", 3) + output_dtype = types.FLOAT16 if normalize_ops.get("output_fp16", + False) else types.FLOAT + + env = os.environ + # assert float(env.get('FLAGS_fraction_of_gpu_memory_to_use', 0.92)) < 0.9, \ + # "Please leave enough GPU memory for DALI workspace, e.g., by setting" \ + # " `export FLAGS_fraction_of_gpu_memory_to_use=0.8`" + + gpu_num = paddle.distributed.get_world_size() + + batch_size = config_dataloader["sampler"]["batch_size"] + + file_root = config_dataloader["dataset"]["image_root"] + file_list = config_dataloader["dataset"]["cls_label_path"] + + interp = 1 # settings.interpolation or 1 # default to linear + interp_map = { + 0: types.DALIInterpType.INTERP_NN, # cv2.INTER_NEAREST + 1: types.DALIInterpType.INTERP_LINEAR, # cv2.INTER_LINEAR + 2: types.DALIInterpType.INTERP_CUBIC, # cv2.INTER_CUBIC + 3: types.DALIInterpType. + INTERP_LANCZOS3, # XXX use LANCZOS3 for cv2.INTER_LANCZOS4 + } + + assert interp in interp_map, "interpolation method not supported by DALI" + interp = interp_map[interp] + pad_output = channel_num == 4 + + transforms = { + k: v + for d in config_dataloader["dataset"]["transform_ops"] + for k, v in d.items() + } + + scale = transforms["NormalizeImage"].get("scale", 1.0 / 255) + scale = eval(scale) if isinstance(scale, str) else scale + mean = transforms["NormalizeImage"].get("mean", [0.485, 0.456, 0.406]) + std = transforms["NormalizeImage"].get("std", [0.229, 0.224, 0.225]) + mean = [v / scale for v in mean] + std = [v / scale for v in std] + + sampler_name = config_dataloader["sampler"].get("name", + "DistributedBatchSampler") + assert sampler_name in ["DistributedBatchSampler", "BatchSampler"] + + if mode.lower() == "train": + resize_shorter = 256 + crop = transforms["RandCropImage"]["size"] + scale = transforms["RandCropImage"].get("scale", [0.08, 1.]) + ratio = transforms["RandCropImage"].get("ratio", [3.0 / 4, 4.0 / 3]) + min_area = scale[0] + lower = ratio[0] + upper = ratio[1] + + if 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env: + shard_id = int(env['PADDLE_TRAINER_ID']) + num_shards = int(env['PADDLE_TRAINERS_NUM']) + device_id = int(env['FLAGS_selected_gpus']) + pipe = HybridTrainPipe( + file_root, + file_list, + batch_size, + resize_shorter, + crop, + min_area, + lower, + upper, + interp, + mean, + std, + device_id, + shard_id, + num_shards, + seed=seed + shard_id, + pad_output=pad_output, + output_dtype=output_dtype) + pipe.build() + pipelines = [pipe] + # sample_per_shard = len(pipe) // num_shards + else: + pipe = HybridTrainPipe( + file_root, + file_list, + batch_size, + resize_shorter, + crop, + min_area, + lower, + upper, + interp, + mean, + std, + device_id=device_id, + shard_id=0, + num_shards=1, + seed=seed, + pad_output=pad_output, + output_dtype=output_dtype) + pipe.build() + pipelines = [pipe] + # sample_per_shard = len(pipelines[0]) + return DALIGenericIterator( + pipelines, ['data', 'label'], reader_name='Reader') + else: + resize_shorter = transforms["ResizeImage"].get("resize_short", 256) + crop = transforms["CropImage"]["size"] + if 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env and sampler_name == "DistributedBatchSampler": + shard_id = int(env['PADDLE_TRAINER_ID']) + num_shards = int(env['PADDLE_TRAINERS_NUM']) + device_id = int(env['FLAGS_selected_gpus']) + + pipe = HybridValPipe( + file_root, + file_list, + batch_size, + resize_shorter, + crop, + interp, + mean, + std, + device_id=device_id, + shard_id=shard_id, + num_shards=num_shards, + pad_output=pad_output, + output_dtype=output_dtype) + else: + pipe = HybridValPipe( + file_root, + file_list, + batch_size, + resize_shorter, + crop, + interp, + mean, + std, + device_id=device_id, + pad_output=pad_output, + output_dtype=output_dtype) + pipe.build() + return DALIGenericIterator( + [pipe], ['data', 'label'], reader_name="Reader") diff --git a/src/PaddleClas/ppcls/data/dataloader/icartoon_dataset.py b/src/PaddleClas/ppcls/data/dataloader/icartoon_dataset.py new file mode 100644 index 0000000..18e3b4b --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/icartoon_dataset.py @@ -0,0 +1,36 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import numpy as np +import os + +from .common_dataset import CommonDataset + + +class ICartoonDataset(CommonDataset): + def _load_anno(self, seed=None): + assert os.path.exists(self._cls_path) + assert os.path.exists(self._img_root) + self.images = [] + self.labels = [] + + with open(self._cls_path) as fd: + lines = fd.readlines() + for l in lines: + l = l.strip().split("\t") + self.images.append(os.path.join(self._img_root, l[0])) + self.labels.append(np.int64(l[1])) + assert os.path.exists(self.images[-1]) diff --git a/src/PaddleClas/ppcls/data/dataloader/imagenet_dataset.py b/src/PaddleClas/ppcls/data/dataloader/imagenet_dataset.py new file mode 100644 index 0000000..1166ab3 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/imagenet_dataset.py @@ -0,0 +1,38 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import numpy as np +import os + +from .common_dataset import CommonDataset + + +class ImageNetDataset(CommonDataset): + def _load_anno(self, seed=None): + assert os.path.exists(self._cls_path) + assert os.path.exists(self._img_root) + self.images = [] + self.labels = [] + + with open(self._cls_path) as fd: + lines = fd.readlines() + if seed is not None: + np.random.RandomState(seed).shuffle(lines) + for l in lines: + l = l.strip().split(" ") + self.images.append(os.path.join(self._img_root, l[0])) + self.labels.append(np.int64(l[1])) + assert os.path.exists(self.images[-1]) diff --git a/src/PaddleClas/ppcls/data/dataloader/logo_dataset.py b/src/PaddleClas/ppcls/data/dataloader/logo_dataset.py new file mode 100644 index 0000000..132ead9 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/logo_dataset.py @@ -0,0 +1,46 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import io +import tarfile +import numpy as np +from PIL import Image #all use default backend + +import paddle +from paddle.io import Dataset +import pickle +import os +import cv2 +import random + +from .common_dataset import CommonDataset + + +class LogoDataset(CommonDataset): + def _load_anno(self): + assert os.path.exists(self._cls_path) + assert os.path.exists(self._img_root) + self.images = [] + self.labels = [] + with open(self._cls_path) as fd: + lines = fd.readlines() + for l in lines: + l = l.strip().split("\t") + if l[0] == 'image_id': + continue + self.images.append(os.path.join(self._img_root, l[3])) + self.labels.append(np.int64(l[1]) - 1) + assert os.path.exists(self.images[-1]) diff --git a/src/PaddleClas/ppcls/data/dataloader/mix_dataset.py b/src/PaddleClas/ppcls/data/dataloader/mix_dataset.py new file mode 100644 index 0000000..cbf4b40 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/mix_dataset.py @@ -0,0 +1,49 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import numpy as np +import os + +from paddle.io import Dataset +from .. import dataloader + + +class MixDataset(Dataset): + def __init__(self, datasets_config): + super().__init__() + self.dataset_list = [] + start_idx = 0 + end_idx = 0 + for config_i in datasets_config: + dataset_name = config_i.pop('name') + dataset = getattr(dataloader, dataset_name)(**config_i) + end_idx += len(dataset) + self.dataset_list.append([end_idx, start_idx, dataset]) + start_idx = end_idx + + self.length = end_idx + + def __getitem__(self, idx): + for dataset_i in self.dataset_list: + if dataset_i[0] > idx: + dataset_i_idx = idx - dataset_i[1] + return dataset_i[2][dataset_i_idx] + + def __len__(self): + return self.length + + def get_dataset_list(self): + return self.dataset_list diff --git a/src/PaddleClas/ppcls/data/dataloader/mix_sampler.py b/src/PaddleClas/ppcls/data/dataloader/mix_sampler.py new file mode 100644 index 0000000..2df3109 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/mix_sampler.py @@ -0,0 +1,79 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division + +from paddle.io import DistributedBatchSampler, Sampler + +from ppcls.utils import logger +from ppcls.data.dataloader.mix_dataset import MixDataset +from ppcls.data import dataloader + + +class MixSampler(DistributedBatchSampler): + def __init__(self, dataset, batch_size, sample_configs, iter_per_epoch): + super().__init__(dataset, batch_size) + assert isinstance(dataset, + MixDataset), "MixSampler only support MixDataset" + self.sampler_list = [] + self.batch_size = batch_size + self.start_list = [] + self.length = iter_per_epoch + dataset_list = dataset.get_dataset_list() + batch_size_left = self.batch_size + self.iter_list = [] + for i, config_i in enumerate(sample_configs): + self.start_list.append(dataset_list[i][1]) + sample_method = config_i.pop("name") + ratio_i = config_i.pop("ratio") + if i < len(sample_configs) - 1: + batch_size_i = int(self.batch_size * ratio_i) + batch_size_left -= batch_size_i + else: + batch_size_i = batch_size_left + assert batch_size_i <= len(dataset_list[i][2]) + config_i["batch_size"] = batch_size_i + if sample_method == "DistributedBatchSampler": + sampler_i = DistributedBatchSampler(dataset_list[i][2], + **config_i) + else: + sampler_i = getattr(dataloader, sample_method)( + dataset_list[i][2], **config_i) + self.sampler_list.append(sampler_i) + self.iter_list.append(iter(sampler_i)) + self.length += len(dataset_list[i][2]) * ratio_i + self.iter_counter = 0 + + def __iter__(self): + while self.iter_counter < self.length: + batch = [] + for i, iter_i in enumerate(self.iter_list): + batch_i = next(iter_i, None) + if batch_i is None: + iter_i = iter(self.sampler_list[i]) + self.iter_list[i] = iter_i + batch_i = next(iter_i, None) + assert batch_i is not None, "dataset {} return None".format( + i) + batch += [idx + self.start_list[i] for idx in batch_i] + if len(batch) == self.batch_size: + self.iter_counter += 1 + yield batch + else: + logger.info("Some dataset reaches end") + self.iter_counter = 0 + + def __len__(self): + return self.length diff --git a/src/PaddleClas/ppcls/data/dataloader/multilabel_dataset.py b/src/PaddleClas/ppcls/data/dataloader/multilabel_dataset.py new file mode 100644 index 0000000..2c1ed77 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/multilabel_dataset.py @@ -0,0 +1,59 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import numpy as np +import os +import cv2 + +from ppcls.data.preprocess import transform +from ppcls.utils import logger + +from .common_dataset import CommonDataset + + +class MultiLabelDataset(CommonDataset): + def _load_anno(self): + assert os.path.exists(self._cls_path) + assert os.path.exists(self._img_root) + self.images = [] + self.labels = [] + with open(self._cls_path) as fd: + lines = fd.readlines() + for l in lines: + l = l.strip().split("\t") + self.images.append(os.path.join(self._img_root, l[0])) + + labels = l[1].split(',') + labels = [np.int64(i) for i in labels] + + self.labels.append(labels) + assert os.path.exists(self.images[-1]) + + def __getitem__(self, idx): + try: + with open(self.images[idx], 'rb') as f: + img = f.read() + if self._transform_ops: + img = transform(img, self._transform_ops) + img = img.transpose((2, 0, 1)) + label = np.array(self.labels[idx]).astype("float32") + return (img, label) + + except Exception as ex: + logger.error("Exception occured when parse line: {} with msg: {}". + format(self.images[idx], ex)) + rnd_idx = np.random.randint(self.__len__()) + return self.__getitem__(rnd_idx) diff --git a/src/PaddleClas/ppcls/data/dataloader/pk_sampler.py b/src/PaddleClas/ppcls/data/dataloader/pk_sampler.py new file mode 100644 index 0000000..bf563a6 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/pk_sampler.py @@ -0,0 +1,105 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from collections import defaultdict +import numpy as np +import random +from paddle.io import DistributedBatchSampler + +from ppcls.utils import logger + + +class PKSampler(DistributedBatchSampler): + """ + First, randomly sample P identities. + Then for each identity randomly sample K instances. + Therefore batch size is P*K, and the sampler called PKSampler. + Args: + dataset (paddle.io.Dataset): list of (img_path, pid, cam_id). + sample_per_id(int): number of instances per identity in a batch. + batch_size (int): number of examples in a batch. + shuffle(bool): whether to shuffle indices order before generating + batch indices. Default False. + """ + + def __init__(self, + dataset, + batch_size, + sample_per_id, + shuffle=True, + drop_last=True, + sample_method="sample_avg_prob"): + super().__init__( + dataset, batch_size, shuffle=shuffle, drop_last=drop_last) + assert batch_size % sample_per_id == 0, \ + "PKSampler configs error, Sample_per_id must be a divisor of batch_size." + assert hasattr(self.dataset, + "labels"), "Dataset must have labels attribute." + self.sample_per_label = sample_per_id + self.label_dict = defaultdict(list) + self.sample_method = sample_method + for idx, label in enumerate(self.dataset.labels): + self.label_dict[label].append(idx) + self.label_list = list(self.label_dict) + assert len(self.label_list) * self.sample_per_label > self.batch_size, \ + "batch size should be smaller than " + if self.sample_method == "id_avg_prob": + self.prob_list = np.array([1 / len(self.label_list)] * + len(self.label_list)) + elif self.sample_method == "sample_avg_prob": + counter = [] + for label_i in self.label_list: + counter.append(len(self.label_dict[label_i])) + self.prob_list = np.array(counter) / sum(counter) + else: + logger.error( + "PKSampler only support id_avg_prob and sample_avg_prob sample method, " + "but receive {}.".format(self.sample_method)) + diff = np.abs(sum(self.prob_list) - 1) + if diff > 0.00000001: + self.prob_list[-1] = 1 - sum(self.prob_list[:-1]) + if self.prob_list[-1] > 1 or self.prob_list[-1] < 0: + logger.error("PKSampler prob list error") + else: + logger.info( + "PKSampler: sum of prob list not equal to 1, diff is {}, change the last prob".format(diff) + ) + + def __iter__(self): + label_per_batch = self.batch_size // self.sample_per_label + for _ in range(len(self)): + batch_index = [] + batch_label_list = np.random.choice( + self.label_list, + size=label_per_batch, + replace=False, + p=self.prob_list) + for label_i in batch_label_list: + label_i_indexes = self.label_dict[label_i] + if self.sample_per_label <= len(label_i_indexes): + batch_index.extend( + np.random.choice( + label_i_indexes, + size=self.sample_per_label, + replace=False)) + else: + batch_index.extend( + np.random.choice( + label_i_indexes, + size=self.sample_per_label, + replace=True)) + if not self.drop_last or len(batch_index) == self.batch_size: + yield batch_index diff --git a/src/PaddleClas/ppcls/data/dataloader/vehicle_dataset.py b/src/PaddleClas/ppcls/data/dataloader/vehicle_dataset.py new file mode 100644 index 0000000..2981a57 --- /dev/null +++ b/src/PaddleClas/ppcls/data/dataloader/vehicle_dataset.py @@ -0,0 +1,138 @@ +# Copyright (c) 2021 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 __future__ import print_function + +import numpy as np +import paddle +from paddle.io import Dataset +import os +import cv2 + +from ppcls.data import preprocess +from ppcls.data.preprocess import transform +from ppcls.utils import logger +from .common_dataset import create_operators + + +class CompCars(Dataset): + def __init__(self, + image_root, + cls_label_path, + label_root=None, + transform_ops=None, + bbox_crop=False): + self._img_root = image_root + self._cls_path = cls_label_path + self._label_root = label_root + if transform_ops: + self._transform_ops = create_operators(transform_ops) + self._bbox_crop = bbox_crop + self._dtype = paddle.get_default_dtype() + self._load_anno() + + def _load_anno(self): + assert os.path.exists(self._cls_path) + assert os.path.exists(self._img_root) + if self._bbox_crop: + assert os.path.exists(self._label_root) + self.images = [] + self.labels = [] + self.bboxes = [] + with open(self._cls_path) as fd: + lines = fd.readlines() + for l in lines: + l = l.strip().split() + if not self._bbox_crop: + self.images.append(os.path.join(self._img_root, l[0])) + self.labels.append(int(l[1])) + else: + label_path = os.path.join(self._label_root, + l[0].split('.')[0] + '.txt') + assert os.path.exists(label_path) + with open(label_path) as f: + bbox = f.readlines()[-1].strip().split() + bbox = [int(x) for x in bbox] + self.images.append(os.path.join(self._img_root, l[0])) + self.labels.append(int(l[1])) + self.bboxes.append(bbox) + assert os.path.exists(self.images[-1]) + + def __getitem__(self, idx): + img = cv2.imread(self.images[idx]) + img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + if self._bbox_crop: + bbox = self.bboxes[idx] + img = img[bbox[1]:bbox[3], bbox[0]:bbox[2], :] + if self._transform_ops: + img = transform(img, self._transform_ops) + img = img.transpose((2, 0, 1)) + return (img, self.labels[idx]) + + def __len__(self): + return len(self.images) + + @property + def class_num(self): + return len(set(self.labels)) + + +class VeriWild(Dataset): + def __init__( + self, + image_root, + cls_label_path, + transform_ops=None, ): + self._img_root = image_root + self._cls_path = cls_label_path + if transform_ops: + self._transform_ops = create_operators(transform_ops) + self._dtype = paddle.get_default_dtype() + self._load_anno() + + def _load_anno(self): + assert os.path.exists(self._cls_path) + assert os.path.exists(self._img_root) + self.images = [] + self.labels = [] + self.cameras = [] + with open(self._cls_path) as fd: + lines = fd.readlines() + for l in lines: + l = l.strip().split() + self.images.append(os.path.join(self._img_root, l[0])) + self.labels.append(np.int64(l[1])) + self.cameras.append(np.int64(l[2])) + assert os.path.exists(self.images[-1]) + + def __getitem__(self, idx): + try: + with open(self.images[idx], 'rb') as f: + img = f.read() + if self._transform_ops: + img = transform(img, self._transform_ops) + img = img.transpose((2, 0, 1)) + return (img, self.labels[idx], self.cameras[idx]) + except Exception as ex: + logger.error("Exception occured when parse line: {} with msg: {}". + format(self.images[idx], ex)) + rnd_idx = np.random.randint(self.__len__()) + return self.__getitem__(rnd_idx) + + def __len__(self): + return len(self.images) + + @property + def class_num(self): + return len(set(self.labels)) diff --git a/src/PaddleClas/ppcls/data/postprocess/__init__.py b/src/PaddleClas/ppcls/data/postprocess/__init__.py new file mode 100644 index 0000000..831a4da --- /dev/null +++ b/src/PaddleClas/ppcls/data/postprocess/__init__.py @@ -0,0 +1,41 @@ +# 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. +import copy +import importlib + +from . import topk + +from .topk import Topk, MultiLabelTopk + + +def build_postprocess(config): + config = copy.deepcopy(config) + model_name = config.pop("name") + mod = importlib.import_module(__name__) + postprocess_func = getattr(mod, model_name)(**config) + return postprocess_func + + +class DistillationPostProcess(object): + def __init__(self, model_name="Student", key=None, func="Topk", **kargs): + super().__init__() + self.func = eval(func)(**kargs) + self.model_name = model_name + self.key = key + + def __call__(self, x, file_names=None): + x = x[self.model_name] + if self.key is not None: + x = x[self.key] + return self.func(x, file_names=file_names) diff --git a/src/PaddleClas/ppcls/data/postprocess/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/postprocess/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..ff25208 Binary files /dev/null and b/src/PaddleClas/ppcls/data/postprocess/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/postprocess/__pycache__/topk.cpython-39.pyc b/src/PaddleClas/ppcls/data/postprocess/__pycache__/topk.cpython-39.pyc new file mode 100644 index 0000000..a88a23e Binary files /dev/null and b/src/PaddleClas/ppcls/data/postprocess/__pycache__/topk.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/postprocess/topk.py b/src/PaddleClas/ppcls/data/postprocess/topk.py new file mode 100644 index 0000000..9c1371b --- /dev/null +++ b/src/PaddleClas/ppcls/data/postprocess/topk.py @@ -0,0 +1,85 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import os +import numpy as np +import paddle +import paddle.nn.functional as F + + +class Topk(object): + def __init__(self, topk=1, class_id_map_file=None): + assert isinstance(topk, (int, )) + self.class_id_map = self.parse_class_id_map(class_id_map_file) + self.topk = topk + + def parse_class_id_map(self, class_id_map_file): + if class_id_map_file is None: + return None + if not os.path.exists(class_id_map_file): + print( + "Warning: If want to use your own label_dict, please input legal path!\nOtherwise label_names will be empty!" + ) + return None + + try: + class_id_map = {} + with open(class_id_map_file, "r") as fin: + lines = fin.readlines() + for line in lines: + partition = line.split("\n")[0].partition(" ") + class_id_map[int(partition[0])] = str(partition[-1]) + except Exception as ex: + print(ex) + class_id_map = None + return class_id_map + + def __call__(self, x, file_names=None, multilabel=False): + assert isinstance(x, paddle.Tensor) + if file_names is not None: + assert x.shape[0] == len(file_names) + x = F.softmax(x, axis=-1) if not multilabel else F.sigmoid(x) + x = x.numpy() + y = [] + for idx, probs in enumerate(x): + index = probs.argsort(axis=0)[-self.topk:][::-1].astype( + "int32") if not multilabel else np.where( + probs >= 0.5)[0].astype("int32") + clas_id_list = [] + score_list = [] + label_name_list = [] + for i in index: + clas_id_list.append(i.item()) + score_list.append(probs[i].item()) + if self.class_id_map is not None: + label_name_list.append(self.class_id_map[i.item()]) + result = { + "class_ids": clas_id_list, + "scores": np.around( + score_list, decimals=5).tolist(), + } + if file_names is not None: + result["file_name"] = file_names[idx] + if label_name_list is not None: + result["label_names"] = label_name_list + y.append(result) + return y + + +class MultiLabelTopk(Topk): + def __init__(self, topk=1, class_id_map_file=None): + super().__init__() + + def __call__(self, x, file_names=None): + return super().__call__(x, file_names, multilabel=True) diff --git a/src/PaddleClas/ppcls/data/preprocess/__init__.py b/src/PaddleClas/ppcls/data/preprocess/__init__.py new file mode 100644 index 0000000..075ee89 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/__init__.py @@ -0,0 +1,100 @@ +# Copyright (c) 2021 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 ppcls.data.preprocess.ops.autoaugment import ImageNetPolicy as RawImageNetPolicy +from ppcls.data.preprocess.ops.randaugment import RandAugment as RawRandAugment +from ppcls.data.preprocess.ops.timm_autoaugment import RawTimmAutoAugment +from ppcls.data.preprocess.ops.cutout import Cutout + +from ppcls.data.preprocess.ops.hide_and_seek import HideAndSeek +from ppcls.data.preprocess.ops.random_erasing import RandomErasing +from ppcls.data.preprocess.ops.grid import GridMask + +from ppcls.data.preprocess.ops.operators import DecodeImage +from ppcls.data.preprocess.ops.operators import ResizeImage +from ppcls.data.preprocess.ops.operators import CropImage +from ppcls.data.preprocess.ops.operators import RandCropImage +from ppcls.data.preprocess.ops.operators import RandFlipImage +from ppcls.data.preprocess.ops.operators import NormalizeImage +from ppcls.data.preprocess.ops.operators import ToCHWImage +from ppcls.data.preprocess.ops.operators import AugMix + +from ppcls.data.preprocess.batch_ops.batch_operators import MixupOperator, CutmixOperator, OpSampler, FmixOperator + +import numpy as np +from PIL import Image + + +def transform(data, ops=[]): + """ transform """ + for op in ops: + data = op(data) + return data + + +class AutoAugment(RawImageNetPolicy): + """ ImageNetPolicy wrapper to auto fit different img types """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def __call__(self, img): + if not isinstance(img, Image.Image): + img = np.ascontiguousarray(img) + img = Image.fromarray(img) + + img = super().__call__(img) + + if isinstance(img, Image.Image): + img = np.asarray(img) + + return img + + +class RandAugment(RawRandAugment): + """ RandAugment wrapper to auto fit different img types """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def __call__(self, img): + if not isinstance(img, Image.Image): + img = np.ascontiguousarray(img) + img = Image.fromarray(img) + + img = super().__call__(img) + + if isinstance(img, Image.Image): + img = np.asarray(img) + + return img + + +class TimmAutoAugment(RawTimmAutoAugment): + """ TimmAutoAugment wrapper to auto fit different img tyeps. """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def __call__(self, img): + if not isinstance(img, Image.Image): + img = np.ascontiguousarray(img) + img = Image.fromarray(img) + + img = super().__call__(img) + + if isinstance(img, Image.Image): + img = np.asarray(img) + + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..aad9c48 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/batch_ops/__init__.py b/src/PaddleClas/ppcls/data/preprocess/batch_ops/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/batch_ops/__init__.py @@ -0,0 +1 @@ + diff --git a/src/PaddleClas/ppcls/data/preprocess/batch_ops/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/batch_ops/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..b641a17 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/batch_ops/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/batch_ops/__pycache__/batch_operators.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/batch_ops/__pycache__/batch_operators.cpython-39.pyc new file mode 100644 index 0000000..fb04253 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/batch_ops/__pycache__/batch_operators.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/batch_ops/batch_operators.py b/src/PaddleClas/ppcls/data/preprocess/batch_ops/batch_operators.py new file mode 100644 index 0000000..6f0abb8 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/batch_ops/batch_operators.py @@ -0,0 +1,231 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import random + +import numpy as np + +from ppcls.utils import logger +from ppcls.data.preprocess.ops.fmix import sample_mask + + +class BatchOperator(object): + """ BatchOperator """ + + def __init__(self, *args, **kwargs): + pass + + def _unpack(self, batch): + """ _unpack """ + assert isinstance(batch, list), \ + 'batch should be a list filled with tuples (img, label)' + bs = len(batch) + assert bs > 0, 'size of the batch data should > 0' + #imgs, labels = list(zip(*batch)) + imgs = [] + labels = [] + for item in batch: + imgs.append(item[0]) + labels.append(item[1]) + return np.array(imgs), np.array(labels), bs + + def _one_hot(self, targets): + return np.eye(self.class_num, dtype="float32")[targets] + + def _mix_target(self, targets0, targets1, lam): + one_hots0 = self._one_hot(targets0) + one_hots1 = self._one_hot(targets1) + return one_hots0 * lam + one_hots1 * (1 - lam) + + def __call__(self, batch): + return batch + + +class MixupOperator(BatchOperator): + """ Mixup operator + reference: https://arxiv.org/abs/1710.09412 + + """ + + def __init__(self, class_num, alpha: float=1.): + """Build Mixup operator + + Args: + alpha (float, optional): The parameter alpha of mixup. Defaults to 1.. + + Raises: + Exception: The value of parameter is illegal. + """ + if alpha <= 0: + raise Exception( + f"Parameter \"alpha\" of Mixup should be greater than 0. \"alpha\": {alpha}." + ) + if not class_num: + msg = "Please set \"Arch.class_num\" in config if use \"MixupOperator\"." + logger.error(Exception(msg)) + raise Exception(msg) + + self._alpha = alpha + self.class_num = class_num + + def __call__(self, batch): + imgs, labels, bs = self._unpack(batch) + idx = np.random.permutation(bs) + lam = np.random.beta(self._alpha, self._alpha) + imgs = lam * imgs + (1 - lam) * imgs[idx] + targets = self._mix_target(labels, labels[idx], lam) + return list(zip(imgs, targets)) + + +class CutmixOperator(BatchOperator): + """ Cutmix operator + reference: https://arxiv.org/abs/1905.04899 + + """ + + def __init__(self, class_num, alpha=0.2): + """Build Cutmix operator + + Args: + alpha (float, optional): The parameter alpha of cutmix. Defaults to 0.2. + + Raises: + Exception: The value of parameter is illegal. + """ + if alpha <= 0: + raise Exception( + f"Parameter \"alpha\" of Cutmix should be greater than 0. \"alpha\": {alpha}." + ) + if not class_num: + msg = "Please set \"Arch.class_num\" in config if use \"CutmixOperator\"." + logger.error(Exception(msg)) + raise Exception(msg) + + self._alpha = alpha + self.class_num = class_num + + def _rand_bbox(self, size, lam): + """ _rand_bbox """ + w = size[2] + h = size[3] + cut_rat = np.sqrt(1. - lam) + cut_w = int(w * cut_rat) + cut_h = int(h * cut_rat) + + # uniform + cx = np.random.randint(w) + cy = np.random.randint(h) + + bbx1 = np.clip(cx - cut_w // 2, 0, w) + bby1 = np.clip(cy - cut_h // 2, 0, h) + bbx2 = np.clip(cx + cut_w // 2, 0, w) + bby2 = np.clip(cy + cut_h // 2, 0, h) + + return bbx1, bby1, bbx2, bby2 + + def __call__(self, batch): + imgs, labels, bs = self._unpack(batch) + idx = np.random.permutation(bs) + lam = np.random.beta(self._alpha, self._alpha) + + bbx1, bby1, bbx2, bby2 = self._rand_bbox(imgs.shape, lam) + imgs[:, :, bbx1:bbx2, bby1:bby2] = imgs[idx, :, bbx1:bbx2, bby1:bby2] + lam = 1 - (float(bbx2 - bbx1) * (bby2 - bby1) / + (imgs.shape[-2] * imgs.shape[-1])) + targets = self._mix_target(labels, labels[idx], lam) + return list(zip(imgs, targets)) + + +class FmixOperator(BatchOperator): + """ Fmix operator + reference: https://arxiv.org/abs/2002.12047 + + """ + + def __init__(self, + class_num, + alpha=1, + decay_power=3, + max_soft=0., + reformulate=False): + if not class_num: + msg = "Please set \"Arch.class_num\" in config if use \"FmixOperator\"." + logger.error(Exception(msg)) + raise Exception(msg) + + self._alpha = alpha + self._decay_power = decay_power + self._max_soft = max_soft + self._reformulate = reformulate + self.class_num = class_num + + def __call__(self, batch): + imgs, labels, bs = self._unpack(batch) + idx = np.random.permutation(bs) + size = (imgs.shape[2], imgs.shape[3]) + lam, mask = sample_mask(self._alpha, self._decay_power, \ + size, self._max_soft, self._reformulate) + imgs = mask * imgs + (1 - mask) * imgs[idx] + targets = self._mix_target(labels, labels[idx], lam) + return list(zip(imgs, targets)) + + +class OpSampler(object): + """ Sample a operator from """ + + def __init__(self, class_num, **op_dict): + """Build OpSampler + + Raises: + Exception: The parameter \"prob\" of operator(s) are be set error. + """ + if not class_num: + msg = "Please set \"Arch.class_num\" in config if use \"OpSampler\"." + logger.error(Exception(msg)) + raise Exception(msg) + + if len(op_dict) < 1: + msg = f"ConfigWarning: No operator in \"OpSampler\". \"OpSampler\" has been skipped." + logger.warning(msg) + + self.ops = {} + total_prob = 0 + for op_name in op_dict: + param = op_dict[op_name] + if "prob" not in param: + msg = f"ConfigWarning: Parameter \"prob\" should be set when use operator in \"OpSampler\". The operator \"{op_name}\"'s prob has been set \"0\"." + logger.warning(msg) + prob = param.pop("prob", 0) + total_prob += prob + param.update({"class_num": class_num}) + op = eval(op_name)(**param) + self.ops.update({op: prob}) + + if total_prob > 1: + msg = f"ConfigError: The total prob of operators in \"OpSampler\" should be less 1." + logger.error(Exception(msg)) + raise Exception(msg) + + # add "None Op" when total_prob < 1, "None Op" do nothing + self.ops[None] = 1 - total_prob + + def __call__(self, batch): + op = random.choices( + list(self.ops.keys()), weights=list(self.ops.values()), k=1)[0] + # return batch directly when None Op + return op(batch) if op else batch diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__init__.py b/src/PaddleClas/ppcls/data/preprocess/ops/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/__init__.py @@ -0,0 +1 @@ + diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..44a6c65 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/autoaugment.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/autoaugment.cpython-39.pyc new file mode 100644 index 0000000..6bc1a31 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/autoaugment.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/cutout.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/cutout.cpython-39.pyc new file mode 100644 index 0000000..087e231 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/cutout.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/fmix.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/fmix.cpython-39.pyc new file mode 100644 index 0000000..a0d5b32 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/fmix.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/functional.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/functional.cpython-39.pyc new file mode 100644 index 0000000..b8c9e26 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/functional.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/grid.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/grid.cpython-39.pyc new file mode 100644 index 0000000..b45f8b6 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/grid.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/hide_and_seek.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/hide_and_seek.cpython-39.pyc new file mode 100644 index 0000000..3fd0a2d Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/hide_and_seek.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/operators.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/operators.cpython-39.pyc new file mode 100644 index 0000000..5f3acbd Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/operators.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/randaugment.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/randaugment.cpython-39.pyc new file mode 100644 index 0000000..e599957 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/randaugment.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/random_erasing.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/random_erasing.cpython-39.pyc new file mode 100644 index 0000000..a86492f Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/random_erasing.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/timm_autoaugment.cpython-39.pyc b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/timm_autoaugment.cpython-39.pyc new file mode 100644 index 0000000..5f8e988 Binary files /dev/null and b/src/PaddleClas/ppcls/data/preprocess/ops/__pycache__/timm_autoaugment.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/autoaugment.py b/src/PaddleClas/ppcls/data/preprocess/ops/autoaugment.py new file mode 100644 index 0000000..330220a --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/autoaugment.py @@ -0,0 +1,264 @@ +# Copyright (c) 2021 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. + +# This code is based on https://github.com/DeepVoltaire/AutoAugment/blob/master/autoaugment.py + +from PIL import Image, ImageEnhance, ImageOps +import numpy as np +import random + + +class ImageNetPolicy(object): + """ Randomly choose one of the best 24 Sub-policies on ImageNet. + + Example: + >>> policy = ImageNetPolicy() + >>> transformed = policy(image) + + Example as a PyTorch Transform: + >>> transform=transforms.Compose([ + >>> transforms.Resize(256), + >>> ImageNetPolicy(), + >>> transforms.ToTensor()]) + """ + + def __init__(self, fillcolor=(128, 128, 128)): + self.policies = [ + SubPolicy(0.4, "posterize", 8, 0.6, "rotate", 9, fillcolor), + SubPolicy(0.6, "solarize", 5, 0.6, "autocontrast", 5, fillcolor), + SubPolicy(0.8, "equalize", 8, 0.6, "equalize", 3, fillcolor), + SubPolicy(0.6, "posterize", 7, 0.6, "posterize", 6, fillcolor), + SubPolicy(0.4, "equalize", 7, 0.2, "solarize", 4, fillcolor), + SubPolicy(0.4, "equalize", 4, 0.8, "rotate", 8, fillcolor), + SubPolicy(0.6, "solarize", 3, 0.6, "equalize", 7, fillcolor), + SubPolicy(0.8, "posterize", 5, 1.0, "equalize", 2, fillcolor), + SubPolicy(0.2, "rotate", 3, 0.6, "solarize", 8, fillcolor), + SubPolicy(0.6, "equalize", 8, 0.4, "posterize", 6, fillcolor), + SubPolicy(0.8, "rotate", 8, 0.4, "color", 0, fillcolor), + SubPolicy(0.4, "rotate", 9, 0.6, "equalize", 2, fillcolor), + SubPolicy(0.0, "equalize", 7, 0.8, "equalize", 8, fillcolor), + SubPolicy(0.6, "invert", 4, 1.0, "equalize", 8, fillcolor), + SubPolicy(0.6, "color", 4, 1.0, "contrast", 8, fillcolor), + SubPolicy(0.8, "rotate", 8, 1.0, "color", 2, fillcolor), + SubPolicy(0.8, "color", 8, 0.8, "solarize", 7, fillcolor), + SubPolicy(0.4, "sharpness", 7, 0.6, "invert", 8, fillcolor), + SubPolicy(0.6, "shearX", 5, 1.0, "equalize", 9, fillcolor), + SubPolicy(0.4, "color", 0, 0.6, "equalize", 3, fillcolor), + SubPolicy(0.4, "equalize", 7, 0.2, "solarize", 4, fillcolor), + SubPolicy(0.6, "solarize", 5, 0.6, "autocontrast", 5, fillcolor), + SubPolicy(0.6, "invert", 4, 1.0, "equalize", 8, fillcolor), + SubPolicy(0.6, "color", 4, 1.0, "contrast", 8, fillcolor), + SubPolicy(0.8, "equalize", 8, 0.6, "equalize", 3, fillcolor) + ] + + def __call__(self, img, policy_idx=None): + if policy_idx is None or not isinstance(policy_idx, int): + policy_idx = random.randint(0, len(self.policies) - 1) + else: + policy_idx = policy_idx % len(self.policies) + return self.policies[policy_idx](img) + + def __repr__(self): + return "AutoAugment ImageNet Policy" + + +class CIFAR10Policy(object): + """ Randomly choose one of the best 25 Sub-policies on CIFAR10. + + Example: + >>> policy = CIFAR10Policy() + >>> transformed = policy(image) + + Example as a PyTorch Transform: + >>> transform=transforms.Compose([ + >>> transforms.Resize(256), + >>> CIFAR10Policy(), + >>> transforms.ToTensor()]) + """ + + def __init__(self, fillcolor=(128, 128, 128)): + self.policies = [ + SubPolicy(0.1, "invert", 7, 0.2, "contrast", 6, fillcolor), + SubPolicy(0.7, "rotate", 2, 0.3, "translateX", 9, fillcolor), + SubPolicy(0.8, "sharpness", 1, 0.9, "sharpness", 3, fillcolor), + SubPolicy(0.5, "shearY", 8, 0.7, "translateY", 9, fillcolor), + SubPolicy(0.5, "autocontrast", 8, 0.9, "equalize", 2, fillcolor), + SubPolicy(0.2, "shearY", 7, 0.3, "posterize", 7, fillcolor), + SubPolicy(0.4, "color", 3, 0.6, "brightness", 7, fillcolor), + SubPolicy(0.3, "sharpness", 9, 0.7, "brightness", 9, fillcolor), + SubPolicy(0.6, "equalize", 5, 0.5, "equalize", 1, fillcolor), + SubPolicy(0.6, "contrast", 7, 0.6, "sharpness", 5, fillcolor), + SubPolicy(0.7, "color", 7, 0.5, "translateX", 8, fillcolor), + SubPolicy(0.3, "equalize", 7, 0.4, "autocontrast", 8, fillcolor), + SubPolicy(0.4, "translateY", 3, 0.2, "sharpness", 6, fillcolor), + SubPolicy(0.9, "brightness", 6, 0.2, "color", 8, fillcolor), + SubPolicy(0.5, "solarize", 2, 0.0, "invert", 3, fillcolor), + SubPolicy(0.2, "equalize", 0, 0.6, "autocontrast", 0, fillcolor), + SubPolicy(0.2, "equalize", 8, 0.8, "equalize", 4, fillcolor), + SubPolicy(0.9, "color", 9, 0.6, "equalize", 6, fillcolor), + SubPolicy(0.8, "autocontrast", 4, 0.2, "solarize", 8, fillcolor), + SubPolicy(0.1, "brightness", 3, 0.7, "color", 0, fillcolor), + SubPolicy(0.4, "solarize", 5, 0.9, "autocontrast", 3, fillcolor), + SubPolicy(0.9, "translateY", 9, 0.7, "translateY", 9, fillcolor), + SubPolicy(0.9, "autocontrast", 2, 0.8, "solarize", 3, fillcolor), + SubPolicy(0.8, "equalize", 8, 0.1, "invert", 3, fillcolor), + SubPolicy(0.7, "translateY", 9, 0.9, "autocontrast", 1, fillcolor) + ] + + def __call__(self, img, policy_idx=None): + if policy_idx is None or not isinstance(policy_idx, int): + policy_idx = random.randint(0, len(self.policies) - 1) + else: + policy_idx = policy_idx % len(self.policies) + return self.policies[policy_idx](img) + + def __repr__(self): + return "AutoAugment CIFAR10 Policy" + + +class SVHNPolicy(object): + """ Randomly choose one of the best 25 Sub-policies on SVHN. + + Example: + >>> policy = SVHNPolicy() + >>> transformed = policy(image) + + Example as a PyTorch Transform: + >>> transform=transforms.Compose([ + >>> transforms.Resize(256), + >>> SVHNPolicy(), + >>> transforms.ToTensor()]) + """ + + def __init__(self, fillcolor=(128, 128, 128)): + self.policies = [ + SubPolicy(0.9, "shearX", 4, 0.2, "invert", 3, fillcolor), + SubPolicy(0.9, "shearY", 8, 0.7, "invert", 5, fillcolor), + SubPolicy(0.6, "equalize", 5, 0.6, "solarize", 6, fillcolor), + SubPolicy(0.9, "invert", 3, 0.6, "equalize", 3, fillcolor), + SubPolicy(0.6, "equalize", 1, 0.9, "rotate", 3, fillcolor), + SubPolicy(0.9, "shearX", 4, 0.8, "autocontrast", 3, fillcolor), + SubPolicy(0.9, "shearY", 8, 0.4, "invert", 5, fillcolor), + SubPolicy(0.9, "shearY", 5, 0.2, "solarize", 6, fillcolor), + SubPolicy(0.9, "invert", 6, 0.8, "autocontrast", 1, fillcolor), + SubPolicy(0.6, "equalize", 3, 0.9, "rotate", 3, fillcolor), + SubPolicy(0.9, "shearX", 4, 0.3, "solarize", 3, fillcolor), + SubPolicy(0.8, "shearY", 8, 0.7, "invert", 4, fillcolor), + SubPolicy(0.9, "equalize", 5, 0.6, "translateY", 6, fillcolor), + SubPolicy(0.9, "invert", 4, 0.6, "equalize", 7, fillcolor), + SubPolicy(0.3, "contrast", 3, 0.8, "rotate", 4, fillcolor), + SubPolicy(0.8, "invert", 5, 0.0, "translateY", 2, fillcolor), + SubPolicy(0.7, "shearY", 6, 0.4, "solarize", 8, fillcolor), + SubPolicy(0.6, "invert", 4, 0.8, "rotate", 4, fillcolor), + SubPolicy( + 0.3, "shearY", 7, 0.9, "translateX", 3, fillcolor), SubPolicy( + 0.1, "shearX", 6, 0.6, "invert", 5, fillcolor), SubPolicy( + 0.7, "solarize", 2, 0.6, "translateY", 7, + fillcolor), SubPolicy(0.8, "shearY", 4, 0.8, "invert", + 8, fillcolor), SubPolicy( + 0.7, "shearX", 9, 0.8, + "translateY", 3, + fillcolor), SubPolicy( + 0.8, "shearY", 5, 0.7, + "autocontrast", 3, + fillcolor), + SubPolicy(0.7, "shearX", 2, 0.1, "invert", 5, fillcolor) + ] + + def __call__(self, img, policy_idx=None): + if policy_idx is None or not isinstance(policy_idx, int): + policy_idx = random.randint(0, len(self.policies) - 1) + else: + policy_idx = policy_idx % len(self.policies) + return self.policies[policy_idx](img) + + def __repr__(self): + return "AutoAugment SVHN Policy" + + +class SubPolicy(object): + def __init__(self, + p1, + operation1, + magnitude_idx1, + p2, + operation2, + magnitude_idx2, + fillcolor=(128, 128, 128)): + ranges = { + "shearX": np.linspace(0, 0.3, 10), + "shearY": np.linspace(0, 0.3, 10), + "translateX": np.linspace(0, 150 / 331, 10), + "translateY": np.linspace(0, 150 / 331, 10), + "rotate": np.linspace(0, 30, 10), + "color": np.linspace(0.0, 0.9, 10), + "posterize": np.round(np.linspace(8, 4, 10), 0).astype(np.int), + "solarize": np.linspace(256, 0, 10), + "contrast": np.linspace(0.0, 0.9, 10), + "sharpness": np.linspace(0.0, 0.9, 10), + "brightness": np.linspace(0.0, 0.9, 10), + "autocontrast": [0] * 10, + "equalize": [0] * 10, + "invert": [0] * 10 + } + + # from https://stackoverflow.com/questions/5252170/specify-image-filling-color-when-rotating-in-python-with-pil-and-setting-expand + def rotate_with_fill(img, magnitude): + rot = img.convert("RGBA").rotate(magnitude) + return Image.composite(rot, + Image.new("RGBA", rot.size, (128, ) * 4), + rot).convert(img.mode) + + func = { + "shearX": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, magnitude * random.choice([-1, 1]), 0, 0, 1, 0), + Image.BICUBIC, fillcolor=fillcolor), + "shearY": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, 0, 0, magnitude * random.choice([-1, 1]), 1, 0), + Image.BICUBIC, fillcolor=fillcolor), + "translateX": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, 0, magnitude * img.size[0] * random.choice([-1, 1]), 0, 1, 0), + fillcolor=fillcolor), + "translateY": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, 0, 0, 0, 1, magnitude * img.size[1] * random.choice([-1, 1])), + fillcolor=fillcolor), + "rotate": lambda img, magnitude: rotate_with_fill(img, magnitude), + # "rotate": lambda img, magnitude: img.rotate(magnitude * random.choice([-1, 1])), + "color": lambda img, magnitude: ImageEnhance.Color(img).enhance(1 + magnitude * random.choice([-1, 1])), + "posterize": lambda img, magnitude: ImageOps.posterize(img, magnitude), + "solarize": lambda img, magnitude: ImageOps.solarize(img, magnitude), + "contrast": lambda img, magnitude: ImageEnhance.Contrast(img).enhance( + 1 + magnitude * random.choice([-1, 1])), + "sharpness": lambda img, magnitude: ImageEnhance.Sharpness(img).enhance( + 1 + magnitude * random.choice([-1, 1])), + "brightness": lambda img, magnitude: ImageEnhance.Brightness(img).enhance( + 1 + magnitude * random.choice([-1, 1])), + "autocontrast": lambda img, magnitude: ImageOps.autocontrast(img), + "equalize": lambda img, magnitude: ImageOps.equalize(img), + "invert": lambda img, magnitude: ImageOps.invert(img) + } + + self.p1 = p1 + self.operation1 = func[operation1] + self.magnitude1 = ranges[operation1][magnitude_idx1] + self.p2 = p2 + self.operation2 = func[operation2] + self.magnitude2 = ranges[operation2][magnitude_idx2] + + def __call__(self, img): + if random.random() < self.p1: + img = self.operation1(img, self.magnitude1) + if random.random() < self.p2: + img = self.operation2(img, self.magnitude2) + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/cutout.py b/src/PaddleClas/ppcls/data/preprocess/ops/cutout.py new file mode 100644 index 0000000..b906e14 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/cutout.py @@ -0,0 +1,41 @@ +# Copyright (c) 2021 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. + +# This code is based on https://github.com/uoguelph-mlrg/Cutout + +import numpy as np +import random + + +class Cutout(object): + def __init__(self, n_holes=1, length=112): + self.n_holes = n_holes + self.length = length + + def __call__(self, img): + """ cutout_image """ + h, w = img.shape[:2] + mask = np.ones((h, w), np.float32) + + for n in range(self.n_holes): + y = np.random.randint(h) + x = np.random.randint(w) + + y1 = np.clip(y - self.length // 2, 0, h) + y2 = np.clip(y + self.length // 2, 0, h) + x1 = np.clip(x - self.length // 2, 0, w) + x2 = np.clip(x + self.length // 2, 0, w) + + img[y1:y2, x1:x2] = 0 + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/fmix.py b/src/PaddleClas/ppcls/data/preprocess/ops/fmix.py new file mode 100644 index 0000000..dc2ef91 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/fmix.py @@ -0,0 +1,217 @@ +# Copyright (c) 2021 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. + +import math +import random + +import numpy as np +from scipy.stats import beta + + +def fftfreqnd(h, w=None, z=None): + """ Get bin values for discrete fourier transform of size (h, w, z) + + :param h: Required, first dimension size + :param w: Optional, second dimension size + :param z: Optional, third dimension size + """ + fz = fx = 0 + fy = np.fft.fftfreq(h) + + if w is not None: + fy = np.expand_dims(fy, -1) + + if w % 2 == 1: + fx = np.fft.fftfreq(w)[:w // 2 + 2] + else: + fx = np.fft.fftfreq(w)[:w // 2 + 1] + + if z is not None: + fy = np.expand_dims(fy, -1) + if z % 2 == 1: + fz = np.fft.fftfreq(z)[:, None] + else: + fz = np.fft.fftfreq(z)[:, None] + + return np.sqrt(fx * fx + fy * fy + fz * fz) + + +def get_spectrum(freqs, decay_power, ch, h, w=0, z=0): + """ Samples a fourier image with given size and frequencies decayed by decay power + + :param freqs: Bin values for the discrete fourier transform + :param decay_power: Decay power for frequency decay prop 1/f**d + :param ch: Number of channels for the resulting mask + :param h: Required, first dimension size + :param w: Optional, second dimension size + :param z: Optional, third dimension size + """ + scale = np.ones(1) / (np.maximum(freqs, np.array([1. / max(w, h, z)])) + **decay_power) + + param_size = [ch] + list(freqs.shape) + [2] + param = np.random.randn(*param_size) + + scale = np.expand_dims(scale, -1)[None, :] + + return scale * param + + +def make_low_freq_image(decay, shape, ch=1): + """ Sample a low frequency image from fourier space + + :param decay_power: Decay power for frequency decay prop 1/f**d + :param shape: Shape of desired mask, list up to 3 dims + :param ch: Number of channels for desired mask + """ + freqs = fftfreqnd(*shape) + spectrum = get_spectrum(freqs, decay, ch, + *shape) #.reshape((1, *shape[:-1], -1)) + spectrum = spectrum[:, 0] + 1j * spectrum[:, 1] + mask = np.real(np.fft.irfftn(spectrum, shape)) + + if len(shape) == 1: + mask = mask[:1, :shape[0]] + if len(shape) == 2: + mask = mask[:1, :shape[0], :shape[1]] + if len(shape) == 3: + mask = mask[:1, :shape[0], :shape[1], :shape[2]] + + mask = mask + mask = (mask - mask.min()) + mask = mask / mask.max() + return mask + + +def sample_lam(alpha, reformulate=False): + """ Sample a lambda from symmetric beta distribution with given alpha + + :param alpha: Alpha value for beta distribution + :param reformulate: If True, uses the reformulation of [1]. + """ + if reformulate: + lam = beta.rvs(alpha + 1, alpha) + else: + lam = beta.rvs(alpha, alpha) + + return lam + + +def binarise_mask(mask, lam, in_shape, max_soft=0.0): + """ Binarises a given low frequency image such that it has mean lambda. + + :param mask: Low frequency image, usually the result of `make_low_freq_image` + :param lam: Mean value of final mask + :param in_shape: Shape of inputs + :param max_soft: Softening value between 0 and 0.5 which smooths hard edges in the mask. + :return: + """ + idx = mask.reshape(-1).argsort()[::-1] + mask = mask.reshape(-1) + num = math.ceil(lam * mask.size) if random.random() > 0.5 else math.floor( + lam * mask.size) + + eff_soft = max_soft + if max_soft > lam or max_soft > (1 - lam): + eff_soft = min(lam, 1 - lam) + + soft = int(mask.size * eff_soft) + num_low = int(num - soft) + num_high = int(num + soft) + + mask[idx[:num_high]] = 1 + mask[idx[num_low:]] = 0 + mask[idx[num_low:num_high]] = np.linspace(1, 0, (num_high - num_low)) + + mask = mask.reshape((1, 1, in_shape[0], in_shape[1])) + return mask + + +def sample_mask(alpha, decay_power, shape, max_soft=0.0, reformulate=False): + """ Samples a mean lambda from beta distribution parametrised by alpha, creates a low frequency image and binarises + it based on this lambda + + :param alpha: Alpha value for beta distribution from which to sample mean of mask + :param decay_power: Decay power for frequency decay prop 1/f**d + :param shape: Shape of desired mask, list up to 3 dims + :param max_soft: Softening value between 0 and 0.5 which smooths hard edges in the mask. + :param reformulate: If True, uses the reformulation of [1]. + """ + if isinstance(shape, int): + shape = (shape, ) + + # Choose lambda + lam = sample_lam(alpha, reformulate) + + # Make mask, get mean / std + mask = make_low_freq_image(decay_power, shape) + mask = binarise_mask(mask, lam, shape, max_soft) + + return float(lam), mask + + +def sample_and_apply(x, + alpha, + decay_power, + shape, + max_soft=0.0, + reformulate=False): + """ + + :param x: Image batch on which to apply fmix of shape [b, c, shape*] + :param alpha: Alpha value for beta distribution from which to sample mean of mask + :param decay_power: Decay power for frequency decay prop 1/f**d + :param shape: Shape of desired mask, list up to 3 dims + :param max_soft: Softening value between 0 and 0.5 which smooths hard edges in the mask. + :param reformulate: If True, uses the reformulation of [1]. + :return: mixed input, permutation indices, lambda value of mix, + """ + lam, mask = sample_mask(alpha, decay_power, shape, max_soft, reformulate) + index = np.random.permutation(x.shape[0]) + + x1, x2 = x * mask, x[index] * (1 - mask) + return x1 + x2, index, lam + + +class FMixBase: + """ FMix augmentation + + Args: + decay_power (float): Decay power for frequency decay prop 1/f**d + alpha (float): Alpha value for beta distribution from which to sample mean of mask + size ([int] | [int, int] | [int, int, int]): Shape of desired mask, list up to 3 dims + max_soft (float): Softening value between 0 and 0.5 which smooths hard edges in the mask. + reformulate (bool): If True, uses the reformulation of [1]. + """ + + def __init__(self, + decay_power=3, + alpha=1, + size=(32, 32), + max_soft=0.0, + reformulate=False): + super().__init__() + self.decay_power = decay_power + self.reformulate = reformulate + self.size = size + self.alpha = alpha + self.max_soft = max_soft + self.index = None + self.lam = None + + def __call__(self, x): + raise NotImplementedError + + def loss(self, *args, **kwargs): + raise NotImplementedError diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/functional.py b/src/PaddleClas/ppcls/data/preprocess/ops/functional.py new file mode 100644 index 0000000..9f1369e --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/functional.py @@ -0,0 +1,138 @@ +# Copyright (c) 2021 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. + +# encoding: utf-8 + +import numpy as np +from PIL import Image, ImageOps, ImageEnhance + + + +def int_parameter(level, maxval): + """Helper function to scale `val` between 0 and maxval . + Args: + level: Level of the operation that will be between [0, `PARAMETER_MAX`]. + maxval: Maximum value that the operation can have. This will be scaled to + level/PARAMETER_MAX. + Returns: + An int that results from scaling `maxval` according to `level`. + """ + return int(level * maxval / 10) + + +def float_parameter(level, maxval): + """Helper function to scale `val` between 0 and maxval. + Args: + level: Level of the operation that will be between [0, `PARAMETER_MAX`]. + maxval: Maximum value that the operation can have. This will be scaled to + level/PARAMETER_MAX. + Returns: + A float that results from scaling `maxval` according to `level`. + """ + return float(level) * maxval / 10. + + +def sample_level(n): + return np.random.uniform(low=0.1, high=n) + + +def autocontrast(pil_img, *args): + return ImageOps.autocontrast(pil_img) + + +def equalize(pil_img, *args): + return ImageOps.equalize(pil_img) + + +def posterize(pil_img, level, *args): + level = int_parameter(sample_level(level), 4) + return ImageOps.posterize(pil_img, 4 - level) + + +def rotate(pil_img, level, *args): + degrees = int_parameter(sample_level(level), 30) + if np.random.uniform() > 0.5: + degrees = -degrees + return pil_img.rotate(degrees, resample=Image.BILINEAR) + + +def solarize(pil_img, level, *args): + level = int_parameter(sample_level(level), 256) + return ImageOps.solarize(pil_img, 256 - level) + + +def shear_x(pil_img, level): + level = float_parameter(sample_level(level), 0.3) + if np.random.uniform() > 0.5: + level = -level + return pil_img.transform(pil_img.size, + Image.AFFINE, (1, level, 0, 0, 1, 0), + resample=Image.BILINEAR) + + +def shear_y(pil_img, level): + level = float_parameter(sample_level(level), 0.3) + if np.random.uniform() > 0.5: + level = -level + return pil_img.transform(pil_img.size, + Image.AFFINE, (1, 0, 0, level, 1, 0), + resample=Image.BILINEAR) + + +def translate_x(pil_img, level): + level = int_parameter(sample_level(level), pil_img.size[0] / 3) + if np.random.random() > 0.5: + level = -level + return pil_img.transform(pil_img.size, + Image.AFFINE, (1, 0, level, 0, 1, 0), + resample=Image.BILINEAR) + + +def translate_y(pil_img, level): + level = int_parameter(sample_level(level), pil_img.size[1] / 3) + if np.random.random() > 0.5: + level = -level + return pil_img.transform(pil_img.size, + Image.AFFINE, (1, 0, 0, 0, 1, level), + resample=Image.BILINEAR) + + +# operation that overlaps with ImageNet-C's test set +def color(pil_img, level, *args): + level = float_parameter(sample_level(level), 1.8) + 0.1 + return ImageEnhance.Color(pil_img).enhance(level) + + +# operation that overlaps with ImageNet-C's test set +def contrast(pil_img, level, *args): + level = float_parameter(sample_level(level), 1.8) + 0.1 + return ImageEnhance.Contrast(pil_img).enhance(level) + + +# operation that overlaps with ImageNet-C's test set +def brightness(pil_img, level, *args): + level = float_parameter(sample_level(level), 1.8) + 0.1 + return ImageEnhance.Brightness(pil_img).enhance(level) + + +# operation that overlaps with ImageNet-C's test set +def sharpness(pil_img, level, *args): + level = float_parameter(sample_level(level), 1.8) + 0.1 + return ImageEnhance.Sharpness(pil_img).enhance(level) + + +augmentations = [ + autocontrast, equalize, posterize, rotate, solarize, shear_x, shear_y, + translate_x, translate_y +] diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/grid.py b/src/PaddleClas/ppcls/data/preprocess/ops/grid.py new file mode 100644 index 0000000..6f0b2dc --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/grid.py @@ -0,0 +1,89 @@ +# Copyright (c) 2021 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. + +# This code is based on https://github.com/akuxcw/GridMask + +import numpy as np +from PIL import Image +import pdb + +# curr +CURR_EPOCH = 0 +# epoch for the prob to be the upper limit +NUM_EPOCHS = 240 + + +class GridMask(object): + def __init__(self, d1=96, d2=224, rotate=1, ratio=0.5, mode=0, prob=1.): + self.d1 = d1 + self.d2 = d2 + self.rotate = rotate + self.ratio = ratio + self.mode = mode + self.st_prob = prob + self.prob = prob + self.last_prob = -1 + + def set_prob(self): + global CURR_EPOCH + global NUM_EPOCHS + self.prob = self.st_prob * min(1, 1.0 * CURR_EPOCH / NUM_EPOCHS) + + def __call__(self, img): + self.set_prob() + if abs(self.last_prob - self.prob) > 1e-10: + global CURR_EPOCH + global NUM_EPOCHS + print( + "self.prob is updated, self.prob={}, CURR_EPOCH: {}, NUM_EPOCHS: {}". + format(self.prob, CURR_EPOCH, NUM_EPOCHS)) + self.last_prob = self.prob + # print("CURR_EPOCH: {}, NUM_EPOCHS: {}, self.prob is set as: {}".format(CURR_EPOCH, NUM_EPOCHS, self.prob) ) + if np.random.rand() > self.prob: + return img + _, h, w = img.shape + hh = int(1.5 * h) + ww = int(1.5 * w) + d = np.random.randint(self.d1, self.d2) + #d = self.d + self.l = int(d * self.ratio + 0.5) + mask = np.ones((hh, ww), np.float32) + st_h = np.random.randint(d) + st_w = np.random.randint(d) + for i in range(-1, hh // d + 1): + s = d * i + st_h + t = s + self.l + s = max(min(s, hh), 0) + t = max(min(t, hh), 0) + mask[s:t, :] *= 0 + for i in range(-1, ww // d + 1): + s = d * i + st_w + t = s + self.l + s = max(min(s, ww), 0) + t = max(min(t, ww), 0) + mask[:, s:t] *= 0 + r = np.random.randint(self.rotate) + mask = Image.fromarray(np.uint8(mask)) + mask = mask.rotate(r) + mask = np.asarray(mask) + mask = mask[(hh - h) // 2:(hh - h) // 2 + h, (ww - w) // 2:(ww - w) // + 2 + w] + + if self.mode == 1: + mask = 1 - mask + + mask = np.expand_dims(mask, axis=0) + img = (img * mask).astype(img.dtype) + + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/hide_and_seek.py b/src/PaddleClas/ppcls/data/preprocess/ops/hide_and_seek.py new file mode 100644 index 0000000..33f25f2 --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/hide_and_seek.py @@ -0,0 +1,44 @@ +# Copyright (c) 2021 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. + +# This code is based on https://github.com/kkanshul/Hide-and-Seek + +import numpy as np +import random + + +class HideAndSeek(object): + def __init__(self): + # possible grid size, 0 means no hiding + self.grid_sizes = [0, 16, 32, 44, 56] + # hiding probability + self.hide_prob = 0.5 + + def __call__(self, img): + # randomly choose one grid size + grid_size = np.random.choice(self.grid_sizes) + + _, h, w = img.shape + + # hide the patches + if grid_size == 0: + return img + for x in range(0, w, grid_size): + for y in range(0, h, grid_size): + x_end = min(w, x + grid_size) + y_end = min(h, y + grid_size) + if (random.random() <= self.hide_prob): + img[:, x:x_end, y:y_end] = 0 + + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/operators.py b/src/PaddleClas/ppcls/data/preprocess/ops/operators.py new file mode 100644 index 0000000..9cdc58b --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/operators.py @@ -0,0 +1,384 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from functools import partial +import six +import math +import random +import cv2 +import numpy as np +from PIL import Image +from paddle.vision.transforms import ColorJitter as RawColorJitter + +from .autoaugment import ImageNetPolicy +from .functional import augmentations +from ppcls.utils import logger + + +class UnifiedResize(object): + def __init__(self, interpolation=None, backend="cv2"): + _cv2_interp_from_str = { + 'nearest': cv2.INTER_NEAREST, + 'bilinear': cv2.INTER_LINEAR, + 'area': cv2.INTER_AREA, + 'bicubic': cv2.INTER_CUBIC, + 'lanczos': cv2.INTER_LANCZOS4 + } + _pil_interp_from_str = { + 'nearest': Image.NEAREST, + 'bilinear': Image.BILINEAR, + 'bicubic': Image.BICUBIC, + 'box': Image.BOX, + 'lanczos': Image.LANCZOS, + 'hamming': Image.HAMMING + } + + def _pil_resize(src, size, resample): + pil_img = Image.fromarray(src) + pil_img = pil_img.resize(size, resample) + return np.asarray(pil_img) + + if backend.lower() == "cv2": + if isinstance(interpolation, str): + interpolation = _cv2_interp_from_str[interpolation.lower()] + # compatible with opencv < version 4.4.0 + elif interpolation is None: + interpolation = cv2.INTER_LINEAR + self.resize_func = partial(cv2.resize, interpolation=interpolation) + elif backend.lower() == "pil": + if isinstance(interpolation, str): + interpolation = _pil_interp_from_str[interpolation.lower()] + self.resize_func = partial(_pil_resize, resample=interpolation) + else: + logger.warning( + f"The backend of Resize only support \"cv2\" or \"PIL\". \"f{backend}\" is unavailable. Use \"cv2\" instead." + ) + self.resize_func = cv2.resize + + def __call__(self, src, size): + return self.resize_func(src, size) + + +class OperatorParamError(ValueError): + """ OperatorParamError + """ + pass + + +class DecodeImage(object): + """ decode image """ + + def __init__(self, to_rgb=True, to_np=False, channel_first=False): + self.to_rgb = to_rgb + self.to_np = to_np # to numpy + self.channel_first = channel_first # only enabled when to_np is True + + def __call__(self, img): + if six.PY2: + assert type(img) is str and len( + img) > 0, "invalid input 'img' in DecodeImage" + else: + assert type(img) is bytes and len( + img) > 0, "invalid input 'img' in DecodeImage" + data = np.frombuffer(img, dtype='uint8') + img = cv2.imdecode(data, 1) + if self.to_rgb: + assert img.shape[2] == 3, 'invalid shape of image[%s]' % ( + img.shape) + img = img[:, :, ::-1] + + if self.channel_first: + img = img.transpose((2, 0, 1)) + + return img + + +class ResizeImage(object): + """ resize image """ + + def __init__(self, + size=None, + resize_short=None, + interpolation=None, + backend="cv2"): + if resize_short is not None and resize_short > 0: + self.resize_short = resize_short + self.w = None + self.h = None + elif size is not None: + self.resize_short = None + self.w = size if type(size) is int else size[0] + self.h = size if type(size) is int else size[1] + else: + raise OperatorParamError("invalid params for ReisizeImage for '\ + 'both 'size' and 'resize_short' are None") + + self._resize_func = UnifiedResize( + interpolation=interpolation, backend=backend) + + def __call__(self, img): + img_h, img_w = img.shape[:2] + if self.resize_short is not None: + percent = float(self.resize_short) / min(img_w, img_h) + w = int(round(img_w * percent)) + h = int(round(img_h * percent)) + else: + w = self.w + h = self.h + return self._resize_func(img, (w, h)) + + +class CropImage(object): + """ crop image """ + + def __init__(self, size): + if type(size) is int: + self.size = (size, size) + else: + self.size = size # (h, w) + + def __call__(self, img): + w, h = self.size + img_h, img_w = img.shape[:2] + w_start = (img_w - w) // 2 + h_start = (img_h - h) // 2 + + w_end = w_start + w + h_end = h_start + h + return img[h_start:h_end, w_start:w_end, :] + + +class RandCropImage(object): + """ random crop image """ + + def __init__(self, + size, + scale=None, + ratio=None, + interpolation=None, + backend="cv2"): + if type(size) is int: + self.size = (size, size) # (h, w) + else: + self.size = size + + self.scale = [0.08, 1.0] if scale is None else scale + self.ratio = [3. / 4., 4. / 3.] if ratio is None else ratio + + self._resize_func = UnifiedResize( + interpolation=interpolation, backend=backend) + + def __call__(self, img): + size = self.size + scale = self.scale + ratio = self.ratio + + aspect_ratio = math.sqrt(random.uniform(*ratio)) + w = 1. * aspect_ratio + h = 1. / aspect_ratio + + img_h, img_w = img.shape[:2] + + bound = min((float(img_w) / img_h) / (w**2), + (float(img_h) / img_w) / (h**2)) + scale_max = min(scale[1], bound) + scale_min = min(scale[0], bound) + + target_area = img_w * img_h * random.uniform(scale_min, scale_max) + target_size = math.sqrt(target_area) + w = int(target_size * w) + h = int(target_size * h) + + i = random.randint(0, img_w - w) + j = random.randint(0, img_h - h) + + img = img[j:j + h, i:i + w, :] + + return self._resize_func(img, size) + + +class RandFlipImage(object): + """ random flip image + flip_code: + 1: Flipped Horizontally + 0: Flipped Vertically + -1: Flipped Horizontally & Vertically + """ + + def __init__(self, flip_code=1): + assert flip_code in [-1, 0, 1 + ], "flip_code should be a value in [-1, 0, 1]" + self.flip_code = flip_code + + def __call__(self, img): + if random.randint(0, 1) == 1: + return cv2.flip(img, self.flip_code) + else: + return img + + +class AutoAugment(object): + def __init__(self): + self.policy = ImageNetPolicy() + + def __call__(self, img): + from PIL import Image + img = np.ascontiguousarray(img) + img = Image.fromarray(img) + img = self.policy(img) + img = np.asarray(img) + + +class NormalizeImage(object): + """ normalize image such as substract mean, divide std + """ + + def __init__(self, + scale=None, + mean=None, + std=None, + order='chw', + output_fp16=False, + channel_num=3): + if isinstance(scale, str): + scale = eval(scale) + assert channel_num in [ + 3, 4 + ], "channel number of input image should be set to 3 or 4." + self.channel_num = channel_num + self.output_dtype = 'float16' if output_fp16 else 'float32' + self.scale = np.float32(scale if scale is not None else 1.0 / 255.0) + self.order = order + mean = mean if mean is not None else [0.485, 0.456, 0.406] + std = std if std is not None else [0.229, 0.224, 0.225] + + shape = (3, 1, 1) if self.order == 'chw' else (1, 1, 3) + self.mean = np.array(mean).reshape(shape).astype('float32') + self.std = np.array(std).reshape(shape).astype('float32') + + def __call__(self, img): + from PIL import Image + if isinstance(img, Image.Image): + img = np.array(img) + + assert isinstance(img, + np.ndarray), "invalid input 'img' in NormalizeImage" + + img = (img.astype('float32') * self.scale - self.mean) / self.std + + if self.channel_num == 4: + img_h = img.shape[1] if self.order == 'chw' else img.shape[0] + img_w = img.shape[2] if self.order == 'chw' else img.shape[1] + pad_zeros = np.zeros( + (1, img_h, img_w)) if self.order == 'chw' else np.zeros( + (img_h, img_w, 1)) + img = (np.concatenate( + (img, pad_zeros), axis=0) + if self.order == 'chw' else np.concatenate( + (img, pad_zeros), axis=2)) + return img.astype(self.output_dtype) + + +class ToCHWImage(object): + """ convert hwc image to chw image + """ + + def __init__(self): + pass + + def __call__(self, img): + from PIL import Image + if isinstance(img, Image.Image): + img = np.array(img) + + return img.transpose((2, 0, 1)) + + +class AugMix(object): + """ Perform AugMix augmentation and compute mixture. + """ + + def __init__(self, + prob=0.5, + aug_prob_coeff=0.1, + mixture_width=3, + mixture_depth=1, + aug_severity=1): + """ + Args: + prob: Probability of taking augmix + aug_prob_coeff: Probability distribution coefficients. + mixture_width: Number of augmentation chains to mix per augmented example. + mixture_depth: Depth of augmentation chains. -1 denotes stochastic depth in [1, 3]' + aug_severity: Severity of underlying augmentation operators (between 1 to 10). + """ + # fmt: off + self.prob = prob + self.aug_prob_coeff = aug_prob_coeff + self.mixture_width = mixture_width + self.mixture_depth = mixture_depth + self.aug_severity = aug_severity + self.augmentations = augmentations + # fmt: on + + def __call__(self, image): + """Perform AugMix augmentations and compute mixture. + Returns: + mixed: Augmented and mixed image. + """ + if random.random() > self.prob: + # Avoid the warning: the given NumPy array is not writeable + return np.asarray(image).copy() + + ws = np.float32( + np.random.dirichlet([self.aug_prob_coeff] * self.mixture_width)) + m = np.float32( + np.random.beta(self.aug_prob_coeff, self.aug_prob_coeff)) + + # image = Image.fromarray(image) + mix = np.zeros(image.shape) + for i in range(self.mixture_width): + image_aug = image.copy() + image_aug = Image.fromarray(image_aug) + depth = self.mixture_depth if self.mixture_depth > 0 else np.random.randint( + 1, 4) + for _ in range(depth): + op = np.random.choice(self.augmentations) + image_aug = op(image_aug, self.aug_severity) + mix += ws[i] * np.asarray(image_aug) + + mixed = (1 - m) * image + m * mix + return mixed.astype(np.uint8) + + +class ColorJitter(RawColorJitter): + """ColorJitter. + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def __call__(self, img): + if not isinstance(img, Image.Image): + img = np.ascontiguousarray(img) + img = Image.fromarray(img) + img = super()._apply_image(img) + if isinstance(img, Image.Image): + img = np.asarray(img) + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/randaugment.py b/src/PaddleClas/ppcls/data/preprocess/ops/randaugment.py new file mode 100644 index 0000000..cca59da --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/randaugment.py @@ -0,0 +1,106 @@ +# Copyright (c) 2021 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. + +# This code is based on https://github.com/heartInsert/randaugment + +from PIL import Image, ImageEnhance, ImageOps +import numpy as np +import random + + +class RandAugment(object): + def __init__(self, num_layers=2, magnitude=5, fillcolor=(128, 128, 128)): + self.num_layers = num_layers + self.magnitude = magnitude + self.max_level = 10 + + abso_level = self.magnitude / self.max_level + self.level_map = { + "shearX": 0.3 * abso_level, + "shearY": 0.3 * abso_level, + "translateX": 150.0 / 331 * abso_level, + "translateY": 150.0 / 331 * abso_level, + "rotate": 30 * abso_level, + "color": 0.9 * abso_level, + "posterize": int(4.0 * abso_level), + "solarize": 256.0 * abso_level, + "contrast": 0.9 * abso_level, + "sharpness": 0.9 * abso_level, + "brightness": 0.9 * abso_level, + "autocontrast": 0, + "equalize": 0, + "invert": 0 + } + + # from https://stackoverflow.com/questions/5252170/ + # specify-image-filling-color-when-rotating-in-python-with-pil-and-setting-expand + def rotate_with_fill(img, magnitude): + rot = img.convert("RGBA").rotate(magnitude) + return Image.composite(rot, + Image.new("RGBA", rot.size, (128, ) * 4), + rot).convert(img.mode) + + rnd_ch_op = random.choice + + self.func = { + "shearX": lambda img, magnitude: img.transform( + img.size, + Image.AFFINE, + (1, magnitude * rnd_ch_op([-1, 1]), 0, 0, 1, 0), + Image.BICUBIC, + fillcolor=fillcolor), + "shearY": lambda img, magnitude: img.transform( + img.size, + Image.AFFINE, + (1, 0, 0, magnitude * rnd_ch_op([-1, 1]), 1, 0), + Image.BICUBIC, + fillcolor=fillcolor), + "translateX": lambda img, magnitude: img.transform( + img.size, + Image.AFFINE, + (1, 0, magnitude * img.size[0] * rnd_ch_op([-1, 1]), 0, 1, 0), + fillcolor=fillcolor), + "translateY": lambda img, magnitude: img.transform( + img.size, + Image.AFFINE, + (1, 0, 0, 0, 1, magnitude * img.size[1] * rnd_ch_op([-1, 1])), + fillcolor=fillcolor), + "rotate": lambda img, magnitude: rotate_with_fill(img, magnitude), + "color": lambda img, magnitude: ImageEnhance.Color(img).enhance( + 1 + magnitude * rnd_ch_op([-1, 1])), + "posterize": lambda img, magnitude: + ImageOps.posterize(img, magnitude), + "solarize": lambda img, magnitude: + ImageOps.solarize(img, magnitude), + "contrast": lambda img, magnitude: + ImageEnhance.Contrast(img).enhance( + 1 + magnitude * rnd_ch_op([-1, 1])), + "sharpness": lambda img, magnitude: + ImageEnhance.Sharpness(img).enhance( + 1 + magnitude * rnd_ch_op([-1, 1])), + "brightness": lambda img, magnitude: + ImageEnhance.Brightness(img).enhance( + 1 + magnitude * rnd_ch_op([-1, 1])), + "autocontrast": lambda img, magnitude: + ImageOps.autocontrast(img), + "equalize": lambda img, magnitude: ImageOps.equalize(img), + "invert": lambda img, magnitude: ImageOps.invert(img) + } + + def __call__(self, img): + avaiable_op_names = list(self.level_map.keys()) + for layer_num in range(self.num_layers): + op_name = np.random.choice(avaiable_op_names) + img = self.func[op_name](img, self.level_map[op_name]) + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/random_erasing.py b/src/PaddleClas/ppcls/data/preprocess/ops/random_erasing.py new file mode 100644 index 0000000..f234abb --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/random_erasing.py @@ -0,0 +1,90 @@ +# Copyright (c) 2021 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. + +#This code is adapted from https://github.com/zhunzhong07/Random-Erasing, and refer to Timm. + +from functools import partial + +import math +import random + +import numpy as np + + +class Pixels(object): + def __init__(self, mode="const", mean=[0., 0., 0.]): + self._mode = mode + self._mean = mean + + def __call__(self, h=224, w=224, c=3): + if self._mode == "rand": + return np.random.normal(size=(1, 1, 3)) + elif self._mode == "pixel": + return np.random.normal(size=(h, w, c)) + elif self._mode == "const": + return self._mean + else: + raise Exception( + "Invalid mode in RandomErasing, only support \"const\", \"rand\", \"pixel\"" + ) + + +class RandomErasing(object): + """RandomErasing. + """ + + def __init__(self, + EPSILON=0.5, + sl=0.02, + sh=0.4, + r1=0.3, + mean=[0., 0., 0.], + attempt=100, + use_log_aspect=False, + mode='const'): + self.EPSILON = eval(EPSILON) if isinstance(EPSILON, str) else EPSILON + self.sl = eval(sl) if isinstance(sl, str) else sl + self.sh = eval(sh) if isinstance(sh, str) else sh + r1 = eval(r1) if isinstance(r1, str) else r1 + self.r1 = (math.log(r1), math.log(1 / r1)) if use_log_aspect else ( + r1, 1 / r1) + self.use_log_aspect = use_log_aspect + self.attempt = attempt + self.get_pixels = Pixels(mode, mean) + + def __call__(self, img): + if random.random() > self.EPSILON: + return img + + for _ in range(self.attempt): + area = img.shape[0] * img.shape[1] + + target_area = random.uniform(self.sl, self.sh) * area + aspect_ratio = random.uniform(*self.r1) + if self.use_log_aspect: + aspect_ratio = math.exp(aspect_ratio) + + h = int(round(math.sqrt(target_area * aspect_ratio))) + w = int(round(math.sqrt(target_area / aspect_ratio))) + + if w < img.shape[1] and h < img.shape[0]: + pixels = self.get_pixels(h, w, img.shape[2]) + x1 = random.randint(0, img.shape[0] - h) + y1 = random.randint(0, img.shape[1] - w) + if img.shape[2] == 3: + img[x1:x1 + h, y1:y1 + w, :] = pixels + else: + img[x1:x1 + h, y1:y1 + w, 0] = pixels[0] + return img + return img diff --git a/src/PaddleClas/ppcls/data/preprocess/ops/timm_autoaugment.py b/src/PaddleClas/ppcls/data/preprocess/ops/timm_autoaugment.py new file mode 100644 index 0000000..dd2994d --- /dev/null +++ b/src/PaddleClas/ppcls/data/preprocess/ops/timm_autoaugment.py @@ -0,0 +1,877 @@ +# Copyright (c) 2021 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. + +# Code was heavily based on https://github.com/rwightman/pytorch-image-models + +import random +import math +import re +from PIL import Image, ImageOps, ImageEnhance, ImageChops +import PIL +import numpy as np + +IMAGENET_DEFAULT_MEAN = (0.485, 0.456, 0.406) + +_PIL_VER = tuple([int(x) for x in PIL.__version__.split('.')[:2]]) + +_FILL = (128, 128, 128) + +# This signifies the max integer that the controller RNN could predict for the +# augmentation scheme. +_MAX_LEVEL = 10. + +_HPARAMS_DEFAULT = dict( + translate_const=250, + img_mean=_FILL, ) + +_RANDOM_INTERPOLATION = (Image.BILINEAR, Image.BICUBIC) + + +def _pil_interp(method): + if method == 'bicubic': + return Image.BICUBIC + elif method == 'lanczos': + return Image.LANCZOS + elif method == 'hamming': + return Image.HAMMING + else: + # default bilinear, do we want to allow nearest? + return Image.BILINEAR + + +def _interpolation(kwargs): + interpolation = kwargs.pop('resample', Image.BILINEAR) + if isinstance(interpolation, (list, tuple)): + return random.choice(interpolation) + else: + return interpolation + + +def _check_args_tf(kwargs): + if 'fillcolor' in kwargs and _PIL_VER < (5, 0): + kwargs.pop('fillcolor') + kwargs['resample'] = _interpolation(kwargs) + + +def shear_x(img, factor, **kwargs): + _check_args_tf(kwargs) + return img.transform(img.size, Image.AFFINE, (1, factor, 0, 0, 1, 0), + **kwargs) + + +def shear_y(img, factor, **kwargs): + _check_args_tf(kwargs) + return img.transform(img.size, Image.AFFINE, (1, 0, 0, factor, 1, 0), + **kwargs) + + +def translate_x_rel(img, pct, **kwargs): + pixels = pct * img.size[0] + _check_args_tf(kwargs) + return img.transform(img.size, Image.AFFINE, (1, 0, pixels, 0, 1, 0), + **kwargs) + + +def translate_y_rel(img, pct, **kwargs): + pixels = pct * img.size[1] + _check_args_tf(kwargs) + return img.transform(img.size, Image.AFFINE, (1, 0, 0, 0, 1, pixels), + **kwargs) + + +def translate_x_abs(img, pixels, **kwargs): + _check_args_tf(kwargs) + return img.transform(img.size, Image.AFFINE, (1, 0, pixels, 0, 1, 0), + **kwargs) + + +def translate_y_abs(img, pixels, **kwargs): + _check_args_tf(kwargs) + return img.transform(img.size, Image.AFFINE, (1, 0, 0, 0, 1, pixels), + **kwargs) + + +def rotate(img, degrees, **kwargs): + _check_args_tf(kwargs) + if _PIL_VER >= (5, 2): + return img.rotate(degrees, **kwargs) + elif _PIL_VER >= (5, 0): + w, h = img.size + post_trans = (0, 0) + rotn_center = (w / 2.0, h / 2.0) + angle = -math.radians(degrees) + matrix = [ + round(math.cos(angle), 15), + round(math.sin(angle), 15), + 0.0, + round(-math.sin(angle), 15), + round(math.cos(angle), 15), + 0.0, + ] + + def transform(x, y, matrix): + (a, b, c, d, e, f) = matrix + return a * x + b * y + c, d * x + e * y + f + + matrix[2], matrix[5] = transform(-rotn_center[0] - post_trans[0], + -rotn_center[1] - post_trans[1], + matrix) + matrix[2] += rotn_center[0] + matrix[5] += rotn_center[1] + return img.transform(img.size, Image.AFFINE, matrix, **kwargs) + else: + return img.rotate(degrees, resample=kwargs['resample']) + + +def auto_contrast(img, **__): + return ImageOps.autocontrast(img) + + +def invert(img, **__): + return ImageOps.invert(img) + + +def equalize(img, **__): + return ImageOps.equalize(img) + + +def solarize(img, thresh, **__): + return ImageOps.solarize(img, thresh) + + +def solarize_add(img, add, thresh=128, **__): + lut = [] + for i in range(256): + if i < thresh: + lut.append(min(255, i + add)) + else: + lut.append(i) + if img.mode in ("L", "RGB"): + if img.mode == "RGB" and len(lut) == 256: + lut = lut + lut + lut + return img.point(lut) + else: + return img + + +def posterize(img, bits_to_keep, **__): + if bits_to_keep >= 8: + return img + return ImageOps.posterize(img, bits_to_keep) + + +def contrast(img, factor, **__): + return ImageEnhance.Contrast(img).enhance(factor) + + +def color(img, factor, **__): + return ImageEnhance.Color(img).enhance(factor) + + +def brightness(img, factor, **__): + return ImageEnhance.Brightness(img).enhance(factor) + + +def sharpness(img, factor, **__): + return ImageEnhance.Sharpness(img).enhance(factor) + + +def _randomly_negate(v): + """With 50% prob, negate the value""" + return -v if random.random() > 0.5 else v + + +def _rotate_level_to_arg(level, _hparams): + # range [-30, 30] + level = (level / _MAX_LEVEL) * 30. + level = _randomly_negate(level) + return level, + + +def _enhance_level_to_arg(level, _hparams): + # range [0.1, 1.9] + return (level / _MAX_LEVEL) * 1.8 + 0.1, + + +def _enhance_increasing_level_to_arg(level, _hparams): + # the 'no change' level is 1.0, moving away from that towards 0. or 2.0 increases the enhancement blend + # range [0.1, 1.9] + level = (level / _MAX_LEVEL) * .9 + level = 1.0 + _randomly_negate(level) + return level, + + +def _shear_level_to_arg(level, _hparams): + # range [-0.3, 0.3] + level = (level / _MAX_LEVEL) * 0.3 + level = _randomly_negate(level) + return level, + + +def _translate_abs_level_to_arg(level, hparams): + translate_const = hparams['translate_const'] + level = (level / _MAX_LEVEL) * float(translate_const) + level = _randomly_negate(level) + return level, + + +def _translate_rel_level_to_arg(level, hparams): + # default range [-0.45, 0.45] + translate_pct = hparams.get('translate_pct', 0.45) + level = (level / _MAX_LEVEL) * translate_pct + level = _randomly_negate(level) + return level, + + +def _posterize_level_to_arg(level, _hparams): + # As per Tensorflow TPU EfficientNet impl + # range [0, 4], 'keep 0 up to 4 MSB of original image' + # intensity/severity of augmentation decreases with level + return int((level / _MAX_LEVEL) * 4), + + +def _posterize_increasing_level_to_arg(level, hparams): + # As per Tensorflow models research and UDA impl + # range [4, 0], 'keep 4 down to 0 MSB of original image', + # intensity/severity of augmentation increases with level + return 4 - _posterize_level_to_arg(level, hparams)[0], + + +def _posterize_original_level_to_arg(level, _hparams): + # As per original AutoAugment paper description + # range [4, 8], 'keep 4 up to 8 MSB of image' + # intensity/severity of augmentation decreases with level + return int((level / _MAX_LEVEL) * 4) + 4, + + +def _solarize_level_to_arg(level, _hparams): + # range [0, 256] + # intensity/severity of augmentation decreases with level + return int((level / _MAX_LEVEL) * 256), + + +def _solarize_increasing_level_to_arg(level, _hparams): + # range [0, 256] + # intensity/severity of augmentation increases with level + return 256 - _solarize_level_to_arg(level, _hparams)[0], + + +def _solarize_add_level_to_arg(level, _hparams): + # range [0, 110] + return int((level / _MAX_LEVEL) * 110), + + +LEVEL_TO_ARG = { + 'AutoContrast': None, + 'Equalize': None, + 'Invert': None, + 'Rotate': _rotate_level_to_arg, + # There are several variations of the posterize level scaling in various Tensorflow/Google repositories/papers + 'Posterize': _posterize_level_to_arg, + 'PosterizeIncreasing': _posterize_increasing_level_to_arg, + 'PosterizeOriginal': _posterize_original_level_to_arg, + 'Solarize': _solarize_level_to_arg, + 'SolarizeIncreasing': _solarize_increasing_level_to_arg, + 'SolarizeAdd': _solarize_add_level_to_arg, + 'Color': _enhance_level_to_arg, + 'ColorIncreasing': _enhance_increasing_level_to_arg, + 'Contrast': _enhance_level_to_arg, + 'ContrastIncreasing': _enhance_increasing_level_to_arg, + 'Brightness': _enhance_level_to_arg, + 'BrightnessIncreasing': _enhance_increasing_level_to_arg, + 'Sharpness': _enhance_level_to_arg, + 'SharpnessIncreasing': _enhance_increasing_level_to_arg, + 'ShearX': _shear_level_to_arg, + 'ShearY': _shear_level_to_arg, + 'TranslateX': _translate_abs_level_to_arg, + 'TranslateY': _translate_abs_level_to_arg, + 'TranslateXRel': _translate_rel_level_to_arg, + 'TranslateYRel': _translate_rel_level_to_arg, +} + +NAME_TO_OP = { + 'AutoContrast': auto_contrast, + 'Equalize': equalize, + 'Invert': invert, + 'Rotate': rotate, + 'Posterize': posterize, + 'PosterizeIncreasing': posterize, + 'PosterizeOriginal': posterize, + 'Solarize': solarize, + 'SolarizeIncreasing': solarize, + 'SolarizeAdd': solarize_add, + 'Color': color, + 'ColorIncreasing': color, + 'Contrast': contrast, + 'ContrastIncreasing': contrast, + 'Brightness': brightness, + 'BrightnessIncreasing': brightness, + 'Sharpness': sharpness, + 'SharpnessIncreasing': sharpness, + 'ShearX': shear_x, + 'ShearY': shear_y, + 'TranslateX': translate_x_abs, + 'TranslateY': translate_y_abs, + 'TranslateXRel': translate_x_rel, + 'TranslateYRel': translate_y_rel, +} + + +class AugmentOp(object): + def __init__(self, name, prob=0.5, magnitude=10, hparams=None): + hparams = hparams or _HPARAMS_DEFAULT + self.aug_fn = NAME_TO_OP[name] + self.level_fn = LEVEL_TO_ARG[name] + self.prob = prob + self.magnitude = magnitude + self.hparams = hparams.copy() + self.kwargs = dict( + fillcolor=hparams['img_mean'] if 'img_mean' in hparams else _FILL, + resample=hparams['interpolation'] + if 'interpolation' in hparams else _RANDOM_INTERPOLATION, ) + + # If magnitude_std is > 0, we introduce some randomness + # in the usually fixed policy and sample magnitude from a normal distribution + # with mean `magnitude` and std-dev of `magnitude_std`. + # NOTE This is my own hack, being tested, not in papers or reference impls. + self.magnitude_std = self.hparams.get('magnitude_std', 0) + + def __call__(self, img): + if self.prob < 1.0 and random.random() > self.prob: + return img + magnitude = self.magnitude + if self.magnitude_std and self.magnitude_std > 0: + magnitude = random.gauss(magnitude, self.magnitude_std) + magnitude = min(_MAX_LEVEL, max(0, magnitude)) # clip to valid range + level_args = self.level_fn( + magnitude, self.hparams) if self.level_fn is not None else tuple() + return self.aug_fn(img, *level_args, **self.kwargs) + + +def auto_augment_policy_v0(hparams): + # ImageNet v0 policy from TPU EfficientNet impl, cannot find a paper reference. + policy = [ + [('Equalize', 0.8, 1), ('ShearY', 0.8, 4)], + [('Color', 0.4, 9), ('Equalize', 0.6, 3)], + [('Color', 0.4, 1), ('Rotate', 0.6, 8)], + [('Solarize', 0.8, 3), ('Equalize', 0.4, 7)], + [('Solarize', 0.4, 2), ('Solarize', 0.6, 2)], + [('Color', 0.2, 0), ('Equalize', 0.8, 8)], + [('Equalize', 0.4, 8), ('SolarizeAdd', 0.8, 3)], + [('ShearX', 0.2, 9), ('Rotate', 0.6, 8)], + [('Color', 0.6, 1), ('Equalize', 1.0, 2)], + [('Invert', 0.4, 9), ('Rotate', 0.6, 0)], + [('Equalize', 1.0, 9), ('ShearY', 0.6, 3)], + [('Color', 0.4, 7), ('Equalize', 0.6, 0)], + [('Posterize', 0.4, 6), ('AutoContrast', 0.4, 7)], + [('Solarize', 0.6, 8), ('Color', 0.6, 9)], + [('Solarize', 0.2, 4), ('Rotate', 0.8, 9)], + [('Rotate', 1.0, 7), ('TranslateYRel', 0.8, 9)], + [('ShearX', 0.0, 0), ('Solarize', 0.8, 4)], + [('ShearY', 0.8, 0), ('Color', 0.6, 4)], + [('Color', 1.0, 0), ('Rotate', 0.6, 2)], + [('Equalize', 0.8, 4), ('Equalize', 0.0, 8)], + [('Equalize', 1.0, 4), ('AutoContrast', 0.6, 2)], + [('ShearY', 0.4, 7), ('SolarizeAdd', 0.6, 7)], + [('Posterize', 0.8, 2), ('Solarize', 0.6, 10) + ], # This results in black image with Tpu posterize + [('Solarize', 0.6, 8), ('Equalize', 0.6, 1)], + [('Color', 0.8, 6), ('Rotate', 0.4, 5)], + ] + pc = [[AugmentOp(*a, hparams=hparams) for a in sp] for sp in policy] + return pc + + +def auto_augment_policy_v0r(hparams): + # ImageNet v0 policy from TPU EfficientNet impl, with variation of Posterize used + # in Google research implementation (number of bits discarded increases with magnitude) + policy = [ + [('Equalize', 0.8, 1), ('ShearY', 0.8, 4)], + [('Color', 0.4, 9), ('Equalize', 0.6, 3)], + [('Color', 0.4, 1), ('Rotate', 0.6, 8)], + [('Solarize', 0.8, 3), ('Equalize', 0.4, 7)], + [('Solarize', 0.4, 2), ('Solarize', 0.6, 2)], + [('Color', 0.2, 0), ('Equalize', 0.8, 8)], + [('Equalize', 0.4, 8), ('SolarizeAdd', 0.8, 3)], + [('ShearX', 0.2, 9), ('Rotate', 0.6, 8)], + [('Color', 0.6, 1), ('Equalize', 1.0, 2)], + [('Invert', 0.4, 9), ('Rotate', 0.6, 0)], + [('Equalize', 1.0, 9), ('ShearY', 0.6, 3)], + [('Color', 0.4, 7), ('Equalize', 0.6, 0)], + [('PosterizeIncreasing', 0.4, 6), ('AutoContrast', 0.4, 7)], + [('Solarize', 0.6, 8), ('Color', 0.6, 9)], + [('Solarize', 0.2, 4), ('Rotate', 0.8, 9)], + [('Rotate', 1.0, 7), ('TranslateYRel', 0.8, 9)], + [('ShearX', 0.0, 0), ('Solarize', 0.8, 4)], + [('ShearY', 0.8, 0), ('Color', 0.6, 4)], + [('Color', 1.0, 0), ('Rotate', 0.6, 2)], + [('Equalize', 0.8, 4), ('Equalize', 0.0, 8)], + [('Equalize', 1.0, 4), ('AutoContrast', 0.6, 2)], + [('ShearY', 0.4, 7), ('SolarizeAdd', 0.6, 7)], + [('PosterizeIncreasing', 0.8, 2), ('Solarize', 0.6, 10)], + [('Solarize', 0.6, 8), ('Equalize', 0.6, 1)], + [('Color', 0.8, 6), ('Rotate', 0.4, 5)], + ] + pc = [[AugmentOp(*a, hparams=hparams) for a in sp] for sp in policy] + return pc + + +def auto_augment_policy_original(hparams): + # ImageNet policy from https://arxiv.org/abs/1805.09501 + policy = [ + [('PosterizeOriginal', 0.4, 8), ('Rotate', 0.6, 9)], + [('Solarize', 0.6, 5), ('AutoContrast', 0.6, 5)], + [('Equalize', 0.8, 8), ('Equalize', 0.6, 3)], + [('PosterizeOriginal', 0.6, 7), ('PosterizeOriginal', 0.6, 6)], + [('Equalize', 0.4, 7), ('Solarize', 0.2, 4)], + [('Equalize', 0.4, 4), ('Rotate', 0.8, 8)], + [('Solarize', 0.6, 3), ('Equalize', 0.6, 7)], + [('PosterizeOriginal', 0.8, 5), ('Equalize', 1.0, 2)], + [('Rotate', 0.2, 3), ('Solarize', 0.6, 8)], + [('Equalize', 0.6, 8), ('PosterizeOriginal', 0.4, 6)], + [('Rotate', 0.8, 8), ('Color', 0.4, 0)], + [('Rotate', 0.4, 9), ('Equalize', 0.6, 2)], + [('Equalize', 0.0, 7), ('Equalize', 0.8, 8)], + [('Invert', 0.6, 4), ('Equalize', 1.0, 8)], + [('Color', 0.6, 4), ('Contrast', 1.0, 8)], + [('Rotate', 0.8, 8), ('Color', 1.0, 2)], + [('Color', 0.8, 8), ('Solarize', 0.8, 7)], + [('Sharpness', 0.4, 7), ('Invert', 0.6, 8)], + [('ShearX', 0.6, 5), ('Equalize', 1.0, 9)], + [('Color', 0.4, 0), ('Equalize', 0.6, 3)], + [('Equalize', 0.4, 7), ('Solarize', 0.2, 4)], + [('Solarize', 0.6, 5), ('AutoContrast', 0.6, 5)], + [('Invert', 0.6, 4), ('Equalize', 1.0, 8)], + [('Color', 0.6, 4), ('Contrast', 1.0, 8)], + [('Equalize', 0.8, 8), ('Equalize', 0.6, 3)], + ] + pc = [[AugmentOp(*a, hparams=hparams) for a in sp] for sp in policy] + return pc + + +def auto_augment_policy_originalr(hparams): + # ImageNet policy from https://arxiv.org/abs/1805.09501 with research posterize variation + policy = [ + [('PosterizeIncreasing', 0.4, 8), ('Rotate', 0.6, 9)], + [('Solarize', 0.6, 5), ('AutoContrast', 0.6, 5)], + [('Equalize', 0.8, 8), ('Equalize', 0.6, 3)], + [('PosterizeIncreasing', 0.6, 7), ('PosterizeIncreasing', 0.6, 6)], + [('Equalize', 0.4, 7), ('Solarize', 0.2, 4)], + [('Equalize', 0.4, 4), ('Rotate', 0.8, 8)], + [('Solarize', 0.6, 3), ('Equalize', 0.6, 7)], + [('PosterizeIncreasing', 0.8, 5), ('Equalize', 1.0, 2)], + [('Rotate', 0.2, 3), ('Solarize', 0.6, 8)], + [('Equalize', 0.6, 8), ('PosterizeIncreasing', 0.4, 6)], + [('Rotate', 0.8, 8), ('Color', 0.4, 0)], + [('Rotate', 0.4, 9), ('Equalize', 0.6, 2)], + [('Equalize', 0.0, 7), ('Equalize', 0.8, 8)], + [('Invert', 0.6, 4), ('Equalize', 1.0, 8)], + [('Color', 0.6, 4), ('Contrast', 1.0, 8)], + [('Rotate', 0.8, 8), ('Color', 1.0, 2)], + [('Color', 0.8, 8), ('Solarize', 0.8, 7)], + [('Sharpness', 0.4, 7), ('Invert', 0.6, 8)], + [('ShearX', 0.6, 5), ('Equalize', 1.0, 9)], + [('Color', 0.4, 0), ('Equalize', 0.6, 3)], + [('Equalize', 0.4, 7), ('Solarize', 0.2, 4)], + [('Solarize', 0.6, 5), ('AutoContrast', 0.6, 5)], + [('Invert', 0.6, 4), ('Equalize', 1.0, 8)], + [('Color', 0.6, 4), ('Contrast', 1.0, 8)], + [('Equalize', 0.8, 8), ('Equalize', 0.6, 3)], + ] + pc = [[AugmentOp(*a, hparams=hparams) for a in sp] for sp in policy] + return pc + + +def auto_augment_policy(name='v0', hparams=None): + hparams = hparams or _HPARAMS_DEFAULT + if name == 'original': + return auto_augment_policy_original(hparams) + elif name == 'originalr': + return auto_augment_policy_originalr(hparams) + elif name == 'v0': + return auto_augment_policy_v0(hparams) + elif name == 'v0r': + return auto_augment_policy_v0r(hparams) + else: + assert False, 'Unknown AA policy (%s)' % name + + +class AutoAugment(object): + def __init__(self, policy): + self.policy = policy + + def __call__(self, img): + sub_policy = random.choice(self.policy) + for op in sub_policy: + img = op(img) + return img + + +def auto_augment_transform(config_str, hparams): + """ + Create a AutoAugment transform + + :param config_str: String defining configuration of auto augmentation. Consists of multiple sections separated by + dashes ('-'). The first section defines the AutoAugment policy (one of 'v0', 'v0r', 'original', 'originalr'). + The remaining sections, not order sepecific determine + 'mstd' - float std deviation of magnitude noise applied + Ex 'original-mstd0.5' results in AutoAugment with original policy, magnitude_std 0.5 + + :param hparams: Other hparams (kwargs) for the AutoAugmentation scheme + + :return: A callable Transform Op + """ + config = config_str.split('-') + policy_name = config[0] + config = config[1:] + for c in config: + cs = re.split(r'(\d.*)', c) + if len(cs) < 2: + continue + key, val = cs[:2] + if key == 'mstd': + # noise param injected via hparams for now + hparams.setdefault('magnitude_std', float(val)) + else: + assert False, 'Unknown AutoAugment config section' + aa_policy = auto_augment_policy(policy_name, hparams=hparams) + return AutoAugment(aa_policy) + + +_RAND_TRANSFORMS = [ + 'AutoContrast', + 'Equalize', + 'Invert', + 'Rotate', + 'Posterize', + 'Solarize', + 'SolarizeAdd', + 'Color', + 'Contrast', + 'Brightness', + 'Sharpness', + 'ShearX', + 'ShearY', + 'TranslateXRel', + 'TranslateYRel', + #'Cutout' # NOTE I've implement this as random erasing separately +] + +_RAND_INCREASING_TRANSFORMS = [ + 'AutoContrast', + 'Equalize', + 'Invert', + 'Rotate', + 'PosterizeIncreasing', + 'SolarizeIncreasing', + 'SolarizeAdd', + 'ColorIncreasing', + 'ContrastIncreasing', + 'BrightnessIncreasing', + 'SharpnessIncreasing', + 'ShearX', + 'ShearY', + 'TranslateXRel', + 'TranslateYRel', + #'Cutout' # NOTE I've implement this as random erasing separately +] + +# These experimental weights are based loosely on the relative improvements mentioned in paper. +# They may not result in increased performance, but could likely be tuned to so. +_RAND_CHOICE_WEIGHTS_0 = { + 'Rotate': 0.3, + 'ShearX': 0.2, + 'ShearY': 0.2, + 'TranslateXRel': 0.1, + 'TranslateYRel': 0.1, + 'Color': .025, + 'Sharpness': 0.025, + 'AutoContrast': 0.025, + 'Solarize': .005, + 'SolarizeAdd': .005, + 'Contrast': .005, + 'Brightness': .005, + 'Equalize': .005, + 'Posterize': 0, + 'Invert': 0, +} + + +def _select_rand_weights(weight_idx=0, transforms=None): + transforms = transforms or _RAND_TRANSFORMS + assert weight_idx == 0 # only one set of weights currently + rand_weights = _RAND_CHOICE_WEIGHTS_0 + probs = [rand_weights[k] for k in transforms] + probs /= np.sum(probs) + return probs + + +def rand_augment_ops(magnitude=10, hparams=None, transforms=None): + hparams = hparams or _HPARAMS_DEFAULT + transforms = transforms or _RAND_TRANSFORMS + return [ + AugmentOp( + name, prob=0.5, magnitude=magnitude, hparams=hparams) + for name in transforms + ] + + +class RandAugment(object): + def __init__(self, ops, num_layers=2, choice_weights=None): + self.ops = ops + self.num_layers = num_layers + self.choice_weights = choice_weights + + def __call__(self, img): + # no replacement when using weighted choice + ops = np.random.choice( + self.ops, + self.num_layers, + replace=self.choice_weights is None, + p=self.choice_weights) + for op in ops: + img = op(img) + return img + + +def rand_augment_transform(config_str, hparams): + """ + Create a RandAugment transform + + :param config_str: String defining configuration of random augmentation. Consists of multiple sections separated by + dashes ('-'). The first section defines the specific variant of rand augment (currently only 'rand'). The remaining + sections, not order sepecific determine + 'm' - integer magnitude of rand augment + 'n' - integer num layers (number of transform ops selected per image) + 'w' - integer probabiliy weight index (index of a set of weights to influence choice of op) + 'mstd' - float std deviation of magnitude noise applied + 'inc' - integer (bool), use augmentations that increase in severity with magnitude (default: 0) + Ex 'rand-m9-n3-mstd0.5' results in RandAugment with magnitude 9, num_layers 3, magnitude_std 0.5 + 'rand-mstd1-w0' results in magnitude_std 1.0, weights 0, default magnitude of 10 and num_layers 2 + + :param hparams: Other hparams (kwargs) for the RandAugmentation scheme + + :return: A callable Transform Op + """ + magnitude = _MAX_LEVEL # default to _MAX_LEVEL for magnitude (currently 10) + num_layers = 2 # default to 2 ops per image + weight_idx = None # default to no probability weights for op choice + transforms = _RAND_TRANSFORMS + config = config_str.split('-') + assert config[0] == 'rand' + config = config[1:] + for c in config: + cs = re.split(r'(\d.*)', c) + if len(cs) < 2: + continue + key, val = cs[:2] + if key == 'mstd': + # noise param injected via hparams for now + hparams.setdefault('magnitude_std', float(val)) + elif key == 'inc': + if bool(val): + transforms = _RAND_INCREASING_TRANSFORMS + elif key == 'm': + magnitude = int(val) + elif key == 'n': + num_layers = int(val) + elif key == 'w': + weight_idx = int(val) + else: + assert False, 'Unknown RandAugment config section' + ra_ops = rand_augment_ops( + magnitude=magnitude, hparams=hparams, transforms=transforms) + choice_weights = None if weight_idx is None else _select_rand_weights( + weight_idx) + return RandAugment(ra_ops, num_layers, choice_weights=choice_weights) + + +_AUGMIX_TRANSFORMS = [ + 'AutoContrast', + 'ColorIncreasing', # not in paper + 'ContrastIncreasing', # not in paper + 'BrightnessIncreasing', # not in paper + 'SharpnessIncreasing', # not in paper + 'Equalize', + 'Rotate', + 'PosterizeIncreasing', + 'SolarizeIncreasing', + 'ShearX', + 'ShearY', + 'TranslateXRel', + 'TranslateYRel', +] + + +def augmix_ops(magnitude=10, hparams=None, transforms=None): + hparams = hparams or _HPARAMS_DEFAULT + transforms = transforms or _AUGMIX_TRANSFORMS + return [ + AugmentOp( + name, prob=1.0, magnitude=magnitude, hparams=hparams) + for name in transforms + ] + + +class AugMixAugment(object): + """ AugMix Transform + Adapted and improved from impl here: https://github.com/google-research/augmix/blob/master/imagenet.py + From paper: 'AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty - + https://arxiv.org/abs/1912.02781 + """ + + def __init__(self, ops, alpha=1., width=3, depth=-1, blended=False): + self.ops = ops + self.alpha = alpha + self.width = width + self.depth = depth + self.blended = blended # blended mode is faster but not well tested + + def _calc_blended_weights(self, ws, m): + ws = ws * m + cump = 1. + rws = [] + for w in ws[::-1]: + alpha = w / cump + cump *= (1 - alpha) + rws.append(alpha) + return np.array(rws[::-1], dtype=np.float32) + + def _apply_blended(self, img, mixing_weights, m): + # This is my first crack and implementing a slightly faster mixed augmentation. Instead + # of accumulating the mix for each chain in a Numpy array and then blending with original, + # it recomputes the blending coefficients and applies one PIL image blend per chain. + # TODO the results appear in the right ballpark but they differ by more than rounding. + img_orig = img.copy() + ws = self._calc_blended_weights(mixing_weights, m) + for w in ws: + depth = self.depth if self.depth > 0 else np.random.randint(1, 4) + ops = np.random.choice(self.ops, depth, replace=True) + img_aug = img_orig # no ops are in-place, deep copy not necessary + for op in ops: + img_aug = op(img_aug) + img = Image.blend(img, img_aug, w) + return img + + def _apply_basic(self, img, mixing_weights, m): + # This is a literal adaptation of the paper/official implementation without normalizations and + # PIL <-> Numpy conversions between every op. It is still quite CPU compute heavy compared to the + # typical augmentation transforms, could use a GPU / Kornia implementation. + img_shape = img.size[0], img.size[1], len(img.getbands()) + mixed = np.zeros(img_shape, dtype=np.float32) + for mw in mixing_weights: + depth = self.depth if self.depth > 0 else np.random.randint(1, 4) + ops = np.random.choice(self.ops, depth, replace=True) + img_aug = img # no ops are in-place, deep copy not necessary + for op in ops: + img_aug = op(img_aug) + mixed += mw * np.asarray(img_aug, dtype=np.float32) + np.clip(mixed, 0, 255., out=mixed) + mixed = Image.fromarray(mixed.astype(np.uint8)) + return Image.blend(img, mixed, m) + + def __call__(self, img): + mixing_weights = np.float32( + np.random.dirichlet([self.alpha] * self.width)) + m = np.float32(np.random.beta(self.alpha, self.alpha)) + if self.blended: + mixed = self._apply_blended(img, mixing_weights, m) + else: + mixed = self._apply_basic(img, mixing_weights, m) + return mixed + + +def augment_and_mix_transform(config_str, hparams): + """ Create AugMix transform + + :param config_str: String defining configuration of random augmentation. Consists of multiple sections separated by + dashes ('-'). The first section defines the specific variant of rand augment (currently only 'rand'). The remaining + sections, not order sepecific determine + 'm' - integer magnitude (severity) of augmentation mix (default: 3) + 'w' - integer width of augmentation chain (default: 3) + 'd' - integer depth of augmentation chain (-1 is random [1, 3], default: -1) + 'b' - integer (bool), blend each branch of chain into end result without a final blend, less CPU (default: 0) + 'mstd' - float std deviation of magnitude noise applied (default: 0) + Ex 'augmix-m5-w4-d2' results in AugMix with severity 5, chain width 4, chain depth 2 + + :param hparams: Other hparams (kwargs) for the Augmentation transforms + + :return: A callable Transform Op + """ + magnitude = 3 + width = 3 + depth = -1 + alpha = 1. + blended = False + config = config_str.split('-') + assert config[0] == 'augmix' + config = config[1:] + for c in config: + cs = re.split(r'(\d.*)', c) + if len(cs) < 2: + continue + key, val = cs[:2] + if key == 'mstd': + # noise param injected via hparams for now + hparams.setdefault('magnitude_std', float(val)) + elif key == 'm': + magnitude = int(val) + elif key == 'w': + width = int(val) + elif key == 'd': + depth = int(val) + elif key == 'a': + alpha = float(val) + elif key == 'b': + blended = bool(val) + else: + assert False, 'Unknown AugMix config section' + ops = augmix_ops(magnitude=magnitude, hparams=hparams) + return AugMixAugment( + ops, alpha=alpha, width=width, depth=depth, blended=blended) + + +class RawTimmAutoAugment(object): + """TimmAutoAugment API for PaddleClas.""" + + def __init__(self, + config_str="rand-m9-mstd0.5-inc1", + interpolation="bicubic", + img_size=224, + mean=IMAGENET_DEFAULT_MEAN): + if isinstance(img_size, (tuple, list)): + img_size_min = min(img_size) + else: + img_size_min = img_size + + aa_params = dict( + translate_const=int(img_size_min * 0.45), + img_mean=tuple([min(255, round(255 * x)) for x in mean]), ) + if interpolation and interpolation != 'random': + aa_params['interpolation'] = _pil_interp(interpolation) + if config_str.startswith('rand'): + self.augment_func = rand_augment_transform(config_str, aa_params) + elif config_str.startswith('augmix'): + aa_params['translate_pct'] = 0.3 + self.augment_func = augment_and_mix_transform(config_str, + aa_params) + elif config_str.startswith('auto'): + self.augment_func = auto_augment_transform(config_str, aa_params) + else: + raise Exception( + "ConfigError: The TimmAutoAugment Op only support RandAugment, AutoAugment, AugMix, and the config_str only starts with \"rand\", \"augmix\", \"auto\"." + ) + + def __call__(self, img): + return self.augment_func(img) diff --git a/src/PaddleClas/ppcls/data/utils/__init__.py b/src/PaddleClas/ppcls/data/utils/__init__.py new file mode 100644 index 0000000..61d5aa2 --- /dev/null +++ b/src/PaddleClas/ppcls/data/utils/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2021 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. \ No newline at end of file diff --git a/src/PaddleClas/ppcls/data/utils/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/data/utils/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..55982e8 Binary files /dev/null and b/src/PaddleClas/ppcls/data/utils/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/utils/__pycache__/get_image_list.cpython-39.pyc b/src/PaddleClas/ppcls/data/utils/__pycache__/get_image_list.cpython-39.pyc new file mode 100644 index 0000000..7a158c4 Binary files /dev/null and b/src/PaddleClas/ppcls/data/utils/__pycache__/get_image_list.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/data/utils/get_image_list.py b/src/PaddleClas/ppcls/data/utils/get_image_list.py new file mode 100644 index 0000000..6f10935 --- /dev/null +++ b/src/PaddleClas/ppcls/data/utils/get_image_list.py @@ -0,0 +1,49 @@ +# 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. + +import os +import argparse +import base64 +import numpy as np + + +def get_image_list(img_file): + imgs_lists = [] + if img_file is None or not os.path.exists(img_file): + raise Exception("not found any img file in {}".format(img_file)) + + img_end = ['jpg', 'png', 'jpeg', 'JPEG', 'JPG', 'bmp'] + if os.path.isfile(img_file) and img_file.split('.')[-1] in img_end: + imgs_lists.append(img_file) + elif os.path.isdir(img_file): + for single_file in os.listdir(img_file): + if single_file.split('.')[-1] in img_end: + imgs_lists.append(os.path.join(img_file, single_file)) + if len(imgs_lists) == 0: + raise Exception("not found any img file in {}".format(img_file)) + imgs_lists = sorted(imgs_lists) + return imgs_lists + + +def get_image_list_from_label_file(image_path, label_file_path): + imgs_lists = [] + gt_labels = [] + with open(label_file_path, "r") as fin: + lines = fin.readlines() + for line in lines: + image_name, label = line.strip("\n").split() + label = int(label) + imgs_lists.append(os.path.join(image_path, image_name)) + gt_labels.append(int(label)) + return imgs_lists, gt_labels diff --git a/src/PaddleClas/ppcls/engine/__init__.py b/src/PaddleClas/ppcls/engine/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/PaddleClas/ppcls/engine/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/engine/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..22fdcbb Binary files /dev/null and b/src/PaddleClas/ppcls/engine/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/__pycache__/engine.cpython-39.pyc b/src/PaddleClas/ppcls/engine/__pycache__/engine.cpython-39.pyc new file mode 100644 index 0000000..3281cbb Binary files /dev/null and b/src/PaddleClas/ppcls/engine/__pycache__/engine.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/engine.py b/src/PaddleClas/ppcls/engine/engine.py new file mode 100644 index 0000000..61d09ff --- /dev/null +++ b/src/PaddleClas/ppcls/engine/engine.py @@ -0,0 +1,465 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +import platform +import paddle +import paddle.distributed as dist +from visualdl import LogWriter +from paddle import nn +import numpy as np +import random + +from ppcls.utils.check import check_gpu +from ppcls.utils.misc import AverageMeter +from ppcls.utils import logger +from ppcls.utils.logger import init_logger +from ppcls.utils.config import print_config +from ppcls.data import build_dataloader +from ppcls.arch import build_model, RecModel, DistillationModel, TheseusLayer +from ppcls.arch import apply_to_static +from ppcls.loss import build_loss +from ppcls.metric import build_metrics +from ppcls.optimizer import build_optimizer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url +from ppcls.utils.save_load import init_model +from ppcls.utils import save_load + +from ppcls.data.utils.get_image_list import get_image_list +from ppcls.data.postprocess import build_postprocess +from ppcls.data import create_operators +from ppcls.engine.train import train_epoch +from ppcls.engine import evaluation +from ppcls.arch.gears.identity_head import IdentityHead + + +class Engine(object): + def __init__(self, config, mode="train"): + assert mode in ["train", "eval", "infer", "export"] + self.mode = mode + self.config = config + self.eval_mode = self.config["Global"].get("eval_mode", + "classification") + if "Head" in self.config["Arch"] or self.config["Arch"].get("is_rec", + False): + self.is_rec = True + else: + self.is_rec = False + + # set seed + seed = self.config["Global"].get("seed", False) + if seed or seed == 0: + assert isinstance(seed, int), "The 'seed' must be a integer!" + paddle.seed(seed) + np.random.seed(seed) + random.seed(seed) + + # init logger + self.output_dir = self.config['Global']['output_dir'] + log_file = os.path.join(self.output_dir, self.config["Arch"]["name"], + f"{mode}.log") + init_logger(name='root', log_file=log_file) + print_config(config) + + # init train_func and eval_func + assert self.eval_mode in ["classification", "retrieval"], logger.error( + "Invalid eval mode: {}".format(self.eval_mode)) + self.train_epoch_func = train_epoch + self.eval_func = getattr(evaluation, self.eval_mode + "_eval") + + self.use_dali = self.config['Global'].get("use_dali", False) + + # for visualdl + self.vdl_writer = None + if self.config['Global'][ + 'use_visualdl'] and mode == "train" and dist.get_rank() == 0: + vdl_writer_path = os.path.join(self.output_dir, "vdl") + if not os.path.exists(vdl_writer_path): + os.makedirs(vdl_writer_path) + self.vdl_writer = LogWriter(logdir=vdl_writer_path) + + # set device + assert self.config["Global"]["device"] in ["cpu", "gpu", "xpu", "npu"] + self.device = paddle.set_device(self.config["Global"]["device"]) + logger.info('train with paddle {} and device {}'.format( + paddle.__version__, self.device)) + + # AMP training + self.amp = True if "AMP" in self.config and self.mode == "train" else False + if self.amp and self.config["AMP"] is not None: + self.scale_loss = self.config["AMP"].get("scale_loss", 1.0) + self.use_dynamic_loss_scaling = self.config["AMP"].get( + "use_dynamic_loss_scaling", False) + else: + self.scale_loss = 1.0 + self.use_dynamic_loss_scaling = False + if self.amp: + AMP_RELATED_FLAGS_SETTING = { + 'FLAGS_cudnn_batchnorm_spatial_persistent': 1, + 'FLAGS_max_inplace_grad_add': 8, + } + paddle.fluid.set_flags(AMP_RELATED_FLAGS_SETTING) + + if "class_num" in config["Global"]: + global_class_num = config["Global"]["class_num"] + if "class_num" not in config["Arch"]: + config["Arch"]["class_num"] = global_class_num + msg = f"The Global.class_num will be deprecated. Please use Arch.class_num instead. Arch.class_num has been set to {global_class_num}." + else: + msg = "The Global.class_num will be deprecated. Please use Arch.class_num instead. The Global.class_num has been ignored." + logger.warning(msg) + #TODO(gaotingquan): support rec + class_num = config["Arch"].get("class_num", None) + self.config["DataLoader"].update({"class_num": class_num}) + # build dataloader + if self.mode == 'train': + self.train_dataloader = build_dataloader( + self.config["DataLoader"], "Train", self.device, self.use_dali) + if self.mode == "eval" or (self.mode == "train" and + self.config["Global"]["eval_during_train"]): + if self.eval_mode == "classification": + self.eval_dataloader = build_dataloader( + self.config["DataLoader"], "Eval", self.device, + self.use_dali) + elif self.eval_mode == "retrieval": + self.gallery_query_dataloader = None + if len(self.config["DataLoader"]["Eval"].keys()) == 1: + key = list(self.config["DataLoader"]["Eval"].keys())[0] + self.gallery_query_dataloader = build_dataloader( + self.config["DataLoader"]["Eval"], key, self.device, + self.use_dali) + else: + self.gallery_dataloader = build_dataloader( + self.config["DataLoader"]["Eval"], "Gallery", + self.device, self.use_dali) + self.query_dataloader = build_dataloader( + self.config["DataLoader"]["Eval"], "Query", + self.device, self.use_dali) + + # build loss + if self.mode == "train": + loss_info = self.config["Loss"]["Train"] + self.train_loss_func = build_loss(loss_info) + if self.mode == "eval" or (self.mode == "train" and + self.config["Global"]["eval_during_train"]): + loss_config = self.config.get("Loss", None) + if loss_config is not None: + loss_config = loss_config.get("Eval") + if loss_config is not None: + self.eval_loss_func = build_loss(loss_config) + else: + self.eval_loss_func = None + else: + self.eval_loss_func = None + + # build metric + if self.mode == 'train': + metric_config = self.config.get("Metric") + if metric_config is not None: + metric_config = metric_config.get("Train") + if metric_config is not None: + if hasattr( + self.train_dataloader, "collate_fn" + ) and self.train_dataloader.collate_fn is not None: + for m_idx, m in enumerate(metric_config): + if "TopkAcc" in m: + msg = f"'TopkAcc' metric can not be used when setting 'batch_transform_ops' in config. The 'TopkAcc' metric has been removed." + logger.warning(msg) + break + metric_config.pop(m_idx) + self.train_metric_func = build_metrics(metric_config) + else: + self.train_metric_func = None + else: + self.train_metric_func = None + + if self.mode == "eval" or (self.mode == "train" and + self.config["Global"]["eval_during_train"]): + metric_config = self.config.get("Metric") + if self.eval_mode == "classification": + if metric_config is not None: + metric_config = metric_config.get("Eval") + if metric_config is not None: + self.eval_metric_func = build_metrics(metric_config) + elif self.eval_mode == "retrieval": + if metric_config is None: + metric_config = [{"name": "Recallk", "topk": (1, 5)}] + else: + metric_config = metric_config["Eval"] + self.eval_metric_func = build_metrics(metric_config) + else: + self.eval_metric_func = None + + # build model + self.model = build_model(self.config) + # set @to_static for benchmark, skip this by default. + apply_to_static(self.config, self.model) + + # load_pretrain + if self.config["Global"]["pretrained_model"] is not None: + if self.config["Global"]["pretrained_model"].startswith("http"): + load_dygraph_pretrain_from_url( + self.model, self.config["Global"]["pretrained_model"]) + else: + load_dygraph_pretrain( + self.model, self.config["Global"]["pretrained_model"]) + + # build optimizer + if self.mode == 'train': + self.optimizer, self.lr_sch = build_optimizer( + self.config["Optimizer"], self.config["Global"]["epochs"], + len(self.train_dataloader), [self.model]) + + # for amp training + if self.amp: + self.scaler = paddle.amp.GradScaler( + init_loss_scaling=self.scale_loss, + use_dynamic_loss_scaling=self.use_dynamic_loss_scaling) + amp_level = self.config['AMP'].get("level", "O1") + if amp_level not in ["O1", "O2"]: + msg = "[Parameter Error]: The optimize level of AMP only support 'O1' and 'O2'. The level has been set 'O1'." + logger.warning(msg) + self.config['AMP']["level"] = "O1" + amp_level = "O1" + self.model, self.optimizer = paddle.amp.decorate( + models=self.model, + optimizers=self.optimizer, + level=amp_level, + save_dtype='float32') + + # for distributed + world_size = dist.get_world_size() + self.config["Global"]["distributed"] = world_size != 1 + if world_size != 4 and self.mode == "train": + msg = f"The training strategy in config files provided by PaddleClas is based on 4 gpus. But the number of gpus is {world_size} in current training. Please modify the stategy (learning rate, batch size and so on) if use config files in PaddleClas to train." + logger.warning(msg) + if self.config["Global"]["distributed"]: + dist.init_parallel_env() + self.model = paddle.DataParallel(self.model) + + # build postprocess for infer + if self.mode == 'infer': + self.preprocess_func = create_operators(self.config["Infer"][ + "transforms"]) + self.postprocess_func = build_postprocess(self.config["Infer"][ + "PostProcess"]) + + def train(self): + assert self.mode == "train" + print_batch_step = self.config['Global']['print_batch_step'] + save_interval = self.config["Global"]["save_interval"] + best_metric = { + "metric": 0.0, + "epoch": 0, + } + # key: + # val: metrics list word + self.output_info = dict() + self.time_info = { + "batch_cost": AverageMeter( + "batch_cost", '.5f', postfix=" s,"), + "reader_cost": AverageMeter( + "reader_cost", ".5f", postfix=" s,"), + } + # global iter counter + self.global_step = 0 + + if self.config["Global"]["checkpoints"] is not None: + metric_info = init_model(self.config["Global"], self.model, + self.optimizer) + if metric_info is not None: + best_metric.update(metric_info) + + self.max_iter = len(self.train_dataloader) - 1 if platform.system( + ) == "Windows" else len(self.train_dataloader) + for epoch_id in range(best_metric["epoch"] + 1, + self.config["Global"]["epochs"] + 1): + acc = 0.0 + # for one epoch train + self.train_epoch_func(self, epoch_id, print_batch_step) + + if self.use_dali: + self.train_dataloader.reset() + metric_msg = ", ".join([ + "{}: {:.5f}".format(key, self.output_info[key].avg) + for key in self.output_info + ]) + logger.info("[Train][Epoch {}/{}][Avg]{}".format( + epoch_id, self.config["Global"]["epochs"], metric_msg)) + self.output_info.clear() + + # eval model and save model if possible + if self.config["Global"][ + "eval_during_train"] and epoch_id % self.config["Global"][ + "eval_interval"] == 0: + acc = self.eval(epoch_id) + if acc > best_metric["metric"]: + best_metric["metric"] = acc + best_metric["epoch"] = epoch_id + save_load.save_model( + self.model, + self.optimizer, + best_metric, + self.output_dir, + model_name=self.config["Arch"]["name"], + prefix="best_model") + logger.info("[Eval][Epoch {}][best metric: {}]".format( + epoch_id, best_metric["metric"])) + logger.scaler( + name="eval_acc", + value=acc, + step=epoch_id, + writer=self.vdl_writer) + + self.model.train() + + # save model + if epoch_id % save_interval == 0: + save_load.save_model( + self.model, + self.optimizer, {"metric": acc, + "epoch": epoch_id}, + self.output_dir, + model_name=self.config["Arch"]["name"], + prefix="epoch_{}".format(epoch_id)) + # save the latest model + save_load.save_model( + self.model, + self.optimizer, {"metric": acc, + "epoch": epoch_id}, + self.output_dir, + model_name=self.config["Arch"]["name"], + prefix="latest") + + if self.vdl_writer is not None: + self.vdl_writer.close() + + @paddle.no_grad() + def eval(self, epoch_id=0): + assert self.mode in ["train", "eval"] + self.model.eval() + eval_result = self.eval_func(self, epoch_id) + self.model.train() + return eval_result + + @paddle.no_grad() + def infer(self): + assert self.mode == "infer" and self.eval_mode == "classification" + total_trainer = dist.get_world_size() + local_rank = dist.get_rank() + image_list = get_image_list(self.config["Infer"]["infer_imgs"]) + # data split + image_list = image_list[local_rank::total_trainer] + + batch_size = self.config["Infer"]["batch_size"] + self.model.eval() + batch_data = [] + image_file_list = [] + for idx, image_file in enumerate(image_list): + with open(image_file, 'rb') as f: + x = f.read() + for process in self.preprocess_func: + x = process(x) + batch_data.append(x) + image_file_list.append(image_file) + if len(batch_data) >= batch_size or idx == len(image_list) - 1: + batch_tensor = paddle.to_tensor(batch_data) + out = self.model(batch_tensor) + if isinstance(out, list): + out = out[0] + if isinstance(out, dict) and "logits" in out: + out = out["logits"] + if isinstance(out, dict) and "output" in out: + out = out["output"] + result = self.postprocess_func(out, image_file_list) + print(result) + batch_data.clear() + image_file_list.clear() + + def export(self): + assert self.mode == "export" + use_multilabel = self.config["Global"].get("use_multilabel", False) + model = ExportModel(self.config["Arch"], self.model, use_multilabel) + if self.config["Global"]["pretrained_model"] is not None: + load_dygraph_pretrain(model.base_model, + self.config["Global"]["pretrained_model"]) + + model.eval() + save_path = os.path.join(self.config["Global"]["save_inference_dir"], + "inference") + if model.quanter: + model.quanter.save_quantized_model( + model.base_model, + save_path, + input_spec=[ + paddle.static.InputSpec( + shape=[None] + self.config["Global"]["image_shape"], + dtype='float32') + ]) + else: + model = paddle.jit.to_static( + model, + input_spec=[ + paddle.static.InputSpec( + shape=[None] + self.config["Global"]["image_shape"], + dtype='float32') + ]) + paddle.jit.save(model, save_path) + + +class ExportModel(TheseusLayer): + """ + ExportModel: add softmax onto the model + """ + + def __init__(self, config, model, use_multilabel): + super().__init__() + self.base_model = model + # we should choose a final model to export + if isinstance(self.base_model, DistillationModel): + self.infer_model_name = config["infer_model_name"] + else: + self.infer_model_name = None + + self.infer_output_key = config.get("infer_output_key", None) + if self.infer_output_key == "features" and isinstance(self.base_model, + RecModel): + self.base_model.head = IdentityHead() + if use_multilabel: + self.out_act = nn.Sigmoid() + else: + if config.get("infer_add_softmax", True): + self.out_act = nn.Softmax(axis=-1) + else: + self.out_act = None + + def eval(self): + self.training = False + for layer in self.sublayers(): + layer.training = False + layer.eval() + + def forward(self, x): + x = self.base_model(x) + if isinstance(x, list): + x = x[0] + if self.infer_model_name is not None: + x = x[self.infer_model_name] + if self.infer_output_key is not None: + x = x[self.infer_output_key] + if self.out_act is not None: + x = self.out_act(x) + return x diff --git a/src/PaddleClas/ppcls/engine/evaluation/__init__.py b/src/PaddleClas/ppcls/engine/evaluation/__init__.py new file mode 100644 index 0000000..e0cd778 --- /dev/null +++ b/src/PaddleClas/ppcls/engine/evaluation/__init__.py @@ -0,0 +1,16 @@ +# Copyright (c) 2021 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 ppcls.engine.evaluation.classification import classification_eval +from ppcls.engine.evaluation.retrieval import retrieval_eval diff --git a/src/PaddleClas/ppcls/engine/evaluation/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/engine/evaluation/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..11ecf66 Binary files /dev/null and b/src/PaddleClas/ppcls/engine/evaluation/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/evaluation/__pycache__/classification.cpython-39.pyc b/src/PaddleClas/ppcls/engine/evaluation/__pycache__/classification.cpython-39.pyc new file mode 100644 index 0000000..089bcd4 Binary files /dev/null and b/src/PaddleClas/ppcls/engine/evaluation/__pycache__/classification.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/evaluation/__pycache__/retrieval.cpython-39.pyc b/src/PaddleClas/ppcls/engine/evaluation/__pycache__/retrieval.cpython-39.pyc new file mode 100644 index 0000000..61d40e3 Binary files /dev/null and b/src/PaddleClas/ppcls/engine/evaluation/__pycache__/retrieval.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/evaluation/classification.py b/src/PaddleClas/ppcls/engine/evaluation/classification.py new file mode 100644 index 0000000..d7b5c47 --- /dev/null +++ b/src/PaddleClas/ppcls/engine/evaluation/classification.py @@ -0,0 +1,169 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import time +import platform +import paddle + +from ppcls.utils.misc import AverageMeter +from ppcls.utils import logger + + +def classification_eval(engine, epoch_id=0): + output_info = dict() + time_info = { + "batch_cost": AverageMeter( + "batch_cost", '.5f', postfix=" s,"), + "reader_cost": AverageMeter( + "reader_cost", ".5f", postfix=" s,"), + } + print_batch_step = engine.config["Global"]["print_batch_step"] + + metric_key = None + tic = time.time() + accum_samples = 0 + total_samples = len( + engine.eval_dataloader. + dataset) if not engine.use_dali else engine.eval_dataloader.size + max_iter = len(engine.eval_dataloader) - 1 if platform.system( + ) == "Windows" else len(engine.eval_dataloader) + for iter_id, batch in enumerate(engine.eval_dataloader): + if iter_id >= max_iter: + break + if iter_id == 5: + for key in time_info: + time_info[key].reset() + if engine.use_dali: + batch = [ + paddle.to_tensor(batch[0]['data']), + paddle.to_tensor(batch[0]['label']) + ] + time_info["reader_cost"].update(time.time() - tic) + batch_size = batch[0].shape[0] + batch[0] = paddle.to_tensor(batch[0]).astype("float32") + if not engine.config["Global"].get("use_multilabel", False): + batch[1] = batch[1].reshape([-1, 1]).astype("int64") + + # image input + if engine.amp: + amp_level = engine.config['AMP'].get("level", "O1").upper() + with paddle.amp.auto_cast( + custom_black_list={ + "flatten_contiguous_range", "greater_than" + }, + level=amp_level): + out = engine.model(batch[0]) + # calc loss + if engine.eval_loss_func is not None: + loss_dict = engine.eval_loss_func(out, batch[1]) + for key in loss_dict: + if key not in output_info: + output_info[key] = AverageMeter(key, '7.5f') + output_info[key].update(loss_dict[key].numpy()[0], + batch_size) + else: + out = engine.model(batch[0]) + # calc loss + if engine.eval_loss_func is not None: + loss_dict = engine.eval_loss_func(out, batch[1]) + for key in loss_dict: + if key not in output_info: + output_info[key] = AverageMeter(key, '7.5f') + output_info[key].update(loss_dict[key].numpy()[0], + batch_size) + + # just for DistributedBatchSampler issue: repeat sampling + current_samples = batch_size * paddle.distributed.get_world_size() + accum_samples += current_samples + + # calc metric + if engine.eval_metric_func is not None: + if paddle.distributed.get_world_size() > 1: + label_list = [] + paddle.distributed.all_gather(label_list, batch[1]) + labels = paddle.concat(label_list, 0) + + if isinstance(out, dict): + if "Student" in out: + out = out["Student"] + elif "logits" in out: + out = out["logits"] + else: + msg = "Error: Wrong key in out!" + raise Exception(msg) + if isinstance(out, list): + pred = [] + for x in out: + pred_list = [] + paddle.distributed.all_gather(pred_list, x) + pred_x = paddle.concat(pred_list, 0) + pred.append(pred_x) + else: + pred_list = [] + paddle.distributed.all_gather(pred_list, out) + pred = paddle.concat(pred_list, 0) + + if accum_samples > total_samples and not engine.use_dali: + pred = pred[:total_samples + current_samples - + accum_samples] + labels = labels[:total_samples + current_samples - + accum_samples] + current_samples = total_samples + current_samples - accum_samples + metric_dict = engine.eval_metric_func(pred, labels) + else: + metric_dict = engine.eval_metric_func(out, batch[1]) + + for key in metric_dict: + if metric_key is None: + metric_key = key + if key not in output_info: + output_info[key] = AverageMeter(key, '7.5f') + + output_info[key].update(metric_dict[key].numpy()[0], + current_samples) + + time_info["batch_cost"].update(time.time() - tic) + + if iter_id % print_batch_step == 0: + time_msg = "s, ".join([ + "{}: {:.5f}".format(key, time_info[key].avg) + for key in time_info + ]) + + ips_msg = "ips: {:.5f} images/sec".format( + batch_size / time_info["batch_cost"].avg) + + metric_msg = ", ".join([ + "{}: {:.5f}".format(key, output_info[key].val) + for key in output_info + ]) + logger.info("[Eval][Epoch {}][Iter: {}/{}]{}, {}, {}".format( + epoch_id, iter_id, + len(engine.eval_dataloader), metric_msg, time_msg, ips_msg)) + + tic = time.time() + if engine.use_dali: + engine.eval_dataloader.reset() + metric_msg = ", ".join([ + "{}: {:.5f}".format(key, output_info[key].avg) for key in output_info + ]) + logger.info("[Eval][Epoch {}][Avg]{}".format(epoch_id, metric_msg)) + + # do not try to save best eval.model + if engine.eval_metric_func is None: + return -1 + # return 1st metric in the dict + return output_info[metric_key].avg diff --git a/src/PaddleClas/ppcls/engine/evaluation/retrieval.py b/src/PaddleClas/ppcls/engine/evaluation/retrieval.py new file mode 100644 index 0000000..8471a42 --- /dev/null +++ b/src/PaddleClas/ppcls/engine/evaluation/retrieval.py @@ -0,0 +1,171 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import platform +import paddle +from ppcls.utils import logger + + +def retrieval_eval(engine, epoch_id=0): + engine.model.eval() + # step1. build gallery + if engine.gallery_query_dataloader is not None: + gallery_feas, gallery_img_id, gallery_unique_id = cal_feature( + engine, name='gallery_query') + query_feas, query_img_id, query_query_id = gallery_feas, gallery_img_id, gallery_unique_id + else: + gallery_feas, gallery_img_id, gallery_unique_id = cal_feature( + engine, name='gallery') + query_feas, query_img_id, query_query_id = cal_feature( + engine, name='query') + + # step2. do evaluation + sim_block_size = engine.config["Global"].get("sim_block_size", 64) + sections = [sim_block_size] * (len(query_feas) // sim_block_size) + if len(query_feas) % sim_block_size: + sections.append(len(query_feas) % sim_block_size) + fea_blocks = paddle.split(query_feas, num_or_sections=sections) + if query_query_id is not None: + query_id_blocks = paddle.split( + query_query_id, num_or_sections=sections) + image_id_blocks = paddle.split(query_img_id, num_or_sections=sections) + metric_key = None + + if engine.eval_loss_func is None: + metric_dict = {metric_key: 0.} + else: + metric_dict = dict() + for block_idx, block_fea in enumerate(fea_blocks): + similarity_matrix = paddle.matmul( + block_fea, gallery_feas, transpose_y=True) + if query_query_id is not None: + query_id_block = query_id_blocks[block_idx] + query_id_mask = (query_id_block != gallery_unique_id.t()) + + image_id_block = image_id_blocks[block_idx] + image_id_mask = (image_id_block != gallery_img_id.t()) + + keep_mask = paddle.logical_or(query_id_mask, image_id_mask) + similarity_matrix = similarity_matrix * keep_mask.astype( + "float32") + else: + keep_mask = None + + metric_tmp = engine.eval_metric_func(similarity_matrix, + image_id_blocks[block_idx], + gallery_img_id, keep_mask) + + for key in metric_tmp: + if key not in metric_dict: + metric_dict[key] = metric_tmp[key] * block_fea.shape[ + 0] / len(query_feas) + else: + metric_dict[key] += metric_tmp[key] * block_fea.shape[ + 0] / len(query_feas) + + metric_info_list = [] + for key in metric_dict: + if metric_key is None: + metric_key = key + metric_info_list.append("{}: {:.5f}".format(key, metric_dict[key])) + metric_msg = ", ".join(metric_info_list) + logger.info("[Eval][Epoch {}][Avg]{}".format(epoch_id, metric_msg)) + + return metric_dict[metric_key] + + +def cal_feature(engine, name='gallery'): + all_feas = None + all_image_id = None + all_unique_id = None + has_unique_id = False + + if name == 'gallery': + dataloader = engine.gallery_dataloader + elif name == 'query': + dataloader = engine.query_dataloader + elif name == 'gallery_query': + dataloader = engine.gallery_query_dataloader + else: + raise RuntimeError("Only support gallery or query dataset") + + max_iter = len(dataloader) - 1 if platform.system() == "Windows" else len( + dataloader) + for idx, batch in enumerate(dataloader): # load is very time-consuming + if idx >= max_iter: + break + if idx % engine.config["Global"]["print_batch_step"] == 0: + logger.info( + f"{name} feature calculation process: [{idx}/{len(dataloader)}]" + ) + if engine.use_dali: + batch = [ + paddle.to_tensor(batch[0]['data']), + paddle.to_tensor(batch[0]['label']) + ] + batch = [paddle.to_tensor(x) for x in batch] + batch[1] = batch[1].reshape([-1, 1]).astype("int64") + if len(batch) == 3: + has_unique_id = True + batch[2] = batch[2].reshape([-1, 1]).astype("int64") + out = engine.model(batch[0], batch[1]) + if "Student" in out: + out = out["Student"] + batch_feas = out["features"] + + # do norm + if engine.config["Global"].get("feature_normalize", True): + feas_norm = paddle.sqrt( + paddle.sum(paddle.square(batch_feas), axis=1, keepdim=True)) + batch_feas = paddle.divide(batch_feas, feas_norm) + + # do binarize + if engine.config["Global"].get("feature_binarize") == "round": + batch_feas = paddle.round(batch_feas).astype("float32") * 2.0 - 1.0 + + if engine.config["Global"].get("feature_binarize") == "sign": + batch_feas = paddle.sign(batch_feas).astype("float32") + + if all_feas is None: + all_feas = batch_feas + if has_unique_id: + all_unique_id = batch[2] + all_image_id = batch[1] + else: + all_feas = paddle.concat([all_feas, batch_feas]) + all_image_id = paddle.concat([all_image_id, batch[1]]) + if has_unique_id: + all_unique_id = paddle.concat([all_unique_id, batch[2]]) + + if engine.use_dali: + dataloader.reset() + + if paddle.distributed.get_world_size() > 1: + feat_list = [] + img_id_list = [] + unique_id_list = [] + paddle.distributed.all_gather(feat_list, all_feas) + paddle.distributed.all_gather(img_id_list, all_image_id) + all_feas = paddle.concat(feat_list, axis=0) + all_image_id = paddle.concat(img_id_list, axis=0) + if has_unique_id: + paddle.distributed.all_gather(unique_id_list, all_unique_id) + all_unique_id = paddle.concat(unique_id_list, axis=0) + + logger.info("Build {} done, all feat shape: {}, begin to eval..".format( + name, all_feas.shape)) + return all_feas, all_image_id, all_unique_id diff --git a/src/PaddleClas/ppcls/engine/train/__init__.py b/src/PaddleClas/ppcls/engine/train/__init__.py new file mode 100644 index 0000000..800d3a4 --- /dev/null +++ b/src/PaddleClas/ppcls/engine/train/__init__.py @@ -0,0 +1,14 @@ +# Copyright (c) 2021 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 ppcls.engine.train.train import train_epoch diff --git a/src/PaddleClas/ppcls/engine/train/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/engine/train/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..01cb834 Binary files /dev/null and b/src/PaddleClas/ppcls/engine/train/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/train/__pycache__/train.cpython-39.pyc b/src/PaddleClas/ppcls/engine/train/__pycache__/train.cpython-39.pyc new file mode 100644 index 0000000..ea695c6 Binary files /dev/null and b/src/PaddleClas/ppcls/engine/train/__pycache__/train.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/train/__pycache__/utils.cpython-39.pyc b/src/PaddleClas/ppcls/engine/train/__pycache__/utils.cpython-39.pyc new file mode 100644 index 0000000..ac0f4e0 Binary files /dev/null and b/src/PaddleClas/ppcls/engine/train/__pycache__/utils.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/engine/train/train.py b/src/PaddleClas/ppcls/engine/train/train.py new file mode 100644 index 0000000..3b02bac --- /dev/null +++ b/src/PaddleClas/ppcls/engine/train/train.py @@ -0,0 +1,83 @@ +# Copyright (c) 2021 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 __future__ import absolute_import, division, print_function + +import time +import paddle +from ppcls.engine.train.utils import update_loss, update_metric, log_info +from ppcls.utils import profiler + + +def train_epoch(engine, epoch_id, print_batch_step): + tic = time.time() + v_current = [int(i) for i in paddle.__version__.split(".")] + for iter_id, batch in enumerate(engine.train_dataloader): + if iter_id >= engine.max_iter: + break + profiler.add_profiler_step(engine.config["profiler_options"]) + if iter_id == 5: + for key in engine.time_info: + engine.time_info[key].reset() + engine.time_info["reader_cost"].update(time.time() - tic) + if engine.use_dali: + batch = [ + paddle.to_tensor(batch[0]['data']), + paddle.to_tensor(batch[0]['label']) + ] + batch_size = batch[0].shape[0] + if not engine.config["Global"].get("use_multilabel", False): + batch[1] = batch[1].reshape([batch_size, -1]) + engine.global_step += 1 + + # image input + if engine.amp: + amp_level = engine.config['AMP'].get("level", "O1").upper() + with paddle.amp.auto_cast( + custom_black_list={ + "flatten_contiguous_range", "greater_than" + }, + level=amp_level): + out = forward(engine, batch) + loss_dict = engine.train_loss_func(out, batch[1]) + else: + out = forward(engine, batch) + loss_dict = engine.train_loss_func(out, batch[1]) + + # step opt and lr + if engine.amp: + scaled = engine.scaler.scale(loss_dict["loss"]) + scaled.backward() + engine.scaler.minimize(engine.optimizer, scaled) + else: + loss_dict["loss"].backward() + engine.optimizer.step() + engine.optimizer.clear_grad() + engine.lr_sch.step() + + # below code just for logging + # update metric_for_logger + update_metric(engine, out, batch, batch_size) + # update_loss_for_logger + update_loss(engine, loss_dict, batch_size) + engine.time_info["batch_cost"].update(time.time() - tic) + if iter_id % print_batch_step == 0: + log_info(engine, batch_size, epoch_id, iter_id) + tic = time.time() + + +def forward(engine, batch): + if not engine.is_rec: + return engine.model(batch[0]) + else: + return engine.model(batch[0], batch[1]) diff --git a/src/PaddleClas/ppcls/engine/train/utils.py b/src/PaddleClas/ppcls/engine/train/utils.py new file mode 100644 index 0000000..92eb35d --- /dev/null +++ b/src/PaddleClas/ppcls/engine/train/utils.py @@ -0,0 +1,72 @@ +# Copyright (c) 2021 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 __future__ import absolute_import, division, print_function + +import datetime +from ppcls.utils import logger +from ppcls.utils.misc import AverageMeter + + +def update_metric(trainer, out, batch, batch_size): + # calc metric + if trainer.train_metric_func is not None: + metric_dict = trainer.train_metric_func(out, batch[-1]) + for key in metric_dict: + if key not in trainer.output_info: + trainer.output_info[key] = AverageMeter(key, '7.5f') + trainer.output_info[key].update(metric_dict[key].numpy()[0], + batch_size) + + +def update_loss(trainer, loss_dict, batch_size): + # update_output_info + for key in loss_dict: + if key not in trainer.output_info: + trainer.output_info[key] = AverageMeter(key, '7.5f') + trainer.output_info[key].update(loss_dict[key].numpy()[0], batch_size) + + +def log_info(trainer, batch_size, epoch_id, iter_id): + lr_msg = "lr: {:.5f}".format(trainer.lr_sch.get_lr()) + metric_msg = ", ".join([ + "{}: {:.5f}".format(key, trainer.output_info[key].avg) + for key in trainer.output_info + ]) + time_msg = "s, ".join([ + "{}: {:.5f}".format(key, trainer.time_info[key].avg) + for key in trainer.time_info + ]) + + ips_msg = "ips: {:.5f} images/sec".format( + batch_size / trainer.time_info["batch_cost"].avg) + eta_sec = ((trainer.config["Global"]["epochs"] - epoch_id + 1 + ) * len(trainer.train_dataloader) - iter_id + ) * trainer.time_info["batch_cost"].avg + eta_msg = "eta: {:s}".format(str(datetime.timedelta(seconds=int(eta_sec)))) + logger.info("[Train][Epoch {}/{}][Iter: {}/{}]{}, {}, {}, {}, {}".format( + epoch_id, trainer.config["Global"]["epochs"], iter_id, + len(trainer.train_dataloader), lr_msg, metric_msg, time_msg, ips_msg, + eta_msg)) + + logger.scaler( + name="lr", + value=trainer.lr_sch.get_lr(), + step=trainer.global_step, + writer=trainer.vdl_writer) + for key in trainer.output_info: + logger.scaler( + name="train_{}".format(key), + value=trainer.output_info[key].avg, + step=trainer.global_step, + writer=trainer.vdl_writer) diff --git a/src/PaddleClas/ppcls/loss/__init__.py b/src/PaddleClas/ppcls/loss/__init__.py new file mode 100644 index 0000000..d15dab9 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/__init__.py @@ -0,0 +1,67 @@ +import copy + +import paddle +import paddle.nn as nn +from ppcls.utils import logger + +from .celoss import CELoss, MixCELoss +from .googlenetloss import GoogLeNetLoss +from .centerloss import CenterLoss +from .emlloss import EmlLoss +from .msmloss import MSMLoss +from .npairsloss import NpairsLoss +from .trihardloss import TriHardLoss +from .triplet import TripletLoss, TripletLossV2 +from .supconloss import SupConLoss +from .pairwisecosface import PairwiseCosface +from .dmlloss import DMLLoss +from .distanceloss import DistanceLoss + +from .distillationloss import DistillationCELoss +from .distillationloss import DistillationGTCELoss +from .distillationloss import DistillationDMLLoss +from .distillationloss import DistillationDistanceLoss +from .distillationloss import DistillationRKDLoss +from .multilabelloss import MultiLabelLoss + +from .deephashloss import DSHSDLoss, LCDSHLoss + + +class CombinedLoss(nn.Layer): + def __init__(self, config_list): + super().__init__() + self.loss_func = [] + self.loss_weight = [] + assert isinstance(config_list, list), ( + 'operator config should be a list') + for config in config_list: + assert isinstance(config, + dict) and len(config) == 1, "yaml format error" + name = list(config)[0] + param = config[name] + assert "weight" in param, "weight must be in param, but param just contains {}".format( + param.keys()) + self.loss_weight.append(param.pop("weight")) + self.loss_func.append(eval(name)(**param)) + + def __call__(self, input, batch): + loss_dict = {} + # just for accelerate classification traing speed + if len(self.loss_func) == 1: + loss = self.loss_func[0](input, batch) + loss_dict.update(loss) + loss_dict["loss"] = list(loss.values())[0] + else: + for idx, loss_func in enumerate(self.loss_func): + loss = loss_func(input, batch) + weight = self.loss_weight[idx] + loss = {key: loss[key] * weight for key in loss} + loss_dict.update(loss) + loss_dict["loss"] = paddle.add_n(list(loss_dict.values())) + return loss_dict + + +def build_loss(config): + module_class = CombinedLoss(copy.deepcopy(config)) + logger.debug("build loss {} success.".format(module_class)) + return module_class diff --git a/src/PaddleClas/ppcls/loss/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..cc3358b Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/celoss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/celoss.cpython-39.pyc new file mode 100644 index 0000000..794a040 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/celoss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/centerloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/centerloss.cpython-39.pyc new file mode 100644 index 0000000..43e5df7 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/centerloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/comfunc.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/comfunc.cpython-39.pyc new file mode 100644 index 0000000..0baf00e Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/comfunc.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/deephashloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/deephashloss.cpython-39.pyc new file mode 100644 index 0000000..9260c26 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/deephashloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/distanceloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/distanceloss.cpython-39.pyc new file mode 100644 index 0000000..20e799b Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/distanceloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/distillationloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/distillationloss.cpython-39.pyc new file mode 100644 index 0000000..9a669ee Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/distillationloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/dmlloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/dmlloss.cpython-39.pyc new file mode 100644 index 0000000..79557bd Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/dmlloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/emlloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/emlloss.cpython-39.pyc new file mode 100644 index 0000000..ac8b739 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/emlloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/googlenetloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/googlenetloss.cpython-39.pyc new file mode 100644 index 0000000..cf905df Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/googlenetloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/msmloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/msmloss.cpython-39.pyc new file mode 100644 index 0000000..4591ee7 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/msmloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/multilabelloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/multilabelloss.cpython-39.pyc new file mode 100644 index 0000000..385d408 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/multilabelloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/npairsloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/npairsloss.cpython-39.pyc new file mode 100644 index 0000000..a31cb1c Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/npairsloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/pairwisecosface.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/pairwisecosface.cpython-39.pyc new file mode 100644 index 0000000..86cee45 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/pairwisecosface.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/rkdloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/rkdloss.cpython-39.pyc new file mode 100644 index 0000000..3ef7b9f Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/rkdloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/supconloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/supconloss.cpython-39.pyc new file mode 100644 index 0000000..e537144 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/supconloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/trihardloss.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/trihardloss.cpython-39.pyc new file mode 100644 index 0000000..56e2651 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/trihardloss.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/__pycache__/triplet.cpython-39.pyc b/src/PaddleClas/ppcls/loss/__pycache__/triplet.cpython-39.pyc new file mode 100644 index 0000000..8554871 Binary files /dev/null and b/src/PaddleClas/ppcls/loss/__pycache__/triplet.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/loss/celoss.py b/src/PaddleClas/ppcls/loss/celoss.py new file mode 100644 index 0000000..a789261 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/celoss.py @@ -0,0 +1,67 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import warnings + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from ppcls.utils import logger + + +class CELoss(nn.Layer): + """ + Cross entropy loss + """ + + def __init__(self, epsilon=None): + super().__init__() + if epsilon is not None and (epsilon <= 0 or epsilon >= 1): + epsilon = None + self.epsilon = epsilon + + def _labelsmoothing(self, target, class_num): + if len(target.shape) == 1 or target.shape[-1] != class_num: + one_hot_target = F.one_hot(target, class_num) + else: + one_hot_target = target + soft_target = F.label_smooth(one_hot_target, epsilon=self.epsilon) + soft_target = paddle.reshape(soft_target, shape=[-1, class_num]) + return soft_target + + def forward(self, x, label): + if isinstance(x, dict): + x = x["logits"] + if self.epsilon is not None: + class_num = x.shape[-1] + label = self._labelsmoothing(label, class_num) + x = -F.log_softmax(x, axis=-1) + loss = paddle.sum(x * label, axis=-1) + else: + if label.shape[-1] == x.shape[-1]: + label = F.softmax(label, axis=-1) + soft_label = True + else: + soft_label = False + loss = F.cross_entropy(x, label=label, soft_label=soft_label) + loss = loss.mean() + return {"CELoss": loss} + + +class MixCELoss(object): + def __init__(self, *args, **kwargs): + msg = "\"MixCELos\" is deprecated, please use \"CELoss\" instead." + logger.error(DeprecationWarning(msg)) + raise DeprecationWarning(msg) diff --git a/src/PaddleClas/ppcls/loss/centerloss.py b/src/PaddleClas/ppcls/loss/centerloss.py new file mode 100644 index 0000000..d85b3f2 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/centerloss.py @@ -0,0 +1,54 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +class CenterLoss(nn.Layer): + def __init__(self, num_classes=5013, feat_dim=2048): + super(CenterLoss, self).__init__() + self.num_classes = num_classes + self.feat_dim = feat_dim + self.centers = paddle.randn( + shape=[self.num_classes, self.feat_dim]).astype( + "float64") #random center + + def __call__(self, input, target): + """ + inputs: network output: {"features: xxx", "logits": xxxx} + target: image label + """ + feats = input["features"] + labels = target + batch_size = feats.shape[0] + + #calc feat * feat + dist1 = paddle.sum(paddle.square(feats), axis=1, keepdim=True) + dist1 = paddle.expand(dist1, [batch_size, self.num_classes]) + + #dist2 of centers + dist2 = paddle.sum(paddle.square(self.centers), axis=1, + keepdim=True) #num_classes + dist2 = paddle.expand(dist2, + [self.num_classes, batch_size]).astype("float64") + dist2 = paddle.transpose(dist2, [1, 0]) + + #first x * x + y * y + distmat = paddle.add(dist1, dist2) + tmp = paddle.matmul(feats, paddle.transpose(self.centers, [1, 0])) + distmat = distmat - 2.0 * tmp + + #generate the mask + classes = paddle.arange(self.num_classes).astype("int64") + labels = paddle.expand( + paddle.unsqueeze(labels, 1), (batch_size, self.num_classes)) + mask = paddle.equal( + paddle.expand(classes, [batch_size, self.num_classes]), + labels).astype("float64") #get mask + + dist = paddle.multiply(distmat, mask) + loss = paddle.sum(paddle.clip(dist, min=1e-12, max=1e+12)) / batch_size + + return {'CenterLoss': loss} diff --git a/src/PaddleClas/ppcls/loss/comfunc.py b/src/PaddleClas/ppcls/loss/comfunc.py new file mode 100644 index 0000000..277bdd6 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/comfunc.py @@ -0,0 +1,45 @@ +# Copyright (c) 2018 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np + + +def rerange_index(batch_size, samples_each_class): + tmp = np.arange(0, batch_size * batch_size) + tmp = tmp.reshape(-1, batch_size) + rerange_index = [] + + for i in range(batch_size): + step = i // samples_each_class + start = step * samples_each_class + end = (step + 1) * samples_each_class + + pos_idx = [] + neg_idx = [] + for j, k in enumerate(tmp[i]): + if j >= start and j < end: + if j == i: + pos_idx.insert(0, k) + else: + pos_idx.append(k) + else: + neg_idx.append(k) + rerange_index += (pos_idx + neg_idx) + + rerange_index = np.array(rerange_index).astype(np.int32) + return rerange_index diff --git a/src/PaddleClas/ppcls/loss/deephashloss.py b/src/PaddleClas/ppcls/loss/deephashloss.py new file mode 100644 index 0000000..c9a58dc --- /dev/null +++ b/src/PaddleClas/ppcls/loss/deephashloss.py @@ -0,0 +1,92 @@ +#copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +#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. + +import paddle +import paddle.nn as nn + +class DSHSDLoss(nn.Layer): + """ + # DSHSD(IEEE ACCESS 2019) + # paper [Deep Supervised Hashing Based on Stable Distribution](https://ieeexplore.ieee.org/document/8648432/) + # [DSHSD] epoch:70, bit:48, dataset:cifar10-1, MAP:0.809, Best MAP: 0.809 + # [DSHSD] epoch:250, bit:48, dataset:nuswide_21, MAP:0.809, Best MAP: 0.815 + # [DSHSD] epoch:135, bit:48, dataset:imagenet, MAP:0.647, Best MAP: 0.647 + """ + def __init__(self, alpha, multi_label=False): + super(DSHSDLoss, self).__init__() + self.alpha = alpha + self.multi_label = multi_label + + def forward(self, input, label): + feature = input["features"] + logits = input["logits"] + + dist = paddle.sum(paddle.square( + (paddle.unsqueeze(feature, 1) - paddle.unsqueeze(feature, 0))), + axis=2) + + # label to ont-hot + label = paddle.flatten(label) + n_class = logits.shape[1] + label = paddle.nn.functional.one_hot(label, n_class).astype("float32") + + s = (paddle.matmul( + label, label, transpose_y=True) == 0).astype("float32") + margin = 2 * feature.shape[1] + Ld = (1 - s) / 2 * dist + s / 2 * (margin - dist).clip(min=0) + Ld = Ld.mean() + + if self.multi_label: + # multiple labels classification loss + Lc = (logits - label * logits + ( + (1 + (-logits).exp()).log())).sum(axis=1).mean() + else: + # single labels classification loss + Lc = (-paddle.nn.functional.softmax(logits).log() * label).sum( + axis=1).mean() + + return {"dshsdloss": Lc + Ld * self.alpha} + + +class LCDSHLoss(nn.Layer): + """ + # paper [Locality-Constrained Deep Supervised Hashing for Image Retrieval](https://www.ijcai.org/Proceedings/2017/0499.pdf) + # [LCDSH] epoch:145, bit:48, dataset:cifar10-1, MAP:0.798, Best MAP: 0.798 + # [LCDSH] epoch:183, bit:48, dataset:nuswide_21, MAP:0.833, Best MAP: 0.834 + """ + def __init__(self, n_class, _lambda): + super(LCDSHLoss, self).__init__() + self._lambda = _lambda + self.n_class = n_class + + def forward(self, input, label): + feature = input["features"] + + # label to ont-hot + label = paddle.flatten(label) + label = paddle.nn.functional.one_hot(label, self.n_class).astype("float32") + + s = 2 * (paddle.matmul(label, label, transpose_y=True) > 0).astype("float32") - 1 + inner_product = paddle.matmul(feature, feature, transpose_y=True) * 0.5 + + inner_product = inner_product.clip(min=-50, max=50) + L1 = paddle.log(1 + paddle.exp(-s * inner_product)).mean() + + b = feature.sign() + inner_product_ = paddle.matmul(b, b, transpose_y=True) * 0.5 + sigmoid = paddle.nn.Sigmoid() + L2 = (sigmoid(inner_product) - sigmoid(inner_product_)).pow(2).mean() + + return {"lcdshloss": L1 + self._lambda * L2} + diff --git a/src/PaddleClas/ppcls/loss/distanceloss.py b/src/PaddleClas/ppcls/loss/distanceloss.py new file mode 100644 index 0000000..0a09f0c --- /dev/null +++ b/src/PaddleClas/ppcls/loss/distanceloss.py @@ -0,0 +1,43 @@ +#copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +#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. + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from paddle.nn import L1Loss +from paddle.nn import MSELoss as L2Loss +from paddle.nn import SmoothL1Loss + + +class DistanceLoss(nn.Layer): + """ + DistanceLoss: + mode: loss mode + """ + + def __init__(self, mode="l2", **kargs): + super().__init__() + assert mode in ["l1", "l2", "smooth_l1"] + if mode == "l1": + self.loss_func = nn.L1Loss(**kargs) + elif mode == "l2": + self.loss_func = nn.MSELoss(**kargs) + elif mode == "smooth_l1": + self.loss_func = nn.SmoothL1Loss(**kargs) + self.mode = mode + + def forward(self, x, y): + loss = self.loss_func(x, y) + return {"loss_{}".format(self.mode): loss} diff --git a/src/PaddleClas/ppcls/loss/distillationloss.py b/src/PaddleClas/ppcls/loss/distillationloss.py new file mode 100644 index 0000000..0340234 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/distillationloss.py @@ -0,0 +1,174 @@ +#copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +#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. + +import paddle +import paddle.nn as nn + +from .celoss import CELoss +from .dmlloss import DMLLoss +from .distanceloss import DistanceLoss +from .rkdloss import RKdAngle, RkdDistance + + +class DistillationCELoss(CELoss): + """ + DistillationCELoss + """ + + def __init__(self, + model_name_pairs=[], + epsilon=None, + key=None, + name="loss_ce"): + super().__init__(epsilon=epsilon) + assert isinstance(model_name_pairs, list) + self.key = key + self.model_name_pairs = model_name_pairs + self.name = name + + def forward(self, predicts, batch): + loss_dict = dict() + for idx, pair in enumerate(self.model_name_pairs): + out1 = predicts[pair[0]] + out2 = predicts[pair[1]] + if self.key is not None: + out1 = out1[self.key] + out2 = out2[self.key] + loss = super().forward(out1, out2) + for key in loss: + loss_dict["{}_{}_{}".format(key, pair[0], pair[1])] = loss[key] + return loss_dict + + +class DistillationGTCELoss(CELoss): + """ + DistillationGTCELoss + """ + + def __init__(self, + model_names=[], + epsilon=None, + key=None, + name="loss_gt_ce"): + super().__init__(epsilon=epsilon) + assert isinstance(model_names, list) + self.key = key + self.model_names = model_names + self.name = name + + def forward(self, predicts, batch): + loss_dict = dict() + for name in self.model_names: + out = predicts[name] + if self.key is not None: + out = out[self.key] + loss = super().forward(out, batch) + for key in loss: + loss_dict["{}_{}".format(key, name)] = loss[key] + return loss_dict + + +class DistillationDMLLoss(DMLLoss): + """ + """ + + def __init__(self, + model_name_pairs=[], + act="softmax", + key=None, + name="loss_dml"): + super().__init__(act=act) + assert isinstance(model_name_pairs, list) + self.key = key + self.model_name_pairs = model_name_pairs + self.name = name + + def forward(self, predicts, batch): + loss_dict = dict() + for idx, pair in enumerate(self.model_name_pairs): + out1 = predicts[pair[0]] + out2 = predicts[pair[1]] + if self.key is not None: + out1 = out1[self.key] + out2 = out2[self.key] + loss = super().forward(out1, out2) + if isinstance(loss, dict): + for key in loss: + loss_dict["{}_{}_{}_{}".format(key, pair[0], pair[1], + idx)] = loss[key] + else: + loss_dict["{}_{}".format(self.name, idx)] = loss + return loss_dict + + +class DistillationDistanceLoss(DistanceLoss): + """ + """ + + def __init__(self, + mode="l2", + model_name_pairs=[], + key=None, + name="loss_", + **kargs): + super().__init__(mode=mode, **kargs) + assert isinstance(model_name_pairs, list) + self.key = key + self.model_name_pairs = model_name_pairs + self.name = name + mode + + def forward(self, predicts, batch): + loss_dict = dict() + for idx, pair in enumerate(self.model_name_pairs): + out1 = predicts[pair[0]] + out2 = predicts[pair[1]] + if self.key is not None: + out1 = out1[self.key] + out2 = out2[self.key] + loss = super().forward(out1, out2) + for key in loss: + loss_dict["{}_{}_{}".format(self.name, key, idx)] = loss[key] + return loss_dict + + +class DistillationRKDLoss(nn.Layer): + def __init__(self, + target_size=None, + model_name_pairs=(["Student", "Teacher"], ), + student_keepkeys=[], + teacher_keepkeys=[]): + super().__init__() + self.student_keepkeys = student_keepkeys + self.teacher_keepkeys = teacher_keepkeys + self.model_name_pairs = model_name_pairs + assert len(self.student_keepkeys) == len(self.teacher_keepkeys) + + self.rkd_angle_loss = RKdAngle(target_size=target_size) + self.rkd_dist_loss = RkdDistance(target_size=target_size) + + def __call__(self, predicts, batch): + loss_dict = {} + for m1, m2 in self.model_name_pairs: + for idx, ( + student_name, teacher_name + ) in enumerate(zip(self.student_keepkeys, self.teacher_keepkeys)): + student_out = predicts[m1][student_name] + teacher_out = predicts[m2][teacher_name] + + loss_dict[f"loss_angle_{idx}_{m1}_{m2}"] = self.rkd_angle_loss( + student_out, teacher_out) + loss_dict[f"loss_dist_{idx}_{m1}_{m2}"] = self.rkd_dist_loss( + student_out, teacher_out) + + return loss_dict diff --git a/src/PaddleClas/ppcls/loss/dmlloss.py b/src/PaddleClas/ppcls/loss/dmlloss.py new file mode 100644 index 0000000..48bf6c0 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/dmlloss.py @@ -0,0 +1,50 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +class DMLLoss(nn.Layer): + """ + DMLLoss + """ + + def __init__(self, act="softmax", eps=1e-12): + super().__init__() + if act is not None: + assert act in ["softmax", "sigmoid"] + if act == "softmax": + self.act = nn.Softmax(axis=-1) + elif act == "sigmoid": + self.act = nn.Sigmoid() + else: + self.act = None + self.eps = eps + + def _kldiv(self, x, target): + class_num = x.shape[-1] + cost = target * paddle.log( + (target + self.eps) / (x + self.eps)) * class_num + return cost + + def forward(self, x, target): + if self.act is not None: + x = self.act(x) + target = self.act(target) + loss = self._kldiv(x, target) + self._kldiv(target, x) + loss = loss / 2 + loss = paddle.mean(loss) + return {"DMLLoss": loss} diff --git a/src/PaddleClas/ppcls/loss/emlloss.py b/src/PaddleClas/ppcls/loss/emlloss.py new file mode 100644 index 0000000..9735703 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/emlloss.py @@ -0,0 +1,97 @@ +# Copyright (c) 2018 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import math +import paddle +import numpy as np +from .comfunc import rerange_index + + +class EmlLoss(paddle.nn.Layer): + def __init__(self, batch_size=40, samples_each_class=2): + super(EmlLoss, self).__init__() + assert (batch_size % samples_each_class == 0) + self.samples_each_class = samples_each_class + self.batch_size = batch_size + self.rerange_index = rerange_index(batch_size, samples_each_class) + self.thresh = 20.0 + self.beta = 100000 + + def surrogate_function(self, beta, theta, bias): + x = theta * paddle.exp(bias) + output = paddle.log(1 + beta * x) / math.log(1 + beta) + return output + + def surrogate_function_approximate(self, beta, theta, bias): + output = ( + paddle.log(theta) + bias + math.log(beta)) / math.log(1 + beta) + return output + + def surrogate_function_stable(self, beta, theta, target, thresh): + max_gap = paddle.to_tensor(thresh, dtype='float32') + max_gap.stop_gradient = True + + target_max = paddle.maximum(target, max_gap) + target_min = paddle.minimum(target, max_gap) + + loss1 = self.surrogate_function(beta, theta, target_min) + loss2 = self.surrogate_function_approximate(beta, theta, target_max) + bias = self.surrogate_function(beta, theta, max_gap) + loss = loss1 + loss2 - bias + return loss + + def forward(self, input, target=None): + features = input["features"] + samples_each_class = self.samples_each_class + batch_size = self.batch_size + rerange_index = self.rerange_index + + #calc distance + diffs = paddle.unsqueeze( + features, axis=1) - paddle.unsqueeze( + features, axis=0) + similary_matrix = paddle.sum(paddle.square(diffs), axis=-1) + + tmp = paddle.reshape(similary_matrix, shape=[-1, 1]) + rerange_index = paddle.to_tensor(rerange_index) + tmp = paddle.gather(tmp, index=rerange_index) + similary_matrix = paddle.reshape(tmp, shape=[-1, batch_size]) + + ignore, pos, neg = paddle.split( + similary_matrix, + num_or_sections=[ + 1, samples_each_class - 1, batch_size - samples_each_class + ], + axis=1) + ignore.stop_gradient = True + + pos_max = paddle.max(pos, axis=1, keepdim=True) + pos = paddle.exp(pos - pos_max) + pos_mean = paddle.mean(pos, axis=1, keepdim=True) + + neg_min = paddle.min(neg, axis=1, keepdim=True) + neg = paddle.exp(neg_min - neg) + neg_mean = paddle.mean(neg, axis=1, keepdim=True) + + bias = pos_max - neg_min + theta = paddle.multiply(neg_mean, pos_mean) + + loss = self.surrogate_function_stable(self.beta, theta, bias, + self.thresh) + loss = paddle.mean(loss) + return {"emlloss": loss} diff --git a/src/PaddleClas/ppcls/loss/googlenetloss.py b/src/PaddleClas/ppcls/loss/googlenetloss.py new file mode 100644 index 0000000..c580aa6 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/googlenetloss.py @@ -0,0 +1,41 @@ +# 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. + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +class GoogLeNetLoss(nn.Layer): + """ + Cross entropy loss used after googlenet + """ + def __init__(self, epsilon=None): + super().__init__() + assert (epsilon is None or epsilon <= 0 or epsilon >= 1), "googlenet is not support label_smooth" + + + def forward(self, inputs, label): + input0, input1, input2 = inputs + if isinstance(input0, dict): + input0 = input0["logits"] + if isinstance(input1, dict): + input1 = input1["logits"] + if isinstance(input2, dict): + input2 = input2["logits"] + + loss0 = F.cross_entropy(input0, label=label, soft_label=False) + loss1 = F.cross_entropy(input1, label=label, soft_label=False) + loss2 = F.cross_entropy(input2, label=label, soft_label=False) + loss = loss0 + 0.3 * loss1 + 0.3 * loss2 + loss = loss.mean() + return {"GooleNetLoss": loss} diff --git a/src/PaddleClas/ppcls/loss/msmloss.py b/src/PaddleClas/ppcls/loss/msmloss.py new file mode 100644 index 0000000..3aa0dd8 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/msmloss.py @@ -0,0 +1,78 @@ +# Copyright (c) 2018 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import paddle +from .comfunc import rerange_index + + +class MSMLoss(paddle.nn.Layer): + """ + MSMLoss Loss, based on triplet loss. USE P * K samples. + the batch size is fixed. Batch_size = P * K; but the K may vary between batches. + same label gather together + + supported_metrics = [ + 'euclidean', + 'sqeuclidean', + 'cityblock', + ] + only consider samples_each_class = 2 + """ + + def __init__(self, batch_size=120, samples_each_class=2, margin=0.1): + super(MSMLoss, self).__init__() + self.margin = margin + self.samples_each_class = samples_each_class + self.batch_size = batch_size + self.rerange_index = rerange_index(batch_size, samples_each_class) + + def forward(self, input, target=None): + #normalization + features = input["features"] + features = self._nomalize(features) + samples_each_class = self.samples_each_class + rerange_index = paddle.to_tensor(self.rerange_index) + + #calc sm + diffs = paddle.unsqueeze( + features, axis=1) - paddle.unsqueeze( + features, axis=0) + similary_matrix = paddle.sum(paddle.square(diffs), axis=-1) + + #rerange + tmp = paddle.reshape(similary_matrix, shape=[-1, 1]) + tmp = paddle.gather(tmp, index=rerange_index) + similary_matrix = paddle.reshape(tmp, shape=[-1, self.batch_size]) + + #split + ignore, pos, neg = paddle.split( + similary_matrix, + num_or_sections=[1, samples_each_class - 1, -1], + axis=1) + ignore.stop_gradient = True + + hard_pos = paddle.max(pos) + hard_neg = paddle.min(neg) + + loss = hard_pos + self.margin - hard_neg + loss = paddle.nn.ReLU()(loss) + return {"msmloss": loss} + + def _nomalize(self, input): + input_norm = paddle.sqrt( + paddle.sum(paddle.square(input), axis=1, keepdim=True)) + return paddle.divide(input, input_norm) diff --git a/src/PaddleClas/ppcls/loss/multilabelloss.py b/src/PaddleClas/ppcls/loss/multilabelloss.py new file mode 100644 index 0000000..d30d5b8 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/multilabelloss.py @@ -0,0 +1,43 @@ +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +class MultiLabelLoss(nn.Layer): + """ + Multi-label loss + """ + + def __init__(self, epsilon=None): + super().__init__() + if epsilon is not None and (epsilon <= 0 or epsilon >= 1): + epsilon = None + self.epsilon = epsilon + + def _labelsmoothing(self, target, class_num): + if target.ndim == 1 or target.shape[-1] != class_num: + one_hot_target = F.one_hot(target, class_num) + else: + one_hot_target = target + soft_target = F.label_smooth(one_hot_target, epsilon=self.epsilon) + soft_target = paddle.reshape(soft_target, shape=[-1, class_num]) + return soft_target + + def _binary_crossentropy(self, input, target, class_num): + if self.epsilon is not None: + target = self._labelsmoothing(target, class_num) + cost = F.binary_cross_entropy_with_logits( + logit=input, label=target) + else: + cost = F.binary_cross_entropy_with_logits( + logit=input, label=target) + + return cost + + def forward(self, x, target): + if isinstance(x, dict): + x = x["logits"] + class_num = x.shape[-1] + loss = self._binary_crossentropy(x, target, class_num) + loss = loss.mean() + return {"MultiLabelLoss": loss} diff --git a/src/PaddleClas/ppcls/loss/npairsloss.py b/src/PaddleClas/ppcls/loss/npairsloss.py new file mode 100644 index 0000000..d4b359e --- /dev/null +++ b/src/PaddleClas/ppcls/loss/npairsloss.py @@ -0,0 +1,38 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import paddle + + +class NpairsLoss(paddle.nn.Layer): + def __init__(self, reg_lambda=0.01): + super(NpairsLoss, self).__init__() + self.reg_lambda = reg_lambda + + def forward(self, input, target=None): + """ + anchor and positive(should include label) + """ + features = input["features"] + reg_lambda = self.reg_lambda + batch_size = features.shape[0] + fea_dim = features.shape[1] + num_class = batch_size // 2 + + #reshape + out_feas = paddle.reshape(features, shape=[-1, 2, fea_dim]) + anc_feas, pos_feas = paddle.split(out_feas, num_or_sections=2, axis=1) + anc_feas = paddle.squeeze(anc_feas, axis=1) + pos_feas = paddle.squeeze(pos_feas, axis=1) + + #get simi matrix + similarity_matrix = paddle.matmul( + anc_feas, pos_feas, transpose_y=True) #get similarity matrix + sparse_labels = paddle.arange(0, num_class, dtype='int64') + xentloss = paddle.nn.CrossEntropyLoss()( + similarity_matrix, sparse_labels) #by default: mean + + #l2 norm + reg = paddle.mean(paddle.sum(paddle.square(features), axis=1)) + l2loss = 0.5 * reg_lambda * reg + return {"npairsloss": xentloss + l2loss} diff --git a/src/PaddleClas/ppcls/loss/pairwisecosface.py b/src/PaddleClas/ppcls/loss/pairwisecosface.py new file mode 100644 index 0000000..beb8068 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/pairwisecosface.py @@ -0,0 +1,55 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import math +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +class PairwiseCosface(nn.Layer): + def __init__(self, margin, gamma): + super(PairwiseCosface, self).__init__() + self.margin = margin + self.gamma = gamma + + def forward(self, embedding, targets): + if isinstance(embedding, dict): + embedding = embedding['features'] + # Normalize embedding features + embedding = F.normalize(embedding, axis=1) + dist_mat = paddle.matmul(embedding, embedding, transpose_y=True) + + N = dist_mat.shape[0] + is_pos = targets.reshape([N,1]).expand([N,N]).equal(paddle.t(targets.reshape([N,1]).expand([N,N]))).astype('float') + is_neg = targets.reshape([N,1]).expand([N,N]).not_equal(paddle.t(targets.reshape([N,1]).expand([N,N]))).astype('float') + + # Mask scores related to itself + is_pos = is_pos - paddle.eye(N, N) + + s_p = dist_mat * is_pos + s_n = dist_mat * is_neg + + logit_p = -self.gamma * s_p + (-99999999.) * (1 - is_pos) + logit_n = self.gamma * (s_n + self.margin) + (-99999999.) * (1 - is_neg) + + loss = F.softplus(paddle.logsumexp(logit_p, axis=1) + paddle.logsumexp(logit_n, axis=1)).mean() + + return {"PairwiseCosface": loss} + + diff --git a/src/PaddleClas/ppcls/loss/rkdloss.py b/src/PaddleClas/ppcls/loss/rkdloss.py new file mode 100644 index 0000000..e6ffea2 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/rkdloss.py @@ -0,0 +1,97 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + + +def pdist(e, squared=False, eps=1e-12): + e_square = e.pow(2).sum(axis=1) + prod = paddle.mm(e, e.t()) + res = (e_square.unsqueeze(1) + e_square.unsqueeze(0) - 2 * prod).clip( + min=eps) + + if not squared: + res = res.sqrt() + return res + + +class RKdAngle(nn.Layer): + # reference: https://github.com/lenscloth/RKD/blob/master/metric/loss.py + def __init__(self, target_size=None): + super().__init__() + if target_size is not None: + self.avgpool = paddle.nn.AdaptiveAvgPool2D(target_size) + else: + self.avgpool = None + + def forward(self, student, teacher): + # GAP to reduce memory + if self.avgpool is not None: + # NxC1xH1xW1 -> NxC1x1x1 + student = self.avgpool(student) + # NxC2xH2xW2 -> NxC2x1x1 + teacher = self.avgpool(teacher) + + # reshape for feature map distillation + bs = student.shape[0] + student = student.reshape([bs, -1]) + teacher = teacher.reshape([bs, -1]) + + td = (teacher.unsqueeze(0) - teacher.unsqueeze(1)) + norm_td = F.normalize(td, p=2, axis=2) + t_angle = paddle.bmm(norm_td, norm_td.transpose([0, 2, 1])).reshape( + [-1, 1]) + + sd = (student.unsqueeze(0) - student.unsqueeze(1)) + norm_sd = F.normalize(sd, p=2, axis=2) + s_angle = paddle.bmm(norm_sd, norm_sd.transpose([0, 2, 1])).reshape( + [-1, 1]) + loss = F.smooth_l1_loss(s_angle, t_angle, reduction='mean') + return loss + + +class RkdDistance(nn.Layer): + # reference: https://github.com/lenscloth/RKD/blob/master/metric/loss.py + def __init__(self, eps=1e-12, target_size=1): + super().__init__() + self.eps = eps + if target_size is not None: + self.avgpool = paddle.nn.AdaptiveAvgPool2D(target_size) + else: + self.avgpool = None + + def forward(self, student, teacher): + # GAP to reduce memory + if self.avgpool is not None: + # NxC1xH1xW1 -> NxC1x1x1 + student = self.avgpool(student) + # NxC2xH2xW2 -> NxC2x1x1 + teacher = self.avgpool(teacher) + + bs = student.shape[0] + student = student.reshape([bs, -1]) + teacher = teacher.reshape([bs, -1]) + + t_d = pdist(teacher, squared=False) + mean_td = t_d.mean() + t_d = t_d / (mean_td + self.eps) + + d = pdist(student, squared=False) + mean_d = d.mean() + d = d / (mean_d + self.eps) + + loss = F.smooth_l1_loss(d, t_d, reduction="mean") + return loss diff --git a/src/PaddleClas/ppcls/loss/supconloss.py b/src/PaddleClas/ppcls/loss/supconloss.py new file mode 100644 index 0000000..3dd33bc --- /dev/null +++ b/src/PaddleClas/ppcls/loss/supconloss.py @@ -0,0 +1,108 @@ +import paddle +from paddle import nn + + +class SupConLoss(nn.Layer): + """Supervised Contrastive Learning: https://arxiv.org/pdf/2004.11362.pdf. + It also supports the unsupervised contrastive loss in SimCLR""" + + def __init__(self, + views=16, + temperature=0.07, + contrast_mode='all', + base_temperature=0.07, + normalize_feature=True): + super(SupConLoss, self).__init__() + self.temperature = paddle.to_tensor(temperature) + self.contrast_mode = contrast_mode + self.base_temperature = paddle.to_tensor(base_temperature) + self.num_ids = None + self.views = views + self.normalize_feature = normalize_feature + + def forward(self, features, labels, mask=None): + """Compute loss for model. If both `labels` and `mask` are None, + it degenerates to SimCLR unsupervised loss: + https://arxiv.org/pdf/2002.05709.pdf + Args: + features: hidden vector of shape [bsz, n_views, ...]. + labels: ground truth of shape [bsz]. + mask: contrastive mask of shape [bsz, bsz], mask_{i,j}=1 if sample j + has the same class as sample i. Can be asymmetric. + Returns: + A loss scalar. + """ + features = features["features"] + if self.num_ids is None: + self.num_ids = int(features.shape[0] / self.views) + + if self.normalize_feature: + features = 1. * features / (paddle.expand_as( + paddle.norm( + features, p=2, axis=-1, keepdim=True), features) + 1e-12) + features = features.reshape([self.num_ids, self.views, -1]) + labels = labels.reshape([self.num_ids, self.views])[:, 0] + + if len(features.shape) < 3: + raise ValueError('`features` needs to be [bsz, n_views, ...],' + 'at least 3 dimensions are required') + if len(features.shape) > 3: + features = features.reshape( + [features.shape[0], features.shape[1], -1]) + + batch_size = features.shape[0] + if labels is not None and mask is not None: + raise ValueError('Cannot define both `labels` and `mask`') + elif labels is None and mask is None: + mask = paddle.eye(batch_size, dtype='float32') + elif labels is not None: + labels = labels.reshape([-1, 1]) + if labels.shape[0] != batch_size: + raise ValueError( + 'Num of labels does not match num of features') + mask = paddle.cast( + paddle.equal(labels, paddle.t(labels)), 'float32') + else: + mask = paddle.cast(mask, 'float32') + + contrast_count = features.shape[1] + contrast_feature = paddle.concat( + paddle.unbind( + features, axis=1), axis=0) + if self.contrast_mode == 'one': + anchor_feature = features[:, 0] + anchor_count = 1 + elif self.contrast_mode == 'all': + anchor_feature = contrast_feature + anchor_count = contrast_count + else: + raise ValueError('Unknown mode: {}'.format(self.contrast_mode)) + + # compute logits + anchor_dot_contrast = paddle.divide( + paddle.matmul(anchor_feature, paddle.t(contrast_feature)), + self.temperature) + # for numerical stability + logits_max = paddle.max(anchor_dot_contrast, axis=1, keepdim=True) + logits = anchor_dot_contrast - logits_max.detach() + + # tile mask + mask = paddle.tile(mask, [anchor_count, contrast_count]) + + logits_mask = 1 - paddle.eye(batch_size * anchor_count) + mask = mask * logits_mask + + # compute log_prob + exp_logits = paddle.exp(logits) * logits_mask + log_prob = logits - paddle.log( + paddle.sum(exp_logits, axis=1, keepdim=True)) + + # compute mean of log-likelihood over positive + mean_log_prob_pos = paddle.sum((mask * log_prob), + axis=1) / paddle.sum(mask, axis=1) + + # loss + loss = -(self.temperature / self.base_temperature) * mean_log_prob_pos + loss = paddle.mean(loss.reshape([anchor_count, batch_size])) + + return {"SupConLoss": loss} diff --git a/src/PaddleClas/ppcls/loss/trihardloss.py b/src/PaddleClas/ppcls/loss/trihardloss.py new file mode 100644 index 0000000..132c604 --- /dev/null +++ b/src/PaddleClas/ppcls/loss/trihardloss.py @@ -0,0 +1,82 @@ +# Copyright (c) 2018 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import paddle +from .comfunc import rerange_index + + +class TriHardLoss(paddle.nn.Layer): + """ + TriHard Loss, based on triplet loss. USE P * K samples. + the batch size is fixed. Batch_size = P * K; but the K may vary between batches. + same label gather together + + supported_metrics = [ + 'euclidean', + 'sqeuclidean', + 'cityblock', + ] + only consider samples_each_class = 2 + """ + + def __init__(self, batch_size=120, samples_each_class=2, margin=0.1): + super(TriHardLoss, self).__init__() + self.margin = margin + self.samples_each_class = samples_each_class + self.batch_size = batch_size + self.rerange_index = rerange_index(batch_size, samples_each_class) + + def forward(self, input, target=None): + features = input["features"] + assert (self.batch_size == features.shape[0]) + + #normalization + features = self._nomalize(features) + samples_each_class = self.samples_each_class + rerange_index = paddle.to_tensor(self.rerange_index) + + #calc sm + diffs = paddle.unsqueeze( + features, axis=1) - paddle.unsqueeze( + features, axis=0) + similary_matrix = paddle.sum(paddle.square(diffs), axis=-1) + + #rerange + tmp = paddle.reshape(similary_matrix, shape=[-1, 1]) + tmp = paddle.gather(tmp, index=rerange_index) + similary_matrix = paddle.reshape(tmp, shape=[-1, self.batch_size]) + + #split + ignore, pos, neg = paddle.split( + similary_matrix, + num_or_sections=[1, samples_each_class - 1, -1], + axis=1) + + ignore.stop_gradient = True + hard_pos = paddle.max(pos, axis=1) + hard_neg = paddle.min(neg, axis=1) + + loss = hard_pos + self.margin - hard_neg + loss = paddle.nn.ReLU()(loss) + loss = paddle.mean(loss) + return {"trihardloss": loss} + + def _nomalize(self, input): + input_norm = paddle.sqrt( + paddle.sum(paddle.square(input), axis=1, keepdim=True)) + return paddle.divide(input, input_norm) diff --git a/src/PaddleClas/ppcls/loss/triplet.py b/src/PaddleClas/ppcls/loss/triplet.py new file mode 100644 index 0000000..d1c7eec --- /dev/null +++ b/src/PaddleClas/ppcls/loss/triplet.py @@ -0,0 +1,137 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import paddle +import paddle.nn as nn + + +class TripletLossV2(nn.Layer): + """Triplet loss with hard positive/negative mining. + Args: + margin (float): margin for triplet. + """ + + def __init__(self, margin=0.5, normalize_feature=True): + super(TripletLossV2, self).__init__() + self.margin = margin + self.ranking_loss = paddle.nn.loss.MarginRankingLoss(margin=margin) + self.normalize_feature = normalize_feature + + def forward(self, input, target): + """ + Args: + inputs: feature matrix with shape (batch_size, feat_dim) + target: ground truth labels with shape (num_classes) + """ + inputs = input["features"] + + if self.normalize_feature: + inputs = 1. * inputs / (paddle.expand_as( + paddle.norm( + inputs, p=2, axis=-1, keepdim=True), inputs) + 1e-12) + + bs = inputs.shape[0] + + # compute distance + dist = paddle.pow(inputs, 2).sum(axis=1, keepdim=True).expand([bs, bs]) + dist = dist + dist.t() + dist = paddle.addmm( + input=dist, x=inputs, y=inputs.t(), alpha=-2.0, beta=1.0) + dist = paddle.clip(dist, min=1e-12).sqrt() + + # hard negative mining + is_pos = paddle.expand(target, ( + bs, bs)).equal(paddle.expand(target, (bs, bs)).t()) + is_neg = paddle.expand(target, ( + bs, bs)).not_equal(paddle.expand(target, (bs, bs)).t()) + + # `dist_ap` means distance(anchor, positive) + ## both `dist_ap` and `relative_p_inds` with shape [N, 1] + ''' + dist_ap, relative_p_inds = paddle.max( + paddle.reshape(dist[is_pos], (bs, -1)), axis=1, keepdim=True) + # `dist_an` means distance(anchor, negative) + # both `dist_an` and `relative_n_inds` with shape [N, 1] + dist_an, relative_n_inds = paddle.min( + paddle.reshape(dist[is_neg], (bs, -1)), axis=1, keepdim=True) + ''' + dist_ap = paddle.max(paddle.reshape( + paddle.masked_select(dist, is_pos), (bs, -1)), + axis=1, + keepdim=True) + # `dist_an` means distance(anchor, negative) + # both `dist_an` and `relative_n_inds` with shape [N, 1] + dist_an = paddle.min(paddle.reshape( + paddle.masked_select(dist, is_neg), (bs, -1)), + axis=1, + keepdim=True) + # shape [N] + dist_ap = paddle.squeeze(dist_ap, axis=1) + dist_an = paddle.squeeze(dist_an, axis=1) + + # Compute ranking hinge loss + y = paddle.ones_like(dist_an) + loss = self.ranking_loss(dist_an, dist_ap, y) + return {"TripletLossV2": loss} + + +class TripletLoss(nn.Layer): + """Triplet loss with hard positive/negative mining. + Reference: + Hermans et al. In Defense of the Triplet Loss for Person Re-Identification. arXiv:1703.07737. + Code imported from https://github.com/Cysu/open-reid/blob/master/reid/loss/triplet.py. + Args: + margin (float): margin for triplet. + """ + + def __init__(self, margin=1.0): + super(TripletLoss, self).__init__() + self.margin = margin + self.ranking_loss = paddle.nn.loss.MarginRankingLoss(margin=margin) + + def forward(self, input, target): + """ + Args: + inputs: feature matrix with shape (batch_size, feat_dim) + target: ground truth labels with shape (num_classes) + """ + inputs = input["features"] + + bs = inputs.shape[0] + # Compute pairwise distance, replace by the official when merged + dist = paddle.pow(inputs, 2).sum(axis=1, keepdim=True).expand([bs, bs]) + dist = dist + dist.t() + dist = paddle.addmm( + input=dist, x=inputs, y=inputs.t(), alpha=-2.0, beta=1.0) + dist = paddle.clip(dist, min=1e-12).sqrt() + + mask = paddle.equal( + target.expand([bs, bs]), target.expand([bs, bs]).t()) + mask_numpy_idx = mask.numpy() + dist_ap, dist_an = [], [] + for i in range(bs): + # dist_ap_i = paddle.to_tensor(dist[i].numpy()[mask_numpy_idx[i]].max(),dtype='float64').unsqueeze(0) + # dist_ap_i.stop_gradient = False + # dist_ap.append(dist_ap_i) + dist_ap.append( + max([ + dist[i][j] if mask_numpy_idx[i][j] == True else float( + "-inf") for j in range(bs) + ]).unsqueeze(0)) + # dist_an_i = paddle.to_tensor(dist[i].numpy()[mask_numpy_idx[i] == False].min(), dtype='float64').unsqueeze(0) + # dist_an_i.stop_gradient = False + # dist_an.append(dist_an_i) + dist_an.append( + min([ + dist[i][k] if mask_numpy_idx[i][k] == False else float( + "inf") for k in range(bs) + ]).unsqueeze(0)) + + dist_ap = paddle.concat(dist_ap, axis=0) + dist_an = paddle.concat(dist_an, axis=0) + + # Compute ranking hinge loss + y = paddle.ones_like(dist_an) + loss = self.ranking_loss(dist_an, dist_ap, y) + return {"TripletLoss": loss} diff --git a/src/PaddleClas/ppcls/metric/__init__.py b/src/PaddleClas/ppcls/metric/__init__.py new file mode 100644 index 0000000..9472123 --- /dev/null +++ b/src/PaddleClas/ppcls/metric/__init__.py @@ -0,0 +1,51 @@ +#copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +#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 paddle import nn +import copy +from collections import OrderedDict + +from .metrics import TopkAcc, mAP, mINP, Recallk, Precisionk +from .metrics import DistillationTopkAcc +from .metrics import GoogLeNetTopkAcc +from .metrics import HammingDistance, AccuracyScore + + +class CombinedMetrics(nn.Layer): + def __init__(self, config_list): + super().__init__() + self.metric_func_list = [] + assert isinstance(config_list, list), ( + 'operator config should be a list') + for config in config_list: + assert isinstance(config, + dict) and len(config) == 1, "yaml format error" + metric_name = list(config)[0] + metric_params = config[metric_name] + if metric_params is not None: + self.metric_func_list.append( + eval(metric_name)(**metric_params)) + else: + self.metric_func_list.append(eval(metric_name)()) + + def __call__(self, *args, **kwargs): + metric_dict = OrderedDict() + for idx, metric_func in enumerate(self.metric_func_list): + metric_dict.update(metric_func(*args, **kwargs)) + return metric_dict + + +def build_metrics(config): + metrics_list = CombinedMetrics(copy.deepcopy(config)) + return metrics_list diff --git a/src/PaddleClas/ppcls/metric/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/metric/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..c075b76 Binary files /dev/null and b/src/PaddleClas/ppcls/metric/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/metric/__pycache__/metrics.cpython-39.pyc b/src/PaddleClas/ppcls/metric/__pycache__/metrics.cpython-39.pyc new file mode 100644 index 0000000..d7ce7f4 Binary files /dev/null and b/src/PaddleClas/ppcls/metric/__pycache__/metrics.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/metric/metrics.py b/src/PaddleClas/ppcls/metric/metrics.py new file mode 100644 index 0000000..7c6407e --- /dev/null +++ b/src/PaddleClas/ppcls/metric/metrics.py @@ -0,0 +1,309 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import numpy as np +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from sklearn.metrics import hamming_loss +from sklearn.metrics import accuracy_score as accuracy_metric +from sklearn.metrics import multilabel_confusion_matrix +from sklearn.preprocessing import binarize + + +class TopkAcc(nn.Layer): + def __init__(self, topk=(1, 5)): + super().__init__() + assert isinstance(topk, (int, list, tuple)) + if isinstance(topk, int): + topk = [topk] + self.topk = topk + + def forward(self, x, label): + if isinstance(x, dict): + x = x["logits"] + + metric_dict = dict() + for k in self.topk: + metric_dict["top{}".format(k)] = paddle.metric.accuracy( + x, label, k=k) + return metric_dict + + +class mAP(nn.Layer): + def __init__(self): + super().__init__() + + def forward(self, similarities_matrix, query_img_id, gallery_img_id, + keep_mask): + metric_dict = dict() + + choosen_indices = paddle.argsort( + similarities_matrix, axis=1, descending=True) + gallery_labels_transpose = paddle.transpose(gallery_img_id, [1, 0]) + gallery_labels_transpose = paddle.broadcast_to( + gallery_labels_transpose, + shape=[ + choosen_indices.shape[0], gallery_labels_transpose.shape[1] + ]) + choosen_label = paddle.index_sample(gallery_labels_transpose, + choosen_indices) + equal_flag = paddle.equal(choosen_label, query_img_id) + if keep_mask is not None: + keep_mask = paddle.index_sample( + keep_mask.astype('float32'), choosen_indices) + equal_flag = paddle.logical_and(equal_flag, + keep_mask.astype('bool')) + equal_flag = paddle.cast(equal_flag, 'float32') + + num_rel = paddle.sum(equal_flag, axis=1) + num_rel = paddle.greater_than(num_rel, paddle.to_tensor(0.)) + num_rel_index = paddle.nonzero(num_rel.astype("int")) + num_rel_index = paddle.reshape(num_rel_index, [num_rel_index.shape[0]]) + equal_flag = paddle.index_select(equal_flag, num_rel_index, axis=0) + + acc_sum = paddle.cumsum(equal_flag, axis=1) + div = paddle.arange(acc_sum.shape[1]).astype("float32") + 1 + precision = paddle.divide(acc_sum, div) + + #calc map + precision_mask = paddle.multiply(equal_flag, precision) + ap = paddle.sum(precision_mask, axis=1) / paddle.sum(equal_flag, + axis=1) + metric_dict["mAP"] = paddle.mean(ap).numpy()[0] + return metric_dict + + +class mINP(nn.Layer): + def __init__(self): + super().__init__() + + def forward(self, similarities_matrix, query_img_id, gallery_img_id, + keep_mask): + metric_dict = dict() + + choosen_indices = paddle.argsort( + similarities_matrix, axis=1, descending=True) + gallery_labels_transpose = paddle.transpose(gallery_img_id, [1, 0]) + gallery_labels_transpose = paddle.broadcast_to( + gallery_labels_transpose, + shape=[ + choosen_indices.shape[0], gallery_labels_transpose.shape[1] + ]) + choosen_label = paddle.index_sample(gallery_labels_transpose, + choosen_indices) + equal_flag = paddle.equal(choosen_label, query_img_id) + if keep_mask is not None: + keep_mask = paddle.index_sample( + keep_mask.astype('float32'), choosen_indices) + equal_flag = paddle.logical_and(equal_flag, + keep_mask.astype('bool')) + equal_flag = paddle.cast(equal_flag, 'float32') + + num_rel = paddle.sum(equal_flag, axis=1) + num_rel = paddle.greater_than(num_rel, paddle.to_tensor(0.)) + num_rel_index = paddle.nonzero(num_rel.astype("int")) + num_rel_index = paddle.reshape(num_rel_index, [num_rel_index.shape[0]]) + equal_flag = paddle.index_select(equal_flag, num_rel_index, axis=0) + + #do accumulative sum + div = paddle.arange(equal_flag.shape[1]).astype("float32") + 2 + minus = paddle.divide(equal_flag, div) + auxilary = paddle.subtract(equal_flag, minus) + hard_index = paddle.argmax(auxilary, axis=1).astype("float32") + all_INP = paddle.divide(paddle.sum(equal_flag, axis=1), hard_index) + mINP = paddle.mean(all_INP) + metric_dict["mINP"] = mINP.numpy()[0] + return metric_dict + + +class Recallk(nn.Layer): + def __init__(self, topk=(1, 5)): + super().__init__() + assert isinstance(topk, (int, list, tuple)) + if isinstance(topk, int): + topk = [topk] + self.topk = topk + + def forward(self, similarities_matrix, query_img_id, gallery_img_id, + keep_mask): + metric_dict = dict() + + #get cmc + choosen_indices = paddle.argsort( + similarities_matrix, axis=1, descending=True) + gallery_labels_transpose = paddle.transpose(gallery_img_id, [1, 0]) + gallery_labels_transpose = paddle.broadcast_to( + gallery_labels_transpose, + shape=[ + choosen_indices.shape[0], gallery_labels_transpose.shape[1] + ]) + choosen_label = paddle.index_sample(gallery_labels_transpose, + choosen_indices) + equal_flag = paddle.equal(choosen_label, query_img_id) + if keep_mask is not None: + keep_mask = paddle.index_sample( + keep_mask.astype('float32'), choosen_indices) + equal_flag = paddle.logical_and(equal_flag, + keep_mask.astype('bool')) + equal_flag = paddle.cast(equal_flag, 'float32') + real_query_num = paddle.sum(equal_flag, axis=1) + real_query_num = paddle.sum( + paddle.greater_than(real_query_num, paddle.to_tensor(0.)).astype( + "float32")) + + acc_sum = paddle.cumsum(equal_flag, axis=1) + mask = paddle.greater_than(acc_sum, + paddle.to_tensor(0.)).astype("float32") + all_cmc = (paddle.sum(mask, axis=0) / real_query_num).numpy() + + for k in self.topk: + metric_dict["recall{}".format(k)] = all_cmc[k - 1] + return metric_dict + + +class Precisionk(nn.Layer): + def __init__(self, topk=(1, 5)): + super().__init__() + assert isinstance(topk, (int, list, tuple)) + if isinstance(topk, int): + topk = [topk] + self.topk = topk + + def forward(self, similarities_matrix, query_img_id, gallery_img_id, + keep_mask): + metric_dict = dict() + + #get cmc + choosen_indices = paddle.argsort( + similarities_matrix, axis=1, descending=True) + gallery_labels_transpose = paddle.transpose(gallery_img_id, [1, 0]) + gallery_labels_transpose = paddle.broadcast_to( + gallery_labels_transpose, + shape=[ + choosen_indices.shape[0], gallery_labels_transpose.shape[1] + ]) + choosen_label = paddle.index_sample(gallery_labels_transpose, + choosen_indices) + equal_flag = paddle.equal(choosen_label, query_img_id) + if keep_mask is not None: + keep_mask = paddle.index_sample( + keep_mask.astype('float32'), choosen_indices) + equal_flag = paddle.logical_and(equal_flag, + keep_mask.astype('bool')) + equal_flag = paddle.cast(equal_flag, 'float32') + + Ns = paddle.arange(gallery_img_id.shape[0]) + 1 + equal_flag_cumsum = paddle.cumsum(equal_flag, axis=1) + Precision_at_k = (paddle.mean(equal_flag_cumsum, axis=0) / Ns).numpy() + + for k in self.topk: + metric_dict["precision@{}".format(k)] = Precision_at_k[k - 1] + + return metric_dict + + +class DistillationTopkAcc(TopkAcc): + def __init__(self, model_key, feature_key=None, topk=(1, 5)): + super().__init__(topk=topk) + self.model_key = model_key + self.feature_key = feature_key + + def forward(self, x, label): + if isinstance(x, dict): + x = x[self.model_key] + if self.feature_key is not None: + x = x[self.feature_key] + return super().forward(x, label) + + +class GoogLeNetTopkAcc(TopkAcc): + def __init__(self, topk=(1, 5)): + super().__init__() + assert isinstance(topk, (int, list, tuple)) + if isinstance(topk, int): + topk = [topk] + self.topk = topk + + def forward(self, x, label): + return super().forward(x[0], label) + + +class MutiLabelMetric(object): + def __init__(self): + pass + + def _multi_hot_encode(self, logits, threshold=0.5): + return binarize(logits, threshold=threshold) + + def __call__(self, output): + output = F.sigmoid(output) + preds = self._multi_hot_encode(logits=output.numpy(), threshold=0.5) + return preds + + +class HammingDistance(MutiLabelMetric): + """ + Soft metric based label for multilabel classification + Returns: + The smaller the return value is, the better model is. + """ + + def __init__(self): + super().__init__() + + def __call__(self, output, target): + preds = super().__call__(output) + metric_dict = dict() + metric_dict["HammingDistance"] = paddle.to_tensor( + hamming_loss(target, preds)) + return metric_dict + + +class AccuracyScore(MutiLabelMetric): + """ + Hard metric for multilabel classification + Args: + base: ["sample", "label"], default="sample" + if "sample", return metric score based sample, + if "label", return metric score based label. + Returns: + accuracy: + """ + + def __init__(self, base="label"): + super().__init__() + assert base in ["sample", "label" + ], 'must be one of ["sample", "label"]' + self.base = base + + def __call__(self, output, target): + preds = super().__call__(output) + metric_dict = dict() + if self.base == "sample": + accuracy = accuracy_metric(target, preds) + elif self.base == "label": + mcm = multilabel_confusion_matrix(target, preds) + tns = mcm[:, 0, 0] + fns = mcm[:, 1, 0] + tps = mcm[:, 1, 1] + fps = mcm[:, 0, 1] + accuracy = (sum(tps) + sum(tns)) / ( + sum(tps) + sum(tns) + sum(fns) + sum(fps)) + precision = sum(tps) / (sum(tps) + sum(fps)) + recall = sum(tps) / (sum(tps) + sum(fns)) + F1 = 2 * (accuracy * recall) / (accuracy + recall) + metric_dict["AccuracyScore"] = paddle.to_tensor(accuracy) + return metric_dict diff --git a/src/PaddleClas/ppcls/optimizer/__init__.py b/src/PaddleClas/ppcls/optimizer/__init__.py new file mode 100644 index 0000000..61db39f --- /dev/null +++ b/src/PaddleClas/ppcls/optimizer/__init__.py @@ -0,0 +1,72 @@ +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import copy +import paddle + +from ppcls.utils import logger + +from . import optimizer + +__all__ = ['build_optimizer'] + + +def build_lr_scheduler(lr_config, epochs, step_each_epoch): + from . import learning_rate + lr_config.update({'epochs': epochs, 'step_each_epoch': step_each_epoch}) + if 'name' in lr_config: + lr_name = lr_config.pop('name') + lr = getattr(learning_rate, lr_name)(**lr_config) + if isinstance(lr, paddle.optimizer.lr.LRScheduler): + return lr + else: + return lr() + else: + lr = lr_config['learning_rate'] + return lr + + +# model_list is None in static graph +def build_optimizer(config, epochs, step_each_epoch, model_list=None): + config = copy.deepcopy(config) + # step1 build lr + lr = build_lr_scheduler(config.pop('lr'), epochs, step_each_epoch) + logger.debug("build lr ({}) success..".format(lr)) + # step2 build regularization + if 'regularizer' in config and config['regularizer'] is not None: + if 'weight_decay' in config: + logger.warning( + "ConfigError: Only one of regularizer and weight_decay can be set in Optimizer Config. \"weight_decay\" has been ignored." + ) + reg_config = config.pop('regularizer') + reg_name = reg_config.pop('name') + 'Decay' + reg = getattr(paddle.regularizer, reg_name)(**reg_config) + config["weight_decay"] = reg + logger.debug("build regularizer ({}) success..".format(reg)) + # step3 build optimizer + optim_name = config.pop('name') + if 'clip_norm' in config: + clip_norm = config.pop('clip_norm') + grad_clip = paddle.nn.ClipGradByNorm(clip_norm=clip_norm) + else: + grad_clip = None + optim = getattr(optimizer, optim_name)(learning_rate=lr, + grad_clip=grad_clip, + **config)(model_list=model_list) + logger.debug("build optimizer ({}) success..".format(optim)) + return optim, lr diff --git a/src/PaddleClas/ppcls/optimizer/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/optimizer/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..282c4ce Binary files /dev/null and b/src/PaddleClas/ppcls/optimizer/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/optimizer/__pycache__/learning_rate.cpython-39.pyc b/src/PaddleClas/ppcls/optimizer/__pycache__/learning_rate.cpython-39.pyc new file mode 100644 index 0000000..d3b715c Binary files /dev/null and b/src/PaddleClas/ppcls/optimizer/__pycache__/learning_rate.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/optimizer/__pycache__/optimizer.cpython-39.pyc b/src/PaddleClas/ppcls/optimizer/__pycache__/optimizer.cpython-39.pyc new file mode 100644 index 0000000..7d244ac Binary files /dev/null and b/src/PaddleClas/ppcls/optimizer/__pycache__/optimizer.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/optimizer/learning_rate.py b/src/PaddleClas/ppcls/optimizer/learning_rate.py new file mode 100644 index 0000000..b59387d --- /dev/null +++ b/src/PaddleClas/ppcls/optimizer/learning_rate.py @@ -0,0 +1,326 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import (absolute_import, division, print_function, + unicode_literals) + +from paddle.optimizer import lr +from paddle.optimizer.lr import LRScheduler + +from ppcls.utils import logger + + +class Linear(object): + """ + Linear learning rate decay + Args: + lr (float): The initial learning rate. It is a python float number. + epochs(int): The decay step size. It determines the decay cycle. + end_lr(float, optional): The minimum final learning rate. Default: 0.0001. + power(float, optional): Power of polynomial. Default: 1.0. + warmup_epoch(int): The epoch numbers for LinearWarmup. Default: 0. + warmup_start_lr(float): Initial learning rate of warm up. Default: 0.0. + last_epoch (int, optional): The index of last epoch. Can be set to restart training. Default: -1, means initial learning rate. + """ + + def __init__(self, + learning_rate, + epochs, + step_each_epoch, + end_lr=0.0, + power=1.0, + warmup_epoch=0, + warmup_start_lr=0.0, + last_epoch=-1, + **kwargs): + super().__init__() + if warmup_epoch >= epochs: + msg = f"When using warm up, the value of \"Global.epochs\" must be greater than value of \"Optimizer.lr.warmup_epoch\". The value of \"Optimizer.lr.warmup_epoch\" has been set to {epochs}." + logger.warning(msg) + warmup_epoch = epochs + self.learning_rate = learning_rate + self.steps = (epochs - warmup_epoch) * step_each_epoch + self.end_lr = end_lr + self.power = power + self.last_epoch = last_epoch + self.warmup_steps = round(warmup_epoch * step_each_epoch) + self.warmup_start_lr = warmup_start_lr + + def __call__(self): + learning_rate = lr.PolynomialDecay( + learning_rate=self.learning_rate, + decay_steps=self.steps, + end_lr=self.end_lr, + power=self.power, + last_epoch=self. + last_epoch) if self.steps > 0 else self.learning_rate + if self.warmup_steps > 0: + learning_rate = lr.LinearWarmup( + learning_rate=learning_rate, + warmup_steps=self.warmup_steps, + start_lr=self.warmup_start_lr, + end_lr=self.learning_rate, + last_epoch=self.last_epoch) + return learning_rate + + +class Cosine(object): + """ + Cosine learning rate decay + lr = 0.05 * (math.cos(epoch * (math.pi / epochs)) + 1) + Args: + lr(float): initial learning rate + step_each_epoch(int): steps each epoch + epochs(int): total training epochs + eta_min(float): Minimum learning rate. Default: 0.0. + warmup_epoch(int): The epoch numbers for LinearWarmup. Default: 0. + warmup_start_lr(float): Initial learning rate of warm up. Default: 0.0. + last_epoch (int, optional): The index of last epoch. Can be set to restart training. Default: -1, means initial learning rate. + """ + + def __init__(self, + learning_rate, + step_each_epoch, + epochs, + eta_min=0.0, + warmup_epoch=0, + warmup_start_lr=0.0, + last_epoch=-1, + **kwargs): + super().__init__() + if warmup_epoch >= epochs: + msg = f"When using warm up, the value of \"Global.epochs\" must be greater than value of \"Optimizer.lr.warmup_epoch\". The value of \"Optimizer.lr.warmup_epoch\" has been set to {epochs}." + logger.warning(msg) + warmup_epoch = epochs + self.learning_rate = learning_rate + self.T_max = (epochs - warmup_epoch) * step_each_epoch + self.eta_min = eta_min + self.last_epoch = last_epoch + self.warmup_steps = round(warmup_epoch * step_each_epoch) + self.warmup_start_lr = warmup_start_lr + + def __call__(self): + learning_rate = lr.CosineAnnealingDecay( + learning_rate=self.learning_rate, + T_max=self.T_max, + eta_min=self.eta_min, + last_epoch=self. + last_epoch) if self.T_max > 0 else self.learning_rate + if self.warmup_steps > 0: + learning_rate = lr.LinearWarmup( + learning_rate=learning_rate, + warmup_steps=self.warmup_steps, + start_lr=self.warmup_start_lr, + end_lr=self.learning_rate, + last_epoch=self.last_epoch) + return learning_rate + + +class Step(object): + """ + Piecewise learning rate decay + Args: + step_each_epoch(int): steps each epoch + learning_rate (float): The initial learning rate. It is a python float number. + step_size (int): the interval to update. + gamma (float, optional): The Ratio that the learning rate will be reduced. ``new_lr = origin_lr * gamma`` . + It should be less than 1.0. Default: 0.1. + warmup_epoch(int): The epoch numbers for LinearWarmup. Default: 0. + warmup_start_lr(float): Initial learning rate of warm up. Default: 0.0. + last_epoch (int, optional): The index of last epoch. Can be set to restart training. Default: -1, means initial learning rate. + """ + + def __init__(self, + learning_rate, + step_size, + step_each_epoch, + epochs, + gamma, + warmup_epoch=0, + warmup_start_lr=0.0, + last_epoch=-1, + **kwargs): + super().__init__() + if warmup_epoch >= epochs: + msg = f"When using warm up, the value of \"Global.epochs\" must be greater than value of \"Optimizer.lr.warmup_epoch\". The value of \"Optimizer.lr.warmup_epoch\" has been set to {epochs}." + logger.warning(msg) + warmup_epoch = epochs + self.step_size = step_each_epoch * step_size + self.learning_rate = learning_rate + self.gamma = gamma + self.last_epoch = last_epoch + self.warmup_steps = round(warmup_epoch * step_each_epoch) + self.warmup_start_lr = warmup_start_lr + + def __call__(self): + learning_rate = lr.StepDecay( + learning_rate=self.learning_rate, + step_size=self.step_size, + gamma=self.gamma, + last_epoch=self.last_epoch) + if self.warmup_steps > 0: + learning_rate = lr.LinearWarmup( + learning_rate=learning_rate, + warmup_steps=self.warmup_steps, + start_lr=self.warmup_start_lr, + end_lr=self.learning_rate, + last_epoch=self.last_epoch) + return learning_rate + + +class Piecewise(object): + """ + Piecewise learning rate decay + Args: + boundaries(list): A list of steps numbers. The type of element in the list is python int. + values(list): A list of learning rate values that will be picked during different epoch boundaries. + The type of element in the list is python float. + warmup_epoch(int): The epoch numbers for LinearWarmup. Default: 0. + warmup_start_lr(float): Initial learning rate of warm up. Default: 0.0. + last_epoch (int, optional): The index of last epoch. Can be set to restart training. Default: -1, means initial learning rate. + """ + + def __init__(self, + step_each_epoch, + decay_epochs, + values, + epochs, + warmup_epoch=0, + warmup_start_lr=0.0, + last_epoch=-1, + **kwargs): + super().__init__() + if warmup_epoch >= epochs: + msg = f"When using warm up, the value of \"Global.epochs\" must be greater than value of \"Optimizer.lr.warmup_epoch\". The value of \"Optimizer.lr.warmup_epoch\" has been set to {epochs}." + logger.warning(msg) + warmup_epoch = epochs + self.boundaries = [step_each_epoch * e for e in decay_epochs] + self.values = values + self.last_epoch = last_epoch + self.warmup_steps = round(warmup_epoch * step_each_epoch) + self.warmup_start_lr = warmup_start_lr + + def __call__(self): + learning_rate = lr.PiecewiseDecay( + boundaries=self.boundaries, + values=self.values, + last_epoch=self.last_epoch) + if self.warmup_steps > 0: + learning_rate = lr.LinearWarmup( + learning_rate=learning_rate, + warmup_steps=self.warmup_steps, + start_lr=self.warmup_start_lr, + end_lr=self.values[0], + last_epoch=self.last_epoch) + return learning_rate + + +class MultiStepDecay(LRScheduler): + """ + Update the learning rate by ``gamma`` once ``epoch`` reaches one of the milestones. + The algorithm can be described as the code below. + .. code-block:: text + learning_rate = 0.5 + milestones = [30, 50] + gamma = 0.1 + if epoch < 30: + learning_rate = 0.5 + elif epoch < 50: + learning_rate = 0.05 + else: + learning_rate = 0.005 + Args: + learning_rate (float): The initial learning rate. It is a python float number. + milestones (tuple|list): List or tuple of each boundaries. Must be increasing. + gamma (float, optional): The Ratio that the learning rate will be reduced. ``new_lr = origin_lr * gamma`` . + It should be less than 1.0. Default: 0.1. + last_epoch (int, optional): The index of last epoch. Can be set to restart training. Default: -1, means initial learning rate. + verbose (bool, optional): If ``True``, prints a message to stdout for each update. Default: ``False`` . + + Returns: + ``MultiStepDecay`` instance to schedule learning rate. + Examples: + + .. code-block:: python + import paddle + import numpy as np + # train on default dynamic graph mode + linear = paddle.nn.Linear(10, 10) + scheduler = paddle.optimizer.lr.MultiStepDecay(learning_rate=0.5, milestones=[2, 4, 6], gamma=0.8, verbose=True) + sgd = paddle.optimizer.SGD(learning_rate=scheduler, parameters=linear.parameters()) + for epoch in range(20): + for batch_id in range(5): + x = paddle.uniform([10, 10]) + out = linear(x) + loss = paddle.mean(out) + loss.backward() + sgd.step() + sgd.clear_gradients() + scheduler.step() # If you update learning rate each step + # scheduler.step() # If you update learning rate each epoch + # train on static graph mode + paddle.enable_static() + main_prog = paddle.static.Program() + start_prog = paddle.static.Program() + with paddle.static.program_guard(main_prog, start_prog): + x = paddle.static.data(name='x', shape=[None, 4, 5]) + y = paddle.static.data(name='y', shape=[None, 4, 5]) + z = paddle.static.nn.fc(x, 100) + loss = paddle.mean(z) + scheduler = paddle.optimizer.lr.MultiStepDecay(learning_rate=0.5, milestones=[2, 4, 6], gamma=0.8, verbose=True) + sgd = paddle.optimizer.SGD(learning_rate=scheduler) + sgd.minimize(loss) + exe = paddle.static.Executor() + exe.run(start_prog) + for epoch in range(20): + for batch_id in range(5): + out = exe.run( + main_prog, + feed={ + 'x': np.random.randn(3, 4, 5).astype('float32'), + 'y': np.random.randn(3, 4, 5).astype('float32') + }, + fetch_list=loss.name) + scheduler.step() # If you update learning rate each step + # scheduler.step() # If you update learning rate each epoch + """ + + def __init__(self, + learning_rate, + milestones, + epochs, + step_each_epoch, + gamma=0.1, + last_epoch=-1, + verbose=False): + if not isinstance(milestones, (tuple, list)): + raise TypeError( + "The type of 'milestones' in 'MultiStepDecay' must be 'tuple, list', but received %s." + % type(milestones)) + if not all([ + milestones[i] < milestones[i + 1] + for i in range(len(milestones) - 1) + ]): + raise ValueError('The elements of milestones must be incremented') + if gamma >= 1.0: + raise ValueError('gamma should be < 1.0.') + self.milestones = [x * step_each_epoch for x in milestones] + self.gamma = gamma + super().__init__(learning_rate, last_epoch, verbose) + + def get_lr(self): + for i in range(len(self.milestones)): + if self.last_epoch < self.milestones[i]: + return self.base_lr * (self.gamma**i) + return self.base_lr * (self.gamma**len(self.milestones)) diff --git a/src/PaddleClas/ppcls/optimizer/optimizer.py b/src/PaddleClas/ppcls/optimizer/optimizer.py new file mode 100644 index 0000000..4422ea7 --- /dev/null +++ b/src/PaddleClas/ppcls/optimizer/optimizer.py @@ -0,0 +1,217 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from paddle import optimizer as optim +import paddle + +from ppcls.utils import logger + + +class Momentum(object): + """ + Simple Momentum optimizer with velocity state. + Args: + learning_rate (float|Variable) - The learning rate used to update parameters. + Can be a float value or a Variable with one float value as data element. + momentum (float) - Momentum factor. + regularization (WeightDecayRegularizer, optional) - The strategy of regularization. + """ + + def __init__(self, + learning_rate, + momentum, + weight_decay=None, + grad_clip=None, + multi_precision=True): + super().__init__() + self.learning_rate = learning_rate + self.momentum = momentum + self.weight_decay = weight_decay + self.grad_clip = grad_clip + self.multi_precision = multi_precision + + def __call__(self, model_list): + # model_list is None in static graph + parameters = sum([m.parameters() for m in model_list], + []) if model_list else None + opt = optim.Momentum( + learning_rate=self.learning_rate, + momentum=self.momentum, + weight_decay=self.weight_decay, + grad_clip=self.grad_clip, + multi_precision=self.multi_precision, + parameters=parameters) + if hasattr(opt, '_use_multi_tensor'): + opt = optim.Momentum( + learning_rate=self.learning_rate, + momentum=self.momentum, + weight_decay=self.weight_decay, + grad_clip=self.grad_clip, + multi_precision=self.multi_precision, + parameters=parameters, + use_multi_tensor=True) + return opt + + +class Adam(object): + def __init__(self, + learning_rate=0.001, + beta1=0.9, + beta2=0.999, + epsilon=1e-08, + parameter_list=None, + weight_decay=None, + grad_clip=None, + name=None, + lazy_mode=False, + multi_precision=False): + self.learning_rate = learning_rate + self.beta1 = beta1 + self.beta2 = beta2 + self.epsilon = epsilon + self.parameter_list = parameter_list + self.learning_rate = learning_rate + self.weight_decay = weight_decay + self.grad_clip = grad_clip + self.name = name + self.lazy_mode = lazy_mode + self.multi_precision = multi_precision + + def __call__(self, model_list): + # model_list is None in static graph + parameters = sum([m.parameters() for m in model_list], + []) if model_list else None + opt = optim.Adam( + learning_rate=self.learning_rate, + beta1=self.beta1, + beta2=self.beta2, + epsilon=self.epsilon, + weight_decay=self.weight_decay, + grad_clip=self.grad_clip, + name=self.name, + lazy_mode=self.lazy_mode, + multi_precision=self.multi_precision, + parameters=parameters) + return opt + + +class RMSProp(object): + """ + Root Mean Squared Propagation (RMSProp) is an unpublished, adaptive learning rate method. + Args: + learning_rate (float|Variable) - The learning rate used to update parameters. + Can be a float value or a Variable with one float value as data element. + momentum (float) - Momentum factor. + rho (float) - rho value in equation. + epsilon (float) - avoid division by zero, default is 1e-6. + regularization (WeightDecayRegularizer, optional) - The strategy of regularization. + """ + + def __init__(self, + learning_rate, + momentum=0.0, + rho=0.95, + epsilon=1e-6, + weight_decay=None, + grad_clip=None, + multi_precision=False): + super().__init__() + self.learning_rate = learning_rate + self.momentum = momentum + self.rho = rho + self.epsilon = epsilon + self.weight_decay = weight_decay + self.grad_clip = grad_clip + + def __call__(self, model_list): + # model_list is None in static graph + parameters = sum([m.parameters() for m in model_list], + []) if model_list else None + opt = optim.RMSProp( + learning_rate=self.learning_rate, + momentum=self.momentum, + rho=self.rho, + epsilon=self.epsilon, + weight_decay=self.weight_decay, + grad_clip=self.grad_clip, + parameters=parameters) + return opt + + +class AdamW(object): + def __init__(self, + learning_rate=0.001, + beta1=0.9, + beta2=0.999, + epsilon=1e-8, + weight_decay=None, + multi_precision=False, + grad_clip=None, + no_weight_decay_name=None, + one_dim_param_no_weight_decay=False, + **args): + super().__init__() + self.learning_rate = learning_rate + self.beta1 = beta1 + self.beta2 = beta2 + self.epsilon = epsilon + self.grad_clip = grad_clip + self.weight_decay = weight_decay + self.multi_precision = multi_precision + self.no_weight_decay_name_list = no_weight_decay_name.split( + ) if no_weight_decay_name else [] + self.one_dim_param_no_weight_decay = one_dim_param_no_weight_decay + + def __call__(self, model_list): + # model_list is None in static graph + parameters = sum([m.parameters() for m in model_list], + []) if model_list else None + + # TODO(gaotingquan): model_list is None when in static graph, "no_weight_decay" not work. + if model_list is None: + if self.one_dim_param_no_weight_decay or len( + self.no_weight_decay_name_list) != 0: + msg = "\"AdamW\" does not support setting \"no_weight_decay\" in static graph. Please use dynamic graph." + logger.error(Exception(msg)) + raise Exception(msg) + + self.no_weight_decay_param_name_list = [ + p.name for model in model_list for n, p in model.named_parameters() + if any(nd in n for nd in self.no_weight_decay_name_list) + ] if model_list else [] + + if self.one_dim_param_no_weight_decay: + self.no_weight_decay_param_name_list += [ + p.name for model in model_list + for n, p in model.named_parameters() if len(p.shape) == 1 + ] if model_list else [] + + opt = optim.AdamW( + learning_rate=self.learning_rate, + beta1=self.beta1, + beta2=self.beta2, + epsilon=self.epsilon, + parameters=parameters, + weight_decay=self.weight_decay, + multi_precision=self.multi_precision, + grad_clip=self.grad_clip, + apply_decay_param_fun=self._apply_decay_param_fun) + return opt + + def _apply_decay_param_fun(self, name): + return name not in self.no_weight_decay_param_name_list diff --git a/src/PaddleClas/ppcls/static/program.py b/src/PaddleClas/ppcls/static/program.py new file mode 100644 index 0000000..b3534a2 --- /dev/null +++ b/src/PaddleClas/ppcls/static/program.py @@ -0,0 +1,449 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +import time +import numpy as np + +from collections import OrderedDict + +import paddle +import paddle.nn.functional as F + +from paddle.distributed import fleet +from paddle.distributed.fleet import DistributedStrategy + +# from ppcls.optimizer import OptimizerBuilder +# from ppcls.optimizer.learning_rate import LearningRateBuilder + +from ppcls.arch import build_model +from ppcls.loss import build_loss +from ppcls.metric import build_metrics +from ppcls.optimizer import build_optimizer +from ppcls.optimizer import build_lr_scheduler + +from ppcls.utils.misc import AverageMeter +from ppcls.utils import logger, profiler + + +def create_feeds(image_shape, use_mix=False, class_num=None, dtype="float32"): + """ + Create feeds as model input + + Args: + image_shape(list[int]): model input shape, such as [3, 224, 224] + use_mix(bool): whether to use mix(include mixup, cutmix, fmix) + class_num(int): the class number of network, required if use_mix + + Returns: + feeds(dict): dict of model input variables + """ + feeds = OrderedDict() + feeds['data'] = paddle.static.data( + name="data", shape=[None] + image_shape, dtype=dtype) + + if use_mix: + if class_num is None: + msg = "When use MixUp, CutMix and so on, you must set class_num." + logger.error(msg) + raise Exception(msg) + feeds['target'] = paddle.static.data( + name="target", shape=[None, class_num], dtype="float32") + else: + feeds['label'] = paddle.static.data( + name="label", shape=[None, 1], dtype="int64") + + return feeds + + +def create_fetchs(out, + feeds, + architecture, + topk=5, + epsilon=None, + class_num=None, + use_mix=False, + config=None, + mode="Train"): + """ + Create fetchs as model outputs(included loss and measures), + will call create_loss and create_metric(if use_mix). + Args: + out(variable): model output variable + feeds(dict): dict of model input variables. + If use mix_up, it will not include label. + architecture(dict): architecture information, + name(such as ResNet50) is needed + topk(int): usually top5 + epsilon(float): parameter for label smoothing, 0.0 <= epsilon <= 1.0 + class_num(int): the class number of network, required if use_mix + use_mix(bool): whether to use mix(include mixup, cutmix, fmix) + config(dict): model config + + Returns: + fetchs(dict): dict of model outputs(included loss and measures) + """ + fetchs = OrderedDict() + # build loss + if use_mix: + if class_num is None: + msg = "When use MixUp, CutMix and so on, you must set class_num." + logger.error(msg) + raise Exception(msg) + target = paddle.reshape(feeds['target'], [-1, class_num]) + else: + target = paddle.reshape(feeds['label'], [-1, 1]) + + loss_func = build_loss(config["Loss"][mode]) + loss_dict = loss_func(out, target) + + loss_out = loss_dict["loss"] + fetchs['loss'] = (loss_out, AverageMeter('loss', '7.4f', need_avg=True)) + + # build metric + if not use_mix: + metric_func = build_metrics(config["Metric"][mode]) + + metric_dict = metric_func(out, target) + + for key in metric_dict: + if mode != "Train" and paddle.distributed.get_world_size() > 1: + paddle.distributed.all_reduce( + metric_dict[key], op=paddle.distributed.ReduceOp.SUM) + metric_dict[key] = metric_dict[ + key] / paddle.distributed.get_world_size() + + fetchs[key] = (metric_dict[key], AverageMeter( + key, '7.4f', need_avg=True)) + + return fetchs + + +def create_optimizer(config, step_each_epoch): + # create learning_rate instance + optimizer, lr_sch = build_optimizer( + config["Optimizer"], config["Global"]["epochs"], step_each_epoch) + return optimizer, lr_sch + + +def create_strategy(config): + """ + Create build strategy and exec strategy. + + Args: + config(dict): config + + Returns: + build_strategy: build strategy + exec_strategy: exec strategy + """ + build_strategy = paddle.static.BuildStrategy() + exec_strategy = paddle.static.ExecutionStrategy() + + exec_strategy.num_threads = 1 + exec_strategy.num_iteration_per_drop_scope = ( + 10000 + if 'AMP' in config and config.AMP.get("level", "O1") == "O2" else 10) + + fuse_op = True if 'AMP' in config else False + + fuse_bn_act_ops = config.get('fuse_bn_act_ops', fuse_op) + fuse_elewise_add_act_ops = config.get('fuse_elewise_add_act_ops', fuse_op) + fuse_bn_add_act_ops = config.get('fuse_bn_add_act_ops', fuse_op) + enable_addto = config.get('enable_addto', fuse_op) + + build_strategy.fuse_bn_act_ops = fuse_bn_act_ops + build_strategy.fuse_elewise_add_act_ops = fuse_elewise_add_act_ops + build_strategy.fuse_bn_add_act_ops = fuse_bn_add_act_ops + build_strategy.enable_addto = enable_addto + + return build_strategy, exec_strategy + + +def dist_optimizer(config, optimizer): + """ + Create a distributed optimizer based on a normal optimizer + + Args: + config(dict): + optimizer(): a normal optimizer + + Returns: + optimizer: a distributed optimizer + """ + build_strategy, exec_strategy = create_strategy(config) + + dist_strategy = DistributedStrategy() + dist_strategy.execution_strategy = exec_strategy + dist_strategy.build_strategy = build_strategy + + dist_strategy.nccl_comm_num = 1 + dist_strategy.fuse_all_reduce_ops = True + dist_strategy.fuse_grad_size_in_MB = 16 + optimizer = fleet.distributed_optimizer(optimizer, strategy=dist_strategy) + + return optimizer + + +def mixed_precision_optimizer(config, optimizer): + if 'AMP' in config: + amp_cfg = config.AMP if config.AMP else dict() + scale_loss = amp_cfg.get('scale_loss', 1.0) + use_dynamic_loss_scaling = amp_cfg.get('use_dynamic_loss_scaling', + False) + use_pure_fp16 = amp_cfg.get("level", "O1") == "O2" + optimizer = paddle.static.amp.decorate( + optimizer, + init_loss_scaling=scale_loss, + use_dynamic_loss_scaling=use_dynamic_loss_scaling, + use_pure_fp16=use_pure_fp16, + use_fp16_guard=True) + + return optimizer + + +def build(config, + main_prog, + startup_prog, + class_num=None, + step_each_epoch=100, + is_train=True, + is_distributed=True): + """ + Build a program using a model and an optimizer + 1. create feeds + 2. create a dataloader + 3. create a model + 4. create fetchs + 5. create an optimizer + + Args: + config(dict): config + main_prog(): main program + startup_prog(): startup program + class_num(int): the class number of network, required if use_mix + is_train(bool): train or eval + is_distributed(bool): whether to use distributed training method + + Returns: + dataloader(): a bridge between the model and the data + fetchs(dict): dict of model outputs(included loss and measures) + """ + with paddle.static.program_guard(main_prog, startup_prog): + with paddle.utils.unique_name.guard(): + mode = "Train" if is_train else "Eval" + use_mix = "batch_transform_ops" in config["DataLoader"][mode][ + "dataset"] + feeds = create_feeds( + config["Global"]["image_shape"], + use_mix, + class_num=class_num, + dtype="float32") + + # build model + # data_format should be assigned in arch-dict + input_image_channel = config["Global"]["image_shape"][ + 0] # default as [3, 224, 224] + model = build_model(config) + out = model(feeds["data"]) + # end of build model + + fetchs = create_fetchs( + out, + feeds, + config["Arch"], + epsilon=config.get('ls_epsilon'), + class_num=class_num, + use_mix=use_mix, + config=config, + mode=mode) + lr_scheduler = None + optimizer = None + if is_train: + optimizer, lr_scheduler = build_optimizer( + config["Optimizer"], config["Global"]["epochs"], + step_each_epoch) + optimizer = mixed_precision_optimizer(config, optimizer) + if is_distributed: + optimizer = dist_optimizer(config, optimizer) + optimizer.minimize(fetchs['loss'][0]) + return fetchs, lr_scheduler, feeds, optimizer + + +def compile(config, program, loss_name=None, share_prog=None): + """ + Compile the program + + Args: + config(dict): config + program(): the program which is wrapped by + loss_name(str): loss name + share_prog(): the shared program, used for evaluation during training + + Returns: + compiled_program(): a compiled program + """ + build_strategy, exec_strategy = create_strategy(config) + + compiled_program = paddle.static.CompiledProgram( + program).with_data_parallel( + share_vars_from=share_prog, + loss_name=loss_name, + build_strategy=build_strategy, + exec_strategy=exec_strategy) + + return compiled_program + + +total_step = 0 + + +def run(dataloader, + exe, + program, + feeds, + fetchs, + epoch=0, + mode='train', + config=None, + vdl_writer=None, + lr_scheduler=None, + profiler_options=None): + """ + Feed data to the model and fetch the measures and loss + + Args: + dataloader(paddle io dataloader): + exe(): + program(): + fetchs(dict): dict of measures and the loss + epoch(int): epoch of training or evaluation + model(str): log only + + Returns: + """ + fetch_list = [f[0] for f in fetchs.values()] + metric_dict = OrderedDict([("lr", AverageMeter( + 'lr', 'f', postfix=",", need_avg=False))]) + + for k in fetchs: + metric_dict[k] = fetchs[k][1] + + metric_dict["batch_time"] = AverageMeter( + 'batch_cost', '.5f', postfix=" s,") + metric_dict["reader_time"] = AverageMeter( + 'reader_cost', '.5f', postfix=" s,") + + for m in metric_dict.values(): + m.reset() + + use_dali = config["Global"].get('use_dali', False) + tic = time.time() + + if not use_dali: + dataloader = dataloader() + + idx = 0 + batch_size = None + while True: + # The DALI maybe raise RuntimeError for some particular images, such as ImageNet1k/n04418357_26036.JPEG + try: + batch = next(dataloader) + except StopIteration: + break + except RuntimeError: + logger.warning( + "Except RuntimeError when reading data from dataloader, try to read once again..." + ) + continue + idx += 1 + # ignore the warmup iters + if idx == 5: + metric_dict["batch_time"].reset() + metric_dict["reader_time"].reset() + + metric_dict['reader_time'].update(time.time() - tic) + + profiler.add_profiler_step(profiler_options) + + if use_dali: + batch_size = batch[0]["data"].shape()[0] + feed_dict = batch[0] + else: + batch_size = batch[0].shape()[0] + feed_dict = { + key.name: batch[idx] + for idx, key in enumerate(feeds.values()) + } + + metrics = exe.run(program=program, + feed=feed_dict, + fetch_list=fetch_list) + + for name, m in zip(fetchs.keys(), metrics): + metric_dict[name].update(np.mean(m), batch_size) + metric_dict["batch_time"].update(time.time() - tic) + if mode == "train": + metric_dict['lr'].update(lr_scheduler.get_lr()) + + fetchs_str = ' '.join([ + str(metric_dict[key].mean) + if "time" in key else str(metric_dict[key].value) + for key in metric_dict + ]) + ips_info = " ips: {:.5f} images/sec.".format( + batch_size / metric_dict["batch_time"].avg) + fetchs_str += ips_info + + if lr_scheduler is not None: + lr_scheduler.step() + + if vdl_writer: + global total_step + logger.scaler('loss', metrics[0][0], total_step, vdl_writer) + total_step += 1 + if mode == 'eval': + if idx % config.get('print_interval', 10) == 0: + logger.info("{:s} step:{:<4d} {:s}".format(mode, idx, + fetchs_str)) + else: + epoch_str = "epoch:{:<3d}".format(epoch) + step_str = "{:s} step:{:<4d}".format(mode, idx) + + if idx % config.get('print_interval', 10) == 0: + logger.info("{:s} {:s} {:s}".format(epoch_str, step_str, + fetchs_str)) + + tic = time.time() + + end_str = ' '.join([str(m.mean) for m in metric_dict.values()] + + [metric_dict["batch_time"].total]) + ips_info = "ips: {:.5f} images/sec.".format(batch_size / + metric_dict["batch_time"].avg) + if mode == 'eval': + logger.info("END {:s} {:s} {:s}".format(mode, end_str, ips_info)) + else: + end_epoch_str = "END epoch:{:<3d}".format(epoch) + logger.info("{:s} {:s} {:s} {:s}".format(end_epoch_str, mode, end_str, + ips_info)) + if use_dali: + dataloader.reset() + + # return top1_acc in order to save the best model + if mode == 'eval': + return fetchs["top1"][1].avg diff --git a/src/PaddleClas/ppcls/static/run_dali.sh b/src/PaddleClas/ppcls/static/run_dali.sh new file mode 100644 index 0000000..5bf0ef4 --- /dev/null +++ b/src/PaddleClas/ppcls/static/run_dali.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +export CUDA_VISIBLE_DEVICES="0,1,2,3" + +python3.7 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + ppcls/static/train.py \ + -c ./ppcls/configs/ImageNet/ResNet/ResNet50_amp_O1.yaml diff --git a/src/PaddleClas/ppcls/static/save_load.py b/src/PaddleClas/ppcls/static/save_load.py new file mode 100644 index 0000000..13badfd --- /dev/null +++ b/src/PaddleClas/ppcls/static/save_load.py @@ -0,0 +1,139 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import errno +import os +import re +import shutil +import tempfile + +import paddle + +from ppcls.utils import logger + +__all__ = ['init_model', 'save_model'] + + +def _mkdir_if_not_exist(path): + """ + mkdir if not exists, ignore the exception when multiprocess mkdir together + """ + if not os.path.exists(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(path): + logger.warning( + 'be happy if some process has already created {}'.format( + path)) + else: + raise OSError('Failed to mkdir {}'.format(path)) + + +def _load_state(path): + if os.path.exists(path + '.pdopt'): + # XXX another hack to ignore the optimizer state + tmp = tempfile.mkdtemp() + dst = os.path.join(tmp, os.path.basename(os.path.normpath(path))) + shutil.copy(path + '.pdparams', dst + '.pdparams') + state = paddle.static.load_program_state(dst) + shutil.rmtree(tmp) + else: + state = paddle.static.load_program_state(path) + return state + + +def load_params(exe, prog, path, ignore_params=None): + """ + Load model from the given path. + Args: + exe (fluid.Executor): The fluid.Executor object. + prog (fluid.Program): load weight to which Program object. + path (string): URL string or loca model path. + ignore_params (list): ignore variable to load when finetuning. + It can be specified by finetune_exclude_pretrained_params + and the usage can refer to the document + docs/advanced_tutorials/TRANSFER_LEARNING.md + """ + if not (os.path.isdir(path) or os.path.exists(path + '.pdparams')): + raise ValueError("Model pretrain path {} does not " + "exists.".format(path)) + + logger.info("Loading parameters from {}...".format(path)) + + ignore_set = set() + state = _load_state(path) + + # ignore the parameter which mismatch the shape + # between the model and pretrain weight. + all_var_shape = {} + for block in prog.blocks: + for param in block.all_parameters(): + all_var_shape[param.name] = param.shape + ignore_set.update([ + name for name, shape in all_var_shape.items() + if name in state and shape != state[name].shape + ]) + + if ignore_params: + all_var_names = [var.name for var in prog.list_vars()] + ignore_list = filter( + lambda var: any([re.match(name, var) for name in ignore_params]), + all_var_names) + ignore_set.update(list(ignore_list)) + + if len(ignore_set) > 0: + for k in ignore_set: + if k in state: + logger.warning( + 'variable {} is already excluded automatically'.format(k)) + del state[k] + + paddle.static.set_program_state(prog, state) + + +def init_model(config, program, exe): + """ + load model from checkpoint or pretrained_model + """ + checkpoints = config.get('checkpoints') + if checkpoints: + paddle.static.load(program, checkpoints, exe) + logger.info("Finish initing model from {}".format(checkpoints)) + return + + pretrained_model = config.get('pretrained_model') + if pretrained_model: + if not isinstance(pretrained_model, list): + pretrained_model = [pretrained_model] + for pretrain in pretrained_model: + load_params(exe, program, pretrain) + logger.info("Finish initing model from {}".format(pretrained_model)) + + +def save_model(program, model_path, epoch_id, prefix='ppcls'): + """ + save model to the target path + """ + if paddle.distributed.get_rank() != 0: + return + model_path = os.path.join(model_path, str(epoch_id)) + _mkdir_if_not_exist(model_path) + model_prefix = os.path.join(model_path, prefix) + paddle.static.save(program, model_prefix) + logger.info("Already save model in {}".format(model_path)) diff --git a/src/PaddleClas/ppcls/static/train.py b/src/PaddleClas/ppcls/static/train.py new file mode 100644 index 0000000..9c03598 --- /dev/null +++ b/src/PaddleClas/ppcls/static/train.py @@ -0,0 +1,209 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(__dir__) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../../'))) + +import paddle +from paddle.distributed import fleet +from visualdl import LogWriter + +from ppcls.data import build_dataloader +from ppcls.utils.config import get_config, print_config +from ppcls.utils import logger +from ppcls.utils.logger import init_logger +from ppcls.static.save_load import init_model, save_model +from ppcls.static import program + + +def parse_args(): + parser = argparse.ArgumentParser("PaddleClas train script") + parser.add_argument( + '-c', + '--config', + type=str, + default='configs/ResNet/ResNet50.yaml', + help='config file path') + parser.add_argument( + '-p', + '--profiler_options', + type=str, + default=None, + help='The option of profiler, which should be in format \"key1=value1;key2=value2;key3=value3\".' + ) + parser.add_argument( + '-o', + '--override', + action='append', + default=[], + help='config options to be overridden') + args = parser.parse_args() + return args + + +def main(args): + """ + all the config of training paradigm should be in config["Global"] + """ + config = get_config(args.config, overrides=args.override, show=False) + global_config = config["Global"] + + mode = "train" + + log_file = os.path.join(global_config['output_dir'], + config["Arch"]["name"], f"{mode}.log") + init_logger(name='root', log_file=log_file) + print_config(config) + + if global_config.get("is_distributed", True): + fleet.init(is_collective=True) + # assign the device + use_gpu = global_config.get("use_gpu", True) + # amp related config + if 'AMP' in config: + AMP_RELATED_FLAGS_SETTING = { + 'FLAGS_cudnn_exhaustive_search': 1, + 'FLAGS_conv_workspace_size_limit': 1500, + 'FLAGS_cudnn_batchnorm_spatial_persistent': 1, + 'FLAGS_max_inplace_grad_add': 8, + } + os.environ['FLAGS_cudnn_batchnorm_spatial_persistent'] = '1' + paddle.fluid.set_flags(AMP_RELATED_FLAGS_SETTING) + + use_xpu = global_config.get("use_xpu", False) + use_npu = global_config.get("use_npu", False) + assert ( + use_gpu and use_xpu and use_npu + ) is not True, "gpu, xpu and npu can not be true in the same time in static mode!" + + if use_gpu: + device = paddle.set_device('gpu') + elif use_xpu: + device = paddle.set_device('xpu') + elif use_npu: + device = paddle.set_device('npu') + else: + device = paddle.set_device('cpu') + + # visualDL + vdl_writer = None + if global_config["use_visualdl"]: + vdl_dir = os.path.join(global_config["output_dir"], "vdl") + vdl_writer = LogWriter(vdl_dir) + + # build dataloader + eval_dataloader = None + use_dali = global_config.get('use_dali', False) + + class_num = config["Arch"].get("class_num", None) + config["DataLoader"].update({"class_num": class_num}) + train_dataloader = build_dataloader( + config["DataLoader"], "Train", device=device, use_dali=use_dali) + if global_config["eval_during_train"]: + eval_dataloader = build_dataloader( + config["DataLoader"], "Eval", device=device, use_dali=use_dali) + + step_each_epoch = len(train_dataloader) + + # startup_prog is used to do some parameter init work, + # and train prog is used to hold the network + startup_prog = paddle.static.Program() + train_prog = paddle.static.Program() + + best_top1_acc = 0.0 # best top1 acc record + + train_fetchs, lr_scheduler, train_feeds, optimizer = program.build( + config, + train_prog, + startup_prog, + class_num, + step_each_epoch=step_each_epoch, + is_train=True, + is_distributed=global_config.get("is_distributed", True)) + + if global_config["eval_during_train"]: + eval_prog = paddle.static.Program() + eval_fetchs, _, eval_feeds, _ = program.build( + config, + eval_prog, + startup_prog, + is_train=False, + is_distributed=global_config.get("is_distributed", True)) + # clone to prune some content which is irrelevant in eval_prog + eval_prog = eval_prog.clone(for_test=True) + + # create the "Executor" with the statement of which device + exe = paddle.static.Executor(device) + # Parameter initialization + exe.run(startup_prog) + # load pretrained models or checkpoints + init_model(global_config, train_prog, exe) + + if 'AMP' in config and config.AMP.get("level", "O1") == "O2": + optimizer.amp_init( + device, + scope=paddle.static.global_scope(), + test_program=eval_prog + if global_config["eval_during_train"] else None) + + if not global_config.get("is_distributed", True): + compiled_train_prog = program.compile( + config, train_prog, loss_name=train_fetchs["loss"][0].name) + else: + compiled_train_prog = train_prog + + if eval_dataloader is not None: + compiled_eval_prog = program.compile(config, eval_prog) + + for epoch_id in range(global_config["epochs"]): + # 1. train with train dataset + program.run(train_dataloader, exe, compiled_train_prog, train_feeds, + train_fetchs, epoch_id, 'train', config, vdl_writer, + lr_scheduler, args.profiler_options) + # 2. evaate with eval dataset + if global_config["eval_during_train"] and epoch_id % global_config[ + "eval_interval"] == 0: + top1_acc = program.run(eval_dataloader, exe, compiled_eval_prog, + eval_feeds, eval_fetchs, epoch_id, "eval", + config) + if top1_acc > best_top1_acc: + best_top1_acc = top1_acc + message = "The best top1 acc {:.5f}, in epoch: {:d}".format( + best_top1_acc, epoch_id) + logger.info(message) + if epoch_id % global_config["save_interval"] == 0: + + model_path = os.path.join(global_config["output_dir"], + config["Arch"]["name"]) + save_model(train_prog, model_path, "best_model") + + # 3. save the persistable model + if epoch_id % global_config["save_interval"] == 0: + model_path = os.path.join(global_config["output_dir"], + config["Arch"]["name"]) + save_model(train_prog, model_path, epoch_id) + + +if __name__ == '__main__': + paddle.enable_static() + args = parse_args() + main(args) diff --git a/src/PaddleClas/ppcls/utils/__init__.py b/src/PaddleClas/ppcls/utils/__init__.py new file mode 100644 index 0000000..632cc78 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/__init__.py @@ -0,0 +1,27 @@ +# 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 logger +from . import misc +from . import model_zoo +from . import metrics + +from .save_load import init_model, save_model +from .config import get_config +from .misc import AverageMeter +from .metrics import multi_hot_encode +from .metrics import hamming_distance +from .metrics import accuracy_score +from .metrics import precision_recall_fscore +from .metrics import mean_average_precision diff --git a/src/PaddleClas/ppcls/utils/__pycache__/__init__.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..742ad34 Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/check.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/check.cpython-39.pyc new file mode 100644 index 0000000..5537a77 Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/check.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/config.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/config.cpython-39.pyc new file mode 100644 index 0000000..bb62e36 Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/config.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/download.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/download.cpython-39.pyc new file mode 100644 index 0000000..7aafa18 Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/download.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/logger.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/logger.cpython-39.pyc new file mode 100644 index 0000000..1a80880 Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/logger.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/metrics.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/metrics.cpython-39.pyc new file mode 100644 index 0000000..d0d59db Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/metrics.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/misc.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/misc.cpython-39.pyc new file mode 100644 index 0000000..bc2f9ff Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/misc.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/model_zoo.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/model_zoo.cpython-39.pyc new file mode 100644 index 0000000..52849be Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/model_zoo.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/profiler.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/profiler.cpython-39.pyc new file mode 100644 index 0000000..87676dd Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/profiler.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/__pycache__/save_load.cpython-39.pyc b/src/PaddleClas/ppcls/utils/__pycache__/save_load.cpython-39.pyc new file mode 100644 index 0000000..621cfc1 Binary files /dev/null and b/src/PaddleClas/ppcls/utils/__pycache__/save_load.cpython-39.pyc differ diff --git a/src/PaddleClas/ppcls/utils/check.py b/src/PaddleClas/ppcls/utils/check.py new file mode 100644 index 0000000..bc70308 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/check.py @@ -0,0 +1,151 @@ +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +import sys + +import paddle +from paddle import is_compiled_with_cuda + +from ppcls.arch import get_architectures +from ppcls.arch import similar_architectures +from ppcls.arch import get_blacklist_model_in_static_mode +from ppcls.utils import logger + + +def check_version(): + """ + Log error and exit when the installed version of paddlepaddle is + not satisfied. + """ + err = "PaddlePaddle version 1.8.0 or higher is required, " \ + "or a suitable develop version is satisfied as well. \n" \ + "Please make sure the version is good with your code." + try: + pass + # paddle.utils.require_version('0.0.0') + except Exception: + logger.error(err) + sys.exit(1) + + +def check_gpu(): + """ + Log error and exit when using paddlepaddle cpu version. + """ + err = "You are using paddlepaddle cpu version! Please try to " \ + "install paddlepaddle-gpu to run model on GPU." + + try: + assert is_compiled_with_cuda() + except AssertionError: + logger.error(err) + sys.exit(1) + + +def check_architecture(architecture): + """ + check architecture and recommend similar architectures + """ + assert isinstance(architecture, dict), \ + ("the type of architecture({}) should be dict". format(architecture)) + assert "name" in architecture, \ + ("name must be in the architecture keys, just contains: {}". format( + architecture.keys())) + + similar_names = similar_architectures(architecture["name"], + get_architectures()) + model_list = ', '.join(similar_names) + err = "Architecture [{}] is not exist! Maybe you want: [{}]" \ + "".format(architecture["name"], model_list) + try: + assert architecture["name"] in similar_names + except AssertionError: + logger.error(err) + sys.exit(1) + + +def check_model_with_running_mode(architecture): + """ + check whether the model is consistent with the operating mode + """ + # some model are not supported in the static mode + blacklist = get_blacklist_model_in_static_mode() + if not paddle.in_dynamic_mode() and architecture["name"] in blacklist: + logger.error("Model: {} is not supported in the staic mode.".format( + architecture["name"])) + sys.exit(1) + return + + +def check_mix(architecture, use_mix=False): + """ + check mix parameter + """ + err = "Cannot use mix processing in GoogLeNet, " \ + "please set use_mix = False." + try: + if architecture["name"] == "GoogLeNet": + assert use_mix is not True + except AssertionError: + logger.error(err) + sys.exit(1) + + +def check_classes_num(classes_num): + """ + check classes_num + """ + err = "classes_num({}) should be a positive integer" \ + "and larger than 1".format(classes_num) + try: + assert isinstance(classes_num, int) + assert classes_num > 1 + except AssertionError: + logger.error(err) + sys.exit(1) + + +def check_data_dir(path): + """ + check cata_dir + """ + err = "Data path is not exist, please given a right path" \ + "".format(path) + try: + assert os.isdir(path) + except AssertionError: + logger.error(err) + sys.exit(1) + + +def check_function_params(config, key): + """ + check specify config + """ + k_config = config.get(key) + assert k_config is not None, \ + ('{} is required in config'.format(key)) + + assert k_config.get('function'), \ + ('function is required {} config'.format(key)) + params = k_config.get('params') + assert params is not None, \ + ('params is required in {} config'.format(key)) + assert isinstance(params, dict), \ + ('the params in {} config should be a dict'.format(key)) diff --git a/src/PaddleClas/ppcls/utils/config.py b/src/PaddleClas/ppcls/utils/config.py new file mode 100644 index 0000000..e3277c4 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/config.py @@ -0,0 +1,210 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import os +import copy +import argparse +import yaml +from ppcls.utils import logger +from ppcls.utils import check +__all__ = ['get_config'] + + +class AttrDict(dict): + def __getattr__(self, key): + return self[key] + + def __setattr__(self, key, value): + if key in self.__dict__: + self.__dict__[key] = value + else: + self[key] = value + + def __deepcopy__(self, content): + return copy.deepcopy(dict(self)) + + +def create_attr_dict(yaml_config): + from ast import literal_eval + for key, value in yaml_config.items(): + if type(value) is dict: + yaml_config[key] = value = AttrDict(value) + if isinstance(value, str): + try: + value = literal_eval(value) + except BaseException: + pass + if isinstance(value, AttrDict): + create_attr_dict(yaml_config[key]) + else: + yaml_config[key] = value + + +def parse_config(cfg_file): + """Load a config file into AttrDict""" + with open(cfg_file, 'r') as fopen: + yaml_config = AttrDict(yaml.load(fopen, Loader=yaml.SafeLoader)) + create_attr_dict(yaml_config) + return yaml_config + + +def print_dict(d, delimiter=0): + """ + Recursively visualize a dict and + indenting acrrording by the relationship of keys. + """ + placeholder = "-" * 60 + for k, v in sorted(d.items()): + if isinstance(v, dict): + logger.info("{}{} : ".format(delimiter * " ", k)) + print_dict(v, delimiter + 4) + elif isinstance(v, list) and len(v) >= 1 and isinstance(v[0], dict): + logger.info("{}{} : ".format(delimiter * " ", k)) + for value in v: + print_dict(value, delimiter + 4) + else: + logger.info("{}{} : {}".format(delimiter * " ", k, v)) + if k.isupper(): + logger.info(placeholder) + + +def print_config(config): + """ + visualize configs + Arguments: + config: configs + """ + logger.advertise() + print_dict(config) + + +def check_config(config): + """ + Check config + """ + check.check_version() + use_gpu = config.get('use_gpu', True) + if use_gpu: + check.check_gpu() + architecture = config.get('ARCHITECTURE') + #check.check_architecture(architecture) + use_mix = config.get('use_mix', False) + check.check_mix(architecture, use_mix) + classes_num = config.get('classes_num') + check.check_classes_num(classes_num) + mode = config.get('mode', 'train') + if mode.lower() == 'train': + check.check_function_params(config, 'LEARNING_RATE') + check.check_function_params(config, 'OPTIMIZER') + + +def override(dl, ks, v): + """ + Recursively replace dict of list + Args: + dl(dict or list): dict or list to be replaced + ks(list): list of keys + v(str): value to be replaced + """ + + def str2num(v): + try: + return eval(v) + except Exception: + return v + + assert isinstance(dl, (list, dict)), ("{} should be a list or a dict") + assert len(ks) > 0, ('lenght of keys should larger than 0') + if isinstance(dl, list): + k = str2num(ks[0]) + if len(ks) == 1: + assert k < len(dl), ('index({}) out of range({})'.format(k, dl)) + dl[k] = str2num(v) + else: + override(dl[k], ks[1:], v) + else: + if len(ks) == 1: + # assert ks[0] in dl, ('{} is not exist in {}'.format(ks[0], dl)) + if not ks[0] in dl: + print('A new filed ({}) detected!'.format(ks[0], dl)) + dl[ks[0]] = str2num(v) + else: + override(dl[ks[0]], ks[1:], v) + + +def override_config(config, options=None): + """ + Recursively override the config + Args: + config(dict): dict to be replaced + options(list): list of pairs(key0.key1.idx.key2=value) + such as: [ + 'topk=2', + 'VALID.transforms.1.ResizeImage.resize_short=300' + ] + Returns: + config(dict): replaced config + """ + if options is not None: + for opt in options: + assert isinstance(opt, str), ( + "option({}) should be a str".format(opt)) + assert "=" in opt, ( + "option({}) should contain a =" + "to distinguish between key and value".format(opt)) + pair = opt.split('=') + assert len(pair) == 2, ("there can be only a = in the option") + key, value = pair + keys = key.split('.') + override(config, keys, value) + return config + + +def get_config(fname, overrides=None, show=False): + """ + Read config from file + """ + assert os.path.exists(fname), ( + 'config file({}) is not exist'.format(fname)) + config = parse_config(fname) + override_config(config, overrides) + if show: + print_config(config) + # check_config(config) + return config + + +def parse_args(): + parser = argparse.ArgumentParser("generic-image-rec train script") + parser.add_argument( + '-c', + '--config', + type=str, + default='configs/config.yaml', + help='config file path') + parser.add_argument( + '-o', + '--override', + action='append', + default=[], + help='config options to be overridden') + parser.add_argument( + '-p', + '--profiler_options', + type=str, + default=None, + help='The option of profiler, which should be in format \"key1=value1;key2=value2;key3=value3\".' + ) + args = parser.parse_args() + return args diff --git a/src/PaddleClas/ppcls/utils/download.py b/src/PaddleClas/ppcls/utils/download.py new file mode 100644 index 0000000..9c45750 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/download.py @@ -0,0 +1,319 @@ +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +import sys +import os.path as osp +import shutil +import requests +import hashlib +import tarfile +import zipfile +import time +from collections import OrderedDict +from tqdm import tqdm + +from ppcls.utils import logger + +__all__ = ['get_weights_path_from_url'] + +WEIGHTS_HOME = osp.expanduser("~/.paddleclas/weights") + +DOWNLOAD_RETRY_LIMIT = 3 + + +def is_url(path): + """ + Whether path is URL. + Args: + path (string): URL string or not. + """ + return path.startswith('http://') or path.startswith('https://') + + +def get_weights_path_from_url(url, md5sum=None): + """Get weights path from WEIGHT_HOME, if not exists, + download it from url. + + Args: + url (str): download url + md5sum (str): md5 sum of download package + + Returns: + str: a local path to save downloaded weights. + + Examples: + .. code-block:: python + + from paddle.utils.download import get_weights_path_from_url + + resnet18_pretrained_weight_url = 'https://paddle-hapi.bj.bcebos.com/models/resnet18.pdparams' + local_weight_path = get_weights_path_from_url(resnet18_pretrained_weight_url) + + """ + path = get_path_from_url(url, WEIGHTS_HOME, md5sum) + return path + + +def _map_path(url, root_dir): + # parse path after download under root_dir + fname = osp.split(url)[-1] + fpath = fname + return osp.join(root_dir, fpath) + + +def _get_unique_endpoints(trainer_endpoints): + # Sorting is to avoid different environmental variables for each card + trainer_endpoints.sort() + ips = set() + unique_endpoints = set() + for endpoint in trainer_endpoints: + ip = endpoint.split(":")[0] + if ip in ips: + continue + ips.add(ip) + unique_endpoints.add(endpoint) + logger.info("unique_endpoints {}".format(unique_endpoints)) + return unique_endpoints + + +def get_path_from_url(url, + root_dir, + md5sum=None, + check_exist=True, + decompress=True): + """ Download from given url to root_dir. + if file or directory specified by url is exists under + root_dir, return the path directly, otherwise download + from url and decompress it, return the path. + + Args: + url (str): download url + root_dir (str): root dir for downloading, it should be + WEIGHTS_HOME or DATASET_HOME + md5sum (str): md5 sum of download package + + Returns: + str: a local path to save downloaded models & weights & datasets. + """ + + from paddle.fluid.dygraph.parallel import ParallelEnv + + assert is_url(url), "downloading from {} not a url".format(url) + # parse path after download to decompress under root_dir + fullpath = _map_path(url, root_dir) + # Mainly used to solve the problem of downloading data from different + # machines in the case of multiple machines. Different ips will download + # data, and the same ip will only download data once. + unique_endpoints = _get_unique_endpoints(ParallelEnv() + .trainer_endpoints[:]) + if osp.exists(fullpath) and check_exist and _md5check(fullpath, md5sum): + logger.info("Found {}".format(fullpath)) + else: + if ParallelEnv().current_endpoint in unique_endpoints: + fullpath = _download(url, root_dir, md5sum) + else: + while not os.path.exists(fullpath): + time.sleep(1) + + if ParallelEnv().current_endpoint in unique_endpoints: + if decompress and (tarfile.is_tarfile(fullpath) or + zipfile.is_zipfile(fullpath)): + fullpath = _decompress(fullpath) + + return fullpath + + +def _download(url, path, md5sum=None): + """ + Download from url, save to path. + + url (str): download url + path (str): download to given path + """ + if not osp.exists(path): + os.makedirs(path) + + fname = osp.split(url)[-1] + fullname = osp.join(path, fname) + retry_cnt = 0 + + while not (osp.exists(fullname) and _md5check(fullname, md5sum)): + if retry_cnt < DOWNLOAD_RETRY_LIMIT: + retry_cnt += 1 + else: + raise RuntimeError("Download from {} failed. " + "Retry limit reached".format(url)) + + logger.info("Downloading {} from {}".format(fname, url)) + + try: + req = requests.get(url, stream=True) + except Exception as e: # requests.exceptions.ConnectionError + logger.info( + "Downloading {} from {} failed {} times with exception {}". + format(fname, url, retry_cnt + 1, str(e))) + time.sleep(1) + continue + + if req.status_code != 200: + raise RuntimeError("Downloading from {} failed with code " + "{}!".format(url, req.status_code)) + + # For protecting download interupted, download to + # tmp_fullname firstly, move tmp_fullname to fullname + # after download finished + tmp_fullname = fullname + "_tmp" + total_size = req.headers.get('content-length') + with open(tmp_fullname, 'wb') as f: + if total_size: + with tqdm(total=(int(total_size) + 1023) // 1024) as pbar: + for chunk in req.iter_content(chunk_size=1024): + f.write(chunk) + pbar.update(1) + else: + for chunk in req.iter_content(chunk_size=1024): + if chunk: + f.write(chunk) + shutil.move(tmp_fullname, fullname) + + return fullname + + +def _md5check(fullname, md5sum=None): + if md5sum is None: + return True + + logger.info("File {} md5 checking...".format(fullname)) + md5 = hashlib.md5() + with open(fullname, 'rb') as f: + for chunk in iter(lambda: f.read(4096), b""): + md5.update(chunk) + calc_md5sum = md5.hexdigest() + + if calc_md5sum != md5sum: + logger.info("File {} md5 check failed, {}(calc) != " + "{}(base)".format(fullname, calc_md5sum, md5sum)) + return False + return True + + +def _decompress(fname): + """ + Decompress for zip and tar file + """ + logger.info("Decompressing {}...".format(fname)) + + # For protecting decompressing interupted, + # decompress to fpath_tmp directory firstly, if decompress + # successed, move decompress files to fpath and delete + # fpath_tmp and remove download compress file. + + if tarfile.is_tarfile(fname): + uncompressed_path = _uncompress_file_tar(fname) + elif zipfile.is_zipfile(fname): + uncompressed_path = _uncompress_file_zip(fname) + else: + raise TypeError("Unsupport compress file type {}".format(fname)) + + return uncompressed_path + + +def _uncompress_file_zip(filepath): + files = zipfile.ZipFile(filepath, 'r') + file_list = files.namelist() + + file_dir = os.path.dirname(filepath) + + if _is_a_single_file(file_list): + rootpath = file_list[0] + uncompressed_path = os.path.join(file_dir, rootpath) + + for item in file_list: + files.extract(item, file_dir) + + elif _is_a_single_dir(file_list): + rootpath = os.path.splitext(file_list[0])[0].split(os.sep)[-1] + uncompressed_path = os.path.join(file_dir, rootpath) + + for item in file_list: + files.extract(item, file_dir) + + else: + rootpath = os.path.splitext(filepath)[0].split(os.sep)[-1] + uncompressed_path = os.path.join(file_dir, rootpath) + if not os.path.exists(uncompressed_path): + os.makedirs(uncompressed_path) + for item in file_list: + files.extract(item, os.path.join(file_dir, rootpath)) + + files.close() + + return uncompressed_path + + +def _uncompress_file_tar(filepath, mode="r:*"): + files = tarfile.open(filepath, mode) + file_list = files.getnames() + + file_dir = os.path.dirname(filepath) + + if _is_a_single_file(file_list): + rootpath = file_list[0] + uncompressed_path = os.path.join(file_dir, rootpath) + for item in file_list: + files.extract(item, file_dir) + elif _is_a_single_dir(file_list): + rootpath = os.path.splitext(file_list[0])[0].split(os.sep)[-1] + uncompressed_path = os.path.join(file_dir, rootpath) + for item in file_list: + files.extract(item, file_dir) + else: + rootpath = os.path.splitext(filepath)[0].split(os.sep)[-1] + uncompressed_path = os.path.join(file_dir, rootpath) + if not os.path.exists(uncompressed_path): + os.makedirs(uncompressed_path) + + for item in file_list: + files.extract(item, os.path.join(file_dir, rootpath)) + + files.close() + + return uncompressed_path + + +def _is_a_single_file(file_list): + if len(file_list) == 1 and file_list[0].find(os.sep) < -1: + return True + return False + + +def _is_a_single_dir(file_list): + new_file_list = [] + for file_path in file_list: + if '/' in file_path: + file_path = file_path.replace('/', os.sep) + elif '\\' in file_path: + file_path = file_path.replace('\\', os.sep) + new_file_list.append(file_path) + + file_name = new_file_list[0].split(os.sep)[0] + for i in range(1, len(new_file_list)): + if file_name != new_file_list[i].split(os.sep)[0]: + return False + return True diff --git a/src/PaddleClas/ppcls/utils/ema.py b/src/PaddleClas/ppcls/utils/ema.py new file mode 100644 index 0000000..b54cdb1 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/ema.py @@ -0,0 +1,63 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import paddle +import numpy as np + + +class ExponentialMovingAverage(): + """ + Exponential Moving Average + Code was heavily based on https://github.com/Wanger-SJTU/SegToolbox.Pytorch/blob/master/lib/utils/ema.py + """ + + def __init__(self, model, decay, thres_steps=True): + self._model = model + self._decay = decay + self._thres_steps = thres_steps + self._shadow = {} + self._backup = {} + + def register(self): + self._update_step = 0 + for name, param in self._model.named_parameters(): + if param.stop_gradient is False: + self._shadow[name] = param.numpy().copy() + + def update(self): + decay = min(self._decay, (1 + self._update_step) / ( + 10 + self._update_step)) if self._thres_steps else self._decay + for name, param in self._model.named_parameters(): + if param.stop_gradient is False: + assert name in self._shadow + new_val = np.array(param.numpy().copy()) + old_val = np.array(self._shadow[name]) + new_average = decay * old_val + (1 - decay) * new_val + self._shadow[name] = new_average + self._update_step += 1 + return decay + + def apply(self): + for name, param in self._model.named_parameters(): + if param.stop_gradient is False: + assert name in self._shadow + self._backup[name] = np.array(param.numpy().copy()) + param.set_value(np.array(self._shadow[name])) + + def restore(self): + for name, param in self._model.named_parameters(): + if param.stop_gradient is False: + assert name in self._backup + param.set_value(self._backup[name]) + self._backup = {} diff --git a/src/PaddleClas/ppcls/utils/feature_maps_visualization/fm_vis.py b/src/PaddleClas/ppcls/utils/feature_maps_visualization/fm_vis.py new file mode 100644 index 0000000..a5368b1 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/feature_maps_visualization/fm_vis.py @@ -0,0 +1,97 @@ +# 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. +import numpy as np +import cv2 +import utils +import argparse +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(__dir__) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../../..'))) + +import paddle +from paddle.distributed import ParallelEnv + +from resnet import ResNet50 +from ppcls.utils.save_load import load_dygraph_pretrain + + +def parse_args(): + def str2bool(v): + return v.lower() in ("true", "t", "1") + + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--image_file", required=True, type=str) + parser.add_argument("-c", "--channel_num", type=int) + parser.add_argument("-p", "--pretrained_model", type=str) + parser.add_argument("--show", type=str2bool, default=False) + parser.add_argument("--interpolation", type=int, default=1) + parser.add_argument("--save_path", type=str, default=None) + parser.add_argument("--use_gpu", type=str2bool, default=True) + + return parser.parse_args() + + +def create_operators(interpolation=1): + size = 224 + img_mean = [0.485, 0.456, 0.406] + img_std = [0.229, 0.224, 0.225] + img_scale = 1.0 / 255.0 + + resize_op = utils.ResizeImage( + resize_short=256, interpolation=interpolation) + crop_op = utils.CropImage(size=(size, size)) + normalize_op = utils.NormalizeImage( + scale=img_scale, mean=img_mean, std=img_std) + totensor_op = utils.ToTensor() + + return [resize_op, crop_op, normalize_op, totensor_op] + + +def preprocess(data, ops): + for op in ops: + data = op(data) + return data + + +def main(): + args = parse_args() + operators = create_operators(args.interpolation) + # assign the place + place = 'gpu:{}'.format(ParallelEnv().dev_id) if args.use_gpu else 'cpu' + place = paddle.set_device(place) + + net = ResNet50() + load_dygraph_pretrain(net, args.pretrained_model) + + img = cv2.imread(args.image_file, cv2.IMREAD_COLOR) + data = preprocess(img, operators) + data = np.expand_dims(data, axis=0) + data = paddle.to_tensor(data) + net.eval() + _, fm = net(data) + assert args.channel_num >= 0 and args.channel_num <= fm.shape[ + 1], "the channel is out of the range, should be in {} but got {}".format( + [0, fm.shape[1]], args.channel_num) + + fm = (np.squeeze(fm[0][args.channel_num].numpy()) * 255).astype(np.uint8) + fm = cv2.resize(fm, (img.shape[1], img.shape[0])) + if args.save_path is not None: + print("the feature map is saved in path: {}".format(args.save_path)) + cv2.imwrite(args.save_path, fm) + + +if __name__ == "__main__": + main() diff --git a/src/PaddleClas/ppcls/utils/feature_maps_visualization/resnet.py b/src/PaddleClas/ppcls/utils/feature_maps_visualization/resnet.py new file mode 100644 index 0000000..b758814 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/feature_maps_visualization/resnet.py @@ -0,0 +1,535 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import, division, print_function + +import numpy as np +import paddle +from paddle import ParamAttr +import paddle.nn as nn +from paddle.nn import Conv2D, BatchNorm, Linear +from paddle.nn import AdaptiveAvgPool2D, MaxPool2D, AvgPool2D +from paddle.nn.initializer import Uniform +import math + +from ppcls.arch.backbone.base.theseus_layer import TheseusLayer +from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url + +MODEL_URLS = { + "ResNet18": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_pretrained.pdparams", + "ResNet18_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_vd_pretrained.pdparams", + "ResNet34": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_pretrained.pdparams", + "ResNet34_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_pretrained.pdparams", + "ResNet50": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_pretrained.pdparams", + "ResNet50_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams", + "ResNet101": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_pretrained.pdparams", + "ResNet101_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_pretrained.pdparams", + "ResNet152": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_pretrained.pdparams", + "ResNet152_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_vd_pretrained.pdparams", + "ResNet200_vd": + "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet200_vd_pretrained.pdparams", +} + +__all__ = MODEL_URLS.keys() +''' +ResNet config: dict. + key: depth of ResNet. + values: config's dict of specific model. + keys: + block_type: Two different blocks in ResNet, BasicBlock and BottleneckBlock are optional. + block_depth: The number of blocks in different stages in ResNet. + num_channels: The number of channels to enter the next stage. +''' +NET_CONFIG = { + "18": { + "block_type": "BasicBlock", + "block_depth": [2, 2, 2, 2], + "num_channels": [64, 64, 128, 256] + }, + "34": { + "block_type": "BasicBlock", + "block_depth": [3, 4, 6, 3], + "num_channels": [64, 64, 128, 256] + }, + "50": { + "block_type": "BottleneckBlock", + "block_depth": [3, 4, 6, 3], + "num_channels": [64, 256, 512, 1024] + }, + "101": { + "block_type": "BottleneckBlock", + "block_depth": [3, 4, 23, 3], + "num_channels": [64, 256, 512, 1024] + }, + "152": { + "block_type": "BottleneckBlock", + "block_depth": [3, 8, 36, 3], + "num_channels": [64, 256, 512, 1024] + }, + "200": { + "block_type": "BottleneckBlock", + "block_depth": [3, 12, 48, 3], + "num_channels": [64, 256, 512, 1024] + }, +} + + +class ConvBNLayer(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + filter_size, + stride=1, + groups=1, + is_vd_mode=False, + act=None, + lr_mult=1.0, + data_format="NCHW"): + super().__init__() + self.is_vd_mode = is_vd_mode + self.act = act + self.avg_pool = AvgPool2D( + kernel_size=2, stride=2, padding=0, ceil_mode=True) + self.conv = Conv2D( + in_channels=num_channels, + out_channels=num_filters, + kernel_size=filter_size, + stride=stride, + padding=(filter_size - 1) // 2, + groups=groups, + weight_attr=ParamAttr(learning_rate=lr_mult), + bias_attr=False, + data_format=data_format) + self.bn = BatchNorm( + num_filters, + param_attr=ParamAttr(learning_rate=lr_mult), + bias_attr=ParamAttr(learning_rate=lr_mult), + data_layout=data_format) + self.relu = nn.ReLU() + + def forward(self, x): + if self.is_vd_mode: + x = self.avg_pool(x) + x = self.conv(x) + x = self.bn(x) + if self.act: + x = self.relu(x) + return x + + +class BottleneckBlock(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + if_first=False, + lr_mult=1.0, + data_format="NCHW"): + super().__init__() + + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + act="relu", + lr_mult=lr_mult, + data_format=data_format) + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + stride=stride, + act="relu", + lr_mult=lr_mult, + data_format=data_format) + self.conv2 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters * 4, + filter_size=1, + act=None, + lr_mult=lr_mult, + data_format=data_format) + + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters * 4, + filter_size=1, + stride=stride if if_first else 1, + is_vd_mode=False if if_first else True, + lr_mult=lr_mult, + data_format=data_format) + self.relu = nn.ReLU() + self.shortcut = shortcut + + def forward(self, x): + identity = x + x = self.conv0(x) + x = self.conv1(x) + x = self.conv2(x) + + if self.shortcut: + short = identity + else: + short = self.short(identity) + x = paddle.add(x=x, y=short) + x = self.relu(x) + return x + + +class BasicBlock(TheseusLayer): + def __init__(self, + num_channels, + num_filters, + stride, + shortcut=True, + if_first=False, + lr_mult=1.0, + data_format="NCHW"): + super().__init__() + + self.stride = stride + self.conv0 = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=3, + stride=stride, + act="relu", + lr_mult=lr_mult, + data_format=data_format) + self.conv1 = ConvBNLayer( + num_channels=num_filters, + num_filters=num_filters, + filter_size=3, + act=None, + lr_mult=lr_mult, + data_format=data_format) + if not shortcut: + self.short = ConvBNLayer( + num_channels=num_channels, + num_filters=num_filters, + filter_size=1, + stride=stride if if_first else 1, + is_vd_mode=False if if_first else True, + lr_mult=lr_mult, + data_format=data_format) + self.shortcut = shortcut + self.relu = nn.ReLU() + + def forward(self, x): + identity = x + x = self.conv0(x) + x = self.conv1(x) + if self.shortcut: + short = identity + else: + short = self.short(identity) + x = paddle.add(x=x, y=short) + x = self.relu(x) + return x + + +class ResNet(TheseusLayer): + """ + ResNet + Args: + config: dict. config of ResNet. + version: str="vb". Different version of ResNet, version vd can perform better. + class_num: int=1000. The number of classes. + lr_mult_list: list. Control the learning rate of different stages. + Returns: + model: nn.Layer. Specific ResNet model depends on args. + """ + + def __init__(self, + config, + version="vb", + class_num=1000, + lr_mult_list=[1.0, 1.0, 1.0, 1.0, 1.0], + data_format="NCHW", + input_image_channel=3, + return_patterns=None): + super().__init__() + + self.cfg = config + self.lr_mult_list = lr_mult_list + self.is_vd_mode = version == "vd" + self.class_num = class_num + self.num_filters = [64, 128, 256, 512] + self.block_depth = self.cfg["block_depth"] + self.block_type = self.cfg["block_type"] + self.num_channels = self.cfg["num_channels"] + self.channels_mult = 1 if self.num_channels[-1] == 256 else 4 + + assert isinstance(self.lr_mult_list, ( + list, tuple + )), "lr_mult_list should be in (list, tuple) but got {}".format( + type(self.lr_mult_list)) + assert len(self.lr_mult_list + ) == 5, "lr_mult_list length should be 5 but got {}".format( + len(self.lr_mult_list)) + + self.stem_cfg = { + #num_channels, num_filters, filter_size, stride + "vb": [[input_image_channel, 64, 7, 2]], + "vd": + [[input_image_channel, 32, 3, 2], [32, 32, 3, 1], [32, 64, 3, 1]] + } + + self.stem = nn.Sequential(* [ + ConvBNLayer( + num_channels=in_c, + num_filters=out_c, + filter_size=k, + stride=s, + act="relu", + lr_mult=self.lr_mult_list[0], + data_format=data_format) + for in_c, out_c, k, s in self.stem_cfg[version] + ]) + + self.max_pool = MaxPool2D( + kernel_size=3, stride=2, padding=1, data_format=data_format) + block_list = [] + for block_idx in range(len(self.block_depth)): + shortcut = False + for i in range(self.block_depth[block_idx]): + block_list.append(globals()[self.block_type]( + num_channels=self.num_channels[block_idx] if i == 0 else + self.num_filters[block_idx] * self.channels_mult, + num_filters=self.num_filters[block_idx], + stride=2 if i == 0 and block_idx != 0 else 1, + shortcut=shortcut, + if_first=block_idx == i == 0 if version == "vd" else True, + lr_mult=self.lr_mult_list[block_idx + 1], + data_format=data_format)) + shortcut = True + self.blocks = nn.Sequential(*block_list) + + self.avg_pool = AdaptiveAvgPool2D(1, data_format=data_format) + self.flatten = nn.Flatten() + self.avg_pool_channels = self.num_channels[-1] * 2 + stdv = 1.0 / math.sqrt(self.avg_pool_channels * 1.0) + self.fc = Linear( + self.avg_pool_channels, + self.class_num, + weight_attr=ParamAttr(initializer=Uniform(-stdv, stdv))) + + self.data_format = data_format + if return_patterns is not None: + self.update_res(return_patterns) + self.register_forward_post_hook(self._return_dict_hook) + + def forward(self, x): + with paddle.static.amp.fp16_guard(): + if self.data_format == "NHWC": + x = paddle.transpose(x, [0, 2, 3, 1]) + x.stop_gradient = True + x = self.stem(x) + fm = x + x = self.max_pool(x) + x = self.blocks(x) + x = self.avg_pool(x) + x = self.flatten(x) + x = self.fc(x) + return x, fm + + +def _load_pretrained(pretrained, model, model_url, use_ssld): + if pretrained is False: + pass + elif pretrained is True: + load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) + elif isinstance(pretrained, str): + load_dygraph_pretrain(model, pretrained) + else: + raise RuntimeError( + "pretrained type is not available. Please use `string` or `boolean` type." + ) + + +def ResNet18(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet18 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet18` model depends on args. + """ + model = ResNet(config=NET_CONFIG["18"], version="vb", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet18"], use_ssld) + return model + + +def ResNet18_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet18_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet18_vd` model depends on args. + """ + model = ResNet(config=NET_CONFIG["18"], version="vd", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet18_vd"], use_ssld) + return model + + +def ResNet34(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet34 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet34` model depends on args. + """ + model = ResNet(config=NET_CONFIG["34"], version="vb", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet34"], use_ssld) + return model + + +def ResNet34_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet34_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet34_vd` model depends on args. + """ + model = ResNet(config=NET_CONFIG["34"], version="vd", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet34_vd"], use_ssld) + return model + + +def ResNet50(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet50 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet50` model depends on args. + """ + model = ResNet(config=NET_CONFIG["50"], version="vb", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet50"], use_ssld) + return model + + +def ResNet50_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet50_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet50_vd` model depends on args. + """ + model = ResNet(config=NET_CONFIG["50"], version="vd", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet50_vd"], use_ssld) + return model + + +def ResNet101(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet101 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet101` model depends on args. + """ + model = ResNet(config=NET_CONFIG["101"], version="vb", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet101"], use_ssld) + return model + + +def ResNet101_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet101_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet101_vd` model depends on args. + """ + model = ResNet(config=NET_CONFIG["101"], version="vd", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet101_vd"], use_ssld) + return model + + +def ResNet152(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet152 + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet152` model depends on args. + """ + model = ResNet(config=NET_CONFIG["152"], version="vb", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet152"], use_ssld) + return model + + +def ResNet152_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet152_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet152_vd` model depends on args. + """ + model = ResNet(config=NET_CONFIG["152"], version="vd", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet152_vd"], use_ssld) + return model + + +def ResNet200_vd(pretrained=False, use_ssld=False, **kwargs): + """ + ResNet200_vd + Args: + pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise. + If str, means the path of the pretrained model. + use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True. + Returns: + model: nn.Layer. Specific `ResNet200_vd` model depends on args. + """ + model = ResNet(config=NET_CONFIG["200"], version="vd", **kwargs) + _load_pretrained(pretrained, model, MODEL_URLS["ResNet200_vd"], use_ssld) + return model diff --git a/src/PaddleClas/ppcls/utils/feature_maps_visualization/utils.py b/src/PaddleClas/ppcls/utils/feature_maps_visualization/utils.py new file mode 100644 index 0000000..7c70149 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/feature_maps_visualization/utils.py @@ -0,0 +1,85 @@ +# 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. + +import cv2 +import numpy as np + + +class DecodeImage(object): + def __init__(self, to_rgb=True): + self.to_rgb = to_rgb + + def __call__(self, img): + data = np.frombuffer(img, dtype='uint8') + img = cv2.imdecode(data, 1) + if self.to_rgb: + assert img.shape[2] == 3, 'invalid shape of image[%s]' % ( + img.shape) + img = img[:, :, ::-1] + + return img + + +class ResizeImage(object): + def __init__(self, resize_short=None, interpolation=1): + self.resize_short = resize_short + self.interpolation = interpolation + + def __call__(self, img): + img_h, img_w = img.shape[:2] + percent = float(self.resize_short) / min(img_w, img_h) + w = int(round(img_w * percent)) + h = int(round(img_h * percent)) + return cv2.resize(img, (w, h), interpolation=self.interpolation) + + +class CropImage(object): + def __init__(self, size): + if type(size) is int: + self.size = (size, size) + else: + self.size = size + + def __call__(self, img): + w, h = self.size + img_h, img_w = img.shape[:2] + w_start = (img_w - w) // 2 + h_start = (img_h - h) // 2 + + w_end = w_start + w + h_end = h_start + h + return img[h_start:h_end, w_start:w_end, :] + + +class NormalizeImage(object): + def __init__(self, scale=None, mean=None, std=None): + self.scale = np.float32(scale if scale is not None else 1.0 / 255.0) + mean = mean if mean is not None else [0.485, 0.456, 0.406] + std = std if std is not None else [0.229, 0.224, 0.225] + + shape = (1, 1, 3) + self.mean = np.array(mean).reshape(shape).astype('float32') + self.std = np.array(std).reshape(shape).astype('float32') + + def __call__(self, img): + return (img.astype('float32') * self.scale - self.mean) / self.std + + +class ToTensor(object): + def __init__(self): + pass + + def __call__(self, img): + img = img.transpose((2, 0, 1)) + return img diff --git a/src/PaddleClas/ppcls/utils/gallery2fc.py b/src/PaddleClas/ppcls/utils/gallery2fc.py new file mode 100644 index 0000000..67b0852 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/gallery2fc.py @@ -0,0 +1,119 @@ +# Copyright (c) 2022 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. + +import os +import paddle +import cv2 + +from ppcls.arch import build_model +from ppcls.utils.config import parse_config, parse_args +from ppcls.utils.save_load import load_dygraph_pretrain +from ppcls.utils.logger import init_logger +from ppcls.data import create_operators +from ppcls.arch.slim import quantize_model + + +class GalleryLayer(paddle.nn.Layer): + def __init__(self, configs): + super().__init__() + self.configs = configs + embedding_size = self.configs["Arch"]["Head"]["embedding_size"] + self.batch_size = self.configs["IndexProcess"]["batch_size"] + self.image_shape = self.configs["Global"]["image_shape"].copy() + self.image_shape.insert(0, self.batch_size) + + image_root = self.configs["IndexProcess"]["image_root"] + data_file = self.configs["IndexProcess"]["data_file"] + delimiter = self.configs["IndexProcess"]["delimiter"] + self.gallery_images = [] + gallery_docs = [] + gallery_labels = [] + + with open(data_file, 'r', encoding='utf-8') as f: + lines = f.readlines() + for ori_line in lines: + line = ori_line.strip().split(delimiter) + text_num = len(line) + assert text_num >= 2, f"line({ori_line}) must be splitted into at least 2 parts, but got {text_num}" + image_file = os.path.join(image_root, line[0]) + + self.gallery_images.append(image_file) + gallery_docs.append(ori_line.strip()) + gallery_labels.append(line[1].strip()) + self.gallery_layer = paddle.nn.Linear(embedding_size, len(self.gallery_images), bias_attr=False) + self.gallery_layer.skip_quant = True + output_label_str = "" + for i, label_i in enumerate(gallery_labels): + output_label_str += "{} {}\n".format(i, label_i) + output_path = configs["Global"]["save_inference_dir"] + "_label.txt" + with open(output_path, "w") as f: + f.write(output_label_str) + + def forward(self, x, label=None): + x = paddle.nn.functional.normalize(x) + x = self.gallery_layer(x) + return x + + def build_gallery_layer(self, feature_extractor): + transform_configs = self.configs["IndexProcess"]["transform_ops"] + preprocess_ops = create_operators(transform_configs) + embedding_size = self.configs["Arch"]["Head"]["embedding_size"] + batch_index = 0 + input_tensor = paddle.zeros(self.image_shape) + gallery_feature = paddle.zeros((len(self.gallery_images), embedding_size)) + for i, image_path in enumerate(self.gallery_images): + image = cv2.imread(image_path)[:, :, ::-1] + for op in preprocess_ops: + image = op(image) + input_tensor[batch_index] = image + batch_index += 1 + if batch_index == self.batch_size or i == len(self.gallery_images) - 1: + batch_feature = feature_extractor(input_tensor)["features"] + for j in range(batch_index): + feature = batch_feature[j] + norm_feature = paddle.nn.functional.normalize(feature, axis=0) + gallery_feature[i - batch_index + j + 1] = norm_feature + self.gallery_layer.set_state_dict({"_layer.weight": gallery_feature.T}) + + +def export_fuse_model(configs): + slim_config = configs["Slim"].copy() + configs["Slim"] = None + fuse_model = build_model(configs) + fuse_model.head = GalleryLayer(configs) + configs["Slim"] = slim_config + quantize_model(configs, fuse_model) + load_dygraph_pretrain(fuse_model, configs["Global"]["pretrained_model"]) + fuse_model.eval() + fuse_model.head.build_gallery_layer(fuse_model) + save_path = configs["Global"]["save_inference_dir"] + fuse_model.quanter.save_quantized_model( + fuse_model, + save_path, + input_spec=[ + paddle.static.InputSpec( + shape=[None] + configs["Global"]["image_shape"], + dtype='float32') + ]) + + +def main(): + args = parse_args() + configs = parse_config(args.config) + init_logger(name='gallery2fc') + export_fuse_model(configs) + + +if __name__ == '__main__': + main() diff --git a/src/PaddleClas/ppcls/utils/imagenet1k_label_list.txt b/src/PaddleClas/ppcls/utils/imagenet1k_label_list.txt new file mode 100644 index 0000000..376e180 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/imagenet1k_label_list.txt @@ -0,0 +1,1000 @@ +0 tench, Tinca tinca +1 goldfish, Carassius auratus +2 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias +3 tiger shark, Galeocerdo cuvieri +4 hammerhead, hammerhead shark +5 electric ray, crampfish, numbfish, torpedo +6 stingray +7 cock +8 hen +9 ostrich, Struthio camelus +10 brambling, Fringilla montifringilla +11 goldfinch, Carduelis carduelis +12 house finch, linnet, Carpodacus mexicanus +13 junco, snowbird +14 indigo bunting, indigo finch, indigo bird, Passerina cyanea +15 robin, American robin, Turdus migratorius +16 bulbul +17 jay +18 magpie +19 chickadee +20 water ouzel, dipper +21 kite +22 bald eagle, American eagle, Haliaeetus leucocephalus +23 vulture +24 great grey owl, great gray owl, Strix nebulosa +25 European fire salamander, Salamandra salamandra +26 common newt, Triturus vulgaris +27 eft +28 spotted salamander, Ambystoma maculatum +29 axolotl, mud puppy, Ambystoma mexicanum +30 bullfrog, Rana catesbeiana +31 tree frog, tree-frog +32 tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui +33 loggerhead, loggerhead turtle, Caretta caretta +34 leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea +35 mud turtle +36 terrapin +37 box turtle, box tortoise +38 banded gecko +39 common iguana, iguana, Iguana iguana +40 American chameleon, anole, Anolis carolinensis +41 whiptail, whiptail lizard +42 agama +43 frilled lizard, Chlamydosaurus kingi +44 alligator lizard +45 Gila monster, Heloderma suspectum +46 green lizard, Lacerta viridis +47 African chameleon, Chamaeleo chamaeleon +48 Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis +49 African crocodile, Nile crocodile, Crocodylus niloticus +50 American alligator, Alligator mississipiensis +51 triceratops +52 thunder snake, worm snake, Carphophis amoenus +53 ringneck snake, ring-necked snake, ring snake +54 hognose snake, puff adder, sand viper +55 green snake, grass snake +56 king snake, kingsnake +57 garter snake, grass snake +58 water snake +59 vine snake +60 night snake, Hypsiglena torquata +61 boa constrictor, Constrictor constrictor +62 rock python, rock snake, Python sebae +63 Indian cobra, Naja naja +64 green mamba +65 sea snake +66 horned viper, cerastes, sand viper, horned asp, Cerastes cornutus +67 diamondback, diamondback rattlesnake, Crotalus adamanteus +68 sidewinder, horned rattlesnake, Crotalus cerastes +69 trilobite +70 harvestman, daddy longlegs, Phalangium opilio +71 scorpion +72 black and gold garden spider, Argiope aurantia +73 barn spider, Araneus cavaticus +74 garden spider, Aranea diademata +75 black widow, Latrodectus mactans +76 tarantula +77 wolf spider, hunting spider +78 tick +79 centipede +80 black grouse +81 ptarmigan +82 ruffed grouse, partridge, Bonasa umbellus +83 prairie chicken, prairie grouse, prairie fowl +84 peacock +85 quail +86 partridge +87 African grey, African gray, Psittacus erithacus +88 macaw +89 sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita +90 lorikeet +91 coucal +92 bee eater +93 hornbill +94 hummingbird +95 jacamar +96 toucan +97 drake +98 red-breasted merganser, Mergus serrator +99 goose +100 black swan, Cygnus atratus +101 tusker +102 echidna, spiny anteater, anteater +103 platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus +104 wallaby, brush kangaroo +105 koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus +106 wombat +107 jellyfish +108 sea anemone, anemone +109 brain coral +110 flatworm, platyhelminth +111 nematode, nematode worm, roundworm +112 conch +113 snail +114 slug +115 sea slug, nudibranch +116 chiton, coat-of-mail shell, sea cradle, polyplacophore +117 chambered nautilus, pearly nautilus, nautilus +118 Dungeness crab, Cancer magister +119 rock crab, Cancer irroratus +120 fiddler crab +121 king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica +122 American lobster, Northern lobster, Maine lobster, Homarus americanus +123 spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish +124 crayfish, crawfish, crawdad, crawdaddy +125 hermit crab +126 isopod +127 white stork, Ciconia ciconia +128 black stork, Ciconia nigra +129 spoonbill +130 flamingo +131 little blue heron, Egretta caerulea +132 American egret, great white heron, Egretta albus +133 bittern +134 crane +135 limpkin, Aramus pictus +136 European gallinule, Porphyrio porphyrio +137 American coot, marsh hen, mud hen, water hen, Fulica americana +138 bustard +139 ruddy turnstone, Arenaria interpres +140 red-backed sandpiper, dunlin, Erolia alpina +141 redshank, Tringa totanus +142 dowitcher +143 oystercatcher, oyster catcher +144 pelican +145 king penguin, Aptenodytes patagonica +146 albatross, mollymawk +147 grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus +148 killer whale, killer, orca, grampus, sea wolf, Orcinus orca +149 dugong, Dugong dugon +150 sea lion +151 Chihuahua +152 Japanese spaniel +153 Maltese dog, Maltese terrier, Maltese +154 Pekinese, Pekingese, Peke +155 Shih-Tzu +156 Blenheim spaniel +157 papillon +158 toy terrier +159 Rhodesian ridgeback +160 Afghan hound, Afghan +161 basset, basset hound +162 beagle +163 bloodhound, sleuthhound +164 bluetick +165 black-and-tan coonhound +166 Walker hound, Walker foxhound +167 English foxhound +168 redbone +169 borzoi, Russian wolfhound +170 Irish wolfhound +171 Italian greyhound +172 whippet +173 Ibizan hound, Ibizan Podenco +174 Norwegian elkhound, elkhound +175 otterhound, otter hound +176 Saluki, gazelle hound +177 Scottish deerhound, deerhound +178 Weimaraner +179 Staffordshire bullterrier, Staffordshire bull terrier +180 American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier +181 Bedlington terrier +182 Border terrier +183 Kerry blue terrier +184 Irish terrier +185 Norfolk terrier +186 Norwich terrier +187 Yorkshire terrier +188 wire-haired fox terrier +189 Lakeland terrier +190 Sealyham terrier, Sealyham +191 Airedale, Airedale terrier +192 cairn, cairn terrier +193 Australian terrier +194 Dandie Dinmont, Dandie Dinmont terrier +195 Boston bull, Boston terrier +196 miniature schnauzer +197 giant schnauzer +198 standard schnauzer +199 Scotch terrier, Scottish terrier, Scottie +200 Tibetan terrier, chrysanthemum dog +201 silky terrier, Sydney silky +202 soft-coated wheaten terrier +203 West Highland white terrier +204 Lhasa, Lhasa apso +205 flat-coated retriever +206 curly-coated retriever +207 golden retriever +208 Labrador retriever +209 Chesapeake Bay retriever +210 German short-haired pointer +211 vizsla, Hungarian pointer +212 English setter +213 Irish setter, red setter +214 Gordon setter +215 Brittany spaniel +216 clumber, clumber spaniel +217 English springer, English springer spaniel +218 Welsh springer spaniel +219 cocker spaniel, English cocker spaniel, cocker +220 Sussex spaniel +221 Irish water spaniel +222 kuvasz +223 schipperke +224 groenendael +225 malinois +226 briard +227 kelpie +228 komondor +229 Old English sheepdog, bobtail +230 Shetland sheepdog, Shetland sheep dog, Shetland +231 collie +232 Border collie +233 Bouvier des Flandres, Bouviers des Flandres +234 Rottweiler +235 German shepherd, German shepherd dog, German police dog, alsatian +236 Doberman, Doberman pinscher +237 miniature pinscher +238 Greater Swiss Mountain dog +239 Bernese mountain dog +240 Appenzeller +241 EntleBucher +242 boxer +243 bull mastiff +244 Tibetan mastiff +245 French bulldog +246 Great Dane +247 Saint Bernard, St Bernard +248 Eskimo dog, husky +249 malamute, malemute, Alaskan malamute +250 Siberian husky +251 dalmatian, coach dog, carriage dog +252 affenpinscher, monkey pinscher, monkey dog +253 basenji +254 pug, pug-dog +255 Leonberg +256 Newfoundland, Newfoundland dog +257 Great Pyrenees +258 Samoyed, Samoyede +259 Pomeranian +260 chow, chow chow +261 keeshond +262 Brabancon griffon +263 Pembroke, Pembroke Welsh corgi +264 Cardigan, Cardigan Welsh corgi +265 toy poodle +266 miniature poodle +267 standard poodle +268 Mexican hairless +269 timber wolf, grey wolf, gray wolf, Canis lupus +270 white wolf, Arctic wolf, Canis lupus tundrarum +271 red wolf, maned wolf, Canis rufus, Canis niger +272 coyote, prairie wolf, brush wolf, Canis latrans +273 dingo, warrigal, warragal, Canis dingo +274 dhole, Cuon alpinus +275 African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus +276 hyena, hyaena +277 red fox, Vulpes vulpes +278 kit fox, Vulpes macrotis +279 Arctic fox, white fox, Alopex lagopus +280 grey fox, gray fox, Urocyon cinereoargenteus +281 tabby, tabby cat +282 tiger cat +283 Persian cat +284 Siamese cat, Siamese +285 Egyptian cat +286 cougar, puma, catamount, mountain lion, painter, panther, Felis concolor +287 lynx, catamount +288 leopard, Panthera pardus +289 snow leopard, ounce, Panthera uncia +290 jaguar, panther, Panthera onca, Felis onca +291 lion, king of beasts, Panthera leo +292 tiger, Panthera tigris +293 cheetah, chetah, Acinonyx jubatus +294 brown bear, bruin, Ursus arctos +295 American black bear, black bear, Ursus americanus, Euarctos americanus +296 ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus +297 sloth bear, Melursus ursinus, Ursus ursinus +298 mongoose +299 meerkat, mierkat +300 tiger beetle +301 ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle +302 ground beetle, carabid beetle +303 long-horned beetle, longicorn, longicorn beetle +304 leaf beetle, chrysomelid +305 dung beetle +306 rhinoceros beetle +307 weevil +308 fly +309 bee +310 ant, emmet, pismire +311 grasshopper, hopper +312 cricket +313 walking stick, walkingstick, stick insect +314 cockroach, roach +315 mantis, mantid +316 cicada, cicala +317 leafhopper +318 lacewing, lacewing fly +319 dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk +320 damselfly +321 admiral +322 ringlet, ringlet butterfly +323 monarch, monarch butterfly, milkweed butterfly, Danaus plexippus +324 cabbage butterfly +325 sulphur butterfly, sulfur butterfly +326 lycaenid, lycaenid butterfly +327 starfish, sea star +328 sea urchin +329 sea cucumber, holothurian +330 wood rabbit, cottontail, cottontail rabbit +331 hare +332 Angora, Angora rabbit +333 hamster +334 porcupine, hedgehog +335 fox squirrel, eastern fox squirrel, Sciurus niger +336 marmot +337 beaver +338 guinea pig, Cavia cobaya +339 sorrel +340 zebra +341 hog, pig, grunter, squealer, Sus scrofa +342 wild boar, boar, Sus scrofa +343 warthog +344 hippopotamus, hippo, river horse, Hippopotamus amphibius +345 ox +346 water buffalo, water ox, Asiatic buffalo, Bubalus bubalis +347 bison +348 ram, tup +349 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis +350 ibex, Capra ibex +351 hartebeest +352 impala, Aepyceros melampus +353 gazelle +354 Arabian camel, dromedary, Camelus dromedarius +355 llama +356 weasel +357 mink +358 polecat, fitch, foulmart, foumart, Mustela putorius +359 black-footed ferret, ferret, Mustela nigripes +360 otter +361 skunk, polecat, wood pussy +362 badger +363 armadillo +364 three-toed sloth, ai, Bradypus tridactylus +365 orangutan, orang, orangutang, Pongo pygmaeus +366 gorilla, Gorilla gorilla +367 chimpanzee, chimp, Pan troglodytes +368 gibbon, Hylobates lar +369 siamang, Hylobates syndactylus, Symphalangus syndactylus +370 guenon, guenon monkey +371 patas, hussar monkey, Erythrocebus patas +372 baboon +373 macaque +374 langur +375 colobus, colobus monkey +376 proboscis monkey, Nasalis larvatus +377 marmoset +378 capuchin, ringtail, Cebus capucinus +379 howler monkey, howler +380 titi, titi monkey +381 spider monkey, Ateles geoffroyi +382 squirrel monkey, Saimiri sciureus +383 Madagascar cat, ring-tailed lemur, Lemur catta +384 indri, indris, Indri indri, Indri brevicaudatus +385 Indian elephant, Elephas maximus +386 African elephant, Loxodonta africana +387 lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens +388 giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca +389 barracouta, snoek +390 eel +391 coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch +392 rock beauty, Holocanthus tricolor +393 anemone fish +394 sturgeon +395 gar, garfish, garpike, billfish, Lepisosteus osseus +396 lionfish +397 puffer, pufferfish, blowfish, globefish +398 abacus +399 abaya +400 academic gown, academic robe, judge's robe +401 accordion, piano accordion, squeeze box +402 acoustic guitar +403 aircraft carrier, carrier, flattop, attack aircraft carrier +404 airliner +405 airship, dirigible +406 altar +407 ambulance +408 amphibian, amphibious vehicle +409 analog clock +410 apiary, bee house +411 apron +412 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin +413 assault rifle, assault gun +414 backpack, back pack, knapsack, packsack, rucksack, haversack +415 bakery, bakeshop, bakehouse +416 balance beam, beam +417 balloon +418 ballpoint, ballpoint pen, ballpen, Biro +419 Band Aid +420 banjo +421 bannister, banister, balustrade, balusters, handrail +422 barbell +423 barber chair +424 barbershop +425 barn +426 barometer +427 barrel, cask +428 barrow, garden cart, lawn cart, wheelbarrow +429 baseball +430 basketball +431 bassinet +432 bassoon +433 bathing cap, swimming cap +434 bath towel +435 bathtub, bathing tub, bath, tub +436 beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon +437 beacon, lighthouse, beacon light, pharos +438 beaker +439 bearskin, busby, shako +440 beer bottle +441 beer glass +442 bell cote, bell cot +443 bib +444 bicycle-built-for-two, tandem bicycle, tandem +445 bikini, two-piece +446 binder, ring-binder +447 binoculars, field glasses, opera glasses +448 birdhouse +449 boathouse +450 bobsled, bobsleigh, bob +451 bolo tie, bolo, bola tie, bola +452 bonnet, poke bonnet +453 bookcase +454 bookshop, bookstore, bookstall +455 bottlecap +456 bow +457 bow tie, bow-tie, bowtie +458 brass, memorial tablet, plaque +459 brassiere, bra, bandeau +460 breakwater, groin, groyne, mole, bulwark, seawall, jetty +461 breastplate, aegis, egis +462 broom +463 bucket, pail +464 buckle +465 bulletproof vest +466 bullet train, bullet +467 butcher shop, meat market +468 cab, hack, taxi, taxicab +469 caldron, cauldron +470 candle, taper, wax light +471 cannon +472 canoe +473 can opener, tin opener +474 cardigan +475 car mirror +476 carousel, carrousel, merry-go-round, roundabout, whirligig +477 carpenter's kit, tool kit +478 carton +479 car wheel +480 cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM +481 cassette +482 cassette player +483 castle +484 catamaran +485 CD player +486 cello, violoncello +487 cellular telephone, cellular phone, cellphone, cell, mobile phone +488 chain +489 chainlink fence +490 chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour +491 chain saw, chainsaw +492 chest +493 chiffonier, commode +494 chime, bell, gong +495 china cabinet, china closet +496 Christmas stocking +497 church, church building +498 cinema, movie theater, movie theatre, movie house, picture palace +499 cleaver, meat cleaver, chopper +500 cliff dwelling +501 cloak +502 clog, geta, patten, sabot +503 cocktail shaker +504 coffee mug +505 coffeepot +506 coil, spiral, volute, whorl, helix +507 combination lock +508 computer keyboard, keypad +509 confectionery, confectionary, candy store +510 container ship, containership, container vessel +511 convertible +512 corkscrew, bottle screw +513 cornet, horn, trumpet, trump +514 cowboy boot +515 cowboy hat, ten-gallon hat +516 cradle +517 crane +518 crash helmet +519 crate +520 crib, cot +521 Crock Pot +522 croquet ball +523 crutch +524 cuirass +525 dam, dike, dyke +526 desk +527 desktop computer +528 dial telephone, dial phone +529 diaper, nappy, napkin +530 digital clock +531 digital watch +532 dining table, board +533 dishrag, dishcloth +534 dishwasher, dish washer, dishwashing machine +535 disk brake, disc brake +536 dock, dockage, docking facility +537 dogsled, dog sled, dog sleigh +538 dome +539 doormat, welcome mat +540 drilling platform, offshore rig +541 drum, membranophone, tympan +542 drumstick +543 dumbbell +544 Dutch oven +545 electric fan, blower +546 electric guitar +547 electric locomotive +548 entertainment center +549 envelope +550 espresso maker +551 face powder +552 feather boa, boa +553 file, file cabinet, filing cabinet +554 fireboat +555 fire engine, fire truck +556 fire screen, fireguard +557 flagpole, flagstaff +558 flute, transverse flute +559 folding chair +560 football helmet +561 forklift +562 fountain +563 fountain pen +564 four-poster +565 freight car +566 French horn, horn +567 frying pan, frypan, skillet +568 fur coat +569 garbage truck, dustcart +570 gasmask, respirator, gas helmet +571 gas pump, gasoline pump, petrol pump, island dispenser +572 goblet +573 go-kart +574 golf ball +575 golfcart, golf cart +576 gondola +577 gong, tam-tam +578 gown +579 grand piano, grand +580 greenhouse, nursery, glasshouse +581 grille, radiator grille +582 grocery store, grocery, food market, market +583 guillotine +584 hair slide +585 hair spray +586 half track +587 hammer +588 hamper +589 hand blower, blow dryer, blow drier, hair dryer, hair drier +590 hand-held computer, hand-held microcomputer +591 handkerchief, hankie, hanky, hankey +592 hard disc, hard disk, fixed disk +593 harmonica, mouth organ, harp, mouth harp +594 harp +595 harvester, reaper +596 hatchet +597 holster +598 home theater, home theatre +599 honeycomb +600 hook, claw +601 hoopskirt, crinoline +602 horizontal bar, high bar +603 horse cart, horse-cart +604 hourglass +605 iPod +606 iron, smoothing iron +607 jack-o'-lantern +608 jean, blue jean, denim +609 jeep, landrover +610 jersey, T-shirt, tee shirt +611 jigsaw puzzle +612 jinrikisha, ricksha, rickshaw +613 joystick +614 kimono +615 knee pad +616 knot +617 lab coat, laboratory coat +618 ladle +619 lampshade, lamp shade +620 laptop, laptop computer +621 lawn mower, mower +622 lens cap, lens cover +623 letter opener, paper knife, paperknife +624 library +625 lifeboat +626 lighter, light, igniter, ignitor +627 limousine, limo +628 liner, ocean liner +629 lipstick, lip rouge +630 Loafer +631 lotion +632 loudspeaker, speaker, speaker unit, loudspeaker system, speaker system +633 loupe, jeweler's loupe +634 lumbermill, sawmill +635 magnetic compass +636 mailbag, postbag +637 mailbox, letter box +638 maillot +639 maillot, tank suit +640 manhole cover +641 maraca +642 marimba, xylophone +643 mask +644 matchstick +645 maypole +646 maze, labyrinth +647 measuring cup +648 medicine chest, medicine cabinet +649 megalith, megalithic structure +650 microphone, mike +651 microwave, microwave oven +652 military uniform +653 milk can +654 minibus +655 miniskirt, mini +656 minivan +657 missile +658 mitten +659 mixing bowl +660 mobile home, manufactured home +661 Model T +662 modem +663 monastery +664 monitor +665 moped +666 mortar +667 mortarboard +668 mosque +669 mosquito net +670 motor scooter, scooter +671 mountain bike, all-terrain bike, off-roader +672 mountain tent +673 mouse, computer mouse +674 mousetrap +675 moving van +676 muzzle +677 nail +678 neck brace +679 necklace +680 nipple +681 notebook, notebook computer +682 obelisk +683 oboe, hautboy, hautbois +684 ocarina, sweet potato +685 odometer, hodometer, mileometer, milometer +686 oil filter +687 organ, pipe organ +688 oscilloscope, scope, cathode-ray oscilloscope, CRO +689 overskirt +690 oxcart +691 oxygen mask +692 packet +693 paddle, boat paddle +694 paddlewheel, paddle wheel +695 padlock +696 paintbrush +697 pajama, pyjama, pj's, jammies +698 palace +699 panpipe, pandean pipe, syrinx +700 paper towel +701 parachute, chute +702 parallel bars, bars +703 park bench +704 parking meter +705 passenger car, coach, carriage +706 patio, terrace +707 pay-phone, pay-station +708 pedestal, plinth, footstall +709 pencil box, pencil case +710 pencil sharpener +711 perfume, essence +712 Petri dish +713 photocopier +714 pick, plectrum, plectron +715 pickelhaube +716 picket fence, paling +717 pickup, pickup truck +718 pier +719 piggy bank, penny bank +720 pill bottle +721 pillow +722 ping-pong ball +723 pinwheel +724 pirate, pirate ship +725 pitcher, ewer +726 plane, carpenter's plane, woodworking plane +727 planetarium +728 plastic bag +729 plate rack +730 plow, plough +731 plunger, plumber's helper +732 Polaroid camera, Polaroid Land camera +733 pole +734 police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria +735 poncho +736 pool table, billiard table, snooker table +737 pop bottle, soda bottle +738 pot, flowerpot +739 potter's wheel +740 power drill +741 prayer rug, prayer mat +742 printer +743 prison, prison house +744 projectile, missile +745 projector +746 puck, hockey puck +747 punching bag, punch bag, punching ball, punchball +748 purse +749 quill, quill pen +750 quilt, comforter, comfort, puff +751 racer, race car, racing car +752 racket, racquet +753 radiator +754 radio, wireless +755 radio telescope, radio reflector +756 rain barrel +757 recreational vehicle, RV, R.V. +758 reel +759 reflex camera +760 refrigerator, icebox +761 remote control, remote +762 restaurant, eating house, eating place, eatery +763 revolver, six-gun, six-shooter +764 rifle +765 rocking chair, rocker +766 rotisserie +767 rubber eraser, rubber, pencil eraser +768 rugby ball +769 rule, ruler +770 running shoe +771 safe +772 safety pin +773 saltshaker, salt shaker +774 sandal +775 sarong +776 sax, saxophone +777 scabbard +778 scale, weighing machine +779 school bus +780 schooner +781 scoreboard +782 screen, CRT screen +783 screw +784 screwdriver +785 seat belt, seatbelt +786 sewing machine +787 shield, buckler +788 shoe shop, shoe-shop, shoe store +789 shoji +790 shopping basket +791 shopping cart +792 shovel +793 shower cap +794 shower curtain +795 ski +796 ski mask +797 sleeping bag +798 slide rule, slipstick +799 sliding door +800 slot, one-armed bandit +801 snorkel +802 snowmobile +803 snowplow, snowplough +804 soap dispenser +805 soccer ball +806 sock +807 solar dish, solar collector, solar furnace +808 sombrero +809 soup bowl +810 space bar +811 space heater +812 space shuttle +813 spatula +814 speedboat +815 spider web, spider's web +816 spindle +817 sports car, sport car +818 spotlight, spot +819 stage +820 steam locomotive +821 steel arch bridge +822 steel drum +823 stethoscope +824 stole +825 stone wall +826 stopwatch, stop watch +827 stove +828 strainer +829 streetcar, tram, tramcar, trolley, trolley car +830 stretcher +831 studio couch, day bed +832 stupa, tope +833 submarine, pigboat, sub, U-boat +834 suit, suit of clothes +835 sundial +836 sunglass +837 sunglasses, dark glasses, shades +838 sunscreen, sunblock, sun blocker +839 suspension bridge +840 swab, swob, mop +841 sweatshirt +842 swimming trunks, bathing trunks +843 swing +844 switch, electric switch, electrical switch +845 syringe +846 table lamp +847 tank, army tank, armored combat vehicle, armoured combat vehicle +848 tape player +849 teapot +850 teddy, teddy bear +851 television, television system +852 tennis ball +853 thatch, thatched roof +854 theater curtain, theatre curtain +855 thimble +856 thresher, thrasher, threshing machine +857 throne +858 tile roof +859 toaster +860 tobacco shop, tobacconist shop, tobacconist +861 toilet seat +862 torch +863 totem pole +864 tow truck, tow car, wrecker +865 toyshop +866 tractor +867 trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi +868 tray +869 trench coat +870 tricycle, trike, velocipede +871 trimaran +872 tripod +873 triumphal arch +874 trolleybus, trolley coach, trackless trolley +875 trombone +876 tub, vat +877 turnstile +878 typewriter keyboard +879 umbrella +880 unicycle, monocycle +881 upright, upright piano +882 vacuum, vacuum cleaner +883 vase +884 vault +885 velvet +886 vending machine +887 vestment +888 viaduct +889 violin, fiddle +890 volleyball +891 waffle iron +892 wall clock +893 wallet, billfold, notecase, pocketbook +894 wardrobe, closet, press +895 warplane, military plane +896 washbasin, handbasin, washbowl, lavabo, wash-hand basin +897 washer, automatic washer, washing machine +898 water bottle +899 water jug +900 water tower +901 whiskey jug +902 whistle +903 wig +904 window screen +905 window shade +906 Windsor tie +907 wine bottle +908 wing +909 wok +910 wooden spoon +911 wool, woolen, woollen +912 worm fence, snake fence, snake-rail fence, Virginia fence +913 wreck +914 yawl +915 yurt +916 web site, website, internet site, site +917 comic book +918 crossword puzzle, crossword +919 street sign +920 traffic light, traffic signal, stoplight +921 book jacket, dust cover, dust jacket, dust wrapper +922 menu +923 plate +924 guacamole +925 consomme +926 hot pot, hotpot +927 trifle +928 ice cream, icecream +929 ice lolly, lolly, lollipop, popsicle +930 French loaf +931 bagel, beigel +932 pretzel +933 cheeseburger +934 hotdog, hot dog, red hot +935 mashed potato +936 head cabbage +937 broccoli +938 cauliflower +939 zucchini, courgette +940 spaghetti squash +941 acorn squash +942 butternut squash +943 cucumber, cuke +944 artichoke, globe artichoke +945 bell pepper +946 cardoon +947 mushroom +948 Granny Smith +949 strawberry +950 orange +951 lemon +952 fig +953 pineapple, ananas +954 banana +955 jackfruit, jak, jack +956 custard apple +957 pomegranate +958 hay +959 carbonara +960 chocolate sauce, chocolate syrup +961 dough +962 meat loaf, meatloaf +963 pizza, pizza pie +964 potpie +965 burrito +966 red wine +967 espresso +968 cup +969 eggnog +970 alp +971 bubble +972 cliff, drop, drop-off +973 coral reef +974 geyser +975 lakeside, lakeshore +976 promontory, headland, head, foreland +977 sandbar, sand bar +978 seashore, coast, seacoast, sea-coast +979 valley, vale +980 volcano +981 ballplayer, baseball player +982 groom, bridegroom +983 scuba diver +984 rapeseed +985 daisy +986 yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum +987 corn +988 acorn +989 hip, rose hip, rosehip +990 buckeye, horse chestnut, conker +991 coral fungus +992 agaric +993 gyromitra +994 stinkhorn, carrion fungus +995 earthstar +996 hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa +997 bolete +998 ear, spike, capitulum +999 toilet tissue, toilet paper, bathroom tissue diff --git a/src/PaddleClas/ppcls/utils/logger.py b/src/PaddleClas/ppcls/utils/logger.py new file mode 100644 index 0000000..d4faaa9 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/logger.py @@ -0,0 +1,137 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import os +import sys + +import logging +import datetime +import paddle.distributed as dist + +_logger = None + + +def init_logger(name='root', log_file=None, log_level=logging.INFO): + """Initialize and get a logger by name. + If the logger has not been initialized, this method will initialize the + logger by adding one or two handlers, otherwise the initialized logger will + be directly returned. During initialization, a StreamHandler will always be + added. If `log_file` is specified a FileHandler will also be added. + Args: + name (str): Logger name. + log_file (str | None): The log filename. If specified, a FileHandler + will be added to the logger. + log_level (int): The logger level. Note that only the process of + rank 0 is affected, and other processes will set the level to + "Error" thus be silent most of the time. + Returns: + logging.Logger: The expected logger. + """ + global _logger + assert _logger is None, "logger should not be initialized twice or more." + _logger = logging.getLogger(name) + + formatter = logging.Formatter( + '[%(asctime)s] %(name)s %(levelname)s: %(message)s', + datefmt="%Y/%m/%d %H:%M:%S") + + stream_handler = logging.StreamHandler(stream=sys.stdout) + stream_handler.setFormatter(formatter) + _logger.addHandler(stream_handler) + if log_file is not None and dist.get_rank() == 0: + log_file_folder = os.path.split(log_file)[0] + os.makedirs(log_file_folder, exist_ok=True) + file_handler = logging.FileHandler(log_file, 'a') + file_handler.setFormatter(formatter) + _logger.addHandler(file_handler) + if dist.get_rank() == 0: + _logger.setLevel(log_level) + else: + _logger.setLevel(logging.ERROR) + + +def log_at_trainer0(log): + """ + logs will print multi-times when calling Fleet API. + Only display single log and ignore the others. + """ + + def wrapper(fmt, *args): + if dist.get_rank() == 0: + log(fmt, *args) + + return wrapper + + +@log_at_trainer0 +def info(fmt, *args): + _logger.info(fmt, *args) + + +@log_at_trainer0 +def debug(fmt, *args): + _logger.debug(fmt, *args) + + +@log_at_trainer0 +def warning(fmt, *args): + _logger.warning(fmt, *args) + + +@log_at_trainer0 +def error(fmt, *args): + _logger.error(fmt, *args) + + +def scaler(name, value, step, writer): + """ + This function will draw a scalar curve generated by the visualdl. + Usage: Install visualdl: pip3 install visualdl==2.0.0b4 + and then: + visualdl --logdir ./scalar --host 0.0.0.0 --port 8830 + to preview loss corve in real time. + """ + if writer is None: + return + writer.add_scalar(tag=name, step=step, value=value) + + +def advertise(): + """ + Show the advertising message like the following: + + =========================================================== + == PaddleClas is powered by PaddlePaddle ! == + =========================================================== + == == + == For more info please go to the following website. == + == == + == https://github.com/PaddlePaddle/PaddleClas == + =========================================================== + + """ + copyright = "PaddleClas is powered by PaddlePaddle !" + ad = "For more info please go to the following website." + website = "https://github.com/PaddlePaddle/PaddleClas" + AD_LEN = 6 + len(max([copyright, ad, website], key=len)) + + info("\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}\n".format( + "=" * (AD_LEN + 4), + "=={}==".format(copyright.center(AD_LEN)), + "=" * (AD_LEN + 4), + "=={}==".format(' ' * AD_LEN), + "=={}==".format(ad.center(AD_LEN)), + "=={}==".format(' ' * AD_LEN), + "=={}==".format(website.center(AD_LEN)), + "=" * (AD_LEN + 4), )) diff --git a/src/PaddleClas/ppcls/utils/metrics.py b/src/PaddleClas/ppcls/utils/metrics.py new file mode 100644 index 0000000..b0db68a --- /dev/null +++ b/src/PaddleClas/ppcls/utils/metrics.py @@ -0,0 +1,107 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from sklearn.metrics import hamming_loss +from sklearn.metrics import accuracy_score as accuracy_metric +from sklearn.metrics import multilabel_confusion_matrix +from sklearn.metrics import precision_recall_fscore_support +from sklearn.metrics import average_precision_score +from sklearn.preprocessing import binarize + +import numpy as np + +__all__ = ["multi_hot_encode", "hamming_distance", "accuracy_score", "precision_recall_fscore", "mean_average_precision"] + + +def multi_hot_encode(logits, threshold=0.5): + """ + Encode logits to multi-hot by elementwise for multilabel + """ + + return binarize(logits, threshold=threshold) + + +def hamming_distance(output, target): + """ + Soft metric based label for multilabel classification + Returns: + The smaller the return value is, the better model is. + """ + + return hamming_loss(target, output) + + +def accuracy_score(output, target, base="sample"): + """ + Hard metric for multilabel classification + Args: + output: + target: + base: ["sample", "label"], default="sample" + if "sample", return metric score based sample, + if "label", return metric score based label. + Returns: + accuracy: + """ + + assert base in ["sample", "label"], 'must be one of ["sample", "label"]' + + if base == "sample": + accuracy = accuracy_metric(target, output) + elif base == "label": + mcm = multilabel_confusion_matrix(target, output) + tns = mcm[:, 0, 0] + fns = mcm[:, 1, 0] + tps = mcm[:, 1, 1] + fps = mcm[:, 0, 1] + + accuracy = (sum(tps) + sum(tns)) / (sum(tps) + sum(tns) + sum(fns) + sum(fps)) + + return accuracy + + +def precision_recall_fscore(output, target): + """ + Metric based label for multilabel classification + Returns: + precisions: + recalls: + fscores: + """ + + precisions, recalls, fscores, _ = precision_recall_fscore_support(target, output) + + return precisions, recalls, fscores + + +def mean_average_precision(logits, target): + """ + Calculate average precision + Args: + logits: probability from network before sigmoid or softmax + target: ground truth, 0 or 1 + """ + if not (isinstance(logits, np.ndarray) and isinstance(target, np.ndarray)): + raise TypeError("logits and target should be np.ndarray.") + + aps = [] + for i in range(target.shape[1]): + ap = average_precision_score(target[:, i], logits[:, i]) + aps.append(ap) + + return np.mean(aps) diff --git a/src/PaddleClas/ppcls/utils/misc.py b/src/PaddleClas/ppcls/utils/misc.py new file mode 100644 index 0000000..08ab7b6 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/misc.py @@ -0,0 +1,63 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +__all__ = ['AverageMeter'] + + +class AverageMeter(object): + """ + Computes and stores the average and current value + Code was based on https://github.com/pytorch/examples/blob/master/imagenet/main.py + """ + + def __init__(self, name='', fmt='f', postfix="", need_avg=True): + self.name = name + self.fmt = fmt + self.postfix = postfix + self.need_avg = need_avg + self.reset() + + def reset(self): + """ reset """ + self.val = 0 + self.avg = 0 + self.sum = 0 + self.count = 0 + + def update(self, val, n=1): + """ update """ + self.val = val + self.sum += val * n + self.count += n + self.avg = self.sum / self.count + + @property + def total(self): + return '{self.name}_sum: {self.sum:{self.fmt}}{self.postfix}'.format( + self=self) + + @property + def total_minute(self): + return '{self.name} {s:{self.fmt}}{self.postfix} min'.format( + s=self.sum / 60, self=self) + + @property + def mean(self): + return '{self.name}: {self.avg:{self.fmt}}{self.postfix}'.format( + self=self) if self.need_avg else '' + + @property + def value(self): + return '{self.name}: {self.val:{self.fmt}}{self.postfix}'.format( + self=self) diff --git a/src/PaddleClas/ppcls/utils/model_zoo.py b/src/PaddleClas/ppcls/utils/model_zoo.py new file mode 100644 index 0000000..fc527f6 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/model_zoo.py @@ -0,0 +1,213 @@ +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +import requests +import shutil +import tarfile +import tqdm +import zipfile + +from ppcls.arch import similar_architectures +from ppcls.utils import logger + +__all__ = ['get'] + +DOWNLOAD_RETRY_LIMIT = 3 + + +class UrlError(Exception): + """ UrlError + """ + + def __init__(self, url='', code=''): + message = "Downloading from {} failed with code {}!".format(url, code) + super(UrlError, self).__init__(message) + + +class ModelNameError(Exception): + """ ModelNameError + """ + + def __init__(self, message=''): + super(ModelNameError, self).__init__(message) + + +class RetryError(Exception): + """ RetryError + """ + + def __init__(self, url='', times=''): + message = "Download from {} failed. Retry({}) limit reached".format( + url, times) + super(RetryError, self).__init__(message) + + +def _get_url(architecture, postfix="pdparams"): + prefix = "https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/" + fname = architecture + "_pretrained." + postfix + return prefix + fname + + +def _move_and_merge_tree(src, dst): + """ + Move src directory to dst, if dst is already exists, + merge src to dst + """ + if not os.path.exists(dst): + shutil.move(src, dst) + elif os.path.isfile(src): + shutil.move(src, dst) + else: + for fp in os.listdir(src): + src_fp = os.path.join(src, fp) + dst_fp = os.path.join(dst, fp) + if os.path.isdir(src_fp): + if os.path.isdir(dst_fp): + _move_and_merge_tree(src_fp, dst_fp) + else: + shutil.move(src_fp, dst_fp) + elif os.path.isfile(src_fp) and \ + not os.path.isfile(dst_fp): + shutil.move(src_fp, dst_fp) + + +def _download(url, path): + """ + Download from url, save to path. + url (str): download url + path (str): download to given path + """ + if not os.path.exists(path): + os.makedirs(path) + + fname = os.path.split(url)[-1] + fullname = os.path.join(path, fname) + retry_cnt = 0 + + while not os.path.exists(fullname): + if retry_cnt < DOWNLOAD_RETRY_LIMIT: + retry_cnt += 1 + else: + raise RetryError(url, DOWNLOAD_RETRY_LIMIT) + + logger.info("Downloading {} from {}".format(fname, url)) + + req = requests.get(url, stream=True) + if req.status_code != 200: + raise UrlError(url, req.status_code) + + # For protecting download interupted, download to + # tmp_fullname firstly, move tmp_fullname to fullname + # after download finished + tmp_fullname = fullname + "_tmp" + total_size = req.headers.get('content-length') + with open(tmp_fullname, 'wb') as f: + if total_size: + for chunk in tqdm.tqdm( + req.iter_content(chunk_size=1024), + total=(int(total_size) + 1023) // 1024, + unit='KB'): + f.write(chunk) + else: + for chunk in req.iter_content(chunk_size=1024): + if chunk: + f.write(chunk) + shutil.move(tmp_fullname, fullname) + + return fullname + + +def _decompress(fname): + """ + Decompress for zip and tar file + """ + logger.info("Decompressing {}...".format(fname)) + + # For protecting decompressing interupted, + # decompress to fpath_tmp directory firstly, if decompress + # successed, move decompress files to fpath and delete + # fpath_tmp and remove download compress file. + fpath = os.path.split(fname)[0] + fpath_tmp = os.path.join(fpath, 'tmp') + if os.path.isdir(fpath_tmp): + shutil.rmtree(fpath_tmp) + os.makedirs(fpath_tmp) + + if fname.find('tar') >= 0: + with tarfile.open(fname) as tf: + tf.extractall(path=fpath_tmp) + elif fname.find('zip') >= 0: + with zipfile.ZipFile(fname) as zf: + zf.extractall(path=fpath_tmp) + else: + raise TypeError("Unsupport compress file type {}".format(fname)) + + fs = os.listdir(fpath_tmp) + assert len( + fs + ) == 1, "There should just be 1 pretrained path in an archive file but got {}.".format( + len(fs)) + + f = fs[0] + src_dir = os.path.join(fpath_tmp, f) + dst_dir = os.path.join(fpath, f) + _move_and_merge_tree(src_dir, dst_dir) + + shutil.rmtree(fpath_tmp) + os.remove(fname) + + return f + + +def _get_pretrained(): + with open('./ppcls/utils/pretrained.list') as flist: + pretrained = [line.strip() for line in flist] + return pretrained + + +def _check_pretrained_name(architecture): + assert isinstance(architecture, str), \ + ("the type of architecture({}) should be str". format(architecture)) + pretrained = _get_pretrained() + similar_names = similar_architectures(architecture, pretrained) + model_list = ', '.join(similar_names) + err = "{} is not exist! Maybe you want: [{}]" \ + "".format(architecture, model_list) + if architecture not in similar_names: + raise ModelNameError(err) + + +def list_models(): + pretrained = _get_pretrained() + msg = "All avialable pretrained models are as follows: {}".format( + pretrained) + logger.info(msg) + return + + +def get(architecture, path, decompress=False, postfix="pdparams"): + """ + Get the pretrained model. + """ + _check_pretrained_name(architecture) + url = _get_url(architecture, postfix=postfix) + fname = _download(url, path) + if postfix == "tar" and decompress: + _decompress(fname) + logger.info("download {} finished ".format(fname)) diff --git a/src/PaddleClas/ppcls/utils/pretrained.list b/src/PaddleClas/ppcls/utils/pretrained.list new file mode 100644 index 0000000..36d70f5 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/pretrained.list @@ -0,0 +1,121 @@ +ResNet18 +ResNet34 +ResNet50 +ResNet101 +ResNet152 +ResNet50_vc +ResNet18_vd +ResNet34_vd +ResNet50_vd +ResNet50_vd_v2 +ResNet101_vd +ResNet152_vd +ResNet200_vd +ResNet50_vd_ssld +ResNet50_vd_ssld_v2 +Fix_ResNet50_vd_ssld_v2 +ResNet101_vd_ssld +MobileNetV3_large_x0_35 +MobileNetV3_large_x0_5 +MobileNetV3_large_x0_75 +MobileNetV3_large_x1_0 +MobileNetV3_large_x1_25 +MobileNetV3_small_x0_35 +MobileNetV3_small_x0_5 +MobileNetV3_small_x0_75 +MobileNetV3_small_x1_0 +MobileNetV3_small_x1_25 +MobileNetV3_large_x1_0_ssld +MobileNetV3_large_x1_0_ssld_int8 +MobileNetV3_small_x1_0_ssld +MobileNetV2_x0_25 +MobileNetV2_x0_5 +MobileNetV2_x0_75 +MobileNetV2 +MobileNetV2_x1_5 +MobileNetV2_x2_0 +MobileNetV2_ssld +MobileNetV1_x0_25 +MobileNetV1_x0_5 +MobileNetV1_x0_75 +MobileNetV1 +MobileNetV1_ssld +ShuffleNetV2_x0_25 +ShuffleNetV2_x0_33 +ShuffleNetV2_x0_5 +ShuffleNetV2 +ShuffleNetV2_x1_5 +ShuffleNetV2_x2_0 +ShuffleNetV2_swish +ResNeXt50_32x4d +ResNeXt50_64x4d +ResNeXt101_32x4d +ResNeXt101_64x4d +ResNeXt152_32x4d +ResNeXt152_64x4d +ResNeXt50_vd_32x4d +ResNeXt50_vd_64x4d +ResNeXt101_vd_32x4d +ResNeXt101_vd_64x4d +ResNeXt152_vd_32x4d +ResNeXt152_vd_64x4d +SE_ResNet18_vd +SE_ResNet34_vd +SE_ResNet50_vd +SE_ResNeXt50_32x4d +SE_ResNeXt101_32x4d +SE_ResNeXt50_vd_32x4d +SENet154_vd +Res2Net50_26w_4s +Res2Net50_vd_26w_4s +Res2Net50_14w_8s +Res2Net101_vd_26w_4s +Res2Net200_vd_26w_4s +GoogLeNet +InceptionV4 +Xception41 +Xception41_deeplab +Xception65 +Xception65_deeplab +Xception71 +HRNet_W18_C +HRNet_W30_C +HRNet_W32_C +HRNet_W40_C +HRNet_W44_C +HRNet_W48_C +HRNet_W64_C +DPN68 +DPN92 +DPN98 +DPN107 +DPN131 +DenseNet121 +DenseNet161 +DenseNet169 +DenseNet201 +DenseNet264 +EfficientNetB0_small +EfficientNetB0 +EfficientNetB1 +EfficientNetB2 +EfficientNetB3 +EfficientNetB4 +EfficientNetB5 +EfficientNetB6 +EfficientNetB7 +ResNeXt101_32x8d_wsl +ResNeXt101_32x16d_wsl +ResNeXt101_32x32d_wsl +ResNeXt101_32x48d_wsl +Fix_ResNeXt101_32x48d_wsl +AlexNet +SqueezeNet1_0 +SqueezeNet1_1 +VGG11 +VGG13 +VGG16 +VGG19 +DarkNet53_ImageNet1k +ResNet50_ACNet_deploy +CSPResNet50_leaky diff --git a/src/PaddleClas/ppcls/utils/profiler.py b/src/PaddleClas/ppcls/utils/profiler.py new file mode 100644 index 0000000..7cf945a --- /dev/null +++ b/src/PaddleClas/ppcls/utils/profiler.py @@ -0,0 +1,111 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +import sys +import paddle + +# A global variable to record the number of calling times for profiler +# functions. It is used to specify the tracing range of training steps. +_profiler_step_id = 0 + +# A global variable to avoid parsing from string every time. +_profiler_options = None + + +class ProfilerOptions(object): + ''' + Use a string to initialize a ProfilerOptions. + The string should be in the format: "key1=value1;key2=value;key3=value3". + For example: + "profile_path=model.profile" + "batch_range=[50, 60]; profile_path=model.profile" + "batch_range=[50, 60]; tracer_option=OpDetail; profile_path=model.profile" + + ProfilerOptions supports following key-value pair: + batch_range - a integer list, e.g. [100, 110]. + state - a string, the optional values are 'CPU', 'GPU' or 'All'. + sorted_key - a string, the optional values are 'calls', 'total', + 'max', 'min' or 'ave. + tracer_option - a string, the optional values are 'Default', 'OpDetail', + 'AllOpDetail'. + profile_path - a string, the path to save the serialized profile data, + which can be used to generate a timeline. + exit_on_finished - a boolean. + ''' + + def __init__(self, options_str): + assert isinstance(options_str, str) + + self._options = { + 'batch_range': [10, 20], + 'state': 'All', + 'sorted_key': 'total', + 'tracer_option': 'Default', + 'profile_path': '/tmp/profile', + 'exit_on_finished': True + } + self._parse_from_string(options_str) + + def _parse_from_string(self, options_str): + for kv in options_str.replace(' ', '').split(';'): + key, value = kv.split('=') + if key == 'batch_range': + value_list = value.replace('[', '').replace(']', '').split(',') + value_list = list(map(int, value_list)) + if len(value_list) >= 2 and value_list[0] >= 0 and value_list[ + 1] > value_list[0]: + self._options[key] = value_list + elif key == 'exit_on_finished': + self._options[key] = value.lower() in ("yes", "true", "t", "1") + elif key in [ + 'state', 'sorted_key', 'tracer_option', 'profile_path' + ]: + self._options[key] = value + + def __getitem__(self, name): + if self._options.get(name, None) is None: + raise ValueError( + "ProfilerOptions does not have an option named %s." % name) + return self._options[name] + + +def add_profiler_step(options_str=None): + ''' + Enable the operator-level timing using PaddlePaddle's profiler. + The profiler uses a independent variable to count the profiler steps. + One call of this function is treated as a profiler step. + + Args: + profiler_options - a string to initialize the ProfilerOptions. + Default is None, and the profiler is disabled. + ''' + if options_str is None: + return + + global _profiler_step_id + global _profiler_options + + if _profiler_options is None: + _profiler_options = ProfilerOptions(options_str) + + if _profiler_step_id == _profiler_options['batch_range'][0]: + paddle.utils.profiler.start_profiler( + _profiler_options['state'], _profiler_options['tracer_option']) + elif _profiler_step_id == _profiler_options['batch_range'][1]: + paddle.utils.profiler.stop_profiler(_profiler_options['sorted_key'], + _profiler_options['profile_path']) + if _profiler_options['exit_on_finished']: + sys.exit(0) + + _profiler_step_id += 1 diff --git a/src/PaddleClas/ppcls/utils/save_load.py b/src/PaddleClas/ppcls/utils/save_load.py new file mode 100644 index 0000000..625a284 --- /dev/null +++ b/src/PaddleClas/ppcls/utils/save_load.py @@ -0,0 +1,136 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import errno +import os +import re +import shutil +import tempfile + +import paddle +from ppcls.utils import logger +from .download import get_weights_path_from_url + +__all__ = ['init_model', 'save_model', 'load_dygraph_pretrain'] + + +def _mkdir_if_not_exist(path): + """ + mkdir if not exists, ignore the exception when multiprocess mkdir together + """ + if not os.path.exists(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(path): + logger.warning( + 'be happy if some process has already created {}'.format( + path)) + else: + raise OSError('Failed to mkdir {}'.format(path)) + + +def load_dygraph_pretrain(model, path=None): + if not (os.path.isdir(path) or os.path.exists(path + '.pdparams')): + raise ValueError("Model pretrain path {} does not " + "exists.".format(path)) + param_state_dict = paddle.load(path + ".pdparams") + model.set_dict(param_state_dict) + return + + +def load_dygraph_pretrain_from_url(model, pretrained_url, use_ssld=False): + if use_ssld: + pretrained_url = pretrained_url.replace("_pretrained", + "_ssld_pretrained") + local_weight_path = get_weights_path_from_url(pretrained_url).replace( + ".pdparams", "") + load_dygraph_pretrain(model, path=local_weight_path) + return + + +def load_distillation_model(model, pretrained_model): + logger.info("In distillation mode, teacher model will be " + "loaded firstly before student model.") + + if not isinstance(pretrained_model, list): + pretrained_model = [pretrained_model] + + teacher = model.teacher if hasattr(model, + "teacher") else model._layers.teacher + student = model.student if hasattr(model, + "student") else model._layers.student + load_dygraph_pretrain(teacher, path=pretrained_model[0]) + logger.info("Finish initing teacher model from {}".format( + pretrained_model)) + # load student model + if len(pretrained_model) >= 2: + load_dygraph_pretrain(student, path=pretrained_model[1]) + logger.info("Finish initing student model from {}".format( + pretrained_model)) + + +def init_model(config, net, optimizer=None): + """ + load model from checkpoint or pretrained_model + """ + checkpoints = config.get('checkpoints') + if checkpoints and optimizer is not None: + assert os.path.exists(checkpoints + ".pdparams"), \ + "Given dir {}.pdparams not exist.".format(checkpoints) + assert os.path.exists(checkpoints + ".pdopt"), \ + "Given dir {}.pdopt not exist.".format(checkpoints) + para_dict = paddle.load(checkpoints + ".pdparams") + opti_dict = paddle.load(checkpoints + ".pdopt") + metric_dict = paddle.load(checkpoints + ".pdstates") + net.set_dict(para_dict) + optimizer.set_state_dict(opti_dict) + logger.info("Finish load checkpoints from {}".format(checkpoints)) + return metric_dict + + pretrained_model = config.get('pretrained_model') + use_distillation = config.get('use_distillation', False) + if pretrained_model: + if use_distillation: + load_distillation_model(net, pretrained_model) + else: # common load + load_dygraph_pretrain(net, path=pretrained_model) + logger.info( + logger.coloring("Finish load pretrained model from {}".format( + pretrained_model), "HEADER")) + + +def save_model(net, + optimizer, + metric_info, + model_path, + model_name="", + prefix='ppcls'): + """ + save model to the target path + """ + if paddle.distributed.get_rank() != 0: + return + model_path = os.path.join(model_path, model_name) + _mkdir_if_not_exist(model_path) + model_path = os.path.join(model_path, prefix) + + paddle.save(net.state_dict(), model_path + ".pdparams") + paddle.save(optimizer.state_dict(), model_path + ".pdopt") + paddle.save(metric_info, model_path + ".pdstates") + logger.info("Already save model in {}".format(model_path)) diff --git a/src/PaddleClas/requirements.txt b/src/PaddleClas/requirements.txt new file mode 100644 index 0000000..79f548c --- /dev/null +++ b/src/PaddleClas/requirements.txt @@ -0,0 +1,11 @@ +prettytable +ujson +opencv-python==4.4.0.46 +pillow +tqdm +PyYAML +visualdl >= 2.2.0 +scipy +scikit-learn==0.23.2 +gast==0.3.3 +faiss-cpu==1.7.1.post2 diff --git a/src/PaddleClas/setup.py b/src/PaddleClas/setup.py new file mode 100644 index 0000000..57045d3 --- /dev/null +++ b/src/PaddleClas/setup.py @@ -0,0 +1,60 @@ +# Copyright (c) 2021 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 io import open +from setuptools import setup + +with open('requirements.txt', encoding="utf-8-sig") as f: + requirements = f.readlines() + + +def readme(): + with open( + 'docs/en/inference_deployment/whl_deploy_en.md', + encoding="utf-8-sig") as f: + README = f.read() + return README + + +setup( + name='paddleclas', + packages=['paddleclas'], + package_dir={'paddleclas': ''}, + include_package_data=True, + entry_points={ + "console_scripts": ["paddleclas= paddleclas.paddleclas:main"] + }, + version='0.0.0', + install_requires=requirements, + license='Apache License 2.0', + description='Awesome Image Classification toolkits based on PaddlePaddle ', + long_description=readme(), + long_description_content_type='text/markdown', + url='https://github.com/PaddlePaddle/PaddleClas', + download_url='https://github.com/PaddlePaddle/PaddleClas.git', + keywords=[ + 'A treasure chest for image classification powered by PaddlePaddle.' + ], + classifiers=[ + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Natural Language :: Chinese (Simplified)', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Utilities' + ], ) diff --git a/src/PaddleClas/test_tipc/README.md b/src/PaddleClas/test_tipc/README.md new file mode 100644 index 0000000..4869f6e --- /dev/null +++ b/src/PaddleClas/test_tipc/README.md @@ -0,0 +1,108 @@ + +# 飞桨训推一体认证 + +## 1. 简介 + +飞桨除了基本的模型训练和预测,还提供了支持多端多平台的高性能推理部署工具。本文档提供了PaddleClas中所有模型的飞桨训推一体认证 (Training and Inference Pipeline Certification(TIPC)) 信息和测试工具,方便用户查阅每种模型的训练推理部署打通情况,并可以进行一键测试。 + +
+ +
+ +## 2. 汇总信息 + +打通情况汇总如下,已填写的部分表示可以使用本工具进行一键测试,未填写的表示正在支持中。 + +**字段说明:** +- 基础训练预测:包括模型训练、Paddle Inference Python预测。 +- 更多训练方式:包括多机多卡、混合精度。 +- 模型压缩:包括裁剪、离线/在线量化、蒸馏。 +- 其他预测部署:包括Paddle Inference C++预测、Paddle Serving部署、Paddle-Lite部署等。 + +更详细的mkldnn、Tensorrt等预测加速相关功能的支持情况可以查看各测试工具的[更多教程](#more)。 +| 算法论文 | 模型名称 | 模型类型 | 基础
训练预测 | 更多
训练方式 | 模型压缩 | 其他预测部署 | +| :--- | :--- | :----: | :--------: | :---- | :---- | :---- | +| ResNet |ResNet50_vd | 分类 | 支持 | 多机多卡
混合精度 | FPGM裁剪
PACT量化| | +| MobileNetV3 |MobileNetV3_large_x1_0 | 分类 | 支持 | 多机多卡
混合精度 | FPGM裁剪
PACT量化| | +| PPLCNet |PPLCNet_x2_5 | 分类 | 支持 | 多机多卡
混合精度 | - | | + +## 3. 测试工具简介 +### 目录介绍 +``` +./test_tipc/ +├── common_func.sh #test_*.sh会调用到的公共函数 +├── config # 配置文件目录 +│ ├── MobileNetV3 # MobileNetV3系列模型测试配置文件目录 +│ │ ├── MobileNetV3_large_x1_0_train_infer_python.txt #基础训练预测配置文件 +│ │ ├── MobileNetV3_large_x1_0_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt #多机多卡训练预测配置文件 +│ │ └── MobileNetV3_large_x1_0_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt #混合精度训练预测配置文件 +│ └── ResNet # ResNet系列模型测试配置文件目录 +│ ├── ResNet50_vd_train_infer_python.txt #基础训练预测配置文件 +│ ├── ResNet50_vd_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt #多机多卡训练预测配置文件 +│ └── ResNet50_vd_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt #混合精度训练预测配置文件 +| ...... +├── docs +│ ├── guide.png +│ └── test.png +├── prepare.sh # 完成test_*.sh运行所需要的数据和模型下载 +├── README.md # 使用文档 +├── results # 预先保存的预测结果,用于和实际预测结果进行精读比对 +└── test_train_inference_python.sh # 测试python训练预测的主程序 +``` + +### 测试流程概述 +使用本工具,可以测试不同功能的支持情况,以及预测结果是否对齐,测试流程如下: +
+ +
+ +1. 运行`prepare.sh`准备测试所需数据和模型; +2. 运行要测试的功能对应的测试脚本`test_*.sh`,产出log,由log可以看到不同配置是否运行成功; +3. 用`compare_results.py`对比log中的预测结果和预存在results目录下的结果,判断预测精度是否符合预期(在误差范围内)。 + +测试单项功能仅需两行命令,**如需测试不同模型/功能,替换配置文件即可**,命令格式如下: + +```shell +# 功能:准备数据 +# 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择 +bash test_tipc/prepare.sh configs/[model_name]/[params_file_name] [Mode] + +# 功能:运行测试 +# 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择 +bash test_tipc/test_train_inference_python.sh configs/[model_name]/[params_file_name] [Mode] + +``` + +例如,测试基本训练预测功能的`lite_train_lite_infer`模式,运行: + +```shell +# 准备数据 +bash test_tipc/prepare.sh ./test_tipc/configs/MobileNetV3/MobileNetV3_large_x1_0_train_infer_python.txt 'lite_train_lite_infer' +# 运行测试 +bash test_tipc/test_train_inference_python.sh ./test_tipc/configs/MobileNetV3/MobileNetV3_large_x1_0_train_infer_python.txt 'lite_train_lite_infer' + +``` + +关于本示例命令的更多信息可查看[基础训练预测使用文档](docs/test_train_inference_python.md)。 + +### 配置文件命名规范 + +在`configs`目录下,**按模型系列划分为子目录**,子目录中存放所有该模型系列测试需要用到的配置文件,如`MobileNetV3`文件夹下存放了所有`MobileNetV3`系列模型的配置文件。配置文件的命名遵循如下规范: + +1. 基础训练预测配置简单命名为:`ModelName_train_infer_python.txt`,表示**Linux环境下单机、不使用混合精度训练+python预测**,其完整命名对应`ModelName_train_linux_gpu_normal_normal_infer_python_linux_gpu_cpu.txt`,由于本配置文件使用频率较高,这里进行了名称简化。其中`ModelName`指具体模型名称 +2. 其他带训练配置命名格式为:`ModelName_train_训练硬件环境(linux_gpu/linux_dcu/…)_是否多机(fleet/normal)_是否混合精度(amp/normal)_预测模式(infer/lite/serving/js)_语言(cpp/python/java)_预测硬件环境(ModelName_linux_gpu/mac/jetson/opencl_arm_gpu/...).txt`。如,linux gpu下多机多卡+混合精度链条测试对应配置 `ModelName_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt`,linux dcu下基础训练预测对应配置 `ModelName_train_linux_dcu_normal_normal_infer_python_linux_dcu.txt`。 +3. 仅预测的配置(如serving、lite等)命名格式:`ModelName_model_训练硬件环境(ModelName_linux_gpu/linux_dcu/…)_是否多机(fleet/normal)_是否混合精度(amp/normal)_(infer/lite/serving/js)_语言(cpp/python/java)_预测硬件环境(ModelName_linux_gpu/mac/jetson/opencl_arm_gpu/...).txt`,即,与2相比,仅第二个字段从train换为model,测试时模型直接下载获取,这里的“训练硬件环境”表示所测试的模型是在哪种环境下训练得到的。 + +**根据上述命名规范,可以直接从子目录名称和配置文件名找到需要测试的场景和功能对应的配置文件。** + + + +## 4 开始测试 + +各功能测试中涉及混合精度、裁剪、量化等训练相关,及mkldnn、Tensorrt等多种预测相关参数配置,请点击下方相应链接了解更多细节和使用教程: + +- [test_train_inference_python 使用](docs/test_train_inference_python.md):测试基于Python的模型训练、评估、推理等基本功能,包括裁剪、量化、蒸馏。 +- [test_inference_cpp 使用](docs/test_inference_cpp.md) :测试基于C++的模型推理。 +- [test_serving 使用](docs/test_serving.md) :测试基于Paddle Serving的服务化部署功能。 +- [test_lite_arm_cpu_cpp 使用](docs/test_lite_arm_cpu_cpp.md): 测试基于Paddle-Lite的ARM CPU端c++预测部署功能. +- [test_paddle2onnx 使用](docs/test_paddle2onnx.md):测试Paddle2ONNX的模型转化功能,并验证正确性。 diff --git a/src/PaddleClas/test_tipc/common_func.sh b/src/PaddleClas/test_tipc/common_func.sh new file mode 100644 index 0000000..3f0fa66 --- /dev/null +++ b/src/PaddleClas/test_tipc/common_func.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +function func_parser_key(){ + strs=$1 + IFS=":" + array=(${strs}) + tmp=${array[0]} + echo ${tmp} +} + +function func_parser_value(){ + strs=$1 + IFS=":" + array=(${strs}) + tmp=${array[1]} + echo ${tmp} +} + +function func_set_params(){ + key=$1 + value=$2 + if [ ${key}x = "null"x ];then + echo " " + elif [[ ${value} = "null" ]] || [[ ${value} = " " ]] || [ ${#value} -le 0 ];then + echo " " + else + echo "${key}=${value}" + fi +} + +function func_parser_params(){ + strs=$1 + IFS=":" + array=(${strs}) + key=${array[0]} + tmp=${array[1]} + IFS="|" + res="" + for _params in ${tmp[*]}; do + IFS="=" + array=(${_params}) + mode=${array[0]} + value=${array[1]} + if [[ ${mode} = ${MODE} ]]; then + IFS="|" + #echo $(func_set_params "${mode}" "${value}") + echo $value + break + fi + IFS="|" + done + echo ${res} +} + +function status_check(){ + last_status=$1 # the exit code + run_command=$2 + run_log=$3 + if [ $last_status -eq 0 ]; then + echo -e "\033[33m Run successfully with command - ${run_command}! \033[0m" | tee -a ${run_log} + else + echo -e "\033[33m Run failed with command - ${run_command}! \033[0m" | tee -a ${run_log} + fi +} + diff --git a/src/PaddleClas/test_tipc/compare_results.py b/src/PaddleClas/test_tipc/compare_results.py new file mode 100644 index 0000000..e28410e --- /dev/null +++ b/src/PaddleClas/test_tipc/compare_results.py @@ -0,0 +1,140 @@ +import numpy as np +import os +import subprocess +import json +import argparse +import glob + + +def init_args(): + parser = argparse.ArgumentParser() + # params for testing assert allclose + parser.add_argument("--atol", type=float, default=1e-3) + parser.add_argument("--rtol", type=float, default=1e-3) + parser.add_argument("--gt_file", type=str, default="") + parser.add_argument("--log_file", type=str, default="") + parser.add_argument("--precision", type=str, default="fp32") + return parser + + +def parse_args(): + parser = init_args() + return parser.parse_args() + + +def run_shell_command(cmd): + p = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + out, err = p.communicate() + + if p.returncode == 0: + return out.decode('utf-8') + else: + return None + + +def parser_results_from_log_by_name(log_path, names_list): + if not os.path.exists(log_path): + raise ValueError("The log file {} does not exists!".format(log_path)) + + if names_list is None or len(names_list) < 1: + return [] + + parser_results = {} + for name in names_list: + cmd = "grep {} {}".format(name, log_path) + outs = run_shell_command(cmd) + outs = outs.split("\n")[0] + result = outs.split("{}".format(name))[-1] + try: + result = json.loads(result) + except: + result = np.array([int(r) for r in result.split()]).reshape(-1, 4) + parser_results[name] = result + return parser_results + + +def load_gt_from_file(gt_file): + if not os.path.exists(gt_file): + raise ValueError("The log file {} does not exists!".format(gt_file)) + with open(gt_file, 'r') as f: + data = f.readlines() + f.close() + parser_gt = {} + for line in data: + image_name, result = line.strip("\n").split("\t") + image_name = image_name.split('/')[-1] + try: + result = json.loads(result) + except: + result = np.array([int(r) for r in result.split()]).reshape(-1, 4) + parser_gt[image_name] = result + return parser_gt + + +def load_gt_from_txts(gt_file): + gt_list = glob.glob(gt_file) + gt_collection = {} + for gt_f in gt_list: + gt_dict = load_gt_from_file(gt_f) + basename = os.path.basename(gt_f) + if "fp32" in basename: + gt_collection["fp32"] = [gt_dict, gt_f] + elif "fp16" in basename: + gt_collection["fp16"] = [gt_dict, gt_f] + elif "int8" in basename: + gt_collection["int8"] = [gt_dict, gt_f] + else: + continue + return gt_collection + + +def collect_predict_from_logs(log_path, key_list): + log_list = glob.glob(log_path) + pred_collection = {} + for log_f in log_list: + pred_dict = parser_results_from_log_by_name(log_f, key_list) + key = os.path.basename(log_f) + pred_collection[key] = pred_dict + + return pred_collection + + +def testing_assert_allclose(dict_x, dict_y, atol=1e-7, rtol=1e-7): + for k in dict_x: + np.testing.assert_allclose( + np.array(dict_x[k]), np.array(dict_y[k]), atol=atol, rtol=rtol) + + +if __name__ == "__main__": + # Usage: + # python3.7 tests/compare_results.py --gt_file=./tests/results/*.txt --log_file=./tests/output/infer_*.log + + args = parse_args() + + gt_collection = load_gt_from_txts(args.gt_file) + key_list = gt_collection["fp32"][0].keys() + + pred_collection = collect_predict_from_logs(args.log_file, key_list) + for filename in pred_collection.keys(): + if "fp32" in filename: + gt_dict, gt_filename = gt_collection["fp32"] + elif "fp16" in filename: + gt_dict, gt_filename = gt_collection["fp16"] + elif "int8" in filename: + gt_dict, gt_filename = gt_collection["int8"] + else: + continue + pred_dict = pred_collection[filename] + + try: + testing_assert_allclose( + gt_dict, pred_dict, atol=args.atol, rtol=args.rtol) + print( + "Assert allclose passed! The results of {} and {} are consistent!". + format(filename, gt_filename)) + except Exception as E: + print(E) + raise ValueError( + "The results of {} and the results of {} are inconsistent!". + format(filename, gt_filename)) diff --git a/src/PaddleClas/test_tipc/config/AlexNet/AlexNet_train_infer_python.txt b/src/PaddleClas/test_tipc/config/AlexNet/AlexNet_train_infer_python.txt new file mode 100644 index 0000000..7662f5d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/AlexNet/AlexNet_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:AlexNet +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/AlexNet/AlexNet.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/AlexNet/AlexNet.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/AlexNet/AlexNet.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/AlexNet_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/CSPNet/CSPDarkNet53_train_infer_python.txt b/src/PaddleClas/test_tipc/config/CSPNet/CSPDarkNet53_train_infer_python.txt new file mode 100644 index 0000000..cd5ec06 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/CSPNet/CSPDarkNet53_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:CSPDarkNet53 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/CSPNet/CSPDarkNet53.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/CSPNet/CSPDarkNet53.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSPNet/CSPDarkNet53.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSPDarkNet53_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=288 -o PreProcess.transform_ops.1.CropImage.size=256 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA102_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA102_train_infer_python.txt new file mode 100644 index 0000000..0a85e2a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA102_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA102 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA102.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA102.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA102.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA102x2_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA102x2_train_infer_python.txt new file mode 100644 index 0000000..fff0ee1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA102x2_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA102x2 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA102x2.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA102x2.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA102x2.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x2_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA102x_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA102x_train_infer_python.txt new file mode 100644 index 0000000..db7af68 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA102x_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA102x +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA102x.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA102x.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA102x.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA102x_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA169_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA169_train_infer_python.txt new file mode 100644 index 0000000..0abc0e2 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA169_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA169 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA169.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA169.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA169.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA169_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA34_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA34_train_infer_python.txt new file mode 100644 index 0000000..fa06405 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA34_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA34 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA34.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA34.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA34.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA34_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA46_c_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA46_c_train_infer_python.txt new file mode 100644 index 0000000..8503452 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA46_c_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA46_c +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA46_c.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA46_c.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA46_c.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA46_c_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA46x_c_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA46x_c_train_infer_python.txt new file mode 100644 index 0000000..ee6c58a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA46x_c_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA46x_c +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA46x_c.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA46x_c.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA46x_c.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA46x_c_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA60_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA60_train_infer_python.txt new file mode 100644 index 0000000..e14fcab --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA60_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA60 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA60.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA60.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA60.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA60x_c_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA60x_c_train_infer_python.txt new file mode 100644 index 0000000..cd45206 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA60x_c_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA60x_c +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA60x_c.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA60x_c.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA60x_c.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_c_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DLA/DLA60x_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DLA/DLA60x_train_infer_python.txt new file mode 100644 index 0000000..51b7e77 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DLA/DLA60x_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DLA60x +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DLA/DLA60x.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DLA/DLA60x.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DLA/DLA60x.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DLA60x_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DPN/DPN107_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DPN/DPN107_train_infer_python.txt new file mode 100644 index 0000000..646bce3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DPN/DPN107_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DPN107 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DPN/DPN107.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DPN/DPN107.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DPN/DPN107.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN107_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DPN/DPN131_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DPN/DPN131_train_infer_python.txt new file mode 100644 index 0000000..1aaea6a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DPN/DPN131_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DPN131 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DPN/DPN131.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DPN/DPN131.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DPN/DPN131.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN131_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DPN/DPN68_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DPN/DPN68_train_infer_python.txt new file mode 100644 index 0000000..d26e5e3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DPN/DPN68_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DPN68 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DPN/DPN68.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DPN/DPN68.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DPN/DPN68.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN68_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DPN/DPN92_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DPN/DPN92_train_infer_python.txt new file mode 100644 index 0000000..3d0d077 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DPN/DPN92_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DPN92 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DPN/DPN92.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DPN/DPN92.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DPN/DPN92.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN92_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DPN/DPN98_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DPN/DPN98_train_infer_python.txt new file mode 100644 index 0000000..e4cee43 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DPN/DPN98_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DPN98 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DPN/DPN98.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DPN/DPN98.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DPN/DPN98.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DPN98_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DarkNet/DarkNet53_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DarkNet/DarkNet53_train_infer_python.txt new file mode 100644 index 0000000..b10918e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DarkNet/DarkNet53_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DarkNet53 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DarkNet53_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=292 -o PreProcess.transform_ops.1.CropImage.size=256 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DeiT/DeiT_base_patch16_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DeiT/DeiT_base_patch16_224_train_infer_python.txt new file mode 100644 index 0000000..d10fc20 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DeiT/DeiT_base_patch16_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DeiT_base_patch16_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DeiT/DeiT_base_patch16_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DeiT/DeiT_base_patch16_384_train_infer_python.txt new file mode 100644 index 0000000..c8fc60e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DeiT/DeiT_base_patch16_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DeiT_base_patch16_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DeiT/DeiT_base_patch16_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_base_patch16_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DeiT/DeiT_small_patch16_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DeiT/DeiT_small_patch16_224_train_infer_python.txt new file mode 100644 index 0000000..83ea4c3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DeiT/DeiT_small_patch16_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DeiT_small_patch16_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DeiT/DeiT_small_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DeiT/DeiT_small_patch16_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DeiT/DeiT_small_patch16_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_small_patch16_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DeiT/DeiT_tiny_patch16_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DeiT/DeiT_tiny_patch16_224_train_infer_python.txt new file mode 100644 index 0000000..cb18502 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DeiT/DeiT_tiny_patch16_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DeiT_tiny_patch16_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DeiT/DeiT_tiny_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DeiT/DeiT_tiny_patch16_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DeiT/DeiT_tiny_patch16_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DeiT_tiny_patch16_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DenseNet/DenseNet121_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet121_train_infer_python.txt new file mode 100644 index 0000000..9f89e4c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet121_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DenseNet121 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DenseNet/DenseNet121.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DenseNet/DenseNet121.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DenseNet/DenseNet121.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet121_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DenseNet/DenseNet161_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet161_train_infer_python.txt new file mode 100644 index 0000000..379cc29 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet161_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DenseNet161 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DenseNet/DenseNet161.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DenseNet/DenseNet161.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DenseNet/DenseNet161.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet161_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DenseNet/DenseNet169_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet169_train_infer_python.txt new file mode 100644 index 0000000..c2e2bbb --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet169_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DenseNet169 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DenseNet/DenseNet169.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DenseNet/DenseNet169.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DenseNet/DenseNet169.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet169_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DenseNet/DenseNet201_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet201_train_infer_python.txt new file mode 100644 index 0000000..08dedc4 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet201_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DenseNet201 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DenseNet/DenseNet201.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DenseNet/DenseNet201.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DenseNet/DenseNet201.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet201_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/DenseNet/DenseNet264_train_infer_python.txt b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet264_train_infer_python.txt new file mode 100644 index 0000000..146ad68 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/DenseNet/DenseNet264_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:DenseNet264 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DenseNet/DenseNet264.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DenseNet/DenseNet264.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DenseNet/DenseNet264.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/DenseNet264_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_25_train_infer_python.txt new file mode 100644 index 0000000..82ead10 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_25_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ESNet_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_5_train_infer_python.txt new file mode 100644 index 0000000..38b376f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ESNet_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_75_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_75_train_infer_python.txt new file mode 100644 index 0000000..dc63498 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x0_75_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ESNet_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ESNet/ESNet_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ESNet/ESNet_x1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x1_0_train_infer_python.txt new file mode 100644 index 0000000..c5a4a5a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ESNet/ESNet_x1_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ESNet_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ESNet/ESNet_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ESNet/ESNet_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ESNet/ESNet_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ESNet_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB0_train_infer_python.txt new file mode 100644 index 0000000..23b3ef1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB1_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB1_train_infer_python.txt new file mode 100644 index 0000000..1c43145 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB1_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB1 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB1.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB1.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB1.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB1_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=272 -o PreProcess.transform_ops.1.CropImage.size=240 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB2_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB2_train_infer_python.txt new file mode 100644 index 0000000..0ac16c3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB2_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB2 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB2.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB2.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB2.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB2_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=292 -o PreProcess.transform_ops.1.CropImage.size=260 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB3_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB3_train_infer_python.txt new file mode 100644 index 0000000..0d0ca3d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB3_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB3 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB3.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB3.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB3.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB3_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=332 -o PreProcess.transform_ops.1.CropImage.size=300 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB4_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB4_train_infer_python.txt new file mode 100644 index 0000000..92d4cb8 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB4_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB4 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB4.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB4.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB4.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB4_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=412 -o PreProcess.transform_ops.1.CropImage.size=380 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB5_train_infer_python.txt new file mode 100644 index 0000000..02c9357 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=488 -o PreProcess.transform_ops.1.CropImage.size=456 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB6_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB6_train_infer_python.txt new file mode 100644 index 0000000..392c048 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB6_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB6 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB6.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB6.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB6.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB6_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=560 -o PreProcess.transform_ops.1.CropImage.size=528 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB7_train_infer_python.txt b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB7_train_infer_python.txt new file mode 100644 index 0000000..7265243 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/EfficientNet/EfficientNetB7_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:EfficientNetB7 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB7.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB7.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/EfficientNet/EfficientNetB7.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/EfficientNetB7_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=632 -o PreProcess.transform_ops.1.CropImage.size=600 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_custom_sampler.txt b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_custom_sampler.txt new file mode 100644 index 0000000..c1dbc89 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_custom_sampler.txt @@ -0,0 +1,27 @@ +===========================train_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml -o DataLoader.Train.sampler.name="PKSampler" -o DataLoader.Train.sampler.sample_per_id=2 +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:null +null:null +## + diff --git a/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_infer_python.txt new file mode 100644 index 0000000..40e6675 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/pretrain/general_PPLCNet_x2_5_pretrained_v1.0.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_rec.py -c configs/inference_rec.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.rec_inference_model_dir:../inference +-o Global.infer_imgs:../dataset/Aliproduct/demo_test/ +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_multicard_eval.txt b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_multicard_eval.txt new file mode 100644 index 0000000..165cfa9 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_multicard_eval.txt @@ -0,0 +1,26 @@ +===========================train_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5 +python:python3.7 +gpu_list:0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:null +null:null +## diff --git a/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_no_eval.txt b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_no_eval.txt new file mode 100644 index 0000000..1e16751 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5_train_no_eval.txt @@ -0,0 +1,26 @@ +===========================train_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/GeneralRecognition/GeneralRecognition_PPLCNet_x2_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False -o Global.eval_during_train=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:null +null:null +## diff --git a/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x0_5_train_infer_python.txt new file mode 100644 index 0000000..7df8dee --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x0_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:GhostNet_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x1_0_train_infer_python.txt new file mode 100644 index 0000000..7d3184b --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x1_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:GhostNet_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x1_3_train_infer_python.txt b/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x1_3_train_infer_python.txt new file mode 100644 index 0000000..e186eea --- /dev/null +++ b/src/PaddleClas/test_tipc/config/GhostNet/GhostNet_x1_3_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:GhostNet_x1_3 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W18_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W18_C_train_infer_python.txt new file mode 100644 index 0000000..3883580 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W18_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W18_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W18_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W30_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W30_C_train_infer_python.txt new file mode 100644 index 0000000..cba0265 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W30_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W30_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W30_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W30_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W30_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W30_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W32_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W32_C_train_infer_python.txt new file mode 100644 index 0000000..197a76b --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W32_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W32_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W32_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W32_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W32_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W32_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W40_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W40_C_train_infer_python.txt new file mode 100644 index 0000000..1deb891 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W40_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W40_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W40_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W40_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W40_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W40_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W44_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W44_C_train_infer_python.txt new file mode 100644 index 0000000..10fab3d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W44_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W44_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W44_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W44_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W44_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W44_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W48_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W48_C_train_infer_python.txt new file mode 100644 index 0000000..6de8e26 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W48_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W48_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W48_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W48_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W48_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W48_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HRNet/HRNet_W64_C_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W64_C_train_infer_python.txt new file mode 100644 index 0000000..c99c5e6 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HRNet/HRNet_W64_C_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HRNet_W64_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W64_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W64_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W64_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/HRNet_W64_C_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HarDNet/HarDNet39_ds_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet39_ds_train_infer_python.txt new file mode 100644 index 0000000..5cda671 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet39_ds_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HarDNet39_ds +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HarDNet/HarDNet39_ds.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HarDNet/HarDNet39_ds.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HarDNet/HarDNet39_ds.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet39_ds_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HarDNet/HarDNet68_ds_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet68_ds_train_infer_python.txt new file mode 100644 index 0000000..bfe601e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet68_ds_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HarDNet68_ds +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HarDNet/HarDNet68_ds.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HarDNet/HarDNet68_ds.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HarDNet/HarDNet68_ds.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_ds_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HarDNet/HarDNet68_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet68_train_infer_python.txt new file mode 100644 index 0000000..b61ea63 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet68_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HarDNet68 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HarDNet/HarDNet68.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HarDNet/HarDNet68.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HarDNet/HarDNet68.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet68_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/HarDNet/HarDNet85_train_infer_python.txt b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet85_train_infer_python.txt new file mode 100644 index 0000000..02237ba --- /dev/null +++ b/src/PaddleClas/test_tipc/config/HarDNet/HarDNet85_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:HarDNet85 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HarDNet/HarDNet85.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HarDNet/HarDNet85.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HarDNet/HarDNet85.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/HarDNet85_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Inception/GoogLeNet_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Inception/GoogLeNet_train_infer_python.txt new file mode 100644 index 0000000..ebbb86d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Inception/GoogLeNet_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:GoogLeNet +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Inception/GoogLeNet.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Inception/GoogLeNet.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Inception/GoogLeNet.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GoogLeNet_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Inception/InceptionV3_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Inception/InceptionV3_train_infer_python.txt new file mode 100644 index 0000000..6a7960c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Inception/InceptionV3_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:InceptionV3 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Inception/InceptionV3.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Inception/InceptionV3.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Inception/InceptionV3.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/InceptionV3_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Inception/InceptionV4_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Inception/InceptionV4_train_infer_python.txt new file mode 100644 index 0000000..1e1d7fd --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Inception/InceptionV4_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:InceptionV4 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Inception/InceptionV4.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Inception/InceptionV4.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Inception/InceptionV4.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/InceptionV4_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/LeViT/LeViT_128S_train_infer_python.txt b/src/PaddleClas/test_tipc/config/LeViT/LeViT_128S_train_infer_python.txt new file mode 100644 index 0000000..772049b --- /dev/null +++ b/src/PaddleClas/test_tipc/config/LeViT/LeViT_128S_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:LeViT_128S +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128S_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/LeViT/LeViT_128_train_infer_python.txt b/src/PaddleClas/test_tipc/config/LeViT/LeViT_128_train_infer_python.txt new file mode 100644 index 0000000..8c8699e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/LeViT/LeViT_128_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:LeViT_128 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/LeViT/LeViT_128.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/LeViT/LeViT_128.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/LeViT/LeViT_128.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_128_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/LeViT/LeViT_192_train_infer_python.txt b/src/PaddleClas/test_tipc/config/LeViT/LeViT_192_train_infer_python.txt new file mode 100644 index 0000000..c2ac115 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/LeViT/LeViT_192_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:LeViT_192 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/LeViT/LeViT_192.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/LeViT/LeViT_192.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/LeViT/LeViT_192.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_192_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/LeViT/LeViT_256_train_infer_python.txt b/src/PaddleClas/test_tipc/config/LeViT/LeViT_256_train_infer_python.txt new file mode 100644 index 0000000..f58880c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/LeViT/LeViT_256_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:LeViT_256 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/LeViT/LeViT_256.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/LeViT/LeViT_256.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/LeViT/LeViT_256.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_256_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/LeViT/LeViT_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/LeViT/LeViT_384_train_infer_python.txt new file mode 100644 index 0000000..0ae0d40 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/LeViT/LeViT_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:LeViT_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/LeViT/LeViT_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/LeViT/LeViT_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/LeViT/LeViT_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/LeViT_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MixNet/MixNet_L_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MixNet/MixNet_L_train_infer_python.txt new file mode 100644 index 0000000..46fcbc1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MixNet/MixNet_L_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MixNet_L +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MixNet/MixNet_L.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MixNet/MixNet_L.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MixNet/MixNet_L.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_L_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MixNet/MixNet_M_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MixNet/MixNet_M_train_infer_python.txt new file mode 100644 index 0000000..87be78a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MixNet/MixNet_M_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MixNet_M +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MixNet/MixNet_M.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MixNet/MixNet_M.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MixNet/MixNet_M.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_M_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MixNet/MixNet_S_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MixNet/MixNet_S_train_infer_python.txt new file mode 100644 index 0000000..42e5df7 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MixNet/MixNet_S_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MixNet_S +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MixNet/MixNet_S.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MixNet/MixNet_S.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MixNet/MixNet_S.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MixNet_S_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_train_infer_python.txt new file mode 100644 index 0000000..65fee15 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV1 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_25_train_infer_python.txt new file mode 100644 index 0000000..a9f63df --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_25_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV1_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_5_train_infer_python.txt new file mode 100644 index 0000000..379cbd6 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV1_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_75_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_75_train_infer_python.txt new file mode 100644 index 0000000..fef81fa --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV1/MobileNetV1_x0_75_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV1_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_train_infer_python.txt new file mode 100644 index 0000000..fb0c8a2 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV2 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_25_train_infer_python.txt new file mode 100644 index 0000000..9183e01 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_25_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV2_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_5_train_infer_python.txt new file mode 100644 index 0000000..bef4e1d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV2_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_75_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_75_train_infer_python.txt new file mode 100644 index 0000000..a788731 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x0_75_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV2_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x1_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x1_5_train_infer_python.txt new file mode 100644 index 0000000..d5f9bf4 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x1_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV2_x1_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x1_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x2_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x2_0_train_infer_python.txt new file mode 100644 index 0000000..f445570 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV2/MobileNetV2_x2_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV2_x2_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x2_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_35_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_35_train_infer_python.txt new file mode 100644 index 0000000..2797a2d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_35_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x0_35 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_35_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_5_train_infer_python.txt new file mode 100644 index 0000000..6f9165c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_5_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_75_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_75_train_infer_python.txt new file mode 100644 index 0000000..da48671 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x0_75_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_infer_python.txt new file mode 100644 index 0000000..25ecbd5 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.save_inference_dir=./inference +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt new file mode 100644 index 0000000..c7c956f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x1_0 +python:python3.7 +gpu_list:xx.xx.xx.xx,yy.yy.yy.yy;0,1 +-o Global.device:gpu +-o Global.auto_cast:null|amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.save_inference_dir=./inference +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/MobileNetV3_large_x1_0_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt new file mode 100644 index 0000000..f251e9c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.save_inference_dir=./inference +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/MobileNetV3_large_x1_0_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_25_train_infer_python.txt new file mode 100644 index 0000000..4b62f54 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_25_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x1_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_35_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_35_train_infer_python.txt new file mode 100644 index 0000000..2e40f89 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_35_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x0_35 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_5_train_infer_python.txt new file mode 100644 index 0000000..e8a2b0e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_5_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_75_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_75_train_infer_python.txt new file mode 100644 index 0000000..65a8671 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x0_75_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x1_0_train_infer_python.txt new file mode 100644 index 0000000..6d2334b --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x1_0_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x1_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x1_25_train_infer_python.txt new file mode 100644 index 0000000..6a730b7 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/MobileNetV3/MobileNetV3_small_x1_25_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x1_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PP-ShiTu/PPShiTu_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/PP-ShiTu/PPShiTu_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000..b86aa9b --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PP-ShiTu/PPShiTu_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,19 @@ +===========================cpp_infer_params=========================== +model_name:PPShiTu +cpp_infer_type:shitu +feature_inference_model_dir:./feature_inference/ +det_inference_model_dir:./det_inference +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar +det_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar +infer_quant:False +inference_cmd:./deploy/cpp_shitu/build/pp_shitu -c inference_drink.yaml +use_gpu:True|False +enable_mkldnn:True|False +cpu_threads:1|6 +batch_size:1 +use_tensorrt:False|True +precision:fp32|fp16 +data_dir:./dataset/drink_dataset_v1.0 +benchmark:True +generate_yaml_cmd:python3 test_tipc/generate_cpp_yaml.py +transform_index_cmd:python3 deploy/cpp_shitu/tools/transform_id_map.py -c inference_drink.yaml diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_25_train_infer_python.txt new file mode 100644 index 0000000..66afc24 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_25_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_35_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_35_train_infer_python.txt new file mode 100644 index 0000000..9aa5362 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_35_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_35 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_35_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_5_train_infer_python.txt new file mode 100644 index 0000000..277ef81 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_5_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_75_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_75_train_infer_python.txt new file mode 100644 index 0000000..14b5ec3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x0_75_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x1_0_train_infer_python.txt new file mode 100644 index 0000000..97bec1f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x1_0_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x1_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x1_5_train_infer_python.txt new file mode 100644 index 0000000..6faaddb --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x1_5_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x1_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_0_train_infer_python.txt new file mode 100644 index 0000000..36145d5 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_0_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x2_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_infer_python.txt new file mode 100644 index 0000000..f369e74 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_infer_python.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x2_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt new file mode 100644 index 0000000..6637565 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x2_5 +python:python3.7 +gpu_list:xx.xx.xx.xx,yy.yy.yy.yy;0,1 +-o Global.device:gpu +-o Global.auto_cast:null|amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt new file mode 100644 index 0000000..74c6d04 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PPLCNet/PPLCNet_x2_5_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x2_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x2_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x2_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B0.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B0.txt new file mode 100644 index 0000000..1e0a380 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B0.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B0.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B1.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B1.txt new file mode 100644 index 0000000..489f8c8 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B1.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B1 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B1.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B1.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B1.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B1.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B2.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B2.txt new file mode 100644 index 0000000..8d274cd --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B2.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B2 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B2.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B2.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B2.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B2_Linear.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B2_Linear.txt new file mode 100644 index 0000000..2fd530c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B2_Linear.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B2_Linear +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B2_Linear.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B2_Linear.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B2_Linear.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_Linear.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B3.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B3.txt new file mode 100644 index 0000000..f375fcf --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B3.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B3 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B3.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B3.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B3.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B3.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B4.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B4.txt new file mode 100644 index 0000000..f0c7084 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B4.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B4 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B4.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B4.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B4.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B4.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B5.txt b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B5.txt new file mode 100644 index 0000000..9383851 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/PVTV2/PVT_V2_B5.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:PVT_V2_B5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PVTV2/PVT_V2_B5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B5.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=256 -o PreProcess.transform_ops.1.CropImage.size=224 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_0_train_infer_python.txt new file mode 100644 index 0000000..352ff5e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ReXNet_1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_3_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_3_train_infer_python.txt new file mode 100644 index 0000000..4c76bad --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_3_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ReXNet_1_3 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_3.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_3.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_3.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_3_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_5_train_infer_python.txt new file mode 100644 index 0000000..b302911 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_1_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ReXNet_1_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_1_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_1_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_2_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_2_0_train_infer_python.txt new file mode 100644 index 0000000..c52d563 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_2_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ReXNet_2_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_2_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_2_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_2_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_2_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_3_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_3_0_train_infer_python.txt new file mode 100644 index 0000000..a2047c4 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ReXNet/ReXNet_3_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ReXNet_3_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_3_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_3_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ReXNet/ReXNet_3_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ReXNet_3_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/RedNet/RedNet101_train_infer_python.txt b/src/PaddleClas/test_tipc/config/RedNet/RedNet101_train_infer_python.txt new file mode 100644 index 0000000..6d7d3b9 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/RedNet/RedNet101_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:RedNet101 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/RedNet/RedNet101.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/RedNet/RedNet101.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/RedNet/RedNet101.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet101_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/RedNet/RedNet152_train_infer_python.txt b/src/PaddleClas/test_tipc/config/RedNet/RedNet152_train_infer_python.txt new file mode 100644 index 0000000..82e8189 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/RedNet/RedNet152_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:RedNet152 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/RedNet/RedNet152.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/RedNet/RedNet152.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/RedNet/RedNet152.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet152_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/RedNet/RedNet26_train_infer_python.txt b/src/PaddleClas/test_tipc/config/RedNet/RedNet26_train_infer_python.txt new file mode 100644 index 0000000..53e5ce0 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/RedNet/RedNet26_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:RedNet26 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/RedNet/RedNet26.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/RedNet/RedNet26.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/RedNet/RedNet26.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet26_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/RedNet/RedNet38_train_infer_python.txt b/src/PaddleClas/test_tipc/config/RedNet/RedNet38_train_infer_python.txt new file mode 100644 index 0000000..3ec2471 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/RedNet/RedNet38_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:RedNet38 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/RedNet/RedNet38.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/RedNet/RedNet38.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/RedNet/RedNet38.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet38_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/RedNet/RedNet50_train_infer_python.txt b/src/PaddleClas/test_tipc/config/RedNet/RedNet50_train_infer_python.txt new file mode 100644 index 0000000..bb36200 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/RedNet/RedNet50_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:RedNet50 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/RedNet/RedNet50.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/RedNet/RedNet50.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/RedNet/RedNet50.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/RedNet50_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Res2Net/Res2Net101_vd_26w_4s_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net101_vd_26w_4s_train_infer_python.txt new file mode 100644 index 0000000..f5542ad --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net101_vd_26w_4s_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Res2Net101_vd_26w_4s +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Res2Net/Res2Net101_vd_26w_4s.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Res2Net/Res2Net101_vd_26w_4s.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Res2Net/Res2Net101_vd_26w_4s.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net101_vd_26w_4s_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Res2Net/Res2Net200_vd_26w_4s_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net200_vd_26w_4s_train_infer_python.txt new file mode 100644 index 0000000..40d7f41 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net200_vd_26w_4s_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Res2Net200_vd_26w_4s +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Res2Net/Res2Net200_vd_26w_4s.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Res2Net/Res2Net200_vd_26w_4s.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Res2Net/Res2Net200_vd_26w_4s.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net200_vd_26w_4s_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_14w_8s_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_14w_8s_train_infer_python.txt new file mode 100644 index 0000000..c6300bc --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_14w_8s_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Res2Net50_14w_8s +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_14w_8s.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_14w_8s.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_14w_8s.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_14w_8s_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_26w_4s_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_26w_4s_train_infer_python.txt new file mode 100644 index 0000000..7491525 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_26w_4s_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Res2Net50_26w_4s +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_26w_4s.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_26w_4s.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_26w_4s.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_26w_4s_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_vd_26w_4s_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_vd_26w_4s_train_infer_python.txt new file mode 100644 index 0000000..cbdc256 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Res2Net/Res2Net50_vd_26w_4s_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Res2Net50_vd_26w_4s +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_vd_26w_4s.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_vd_26w_4s.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Res2Net/Res2Net50_vd_26w_4s.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Res2Net50_vd_26w_4s_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeSt/ResNeSt50_fast_1s1x64d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeSt/ResNeSt50_fast_1s1x64d_train_infer_python.txt new file mode 100644 index 0000000..66ce66a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeSt/ResNeSt50_fast_1s1x64d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeSt50_fast_1s1x64d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeSt/ResNeSt50_fast_1s1x64d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeSt/ResNeSt50_fast_1s1x64d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeSt/ResNeSt50_fast_1s1x64d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_fast_1s1x64d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeSt/ResNeSt50_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeSt/ResNeSt50_train_infer_python.txt new file mode 100644 index 0000000..2d1bfb2 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeSt/ResNeSt50_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeSt50 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeSt/ResNeSt50.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeSt/ResNeSt50.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeSt/ResNeSt50.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeSt50_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_32x4d_train_infer_python.txt new file mode 100644 index 0000000..eb21af6 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt101_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_64x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_64x4d_train_infer_python.txt new file mode 100644 index 0000000..8e4ac81 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_64x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt101_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_64x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_vd_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_vd_32x4d_train_infer_python.txt new file mode 100644 index 0000000..cf9211f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_vd_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt101_vd_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_vd_64x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_vd_64x4d_train_infer_python.txt new file mode 100644 index 0000000..eae4d0e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt101_vd_64x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt101_vd_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_vd_64x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_32x4d_train_infer_python.txt new file mode 100644 index 0000000..eb21af6 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt101_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt101_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_64x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_64x4d_train_infer_python.txt new file mode 100644 index 0000000..c8a85f6 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_64x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt152_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_64x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_vd_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_vd_32x4d_train_infer_python.txt new file mode 100644 index 0000000..4abaa87 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_vd_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt152_vd_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_vd_64x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_vd_64x4d_train_infer_python.txt new file mode 100644 index 0000000..8d8a4ea --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt152_vd_64x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt152_vd_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt152_vd_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt152_vd_64x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_32x4d_train_infer_python.txt new file mode 100644 index 0000000..4cb942f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt50_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_64x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_64x4d_train_infer_python.txt new file mode 100644 index 0000000..0cad348 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_64x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt50_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_64x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_vd_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_vd_32x4d_train_infer_python.txt new file mode 100644 index 0000000..fc74560 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_vd_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt50_vd_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_vd_64x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_vd_64x4d_train_infer_python.txt new file mode 100644 index 0000000..b2817db --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNeXt/ResNeXt50_vd_64x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNeXt50_vd_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt50_vd_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNeXt50_vd_64x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet101_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet101_train_infer_python.txt new file mode 100644 index 0000000..f10760d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet101_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet101 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet101.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet101.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet101.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet101_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet101_vd_train_infer_python.txt new file mode 100644 index 0000000..7027d30 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet101_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet101_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet101_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet101_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet101_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet101_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet152_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet152_train_infer_python.txt new file mode 100644 index 0000000..1d4cc80 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet152_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet152 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet152.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet152.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet152.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet152_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet152_vd_train_infer_python.txt new file mode 100644 index 0000000..4091328 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet152_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet152_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet152_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet152_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet152_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet152_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet18_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet18_train_infer_python.txt new file mode 100644 index 0000000..06d5504 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet18_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet18 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet18.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet18.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet18.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet18_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet18_vd_train_infer_python.txt new file mode 100644 index 0000000..d3d2bcf --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet18_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet18_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet18_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet18_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet18_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet18_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet200_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet200_vd_train_infer_python.txt new file mode 100644 index 0000000..e742e87 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet200_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet200_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet200_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet200_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet200_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet200_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet34_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet34_train_infer_python.txt new file mode 100644 index 0000000..4a520b5 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet34_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet34 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet34.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet34.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet34.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet34_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet34_vd_train_infer_python.txt new file mode 100644 index 0000000..b956c83 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet34_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet34_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet34_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet34_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet34_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet34_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_train_infer_python.txt new file mode 100644 index 0000000..6775f95 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet50 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet50.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet50.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000..51c73f1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:ResNet50_vd +cpp_infer_type:cls +cls_inference_model_dir:./cls_inference/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/ResNet50_vd_inference.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:True|False +cpu_threads:1|6 +batch_size:1 +use_tensorrt:False|True +precision:fp32|fp16 +image_dir:./dataset/ILSVRC2012/val +benchmark:True +generate_yaml_cmd:python3 test_tipc/generate_cpp_yaml.py diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_paddle2onnx_python_linux_cpu.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_paddle2onnx_python_linux_cpu.txt new file mode 100644 index 0000000..163bb48 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_paddle2onnx_python_linux_cpu.txt @@ -0,0 +1,14 @@ +===========================paddle2onnx_params=========================== +model_name:ResNet50_vd +python:python3.7 +2onnx: paddle2onnx +--model_dir:./deploy/models/ResNet50_vd_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--save_file:./deploy/models/ResNet50_vd_infer/inference.onnx +--opset_version:10 +--enable_onnx_checker:True +inference: python/predict_cls.py -c configs/inference_cls.yaml +Global.use_onnx:True +Global.inference_model_dir:models/ResNet50_vd_infer/ +Global.use_gpu:False diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt new file mode 100644 index 0000000..d16ecd3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet50_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./inference +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/ResNet50_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt new file mode 100644 index 0000000..2cb6915 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_fleet_amp_infer_python_linux_gpu_cpu.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet50_vd +python:python3.7 +gpu_list:xx.xx.xx.xx,yy.yy.yy.yy;0,1 +-o Global.device:gpu +-o Global.auto_cast:null|amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./inference +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/ResNet50_vd_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt new file mode 100644 index 0000000..22c0f8d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_normal_amp_infer_python_linux_gpu_cpu.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ResNet50_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./inference +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/ResNet50_vd_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_use_dali.txt b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_use_dali.txt new file mode 100644 index 0000000..9d4bf7f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ResNet/ResNet50_vd_train_linux_gpu_use_dali.txt @@ -0,0 +1,22 @@ +===========================train_params=========================== +model_name:ResNet50_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null|amp +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False -o Global.use_dali=True +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## diff --git a/src/PaddleClas/test_tipc/config/SENet/SENet154_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SENet154_vd_train_infer_python.txt new file mode 100644 index 0000000..29d2954 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SENet154_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SENet154_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SENet154_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SENet154_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SENet154_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SENet154_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt101_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt101_32x4d_train_infer_python.txt new file mode 100644 index 0000000..023dceb --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt101_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SE_ResNeXt101_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt101_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt50_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt50_32x4d_train_infer_python.txt new file mode 100644 index 0000000..e6c6db7 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt50_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SE_ResNeXt50_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt50_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt50_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt50_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt50_vd_32x4d_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt50_vd_32x4d_train_infer_python.txt new file mode 100644 index 0000000..c2704f9 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SE_ResNeXt50_vd_32x4d_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SE_ResNeXt50_vd_32x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt50_vd_32x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt50_vd_32x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SE_ResNeXt50_vd_32x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNeXt50_vd_32x4d_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SENet/SE_ResNet18_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SE_ResNet18_vd_train_infer_python.txt new file mode 100644 index 0000000..095b1b9 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SE_ResNet18_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SE_ResNet18_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SE_ResNet18_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SE_ResNet18_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SE_ResNet18_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet18_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SENet/SE_ResNet34_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SE_ResNet34_vd_train_infer_python.txt new file mode 100644 index 0000000..260bc63 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SE_ResNet34_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SE_ResNet34_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SE_ResNet34_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SE_ResNet34_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SE_ResNet34_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet34_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SENet/SE_ResNet50_vd_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SENet/SE_ResNet50_vd_train_infer_python.txt new file mode 100644 index 0000000..b486f3c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SENet/SE_ResNet50_vd_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SE_ResNet50_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SENet/SE_ResNet50_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SENet/SE_ResNet50_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SENet/SE_ResNet50_vd.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SE_ResNet50_vd_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_swish_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_swish_train_infer_python.txt new file mode 100644 index 0000000..616e269 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_swish_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_swish +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_swish.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_swish.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_swish.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_swish_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_25_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_25_train_infer_python.txt new file mode 100644 index 0000000..df20812 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_25_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_33_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_33_train_infer_python.txt new file mode 100644 index 0000000..91df1ac --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_33_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x0_33 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_33_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_5_train_infer_python.txt new file mode 100644 index 0000000..e0ee753 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x0_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x1_0_train_infer_python.txt new file mode 100644 index 0000000..a0f354c --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x1_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x1_5_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x1_5_train_infer_python.txt new file mode 100644 index 0000000..f9ab9c1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x1_5_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x1_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x1_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x2_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x2_0_train_infer_python.txt new file mode 100644 index 0000000..eea768a --- /dev/null +++ b/src/PaddleClas/test_tipc/config/ShuffleNet/ShuffleNetV2_x2_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x2_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x2_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x2_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x2_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x2_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SqueezeNet/SqueezeNet1_0_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SqueezeNet/SqueezeNet1_0_train_infer_python.txt new file mode 100644 index 0000000..49c59a9 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SqueezeNet/SqueezeNet1_0_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SqueezeNet1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SqueezeNet/SqueezeNet1_1_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SqueezeNet/SqueezeNet1_1_train_infer_python.txt new file mode 100644 index 0000000..1b957af --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SqueezeNet/SqueezeNet1_1_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SqueezeNet1_1 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_1.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_1.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SqueezeNet/SqueezeNet1_1.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SqueezeNet1_1_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_base_patch4_window12_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_base_patch4_window12_384_train_infer_python.txt new file mode 100644 index 0000000..e7161c8 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_base_patch4_window12_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SwinTransformer_base_patch4_window12_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window12_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window12_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window12_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window12_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_base_patch4_window7_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_base_patch4_window7_224_train_infer_python.txt new file mode 100644 index 0000000..2307086 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_base_patch4_window7_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SwinTransformer_base_patch4_window7_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window7_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window7_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_base_patch4_window7_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_base_patch4_window7_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_large_patch4_window12_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_large_patch4_window12_384_train_infer_python.txt new file mode 100644 index 0000000..f1a1873 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_large_patch4_window12_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SwinTransformer_large_patch4_window12_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window12_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window12_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window12_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window12_384_22kto1k_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_large_patch4_window7_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_large_patch4_window7_224_train_infer_python.txt new file mode 100644 index 0000000..359899e --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_large_patch4_window7_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SwinTransformer_large_patch4_window7_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window7_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window7_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_large_patch4_window7_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_large_patch4_window7_224_22kto1k_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_small_patch4_window7_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_small_patch4_window7_224_train_infer_python.txt new file mode 100644 index 0000000..7f9edb8 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_small_patch4_window7_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SwinTransformer_small_patch4_window7_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_small_patch4_window7_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_small_patch4_window7_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_small_patch4_window7_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_small_patch4_window7_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_train_infer_python.txt new file mode 100644 index 0000000..80b76ed --- /dev/null +++ b/src/PaddleClas/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:SwinTransformer_tiny_patch4_window7_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/SwinTransformer_tiny_patch4_window7_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/TNT/TNT_small_train_infer_python.txt b/src/PaddleClas/test_tipc/config/TNT/TNT_small_train_infer_python.txt new file mode 100644 index 0000000..20d4264 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/TNT/TNT_small_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:TNT_small +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/TNT/TNT_small.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/TNT/TNT_small.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/TNT/TNT_small.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/TNT_small_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Twins/alt_gvt_base_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Twins/alt_gvt_base_train_infer_python.txt new file mode 100644 index 0000000..a08a732 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Twins/alt_gvt_base_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:alt_gvt_base +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Twins/alt_gvt_base.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Twins/alt_gvt_base.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Twins/alt_gvt_base.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_base_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Twins/alt_gvt_large_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Twins/alt_gvt_large_train_infer_python.txt new file mode 100644 index 0000000..d75f8a1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Twins/alt_gvt_large_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:alt_gvt_large +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Twins/alt_gvt_large.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Twins/alt_gvt_large.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Twins/alt_gvt_large.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_large_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Twins/alt_gvt_small_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Twins/alt_gvt_small_train_infer_python.txt new file mode 100644 index 0000000..d0686e5 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Twins/alt_gvt_small_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:alt_gvt_small +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Twins/alt_gvt_small.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Twins/alt_gvt_small.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Twins/alt_gvt_small.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/alt_gvt_small_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Twins/pcpvt_base_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Twins/pcpvt_base_train_infer_python.txt new file mode 100644 index 0000000..76486b8 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Twins/pcpvt_base_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:pcpvt_base +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Twins/pcpvt_base.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Twins/pcpvt_base.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Twins/pcpvt_base.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_base_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Twins/pcpvt_large_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Twins/pcpvt_large_train_infer_python.txt new file mode 100644 index 0000000..928c0b3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Twins/pcpvt_large_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:pcpvt_large +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Twins/pcpvt_large.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Twins/pcpvt_large.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Twins/pcpvt_large.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_large_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Twins/pcpvt_small_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Twins/pcpvt_small_train_infer_python.txt new file mode 100644 index 0000000..9ce13df --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Twins/pcpvt_small_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:pcpvt_small +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Twins/pcpvt_small.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Twins/pcpvt_small.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Twins/pcpvt_small.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/pcpvt_small_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VGG/VGG11_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VGG/VGG11_train_infer_python.txt new file mode 100644 index 0000000..4d5f7b1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VGG/VGG11_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:VGG11 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VGG/VGG11.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VGG/VGG11.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VGG/VGG11.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG11_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VGG/VGG13_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VGG/VGG13_train_infer_python.txt new file mode 100644 index 0000000..737a56b --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VGG/VGG13_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:VGG13 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VGG/VGG13.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VGG/VGG13.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VGG/VGG13.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG13_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VGG/VGG16_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VGG/VGG16_train_infer_python.txt new file mode 100644 index 0000000..b8bf46f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VGG/VGG16_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:VGG16 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VGG/VGG16.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VGG/VGG16.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VGG/VGG16.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG16_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VGG/VGG19_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VGG/VGG19_train_infer_python.txt new file mode 100644 index 0000000..3f5a8f3 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VGG/VGG19_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:VGG19 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VGG/VGG19.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VGG/VGG19.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VGG/VGG19.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/VGG19_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch16_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch16_224_train_infer_python.txt new file mode 100644 index 0000000..d9f6e2f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch16_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_base_patch16_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch16_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch16_384_train_infer_python.txt new file mode 100644 index 0000000..ed88b51 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch16_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_base_patch16_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch16_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch32_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch32_384_train_infer_python.txt new file mode 100644 index 0000000..9c3abcd --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_base_patch32_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_base_patch32_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch32_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch32_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_base_patch32_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch32_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch16_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch16_224_train_infer_python.txt new file mode 100644 index 0000000..ec77af6 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch16_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_large_patch16_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch16_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch16_384_train_infer_python.txt new file mode 100644 index 0000000..e05c6df --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch16_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_large_patch16_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch16_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch32_384_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch32_384_train_infer_python.txt new file mode 100644 index 0000000..43b313f --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_large_patch32_384_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_large_patch32_384 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:2 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch32_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch32_384.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_large_patch32_384.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch32_384_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_small_patch16_224_train_infer_python.txt b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_small_patch16_224_train_infer_python.txt new file mode 100644 index 0000000..6fc2cd0 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/VisionTransformer/ViT_small_patch16_224_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ViT_small_patch16_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_small_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_small_patch16_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_small_patch16_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_small_patch16_224_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Xception/Xception41_deeplab_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Xception/Xception41_deeplab_train_infer_python.txt new file mode 100644 index 0000000..b9c1621 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Xception/Xception41_deeplab_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Xception41_deeplab +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Xception/Xception41_deeplab.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Xception/Xception41_deeplab.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Xception/Xception41_deeplab.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_deeplab_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Xception/Xception41_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Xception/Xception41_train_infer_python.txt new file mode 100644 index 0000000..7d7fbf1 --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Xception/Xception41_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Xception41 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Xception/Xception41.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Xception/Xception41.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Xception/Xception41.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception41_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Xception/Xception65_deeplab_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Xception/Xception65_deeplab_train_infer_python.txt new file mode 100644 index 0000000..adf12cb --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Xception/Xception65_deeplab_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Xception65_deeplab +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Xception/Xception65_deeplab.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Xception/Xception65_deeplab.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Xception/Xception65_deeplab.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_deeplab_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Xception/Xception65_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Xception/Xception65_train_infer_python.txt new file mode 100644 index 0000000..463e20d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Xception/Xception65_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Xception65 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Xception/Xception65.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Xception/Xception65.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Xception/Xception65.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception65_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/config/Xception/Xception71_train_infer_python.txt b/src/PaddleClas/test_tipc/config/Xception/Xception71_train_infer_python.txt new file mode 100644 index 0000000..52ea37d --- /dev/null +++ b/src/PaddleClas/test_tipc/config/Xception/Xception71_train_infer_python.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:Xception71 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/Xception/Xception71.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/Xception/Xception71.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/Xception/Xception71.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/Xception71_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=320 -o PreProcess.transform_ops.1.CropImage.size=299 +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null diff --git a/src/PaddleClas/test_tipc/docs/compare_cpp_right.png b/src/PaddleClas/test_tipc/docs/compare_cpp_right.png new file mode 100644 index 0000000..f9d0ba8 Binary files /dev/null and b/src/PaddleClas/test_tipc/docs/compare_cpp_right.png differ diff --git a/src/PaddleClas/test_tipc/docs/compare_cpp_wrong.png b/src/PaddleClas/test_tipc/docs/compare_cpp_wrong.png new file mode 100644 index 0000000..621d446 Binary files /dev/null and b/src/PaddleClas/test_tipc/docs/compare_cpp_wrong.png differ diff --git a/src/PaddleClas/test_tipc/docs/compare_right.png b/src/PaddleClas/test_tipc/docs/compare_right.png new file mode 100644 index 0000000..3d74ef1 Binary files /dev/null and b/src/PaddleClas/test_tipc/docs/compare_right.png differ diff --git a/src/PaddleClas/test_tipc/docs/compare_wrong.png b/src/PaddleClas/test_tipc/docs/compare_wrong.png new file mode 100644 index 0000000..26ad576 Binary files /dev/null and b/src/PaddleClas/test_tipc/docs/compare_wrong.png differ diff --git a/src/PaddleClas/test_tipc/docs/guide.png b/src/PaddleClas/test_tipc/docs/guide.png new file mode 100644 index 0000000..319ac81 Binary files /dev/null and b/src/PaddleClas/test_tipc/docs/guide.png differ diff --git a/src/PaddleClas/test_tipc/docs/install.md b/src/PaddleClas/test_tipc/docs/install.md new file mode 100644 index 0000000..35e2866 --- /dev/null +++ b/src/PaddleClas/test_tipc/docs/install.md @@ -0,0 +1,121 @@ +## 1. 环境准备 + +本教程适用于test_tipc目录下基础功能测试的运行环境搭建。 + +推荐环境: +- CUDA 10.1/10.2 +- CUDNN 7.6/cudnn8.1 +- TensorRT 6.1.0.5 / 7.1 / 7.2 + +环境配置可以选择docker镜像安装,或者在本地环境Python搭建环境。推荐使用docker镜像安装,避免不必要的环境配置。 + +## 2. Docker 镜像安装 + +推荐docker镜像安装,按照如下命令创建镜像,当前目录映射到镜像中的`/paddle`目录下 +``` +nvidia-docker run --name paddle -it -v $PWD:/paddle paddlepaddle/paddle:latest-dev-cuda10.1-cudnn7-gcc82 /bin/bash +cd /paddle + +# 安装带TRT的paddle +pip3.7 install https://paddle-wheel.bj.bcebos.com/with-trt/2.1.3/linux-gpu-cuda10.1-cudnn7-mkl-gcc8.2-trt6-avx/paddlepaddle_gpu-2.1.3.post101-cp37-cp37m-linux_x86_64.whl +``` + +## 3 Python 环境构建 + +非docker环境下,环境配置比较灵活,推荐环境组合配置: +- CUDA10.1 + CUDNN7.6 + TensorRT 6 +- CUDA10.2 + CUDNN8.1 + TensorRT 7 +- CUDA11.1 + CUDNN8.1 + TensorRT 7 + +下面以 CUDA10.2 + CUDNN8.1 + TensorRT 7 配置为例,介绍环境配置的流程。 + +### 3.1 安装CUDNN + +如果当前环境满足CUDNN版本的要求,可以跳过此步骤。 + +以CUDNN8.1 安装安装为例,安装步骤如下,首先下载CUDNN,从[Nvidia官网](https://developer.nvidia.com/rdp/cudnn-archive)下载CUDNN8.1版本,下载符合当前系统版本的三个deb文件,分别是: +- cuDNN Runtime Library ,如:libcudnn8_8.1.0.77-1+cuda10.2_amd64.deb +- cuDNN Developer Library ,如:libcudnn8-dev_8.1.0.77-1+cuda10.2_amd64.deb +- cuDNN Code Samples,如:libcudnn8-samples_8.1.0.77-1+cuda10.2_amd64.deb + +deb安装可以参考[官方文档](https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#installlinux-deb),安装方式如下 +``` +# x.x.x表示下载的版本号 +# $HOME为工作目录 +sudo dpkg -i libcudnn8_x.x.x-1+cudax.x_arm64.deb +sudo dpkg -i libcudnn8-dev_8.x.x.x-1+cudax.x_arm64.deb +sudo dpkg -i libcudnn8-samples_8.x.x.x-1+cudax.x_arm64.deb + +# 验证是否正确安装 +cp -r /usr/src/cudnn_samples_v8/ $HOME +cd $HOME/cudnn_samples_v8/mnistCUDNN + +# 编译 +make clean && make +./mnistCUDNN +``` +如果运行mnistCUDNN完后提示运行成功,则表示安装成功。如果运行后出现freeimage相关的报错,需要按照提示安装freeimage库: +``` +sudo apt-get install libfreeimage-dev +sudo apt-get install libfreeimage +``` + +### 3.2 安装TensorRT + +首先,从[Nvidia官网TensorRT板块](https://developer.nvidia.com/tensorrt-getting-started)下载TensorRT,这里选择7.1.3.4版本的TensorRT,注意选择适合自己系统版本和CUDA版本的TensorRT,另外建议下载TAR package的安装包。 + +以Ubuntu16.04+CUDA10.2为例,下载并解压后可以参考[官方文档](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-713/install-guide/index.html#installing-tar)的安装步骤,按照如下步骤安装: +``` +# 以下安装命令中 '${version}' 为下载的TensorRT版本,如7.1.3.4 +# 设置环境变量, 为解压后的TensorRT的lib目录 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: + +# 安装TensorRT +cd TensorRT-${version}/python +pip3.7 install tensorrt-*-cp3x-none-linux_x86_64.whl + +# 安装graphsurgeon +cd TensorRT-${version}/graphsurgeon +``` + + +### 3.3 安装PaddlePaddle + +下载支持TensorRT版本的Paddle安装包,注意安装包的TensorRT版本需要与本地TensorRT一致,下载[链接](https://paddleinference.paddlepaddle.org.cn/user_guides/download_lib.html#python) +选择下载 linux-cuda10.2-trt7-gcc8.2 Python3.7版本的Paddle: +``` +# 从下载链接中可以看到是paddle2.1.1-cuda10.2-cudnn8.1版本 +wget https://paddle-wheel.bj.bcebos.com/with-trt/2.1.1-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2/paddlepaddle_gpu-2.1.1-cp37-cp37m-linux_x86_64.whl +pip3.7 install -U paddlepaddle_gpu-2.1.1-cp37-cp37m-linux_x86_64.whl +``` + +## 4. 安装PaddleClas依赖 +``` +# 安装AutoLog +git clone https://github.com/LDOUBLEV/AutoLog +cd AutoLog +pip3.7 install -r requirements.txt +python3.7 setup.py bdist_wheel +pip3.7 install ./dist/auto_log-1.0.0-py3-none-any.whl + +# 下载Clas代码 +cd ../ +git clone https://github.com/PaddlePaddle/PaddleClas + +``` + +安装PaddleClas依赖: +``` +cd PaddleClas +pip3.7 install -r requirements.txt +``` + +## FAQ : +Q. You are using Paddle compiled with TensorRT, but TensorRT dynamic library is not found. Ignore this if TensorRT is not needed. + +A. 问题一般是当前安装paddle版本带TRT,但是本地环境找不到TensorRT的预测库,需要下载TensorRT库,解压后设置环境变量LD_LIBRARY_PATH; +如: +``` +export LD_LIBRARY_PATH=/usr/local/python3.7.0/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/paddle/package/TensorRT-6.0.1.5/lib +``` +或者问题是下载的TensorRT版本和当前paddle中编译的TRT版本不匹配,需要下载版本相符的TensorRT重新安装。 diff --git a/src/PaddleClas/test_tipc/docs/test.png b/src/PaddleClas/test_tipc/docs/test.png new file mode 100644 index 0000000..f99f23d Binary files /dev/null and b/src/PaddleClas/test_tipc/docs/test.png differ diff --git a/src/PaddleClas/test_tipc/docs/test_inference_cpp.md b/src/PaddleClas/test_tipc/docs/test_inference_cpp.md new file mode 100644 index 0000000..eabf877 --- /dev/null +++ b/src/PaddleClas/test_tipc/docs/test_inference_cpp.md @@ -0,0 +1,86 @@ +# C++预测功能测试 + +C++预测功能测试的主程序为`test_inference_cpp.sh`,可以测试基于C++预测库的模型推理功能。 + +## 1. 测试结论汇总 + +基于训练是否使用量化,进行本测试的模型可以分为`正常模型`和`量化模型`,这两类模型对应的C++预测功能汇总如下: + +| 模型类型 |device | batchsize | tensorrt | mkldnn | cpu多线程 | +| ---- | ---- | ---- | :----: | :----: | :----: | +| 正常模型 | GPU | 1/6 | fp32/fp16 | - | - | +| 正常模型 | CPU | 1/6 | - | fp32 | 支持 | +| 量化模型 | GPU | 1/6 | int8 | - | - | +| 量化模型 | CPU | 1/6 | - | int8 | 支持 | + +## 2. 测试流程 +运行环境配置请参考[文档](./install.md)的内容配置TIPC的运行环境。 + +### 2.1 功能测试 +先运行`prepare.sh`准备数据和模型,然后运行`test_inference_cpp.sh`进行测试,最终在```test_tipc/output```目录下生成`cpp_infer_*.log`后缀的日志文件。 + +```shell +bash test_tipc/prepare.sh test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt cpp_infer + +# 用法1: +bash test_tipc/test_inference_cpp.sh test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt +# 用法2: 指定GPU卡预测,第三个传入参数为GPU卡号 +bash test_tipc/test_inference_cpp.sh test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt 1 +``` + +运行预测指令后,在`test_tipc/output`文件夹下自动会保存运行日志,包括以下文件: + +```shell +test_tipc/output/ +|- results_cpp.log # 运行指令状态的日志 +|- cls_cpp_infer_cpu_usemkldnn_False_threads_1_precision_fp32_batchsize_1.log # CPU上不开启Mkldnn,线程数设置为1,测试batch_size=1条件下的预测运行日志 +|- cls_cpp_infer_cpu_usemkldnn_False_threads_6_precision_fp32_batchsize_1.log # CPU上不开启Mkldnn,线程数设置为6,测试batch_size=1条件下的预测运行日志 +|- cls_cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log # GPU上不开启TensorRT,测试batch_size=1的fp32精度预测日志 +|- cls_cpp_infer_gpu_usetrt_True_precision_fp16_batchsize_1.log # GPU上开启TensorRT,测试batch_size=1的fp16精度预测日志 +...... +``` +其中results_cpp.log中包含了每条指令的运行状态,如果运行成功会输出: + +``` +Run successfully with command - ./deploy/cpp/build/clas_system -c inference_cls.yaml 2>&1|tee test_tipc/output/cls_cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log +...... +``` +如果运行失败,会输出: +``` +Run failed with command - ./deploy/cpp/build/clas_system -c inference_cls.yaml 2>&1|tee test_tipc/output/cls_cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log +...... +``` +可以很方便的根据results_cpp.log中的内容判定哪一个指令运行错误。 + + +### 2.2 精度测试 + +使用compare_results.py脚本比较模型预测的结果是否符合预期,主要步骤包括: +- 提取日志中的预测坐标; +- 从本地文件中提取保存好的坐标结果; +- 比较上述两个结果是否符合精度预期,误差大于设置阈值时会报错。 + +#### 使用方式 +运行命令: +```shell +python3.7 test_tipc/compare_results.py --gt_file=./test_tipc/results/cls_cpp_*.txt --log_file=./test_tipc/output/cls_cpp_*.log --atol=1e-3 --rtol=1e-3 +``` + +参数介绍: +- gt_file: 指向事先保存好的预测结果路径,支持*.txt 结尾,会自动索引*.txt格式的文件,文件默认保存在test_tipc/result/ 文件夹下 +- log_file: 指向运行test_tipc/test_inference_cpp.sh 脚本的infer模式保存的预测日志,预测日志中打印的有预测结果,比如:文本框,预测文本,类别等等,同样支持cpp_infer_*.log格式传入 +- atol: 设置的绝对误差 +- rtol: 设置的相对误差 + +#### 运行结果 + +正常运行效果如下图: + + +出现不一致结果时的运行输出: + + + +## 3. 更多教程 + +本文档为功能测试用,更详细的c++预测使用教程请参考:[服务器端C++预测](../../docs/zh_CN/inference_deployment/) diff --git a/src/PaddleClas/test_tipc/docs/test_train_inference_python.md b/src/PaddleClas/test_tipc/docs/test_train_inference_python.md new file mode 100644 index 0000000..ef25e14 --- /dev/null +++ b/src/PaddleClas/test_tipc/docs/test_train_inference_python.md @@ -0,0 +1,154 @@ +# Linux端基础训练预测功能测试 + +Linux端基础训练预测功能测试的主程序为`test_train_inference_python.sh`,可以测试基于Python的模型训练、评估、推理等基本功能,包括裁剪、量化、蒸馏。 + +- Mac端基础训练预测功能测试参考[链接](./mac_test_train_inference_python.md) +- Windows端基础训练预测功能测试参考[链接](./win_test_train_inference_python.md) + +## 1. 测试结论汇总 + +- 训练相关: + +| 算法名称 | 模型名称 | 单机单卡 | 单机多卡 | 多机多卡 | 模型压缩(单机多卡) | +| :---- | :---- | :---- | :---- | :---- | :---- | +| MobileNetV3 | MobileNetV3_large_x1_0 | 正常训练
混合精度 | 正常训练
混合精度 | 正常训练
混合精度 | 正常训练:FPGM裁剪、PACT量化
离线量化(无需训练) | +| ResNet50 | ResNet50_vd | 正常训练
混合精度 | 正常训练
混合精度 | 正常训练
混合精度 | 正常训练:FPGM裁剪、PACT量化
离线量化(无需训练) | + + +- 预测相关:基于训练是否使用量化,可以将训练产出的模型可以分为`正常模型`和`量化模型`,这两类模型对应的预测功能汇总如下, + +| 模型类型 |device | batchsize | tensorrt | mkldnn | cpu多线程 | +| ---- | ---- | ---- | :----: | :----: | :----: | +| 正常模型 | GPU | 1/6 | fp32/fp16 | - | - | +| 正常模型 | CPU | 1/6 | - | fp32/fp16 | 支持 | +| 量化模型 | GPU | 1/6 | int8 | - | - | +| 量化模型 | CPU | 1/6 | - | int8 | 支持 | + + +## 2. 测试流程 + +运行环境配置请参考[文档](./install.md)的内容配置TIPC的运行环境。 + +### 2.1 安装依赖 +- 安装PaddlePaddle >= 2.2 +- 安装PaddleClas依赖 + ``` + pip3 install -r ../requirements.txt + ``` +- 安装autolog(规范化日志输出工具) + ``` + git clone https://github.com/LDOUBLEV/AutoLog + cd AutoLog + pip3 install -r requirements.txt + python3 setup.py bdist_wheel + pip3 install ./dist/auto_log-1.0.0-py3-none-any.whl + cd ../ + ``` +- 安装PaddleSlim (可选) + ``` + # 如果要测试量化、裁剪等功能,需要安装PaddleSlim + pip3 install paddleslim + ``` + + +### 2.2 功能测试 +先运行`prepare.sh`准备数据和模型,然后运行`test_train_inference_python.sh`进行测试,最终在```test_tipc/output```目录下生成`python_infer_*.log`格式的日志文件。 + +`test_train_inference_python.sh`包含5种运行模式,每种模式的运行数据不同,分别用于测试速度和精度,分别是: + +- 模式1:lite_train_lite_infer,使用少量数据训练,用于快速验证训练到预测的走通流程,不验证精度和速度; +```shell +bash test_tipc/prepare.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'lite_train_lite_infer' +bash test_tipc/test_train_inference_python.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'lite_train_lite_infer' +``` + +- 模式2:lite_train_whole_infer,使用少量数据训练,一定量数据预测,用于验证训练后的模型执行预测,预测速度是否合理; +```shell +bash test_tipc/prepare.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'lite_train_whole_infer' +bash test_tipc/test_train_inference_python.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'lite_train_whole_infer' +``` + +- 模式3:whole_infer,不训练,全量数据预测,走通开源模型评估、动转静,检查inference model预测时间和精度; +```shell +bash test_tipc/prepare.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'whole_infer' +# 用法1: +bash test_tipc/test_train_inference_python.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'whole_infer' +# 用法2: 指定GPU卡预测,第三个传入参数为GPU卡号 +bash test_tipc/test_train_inference_python.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'whole_infer' '1' +``` + +- 模式4:whole_train_whole_infer,CE: 全量数据训练,全量数据预测,验证模型训练精度,预测精度,预测速度; +```shell +bash test_tipc/prepare.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'whole_train_whole_infer' +bash test_tipc/test_train_inference_python.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'whole_train_whole_infer' +``` + +- 模式5: klquant_whole_infer,测试离线量化; + +```shell +bash test_tipc/prepare.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'klquant_whole_infer' +bash test_tipc/test_train_inference_python.sh ./test_tipc/config/ResNet/ResNet50_vd_train_infer_python.txt 'klquant_whole_infer' +``` + + + +运行相应指令后,在`test_tipc/output`文件夹下自动会保存运行日志。如'lite_train_lite_infer'模式下,会运行训练+inference的链条,因此,在`test_tipc/output`文件夹有以下文件: + +``` +test_tipc/output/ +|- results_python.log # 运行指令状态的日志 +|- norm_train_gpus_0_autocast_null/ # GPU 0号卡上正常训练的训练日志和模型保存文件夹 +|- pact_train_gpus_0_autocast_null/ # GPU 0号卡上量化训练的训练日志和模型保存文件夹 +...... +|- python_infer_cpu_usemkldnn_True_threads_1_batchsize_1.log # CPU上开启Mkldnn线程数设置为1,测试batch_size=1条件下的预测运行日志 +|- python_infer_gpu_usetrt_True_precision_fp16_batchsize_1.log # GPU上开启TensorRT,测试batch_size=1的半精度预测日志 +...... +``` + +其中`results_python.log`中包含了每条指令的运行状态,如果运行成功会输出: +``` +Run successfully with command - python3.7 tools/train.py -c tests/configs/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained Global.use_gpu=True Global.save_model_dir=./tests/output/norm_train_gpus_0_autocast_null Global.epoch_num=1 Train.loader.batch_size_per_card=2 ! +Run successfully with command - python3.7 tools/export_model.py -c tests/configs/det_mv3_db.yml -o Global.pretrained_model=./tests/output/norm_train_gpus_0_autocast_null/latest Global.save_inference_dir=./tests/output/norm_train_gpus_0_autocast_null! +...... +``` +如果运行失败,会输出: +``` +Run failed with command - python3.7 tools/train.py -c tests/configs/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained Global.use_gpu=True Global.save_model_dir=./tests/output/norm_train_gpus_0_autocast_null Global.epoch_num=1 Train.loader.batch_size_per_card=2 ! +Run failed with command - python3.7 tools/export_model.py -c tests/configs/det_mv3_db.yml -o Global.pretrained_model=./tests/output/norm_train_gpus_0_autocast_null/latest Global.save_inference_dir=./tests/output/norm_train_gpus_0_autocast_null! +...... +``` +可以很方便的根据`results_python.log`中的内容判定哪一个指令运行错误。 + + +### 2.3 精度测试 + +使用compare_results.py脚本比较模型预测的结果是否符合预期,主要步骤包括: +- 提取日志中的预测坐标; +- 从本地文件中提取保存好的坐标结果; +- 比较上述两个结果是否符合精度预期,误差大于设置阈值时会报错。 + +#### 使用方式 +运行命令: +```shell +python3.7 test_tipc/compare_results.py --gt_file=./test_tipc/results/python_*.txt --log_file=./test_tipc/output/python_*.log --atol=1e-3 --rtol=1e-3 +``` + +参数介绍: +- gt_file: 指向事先保存好的预测结果路径,支持*.txt 结尾,会自动索引*.txt格式的文件,文件默认保存在test_tipc/result/ 文件夹下 +- log_file: 指向运行test_tipc/test_train_inference_python.sh 脚本的infer模式保存的预测日志,预测日志中打印的有预测结果,比如:文本框,预测文本,类别等等,同样支持python_infer_*.log格式传入 +- atol: 设置的绝对误差 +- rtol: 设置的相对误差 + +#### 运行结果 + +正常运行效果如下图: + + +出现不一致结果时的运行输出: + + + +## 3. 更多教程 +本文档为功能测试用,更丰富的训练预测使用教程请参考: +[模型训练](../../docs/zh_CN/models_training) +[基于Python预测引擎推理](../../docs/zh_CN/inference_deployment/python_deploy.md) diff --git a/src/PaddleClas/test_tipc/generate_cpp_yaml.py b/src/PaddleClas/test_tipc/generate_cpp_yaml.py new file mode 100644 index 0000000..2e541de --- /dev/null +++ b/src/PaddleClas/test_tipc/generate_cpp_yaml.py @@ -0,0 +1,80 @@ +import os +import yaml +import argparse + + +def str2bool(v): + if v.lower() == 'true': + return True + else: + return False + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--type', required=True, choices=["cls", "shitu"]) + parser.add_argument('--batch_size', type=int, default=1) + parser.add_argument('--mkldnn', type=str2bool, default=True) + parser.add_argument('--gpu', type=str2bool, default=False) + parser.add_argument('--cpu_thread', type=int, default=1) + parser.add_argument('--tensorrt', type=str2bool, default=False) + parser.add_argument('--precision', type=str, choices=["fp32", "fp16"]) + parser.add_argument('--benchmark', type=str2bool, default=True) + parser.add_argument('--gpu_id', type=int, default=0) + parser.add_argument( + '--cls_yaml_path', + type=str, + default="deploy/configs/inference_cls.yaml") + parser.add_argument( + '--shitu_yaml_path', + type=str, + default="deploy/configs/inference_drink.yaml") + parser.add_argument('--data_dir', type=str, required=True) + parser.add_argument('--save_path', type=str, default='./') + parser.add_argument('--cls_model_dir', type=str) + parser.add_argument('--det_model_dir', type=str) + args = parser.parse_args() + return args + + +def main(): + args = parse_args() + if args.type == "cls": + save_path = os.path.join(args.save_path, + os.path.basename(args.cls_yaml_path)) + fd = open(args.cls_yaml_path) + else: + save_path = os.path.join(args.save_path, + os.path.basename(args.shitu_yaml_path)) + fd = open(args.shitu_yaml_path) + config = yaml.load(fd, yaml.FullLoader) + fd.close() + + config["Global"]["batch_size"] = args.batch_size + config["Global"]["use_gpu"] = args.gpu + config["Global"]["enable_mkldnn"] = args.mkldnn + config["Global"]["benchmark"] = args.benchmark + config["Global"]["use_tensorrt"] = args.tensorrt + config["Global"]["use_fp16"] = True if args.precision == "fp16" else False + config["Global"]["gpu_id"] = args.gpu_id + if args.type == "cls": + config["Global"]["infer_imgs"] = args.data_dir + assert args.cls_model_dir + config["Global"]["inference_model_dir"] = args.cls_model_dir + else: + config["Global"]["infer_imgs"] = os.path.join(args.data_dir, + "test_images") + config["IndexProcess"]["index_dir"] = os.path.join(args.data_dir, + "index") + assert args.cls_model_dir + assert args.det_model_dir + config["Global"]["det_inference_model_dir"] = args.det_model_dir + config["Global"]["rec_inference_model_dir"] = args.cls_model_dir + + with open(save_path, 'w') as fd: + yaml.dump(config, fd) + print("Generate new yaml done") + + +if __name__ == "__main__": + main() diff --git a/src/PaddleClas/test_tipc/prepare.sh b/src/PaddleClas/test_tipc/prepare.sh new file mode 100644 index 0000000..acb2eb0 --- /dev/null +++ b/src/PaddleClas/test_tipc/prepare.sh @@ -0,0 +1,184 @@ +#!/bin/bash +FILENAME=$1 + +# MODE be one of ['lite_train_lite_infer' 'lite_train_whole_infer' 'whole_train_whole_infer', +# 'whole_infer', 'klquant_whole_infer', +# 'cpp_infer', 'serving_infer', 'lite_infer'] + +MODE=$2 + +dataline=$(cat ${FILENAME}) +# parser params +IFS=$'\n' +lines=(${dataline}) + +function func_parser_key(){ + strs=$1 + IFS=":" + array=(${strs}) + tmp=${array[0]} + echo ${tmp} +} + +function func_parser_value(){ + strs=$1 + IFS=":" + array=(${strs}) + if [ ${#array[*]} = 2 ]; then + echo ${array[1]} + else + IFS="|" + tmp="${array[1]}:${array[2]}" + echo ${tmp} + fi +} + +function func_get_url_file_name(){ + strs=$1 + IFS="/" + array=(${strs}) + tmp=${array[${#array[@]}-1]} + echo ${tmp} +} + +model_name=$(func_parser_value "${lines[1]}") + +if [ ${MODE} = "cpp_infer" ];then + if [[ $FILENAME == *infer_cpp_linux_gpu_cpu.txt ]];then + cpp_type=$(func_parser_value "${lines[2]}") + cls_inference_model_dir=$(func_parser_value "${lines[3]}") + det_inference_model_dir=$(func_parser_value "${lines[4]}") + cls_inference_url=$(func_parser_value "${lines[5]}") + det_inference_url=$(func_parser_value "${lines[6]}") + + if [[ $cpp_type == "cls" ]];then + eval "wget -nc $cls_inference_url" + tar xf "${model_name}_inference.tar" + eval "mv inference $cls_inference_model_dir" + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_infer.tar + tar xf whole_chain_infer.tar + ln -s whole_chain_infer ILSVRC2012 + cd .. + elif [[ $cpp_type == "shitu" ]];then + eval "wget -nc $cls_inference_url" + tar_name=$(func_get_url_file_name "$cls_inference_url") + model_dir=${tar_name%.*} + eval "tar xf ${tar_name}" + eval "mv ${model_dir} ${cls_inference_model_dir}" + + eval "wget -nc $det_inference_url" + tar_name=$(func_get_url_file_name "$det_inference_url") + model_dir=${tar_name%.*} + eval "tar xf ${tar_name}" + eval "mv ${model_dir} ${det_inference_model_dir}" + cd dataset + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v1.0.tar + tar -xf drink_dataset_v1.0.tar + else + echo "Wrong cpp type in config file in line 3. only support cls, shitu" + fi + exit 0 + else + echo "use wrong config file" + exit 1 + fi +fi + +model_name=$(func_parser_value "${lines[1]}") +model_url_value=$(func_parser_value "${lines[35]}") +model_url_key=$(func_parser_key "${lines[35]}") + +if [[ $FILENAME == *GeneralRecognition* ]];then + cd dataset + rm -rf Aliproduct + rm -rf train_reg_all_data.txt + rm -rf demo_train + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/tipc_shitu_demo_data.tar + tar -xf tipc_shitu_demo_data.tar + ln -s tipc_shitu_demo_data Aliproduct + ln -s tipc_shitu_demo_data/demo_train.txt train_reg_all_data.txt + ln -s tipc_shitu_demo_data/demo_train demo_train + cd tipc_shitu_demo_data + ln -s demo_test.txt val_list.txt + cd ../../ + eval "wget -nc $model_url_value" + mv general_PPLCNet_x2_5_pretrained_v1.0.pdparams GeneralRecognition_PPLCNet_x2_5_pretrained.pdparams + exit 0 +fi + +if [[ $FILENAME == *use_dali* ]];then + python_name=$(func_parser_value "${lines[2]}") + ${python_name} -m pip install --extra-index-url https://developer.download.nvidia.com/compute/redist/nightly --upgrade nvidia-dali-nightly-cuda102 +fi + +if [ ${MODE} = "lite_train_lite_infer" ] || [ ${MODE} = "lite_train_whole_infer" ];then + # pretrain lite train data + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_little_train.tar + tar xf whole_chain_little_train.tar + ln -s whole_chain_little_train ILSVRC2012 + cd ILSVRC2012 + mv train.txt train_list.txt + mv val.txt val_list.txt + cp -r train/* val/ + cd ../../ +elif [ ${MODE} = "whole_infer" ] || [ ${MODE} = "klquant_whole_infer" ];then + # download data + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_infer.tar + tar xf whole_chain_infer.tar + ln -s whole_chain_infer ILSVRC2012 + cd ILSVRC2012 + mv val.txt val_list.txt + ln -s val_list.txt train_list.txt + cd ../../ + # download inference or pretrained model + eval "wget -nc $model_url_value" + if [[ $model_url_key == *inference* ]]; then + rm -rf inference + tar xf "${model_name}_inference.tar" + fi + if [[ $model_name == "SwinTransformer_large_patch4_window7_224" || $model_name == "SwinTransformer_large_patch4_window12_384" ]];then + cmd="mv ${model_name}_22kto1k_pretrained.pdparams ${model_name}_pretrained.pdparams" + eval $cmd + fi + +elif [ ${MODE} = "whole_train_whole_infer" ];then + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar + tar xf whole_chain_CIFAR100.tar + ln -s whole_chain_CIFAR100 ILSVRC2012 + cd ILSVRC2012 + mv train.txt train_list.txt + mv test.txt val_list.txt + cd ../../ +fi + +if [ ${MODE} = "serving_infer" ];then + # prepare serving env + python_name=$(func_parser_value "${lines[2]}") + ${python_name} -m pip install install paddle-serving-server-gpu==0.6.1.post101 + ${python_name} -m pip install paddle_serving_client==0.6.1 + ${python_name} -m pip install paddle-serving-app==0.6.1 + unset http_proxy + unset https_proxy + cd ./deploy/paddleserving + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar +fi + +if [ ${MODE} = "paddle2onnx_infer" ];then + # prepare paddle2onnx env + python_name=$(func_parser_value "${lines[2]}") + ${python_name} -m pip install install paddle2onnx + ${python_name} -m pip install onnxruntime + + # wget model + cd deploy && mkdir models && cd models + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar + cd ../../ +fi diff --git a/src/PaddleClas/test_tipc/prepare_lite_cpp.sh b/src/PaddleClas/test_tipc/prepare_lite_cpp.sh new file mode 100644 index 0000000..b129322 --- /dev/null +++ b/src/PaddleClas/test_tipc/prepare_lite_cpp.sh @@ -0,0 +1,93 @@ +#!/bin/bash +source ./test_tipc/common_func.sh +FILENAME=$1 +dataline=$(cat ${FILENAME}) +# parser params +IFS=$'\n' +lines=(${dataline}) +IFS=$'\n' + +inference_cmd=$(func_parser_value "${lines[1]}") +DEVICE=$(func_parser_value "${lines[2]}") +det_lite_model_list=$(func_parser_value "${lines[3]}") +rec_lite_model_list=$(func_parser_value "${lines[4]}") +cls_lite_model_list=$(func_parser_value "${lines[5]}") + +if [[ $inference_cmd =~ "det" ]];then + lite_model_list=${det_lite_model_list} +elif [[ $inference_cmd =~ "rec" ]];then + lite_model_list=(${rec_lite_model_list[*]} ${cls_lite_model_list[*]}) +elif [[ $inference_cmd =~ "system" ]];then + lite_model_list=(${det_lite_model_list[*]} ${rec_lite_model_list[*]} ${cls_lite_model_list[*]}) +else + echo "inference_cmd is wrong, please check." + exit 1 +fi + +if [ ${DEVICE} = "ARM_CPU" ];then + valid_targets="arm" + paddlelite_url="https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.android.armv8.gcc.c++_shared.with_extra.with_cv.tar.gz" + end_index="66" +elif [ ${DEVICE} = "ARM_GPU_OPENCL" ];then + valid_targets="opencl" + paddlelite_url="https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.armv8.clang.with_exception.with_extra.with_cv.opencl.tar.gz" + end_index="71" +else + echo "DEVICE only suport ARM_CPU, ARM_GPU_OPENCL." + exit 2 +fi + +# prepare lite .nb model +pip install paddlelite==2.10-rc +current_dir=${PWD} +IFS="|" +model_path=./inference_models + +for model in ${lite_model_list[*]}; do + if [[ $model =~ "PP-OCRv2" ]];then + inference_model_url=https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/${model}.tar + elif [[ $model =~ "v2.0" ]];then + inference_model_url=https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/${model}.tar + else + echo "Model is wrong, please check." + exit 3 + fi + inference_model=${inference_model_url##*/} + wget -nc -P ${model_path} ${inference_model_url} + cd ${model_path} && tar -xf ${inference_model} && cd ../ + model_dir=${model_path}/${inference_model%.*} + model_file=${model_dir}/inference.pdmodel + param_file=${model_dir}/inference.pdiparams + paddle_lite_opt --model_dir=${model_dir} --model_file=${model_file} --param_file=${param_file} --valid_targets=${valid_targets} --optimize_out=${model_dir}_opt +done + +# prepare test data +data_url=https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar +model_path=./inference_models +inference_model=${inference_model_url##*/} +data_file=${data_url##*/} +wget -nc -P ./inference_models ${inference_model_url} +wget -nc -P ./test_data ${data_url} +cd ./inference_models && tar -xf ${inference_model} && cd ../ +cd ./test_data && tar -xf ${data_file} && rm ${data_file} && cd ../ + +# prepare lite env +paddlelite_zipfile=$(echo $paddlelite_url | awk -F "/" '{print $NF}') +paddlelite_file=${paddlelite_zipfile:0:${end_index}} +wget ${paddlelite_url} && tar -xf ${paddlelite_zipfile} +mkdir -p ${paddlelite_file}/demo/cxx/ocr/test_lite +cp -r ${model_path}/*_opt.nb test_data ${paddlelite_file}/demo/cxx/ocr/test_lite +cp ppocr/utils/ppocr_keys_v1.txt deploy/lite/config.txt ${paddlelite_file}/demo/cxx/ocr/test_lite +cp -r ./deploy/lite/* ${paddlelite_file}/demo/cxx/ocr/ +cp ${paddlelite_file}/cxx/lib/libpaddle_light_api_shared.so ${paddlelite_file}/demo/cxx/ocr/test_lite +cp ${FILENAME} test_tipc/test_lite_arm_cpp.sh test_tipc/common_func.sh ${paddlelite_file}/demo/cxx/ocr/test_lite +cd ${paddlelite_file}/demo/cxx/ocr/ +git clone https://github.com/cuicheng01/AutoLog.git + +# make +make -j +sleep 1 +make -j +cp ocr_db_crnn test_lite && cp test_lite/libpaddle_light_api_shared.so test_lite/libc++_shared.so +tar -cf test_lite.tar ./test_lite && cp test_lite.tar ${current_dir} && cd ${current_dir} +rm -rf ${paddlelite_file}* && rm -rf ${model_path} diff --git a/src/PaddleClas/test_tipc/test_inference_cpp.sh b/src/PaddleClas/test_tipc/test_inference_cpp.sh new file mode 100644 index 0000000..129e439 --- /dev/null +++ b/src/PaddleClas/test_tipc/test_inference_cpp.sh @@ -0,0 +1,303 @@ +#!/bin/bash +source test_tipc/common_func.sh + +FILENAME=$1 +GPUID=$2 +if [[ ! $GPUID ]];then + GPUID=0 +fi +dataline=$(awk 'NR==1, NR==16{print}' $FILENAME) + +# parser params +IFS=$'\n' +lines=(${dataline}) + +# parser cpp inference model +model_name=$(func_parser_value "${lines[1]}") +cpp_infer_type=$(func_parser_value "${lines[2]}") +cpp_infer_model_dir=$(func_parser_value "${lines[3]}") +cpp_det_infer_model_dir=$(func_parser_value "${lines[4]}") +cpp_infer_is_quant=$(func_parser_value "${lines[7]}") +# parser cpp inference +inference_cmd=$(func_parser_value "${lines[8]}") +cpp_use_gpu_list=$(func_parser_value "${lines[9]}") +cpp_use_mkldnn_list=$(func_parser_value "${lines[10]}") +cpp_cpu_threads_list=$(func_parser_value "${lines[11]}") +cpp_batch_size_list=$(func_parser_value "${lines[12]}") +cpp_use_trt_list=$(func_parser_value "${lines[13]}") +cpp_precision_list=$(func_parser_value "${lines[14]}") +cpp_image_dir_value=$(func_parser_value "${lines[15]}") +cpp_benchmark_value=$(func_parser_value "${lines[16]}") +generate_yaml_cmd=$(func_parser_value "${lines[17]}") +transform_index_cmd=$(func_parser_value "${lines[18]}") + +LOG_PATH="./test_tipc/output" +mkdir -p ${LOG_PATH} +status_log="${LOG_PATH}/results_cpp.log" +# generate_yaml_cmd="python3 test_tipc/generate_cpp_yaml.py" + +function func_shitu_cpp_inference(){ + IFS='|' + _script=$1 + _model_dir=$2 + _log_path=$3 + _img_dir=$4 + _flag_quant=$5 + # inference + + for use_gpu in ${cpp_use_gpu_list[*]}; do + if [ ${use_gpu} = "False" ] || [ ${use_gpu} = "cpu" ]; then + for use_mkldnn in ${cpp_use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + continue + fi + for threads in ${cpp_cpu_threads_list[*]}; do + for batch_size in ${cpp_batch_size_list[*]}; do + precision="fp32" + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + precison="int8" + fi + _save_log_path="${_log_path}/shitu_cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_precision_${precision}_batchsize_${batch_size}.log" + + command="${generate_yaml_cmd} --type shitu --batch_size ${batch_size} --mkldnn ${use_mkldnn} --gpu ${use_gpu} --cpu_thread ${threads} --tensorrt False --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --det_model_dir ${cpp_det_infer_model_dir} --gpu_id ${GPUID}" + eval $command + eval $transform_index_cmd + command="${_script} 2>&1|tee ${_save_log_path}" + eval $command + last_status=${PIPESTATUS[0]} + status_check $last_status "${command}" "${status_log}" + done + done + done + elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then + for use_trt in ${cpp_use_trt_list[*]}; do + for precision in ${cpp_precision_list[*]}; do + if [[ ${_flag_quant} = "False" ]] && [[ ${precision} =~ "int8" ]]; then + continue + fi + if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then + continue + fi + for batch_size in ${cpp_batch_size_list[*]}; do + _save_log_path="${_log_path}/shitu_cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + command="${generate_yaml_cmd} --type shitu --batch_size ${batch_size} --mkldnn False --gpu ${use_gpu} --cpu_thread 1 --tensorrt ${use_trt} --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --det_model_dir ${cpp_det_infer_model_dir} --gpu_id ${GPUID}" + eval $command + eval $transform_index_cmd + command="${_script} 2>&1|tee ${_save_log_path}" + eval $command + last_status=${PIPESTATUS[0]} + status_check $last_status "${_script}" "${status_log}" + done + done + done + else + echo "Does not support hardware other than CPU and GPU Currently!" + fi + done +} + +function func_cls_cpp_inference(){ + IFS='|' + _script=$1 + _model_dir=$2 + _log_path=$3 + _img_dir=$4 + _flag_quant=$5 + # inference + + for use_gpu in ${cpp_use_gpu_list[*]}; do + if [ ${use_gpu} = "False" ] || [ ${use_gpu} = "cpu" ]; then + for use_mkldnn in ${cpp_use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + continue + fi + for threads in ${cpp_cpu_threads_list[*]}; do + for batch_size in ${cpp_batch_size_list[*]}; do + precision="fp32" + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + precison="int8" + fi + _save_log_path="${_log_path}/cls_cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_precision_${precision}_batchsize_${batch_size}.log" + + command="${generate_yaml_cmd} --type cls --batch_size ${batch_size} --mkldnn ${use_mkldnn} --gpu ${use_gpu} --cpu_thread ${threads} --tensorrt False --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --gpu_id ${GPUID}" + eval $command + command1="${_script} 2>&1|tee ${_save_log_path}" + eval ${command1} + last_status=${PIPESTATUS[0]} + status_check $last_status "${command1}" "${status_log}" + done + done + done + elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then + for use_trt in ${cpp_use_trt_list[*]}; do + for precision in ${cpp_precision_list[*]}; do + if [[ ${_flag_quant} = "False" ]] && [[ ${precision} =~ "int8" ]]; then + continue + fi + if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then + continue + fi + for batch_size in ${cpp_batch_size_list[*]}; do + _save_log_path="${_log_path}/cls_cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + command="${generate_yaml_cmd} --type cls --batch_size ${batch_size} --mkldnn False --gpu ${use_gpu} --cpu_thread 1 --tensorrt ${use_trt} --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --gpu_id ${GPUID}" + eval $command + command="${_script} 2>&1|tee ${_save_log_path}" + eval $command + last_status=${PIPESTATUS[0]} + status_check $last_status "${command}" "${status_log}" + done + done + done + else + echo "Does not support hardware other than CPU and GPU Currently!" + fi + done +} + + +if [[ $cpp_infer_type == "cls" ]]; then + cd deploy/cpp +elif [[ $cpp_infer_type == "shitu" ]]; then + cd deploy/cpp_shitu +else + echo "Only support cls and shitu" + exit 0 +fi + +if [[ $cpp_infer_type == "shitu" ]]; then + echo "################### update cmake ###################" + wget -nc https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0.tar.gz + tar xf cmake-3.22.0.tar.gz + cd ./cmake-3.22.0 + export root_path=$PWD + export install_path=${root_path}/cmake + eval "./bootstrap --prefix=${install_path}" + make -j + make install + export PATH=${install_path}/bin:$PATH + cd .. + echo "################### update cmake done ###################" + + echo "################### build faiss ###################" + apt-get install -y libopenblas-dev + git clone https://github.com/facebookresearch/faiss.git + cd faiss + export faiss_install_path=$PWD/faiss_install + eval "cmake -B build . -DFAISS_ENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=${faiss_install_path}" + make -C build -j faiss + make -C build install + cd .. +fi + +if [ -d "opencv-3.4.7/opencv3/" ] && [ $(md5sum opencv-3.4.7.tar.gz | awk -F ' ' '{print $1}') = "faa2b5950f8bee3f03118e600c74746a" ];then + echo "################### build opencv skipped ###################" +else + echo "################### build opencv ###################" + rm -rf opencv-3.4.7.tar.gz opencv-3.4.7/ + wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/opencv-3.4.7.tar.gz + tar -xf opencv-3.4.7.tar.gz + + cd opencv-3.4.7/ + install_path=$(pwd)/opencv3 + + rm -rf build + mkdir build + cd build + + cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + + make -j + make install + cd ../../ + echo "################### build opencv finished ###################" +fi + +echo "################### build PaddleClas demo ####################" +OPENCV_DIR=$(pwd)/opencv-3.4.7/opencv3/ +# LIB_DIR=/work/project/project/test/paddle_inference/ +LIB_DIR=$(pwd)/Paddle/build/paddle_inference_install_dir/ +CUDA_LIB_DIR=$(dirname `find /usr -name libcudart.so`) +CUDNN_LIB_DIR=$(dirname `find /usr -name libcudnn.so`) + +BUILD_DIR=build +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} +if [[ $cpp_infer_type == cls ]]; then + cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=ON \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DTENSORRT_DIR=${TENSORRT_DIR} +else + cmake ..\ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=ON \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DTENSORRT_DIR=${TENSORRT_DIR} \ + -DFAISS_DIR=${faiss_install_path} \ + -DFAISS_WITH_MKL=OFF +fi +make -j +cd ../../../ +# cd ../../ +echo "################### build PaddleClas demo finished ###################" + + +# set cuda device +# GPUID=$2 +# if [ ${#GPUID} -le 0 ];then +# env="export CUDA_VISIBLE_DEVICES=0" +# else +# env="export CUDA_VISIBLE_DEVICES=${GPUID}" +# fi +# set CUDA_VISIBLE_DEVICES +# eval $env + + +echo "################### run test ###################" +export Count=0 +IFS="|" +infer_quant_flag=(${cpp_infer_is_quant}) +for infer_model in ${cpp_infer_model_dir[*]}; do + #run inference + is_quant=${infer_quant_flag[Count]} + if [[ $cpp_infer_type == "cls" ]]; then + func_cls_cpp_inference "${inference_cmd}" "${infer_model}" "${LOG_PATH}" "${cpp_image_dir_value}" ${is_quant} + else + func_shitu_cpp_inference "${inference_cmd}" "${infer_model}" "${LOG_PATH}" "${cpp_image_dir_value}" ${is_quant} + fi + Count=$(($Count + 1)) +done diff --git a/src/PaddleClas/test_tipc/test_inference_jeston.sh b/src/PaddleClas/test_tipc/test_inference_jeston.sh new file mode 100644 index 0000000..2fd76e1 --- /dev/null +++ b/src/PaddleClas/test_tipc/test_inference_jeston.sh @@ -0,0 +1,87 @@ +#!/bin/bash +source test_tipc/common_func.sh +source test_tipc/test_train_inference_python.sh + +FILENAME=$1 +# MODE be one of ['whole_infer'] +MODE=$2 + +dataline=$(awk 'NR==1, NR==17{print}' $FILENAME) + +# parser params +IFS=$'\n' +lines=(${dataline}) + +model_name=$(func_parser_value "${lines[1]}") +python=$(func_parser_value "${lines[2]}") + +infer_model_dir_list=$(func_parser_value "${lines[3]}") +infer_export_list=$(func_parser_value "${lines[4]}") +infer_is_quant=$(func_parser_value "${lines[5]}") +# parser inference +inference_py=$(func_parser_value "${lines[6]}") +use_gpu_key=$(func_parser_key "${lines[7]}") +use_gpu_list=$(func_parser_value "${lines[7]}") +use_mkldnn_key=$(func_parser_key "${lines[8]}") +use_mkldnn_list=$(func_parser_value "${lines[8]}") +cpu_threads_key=$(func_parser_key "${lines[9]}") +cpu_threads_list=$(func_parser_value "${lines[9]}") +batch_size_key=$(func_parser_key "${lines[10]}") +batch_size_list=$(func_parser_value "${lines[10]}") +use_trt_key=$(func_parser_key "${lines[11]}") +use_trt_list=$(func_parser_value "${lines[11]}") +precision_key=$(func_parser_key "${lines[12]}") +precision_list=$(func_parser_value "${lines[12]}") +infer_model_key=$(func_parser_key "${lines[13]}") +image_dir_key=$(func_parser_key "${lines[14]}") +infer_img_dir=$(func_parser_value "${lines[14]}") +save_log_key=$(func_parser_key "${lines[15]}") +benchmark_key=$(func_parser_key "${lines[16]}") +benchmark_value=$(func_parser_value "${lines[16]}") +infer_key1=$(func_parser_key "${lines[17]}") +infer_value1=$(func_parser_value "${lines[17]}") + + +LOG_PATH="./test_tipc/output" +mkdir -p ${LOG_PATH} +status_log="${LOG_PATH}/results_python.log" + + +if [ ${MODE} = "whole_infer" ]; then + GPUID=$3 + if [ ${#GPUID} -le 0 ];then + env=" " + else + env="export CUDA_VISIBLE_DEVICES=${GPUID}" + fi + # set CUDA_VISIBLE_DEVICES + eval $env + export Count=0 + IFS="|" + infer_run_exports=(${infer_export_list}) + infer_quant_flag=(${infer_is_quant}) + for infer_model in ${infer_model_dir_list[*]}; do + # run export + if [ ${infer_run_exports[Count]} != "null" ];then + save_infer_dir=$(dirname $infer_model) + set_export_weight=$(func_set_params "${export_weight}" "${infer_model}") + set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_dir}") + export_cmd="${python} ${infer_run_exports[Count]} ${set_export_weight} ${set_save_infer_key}" + echo ${infer_run_exports[Count]} + echo $export_cmd + eval $export_cmd + status_export=$? + status_check $status_export "${export_cmd}" "${status_log}" + else + save_infer_dir=${infer_model} + fi + #run inference + is_quant=${infer_quant_flag[Count]} + if [ ${MODE} = "klquant_infer" ]; then + is_quant="True" + fi + func_inference "${python}" "${inference_py}" "${save_infer_dir}" "${LOG_PATH}" "${infer_img_dir}" ${is_quant} + Count=$(($Count + 1)) + done +fi + diff --git a/src/PaddleClas/test_tipc/test_lite_arm_cpp.sh b/src/PaddleClas/test_tipc/test_lite_arm_cpp.sh new file mode 100644 index 0000000..c071a23 --- /dev/null +++ b/src/PaddleClas/test_tipc/test_lite_arm_cpp.sh @@ -0,0 +1,159 @@ +#!/bin/bash +source ./common_func.sh +export LD_LIBRARY_PATH=${PWD}:$LD_LIBRARY_PATH + +FILENAME=$1 +dataline=$(cat $FILENAME) +# parser params +IFS=$'\n' +lines=(${dataline}) + +# parser lite inference +inference_cmd=$(func_parser_value "${lines[1]}") +runtime_device=$(func_parser_value "${lines[2]}") +det_model_list=$(func_parser_value "${lines[3]}") +rec_model_list=$(func_parser_value "${lines[4]}") +cls_model_list=$(func_parser_value "${lines[5]}") +cpu_threads_list=$(func_parser_value "${lines[6]}") +det_batch_size_list=$(func_parser_value "${lines[7]}") +rec_batch_size_list=$(func_parser_value "${lines[8]}") +infer_img_dir_list=$(func_parser_value "${lines[9]}") +config_dir=$(func_parser_value "${lines[10]}") +rec_dict_dir=$(func_parser_value "${lines[11]}") +benchmark_value=$(func_parser_value "${lines[12]}") + +if [[ $inference_cmd =~ "det" ]]; then + lite_model_list=${det_lite_model_list} +elif [[ $inference_cmd =~ "rec" ]]; then + lite_model_list=(${rec_lite_model_list[*]} ${cls_lite_model_list[*]}) +elif [[ $inference_cmd =~ "system" ]]; then + lite_model_list=(${det_lite_model_list[*]} ${rec_lite_model_list[*]} ${cls_lite_model_list[*]}) +else + echo "inference_cmd is wrong, please check." + exit 1 +fi + +LOG_PATH="./output" +mkdir -p ${LOG_PATH} +status_log="${LOG_PATH}/results.log" + + +function func_test_det(){ + IFS='|' + _script=$1 + _det_model=$2 + _log_path=$3 + _img_dir=$4 + _config=$5 + if [[ $_det_model =~ "slim" ]]; then + precision="INT8" + else + precision="FP32" + fi + + # lite inference + for num_threads in ${cpu_threads_list[*]}; do + for det_batchsize in ${det_batch_size_list[*]}; do + _save_log_path="${_log_path}/lite_${_det_model}_runtime_device_${runtime_device}_precision_${precision}_det_batchsize_${det_batchsize}_threads_${num_threads}.log" + command="${_script} ${_det_model} ${runtime_device} ${precision} ${num_threads} ${det_batchsize} ${_img_dir} ${_config} ${benchmark_value} > ${_save_log_path} 2>&1" + eval ${command} + status_check $? "${command}" "${status_log}" + done + done +} + +function func_test_rec(){ + IFS='|' + _script=$1 + _rec_model=$2 + _cls_model=$3 + _log_path=$4 + _img_dir=$5 + _config=$6 + _rec_dict_dir=$7 + + if [[ $_det_model =~ "slim" ]]; then + _precision="INT8" + else + _precision="FP32" + fi + + # lite inference + for num_threads in ${cpu_threads_list[*]}; do + for rec_batchsize in ${rec_batch_size_list[*]}; do + _save_log_path="${_log_path}/lite_${_rec_model}_${cls_model}_runtime_device_${runtime_device}_precision_${_precision}_rec_batchsize_${rec_batchsize}_threads_${num_threads}.log" + command="${_script} ${_rec_model} ${_cls_model} ${runtime_device} ${_precision} ${num_threads} ${rec_batchsize} ${_img_dir} ${_config} ${_rec_dict_dir} ${benchmark_value} > ${_save_log_path} 2>&1" + eval ${command} + status_check $? "${command}" "${status_log}" + done + done +} + +function func_test_system(){ + IFS='|' + _script=$1 + _det_model=$2 + _rec_model=$3 + _cls_model=$4 + _log_path=$5 + _img_dir=$6 + _config=$7 + _rec_dict_dir=$8 + if [[ $_det_model =~ "slim" ]]; then + _precision="INT8" + else + _precision="FP32" + fi + + # lite inference + for num_threads in ${cpu_threads_list[*]}; do + for det_batchsize in ${det_batch_size_list[*]}; do + for rec_batchsize in ${rec_batch_size_list[*]}; do + _save_log_path="${_log_path}/lite_${_det_model}_${_rec_model}_${_cls_model}_runtime_device_${runtime_device}_precision_${_precision}_det_batchsize_${det_batchsize}_rec_batchsize_${rec_batchsize}_threads_${num_threads}.log" + command="${_script} ${_det_model} ${_rec_model} ${_cls_model} ${runtime_device} ${_precision} ${num_threads} ${det_batchsize} ${_img_dir} ${_config} ${_rec_dict_dir} ${benchmark_value} > ${_save_log_path} 2>&1" + eval ${command} + status_check $? "${command}" "${status_log}" + done + done + done +} + + +echo "################### run test ###################" + +if [[ $inference_cmd =~ "det" ]]; then + IFS="|" + det_model_list=(${det_model_list[*]}) + + for i in {0..1}; do + #run lite inference + for img_dir in ${infer_img_dir_list[*]}; do + func_test_det "${inference_cmd}" "${det_model_list[i]}_opt.nb" "${LOG_PATH}" "${img_dir}" "${config_dir}" + done + done + +elif [[ $inference_cmd =~ "rec" ]]; then + IFS="|" + rec_model_list=(${rec_model_list[*]}) + cls_model_list=(${cls_model_list[*]}) + + for i in {0..1}; do + #run lite inference + for img_dir in ${infer_img_dir_list[*]}; do + func_test_rec "${inference_cmd}" "${rec_model}_opt.nb" "${cls_model_list[i]}_opt.nb" "${LOG_PATH}" "${img_dir}" "${rec_dict_dir}" "${config_dir}" + done + done + +elif [[ $inference_cmd =~ "system" ]]; then + IFS="|" + det_model_list=(${det_model_list[*]}) + rec_model_list=(${rec_model_list[*]}) + cls_model_list=(${cls_model_list[*]}) + + for i in {0..1}; do + #run lite inference + for img_dir in ${infer_img_dir_list[*]}; do + func_test_system "${inference_cmd}" "${det_model_list[i]}_opt.nb" "${rec_model_list[i]}_opt.nb" "${cls_model_list[i]}_opt.nb" "${LOG_PATH}" "${img_dir}" "${config_dir}" "${rec_dict_dir}" + done + done +fi diff --git a/src/PaddleClas/test_tipc/test_paddle2onnx.sh b/src/PaddleClas/test_tipc/test_paddle2onnx.sh new file mode 100644 index 0000000..850fc90 --- /dev/null +++ b/src/PaddleClas/test_tipc/test_paddle2onnx.sh @@ -0,0 +1,78 @@ +#!/bin/bash +source test_tipc/common_func.sh + +FILENAME=$1 + +dataline=$(cat ${FILENAME}) +lines=(${dataline}) +# common params +model_name=$(func_parser_value "${lines[1]}") +python=$(func_parser_value "${lines[2]}") + + +# parser params +dataline=$(awk 'NR==1, NR==14{print}' $FILENAME) +IFS=$'\n' +lines=(${dataline}) + +# parser paddle2onnx +model_name=$(func_parser_value "${lines[1]}") +python=$(func_parser_value "${lines[2]}") +padlle2onnx_cmd=$(func_parser_value "${lines[3]}") +infer_model_dir_key=$(func_parser_key "${lines[4]}") +infer_model_dir_value=$(func_parser_value "${lines[4]}") +model_filename_key=$(func_parser_key "${lines[5]}") +model_filename_value=$(func_parser_value "${lines[5]}") +params_filename_key=$(func_parser_key "${lines[6]}") +params_filename_value=$(func_parser_value "${lines[6]}") +save_file_key=$(func_parser_key "${lines[7]}") +save_file_value=$(func_parser_value "${lines[7]}") +opset_version_key=$(func_parser_key "${lines[8]}") +opset_version_value=$(func_parser_value "${lines[8]}") +enable_onnx_checker_key=$(func_parser_key "${lines[9]}") +enable_onnx_checker_value=$(func_parser_value "${lines[9]}") +# parser onnx inference +inference_py=$(func_parser_value "${lines[10]}") +use_onnx_key=$(func_parser_key "${lines[11]}") +use_onnx_value=$(func_parser_value "${lines[11]}") +inference_model_dir_key=$(func_parser_key "${lines[12]}") +inference_model_dir_value=$(func_parser_value "${lines[12]}") +inference_hardware_key=$(func_parser_key "${lines[13]}") +inference_hardware_value=$(func_parser_value "${lines[13]}") + +LOG_PATH="./test_tipc/output" +mkdir -p ./test_tipc/output +status_log="${LOG_PATH}/results_paddle2onnx.log" + + +function func_paddle2onnx(){ + IFS='|' + _script=$1 + + # paddle2onnx + _save_log_path=".${LOG_PATH}/paddle2onnx_infer_cpu.log" + set_dirname=$(func_set_params "${infer_model_dir_key}" "${infer_model_dir_value}") + set_model_filename=$(func_set_params "${model_filename_key}" "${model_filename_value}") + set_params_filename=$(func_set_params "${params_filename_key}" "${params_filename_value}") + set_save_model=$(func_set_params "${save_file_key}" "${save_file_value}") + set_opset_version=$(func_set_params "${opset_version_key}" "${opset_version_value}") + set_enable_onnx_checker=$(func_set_params "${enable_onnx_checker_key}" "${enable_onnx_checker_value}") + trans_model_cmd="${padlle2onnx_cmd} ${set_dirname} ${set_model_filename} ${set_params_filename} ${set_save_model} ${set_opset_version} ${set_enable_onnx_checker}" + eval $trans_model_cmd + last_status=${PIPESTATUS[0]} + status_check $last_status "${trans_model_cmd}" "${status_log}" + # python inference + set_model_dir=$(func_set_params "${inference_model_dir_key}" "${inference_model_dir_value}") + set_use_onnx=$(func_set_params "${use_onnx_key}" "${use_onnx_value}") + set_hardware=$(func_set_params "${inference_hardware_key}" "${inference_hardware_value}") + infer_model_cmd="cd deploy && ${python} ${inference_py} -o ${set_model_dir} -o ${set_use_onnx} -o ${set_hardware} >${_save_log_path} 2>&1 && cd ../" + eval $infer_model_cmd + status_check $last_status "${infer_model_cmd}" "${status_log}" +} + + +echo "################### run test ###################" + +export Count=0 +IFS="|" +func_paddle2onnx \ No newline at end of file diff --git a/src/PaddleClas/test_tipc/test_serving.sh b/src/PaddleClas/test_tipc/test_serving.sh new file mode 100644 index 0000000..c36935a --- /dev/null +++ b/src/PaddleClas/test_tipc/test_serving.sh @@ -0,0 +1,168 @@ +#!/bin/bash +source test_tipc/common_func.sh + +FILENAME=$1 +dataline=$(awk 'NR==1, NR==18{print}' $FILENAME) + +# parser params +IFS=$'\n' +lines=(${dataline}) + +# parser serving +model_name=$(func_parser_value "${lines[1]}") +python=$(func_parser_value "${lines[2]}") +trans_model_py=$(func_parser_value "${lines[3]}") +infer_model_dir_key=$(func_parser_key "${lines[4]}") +infer_model_dir_value=$(func_parser_value "${lines[4]}") +model_filename_key=$(func_parser_key "${lines[5]}") +model_filename_value=$(func_parser_value "${lines[5]}") +params_filename_key=$(func_parser_key "${lines[6]}") +params_filename_value=$(func_parser_value "${lines[6]}") +serving_server_key=$(func_parser_key "${lines[7]}") +serving_server_value=$(func_parser_value "${lines[7]}") +serving_client_key=$(func_parser_key "${lines[8]}") +serving_client_value=$(func_parser_value "${lines[8]}") +serving_dir_value=$(func_parser_value "${lines[9]}") +web_service_py=$(func_parser_value "${lines[10]}") +web_use_gpu_key=$(func_parser_key "${lines[11]}") +web_use_gpu_list=$(func_parser_value "${lines[11]}") +web_use_mkldnn_key=$(func_parser_key "${lines[12]}") +web_use_mkldnn_list=$(func_parser_value "${lines[12]}") +web_cpu_threads_key=$(func_parser_key "${lines[13]}") +web_cpu_threads_list=$(func_parser_value "${lines[13]}") +web_use_trt_key=$(func_parser_key "${lines[14]}") +web_use_trt_list=$(func_parser_value "${lines[14]}") +web_precision_key=$(func_parser_key "${lines[15]}") +web_precision_list=$(func_parser_value "${lines[15]}") +pipeline_py=$(func_parser_value "${lines[16]}") +image_dir_key=$(func_parser_key "${lines[17]}") +image_dir_value=$(func_parser_value "${lines[17]}") + +LOG_PATH="../../test_tipc/output" +mkdir -p ./test_tipc/output +status_log="${LOG_PATH}/results_serving.log" + +function func_serving(){ + IFS='|' + _python=$1 + _script=$2 + _model_dir=$3 + # pdserving + set_dirname=$(func_set_params "${infer_model_dir_key}" "${infer_model_dir_value}") + set_model_filename=$(func_set_params "${model_filename_key}" "${model_filename_value}") + set_params_filename=$(func_set_params "${params_filename_key}" "${params_filename_value}") + set_serving_server=$(func_set_params "${serving_server_key}" "${serving_server_value}") + set_serving_client=$(func_set_params "${serving_client_key}" "${serving_client_value}") + set_image_dir=$(func_set_params "${image_dir_key}" "${image_dir_value}") + trans_model_cmd="${python} ${trans_model_py} ${set_dirname} ${set_model_filename} ${set_params_filename} ${set_serving_server} ${set_serving_client}" + eval $trans_model_cmd + cd ${serving_dir_value} + echo $PWD + unset https_proxy + unset http_proxy + for python in ${python[*]}; do + if [ ${python} = "cpp"]; then + for use_gpu in ${web_use_gpu_list[*]}; do + if [ ${use_gpu} = "null" ]; then + web_service_cpp_cmd="${python} -m paddle_serving_server.serve --model ppocr_det_mobile_2.0_serving/ ppocr_rec_mobile_2.0_serving/ --port 9293" + eval $web_service_cmd + sleep 2s + _save_log_path="${LOG_PATH}/server_infer_cpp_cpu_pipeline_usemkldnn_False_threads_4_batchsize_1.log" + pipeline_cmd="${python} ocr_cpp_client.py ppocr_det_mobile_2.0_client/ ppocr_rec_mobile_2.0_client/" + eval $pipeline_cmd + status_check $last_status "${pipeline_cmd}" "${status_log}" + sleep 2s + ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 + else + web_service_cpp_cmd="${python} -m paddle_serving_server.serve --model ppocr_det_mobile_2.0_serving/ ppocr_rec_mobile_2.0_serving/ --port 9293 --gpu_id=0" + eval $web_service_cmd + sleep 2s + _save_log_path="${LOG_PATH}/server_infer_cpp_cpu_pipeline_usemkldnn_False_threads_4_batchsize_1.log" + pipeline_cmd="${python} ocr_cpp_client.py ppocr_det_mobile_2.0_client/ ppocr_rec_mobile_2.0_client/" + eval $pipeline_cmd + status_check $last_status "${pipeline_cmd}" "${status_log}" + sleep 2s + ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 + fi + done + else + # python serving + for use_gpu in ${web_use_gpu_list[*]}; do + echo ${ues_gpu} + if [ ${use_gpu} = "null" ]; then + for use_mkldnn in ${web_use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "False" ]; then + continue + fi + for threads in ${web_cpu_threads_list[*]}; do + set_cpu_threads=$(func_set_params "${web_cpu_threads_key}" "${threads}") + web_service_cmd="${python} ${web_service_py} ${web_use_gpu_key}=${use_gpu} ${web_use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} &" + eval $web_service_cmd + sleep 2s + for pipeline in ${pipeline_py[*]}; do + _save_log_path="${LOG_PATH}/server_infer_cpu_${pipeline%_client*}_usemkldnn_${use_mkldnn}_threads_${threads}_batchsize_1.log" + pipeline_cmd="${python} ${pipeline} ${set_image_dir} > ${_save_log_path} 2>&1 " + eval $pipeline_cmd + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${pipeline_cmd}" "${status_log}" + sleep 2s + done + ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 + done + done + elif [ ${use_gpu} = "0" ]; then + for use_trt in ${web_use_trt_list[*]}; do + for precision in ${web_precision_list[*]}; do + if [[ ${_flag_quant} = "False" ]] && [[ ${precision} =~ "int8" ]]; then + continue + fi + if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [[ ${_flag_quant} = "True" ]]; then + continue + fi + set_tensorrt=$(func_set_params "${web_use_trt_key}" "${use_trt}") + set_precision=$(func_set_params "${web_precision_key}" "${precision}") + web_service_cmd="${python} ${web_service_py} ${web_use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} & " + eval $web_service_cmd + + sleep 2s + for pipeline in ${pipeline_py[*]}; do + _save_log_path="${LOG_PATH}/server_infer_gpu_${pipeline%_client*}_usetrt_${use_trt}_precision_${precision}_batchsize_1.log" + pipeline_cmd="${python} ${pipeline} ${set_image_dir}> ${_save_log_path} 2>&1" + eval $pipeline_cmd + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${pipeline_cmd}" "${status_log}" + sleep 2s + done + ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 + done + done + else + echo "Does not support hardware other than CPU and GPU Currently!" + fi + done + fi + done +} + + +# set cuda device +GPUID=$2 +if [ ${#GPUID} -le 0 ];then + env=" " +else + env="export CUDA_VISIBLE_DEVICES=${GPUID}" +fi +set CUDA_VISIBLE_DEVICES +eval $env + + +echo "################### run test ###################" + +export Count=0 +IFS="|" +func_serving "${web_service_cmd}" diff --git a/src/PaddleClas/test_tipc/test_train_inference_python.sh b/src/PaddleClas/test_tipc/test_train_inference_python.sh new file mode 100644 index 0000000..39503dd --- /dev/null +++ b/src/PaddleClas/test_tipc/test_train_inference_python.sh @@ -0,0 +1,340 @@ +#!/bin/bash +FILENAME=$1 +source test_tipc/common_func.sh + +# MODE be one of ['lite_train_lite_infer' 'lite_train_whole_infer' 'whole_train_whole_infer', 'whole_infer', 'klquant_whole_infer'] +MODE=$2 + +dataline=$(cat ${FILENAME}) + +# parser params +IFS=$'\n' +lines=(${dataline}) + +# The training params +model_name=$(func_parser_value "${lines[1]}") +python=$(func_parser_value "${lines[2]}") +gpu_list=$(func_parser_value "${lines[3]}") +train_use_gpu_key=$(func_parser_key "${lines[4]}") +train_use_gpu_value=$(func_parser_value "${lines[4]}") +autocast_list=$(func_parser_value "${lines[5]}") +autocast_key=$(func_parser_key "${lines[5]}") +epoch_key=$(func_parser_key "${lines[6]}") +epoch_num=$(func_parser_params "${lines[6]}") +save_model_key=$(func_parser_key "${lines[7]}") +train_batch_key=$(func_parser_key "${lines[8]}") +train_batch_value=$(func_parser_value "${lines[8]}") +pretrain_model_key=$(func_parser_key "${lines[9]}") +pretrain_model_value=$(func_parser_value "${lines[9]}") +train_model_name=$(func_parser_value "${lines[10]}") +train_infer_img_dir=$(func_parser_value "${lines[11]}") +train_param_key1=$(func_parser_key "${lines[12]}") +train_param_value1=$(func_parser_value "${lines[12]}") + +trainer_list=$(func_parser_value "${lines[14]}") +trainer_norm=$(func_parser_key "${lines[15]}") +norm_trainer=$(func_parser_value "${lines[15]}") +pact_key=$(func_parser_key "${lines[16]}") +pact_trainer=$(func_parser_value "${lines[16]}") +fpgm_key=$(func_parser_key "${lines[17]}") +fpgm_trainer=$(func_parser_value "${lines[17]}") +distill_key=$(func_parser_key "${lines[18]}") +distill_trainer=$(func_parser_value "${lines[18]}") +trainer_key1=$(func_parser_key "${lines[19]}") +trainer_value1=$(func_parser_value "${lines[19]}") +trainer_key2=$(func_parser_key "${lines[20]}") +trainer_value2=$(func_parser_value "${lines[20]}") + +eval_py=$(func_parser_value "${lines[23]}") +eval_key1=$(func_parser_key "${lines[24]}") +eval_value1=$(func_parser_value "${lines[24]}") + +save_infer_key=$(func_parser_key "${lines[27]}") +export_weight=$(func_parser_key "${lines[28]}") +norm_export=$(func_parser_value "${lines[29]}") +pact_export=$(func_parser_value "${lines[30]}") +fpgm_export=$(func_parser_value "${lines[31]}") +distill_export=$(func_parser_value "${lines[32]}") +kl_quant_cmd_key=$(func_parser_key "${lines[33]}") +kl_quant_cmd_value=$(func_parser_value "${lines[33]}") +export_key2=$(func_parser_key "${lines[34]}") +export_value2=$(func_parser_value "${lines[34]}") + +# parser inference model +infer_model_dir_list=$(func_parser_value "${lines[36]}") +infer_export_flag=$(func_parser_value "${lines[37]}") +infer_is_quant=$(func_parser_value "${lines[38]}") + +# parser inference +inference_py=$(func_parser_value "${lines[39]}") +use_gpu_key=$(func_parser_key "${lines[40]}") +use_gpu_list=$(func_parser_value "${lines[40]}") +use_mkldnn_key=$(func_parser_key "${lines[41]}") +use_mkldnn_list=$(func_parser_value "${lines[41]}") +cpu_threads_key=$(func_parser_key "${lines[42]}") +cpu_threads_list=$(func_parser_value "${lines[42]}") +batch_size_key=$(func_parser_key "${lines[43]}") +batch_size_list=$(func_parser_value "${lines[43]}") +use_trt_key=$(func_parser_key "${lines[44]}") +use_trt_list=$(func_parser_value "${lines[44]}") +precision_key=$(func_parser_key "${lines[45]}") +precision_list=$(func_parser_value "${lines[45]}") +infer_model_key=$(func_parser_key "${lines[46]}") +image_dir_key=$(func_parser_key "${lines[47]}") +infer_img_dir=$(func_parser_value "${lines[47]}") +save_log_key=$(func_parser_key "${lines[48]}") +benchmark_key=$(func_parser_key "${lines[49]}") +benchmark_value=$(func_parser_value "${lines[49]}") +infer_key1=$(func_parser_key "${lines[50]}") +infer_value1=$(func_parser_value "${lines[50]}") +if [ ! $epoch_num ]; then + epoch_num=2 +fi +LOG_PATH="./test_tipc/output" +mkdir -p ${LOG_PATH} +status_log="${LOG_PATH}/results_python.log" + +function func_inference(){ + IFS='|' + _python=$1 + _script=$2 + _model_dir=$3 + _log_path=$4 + _img_dir=$5 + _flag_quant=$6 + # inference + for use_gpu in ${use_gpu_list[*]}; do + if [ ${use_gpu} = "False" ] || [ ${use_gpu} = "cpu" ]; then + for use_mkldnn in ${use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + continue + fi + for threads in ${cpu_threads_list[*]}; do + for batch_size in ${batch_size_list[*]}; do + _save_log_path="${_log_path}/infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_batchsize_${batch_size}.log" + set_infer_data=$(func_set_params "${image_dir_key}" "${_img_dir}") + set_benchmark=$(func_set_params "${benchmark_key}" "${benchmark_value}") + set_batchsize=$(func_set_params "${batch_size_key}" "${batch_size}") + set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}") + set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}") + set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}") + command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "../${status_log}" + done + done + done + elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then + for use_trt in ${use_trt_list[*]}; do + for precision in ${precision_list[*]}; do + if [ ${precision} = "True" ] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then + continue + fi + for batch_size in ${batch_size_list[*]}; do + _save_log_path="${_log_path}/infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + set_infer_data=$(func_set_params "${image_dir_key}" "${_img_dir}") + set_benchmark=$(func_set_params "${benchmark_key}" "${benchmark_value}") + set_batchsize=$(func_set_params "${batch_size_key}" "${batch_size}") + set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}") + set_precision=$(func_set_params "${precision_key}" "${precision}") + set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}") + command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "../${status_log}" + done + done + done + else + echo "Does not support hardware other than CPU and GPU Currently!" + fi + done +} + +if [ ${MODE} = "whole_infer" ] || [ ${MODE} = "klquant_whole_infer" ]; then + IFS="|" + infer_export_flag=(${infer_export_flag}) + if [ ${infer_export_flag} != "null" ] && [ ${infer_export_flag} != "False" ]; then + rm -rf ${infer_model_dir_list/..\//} + export_cmd="${python} ${norm_export} -o Global.pretrained_model=${model_name}_pretrained -o Global.save_inference_dir=${infer_model_dir_list/..\//}" + eval $export_cmd + fi +fi + +if [ ${MODE} = "whole_infer" ]; then + GPUID=$3 + if [ ${#GPUID} -le 0 ];then + env=" " + else + env="export CUDA_VISIBLE_DEVICES=${GPUID}" + fi + # set CUDA_VISIBLE_DEVICES + eval $env + export Count=0 + cd deploy + for infer_model in ${infer_model_dir_list[*]}; do + #run inference + is_quant=${infer_quant_flag[Count]} + echo "is_quant: ${is_quant}" + func_inference "${python}" "${inference_py}" "${infer_model}" "../${LOG_PATH}" "${infer_img_dir}" ${is_quant} + Count=$(($Count + 1)) + done + cd .. + +elif [ ${MODE} = "klquant_whole_infer" ]; then + # for kl_quant + if [ ${kl_quant_cmd_value} != "null" ] && [ ${kl_quant_cmd_value} != "False" ]; then + echo "kl_quant" + command="${python} ${kl_quant_cmd_value}" + eval $command + last_status=${PIPESTATUS[0]} + status_check $last_status "${command}" "${status_log}" + cd inference/quant_post_static_model + ln -s __model__ inference.pdmodel + ln -s __params__ inference.pdiparams + cd ../../deploy + is_quant=True + func_inference "${python}" "${inference_py}" "${infer_model_dir_list}/quant_post_static_model" "../${LOG_PATH}" "${infer_img_dir}" ${is_quant} + cd .. + fi +else + IFS="|" + export Count=0 + USE_GPU_KEY=(${train_use_gpu_value}) + for gpu in ${gpu_list[*]}; do + train_use_gpu=${USE_GPU_KEY[Count]} + Count=$(($Count + 1)) + ips="" + if [ ${gpu} = "-1" ];then + env="" + elif [ ${#gpu} -le 1 ];then + env="export CUDA_VISIBLE_DEVICES=${gpu}" + eval ${env} + elif [ ${#gpu} -le 15 ];then + IFS="," + array=(${gpu}) + env="export CUDA_VISIBLE_DEVICES=${array[0]}" + IFS="|" + else + IFS=";" + array=(${gpu}) + ips=${array[0]} + gpu=${array[1]} + IFS="|" + env=" " + fi + for autocast in ${autocast_list[*]}; do + for trainer in ${trainer_list[*]}; do + flag_quant=False + if [ ${trainer} = ${pact_key} ]; then + run_train=${pact_trainer} + run_export=${pact_export} + flag_quant=True + elif [ ${trainer} = "${fpgm_key}" ]; then + run_train=${fpgm_trainer} + run_export=${fpgm_export} + elif [ ${trainer} = "${distill_key}" ]; then + run_train=${distill_trainer} + run_export=${distill_export} + elif [ ${trainer} = ${trainer_key1} ]; then + run_train=${trainer_value1} + run_export=${export_value1} + elif [[ ${trainer} = ${trainer_key2} ]]; then + run_train=${trainer_value2} + run_export=${export_value2} + else + run_train=${norm_trainer} + run_export=${norm_export} + fi + + if [ ${run_train} = "null" ]; then + continue + fi + + set_autocast=$(func_set_params "${autocast_key}" "${autocast}") + set_epoch=$(func_set_params "${epoch_key}" "${epoch_num}") + set_pretrain=$(func_set_params "${pretrain_model_key}" "${pretrain_model_value}") + set_batchsize=$(func_set_params "${train_batch_key}" "${train_batch_value}") + set_train_params1=$(func_set_params "${train_param_key1}" "${train_param_value1}") + set_use_gpu=$(func_set_params "${train_use_gpu_key}" "${train_use_gpu_value}") + if [ ${#ips} -le 26 ];then + save_log="${LOG_PATH}/${trainer}_gpus_${gpu}_autocast_${autocast}" + nodes=1 + else + IFS="," + ips_array=(${ips}) + IFS="|" + nodes=${#ips_array[@]} + save_log="${LOG_PATH}/${trainer}_gpus_${gpu}_autocast_${autocast}_nodes_${nodes}" + fi + + # load pretrain from norm training if current trainer is pact or fpgm trainer + # if [ ${trainer} = ${pact_key} ] || [ ${trainer} = ${fpgm_key} ]; then + # set_pretrain="${load_norm_train_model}" + # fi + + set_save_model=$(func_set_params "${save_model_key}" "${save_log}") + if [ ${#gpu} -le 2 ];then # train with cpu or single gpu + cmd="${python} ${run_train} ${set_use_gpu} ${set_save_model} ${set_epoch} ${set_pretrain} ${set_autocast} ${set_batchsize} ${set_train_params1} " + elif [ ${#ips} -le 26 ];then # train with multi-gpu + cmd="${python} -m paddle.distributed.launch --gpus=${gpu} ${run_train} ${set_use_gpu} ${set_save_model} ${set_epoch} ${set_pretrain} ${set_autocast} ${set_batchsize} ${set_train_params1}" + else # train with multi-machine + cmd="${python} -m paddle.distributed.launch --ips=${ips} --gpus=${gpu} ${run_train} ${set_use_gpu} ${set_save_model} ${set_pretrain} ${set_epoch} ${set_autocast} ${set_batchsize} ${set_train_params1}" + fi + # run train + eval "unset CUDA_VISIBLE_DEVICES" + export FLAGS_cudnn_deterministic=True + sleep 5 + eval $cmd + status_check $? "${cmd}" "${status_log}" + sleep 5 + + if [[ $FILENAME == *GeneralRecognition* ]]; then + set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/RecModel/${train_model_name}") + else + set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${model_name}/${train_model_name}") + fi + # save norm trained models to set pretrain for pact training and fpgm training + if [ ${trainer} = ${trainer_norm} ]; then + load_norm_train_model=${set_eval_pretrain} + fi + # run eval + if [ ${eval_py} != "null" ]; then + set_eval_params1=$(func_set_params "${eval_key1}" "${eval_value1}") + eval_cmd="${python} ${eval_py} ${set_eval_pretrain} ${set_use_gpu} ${set_eval_params1}" + eval $eval_cmd + status_check $? "${eval_cmd}" "${status_log}" + sleep 5 + fi + # run export model + if [ ${run_export} != "null" ]; then + # run export model + save_infer_path="${save_log}" + if [[ $FILENAME == *GeneralRecognition* ]]; then + set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/RecModel/${train_model_name}") + else + set_export_weight=$(func_set_params "${export_weight}" "${save_log}/${model_name}/${train_model_name}") + fi + set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_path}") + export_cmd="${python} ${run_export} ${set_export_weight} ${set_save_infer_key}" + eval $export_cmd + status_check $? "${export_cmd}" "${status_log}" + + #run inference + eval $env + save_infer_path="${save_log}" + cd deploy + func_inference "${python}" "${inference_py}" "../${save_infer_path}" "../${LOG_PATH}" "${infer_img_dir}" "${flag_quant}" + cd .. + fi + eval "unset CUDA_VISIBLE_DEVICES" + done # done with: for trainer in ${trainer_list[*]}; do + done # done with: for autocast in ${autocast_list[*]}; do + done # done with: for gpu in ${gpu_list[*]}; do +fi # end if [ ${MODE} = "infer" ]; then diff --git a/src/PaddleClas/tests/README.md b/src/PaddleClas/tests/README.md new file mode 100644 index 0000000..55b3690 --- /dev/null +++ b/src/PaddleClas/tests/README.md @@ -0,0 +1,70 @@ + +# 从训练到推理部署工具链测试方法介绍 + +test.sh和config文件夹下的txt文件配合使用,完成Clas模型从训练到预测的流程测试。 + +# 安装依赖 +- 安装PaddlePaddle >= 2.0 +- 安装PaddleClass依赖 + ``` + pip3 install -r ../requirements.txt + ``` +- 安装autolog + ``` + git clone https://github.com/LDOUBLEV/AutoLog + cd AutoLog + pip3 install -r requirements.txt + python3 setup.py bdist_wheel + pip3 install ./dist/auto_log-1.0.0-py3-none-any.whl + cd ../ + ``` + +# 目录介绍 + +```bash +tests/ +├── config # 测试模型的参数配置文件 +| |--- *.txt +└── prepare.sh # 完成test.sh运行所需要的数据和模型下载 +└── test.sh # 测试主程序 +``` + +# 使用方法 + +test.sh包四种运行模式,每种模式的运行数据不同,分别用于测试速度和精度,分别是: + +- 模式1:lite_train_infer,使用少量数据训练,用于快速验证训练到预测的走通流程,不验证精度和速度; +```shell +bash tests/prepare.sh ./tests/config/ResNet50_vd.txt 'lite_train_infer' +bash tests/test.sh ./tests/config/ResNet50_vd.txt 'lite_train_infer' +``` + +- 模式2:whole_infer,使用少量数据训练,一定量数据预测,用于验证训练后的模型执行预测,预测速度是否合理; +```shell +bash tests/prepare.sh ./tests/config/ResNet50_vd.txt 'whole_infer' +bash tests/test.sh ./tests/config/ResNet50_vd.txt 'whole_infer' +``` + +- 模式3:infer 不训练,全量数据预测,走通开源模型评估、动转静,检查inference model预测时间和精度; +```shell +bash tests/prepare.sh ./tests/config/ResNet50_vd.txt 'infer' +# 用法1: +bash tests/test.sh ./tests/config/ResNet50_vd.txt 'infer' +``` + +需注意的是,模型的离线量化需使用`infer`模式进行测试 + +- 模式4:whole_train_infer , CE: 全量数据训练,全量数据预测,验证模型训练精度,预测精度,预测速度; +```shell +bash tests/prepare.sh ./tests/config/ResNet50_vd.txt 'whole_train_infer' +bash tests/test.sh ./tests/config/ResNet50_vd.txt 'whole_train_infer' +``` + +- 模式5:cpp_infer , CE: 验证inference model的c++预测是否走通; +```shell +bash tests/prepare.sh ./tests/config/ResNet50_vd.txt 'cpp_infer' +bash tests/test.sh ./tests/config/ResNet50_vd.txt 'cpp_infer' +``` + +# 日志输出 +最终在```tests/output```目录下生成.log后缀的日志文件 diff --git a/src/PaddleClas/tests/config/DarkNet53.txt b/src/PaddleClas/tests/config/DarkNet53.txt new file mode 100644 index 0000000..9b9b95c --- /dev/null +++ b/src/PaddleClas/tests/config/DarkNet53.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:DarkNet53 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/DarkNet/DarkNet53.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +infer_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/DarkNet53_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/GhostNet_x0_5.txt b/src/PaddleClas/tests/config/GhostNet_x0_5.txt new file mode 100644 index 0000000..b752da4 --- /dev/null +++ b/src/PaddleClas/tests/config/GhostNet_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:GhostNet_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/GhostNet_x1_0.txt b/src/PaddleClas/tests/config/GhostNet_x1_0.txt new file mode 100644 index 0000000..c927b2b --- /dev/null +++ b/src/PaddleClas/tests/config/GhostNet_x1_0.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:GhostNet_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/GhostNet_x1_3.txt b/src/PaddleClas/tests/config/GhostNet_x1_3.txt new file mode 100644 index 0000000..5766332 --- /dev/null +++ b/src/PaddleClas/tests/config/GhostNet_x1_3.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:GhostNet_x1_3 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/GhostNet/GhostNet_x1_3.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/GhostNet_x1_3_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/HRNet_W18_C.txt b/src/PaddleClas/tests/config/HRNet_W18_C.txt new file mode 100644 index 0000000..c5334e3 --- /dev/null +++ b/src/PaddleClas/tests/config/HRNet_W18_C.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:HRNet_W18_C +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/HRNet/HRNet_W18_C.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/HRNet_W18_C_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/LeViT_128S.txt b/src/PaddleClas/tests/config/LeViT_128S.txt new file mode 100644 index 0000000..6ddc0cd --- /dev/null +++ b/src/PaddleClas/tests/config/LeViT_128S.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:LeViT_128S +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/LeViT/LeViT_128S.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +infer_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/LeViT_128S_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|Fasle +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV1.txt b/src/PaddleClas/tests/config/MobileNetV1.txt new file mode 100644 index 0000000..319f852 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV1.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV1 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/MobileNetV1_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV1_x0_25.txt b/src/PaddleClas/tests/config/MobileNetV1_x0_25.txt new file mode 100644 index 0000000..a46a8e3 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV1_x0_25.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV1_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV1_x0_5.txt b/src/PaddleClas/tests/config/MobileNetV1_x0_5.txt new file mode 100644 index 0000000..bca197b --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV1_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV1_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV1_x0_75.txt b/src/PaddleClas/tests/config/MobileNetV1_x0_75.txt new file mode 100644 index 0000000..ba81e35 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV1_x0_75.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV1_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV1/MobileNetV1_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV1_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV2.txt b/src/PaddleClas/tests/config/MobileNetV2.txt new file mode 100644 index 0000000..d4cf3fc --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV2.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV2 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +infer_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/MobileNetV2_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV2_x0_25.txt b/src/PaddleClas/tests/config/MobileNetV2_x0_25.txt new file mode 100644 index 0000000..5368aef --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV2_x0_25.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV2_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV2_x0_5.txt b/src/PaddleClas/tests/config/MobileNetV2_x0_5.txt new file mode 100644 index 0000000..ba35c3a --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV2_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV2_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV2_x0_75.txt b/src/PaddleClas/tests/config/MobileNetV2_x0_75.txt new file mode 100644 index 0000000..0f5a8ab --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV2_x0_75.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV2_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV2_x1_5.txt b/src/PaddleClas/tests/config/MobileNetV2_x1_5.txt new file mode 100644 index 0000000..55da65b --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV2_x1_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV2_x1_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x1_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x1_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV2_x2_0.txt b/src/PaddleClas/tests/config/MobileNetV2_x2_0.txt new file mode 100644 index 0000000..cd32244 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV2_x2_0.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV2_x2_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV2/MobileNetV2_x2_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV2_x2_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_large_x0_35.txt b/src/PaddleClas/tests/config/MobileNetV3_large_x0_35.txt new file mode 100644 index 0000000..bc6e77c --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_large_x0_35.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x0_35 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_35.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_35_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_large_x0_5.txt b/src/PaddleClas/tests/config/MobileNetV3_large_x0_5.txt new file mode 100644 index 0000000..693423d --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_large_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_large_x0_75.txt b/src/PaddleClas/tests/config/MobileNetV3_large_x0_75.txt new file mode 100644 index 0000000..24b35de --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_large_x0_75.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_large_x1_0.txt b/src/PaddleClas/tests/config/MobileNetV3_large_x1_0.txt new file mode 100644 index 0000000..873072f --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_large_x1_0.txt @@ -0,0 +1,58 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/MobileNetV3_large_x1_0_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml -o Global.save_inference_dir=./inference +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/MobileNetV3_large_x1_0_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null +===========================cpp_infer_params=========================== +use_gpu:0|1 +cpu_threads:1|6 +use_mkldnn:0|1 +use_tensorrt:0|1 +use_fp16:0|1 diff --git a/src/PaddleClas/tests/config/MobileNetV3_large_x1_25.txt b/src/PaddleClas/tests/config/MobileNetV3_large_x1_25.txt new file mode 100644 index 0000000..34057be --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_large_x1_25.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_large_x1_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_large_x1_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_small_x0_35.txt b/src/PaddleClas/tests/config/MobileNetV3_small_x0_35.txt new file mode 100644 index 0000000..0f8b75e --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_small_x0_35.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x0_35 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_35.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_35_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_small_x0_5.txt b/src/PaddleClas/tests/config/MobileNetV3_small_x0_5.txt new file mode 100644 index 0000000..0693c08 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_small_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_small_x0_75.txt b/src/PaddleClas/tests/config/MobileNetV3_small_x0_75.txt new file mode 100644 index 0000000..ce42427 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_small_x0_75.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x0_75 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x0_75.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x0_75_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_small_x1_0.txt b/src/PaddleClas/tests/config/MobileNetV3_small_x1_0.txt new file mode 100644 index 0000000..a1f2b8b --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_small_x1_0.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/MobileNetV3_small_x1_25.txt b/src/PaddleClas/tests/config/MobileNetV3_small_x1_25.txt new file mode 100644 index 0000000..49831b6 --- /dev/null +++ b/src/PaddleClas/tests/config/MobileNetV3_small_x1_25.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:MobileNetV3_small_x1_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/MobileNetV3_small_x1_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/PPLCNet_x0_25.txt b/src/PaddleClas/tests/config/PPLCNet_x0_25.txt new file mode 100644 index 0000000..0777cfa --- /dev/null +++ b/src/PaddleClas/tests/config/PPLCNet_x0_25.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/PPLCNet_x0_35.txt b/src/PaddleClas/tests/config/PPLCNet_x0_35.txt new file mode 100644 index 0000000..0ce679e --- /dev/null +++ b/src/PaddleClas/tests/config/PPLCNet_x0_35.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_35 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_35.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_35_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/PPLCNet_x0_5.txt b/src/PaddleClas/tests/config/PPLCNet_x0_5.txt new file mode 100644 index 0000000..fbee882 --- /dev/null +++ b/src/PaddleClas/tests/config/PPLCNet_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/PPLCNet_x1_0.txt b/src/PaddleClas/tests/config/PPLCNet_x1_0.txt new file mode 100644 index 0000000..1e99116 --- /dev/null +++ b/src/PaddleClas/tests/config/PPLCNet_x1_0.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:PPLCNet_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/legendary_models/PPLCNet_x1_0_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/ResNeXt101_vd_64x4d.txt b/src/PaddleClas/tests/config/ResNeXt101_vd_64x4d.txt new file mode 100644 index 0000000..aab18d5 --- /dev/null +++ b/src/PaddleClas/tests/config/ResNeXt101_vd_64x4d.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:ResNeXt101_vd_64x4d +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNeXt/ResNeXt101_vd_64x4d.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/ResNeXt101_64x4d_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/ResNet50_vd.txt b/src/PaddleClas/tests/config/ResNet50_vd.txt new file mode 100644 index 0000000..ed70608 --- /dev/null +++ b/src/PaddleClas/tests/config/ResNet50_vd.txt @@ -0,0 +1,58 @@ +===========================train_params=========================== +model_name:ResNet50_vd +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train|pact_train|fpgm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +fpgm_train:tools/train.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml +quant_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_quantization.yaml +fpgm_export:tools/export_model.py -c ppcls/configs/slim/ResNet50_vd_prune.yaml +distill_export:null +kl_quant:deploy/slim/quant_post_static.py -c ppcls/configs/ImageNet/ResNet/ResNet50_vd.yaml -o Global.save_inference_dir=./inference +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/ResNet50_vd_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null +null:null +===========================cpp_infer_params=========================== +use_gpu:0|1 +cpu_threads:1|6 +use_mkldnn:0|1 +use_tensorrt:0|1 +use_fp16:0|1 diff --git a/src/PaddleClas/tests/config/ShuffleNetV2_x0_25.txt b/src/PaddleClas/tests/config/ShuffleNetV2_x0_25.txt new file mode 100644 index 0000000..1c80e4f --- /dev/null +++ b/src/PaddleClas/tests/config/ShuffleNetV2_x0_25.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x0_25 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_25.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_25_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/ShuffleNetV2_x0_33.txt b/src/PaddleClas/tests/config/ShuffleNetV2_x0_33.txt new file mode 100644 index 0000000..34e813f --- /dev/null +++ b/src/PaddleClas/tests/config/ShuffleNetV2_x0_33.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x0_33 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_33.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_33_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/ShuffleNetV2_x0_5.txt b/src/PaddleClas/tests/config/ShuffleNetV2_x0_5.txt new file mode 100644 index 0000000..b918a78 --- /dev/null +++ b/src/PaddleClas/tests/config/ShuffleNetV2_x0_5.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x0_5 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x0_5.yaml +quant_export:null +fpgm_export:null +distill_export:null +kl_quant:null +export2:null +pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ShuffleNetV2_x0_5_pretrained.pdparams +infer_model:../inference/ +infer_export:True +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/ShuffleNetV2_x1_0.txt b/src/PaddleClas/tests/config/ShuffleNetV2_x1_0.txt new file mode 100644 index 0000000..1055910 --- /dev/null +++ b/src/PaddleClas/tests/config/ShuffleNetV2_x1_0.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:ShuffleNetV2_x1_0 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/ShuffleNet/ShuffleNetV2_x1_0.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/ShuffleNetV2_x1_0_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/SwinTransformer_tiny_patch4_window7_224.txt b/src/PaddleClas/tests/config/SwinTransformer_tiny_patch4_window7_224.txt new file mode 100644 index 0000000..94acb15 --- /dev/null +++ b/src/PaddleClas/tests/config/SwinTransformer_tiny_patch4_window7_224.txt @@ -0,0 +1,51 @@ +===========================train_params=========================== +model_name:SwinTransformer_tiny_patch4_window7_224 +python:python3.7 +gpu_list:0|0,1 +-o Global.device:gpu +-o Global.auto_cast:null +-o Global.epochs:lite_train_infer=2|whole_train_infer=120 +-o Global.output_dir:./output/ +-o DataLoader.Train.sampler.batch_size:8 +-o Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./dataset/ILSVRC2012/val +null:null +## +trainer:norm_train +norm_train:tools/train.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml +null:null +## +===========================infer_params========================== +-o Global.save_inference_dir:./inference +-o Global.pretrained_model: +norm_export:tools/export_model.py -c ppcls/configs/ImageNet/SwinTransformer/SwinTransformer_tiny_patch4_window7_224.yaml +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/whole_chain/SwinTransformer_tiny_patch4_window7_224_inference.tar +infer_model:../inference/ +infer_export:null +infer_quant:Fasle +inference:python/predict_cls.py -c configs/inference_cls.yaml +-o Global.use_gpu:True|False +-o Global.enable_mkldnn:True|False +-o Global.cpu_num_threads:1|6 +-o Global.batch_size:1|16 +-o Global.use_tensorrt:True|False +-o Global.use_fp16:True|False +-o Global.inference_model_dir:../inference +-o Global.infer_imgs:../dataset/ILSVRC2012/val +-o Global.save_log_path:null +-o Global.benchmark:True +null:null diff --git a/src/PaddleClas/tests/config/cpp_config.txt b/src/PaddleClas/tests/config/cpp_config.txt new file mode 100644 index 0000000..2f12864 --- /dev/null +++ b/src/PaddleClas/tests/config/cpp_config.txt @@ -0,0 +1,19 @@ +# model load config +gpu_id 0 +gpu_mem 2000 + +# whole chain test will add following config +# use_gpu 0 +# cpu_threads 10 +# use_mkldnn 1 +# use_tensorrt 0 +# use_fp16 0 + +# cls config +cls_model_path ../inference/inference.pdmodel +cls_params_path ../inference/inference.pdiparams +resize_short_size 256 +crop_size 224 + +# for log env info +benchmark 1 diff --git a/src/PaddleClas/tests/prepare.sh b/src/PaddleClas/tests/prepare.sh new file mode 100644 index 0000000..57e9a94 --- /dev/null +++ b/src/PaddleClas/tests/prepare.sh @@ -0,0 +1,137 @@ +#!/bin/bash +FILENAME=$1 +# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer'] +MODE=$2 + +dataline=$(cat ${FILENAME}) +# parser params +IFS=$'\n' +lines=(${dataline}) + +function func_parser_key(){ + strs=$1 + IFS=":" + array=(${strs}) + tmp=${array[0]} + echo ${tmp} +} + +function func_parser_value(){ + strs=$1 + IFS=":" + array=(${strs}) + if [ ${#array[*]} = 2 ]; then + echo ${array[1]} + else + IFS="|" + tmp="${array[1]}:${array[2]}" + echo ${tmp} + fi +} +model_name=$(func_parser_value "${lines[1]}") +model_url_value=$(func_parser_value "${lines[35]}") +model_url_key=$(func_parser_key "${lines[35]}") + +if [ ${MODE} = "lite_train_infer" ] || [ ${MODE} = "whole_infer" ];then + # pretrain lite train data + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_little_train.tar + tar xf whole_chain_little_train.tar + ln -s whole_chain_little_train ILSVRC2012 + cd ILSVRC2012 + mv train.txt train_list.txt + mv val.txt val_list.txt + if [ ${MODE} = "lite_train_infer" ];then + cp -r train/* val/ + fi + cd ../../ +elif [ ${MODE} = "infer" ] || [ ${MODE} = "cpp_infer" ];then + # download data + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_infer.tar + tar xf whole_chain_infer.tar + ln -s whole_chain_infer ILSVRC2012 + cd ILSVRC2012 + mv val.txt val_list.txt + ln -s val_list.txt train_list.txt + cd ../../ + # download inference or pretrained model + eval "wget -nc $model_url_value" + if [[ $model_url_key == *inference* ]]; then + rm -rf inference + tar xf "${model_name}_inference.tar" + fi + +elif [ ${MODE} = "whole_train_infer" ];then + cd dataset + rm -rf ILSVRC2012 + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar + tar xf whole_chain_CIFAR100.tar + ln -s whole_chain_CIFAR100 ILSVRC2012 + cd ILSVRC2012 + mv train.txt train_list.txt + mv val.txt val_list.txt + cd ../../ +fi + +if [ ${MODE} = "cpp_infer" ];then + cd deploy/cpp + echo "################### build opencv ###################" + rm -rf 3.4.7.tar.gz opencv-3.4.7/ + wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz + tar -xf 3.4.7.tar.gz + install_path=$(pwd)/opencv-3.4.7/opencv3 + cd opencv-3.4.7/ + + rm -rf build + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + make -j + make install + cd ../../ + echo "################### build opencv finished ###################" + + echo "################### build PaddleClas demo ####################" + OPENCV_DIR=$(pwd)/opencv-3.4.7/opencv3/ + LIB_DIR=$(pwd)/Paddle/build/paddle_inference_install_dir/ + CUDA_LIB_DIR=$(dirname `find /usr -name libcudart.so`) + CUDNN_LIB_DIR=$(dirname `find /usr -name libcudnn.so`) + + BUILD_DIR=build + rm -rf ${BUILD_DIR} + mkdir ${BUILD_DIR} + cd ${BUILD_DIR} + cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DDEMO_NAME=clas_system \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DTENSORRT_DIR=${TENSORRT_DIR} \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + + make -j + echo "################### build PaddleClas demo finished ###################" +fi diff --git a/src/PaddleClas/tests/test.sh b/src/PaddleClas/tests/test.sh new file mode 100644 index 0000000..56af96a --- /dev/null +++ b/src/PaddleClas/tests/test.sh @@ -0,0 +1,448 @@ +#!/bin/bash +FILENAME=$1 +# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer', 'cpp_infer'] +MODE=$2 + +dataline=$(cat ${FILENAME}) + +# parser params +IFS=$'\n' +lines=(${dataline}) + +function func_parser_key(){ + strs=$1 + IFS=":" + array=(${strs}) + tmp=${array[0]} + echo ${tmp} +} +function func_parser_value(){ + strs=$1 + IFS=":" + array=(${strs}) + tmp=${array[1]} + echo ${tmp} +} +function func_set_params(){ + key=$1 + value=$2 + if [ ${key} = "null" ];then + echo " " + elif [[ ${value} = "null" ]] || [[ ${value} = " " ]] || [ ${#value} -le 0 ];then + echo " " + else + echo "${key}=${value}" + fi +} +function func_parser_params(){ + strs=$1 + IFS=":" + array=(${strs}) + key=${array[0]} + tmp=${array[1]} + IFS="|" + res="" + for _params in ${tmp[*]}; do + IFS="=" + array=(${_params}) + mode=${array[0]} + value=${array[1]} + if [[ ${mode} = ${MODE} ]]; then + IFS="|" + #echo $(func_set_params "${mode}" "${value}") + echo $value + break + fi + IFS="|" + done + echo ${res} +} +function status_check(){ + last_status=$1 # the exit code + run_command=$2 + run_log=$3 + if [ $last_status -eq 0 ]; then + echo -e "\033[33m Run successfully with command - ${run_command}! \033[0m" | tee -a ${run_log} + else + echo -e "\033[33m Run failed with command - ${run_command}! \033[0m" | tee -a ${run_log} + fi +} + +IFS=$'\n' +# The training params +model_name=$(func_parser_value "${lines[1]}") +python=$(func_parser_value "${lines[2]}") +gpu_list=$(func_parser_value "${lines[3]}") +train_use_gpu_key=$(func_parser_key "${lines[4]}") +train_use_gpu_value=$(func_parser_value "${lines[4]}") +autocast_list=$(func_parser_value "${lines[5]}") +autocast_key=$(func_parser_key "${lines[5]}") +epoch_key=$(func_parser_key "${lines[6]}") +epoch_num=$(func_parser_params "${lines[6]}") +save_model_key=$(func_parser_key "${lines[7]}") +train_batch_key=$(func_parser_key "${lines[8]}") +train_batch_value=$(func_parser_params "${lines[8]}") +pretrain_model_key=$(func_parser_key "${lines[9]}") +pretrain_model_value=$(func_parser_value "${lines[9]}") +train_model_name=$(func_parser_value "${lines[10]}") +train_infer_img_dir=$(func_parser_value "${lines[11]}") +train_param_key1=$(func_parser_key "${lines[12]}") +train_param_value1=$(func_parser_value "${lines[12]}") + +trainer_list=$(func_parser_value "${lines[14]}") +trainer_norm=$(func_parser_key "${lines[15]}") +norm_trainer=$(func_parser_value "${lines[15]}") +pact_key=$(func_parser_key "${lines[16]}") +pact_trainer=$(func_parser_value "${lines[16]}") +fpgm_key=$(func_parser_key "${lines[17]}") +fpgm_trainer=$(func_parser_value "${lines[17]}") +distill_key=$(func_parser_key "${lines[18]}") +distill_trainer=$(func_parser_value "${lines[18]}") +trainer_key1=$(func_parser_key "${lines[19]}") +trainer_value1=$(func_parser_value "${lines[19]}") +trainer_key2=$(func_parser_key "${lines[20]}") +trainer_value2=$(func_parser_value "${lines[20]}") + +eval_py=$(func_parser_value "${lines[23]}") +eval_key1=$(func_parser_key "${lines[24]}") +eval_value1=$(func_parser_value "${lines[24]}") + +save_infer_key=$(func_parser_key "${lines[27]}") +export_weight=$(func_parser_key "${lines[28]}") +norm_export=$(func_parser_value "${lines[29]}") +pact_export=$(func_parser_value "${lines[30]}") +fpgm_export=$(func_parser_value "${lines[31]}") +distill_export=$(func_parser_value "${lines[32]}") +kl_quant_cmd_key=$(func_parser_key "${lines[33]}") +kl_quant_cmd_value=$(func_parser_value "${lines[33]}") +export_key2=$(func_parser_key "${lines[34]}") +export_value2=$(func_parser_value "${lines[34]}") + +# parser inference model +infer_model_dir_list=$(func_parser_value "${lines[36]}") +infer_export_flag=$(func_parser_value "${lines[37]}") +infer_is_quant=$(func_parser_value "${lines[38]}") +# parser inference +inference_py=$(func_parser_value "${lines[39]}") +use_gpu_key=$(func_parser_key "${lines[40]}") +use_gpu_list=$(func_parser_value "${lines[40]}") +use_mkldnn_key=$(func_parser_key "${lines[41]}") +use_mkldnn_list=$(func_parser_value "${lines[41]}") +cpu_threads_key=$(func_parser_key "${lines[42]}") +cpu_threads_list=$(func_parser_value "${lines[42]}") +batch_size_key=$(func_parser_key "${lines[43]}") +batch_size_list=$(func_parser_value "${lines[43]}") +use_trt_key=$(func_parser_key "${lines[44]}") +use_trt_list=$(func_parser_value "${lines[44]}") +precision_key=$(func_parser_key "${lines[45]}") +precision_list=$(func_parser_value "${lines[45]}") +infer_model_key=$(func_parser_key "${lines[46]}") +image_dir_key=$(func_parser_key "${lines[47]}") +infer_img_dir=$(func_parser_value "${lines[47]}") +save_log_key=$(func_parser_key "${lines[48]}") +benchmark_key=$(func_parser_key "${lines[49]}") +benchmark_value=$(func_parser_value "${lines[49]}") +infer_key1=$(func_parser_key "${lines[50]}") +infer_value1=$(func_parser_value "${lines[50]}") + +if [ ${MODE} = "cpp_infer" ]; then + cpp_use_gpu_key=$(func_parser_key "${lines[53]}") + cpp_use_gpu_list=$(func_parser_value "${lines[53]}") + cpp_cpu_threads_key=$(func_parser_key "${lines[54]}") + cpp_cpu_threads_list=$(func_parser_value "${lines[54]}") + cpp_use_mkldnn_key=$(func_parser_key "${lines[55]}") + cpp_use_mkldnn_list=$(func_parser_value "${lines[55]}") + cpp_use_tensorrt_key=$(func_parser_key "${lines[56]}") + cpp_use_tensorrt_list=$(func_parser_value "${lines[56]}") + cpp_use_fp16_key=$(func_parser_key "${lines[57]}") + cpp_use_fp16_list=$(func_parser_value "${lines[57]}") +fi + +LOG_PATH="./tests/output" +mkdir -p ${LOG_PATH} +status_log="${LOG_PATH}/results.log" + +function func_cpp_inference(){ + IFS='|' + _script=$1 + _log_path=$2 + _img_dir=$3 + # inference + for use_gpu in ${cpp_use_gpu_list[*]}; do + if [ ${use_gpu} = "0" ] || [ ${use_gpu} = "cpu" ]; then + for use_mkldnn in ${cpp_use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "0" ] && [ ${_flag_quant} = "True" ]; then + continue + fi + for threads in ${cpp_cpu_threads_list[*]}; do + _save_log_path="${_log_path}/cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}.log" + set_infer_data=$(func_set_params "${cpp_image_dir_key}" "${_img_dir}") + cp ../tests/config/cpp_config.txt cpp_config.txt + echo "${cpp_use_gpu_key} ${use_gpu}" >> cpp_config.txt + echo "${cpp_cpu_threads_key} ${threads}" >> cpp_config.txt + echo "${cpp_use_mkldnn_key} ${use_mkldnn}" >> cpp_config.txt + echo "${cpp_use_tensorrt_key} 0" >> cpp_config.txt + echo "${cpp_use_fp16_key} 0" >> cpp_config.txt + command="${_script} cpp_config.txt ${_img_dir} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "${status_log}" + done + done + elif [ ${use_gpu} = "1" ] || [ ${use_gpu} = "gpu" ]; then + for use_trt in ${cpp_use_tensorrt_list[*]}; do + for precision in ${cpp_use_fp16_list[*]}; do + if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then + continue + fi + _save_log_path="${_log_path}/cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + cp ../tests/config/cpp_config.txt cpp_config.txt + echo "${cpp_use_gpu_key} ${use_gpu}" >> cpp_config.txt + echo "${cpp_cpu_threads_key} ${threads}" >> cpp_config.txt + echo "${cpp_use_mkldnn_key} ${use_mkldnn}" >> cpp_config.txt + echo "${cpp_use_tensorrt_key} ${use_trt}" >> cpp_config.txt + echo "${cpp_use_fp16_key} ${precision}" >> cpp_config.txt + command="${_script} cpp_config.txt ${_img_dir} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "${status_log}" + + done + done + else + echo "Does not support hardware other than CPU and GPU Currently!" + fi + done +} + +function func_inference(){ + IFS='|' + _python=$1 + _script=$2 + _model_dir=$3 + _log_path=$4 + _img_dir=$5 + _flag_quant=$6 + # inference + for use_gpu in ${use_gpu_list[*]}; do + if [ ${use_gpu} = "False" ] || [ ${use_gpu} = "cpu" ]; then + for use_mkldnn in ${use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + continue + fi + for threads in ${cpu_threads_list[*]}; do + for batch_size in ${batch_size_list[*]}; do + _save_log_path="${_log_path}/infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_batchsize_${batch_size}.log" + set_infer_data=$(func_set_params "${image_dir_key}" "${_img_dir}") + set_benchmark=$(func_set_params "${benchmark_key}" "${benchmark_value}") + set_batchsize=$(func_set_params "${batch_size_key}" "${batch_size}") + set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}") + set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}") + set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}") + command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "../${status_log}" + done + done + done + elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then + for use_trt in ${use_trt_list[*]}; do + for precision in ${precision_list[*]}; do + if [ ${precision} = "True" ] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then + continue + fi + for batch_size in ${batch_size_list[*]}; do + _save_log_path="${_log_path}/infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + set_infer_data=$(func_set_params "${image_dir_key}" "${_img_dir}") + set_benchmark=$(func_set_params "${benchmark_key}" "${benchmark_value}") + set_batchsize=$(func_set_params "${batch_size_key}" "${batch_size}") + set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}") + set_precision=$(func_set_params "${precision_key}" "${precision}") + set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}") + command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "../${status_log}" + + done + done + done + else + echo "Does not support hardware other than CPU and GPU Currently!" + fi + done +} + +if [ ${MODE} = "infer" ]; then + GPUID=$3 + if [ ${#GPUID} -le 0 ];then + env=" " + else + env="export CUDA_VISIBLE_DEVICES=${GPUID}" + fi + # set CUDA_VISIBLE_DEVICES + eval $env + export Count=0 + IFS="|" + infer_export_flag=(${infer_export_flag}) + infer_quant_flag=(${infer_is_quant}) + if [ ${infer_export_flag} != "null" ] && [ ${infer_export_flag} != "False" ]; then + rm -rf ${infer_model_dir_list/..\//} + export_cmd="${python} ${norm_export} -o Global.pretrained_model=${model_name}_pretrained -o Global.save_inference_dir=${infer_model_dir_list/..\//}" + eval $export_cmd + fi + cd deploy + for infer_model in ${infer_model_dir_list[*]}; do + #run inference + is_quant=${infer_quant_flag[Count]} + echo "is_quant: ${is_quant}" + func_inference "${python}" "${inference_py}" "${infer_model}" "../${LOG_PATH}" "${infer_img_dir}" ${is_quant} + Count=$(($Count + 1)) + done + cd .. + + # for kl_quant + if [ ${kl_quant_cmd_value} != "null" ] && [ ${kl_quant_cmd_value} != "False" ]; then + echo "kl_quant" + command="${python} ${kl_quant_cmd_value}" + eval $command + last_status=${PIPESTATUS[0]} + status_check $last_status "${command}" "${status_log}" + cd inference/quant_post_static_model + ln -s __model__ inference.pdmodel + ln -s __params__ inference.pdiparams + cd ../../deploy + is_quant=True + func_inference "${python}" "${inference_py}" "${infer_model}/quant_post_static_model" "../${LOG_PATH}" "${infer_img_dir}" ${is_quant} + cd .. + fi +elif [ ${MODE} = "cpp_infer" ]; then + cd deploy + func_cpp_inference "./cpp/build/clas_system" "../${LOG_PATH}" "${infer_img_dir}" + cd .. + +else + IFS="|" + export Count=0 + USE_GPU_KEY=(${train_use_gpu_value}) + for gpu in ${gpu_list[*]}; do + use_gpu=${USE_GPU_KEY[Count]} + Count=$(($Count + 1)) + if [ ${gpu} = "-1" ];then + env="" + elif [ ${#gpu} -le 1 ];then + env="export CUDA_VISIBLE_DEVICES=${gpu}" + eval ${env} + elif [ ${#gpu} -le 15 ];then + IFS="," + array=(${gpu}) + env="export CUDA_VISIBLE_DEVICES=${array[0]}" + IFS="|" + else + IFS=";" + array=(${gpu}) + ips=${array[0]} + gpu=${array[1]} + IFS="|" + env=" " + fi + for autocast in ${autocast_list[*]}; do + for trainer in ${trainer_list[*]}; do + flag_quant=False + if [ ${trainer} = ${pact_key} ]; then + run_train=${pact_trainer} + run_export=${pact_export} + flag_quant=True + elif [ ${trainer} = "${fpgm_key}" ]; then + run_train=${fpgm_trainer} + run_export=${fpgm_export} + elif [ ${trainer} = "${distill_key}" ]; then + run_train=${distill_trainer} + run_export=${distill_export} + elif [ ${trainer} = ${trainer_key1} ]; then + run_train=${trainer_value1} + run_export=${export_value1} + elif [[ ${trainer} = ${trainer_key2} ]]; then + run_train=${trainer_value2} + run_export=${export_value2} + else + run_train=${norm_trainer} + run_export=${norm_export} + fi + + if [ ${run_train} = "null" ]; then + continue + fi + + set_autocast=$(func_set_params "${autocast_key}" "${autocast}") + set_epoch=$(func_set_params "${epoch_key}" "${epoch_num}") + set_pretrain=$(func_set_params "${pretrain_model_key}" "${pretrain_model_value}") + set_batchsize=$(func_set_params "${train_batch_key}" "${train_batch_value}") + set_train_params1=$(func_set_params "${train_param_key1}" "${train_param_value1}") + set_use_gpu=$(func_set_params "${train_use_gpu_key}" "${train_use_gpu_value}") + save_log="${LOG_PATH}/${trainer}_gpus_${gpu}_autocast_${autocast}" + + # load pretrain from norm training if current trainer is pact or fpgm trainer + if [ ${trainer} = ${pact_key} ] || [ ${trainer} = ${fpgm_key} ]; then + set_pretrain="${load_norm_train_model}" + fi + + set_save_model=$(func_set_params "${save_model_key}" "${save_log}") + if [ ${#gpu} -le 2 ];then # train with cpu or single gpu + cmd="${python} ${run_train} ${set_use_gpu} ${set_save_model} ${set_epoch} ${set_pretrain} ${set_autocast} ${set_batchsize} ${set_train_params1} " + elif [ ${#gpu} -le 15 ];then # train with multi-gpu + cmd="${python} -m paddle.distributed.launch --gpus=${gpu} ${run_train} ${set_save_model} ${set_epoch} ${set_pretrain} ${set_autocast} ${set_batchsize} ${set_train_params1}" + else # train with multi-machine + cmd="${python} -m paddle.distributed.launch --ips=${ips} --gpus=${gpu} ${run_train} ${set_save_model} ${set_pretrain} ${set_epoch} ${set_autocast} ${set_batchsize} ${set_train_params1}" + fi + # run train + eval "unset CUDA_VISIBLE_DEVICES" + export FLAGS_cudnn_deterministic=True + eval $cmd + status_check $? "${cmd}" "${status_log}" + + set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${$model_name}/${train_model_name}") + # save norm trained models to set pretrain for pact training and fpgm training + if [ ${trainer} = ${trainer_norm} ]; then + load_norm_train_model=${set_eval_pretrain} + fi + # run eval + if [ ${eval_py} != "null" ]; then + set_eval_params1=$(func_set_params "${eval_key1}" "${eval_value1}") + eval_cmd="${python} ${eval_py} ${set_eval_pretrain} ${set_use_gpu} ${set_eval_params1}" + eval $eval_cmd + status_check $? "${eval_cmd}" "${status_log}" + fi + # run export model + if [ ${run_export} != "null" ]; then + # run export model + save_infer_path="${save_log}" + set_export_weight=$(func_set_params "${export_weight}" "${save_log}/${model_name}/${train_model_name}") + set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_path}") + export_cmd="${python} ${run_export} ${set_export_weight} ${set_save_infer_key}" + eval $export_cmd + status_check $? "${export_cmd}" "${status_log}" + + #run inference + eval $env + save_infer_path="${save_log}" + cd deploy + func_inference "${python}" "${inference_py}" "../${save_infer_path}" "../${LOG_PATH}" "${infer_img_dir}" "${flag_quant}" + cd .. + fi + eval "unset CUDA_VISIBLE_DEVICES" + done # done with: for trainer in ${trainer_list[*]}; do + done # done with: for autocast in ${autocast_list[*]}; do + done # done with: for gpu in ${gpu_list[*]}; do +fi # end if [ ${MODE} = "infer" ]; then diff --git a/src/PaddleClas/tools/.train.py.un~ b/src/PaddleClas/tools/.train.py.un~ new file mode 100644 index 0000000..1b2c290 Binary files /dev/null and b/src/PaddleClas/tools/.train.py.un~ differ diff --git a/src/PaddleClas/tools/__init__.py b/src/PaddleClas/tools/__init__.py new file mode 100644 index 0000000..cdefb80 --- /dev/null +++ b/src/PaddleClas/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/src/PaddleClas/tools/eval.py b/src/PaddleClas/tools/eval.py new file mode 100644 index 0000000..e086da1 --- /dev/null +++ b/src/PaddleClas/tools/eval.py @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +from ppcls.utils import config +from ppcls.engine.engine import Engine + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config( + args.config, overrides=args.override, show=False) + engine = Engine(config, mode="eval") + engine.eval() diff --git a/src/PaddleClas/tools/eval.sh b/src/PaddleClas/tools/eval.sh new file mode 100644 index 0000000..c13ea6d --- /dev/null +++ b/src/PaddleClas/tools/eval.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# for single card eval +# python3.7 tools/eval.py -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml + +# for multi-cards eval +python3.7 -m paddle.distributed.launch --gpus="0,1,2,3" tools/eval.py -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml diff --git a/src/PaddleClas/tools/export_model.py b/src/PaddleClas/tools/export_model.py new file mode 100644 index 0000000..01aba06 --- /dev/null +++ b/src/PaddleClas/tools/export_model.py @@ -0,0 +1,34 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +import paddle +import paddle.nn as nn + +from ppcls.utils import config +from ppcls.engine.engine import Engine + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config( + args.config, overrides=args.override, show=False) + engine = Engine(config, mode="export") + engine.export() diff --git a/src/PaddleClas/tools/infer.py b/src/PaddleClas/tools/infer.py new file mode 100644 index 0000000..4f6bf92 --- /dev/null +++ b/src/PaddleClas/tools/infer.py @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +from ppcls.utils import config +from ppcls.engine.engine import Engine + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config( + args.config, overrides=args.override, show=False) + engine = Engine(config, mode="infer") + engine.infer() diff --git a/src/PaddleClas/tools/train.py b/src/PaddleClas/tools/train.py new file mode 100644 index 0000000..e7c9d7b --- /dev/null +++ b/src/PaddleClas/tools/train.py @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import os +import sys +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(__dir__, '../'))) + +from ppcls.utils import config +from ppcls.engine.engine import Engine + +if __name__ == "__main__": + args = config.parse_args() + config = config.get_config( + args.config, overrides=args.override, show=False) + config.profiler_options = args.profiler_options + engine = Engine(config, mode="train") + engine.train() diff --git a/src/PaddleClas/tools/train.sh b/src/PaddleClas/tools/train.sh new file mode 100644 index 0000000..412f108 --- /dev/null +++ b/src/PaddleClas/tools/train.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# for single card train +# python3.7 tools/train.py -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml + +# for multi-cards train +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3.7 -m paddle.distributed.launch --gpus="0,1,2,3" tools/train.py -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml diff --git a/src/Search_2D/.idea/.gitignore b/src/Search_2D/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/src/Search_2D/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/src/Search_2D/.idea/Search_2D.iml b/src/Search_2D/.idea/Search_2D.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/src/Search_2D/.idea/Search_2D.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Search_2D/.idea/inspectionProfiles/Project_Default.xml b/src/Search_2D/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..6736707 --- /dev/null +++ b/src/Search_2D/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/src/Search_2D/.idea/inspectionProfiles/profiles_settings.xml b/src/Search_2D/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/src/Search_2D/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/src/Search_2D/.idea/misc.xml b/src/Search_2D/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/src/Search_2D/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Search_2D/.idea/modules.xml b/src/Search_2D/.idea/modules.xml new file mode 100644 index 0000000..01049a7 --- /dev/null +++ b/src/Search_2D/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Search_2D/ARAstar.py b/src/Search_2D/ARAstar.py new file mode 100644 index 0000000..c014616 --- /dev/null +++ b/src/Search_2D/ARAstar.py @@ -0,0 +1,222 @@ +""" +ARA_star 2D (Anytime Repairing A*) +@author: huiming zhou + +@description: local inconsistency: g-value decreased. +g(s) decreased introduces a local inconsistency between s and its successors. + +""" + +import os +import sys +import math + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env + + +class AraStar: + def __init__(self, s_start, s_goal, e, heuristic_type): + self.s_start, self.s_goal = s_start, s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() # class Env + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + self.e = e # weight + + self.g = dict() # Cost to come + self.OPEN = dict() # priority queue / OPEN set + self.CLOSED = set() # CLOSED set + self.INCONS = {} # INCONSISTENT set + self.PARENT = dict() # relations + self.path = [] # planning path + self.visited = [] # order of visited nodes + + def init(self): + """ + initialize each set. + """ + + self.g[self.s_start] = 0.0 + self.g[self.s_goal] = math.inf + self.OPEN[self.s_start] = self.f_value(self.s_start) + self.PARENT[self.s_start] = self.s_start + + def searching(self): + self.init() + self.ImprovePath() + self.path.append(self.extract_path()) + + while self.update_e() > 1: # continue condition + self.e -= 0.4 # increase weight + self.OPEN.update(self.INCONS) + self.OPEN = {s: self.f_value(s) for s in self.OPEN} # update f_value of OPEN set + + self.INCONS = dict() + self.CLOSED = set() + self.ImprovePath() # improve path + self.path.append(self.extract_path()) + + return self.path, self.visited + + def ImprovePath(self): + """ + :return: a e'-suboptimal path + """ + + visited_each = [] + + while True: + s, f_small = self.calc_smallest_f() + + if self.f_value(self.s_goal) <= f_small: + break + + self.OPEN.pop(s) + self.CLOSED.add(s) + + for s_n in self.get_neighbor(s): + if s_n in self.obs: + continue + + new_cost = self.g[s] + self.cost(s, s_n) + + if s_n not in self.g or new_cost < self.g[s_n]: + self.g[s_n] = new_cost + self.PARENT[s_n] = s + visited_each.append(s_n) + + if s_n not in self.CLOSED: + self.OPEN[s_n] = self.f_value(s_n) + else: + self.INCONS[s_n] = 0.0 + + self.visited.append(visited_each) + + def calc_smallest_f(self): + """ + :return: node with smallest f_value in OPEN set. + """ + + s_small = min(self.OPEN, key=self.OPEN.get) + + return s_small, self.OPEN[s_small] + + def get_neighbor(self, s): + """ + find neighbors of state s that not in obstacles. + :param s: state + :return: neighbors + """ + + return {(s[0] + u[0], s[1] + u[1]) for u in self.u_set} + + def update_e(self): + v = float("inf") + + if self.OPEN: + v = min(self.g[s] + self.h(s) for s in self.OPEN) + if self.INCONS: + v = min(v, min(self.g[s] + self.h(s) for s in self.INCONS)) + + return min(self.e, self.g[self.s_goal] / v) + + def f_value(self, x): + """ + f = g + e * h + f = cost-to-come + weight * cost-to-go + :param x: current state + :return: f_value + """ + + return self.g[x] + self.e * self.h(x) + + def extract_path(self): + """ + Extract the path based on the PARENT set. + :return: The planning path + """ + + path = [self.s_goal] + s = self.s_goal + + while True: + s = self.PARENT[s] + path.append(s) + + if s == self.s_start: + break + + return list(path) + + def h(self, s): + """ + Calculate heuristic. + :param s: current node (state) + :return: heuristic function value + """ + + heuristic_type = self.heuristic_type # heuristic type + goal = self.s_goal # goal node + + if heuristic_type == "manhattan": + return abs(goal[0] - s[0]) + abs(goal[1] - s[1]) + else: + return math.hypot(goal[0] - s[0], goal[1] - s[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return math.inf + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + """ + check if the line segment (s_start, s_end) is collision. + :param s_start: start node + :param s_end: end node + :return: True: is collision / False: not collision + """ + + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + arastar = AraStar(s_start, s_goal, 2.5, "euclidean") + plot = plotting.Plotting(s_start, s_goal) + + path, visited = arastar.searching() + plot.animation_ara_star(path, visited, "Anytime Repairing A* (ARA*)") + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/Anytime_D_star.py b/src/Search_2D/Anytime_D_star.py new file mode 100644 index 0000000..cd1d62b --- /dev/null +++ b/src/Search_2D/Anytime_D_star.py @@ -0,0 +1,317 @@ +""" +Anytime_D_star 2D +@author: huiming zhou +""" + +import os +import sys +import math +import matplotlib.pyplot as plt + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting +from Search_2D import env + + +class ADStar: + def __init__(self, s_start, s_goal, eps, heuristic_type): + self.s_start, self.s_goal = s_start, s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() # class Env + self.Plot = plotting.Plotting(s_start, s_goal) + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + self.x = self.Env.x_range + self.y = self.Env.y_range + + self.g, self.rhs, self.OPEN = {}, {}, {} + + for i in range(1, self.Env.x_range - 1): + for j in range(1, self.Env.y_range - 1): + self.rhs[(i, j)] = float("inf") + self.g[(i, j)] = float("inf") + + self.rhs[self.s_goal] = 0.0 + self.eps = eps + self.OPEN[self.s_goal] = self.Key(self.s_goal) + self.CLOSED, self.INCONS = set(), dict() + + self.visited = set() + self.count = 0 + self.count_env_change = 0 + self.obs_add = set() + self.obs_remove = set() + self.title = "Anytime D*: Small changes" # Significant changes + self.fig = plt.figure() + + def run(self): + self.Plot.plot_grid(self.title) + self.ComputeOrImprovePath() + self.plot_visited() + self.plot_path(self.extract_path()) + self.visited = set() + + while True: + if self.eps <= 1.0: + break + self.eps -= 0.5 + self.OPEN.update(self.INCONS) + for s in self.OPEN: + self.OPEN[s] = self.Key(s) + self.CLOSED = set() + self.ComputeOrImprovePath() + self.plot_visited() + self.plot_path(self.extract_path()) + self.visited = set() + plt.pause(0.5) + + self.fig.canvas.mpl_connect('button_press_event', self.on_press) + plt.show() + + def on_press(self, event): + x, y = event.xdata, event.ydata + if x < 0 or x > self.x - 1 or y < 0 or y > self.y - 1: + print("Please choose right area!") + else: + self.count_env_change += 1 + x, y = int(x), int(y) + print("Change position: s =", x, ",", "y =", y) + + # for small changes + if self.title == "Anytime D*: Small changes": + if (x, y) not in self.obs: + self.obs.add((x, y)) + self.g[(x, y)] = float("inf") + self.rhs[(x, y)] = float("inf") + else: + self.obs.remove((x, y)) + self.UpdateState((x, y)) + + self.Plot.update_obs(self.obs) + + for sn in self.get_neighbor((x, y)): + self.UpdateState(sn) + + plt.cla() + self.Plot.plot_grid(self.title) + + while True: + if len(self.INCONS) == 0: + break + self.OPEN.update(self.INCONS) + for s in self.OPEN: + self.OPEN[s] = self.Key(s) + self.CLOSED = set() + self.ComputeOrImprovePath() + self.plot_visited() + self.plot_path(self.extract_path()) + # plt.plot(self.title) + self.visited = set() + + if self.eps <= 1.0: + break + + else: + if (x, y) not in self.obs: + self.obs.add((x, y)) + self.obs_add.add((x, y)) + plt.plot(x, y, 'sk') + if (x, y) in self.obs_remove: + self.obs_remove.remove((x, y)) + else: + self.obs.remove((x, y)) + self.obs_remove.add((x, y)) + plt.plot(x, y, marker='s', color='white') + if (x, y) in self.obs_add: + self.obs_add.remove((x, y)) + + self.Plot.update_obs(self.obs) + + if self.count_env_change >= 15: + self.count_env_change = 0 + self.eps += 2.0 + for s in self.obs_add: + self.g[(x, y)] = float("inf") + self.rhs[(x, y)] = float("inf") + + for sn in self.get_neighbor(s): + self.UpdateState(sn) + + for s in self.obs_remove: + for sn in self.get_neighbor(s): + self.UpdateState(sn) + self.UpdateState(s) + + plt.cla() + self.Plot.plot_grid(self.title) + + while True: + if self.eps <= 1.0: + break + self.eps -= 0.5 + self.OPEN.update(self.INCONS) + for s in self.OPEN: + self.OPEN[s] = self.Key(s) + self.CLOSED = set() + self.ComputeOrImprovePath() + self.plot_visited() + self.plot_path(self.extract_path()) + plt.title(self.title) + self.visited = set() + plt.pause(0.5) + + self.fig.canvas.draw_idle() + + def ComputeOrImprovePath(self): + while True: + s, v = self.TopKey() + if v >= self.Key(self.s_start) and \ + self.rhs[self.s_start] == self.g[self.s_start]: + break + + self.OPEN.pop(s) + self.visited.add(s) + + if self.g[s] > self.rhs[s]: + self.g[s] = self.rhs[s] + self.CLOSED.add(s) + for sn in self.get_neighbor(s): + self.UpdateState(sn) + else: + self.g[s] = float("inf") + for sn in self.get_neighbor(s): + self.UpdateState(sn) + self.UpdateState(s) + + def UpdateState(self, s): + if s != self.s_goal: + self.rhs[s] = float("inf") + for x in self.get_neighbor(s): + self.rhs[s] = min(self.rhs[s], self.g[x] + self.cost(s, x)) + if s in self.OPEN: + self.OPEN.pop(s) + + if self.g[s] != self.rhs[s]: + if s not in self.CLOSED: + self.OPEN[s] = self.Key(s) + else: + self.INCONS[s] = 0 + + def Key(self, s): + if self.g[s] > self.rhs[s]: + return [self.rhs[s] + self.eps * self.h(self.s_start, s), self.rhs[s]] + else: + return [self.g[s] + self.h(self.s_start, s), self.g[s]] + + def TopKey(self): + """ + :return: return the min key and its value. + """ + + s = min(self.OPEN, key=self.OPEN.get) + return s, self.OPEN[s] + + def h(self, s_start, s_goal): + heuristic_type = self.heuristic_type # heuristic type + + if heuristic_type == "manhattan": + return abs(s_goal[0] - s_start[0]) + abs(s_goal[1] - s_start[1]) + else: + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return float("inf") + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + def get_neighbor(self, s): + nei_list = set() + for u in self.u_set: + s_next = tuple([s[i] + u[i] for i in range(2)]) + if s_next not in self.obs: + nei_list.add(s_next) + + return nei_list + + def extract_path(self): + """ + Extract the path based on the PARENT set. + :return: The planning path + """ + + path = [self.s_start] + s = self.s_start + + for k in range(100): + g_list = {} + for x in self.get_neighbor(s): + if not self.is_collision(s, x): + g_list[x] = self.g[x] + s = min(g_list, key=g_list.get) + path.append(s) + if s == self.s_goal: + break + + return list(path) + + def plot_path(self, path): + px = [x[0] for x in path] + py = [x[1] for x in path] + plt.plot(px, py, linewidth=2) + plt.plot(self.s_start[0], self.s_start[1], "bs") + plt.plot(self.s_goal[0], self.s_goal[1], "gs") + + def plot_visited(self): + self.count += 1 + + color = ['gainsboro', 'lightgray', 'silver', 'darkgray', + 'bisque', 'navajowhite', 'moccasin', 'wheat', + 'powderblue', 'skyblue', 'lightskyblue', 'cornflowerblue'] + + if self.count >= len(color) - 1: + self.count = 0 + + for x in self.visited: + plt.plot(x[0], x[1], marker='s', color=color[self.count]) + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + dstar = ADStar(s_start, s_goal, 2.5, "euclidean") + dstar.run() + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/Astar.py b/src/Search_2D/Astar.py new file mode 100644 index 0000000..3c8e554 --- /dev/null +++ b/src/Search_2D/Astar.py @@ -0,0 +1,224 @@ +""" +A_star 2D +@author: huiming zhou +""" + +import os +import sys +import math +import heapq + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../PaddleClas-release-2.3") + +from Search_2D import plotting, env + + +class AStar: + """AStar set the cost + heuristics as the priority + """ + def __init__(self, s_start, s_goal, heuristic_type): + self.s_start = s_start + self.s_goal = s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() # class Env + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + + self.OPEN = [] # priority queue / OPEN set + self.CLOSED = [] # CLOSED set / VISITED order + self.PARENT = dict() # recorded parent + self.g = dict() # cost to come + + def searching(self): + """ + A_star Searching. + :return: path, visited order + """ + + self.PARENT[self.s_start] = self.s_start + self.g[self.s_start] = 0 + self.g[self.s_goal] = math.inf + heapq.heappush(self.OPEN, + (self.f_value(self.s_start), self.s_start)) + + while self.OPEN: + _, s = heapq.heappop(self.OPEN) + self.CLOSED.append(s) + + if s == self.s_goal: # stop condition + break + + for s_n in self.get_neighbor(s): + new_cost = self.g[s] + self.cost(s, s_n) + + if s_n not in self.g: + self.g[s_n] = math.inf + + if new_cost < self.g[s_n]: # conditions for updating Cost + self.g[s_n] = new_cost + self.PARENT[s_n] = s + heapq.heappush(self.OPEN, (self.f_value(s_n), s_n)) + + return self.extract_path(self.PARENT), self.CLOSED + + def searching_repeated_astar(self, e): + """ + repeated A*. + :param e: weight of A* + :return: path and visited order + """ + + path, visited = [], [] + + while e >= 1: + p_k, v_k = self.repeated_searching(self.s_start, self.s_goal, e) + path.append(p_k) + visited.append(v_k) + e -= 0.5 + + return path, visited + + def repeated_searching(self, s_start, s_goal, e): + """ + run A* with weight e. + :param s_start: starting state + :param s_goal: goal state + :param e: weight of a* + :return: path and visited order. + """ + + g = {s_start: 0, s_goal: float("inf")} + PARENT = {s_start: s_start} + OPEN = [] + CLOSED = [] + heapq.heappush(OPEN, + (g[s_start] + e * self.heuristic(s_start), s_start)) + + while OPEN: + _, s = heapq.heappop(OPEN) + CLOSED.append(s) + + if s == s_goal: + break + + for s_n in self.get_neighbor(s): + new_cost = g[s] + self.cost(s, s_n) + + if s_n not in g: + g[s_n] = math.inf + + if new_cost < g[s_n]: # conditions for updating Cost + g[s_n] = new_cost + PARENT[s_n] = s + heapq.heappush(OPEN, (g[s_n] + e * self.heuristic(s_n), s_n)) + + return self.extract_path(PARENT), CLOSED + + def get_neighbor(self, s): + """ + find neighbors of state s that not in obstacles. + :param s: state + :return: neighbors + """ + + return [(s[0] + u[0], s[1] + u[1]) for u in self.u_set] + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return math.inf + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + """ + check if the line segment (s_start, s_end) is collision. + :param s_start: start node + :param s_end: end node + :return: True: is collision / False: not collision + """ + + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + def f_value(self, s): + """ + f = g + h. (g: Cost to come, h: heuristic value) + :param s: current state + :return: f + """ + + return self.g[s] + self.heuristic(s) + + def extract_path(self, PARENT): + """ + Extract the path based on the PARENT set. + :return: The planning path + """ + + path = [self.s_goal] + s = self.s_goal + + while True: + s = PARENT[s] + path.append(s) + + if s == self.s_start: + break + + return list(path) + + def heuristic(self, s): + """ + Calculate heuristic. + :param s: current node (state) + :return: heuristic function value + """ + + heuristic_type = self.heuristic_type # heuristic type + goal = self.s_goal # goal node + + if heuristic_type == "manhattan": + return abs(goal[0] - s[0]) + abs(goal[1] - s[1]) + else: + return math.hypot(goal[0] - s[0], goal[1] - s[1]) + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + astar = AStar(s_start, s_goal, "euclidean") + plot = plotting.Plotting(s_start, s_goal) + + path, visited = astar.searching() + plot.animation(path, visited, "A*") # animation + + # path, visited = astar.searching_repeated_astar(2.5) # initial weight e = 2.5 + # plot.animation_ara_star(path, visited, "Repeated A*") + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/Best_First.py b/src/Search_2D/Best_First.py new file mode 100644 index 0000000..0c85fba --- /dev/null +++ b/src/Search_2D/Best_First.py @@ -0,0 +1,68 @@ +""" +Best-First Searching +@author: huiming zhou +""" + +import os +import sys +import math +import heapq + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env +from Search_2D.Astar import AStar + + +class BestFirst(AStar): + """BestFirst set the heuristics as the priority + """ + def searching(self): + """ + Breadth-first Searching. + :return: path, visited order + """ + + self.PARENT[self.s_start] = self.s_start + self.g[self.s_start] = 0 + self.g[self.s_goal] = math.inf + heapq.heappush(self.OPEN, + (self.heuristic(self.s_start), self.s_start)) + + while self.OPEN: + _, s = heapq.heappop(self.OPEN) + self.CLOSED.append(s) + + if s == self.s_goal: + break + + for s_n in self.get_neighbor(s): + new_cost = self.g[s] + self.cost(s, s_n) + + if s_n not in self.g: + self.g[s_n] = math.inf + + if new_cost < self.g[s_n]: # conditions for updating Cost + self.g[s_n] = new_cost + self.PARENT[s_n] = s + + # best first set the heuristics as the priority + heapq.heappush(self.OPEN, (self.heuristic(s_n), s_n)) + + return self.extract_path(self.PARENT), self.CLOSED + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + BF = BestFirst(s_start, s_goal, 'euclidean') + plot = plotting.Plotting(s_start, s_goal) + + path, visited = BF.searching() + plot.animation(path, visited, "Best-first Searching") # animation + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/Bidirectional_a_star.py b/src/Search_2D/Bidirectional_a_star.py new file mode 100644 index 0000000..3580c1a --- /dev/null +++ b/src/Search_2D/Bidirectional_a_star.py @@ -0,0 +1,229 @@ +""" +Bidirectional_a_star 2D +@author: huiming zhou +""" + +import os +import sys +import math +import heapq + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env + + +class BidirectionalAStar: + def __init__(self, s_start, s_goal, heuristic_type): + self.s_start = s_start + self.s_goal = s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() # class Env + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + + self.OPEN_fore = [] # OPEN set for forward searching + self.OPEN_back = [] # OPEN set for backward searching + self.CLOSED_fore = [] # CLOSED set for forward + self.CLOSED_back = [] # CLOSED set for backward + self.PARENT_fore = dict() # recorded parent for forward + self.PARENT_back = dict() # recorded parent for backward + self.g_fore = dict() # cost to come for forward + self.g_back = dict() # cost to come for backward + + def init(self): + """ + initialize parameters + """ + + self.g_fore[self.s_start] = 0.0 + self.g_fore[self.s_goal] = math.inf + self.g_back[self.s_goal] = 0.0 + self.g_back[self.s_start] = math.inf + self.PARENT_fore[self.s_start] = self.s_start + self.PARENT_back[self.s_goal] = self.s_goal + heapq.heappush(self.OPEN_fore, + (self.f_value_fore(self.s_start), self.s_start)) + heapq.heappush(self.OPEN_back, + (self.f_value_back(self.s_goal), self.s_goal)) + + def searching(self): + """ + Bidirectional A* + :return: connected path, visited order of forward, visited order of backward + """ + + self.init() + s_meet = self.s_start + + while self.OPEN_fore and self.OPEN_back: + # solve foreward-search + _, s_fore = heapq.heappop(self.OPEN_fore) + + if s_fore in self.PARENT_back: + s_meet = s_fore + break + + self.CLOSED_fore.append(s_fore) + + for s_n in self.get_neighbor(s_fore): + new_cost = self.g_fore[s_fore] + self.cost(s_fore, s_n) + + if s_n not in self.g_fore: + self.g_fore[s_n] = math.inf + + if new_cost < self.g_fore[s_n]: + self.g_fore[s_n] = new_cost + self.PARENT_fore[s_n] = s_fore + heapq.heappush(self.OPEN_fore, + (self.f_value_fore(s_n), s_n)) + + # solve backward-search + _, s_back = heapq.heappop(self.OPEN_back) + + if s_back in self.PARENT_fore: + s_meet = s_back + break + + self.CLOSED_back.append(s_back) + + for s_n in self.get_neighbor(s_back): + new_cost = self.g_back[s_back] + self.cost(s_back, s_n) + + if s_n not in self.g_back: + self.g_back[s_n] = math.inf + + if new_cost < self.g_back[s_n]: + self.g_back[s_n] = new_cost + self.PARENT_back[s_n] = s_back + heapq.heappush(self.OPEN_back, + (self.f_value_back(s_n), s_n)) + + return self.extract_path(s_meet), self.CLOSED_fore, self.CLOSED_back + + def get_neighbor(self, s): + """ + find neighbors of state s that not in obstacles. + :param s: state + :return: neighbors + """ + + return [(s[0] + u[0], s[1] + u[1]) for u in self.u_set] + + def extract_path(self, s_meet): + """ + extract path from start and goal + :param s_meet: meet point of bi-direction a* + :return: path + """ + + # extract path for foreward part + path_fore = [s_meet] + s = s_meet + + while True: + s = self.PARENT_fore[s] + path_fore.append(s) + if s == self.s_start: + break + + # extract path for backward part + path_back = [] + s = s_meet + + while True: + s = self.PARENT_back[s] + path_back.append(s) + if s == self.s_goal: + break + + return list(reversed(path_fore)) + list(path_back) + + def f_value_fore(self, s): + """ + forward searching: f = g + h. (g: Cost to come, h: heuristic value) + :param s: current state + :return: f + """ + + return self.g_fore[s] + self.h(s, self.s_goal) + + def f_value_back(self, s): + """ + backward searching: f = g + h. (g: Cost to come, h: heuristic value) + :param s: current state + :return: f + """ + + return self.g_back[s] + self.h(s, self.s_start) + + def h(self, s, goal): + """ + Calculate heuristic value. + :param s: current node (state) + :param goal: goal node (state) + :return: heuristic value + """ + + heuristic_type = self.heuristic_type + + if heuristic_type == "manhattan": + return abs(goal[0] - s[0]) + abs(goal[1] - s[1]) + else: + return math.hypot(goal[0] - s[0], goal[1] - s[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return math.inf + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + """ + check if the line segment (s_start, s_end) is collision. + :param s_start: start node + :param s_end: end node + :return: True: is collision / False: not collision + """ + + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + +def main(): + x_start = (5, 5) + x_goal = (45, 25) + + bastar = BidirectionalAStar(x_start, x_goal, "euclidean") + plot = plotting.Plotting(x_start, x_goal) + + path, visited_fore, visited_back = bastar.searching() + plot.animation_bi_astar(path, visited_fore, visited_back, "Bidirectional-A*") # animation + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/D_star.py b/src/Search_2D/D_star.py new file mode 100644 index 0000000..60b6c7e --- /dev/null +++ b/src/Search_2D/D_star.py @@ -0,0 +1,304 @@ +""" +D_star 2D +@author: huiming zhou +""" + +import os +import sys +import math +import matplotlib.pyplot as plt + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env + + +class DStar: + def __init__(self, s_start, s_goal): + self.s_start, self.s_goal = s_start, s_goal + + self.Env = env.Env() + self.Plot = plotting.Plotting(self.s_start, self.s_goal) + + self.u_set = self.Env.motions + self.obs = self.Env.obs + self.x = self.Env.x_range + self.y = self.Env.y_range + + self.fig = plt.figure() + + self.OPEN = set() + self.t = dict() + self.PARENT = dict() + self.h = dict() + self.k = dict() + self.path = [] + self.visited = set() + self.count = 0 + + def init(self): + for i in range(self.Env.x_range): + for j in range(self.Env.y_range): + self.t[(i, j)] = 'NEW' + self.k[(i, j)] = 0.0 + self.h[(i, j)] = float("inf") + self.PARENT[(i, j)] = None + + self.h[self.s_goal] = 0.0 + + def run(self, s_start, s_end): + self.init() + self.insert(s_end, 0) + + while True: + self.process_state() + if self.t[s_start] == 'CLOSED': + break + + self.path = self.extract_path(s_start, s_end) + self.Plot.plot_grid("Dynamic A* (D*)") + self.plot_path(self.path) + self.fig.canvas.mpl_connect('button_press_event', self.on_press) + plt.show() + + def on_press(self, event): + x, y = event.xdata, event.ydata + if x < 0 or x > self.x - 1 or y < 0 or y > self.y - 1: + print("Please choose right area!") + else: + x, y = int(x), int(y) + if (x, y) not in self.obs: + print("Add obstacle at: s =", x, ",", "y =", y) + self.obs.add((x, y)) + self.Plot.update_obs(self.obs) + + s = self.s_start + self.visited = set() + self.count += 1 + + while s != self.s_goal: + if self.is_collision(s, self.PARENT[s]): + self.modify(s) + continue + s = self.PARENT[s] + + self.path = self.extract_path(self.s_start, self.s_goal) + + plt.cla() + self.Plot.plot_grid("Dynamic A* (D*)") + self.plot_visited(self.visited) + self.plot_path(self.path) + + self.fig.canvas.draw_idle() + + def extract_path(self, s_start, s_end): + path = [s_start] + s = s_start + while True: + s = self.PARENT[s] + path.append(s) + if s == s_end: + return path + + def process_state(self): + s = self.min_state() # get node in OPEN set with min k value + self.visited.add(s) + + if s is None: + return -1 # OPEN set is empty + + k_old = self.get_k_min() # record the min k value of this iteration (min path cost) + self.delete(s) # move state s from OPEN set to CLOSED set + + # k_min < h[s] --> s: RAISE state (increased cost) + if k_old < self.h[s]: + for s_n in self.get_neighbor(s): + if self.h[s_n] <= k_old and \ + self.h[s] > self.h[s_n] + self.cost(s_n, s): + + # update h_value and choose parent + self.PARENT[s] = s_n + self.h[s] = self.h[s_n] + self.cost(s_n, s) + + # s: k_min >= h[s] -- > s: LOWER state (cost reductions) + if k_old == self.h[s]: + for s_n in self.get_neighbor(s): + if self.t[s_n] == 'NEW' or \ + (self.PARENT[s_n] == s and self.h[s_n] != self.h[s] + self.cost(s, s_n)) or \ + (self.PARENT[s_n] != s and self.h[s_n] > self.h[s] + self.cost(s, s_n)): + + # Condition: + # 1) t[s_n] == 'NEW': not visited + # 2) s_n's parent: cost reduction + # 3) s_n find a better parent + self.PARENT[s_n] = s + self.insert(s_n, self.h[s] + self.cost(s, s_n)) + else: + for s_n in self.get_neighbor(s): + if self.t[s_n] == 'NEW' or \ + (self.PARENT[s_n] == s and self.h[s_n] != self.h[s] + self.cost(s, s_n)): + + # Condition: + # 1) t[s_n] == 'NEW': not visited + # 2) s_n's parent: cost reduction + self.PARENT[s_n] = s + self.insert(s_n, self.h[s] + self.cost(s, s_n)) + else: + if self.PARENT[s_n] != s and \ + self.h[s_n] > self.h[s] + self.cost(s, s_n): + + # Condition: LOWER happened in OPEN set (s), s should be explored again + self.insert(s, self.h[s]) + else: + if self.PARENT[s_n] != s and \ + self.h[s] > self.h[s_n] + self.cost(s_n, s) and \ + self.t[s_n] == 'CLOSED' and \ + self.h[s_n] > k_old: + + # Condition: LOWER happened in CLOSED set (s_n), s_n should be explored again + self.insert(s_n, self.h[s_n]) + + return self.get_k_min() + + def min_state(self): + """ + choose the node with the minimum k value in OPEN set. + :return: state + """ + + if not self.OPEN: + return None + + return min(self.OPEN, key=lambda x: self.k[x]) + + def get_k_min(self): + """ + calc the min k value for nodes in OPEN set. + :return: k value + """ + + if not self.OPEN: + return -1 + + return min([self.k[x] for x in self.OPEN]) + + def insert(self, s, h_new): + """ + insert node into OPEN set. + :param s: node + :param h_new: new or better cost to come value + """ + + if self.t[s] == 'NEW': + self.k[s] = h_new + elif self.t[s] == 'OPEN': + self.k[s] = min(self.k[s], h_new) + elif self.t[s] == 'CLOSED': + self.k[s] = min(self.h[s], h_new) + + self.h[s] = h_new + self.t[s] = 'OPEN' + self.OPEN.add(s) + + def delete(self, s): + """ + delete: move state s from OPEN set to CLOSED set. + :param s: state should be deleted + """ + + if self.t[s] == 'OPEN': + self.t[s] = 'CLOSED' + + self.OPEN.remove(s) + + def modify(self, s): + """ + start processing from state s. + :param s: is a node whose status is RAISE or LOWER. + """ + + self.modify_cost(s) + + while True: + k_min = self.process_state() + + if k_min >= self.h[s]: + break + + def modify_cost(self, s): + # if node in CLOSED set, put it into OPEN set. + # Since cost may be changed between s - s.parent, calc cost(s, s.p) again + + if self.t[s] == 'CLOSED': + self.insert(s, self.h[self.PARENT[s]] + self.cost(s, self.PARENT[s])) + + def get_neighbor(self, s): + nei_list = set() + + for u in self.u_set: + s_next = tuple([s[i] + u[i] for i in range(2)]) + if s_next not in self.obs: + nei_list.add(s_next) + + return nei_list + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return float("inf") + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + def plot_path(self, path): + px = [x[0] for x in path] + py = [x[1] for x in path] + plt.plot(px, py, linewidth=2) + plt.plot(self.s_start[0], self.s_start[1], "bs") + plt.plot(self.s_goal[0], self.s_goal[1], "gs") + + def plot_visited(self, visited): + color = ['gainsboro', 'lightgray', 'silver', 'darkgray', + 'bisque', 'navajowhite', 'moccasin', 'wheat', + 'powderblue', 'skyblue', 'lightskyblue', 'cornflowerblue'] + + if self.count >= len(color) - 1: + self.count = 0 + + for x in visited: + plt.plot(x[0], x[1], marker='s', color=color[self.count]) + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + dstar = DStar(s_start, s_goal) + dstar.run(s_start, s_goal) + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/D_star_Lite.py b/src/Search_2D/D_star_Lite.py new file mode 100644 index 0000000..4996be2 --- /dev/null +++ b/src/Search_2D/D_star_Lite.py @@ -0,0 +1,239 @@ +""" +D_star_Lite 2D +@author: huiming zhou +""" + +import os +import sys +import math +import matplotlib.pyplot as plt + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env + + +class DStar: + def __init__(self, s_start, s_goal, heuristic_type): + self.s_start, self.s_goal = s_start, s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() # class Env + self.Plot = plotting.Plotting(s_start, s_goal) + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + self.x = self.Env.x_range + self.y = self.Env.y_range + + self.g, self.rhs, self.U = {}, {}, {} + self.km = 0 + + for i in range(1, self.Env.x_range - 1): + for j in range(1, self.Env.y_range - 1): + self.rhs[(i, j)] = float("inf") + self.g[(i, j)] = float("inf") + + self.rhs[self.s_goal] = 0.0 + self.U[self.s_goal] = self.CalculateKey(self.s_goal) + self.visited = set() + self.count = 0 + self.fig = plt.figure() + + def run(self): + self.Plot.plot_grid("D* Lite") + self.ComputePath() + self.plot_path(self.extract_path()) + self.fig.canvas.mpl_connect('button_press_event', self.on_press) + plt.show() + + def on_press(self, event): + x, y = event.xdata, event.ydata + if x < 0 or x > self.x - 1 or y < 0 or y > self.y - 1: + print("Please choose right area!") + else: + x, y = int(x), int(y) + print("Change position: s =", x, ",", "y =", y) + + s_curr = self.s_start + s_last = self.s_start + i = 0 + path = [self.s_start] + + while s_curr != self.s_goal: + s_list = {} + + for s in self.get_neighbor(s_curr): + s_list[s] = self.g[s] + self.cost(s_curr, s) + s_curr = min(s_list, key=s_list.get) + path.append(s_curr) + + if i < 1: + self.km += self.h(s_last, s_curr) + s_last = s_curr + if (x, y) not in self.obs: + self.obs.add((x, y)) + plt.plot(x, y, 'sk') + self.g[(x, y)] = float("inf") + self.rhs[(x, y)] = float("inf") + else: + self.obs.remove((x, y)) + plt.plot(x, y, marker='s', color='white') + self.UpdateVertex((x, y)) + for s in self.get_neighbor((x, y)): + self.UpdateVertex(s) + i += 1 + + self.count += 1 + self.visited = set() + self.ComputePath() + + self.plot_visited(self.visited) + self.plot_path(path) + self.fig.canvas.draw_idle() + + def ComputePath(self): + while True: + s, v = self.TopKey() + if v >= self.CalculateKey(self.s_start) and \ + self.rhs[self.s_start] == self.g[self.s_start]: + break + + k_old = v + self.U.pop(s) + self.visited.add(s) + + if k_old < self.CalculateKey(s): + self.U[s] = self.CalculateKey(s) + elif self.g[s] > self.rhs[s]: + self.g[s] = self.rhs[s] + for x in self.get_neighbor(s): + self.UpdateVertex(x) + else: + self.g[s] = float("inf") + self.UpdateVertex(s) + for x in self.get_neighbor(s): + self.UpdateVertex(x) + + def UpdateVertex(self, s): + if s != self.s_goal: + self.rhs[s] = float("inf") + for x in self.get_neighbor(s): + self.rhs[s] = min(self.rhs[s], self.g[x] + self.cost(s, x)) + if s in self.U: + self.U.pop(s) + + if self.g[s] != self.rhs[s]: + self.U[s] = self.CalculateKey(s) + + def CalculateKey(self, s): + return [min(self.g[s], self.rhs[s]) + self.h(self.s_start, s) + self.km, + min(self.g[s], self.rhs[s])] + + def TopKey(self): + """ + :return: return the min key and its value. + """ + + s = min(self.U, key=self.U.get) + return s, self.U[s] + + def h(self, s_start, s_goal): + heuristic_type = self.heuristic_type # heuristic type + + if heuristic_type == "manhattan": + return abs(s_goal[0] - s_start[0]) + abs(s_goal[1] - s_start[1]) + else: + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return float("inf") + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + def get_neighbor(self, s): + nei_list = set() + for u in self.u_set: + s_next = tuple([s[i] + u[i] for i in range(2)]) + if s_next not in self.obs: + nei_list.add(s_next) + + return nei_list + + def extract_path(self): + """ + Extract the path based on the PARENT set. + :return: The planning path + """ + + path = [self.s_start] + s = self.s_start + + for k in range(100): + g_list = {} + for x in self.get_neighbor(s): + if not self.is_collision(s, x): + g_list[x] = self.g[x] + s = min(g_list, key=g_list.get) + path.append(s) + if s == self.s_goal: + break + + return list(path) + + def plot_path(self, path): + px = [x[0] for x in path] + py = [x[1] for x in path] + plt.plot(px, py, linewidth=2) + plt.plot(self.s_start[0], self.s_start[1], "bs") + plt.plot(self.s_goal[0], self.s_goal[1], "gs") + + def plot_visited(self, visited): + color = ['gainsboro', 'lightgray', 'silver', 'darkgray', + 'bisque', 'navajowhite', 'moccasin', 'wheat', + 'powderblue', 'skyblue', 'lightskyblue', 'cornflowerblue'] + + if self.count >= len(color) - 1: + self.count = 0 + + for x in visited: + plt.plot(x[0], x[1], marker='s', color=color[self.count]) + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + dstar = DStar(s_start, s_goal, "euclidean") + dstar.run() + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/Dijkstra.py b/src/Search_2D/Dijkstra.py new file mode 100644 index 0000000..e5e7b68 --- /dev/null +++ b/src/Search_2D/Dijkstra.py @@ -0,0 +1,69 @@ +""" +Dijkstra 2D +@author: huiming zhou +""" + +import os +import sys +import math +import heapq + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env + +from Search_2D.Astar import AStar + + +class Dijkstra(AStar): + """Dijkstra set the cost as the priority + """ + def searching(self): + """ + Breadth-first Searching. + :return: path, visited order + """ + + self.PARENT[self.s_start] = self.s_start + self.g[self.s_start] = 0 + self.g[self.s_goal] = math.inf + heapq.heappush(self.OPEN, + (0, self.s_start)) + + while self.OPEN: + _, s = heapq.heappop(self.OPEN) + self.CLOSED.append(s) + + if s == self.s_goal: + break + + for s_n in self.get_neighbor(s): + new_cost = self.g[s] + self.cost(s, s_n) + + if s_n not in self.g: + self.g[s_n] = math.inf + + if new_cost < self.g[s_n]: # conditions for updating Cost + self.g[s_n] = new_cost + self.PARENT[s_n] = s + + # best first set the heuristics as the priority + heapq.heappush(self.OPEN, (new_cost, s_n)) + + return self.extract_path(self.PARENT), self.CLOSED + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + dijkstra = Dijkstra(s_start, s_goal, 'None') + plot = plotting.Plotting(s_start, s_goal) + + path, visited = dijkstra.searching() + plot.animation(path, visited, "Dijkstra's") # animation generate + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/LPAstar.py b/src/Search_2D/LPAstar.py new file mode 100644 index 0000000..4fd70ae --- /dev/null +++ b/src/Search_2D/LPAstar.py @@ -0,0 +1,256 @@ +""" +LPA_star 2D +@author: huiming zhou +""" + +import os +import sys +import math +import matplotlib.pyplot as plt + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env + + +class LPAStar: + def __init__(self, s_start, s_goal, heuristic_type): + self.s_start, self.s_goal = s_start, s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() + self.Plot = plotting.Plotting(self.s_start, self.s_goal) + + self.u_set = self.Env.motions + self.obs = self.Env.obs + self.x = self.Env.x_range + self.y = self.Env.y_range + + self.g, self.rhs, self.U = {}, {}, {} + + for i in range(self.Env.x_range): + for j in range(self.Env.y_range): + self.rhs[(i, j)] = float("inf") + self.g[(i, j)] = float("inf") + + self.rhs[self.s_start] = 0 + self.U[self.s_start] = self.CalculateKey(self.s_start) + self.visited = set() + self.count = 0 + + self.fig = plt.figure() + + def run(self): + self.Plot.plot_grid("Lifelong Planning A*") + + self.ComputeShortestPath() + self.plot_path(self.extract_path()) + self.fig.canvas.mpl_connect('button_press_event', self.on_press) + + plt.show() + + def on_press(self, event): + x, y = event.xdata, event.ydata + if x < 0 or x > self.x - 1 or y < 0 or y > self.y - 1: + print("Please choose right area!") + else: + x, y = int(x), int(y) + print("Change position: s =", x, ",", "y =", y) + + self.visited = set() + self.count += 1 + + if (x, y) not in self.obs: + self.obs.add((x, y)) + else: + self.obs.remove((x, y)) + self.UpdateVertex((x, y)) + + self.Plot.update_obs(self.obs) + + for s_n in self.get_neighbor((x, y)): + self.UpdateVertex(s_n) + + self.ComputeShortestPath() + + plt.cla() + self.Plot.plot_grid("Lifelong Planning A*") + self.plot_visited(self.visited) + self.plot_path(self.extract_path()) + self.fig.canvas.draw_idle() + + def ComputeShortestPath(self): + while True: + s, v = self.TopKey() + + if v >= self.CalculateKey(self.s_goal) and \ + self.rhs[self.s_goal] == self.g[self.s_goal]: + break + + self.U.pop(s) + self.visited.add(s) + + if self.g[s] > self.rhs[s]: + + # Condition: over-consistent (eg: deleted obstacles) + # So, rhs[s] decreased -- > rhs[s] < g[s] + self.g[s] = self.rhs[s] + else: + + # Condition: # under-consistent (eg: added obstacles) + # So, rhs[s] increased --> rhs[s] > g[s] + self.g[s] = float("inf") + self.UpdateVertex(s) + + for s_n in self.get_neighbor(s): + self.UpdateVertex(s_n) + + def UpdateVertex(self, s): + """ + update the status and the current cost to come of state s. + :param s: state s + """ + + if s != self.s_start: + + # Condition: cost of parent of s changed + # Since we do not record the children of a state, we need to enumerate its neighbors + self.rhs[s] = min(self.g[s_n] + self.cost(s_n, s) + for s_n in self.get_neighbor(s)) + + if s in self.U: + self.U.pop(s) + + if self.g[s] != self.rhs[s]: + + # Condition: current cost to come is different to that of last time + # state s should be added into OPEN set (set U) + self.U[s] = self.CalculateKey(s) + + def TopKey(self): + """ + :return: return the min key and its value. + """ + + s = min(self.U, key=self.U.get) + + return s, self.U[s] + + def CalculateKey(self, s): + + return [min(self.g[s], self.rhs[s]) + self.h(s), + min(self.g[s], self.rhs[s])] + + def get_neighbor(self, s): + """ + find neighbors of state s that not in obstacles. + :param s: state + :return: neighbors + """ + + s_list = set() + + for u in self.u_set: + s_next = tuple([s[i] + u[i] for i in range(2)]) + if s_next not in self.obs: + s_list.add(s_next) + + return s_list + + def h(self, s): + """ + Calculate heuristic. + :param s: current node (state) + :return: heuristic function value + """ + + heuristic_type = self.heuristic_type # heuristic type + goal = self.s_goal # goal node + + if heuristic_type == "manhattan": + return abs(goal[0] - s[0]) + abs(goal[1] - s[1]) + else: + return math.hypot(goal[0] - s[0], goal[1] - s[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return float("inf") + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + def extract_path(self): + """ + Extract the path based on the PARENT set. + :return: The planning path + """ + + path = [self.s_goal] + s = self.s_goal + + for k in range(100): + g_list = {} + for x in self.get_neighbor(s): + if not self.is_collision(s, x): + g_list[x] = self.g[x] + s = min(g_list, key=g_list.get) + path.append(s) + if s == self.s_start: + break + + return list(reversed(path)) + + def plot_path(self, path): + px = [x[0] for x in path] + py = [x[1] for x in path] + plt.plot(px, py, linewidth=2) + plt.plot(self.s_start[0], self.s_start[1], "bs") + plt.plot(self.s_goal[0], self.s_goal[1], "gs") + + def plot_visited(self, visited): + color = ['gainsboro', 'lightgray', 'silver', 'darkgray', + 'bisque', 'navajowhite', 'moccasin', 'wheat', + 'powderblue', 'skyblue', 'lightskyblue', 'cornflowerblue'] + + if self.count >= len(color) - 1: + self.count = 0 + + for x in visited: + plt.plot(x[0], x[1], marker='s', color=color[self.count]) + + +def main(): + x_start = (5, 5) + x_goal = (45, 25) + + lpastar = LPAStar(x_start, x_goal, "Euclidean") + lpastar.run() + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/LRTAstar.py b/src/Search_2D/LRTAstar.py new file mode 100644 index 0000000..108903b --- /dev/null +++ b/src/Search_2D/LRTAstar.py @@ -0,0 +1,230 @@ +""" +LRTA_star 2D (Learning Real-time A*) +@author: huiming zhou +""" + +import os +import sys +import copy +import math + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import queue, plotting, env + + +class LrtAStarN: + def __init__(self, s_start, s_goal, N, heuristic_type): + self.s_start, self.s_goal = s_start, s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + + self.N = N # number of expand nodes each iteration + self.visited = [] # order of visited nodes in planning + self.path = [] # path of each iteration + self.h_table = {} # h_value table + + def init(self): + """ + initialize the h_value of all nodes in the environment. + it is a global table. + """ + + for i in range(self.Env.x_range): + for j in range(self.Env.y_range): + self.h_table[(i, j)] = self.h((i, j)) + + def searching(self): + self.init() + s_start = self.s_start # initialize start node + + while True: + OPEN, CLOSED = self.AStar(s_start, self.N) # OPEN, CLOSED sets in each iteration + + if OPEN == "FOUND": # reach the goal node + self.path.append(CLOSED) + break + + h_value = self.iteration(CLOSED) # h_value table of CLOSED nodes + + for x in h_value: + self.h_table[x] = h_value[x] + + s_start, path_k = self.extract_path_in_CLOSE(s_start, h_value) # x_init -> expected node in OPEN set + self.path.append(path_k) + + def extract_path_in_CLOSE(self, s_start, h_value): + path = [s_start] + s = s_start + + while True: + h_list = {} + + for s_n in self.get_neighbor(s): + if s_n in h_value: + h_list[s_n] = h_value[s_n] + else: + h_list[s_n] = self.h_table[s_n] + + s_key = min(h_list, key=h_list.get) # move to the smallest node with min h_value + path.append(s_key) # generate path + s = s_key # use end of this iteration as the start of next + + if s_key not in h_value: # reach the expected node in OPEN set + return s_key, path + + def iteration(self, CLOSED): + h_value = {} + + for s in CLOSED: + h_value[s] = float("inf") # initialize h_value of CLOSED nodes + + while True: + h_value_rec = copy.deepcopy(h_value) + for s in CLOSED: + h_list = [] + for s_n in self.get_neighbor(s): + if s_n not in CLOSED: + h_list.append(self.cost(s, s_n) + self.h_table[s_n]) + else: + h_list.append(self.cost(s, s_n) + h_value[s_n]) + h_value[s] = min(h_list) # update h_value of current node + + if h_value == h_value_rec: # h_value table converged + return h_value + + def AStar(self, x_start, N): + OPEN = queue.QueuePrior() # OPEN set + OPEN.put(x_start, self.h(x_start)) + CLOSED = [] # CLOSED set + g_table = {x_start: 0, self.s_goal: float("inf")} # Cost to come + PARENT = {x_start: x_start} # relations + count = 0 # counter + + while not OPEN.empty(): + count += 1 + s = OPEN.get() + CLOSED.append(s) + + if s == self.s_goal: # reach the goal node + self.visited.append(CLOSED) + return "FOUND", self.extract_path(x_start, PARENT) + + for s_n in self.get_neighbor(s): + if s_n not in CLOSED: + new_cost = g_table[s] + self.cost(s, s_n) + if s_n not in g_table: + g_table[s_n] = float("inf") + if new_cost < g_table[s_n]: # conditions for updating Cost + g_table[s_n] = new_cost + PARENT[s_n] = s + OPEN.put(s_n, g_table[s_n] + self.h_table[s_n]) + + if count == N: # expand needed CLOSED nodes + break + + self.visited.append(CLOSED) # visited nodes in each iteration + + return OPEN, CLOSED + + def get_neighbor(self, s): + """ + find neighbors of state s that not in obstacles. + :param s: state + :return: neighbors + """ + + s_list = [] + + for u in self.u_set: + s_next = tuple([s[i] + u[i] for i in range(2)]) + if s_next not in self.obs: + s_list.append(s_next) + + return s_list + + def extract_path(self, x_start, parent): + """ + Extract the path based on the relationship of nodes. + + :return: The planning path + """ + + path_back = [self.s_goal] + x_current = self.s_goal + + while True: + x_current = parent[x_current] + path_back.append(x_current) + + if x_current == x_start: + break + + return list(reversed(path_back)) + + def h(self, s): + """ + Calculate heuristic. + :param s: current node (state) + :return: heuristic function value + """ + + heuristic_type = self.heuristic_type # heuristic type + goal = self.s_goal # goal node + + if heuristic_type == "manhattan": + return abs(goal[0] - s[0]) + abs(goal[1] - s[1]) + else: + return math.hypot(goal[0] - s[0], goal[1] - s[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return float("inf") + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + +def main(): + s_start = (10, 5) + s_goal = (45, 25) + + lrta = LrtAStarN(s_start, s_goal, 250, "euclidean") + plot = plotting.Plotting(s_start, s_goal) + + lrta.searching() + plot.animation_lrta(lrta.path, lrta.visited, + "Learning Real-time A* (LRTA*)") + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/RTAAStar.py b/src/Search_2D/RTAAStar.py new file mode 100644 index 0000000..de0a615 --- /dev/null +++ b/src/Search_2D/RTAAStar.py @@ -0,0 +1,237 @@ +""" +RTAAstar 2D (Real-time Adaptive A*) +@author: huiming zhou +""" + +import os +import sys +import copy +import math + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import queue, plotting, env + + +class RTAAStar: + def __init__(self, s_start, s_goal, N, heuristic_type): + self.s_start, self.s_goal = s_start, s_goal + self.heuristic_type = heuristic_type + + self.Env = env.Env() + + self.u_set = self.Env.motions # feasible input set + self.obs = self.Env.obs # position of obstacles + + self.N = N # number of expand nodes each iteration + self.visited = [] # order of visited nodes in planning + self.path = [] # path of each iteration + self.h_table = {} # h_value table + + def init(self): + """ + initialize the h_value of all nodes in the environment. + it is a global table. + """ + + for i in range(self.Env.x_range): + for j in range(self.Env.y_range): + self.h_table[(i, j)] = self.h((i, j)) + + def searching(self): + self.init() + s_start = self.s_start # initialize start node + + while True: + OPEN, CLOSED, g_table, PARENT = \ + self.Astar(s_start, self.N) + + if OPEN == "FOUND": # reach the goal node + self.path.append(CLOSED) + break + + s_next, h_value = self.cal_h_value(OPEN, CLOSED, g_table, PARENT) + + for x in h_value: + self.h_table[x] = h_value[x] + + s_start, path_k = self.extract_path_in_CLOSE(s_start, s_next, h_value) + self.path.append(path_k) + + def cal_h_value(self, OPEN, CLOSED, g_table, PARENT): + v_open = {} + h_value = {} + for (_, x) in OPEN.enumerate(): + v_open[x] = g_table[PARENT[x]] + 1 + self.h_table[x] + s_open = min(v_open, key=v_open.get) + f_min = v_open[s_open] + for x in CLOSED: + h_value[x] = f_min - g_table[x] + + return s_open, h_value + + def iteration(self, CLOSED): + h_value = {} + + for s in CLOSED: + h_value[s] = float("inf") # initialize h_value of CLOSED nodes + + while True: + h_value_rec = copy.deepcopy(h_value) + for s in CLOSED: + h_list = [] + for s_n in self.get_neighbor(s): + if s_n not in CLOSED: + h_list.append(self.cost(s, s_n) + self.h_table[s_n]) + else: + h_list.append(self.cost(s, s_n) + h_value[s_n]) + h_value[s] = min(h_list) # update h_value of current node + + if h_value == h_value_rec: # h_value table converged + return h_value + + def Astar(self, x_start, N): + OPEN = queue.QueuePrior() # OPEN set + OPEN.put(x_start, self.h_table[x_start]) + CLOSED = [] # CLOSED set + g_table = {x_start: 0, self.s_goal: float("inf")} # Cost to come + PARENT = {x_start: x_start} # relations + count = 0 # counter + + while not OPEN.empty(): + count += 1 + s = OPEN.get() + CLOSED.append(s) + + if s == self.s_goal: # reach the goal node + self.visited.append(CLOSED) + return "FOUND", self.extract_path(x_start, PARENT), [], [] + + for s_n in self.get_neighbor(s): + if s_n not in CLOSED: + new_cost = g_table[s] + self.cost(s, s_n) + if s_n not in g_table: + g_table[s_n] = float("inf") + if new_cost < g_table[s_n]: # conditions for updating Cost + g_table[s_n] = new_cost + PARENT[s_n] = s + OPEN.put(s_n, g_table[s_n] + self.h_table[s_n]) + + if count == N: # expand needed CLOSED nodes + break + + self.visited.append(CLOSED) # visited nodes in each iteration + + return OPEN, CLOSED, g_table, PARENT + + def get_neighbor(self, s): + """ + find neighbors of state s that not in obstacles. + :param s: state + :return: neighbors + """ + + s_list = set() + + for u in self.u_set: + s_next = tuple([s[i] + u[i] for i in range(2)]) + if s_next not in self.obs: + s_list.add(s_next) + + return s_list + + def extract_path_in_CLOSE(self, s_end, s_start, h_value): + path = [s_start] + s = s_start + + while True: + h_list = {} + for s_n in self.get_neighbor(s): + if s_n in h_value: + h_list[s_n] = h_value[s_n] + s_key = max(h_list, key=h_list.get) # move to the smallest node with min h_value + path.append(s_key) # generate path + s = s_key # use end of this iteration as the start of next + + if s_key == s_end: # reach the expected node in OPEN set + return s_start, list(reversed(path)) + + def extract_path(self, x_start, parent): + """ + Extract the path based on the relationship of nodes. + :return: The planning path + """ + + path = [self.s_goal] + s = self.s_goal + + while True: + s = parent[s] + path.append(s) + if s == x_start: + break + + return list(reversed(path)) + + def h(self, s): + """ + Calculate heuristic. + :param s: current node (state) + :return: heuristic function value + """ + + heuristic_type = self.heuristic_type # heuristic type + goal = self.s_goal # goal node + + if heuristic_type == "manhattan": + return abs(goal[0] - s[0]) + abs(goal[1] - s[1]) + else: + return math.hypot(goal[0] - s[0], goal[1] - s[1]) + + def cost(self, s_start, s_goal): + """ + Calculate Cost for this motion + :param s_start: starting node + :param s_goal: end node + :return: Cost for this motion + :note: Cost function could be more complicate! + """ + + if self.is_collision(s_start, s_goal): + return float("inf") + + return math.hypot(s_goal[0] - s_start[0], s_goal[1] - s_start[1]) + + def is_collision(self, s_start, s_end): + if s_start in self.obs or s_end in self.obs: + return True + + if s_start[0] != s_end[0] and s_start[1] != s_end[1]: + if s_end[0] - s_start[0] == s_start[1] - s_end[1]: + s1 = (min(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + else: + s1 = (min(s_start[0], s_end[0]), max(s_start[1], s_end[1])) + s2 = (max(s_start[0], s_end[0]), min(s_start[1], s_end[1])) + + if s1 in self.obs or s2 in self.obs: + return True + + return False + + +def main(): + s_start = (10, 5) + s_goal = (45, 25) + + rtaa = RTAAStar(s_start, s_goal, 240, "euclidean") + plot = plotting.Plotting(s_start, s_goal) + + rtaa.searching() + plot.animation_lrta(rtaa.path, rtaa.visited, + "Real-time Adaptive A* (RTAA*)") + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/__pycache__/Astar.cpython-38.pyc b/src/Search_2D/__pycache__/Astar.cpython-38.pyc new file mode 100644 index 0000000..7d90ba3 Binary files /dev/null and b/src/Search_2D/__pycache__/Astar.cpython-38.pyc differ diff --git a/src/Search_2D/__pycache__/env.cpython-37.pyc b/src/Search_2D/__pycache__/env.cpython-37.pyc new file mode 100644 index 0000000..945aa4d Binary files /dev/null and b/src/Search_2D/__pycache__/env.cpython-37.pyc differ diff --git a/src/Search_2D/__pycache__/env.cpython-38.pyc b/src/Search_2D/__pycache__/env.cpython-38.pyc new file mode 100644 index 0000000..e45c75b Binary files /dev/null and b/src/Search_2D/__pycache__/env.cpython-38.pyc differ diff --git a/src/Search_2D/__pycache__/env.cpython-39.pyc b/src/Search_2D/__pycache__/env.cpython-39.pyc new file mode 100644 index 0000000..4776345 Binary files /dev/null and b/src/Search_2D/__pycache__/env.cpython-39.pyc differ diff --git a/src/Search_2D/__pycache__/plotting.cpython-37.pyc b/src/Search_2D/__pycache__/plotting.cpython-37.pyc new file mode 100644 index 0000000..8a41db2 Binary files /dev/null and b/src/Search_2D/__pycache__/plotting.cpython-37.pyc differ diff --git a/src/Search_2D/__pycache__/plotting.cpython-38.pyc b/src/Search_2D/__pycache__/plotting.cpython-38.pyc new file mode 100644 index 0000000..5e8cff3 Binary files /dev/null and b/src/Search_2D/__pycache__/plotting.cpython-38.pyc differ diff --git a/src/Search_2D/__pycache__/plotting.cpython-39.pyc b/src/Search_2D/__pycache__/plotting.cpython-39.pyc new file mode 100644 index 0000000..c381ea6 Binary files /dev/null and b/src/Search_2D/__pycache__/plotting.cpython-39.pyc differ diff --git a/src/Search_2D/__pycache__/queue.cpython-37.pyc b/src/Search_2D/__pycache__/queue.cpython-37.pyc new file mode 100644 index 0000000..6c5f684 Binary files /dev/null and b/src/Search_2D/__pycache__/queue.cpython-37.pyc differ diff --git a/src/Search_2D/__pycache__/queue.cpython-38.pyc b/src/Search_2D/__pycache__/queue.cpython-38.pyc new file mode 100644 index 0000000..69c46c6 Binary files /dev/null and b/src/Search_2D/__pycache__/queue.cpython-38.pyc differ diff --git a/src/Search_2D/bfs.py b/src/Search_2D/bfs.py new file mode 100644 index 0000000..881e7ff --- /dev/null +++ b/src/Search_2D/bfs.py @@ -0,0 +1,69 @@ +""" +Breadth-first Searching_2D (BFS) +@author: huiming zhou +""" + +import os +import sys +from collections import deque + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env +from Search_2D.Astar import AStar +import math +import heapq + +class BFS(AStar): + """BFS add the new visited node in the end of the openset + """ + def searching(self): + """ + Breadth-first Searching. + :return: path, visited order + """ + + self.PARENT[self.s_start] = self.s_start + self.g[self.s_start] = 0 + self.g[self.s_goal] = math.inf + heapq.heappush(self.OPEN, + (0, self.s_start)) + + while self.OPEN: + _, s = heapq.heappop(self.OPEN) + self.CLOSED.append(s) + + if s == self.s_goal: + break + + for s_n in self.get_neighbor(s): + new_cost = self.g[s] + self.cost(s, s_n) + + if s_n not in self.g: + self.g[s_n] = math.inf + + if new_cost < self.g[s_n]: # conditions for updating Cost + self.g[s_n] = new_cost + self.PARENT[s_n] = s + + # bfs, add new node to the end of the openset + prior = self.OPEN[-1][0]+1 if len(self.OPEN)>0 else 0 + heapq.heappush(self.OPEN, (prior, s_n)) + + return self.extract_path(self.PARENT), self.CLOSED + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + bfs = BFS(s_start, s_goal, 'None') + plot = plotting.Plotting(s_start, s_goal) + + path, visited = bfs.searching() + plot.animation(path, visited, "Breadth-first Searching (BFS)") + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/dfs.py b/src/Search_2D/dfs.py new file mode 100644 index 0000000..3b30b03 --- /dev/null +++ b/src/Search_2D/dfs.py @@ -0,0 +1,65 @@ + +import os +import sys +import math +import heapq + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import plotting, env +from Search_2D.Astar import AStar + +class DFS(AStar): + """DFS add the new visited node in the front of the openset + """ + def searching(self): + """ + Breadth-first Searching. + :return: path, visited order + """ + + self.PARENT[self.s_start] = self.s_start + self.g[self.s_start] = 0 + self.g[self.s_goal] = math.inf + heapq.heappush(self.OPEN, + (0, self.s_start)) + + while self.OPEN: + _, s = heapq.heappop(self.OPEN) + self.CLOSED.append(s) + + if s == self.s_goal: + break + + for s_n in self.get_neighbor(s): + new_cost = self.g[s] + self.cost(s, s_n) + + if s_n not in self.g: + self.g[s_n] = math.inf + + if new_cost < self.g[s_n]: # conditions for updating Cost + self.g[s_n] = new_cost + self.PARENT[s_n] = s + + # dfs, add new node to the front of the openset + prior = self.OPEN[0][0]-1 if len(self.OPEN)>0 else 0 + heapq.heappush(self.OPEN, (prior, s_n)) + + return self.extract_path(self.PARENT), self.CLOSED + + +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + dfs = DFS(s_start, s_goal, 'None') + plot = plotting.Plotting(s_start, s_goal) + + path, visited = dfs.searching() + visited = list(dict.fromkeys(visited)) + plot.animation(path, visited, "Depth-first Searching (DFS)") # animation + + +if __name__ == '__main__': + main() diff --git a/src/Search_2D/env.py b/src/Search_2D/env.py new file mode 100644 index 0000000..9523c98 --- /dev/null +++ b/src/Search_2D/env.py @@ -0,0 +1,52 @@ +""" +Env 2D +@author: huiming zhou +""" + + +class Env: + def __init__(self): + self.x_range = 51 # size of background + self.y_range = 31 + self.motions = [(-1, 0), (-1, 1), (0, 1), (1, 1), + (1, 0), (1, -1), (0, -1), (-1, -1)] + self.obs = self.obs_map() + + def update_obs(self, obs): + self.obs = obs + + def obs_map(self): + """ + Initialize obstacles' positions + :return: map of obstacles + """ + + x = self.x_range #51 + y = self.y_range #31 + obs = set() + #画上下边框 + for i in range(x): + obs.add((i, 0)) + for i in range(x): + obs.add((i, y - 1)) + #画左右边框 + for i in range(y): + obs.add((0, i)) + for i in range(y): + obs.add((x - 1, i)) + + for i in range(2, 21): + obs.add((i, 15)) + for i in range(15): + obs.add((20, i)) + + for i in range(15, 30): + obs.add((30, i)) + for i in range(16): + obs.add((40, i)) + + return obs + +# if __name__ == '__main__': +# a = Env() +# print(a.obs) \ No newline at end of file diff --git a/src/Search_2D/plotting.py b/src/Search_2D/plotting.py new file mode 100644 index 0000000..1cf98a3 --- /dev/null +++ b/src/Search_2D/plotting.py @@ -0,0 +1,165 @@ +""" +Plot tools 2D +@author: huiming zhou +""" + +import os +import sys +import matplotlib.pyplot as plt + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + + "/../../Search_based_Planning/") + +from Search_2D import env + + +class Plotting: + def __init__(self, xI, xG): + self.xI, self.xG = xI, xG + self.env = env.Env() + self.obs = self.env.obs_map() + + def update_obs(self, obs): + self.obs = obs + + def animation(self, path, visited, name): + self.plot_grid(name) + self.plot_visited(visited) + self.plot_path(path) + plt.show() + + def animation_lrta(self, path, visited, name): + self.plot_grid(name) + cl = self.color_list_2() + path_combine = [] + + for k in range(len(path)): + self.plot_visited(visited[k], cl[k]) + plt.pause(0.2) + self.plot_path(path[k]) + path_combine += path[k] + plt.pause(0.2) + if self.xI in path_combine: + path_combine.remove(self.xI) + self.plot_path(path_combine) + plt.show() + + def animation_ara_star(self, path, visited, name): + self.plot_grid(name) + cl_v, cl_p = self.color_list() + + for k in range(len(path)): + self.plot_visited(visited[k], cl_v[k]) + self.plot_path(path[k], cl_p[k], True) + plt.pause(0.5) + + plt.show() + + def animation_bi_astar(self, path, v_fore, v_back, name): + self.plot_grid(name) + self.plot_visited_bi(v_fore, v_back) + self.plot_path(path) + plt.show() + + def plot_grid(self, name): + obs_x = [x[0] for x in self.obs] + obs_y = [x[1] for x in self.obs] + + plt.plot(self.xI[0], self.xI[1], "bs") + plt.plot(self.xG[0], self.xG[1], "gs") + plt.plot(obs_x, obs_y, "sk") + plt.title(name) + plt.axis("equal") + + def plot_visited(self, visited, cl='gray'): + if self.xI in visited: + visited.remove(self.xI) + + if self.xG in visited: + visited.remove(self.xG) + + count = 0 + + for x in visited: + count += 1 + plt.plot(x[0], x[1], color=cl, marker='o') + plt.gcf().canvas.mpl_connect('key_release_event', + lambda event: [exit(0) if event.key == 'escape' else None]) + + if count < len(visited) / 3: + length = 20 + elif count < len(visited) * 2 / 3: + length = 30 + else: + length = 40 + # + # length = 15 + + if count % length == 0: + plt.pause(0.001) + plt.pause(0.01) + + def plot_path(self, path, cl='r', flag=False): + path_x = [path[i][0] for i in range(len(path))] + path_y = [path[i][1] for i in range(len(path))] + + if not flag: + plt.plot(path_x, path_y, linewidth='3', color='r') + else: + plt.plot(path_x, path_y, linewidth='3', color=cl) + + plt.plot(self.xI[0], self.xI[1], "bs") + plt.plot(self.xG[0], self.xG[1], "gs") + + plt.pause(0.01) + + def plot_visited_bi(self, v_fore, v_back): + if self.xI in v_fore: + v_fore.remove(self.xI) + + if self.xG in v_back: + v_back.remove(self.xG) + + len_fore, len_back = len(v_fore), len(v_back) + + for k in range(max(len_fore, len_back)): + if k < len_fore: + plt.plot(v_fore[k][0], v_fore[k][1], linewidth='3', color='gray', marker='o') + if k < len_back: + plt.plot(v_back[k][0], v_back[k][1], linewidth='3', color='cornflowerblue', marker='o') + + plt.gcf().canvas.mpl_connect('key_release_event', + lambda event: [exit(0) if event.key == 'escape' else None]) + + if k % 10 == 0: + plt.pause(0.001) + plt.pause(0.01) + + @staticmethod + def color_list(): + cl_v = ['silver', + 'wheat', + 'lightskyblue', + 'royalblue', + 'slategray'] + cl_p = ['gray', + 'orange', + 'deepskyblue', + 'red', + 'm'] + return cl_v, cl_p + + @staticmethod + def color_list_2(): + cl = ['silver', + 'steelblue', + 'dimgray', + 'cornflowerblue', + 'dodgerblue', + 'royalblue', + 'plum', + 'mediumslateblue', + 'mediumpurple', + 'blueviolet', + ] + return cl diff --git a/src/Search_2D/queue.py b/src/Search_2D/queue.py new file mode 100644 index 0000000..51703ae --- /dev/null +++ b/src/Search_2D/queue.py @@ -0,0 +1,62 @@ +import collections +import heapq + + +class QueueFIFO: + """ + Class: QueueFIFO + Description: QueueFIFO is designed for First-in-First-out rule. + """ + + def __init__(self): + self.queue = collections.deque() + + def empty(self): + return len(self.queue) == 0 + + def put(self, node): + self.queue.append(node) # enter from back + + def get(self): + return self.queue.popleft() # leave from front + + +class QueueLIFO: + """ + Class: QueueLIFO + Description: QueueLIFO is designed for Last-in-First-out rule. + """ + + def __init__(self): + self.queue = collections.deque() + + def empty(self): + return len(self.queue) == 0 + + def put(self, node): + self.queue.append(node) # enter from back + + def get(self): + return self.queue.pop() # leave from back + + +class QueuePrior: + """ + Class: QueuePrior + Description: QueuePrior reorders elements using value [priority] + """ + + def __init__(self): + self.queue = [] + + def empty(self): + return len(self.queue) == 0 + + def put(self, item, priority): + heapq.heappush(self.queue, (priority, item)) # reorder s using priority + + def get(self): + return heapq.heappop(self.queue)[1] # pop out the smallest item + + def enumerate(self): + return self.queue diff --git a/src/Tello/KeyPress.py b/src/Tello/KeyPress.py new file mode 100644 index 0000000..66e9f94 --- /dev/null +++ b/src/Tello/KeyPress.py @@ -0,0 +1,19 @@ +# @Time : 2022/5/9 20:49 +# @Author : 2890199310@qq.com +# @File : KeyPress.py +# @Software: PyCharm +# @Function: + +def main(): + keyPress() + +def keyPress(key): + if(key == 1): + return "e" + +def result(): + return keyPress() + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/src/Tello/KeyPressModule.py b/src/Tello/KeyPressModule.py new file mode 100644 index 0000000..bd7182a --- /dev/null +++ b/src/Tello/KeyPressModule.py @@ -0,0 +1,31 @@ +# @Time : 2022/4/20 12:27 +# @Author : 2890199310@qq.com +# @File : KeyPressModule.py.py +# @Software: PyCharm +# @Function: +import os +import sys +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../PaddleClas-release-2.3") + +# import pygame +import Tello.KeyPress as k + +def init(): + return + +def getKey(keyName): + # ans = False + # for eve in pygame.event.get(): pass + # keyInput = pygame.key.get_pressed() + # myKey = getattr(pygame,'K_{}'.format(keyName)) + # if keyInput[myKey]: + if keyName == k.result(): + ans = True + # pygame.display.update() + return ans + +def key(a): + return a + +if __name__ == '__main__': + init() \ No newline at end of file diff --git a/src/Tello/KeyboardControl.py b/src/Tello/KeyboardControl.py new file mode 100644 index 0000000..6997c9f --- /dev/null +++ b/src/Tello/KeyboardControl.py @@ -0,0 +1,105 @@ +# @Time : 2022/4/20 12:27 +# @Author : 2890199310@qq.com +# @File : KeyboardControl.py.py +# @Software: PyCharm +# @Function: +import os +import sys +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../PaddleClas-release-2.3") +import logging +import time +import cv2 +from djitellopy import tello +# import Tello.KeyPressModule as kp # 用于获取键盘按键 +from time import sleep + +# Tello初始化设置 +Drone = tello.Tello() # 创建飞行器对象 +Drone.connect() # 连接到飞行器 +Drone.streamon() # 开启视频传输 +Drone.LOGGER.setLevel(logging.ERROR) # 只显示错误信息 +sleep(5) # 等待视频初始化 +# kp.init() # 初始化按键处理模块 + +def getKeyboardInput(key): + image = cv2.resize(OriginalImage, (Camera_Width, Camera_Height)) + speed = 70 + drone = Drone + lr, fb, ud, yv = 0, 0, 0, 0 + key_pressed = 0 + # if kp.getKey("e"): # + if key == "e": + cv2.imwrite('D:/snap-{}.jpg'.format(time.strftime("%H%M%S", time.localtime())), image) + # if kp.getKey("UP"):# 上升 + if key == "UP": + Drone.takeoff() + # elif kp.getKey("DOWN"):#下降 + if key == "DOWN": + Drone.land() + + # if kp.getKey("j"):# 向左飞行 + if key == "j": + key_pressed = 1 + lr = -speed + # elif kp.getKey("l"): #向右飞行 + if key == "l": + key_pressed = 1 + lr = speed + + # if kp.getKey("i"): #向前飞行 + if key == "i": + key_pressed = 1 + fb = speed + # elif kp.getKey("k"):# 向后飞行 + if key == "k": + key_pressed = 1 + fb = -speed + + # if kp.getKey("w"):# 向上飞行 + if key == "w": + key_pressed = 1 + ud = speed + # elif kp.getKey("s"): #向下飞行 + if key == "s": + key_pressed = 1 + ud = -speed + + # if kp.getKey("a"): # 向左旋转 + if key == "a": + key_pressed = 1 + yv = -speed + # elif kp.getKey("d"): #向右旋转 + if key == "d": + key_pressed = 1 + yv = speed + InfoText = "battery : {0}% height: {1}cm time: {2}".format(drone.get_battery(), drone.get_height(), time.strftime("%H:%M:%S",time.localtime())) + cv2.putText(image, InfoText, (10, 20), font, fontScale, (0, 0, 255), lineThickness) + if key_pressed == 1: + InfoText = "Command : lr:{0}% fb:{1} ud:{2} yv:{3}".format(lr, fb, ud, yv) + cv2.putText(image, InfoText, (10, 40), font, fontScale, (0, 0, 255), lineThickness) + + drone.send_rc_control(lr, fb, ud, yv) + +# 主程序 +# 摄像头设置 +Camera_Width = 720 +Camera_Height = 480 +DetectRange = [6000, 11000] # DetectRange[0] 是保持静止的检测人脸面积阈值下限,DetectRange[0] 是保持静止的检测人脸面积阈值上限 +PID_Parameter = [0.5, 0.0004, 0.4] +pErrorRotate, pErrorUp = 0, 0 + +# 字体设置 +font = cv2.FONT_HERSHEY_SIMPLEX +fontScale = 0.5 +fontColor = (255, 0, 0) +lineThickness = 1 + + + + +while True: + OriginalImage = Drone.get_frame_read().frame + Image = cv2.resize(OriginalImage, (Camera_Width, Camera_Height)) + # getKeyboardInput(drone=Drone, speed=70, image=Image) # 按键控制 + cv2.imshow("Drone Control Centre", Image) + cv2.waitKey(1) \ No newline at end of file diff --git a/src/Tello/__pycache__/KeyPress.cpython-39.pyc b/src/Tello/__pycache__/KeyPress.cpython-39.pyc new file mode 100644 index 0000000..3608c27 Binary files /dev/null and b/src/Tello/__pycache__/KeyPress.cpython-39.pyc differ diff --git a/src/Tello/__pycache__/KeyPressModule.cpython-39.pyc b/src/Tello/__pycache__/KeyPressModule.cpython-39.pyc new file mode 100644 index 0000000..1114802 Binary files /dev/null and b/src/Tello/__pycache__/KeyPressModule.cpython-39.pyc differ diff --git a/src/Tello/__pycache__/KeyboardControl.cpython-39.pyc b/src/Tello/__pycache__/KeyboardControl.cpython-39.pyc new file mode 100644 index 0000000..aad69a2 Binary files /dev/null and b/src/Tello/__pycache__/KeyboardControl.cpython-39.pyc differ diff --git a/src/prepare/calculate.py b/src/prepare/calculate.py new file mode 100644 index 0000000..7182c26 --- /dev/null +++ b/src/prepare/calculate.py @@ -0,0 +1,12 @@ +# @Time : 2022/5/9 8:45 +# @Author : 2890199310@qq.com +# @File : calculate.py +# @Software: PyCharm +# @Function: +import os + +os.chdir(r'E:\PaddleClas-release-2.3\PaddleClas-release-2.3\deploy') + +#### + +os.system('python python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs="./Trees/test_images/90.jpeg" -o IndexProcess.index_dir="./Trees/index" -o Global.use_gpu=False -o IndexProcess.Image_root="./Trees/gallery/" -o IndexProcess.data_file="./Trees/gallery/tree_list.txt') diff --git a/src/prepare/change_file.py b/src/prepare/change_file.py new file mode 100644 index 0000000..2c06271 --- /dev/null +++ b/src/prepare/change_file.py @@ -0,0 +1,84 @@ +# @Time : 2022/4/19 9:41 +# @Author : 2890199310@qq.com +# @File : change_file.py +# @Software: PyCharm +# @Function: + +import os +import shutil + +# 读取文件名 +def readname(): + filepath = "/deploy/Trees/gallery/0" + name = os.listdir(filepath) + return name + +def main(): + gallery = os.path.abspath(r"/deploy/drink_dataset_v1.0/gallery") + all_files = os.listdir(gallery)[:-2] + all_files.sort(key=lambda x:int(x)) + # for file in all_files: + # print(file) + + for i in range(0, 102): #创建文件夹 + dire = "E:\\PaddleClas-release-2.3\\PaddleClas-release-2.3\\deploy\\flowers102\\gallery\\" + str(i) + if not os.path.exists(dire): + os.makedirs(dire) + print(f"{i}创建完毕") + f = open(r"/deploy/flowers102/train_extra_list.txt") + for line in f.readlines(): + base = "E://PaddleClas-release-2.3//PaddleClas-release-2.3/deploy//flowers102//" + s = line.split('/') + + str1 = s[0].strip() + "//" + str2 = s[1].split(' ')[0].strip() + str3 = s[1].split(' ')[1].strip() + "//" + # print(base + "gallery//" + str3 + str2) + + # 复制训练文件 + # shutil.copy(base + str1 + str2, base + "gallery/" + str3 + str2) + f.close() + + f = open(r"/deploy/flowers102/val_list.txt") + for line in f.readlines(): + base = "E://PaddleClas-release-2.3//PaddleClas-release-2.3/deploy//flowers102//" + s = line.split('/') + str1 = s[0].strip() + "//" + str2 = s[1].split(' ')[0].strip() + str3 = s[1].split(' ')[1].strip() + "//" + # 复制测试文件 + # shutil.copy(base + str1 + str2, base + "test_images/" + str2) + f.close() + + dit = dict() + + + with open(r"/deploy/flowers102/flowers102_label_list.txt", "r", encoding="utf-8") as f2: + for line in f2.readlines(): + tmp = line.split(' ', 1) + dit[tmp[0]] = tmp[1].strip() + #print(dit) + + #更改list内容 + with open(r"/deploy/flowers102/train_list.txt", "r", encoding="utf-8") as f1, open( + r"/deploy/flowers102/train_label.txt", "w", encoding="utf-8") as f3: + for line1 in f1.readlines(): + tmp1 = line1.split(' ', 1) + # f3.write(tmp1[1].strip() + '/' + tmp1[0].split('/', 1)[1].strip() + '\t' + dit[tmp1[1].strip()] + '\n') + + # print(line1) + # print(line2) + # break + f1.close() + f2.close() + f3.close() + with open(r"/deploy/Trees/gallery/tree_list.txt", "w", encoding="utf-8") as f1: + name = readname() + for i in name: + if('GIF' not in i): + f1.write('0/' + i + '\t' + 'tree\n') + f1.close() + + +if __name__ == '__main__': + main() diff --git a/src/prepare/spider.py b/src/prepare/spider.py new file mode 100644 index 0000000..0373296 --- /dev/null +++ b/src/prepare/spider.py @@ -0,0 +1,5 @@ +# @Time : 2022/4/19 9:54 +# @Author : 2890199310@qq.com +# @File : spider.py +# @Software: PyCharm +# @Function: