「这是我参与2022首次更文挑战的第30天,活动详情查看:2022首次更文挑战」。
Oxford 102 Flowers Dataset 是一个花卉集合数据集,主要用于图像分类,它分为 102 个类别共计 102 种花,其中每个类别包含 40 到 258 张图像。
该数据集由牛津大学工程科学系于 2008 年发布,相关论文有《Automated flower classification over a large number of classes》。
在文件夹下已经生成用于训练和测试的三个.txt文件:train.txt(训练集,1020张图)、valid.txt(验证集,1020张图)、test.txt(6149)。文件中每行格式:图像相对路径 图像的label_id(注意:中间有空格)。
PaddleClas目前已经是 release2.3了,和以前有脱胎换骨的差别,所以需要重新熟悉。
地址: gitee.com/paddlepaddl…
configs已经移动到了ppcls目录 部署为单独的deploy目录
# 解压缩数据集 !tar -xvf data/data19852/flowers102.tar -C ./data/
# 下载最新版 !git clone https://gitee.com/paddlepaddle/PaddleClas/ --depth=1
Cloning into 'PaddleClas'... remote: Enumerating objects: 1420, done.[K remote: Counting objects: 100% (1420/1420), done.[K remote: Compressing objects: 100% (1256/1256), done.[K remote: Total 1420 (delta 326), reused 967 (delta 138), pack-reused 0[K Receiving objects: 100% (1420/1420), 92.84 MiB | 2.32 MiB/s, done. Resolving deltas: 100% (326/326), done. Checking connectivity... done.
%cd PaddleClas/
/home/aistudio/PaddleClas
目录: ppclsdatadataloaderimagenet_dataset.py
修改原因是目录这块存在bug,注释:
assert os.path.exists(self._cls_path) assert os.path.exists(self._img_root)添加
self._cls_path=os.path.join(self._img_root,self._cls_path)否则不能使用相对路径
class ImageNetDataset(CommonDataset): def _load_anno(self, seed=None): 会对目录进行检测,如果cls_path使用相对目录,就会报错,在此注释掉,并修改为self._cls_path=os.path.join(self._img_root,self._cls_path) # assert os.path.exists(self._cls_path) # assert os.path.exists(self._img_root) self._cls_path=os.path.join(self._img_root,self._cls_path) print('self._cls_path',self._cls_path) 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(int(l[1])) assert os.path.exists(self.images[-1])
# global configs Global: checkpoints: null pretrained_model: null output_dir: ./output/ # gpu或cpu配置 device: gpu # 分类数量 class_num: 102 # 保存间隔 save_interval: 5 # 是否再训练立案过程中进行eval eval_during_train: True # eval间隔 eval_interval: 5 # 训练轮数 epochs: 20 # 打印batch step设置 print_batch_step: 10 # 是否使用visualdl 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 # 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: /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ cls_label_path: train.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: /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ cls_label_path: valid.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: /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ 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: /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00030.jpg Metric: Train: - TopkAcc: topk: [1, 5] Eval: - TopkAcc: topk: [1, 5] -c 参数是指定训练的配置文件路径,训练的具体超参数可查看yaml文件 yaml文Global.device 参数设置为cpu,即使用CPU进行训练(若不设置,此参数默认为True) yaml文件中epochs参数设置为20,说明对整个数据集进行20个epoch迭代,预计训练20分钟左右(不同CPU,训练时间略有不同),此时训练模型不充分。若提高训练模型精度,请将此参数设大,如40,训练时间也会相应延长
# GPU设置 !export CUDA_VISIBLE_DEVICES=0 # -o Arch.pretrained=True 使用预训练模型,当选择为True时,预训练权重会自动下载到本地 !python tools/train.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Arch.pretrained=True
训练日志如下
[2021/10/31 01:53:47] root INFO: [Train][Epoch 16/20][Iter: 0/4]lr: 0.00285, top1: 0.93750, top5: 0.96484, CELoss: 0.36489, loss: 0.36489, batch_cost: 1.48066s, reader_cost: 0.68550, ips: 172.89543 images/sec, eta: 0:00:29 [2021/10/31 01:53:49] root INFO: [Train][Epoch 16/20][Avg]top1: 0.95098, top5: 0.97745, CELoss: 0.31581, loss: 0.31581 [2021/10/31 01:53:53] root INFO: [Train][Epoch 17/20][Iter: 0/4]lr: 0.00183, top1: 0.94531, top5: 0.97656, CELoss: 0.32916, loss: 0.32916, batch_cost: 1.47958s, reader_cost: 0.68473, ips: 173.02266 images/sec, eta: 0:00:23 [2021/10/31 01:53:55] root INFO: [Train][Epoch 17/20][Avg]top1: 0.95686, top5: 0.98137, CELoss: 0.29560, loss: 0.29560 [2021/10/31 01:53:58] root INFO: [Train][Epoch 18/20][Iter: 0/4]lr: 0.00101, top1: 0.93750, top5: 0.98047, CELoss: 0.31542, loss: 0.31542, batch_cost: 1.47524s, reader_cost: 0.68058, ips: 173.53117 images/sec, eta: 0:00:17 [2021/10/31 01:54:01] root INFO: [Train][Epoch 18/20][Avg]top1: 0.94608, top5: 0.98627, CELoss: 0.29086, loss: 0.29086 [2021/10/31 01:54:04] root INFO: [Train][Epoch 19/20][Iter: 0/4]lr: 0.00042, top1: 0.97266, top5: 0.98438, CELoss: 0.24642, loss: 0.24642, batch_cost: 1.47376s, reader_cost: 0.67916, ips: 173.70590 images/sec, eta: 0:00:11 [2021/10/31 01:54:07] root INFO: [Train][Epoch 19/20][Avg]top1: 0.94608, top5: 0.97941, CELoss: 0.30998, loss: 0.30998 [2021/10/31 01:54:10] root INFO: [Train][Epoch 20/20][Iter: 0/4]lr: 0.00008, top1: 0.98047, top5: 0.98438, CELoss: 0.20209, loss: 0.20209, batch_cost: 1.47083s, reader_cost: 0.67647, ips: 174.05180 images/sec, eta: 0:00:05 [2021/10/31 01:54:13] root INFO: [Train][Epoch 20/20][Avg]top1: 0.95784, top5: 0.98922, CELoss: 0.25974, loss: 0.25974 [2021/10/31 01:54:16] root INFO: [Eval][Epoch 20][Iter: 0/4]CELoss: 0.47912, loss: 0.47912, top1: 0.91797, top5: 0.96094, batch_cost: 3.26175s, reader_cost: 3.02034, ips: 78.48538 images/sec [2021/10/31 01:54:17] root INFO: [Eval][Epoch 20][Avg]CELoss: 0.54982, loss: 0.54982, top1: 0.88922, top5: 0.96667 [2021/10/31 01:54:18] root INFO: Already save model in ./output/ResNet50_vd/best_model [2021/10/31 01:54:18] root INFO: [Eval][Epoch 20][best metric: 0.8892156844045601] [2021/10/31 01:54:18] root INFO: Already save model in ./output/ResNet50_vd/epoch_20 [2021/10/31 01:54:18] root INFO: Already save model in ./output/ResNet50_vd/latest
可见日志输出比较混乱,没有以前那么清晰,最好使用visualdl来查看训练情况
from PIL import Image img=Image.open('/home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg') img
# 预测 !python3 tools/infer.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Infer.infer_imgs=/home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg -o Global.pretrained_model=output/ResNet50_vd/best_model
/home/aistudio/PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py:15: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Callable [2021/10/31 02:02:53] root INFO: =========================================================== == PaddleClas is powered by PaddlePaddle ! == =========================================================== == == == For more info please go to the following website. == == == == https://github.com/PaddlePaddle/PaddleClas == =========================================================== [2021/10/31 02:02:53] root INFO: Arch : [2021/10/31 02:02:53] root INFO: name : ResNet50_vd [2021/10/31 02:02:53] root INFO: DataLoader : [2021/10/31 02:02:53] root INFO: Eval : [2021/10/31 02:02:53] root INFO: dataset : [2021/10/31 02:02:53] root INFO: cls_label_path : valid.txt [2021/10/31 02:02:53] root INFO: image_root : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:02:53] root INFO: name : ImageNetDataset [2021/10/31 02:02:53] root INFO: transform_ops : [2021/10/31 02:02:53] root INFO: DecodeImage : [2021/10/31 02:02:53] root INFO: channel_first : False [2021/10/31 02:02:53] root INFO: to_rgb : True [2021/10/31 02:02:53] root INFO: ResizeImage : [2021/10/31 02:02:53] root INFO: resize_short : 256 [2021/10/31 02:02:53] root INFO: CropImage : [2021/10/31 02:02:53] root INFO: size : 224 [2021/10/31 02:02:53] root INFO: NormalizeImage : [2021/10/31 02:02:53] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:02:53] root INFO: order : [2021/10/31 02:02:53] root INFO: scale : 1.0/255.0 [2021/10/31 02:02:53] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:02:53] root INFO: loader : [2021/10/31 02:02:53] root INFO: num_workers : 4 [2021/10/31 02:02:53] root INFO: use_shared_memory : True [2021/10/31 02:02:53] root INFO: sampler : [2021/10/31 02:02:53] root INFO: batch_size : 256 [2021/10/31 02:02:53] root INFO: drop_last : False [2021/10/31 02:02:53] root INFO: name : DistributedBatchSampler [2021/10/31 02:02:53] root INFO: shuffle : False [2021/10/31 02:02:53] root INFO: Train : [2021/10/31 02:02:53] root INFO: dataset : [2021/10/31 02:02:53] root INFO: cls_label_path : train.txt [2021/10/31 02:02:53] root INFO: image_root : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:02:53] root INFO: name : ImageNetDataset [2021/10/31 02:02:53] root INFO: transform_ops : [2021/10/31 02:02:53] root INFO: DecodeImage : [2021/10/31 02:02:53] root INFO: channel_first : False [2021/10/31 02:02:53] root INFO: to_rgb : True [2021/10/31 02:02:53] root INFO: RandCropImage : [2021/10/31 02:02:53] root INFO: size : 224 [2021/10/31 02:02:53] root INFO: RandFlipImage : [2021/10/31 02:02:53] root INFO: flip_code : 1 [2021/10/31 02:02:53] root INFO: NormalizeImage : [2021/10/31 02:02:53] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:02:53] root INFO: order : [2021/10/31 02:02:53] root INFO: scale : 1.0/255.0 [2021/10/31 02:02:53] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:02:53] root INFO: loader : [2021/10/31 02:02:53] root INFO: num_workers : 4 [2021/10/31 02:02:53] root INFO: use_shared_memory : True [2021/10/31 02:02:53] root INFO: sampler : [2021/10/31 02:02:53] root INFO: batch_size : 256 [2021/10/31 02:02:53] root INFO: drop_last : False [2021/10/31 02:02:53] root INFO: name : DistributedBatchSampler [2021/10/31 02:02:53] root INFO: shuffle : True [2021/10/31 02:02:53] root INFO: Global : [2021/10/31 02:02:53] root INFO: checkpoints : None [2021/10/31 02:02:53] root INFO: class_num : 102 [2021/10/31 02:02:53] root INFO: device : gpu [2021/10/31 02:02:53] root INFO: epochs : 20 [2021/10/31 02:02:53] root INFO: eval_during_train : True [2021/10/31 02:02:53] root INFO: eval_interval : 5 [2021/10/31 02:02:53] root INFO: image_shape : [3, 224, 224] [2021/10/31 02:02:53] root INFO: output_dir : ./output/ [2021/10/31 02:02:53] root INFO: pretrained_model : output/ResNet50_vd/best_model [2021/10/31 02:02:53] root INFO: print_batch_step : 10 [2021/10/31 02:02:53] root INFO: save_inference_dir : ./inference [2021/10/31 02:02:53] root INFO: save_interval : 5 [2021/10/31 02:02:53] root INFO: use_visualdl : False [2021/10/31 02:02:53] root INFO: Infer : [2021/10/31 02:02:53] root INFO: PostProcess : [2021/10/31 02:02:53] root INFO: class_id_map_file : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00030.jpg [2021/10/31 02:02:53] root INFO: name : Topk [2021/10/31 02:02:53] root INFO: topk : 5 [2021/10/31 02:02:53] root INFO: batch_size : 10 [2021/10/31 02:02:53] root INFO: infer_imgs : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg [2021/10/31 02:02:53] root INFO: transforms : [2021/10/31 02:02:53] root INFO: DecodeImage : [2021/10/31 02:02:53] root INFO: channel_first : False [2021/10/31 02:02:53] root INFO: to_rgb : True [2021/10/31 02:02:53] root INFO: ResizeImage : [2021/10/31 02:02:53] root INFO: resize_short : 256 [2021/10/31 02:02:53] root INFO: CropImage : [2021/10/31 02:02:53] root INFO: size : 224 [2021/10/31 02:02:53] root INFO: NormalizeImage : [2021/10/31 02:02:53] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:02:53] root INFO: order : [2021/10/31 02:02:53] root INFO: scale : 1.0/255.0 [2021/10/31 02:02:53] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:02:53] root INFO: ToCHWImage : None [2021/10/31 02:02:53] root INFO: Loss : [2021/10/31 02:02:53] root INFO: Eval : [2021/10/31 02:02:53] root INFO: CELoss : [2021/10/31 02:02:53] root INFO: weight : 1.0 [2021/10/31 02:02:53] root INFO: Train : [2021/10/31 02:02:53] root INFO: CELoss : [2021/10/31 02:02:53] root INFO: weight : 1.0 [2021/10/31 02:02:53] root INFO: Metric : [2021/10/31 02:02:53] root INFO: Eval : [2021/10/31 02:02:53] root INFO: TopkAcc : [2021/10/31 02:02:53] root INFO: topk : [1, 5] [2021/10/31 02:02:53] root INFO: Train : [2021/10/31 02:02:53] root INFO: TopkAcc : [2021/10/31 02:02:53] root INFO: topk : [1, 5] [2021/10/31 02:02:53] root INFO: Optimizer : [2021/10/31 02:02:53] root INFO: lr : [2021/10/31 02:02:53] root INFO: learning_rate : 0.0125 [2021/10/31 02:02:53] root INFO: name : Cosine [2021/10/31 02:02:53] root INFO: warmup_epoch : 5 [2021/10/31 02:02:53] root INFO: momentum : 0.9 [2021/10/31 02:02:53] root INFO: name : Momentum [2021/10/31 02:02:53] root INFO: regularizer : [2021/10/31 02:02:53] root INFO: coeff : 1e-05 [2021/10/31 02:02:53] root INFO: name : L2 [2021/10/31 02:02:53] root INFO: train with paddle 2.1.2 and device CUDAPlace(0) W1031 02:02:53.626825 7656 device_context.cc:404] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1 W1031 02:02:53.631515 7656 device_context.cc:422] device: 0, cuDNN Version: 7.6. 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/tensor/creation.py:125: DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`. To silence this warning, use `object` by itself. Doing this will not modify any behavior and is safe. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations if data.dtype == np.object: [{'class_ids': [37, 35, 76, 28, 50], 'scores': [0.45998, 0.13054, 0.03585, 0.03207, 0.02833], 'file_name': '/home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg', 'label_names': []}]
可见,更新后的版本日志输出比较混乱。
最终输出
[{'class_ids': [37, 35, 76, 28, 50], 'scores': [0.45998, 0.13054, 0.03585, 0.03207, 0.02833], 'file_name': '/home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg', 'label_names': []}]
显示的是top5的概率,可见分类为37类。由于没有设置label_names,所以这处为空。
通过导出inference模型,PaddlePaddle支持使用预测引擎进行预测推理。
!python3 tools/export_model.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Global.pretrained_model=output/ResNet50_vd/best_model
/home/aistudio/PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py:15: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Callable [2021/10/31 02:30:38] root INFO: =========================================================== == PaddleClas is powered by PaddlePaddle ! == =========================================================== == == == For more info please go to the following website. == == == == https://github.com/PaddlePaddle/PaddleClas == =========================================================== [2021/10/31 02:30:38] root INFO: Arch : [2021/10/31 02:30:38] root INFO: name : ResNet50_vd [2021/10/31 02:30:38] root INFO: DataLoader : [2021/10/31 02:30:38] root INFO: Eval : [2021/10/31 02:30:38] root INFO: dataset : [2021/10/31 02:30:38] root INFO: cls_label_path : valid.txt [2021/10/31 02:30:38] root INFO: image_root : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:30:38] root INFO: name : ImageNetDataset [2021/10/31 02:30:38] root INFO: transform_ops : [2021/10/31 02:30:38] root INFO: DecodeImage : [2021/10/31 02:30:38] root INFO: channel_first : False [2021/10/31 02:30:38] root INFO: to_rgb : True [2021/10/31 02:30:38] root INFO: ResizeImage : [2021/10/31 02:30:38] root INFO: resize_short : 256 [2021/10/31 02:30:38] root INFO: CropImage : [2021/10/31 02:30:38] root INFO: size : 224 [2021/10/31 02:30:38] root INFO: NormalizeImage : [2021/10/31 02:30:38] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:30:38] root INFO: order : [2021/10/31 02:30:38] root INFO: scale : 1.0/255.0 [2021/10/31 02:30:38] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:30:38] root INFO: loader : [2021/10/31 02:30:38] root INFO: num_workers : 4 [2021/10/31 02:30:38] root INFO: use_shared_memory : True [2021/10/31 02:30:38] root INFO: sampler : [2021/10/31 02:30:38] root INFO: batch_size : 256 [2021/10/31 02:30:38] root INFO: drop_last : False [2021/10/31 02:30:38] root INFO: name : DistributedBatchSampler [2021/10/31 02:30:38] root INFO: shuffle : False [2021/10/31 02:30:38] root INFO: Train : [2021/10/31 02:30:38] root INFO: dataset : [2021/10/31 02:30:38] root INFO: cls_label_path : train.txt [2021/10/31 02:30:38] root INFO: image_root : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:30:38] root INFO: name : ImageNetDataset [2021/10/31 02:30:38] root INFO: transform_ops : [2021/10/31 02:30:38] root INFO: DecodeImage : [2021/10/31 02:30:38] root INFO: channel_first : False [2021/10/31 02:30:38] root INFO: to_rgb : True [2021/10/31 02:30:38] root INFO: RandCropImage : [2021/10/31 02:30:38] root INFO: size : 224 [2021/10/31 02:30:38] root INFO: RandFlipImage : [2021/10/31 02:30:38] root INFO: flip_code : 1 [2021/10/31 02:30:38] root INFO: NormalizeImage : [2021/10/31 02:30:38] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:30:38] root INFO: order : [2021/10/31 02:30:38] root INFO: scale : 1.0/255.0 [2021/10/31 02:30:38] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:30:38] root INFO: loader : [2021/10/31 02:30:38] root INFO: num_workers : 4 [2021/10/31 02:30:38] root INFO: use_shared_memory : True [2021/10/31 02:30:38] root INFO: sampler : [2021/10/31 02:30:38] root INFO: batch_size : 256 [2021/10/31 02:30:38] root INFO: drop_last : False [2021/10/31 02:30:38] root INFO: name : DistributedBatchSampler [2021/10/31 02:30:38] root INFO: shuffle : True [2021/10/31 02:30:38] root INFO: Global : [2021/10/31 02:30:38] root INFO: checkpoints : None [2021/10/31 02:30:38] root INFO: class_num : 102 [2021/10/31 02:30:38] root INFO: device : gpu [2021/10/31 02:30:38] root INFO: epochs : 20 [2021/10/31 02:30:38] root INFO: eval_during_train : True [2021/10/31 02:30:38] root INFO: eval_interval : 5 [2021/10/31 02:30:38] root INFO: image_shape : [3, 224, 224] [2021/10/31 02:30:38] root INFO: output_dir : ./output/ [2021/10/31 02:30:38] root INFO: pretrained_model : output/ResNet50_vd/best_model [2021/10/31 02:30:38] root INFO: print_batch_step : 10 [2021/10/31 02:30:38] root INFO: save_inference_dir : ./inference [2021/10/31 02:30:38] root INFO: save_interval : 5 [2021/10/31 02:30:38] root INFO: use_visualdl : False [2021/10/31 02:30:38] root INFO: Infer : [2021/10/31 02:30:38] root INFO: PostProcess : [2021/10/31 02:30:38] root INFO: class_id_map_file : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00030.jpg [2021/10/31 02:30:38] root INFO: name : Topk [2021/10/31 02:30:38] root INFO: topk : 5 [2021/10/31 02:30:38] root INFO: batch_size : 10 [2021/10/31 02:30:38] root INFO: infer_imgs : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:30:38] root INFO: transforms : [2021/10/31 02:30:38] root INFO: DecodeImage : [2021/10/31 02:30:38] root INFO: channel_first : False [2021/10/31 02:30:38] root INFO: to_rgb : True [2021/10/31 02:30:38] root INFO: ResizeImage : [2021/10/31 02:30:38] root INFO: resize_short : 256 [2021/10/31 02:30:38] root INFO: CropImage : [2021/10/31 02:30:38] root INFO: size : 224 [2021/10/31 02:30:38] root INFO: NormalizeImage : [2021/10/31 02:30:38] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:30:38] root INFO: order : [2021/10/31 02:30:38] root INFO: scale : 1.0/255.0 [2021/10/31 02:30:38] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:30:38] root INFO: ToCHWImage : None [2021/10/31 02:30:38] root INFO: Loss : [2021/10/31 02:30:38] root INFO: Eval : [2021/10/31 02:30:38] root INFO: CELoss : [2021/10/31 02:30:38] root INFO: weight : 1.0 [2021/10/31 02:30:38] root INFO: Train : [2021/10/31 02:30:38] root INFO: CELoss : [2021/10/31 02:30:38] root INFO: weight : 1.0 [2021/10/31 02:30:38] root INFO: Metric : [2021/10/31 02:30:38] root INFO: Eval : [2021/10/31 02:30:38] root INFO: TopkAcc : [2021/10/31 02:30:38] root INFO: topk : [1, 5] [2021/10/31 02:30:38] root INFO: Train : [2021/10/31 02:30:38] root INFO: TopkAcc : [2021/10/31 02:30:38] root INFO: topk : [1, 5] [2021/10/31 02:30:38] root INFO: Optimizer : [2021/10/31 02:30:38] root INFO: lr : [2021/10/31 02:30:38] root INFO: learning_rate : 0.0125 [2021/10/31 02:30:38] root INFO: name : Cosine [2021/10/31 02:30:38] root INFO: warmup_epoch : 5 [2021/10/31 02:30:38] root INFO: momentum : 0.9 [2021/10/31 02:30:38] root INFO: name : Momentum [2021/10/31 02:30:38] root INFO: regularizer : [2021/10/31 02:30:38] root INFO: coeff : 1e-05 [2021/10/31 02:30:38] root INFO: name : L2 [2021/10/31 02:30:38] root INFO: train with paddle 2.1.2 and device CUDAPlace(0) W1031 02:30:38.361168 11634 device_context.cc:404] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1 W1031 02:30:38.365787 11634 device_context.cc:422] device: 0, cuDNN Version: 7.6. /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/utils.py:77: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working return (isinstance(seq, collections.Sequence) and
文件保存到了PaddleClas/inference/目录
inference.pdiparams inference.pdiparams.info inference.pdmodel
%cd deploy !python3 python/predict_cls.py -c configs/inference_cls.yaml -o Global.infer_imgs=/home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg -o Global.inference_model_dir=../inference/ -o PostProcess.Topk.class_id_map_file=None
/home/aistudio/PaddleClas/deploy 2021-10-31 02:34:50 INFO: =========================================================== == PaddleClas is powered by PaddlePaddle ! == =========================================================== == == == For more info please go to the following website. == == == == https://github.com/PaddlePaddle/PaddleClas == =========================================================== 2021-10-31 02:34:50 INFO: Global : 2021-10-31 02:34:50 INFO: batch_size : 1 2021-10-31 02:34:50 INFO: cpu_num_threads : 10 2021-10-31 02:34:50 INFO: enable_benchmark : True 2021-10-31 02:34:50 INFO: enable_mkldnn : True 2021-10-31 02:34:50 INFO: enable_profile : False 2021-10-31 02:34:50 INFO: gpu_mem : 8000 2021-10-31 02:34:50 INFO: infer_imgs : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00033.jpg 2021-10-31 02:34:50 INFO: inference_model_dir : ../inference/ 2021-10-31 02:34:50 INFO: ir_optim : True 2021-10-31 02:34:50 INFO: use_fp16 : False 2021-10-31 02:34:50 INFO: use_gpu : True 2021-10-31 02:34:50 INFO: use_tensorrt : False 2021-10-31 02:34:50 INFO: PostProcess : 2021-10-31 02:34:50 INFO: SavePreLabel : 2021-10-31 02:34:50 INFO: save_dir : ./pre_label/ 2021-10-31 02:34:50 INFO: Topk : 2021-10-31 02:34:50 INFO: class_id_map_file : None 2021-10-31 02:34:50 INFO: topk : 5 2021-10-31 02:34:50 INFO: main_indicator : Topk 2021-10-31 02:34:50 INFO: PreProcess : 2021-10-31 02:34:50 INFO: transform_ops : 2021-10-31 02:34:50 INFO: ResizeImage : 2021-10-31 02:34:50 INFO: resize_short : 256 2021-10-31 02:34:50 INFO: CropImage : 2021-10-31 02:34:50 INFO: size : 224 2021-10-31 02:34:50 INFO: NormalizeImage : 2021-10-31 02:34:50 INFO: channel_num : 3 2021-10-31 02:34:50 INFO: mean : [0.485, 0.456, 0.406] 2021-10-31 02:34:50 INFO: order : 2021-10-31 02:34:50 INFO: scale : 0.00392157 2021-10-31 02:34:50 INFO: std : [0.229, 0.224, 0.225] 2021-10-31 02:34:50 INFO: ToCHWImage : None image_00033.jpg:class id(s): [37, 35, 76, 28, 50], score(s): [0.46, 0.13, 0.04, 0.03, 0.03], label_name(s): []
!python tools/eval.py -c ./ppcls/configs/quick_start/ResNet50_vd.yaml -o Global.pretrained_model=output/ResNet50_vd/best_model
/home/aistudio/PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py:15: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Callable [2021/10/31 02:28:12] root INFO: =========================================================== == PaddleClas is powered by PaddlePaddle ! == =========================================================== == == == For more info please go to the following website. == == == == https://github.com/PaddlePaddle/PaddleClas == =========================================================== [2021/10/31 02:28:12] root INFO: Arch : [2021/10/31 02:28:12] root INFO: name : ResNet50_vd [2021/10/31 02:28:12] root INFO: DataLoader : [2021/10/31 02:28:12] root INFO: Eval : [2021/10/31 02:28:12] root INFO: dataset : [2021/10/31 02:28:12] root INFO: cls_label_path : valid.txt [2021/10/31 02:28:12] root INFO: image_root : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:28:12] root INFO: name : ImageNetDataset [2021/10/31 02:28:12] root INFO: transform_ops : [2021/10/31 02:28:12] root INFO: DecodeImage : [2021/10/31 02:28:12] root INFO: channel_first : False [2021/10/31 02:28:12] root INFO: to_rgb : True [2021/10/31 02:28:12] root INFO: ResizeImage : [2021/10/31 02:28:12] root INFO: resize_short : 256 [2021/10/31 02:28:12] root INFO: CropImage : [2021/10/31 02:28:12] root INFO: size : 224 [2021/10/31 02:28:12] root INFO: NormalizeImage : [2021/10/31 02:28:12] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:28:12] root INFO: order : [2021/10/31 02:28:12] root INFO: scale : 1.0/255.0 [2021/10/31 02:28:12] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:28:12] root INFO: loader : [2021/10/31 02:28:12] root INFO: num_workers : 4 [2021/10/31 02:28:12] root INFO: use_shared_memory : True [2021/10/31 02:28:12] root INFO: sampler : [2021/10/31 02:28:12] root INFO: batch_size : 256 [2021/10/31 02:28:12] root INFO: drop_last : False [2021/10/31 02:28:12] root INFO: name : DistributedBatchSampler [2021/10/31 02:28:12] root INFO: shuffle : False [2021/10/31 02:28:12] root INFO: Train : [2021/10/31 02:28:12] root INFO: dataset : [2021/10/31 02:28:12] root INFO: cls_label_path : train.txt [2021/10/31 02:28:12] root INFO: image_root : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:28:12] root INFO: name : ImageNetDataset [2021/10/31 02:28:12] root INFO: transform_ops : [2021/10/31 02:28:12] root INFO: DecodeImage : [2021/10/31 02:28:12] root INFO: channel_first : False [2021/10/31 02:28:12] root INFO: to_rgb : True [2021/10/31 02:28:12] root INFO: RandCropImage : [2021/10/31 02:28:12] root INFO: size : 224 [2021/10/31 02:28:12] root INFO: RandFlipImage : [2021/10/31 02:28:12] root INFO: flip_code : 1 [2021/10/31 02:28:12] root INFO: NormalizeImage : [2021/10/31 02:28:12] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:28:12] root INFO: order : [2021/10/31 02:28:12] root INFO: scale : 1.0/255.0 [2021/10/31 02:28:12] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:28:12] root INFO: loader : [2021/10/31 02:28:12] root INFO: num_workers : 4 [2021/10/31 02:28:12] root INFO: use_shared_memory : True [2021/10/31 02:28:12] root INFO: sampler : [2021/10/31 02:28:12] root INFO: batch_size : 256 [2021/10/31 02:28:12] root INFO: drop_last : False [2021/10/31 02:28:12] root INFO: name : DistributedBatchSampler [2021/10/31 02:28:12] root INFO: shuffle : True [2021/10/31 02:28:12] root INFO: Global : [2021/10/31 02:28:12] root INFO: checkpoints : None [2021/10/31 02:28:12] root INFO: class_num : 102 [2021/10/31 02:28:12] root INFO: device : gpu [2021/10/31 02:28:12] root INFO: epochs : 20 [2021/10/31 02:28:12] root INFO: eval_during_train : True [2021/10/31 02:28:12] root INFO: eval_interval : 5 [2021/10/31 02:28:12] root INFO: image_shape : [3, 224, 224] [2021/10/31 02:28:12] root INFO: output_dir : ./output/ [2021/10/31 02:28:12] root INFO: pretrained_model : output/ResNet50_vd/best_model [2021/10/31 02:28:12] root INFO: print_batch_step : 10 [2021/10/31 02:28:12] root INFO: save_inference_dir : ./inference [2021/10/31 02:28:12] root INFO: save_interval : 5 [2021/10/31 02:28:12] root INFO: use_visualdl : False [2021/10/31 02:28:12] root INFO: Infer : [2021/10/31 02:28:12] root INFO: PostProcess : [2021/10/31 02:28:12] root INFO: class_id_map_file : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/jpg/image_00030.jpg [2021/10/31 02:28:12] root INFO: name : Topk [2021/10/31 02:28:12] root INFO: topk : 5 [2021/10/31 02:28:12] root INFO: batch_size : 10 [2021/10/31 02:28:12] root INFO: infer_imgs : /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/ [2021/10/31 02:28:12] root INFO: transforms : [2021/10/31 02:28:12] root INFO: DecodeImage : [2021/10/31 02:28:12] root INFO: channel_first : False [2021/10/31 02:28:12] root INFO: to_rgb : True [2021/10/31 02:28:12] root INFO: ResizeImage : [2021/10/31 02:28:12] root INFO: resize_short : 256 [2021/10/31 02:28:12] root INFO: CropImage : [2021/10/31 02:28:12] root INFO: size : 224 [2021/10/31 02:28:12] root INFO: NormalizeImage : [2021/10/31 02:28:12] root INFO: mean : [0.485, 0.456, 0.406] [2021/10/31 02:28:12] root INFO: order : [2021/10/31 02:28:12] root INFO: scale : 1.0/255.0 [2021/10/31 02:28:12] root INFO: std : [0.229, 0.224, 0.225] [2021/10/31 02:28:12] root INFO: ToCHWImage : None [2021/10/31 02:28:12] root INFO: Loss : [2021/10/31 02:28:12] root INFO: Eval : [2021/10/31 02:28:12] root INFO: CELoss : [2021/10/31 02:28:12] root INFO: weight : 1.0 [2021/10/31 02:28:12] root INFO: Train : [2021/10/31 02:28:12] root INFO: CELoss : [2021/10/31 02:28:12] root INFO: weight : 1.0 [2021/10/31 02:28:12] root INFO: Metric : [2021/10/31 02:28:12] root INFO: Eval : [2021/10/31 02:28:12] root INFO: TopkAcc : [2021/10/31 02:28:12] root INFO: topk : [1, 5] [2021/10/31 02:28:12] root INFO: Train : [2021/10/31 02:28:12] root INFO: TopkAcc : [2021/10/31 02:28:12] root INFO: topk : [1, 5] [2021/10/31 02:28:12] root INFO: Optimizer : [2021/10/31 02:28:12] root INFO: lr : [2021/10/31 02:28:12] root INFO: learning_rate : 0.0125 [2021/10/31 02:28:12] root INFO: name : Cosine [2021/10/31 02:28:12] root INFO: warmup_epoch : 5 [2021/10/31 02:28:12] root INFO: momentum : 0.9 [2021/10/31 02:28:12] root INFO: name : Momentum [2021/10/31 02:28:12] root INFO: regularizer : [2021/10/31 02:28:12] root INFO: coeff : 1e-05 [2021/10/31 02:28:12] root INFO: name : L2 [2021/10/31 02:28:12] root INFO: train with paddle 2.1.2 and device CUDAPlace(0) self._cls_path /home/aistudio/data/oxford-102-flowers/oxford-102-flowers/valid.txt W1031 02:28:12.918593 11295 device_context.cc:404] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1 W1031 02:28:12.923264 11295 device_context.cc:422] device: 0, cuDNN Version: 7.6. [2021/10/31 02:28:21] root INFO: [Eval][Epoch 0][Iter: 0/4]CELoss: 0.47912, loss: 0.47912, top1: 0.91797, top5: 0.96094, batch_cost: 3.39170s, reader_cost: 2.99661, ips: 75.47843 images/sec [2021/10/31 02:28:22] root INFO: [Eval][Epoch 0][Avg]CELoss: 0.54982, loss: 0.54982, top1: 0.88922, top5: 0.96667
eval结果
W1031 02:28:12.923264 11295 device_context.cc:422] device: 0, cuDNN Version: 7.6. [2021/10/31 02:28:21] root INFO: [Eval][Epoch 0][Iter: 0/4]CELoss: 0.47912, loss: 0.47912, top1: 0.91797, top5: 0.96094, batch_cost: 3.39170s, reader_cost: 2.99661, ips: 75.47843 images/sec [2021/10/31 02:28:22] root INFO: [Eval][Epoch 0][Avg]CELoss: 0.54982, loss: 0.54982, top1: 0.88922, top5: 0.96667
相关知识
鲜花行业市场分析 鲜花市场前景分析2022
2022静安·新湖郁金香花博会
关于举办荆楚理工学院2022年度花卉文创大赛活动的通知
花娃的花园种植挑战:参与种植挑战,提升园艺技能
城市热缓解的基于自然的解决方案与实施路径——以北京市为例
苏州公园:“自然探索、夏日识花”(第三期)花卉植物亲子识别挑战活动
2022鲜花消费市场调查 花卉行业规模预测分析
2022深圳簕杜鹃花展开幕
2022我国花卉进出口数据情况与消费模式分析
植物病害识别大全2022 ;植物病害识别排行
网址: 基于PaddleClas2.3 的鲜花识别「这是我参与2022首次更文挑战的第30天,活动详情查看:2022首次更文挑战 https://m.huajiangbk.com/newsview720506.html
上一篇: 基于百度飞浆平台的‘鲜花识别程序 |
下一篇: 【冯艺茜】的意思 |