Open jkluo opened 2 years ago
我训练的是三个手势的图片 ( 👌 ✌️ 👍 ), 识别对应的手势准确率挺高的。但是随便给个其他照片,topk也输出了个高分的。这里我理解是,不在数据集范畴的图片,预测的时候结果集得分不应该这么高。
如果数据集的类别特别少的话,确实会出现这种情况,这是正常的情况哈。
如果数据集的类别特别少的话,确实会出现这种情况,这是正常的情况哈。
大佬,如果就只想识别特定的几个类别,这种情况要怎么避免呢? topk给的预值都很高,如果预值低的话,可以根据预值低于多少,判断出预测不在 类别里面。
问题描述
PaddleClas 使用的是 develop 分支。 paddle 版本 PaddlePaddle 2.3.0, compiled with with_avx: ON with_gpu: OFF with_mkl: OFF with_mkldnn: OFF with_python: ON
无
训练环境信息:本地 a. 具体操作系统,MacOS b. Python版本号,如Python3.9.10
完整的代码(相比于repo中代码,有改动的地方)、详细的错误信息及相关log 我根据quickstart自己进行了训练,共三个label,也有使用到预训练模型 ResNet50_vd_ssld_pretrained。 训练完预测的时候,能识别出一部分数据,但为什么不管给的是什么图片,topk 都会给一个高百分比对应的结果呢? 比如下面这个结果集返回,应该是不符合的才对。却命中 ID:1 [{'class_ids': [1, 2, 3], 'scores': [0.99649, 0.00329, 0.00022]}]
输入的日志: ➜ PaddleClas git:(develop) ✗ python3 tools/infer.py -c ./ppcls/configs/quick_start/ResNet50_ok.yaml -o Infer.infer_imgs=/Users/luolongming/Downloads/rose3.jpeg -o Global.pretrained_model=output/gesture/ResNet50_vd/best_model
[2022/06/29 15:47:25] ppcls INFO:
== PaddleClas is powered by PaddlePaddle ! ==
== == == For more info please go to the following website. == == == == https://github.com/PaddlePaddle/PaddleClas ==
[2022/06/29 15:47:25] ppcls INFO: Arch : [2022/06/29 15:47:25] ppcls INFO: class_num : 4 [2022/06/29 15:47:25] ppcls INFO: name : ResNet50_vd [2022/06/29 15:47:25] ppcls INFO: params : [2022/06/29 15:47:25] ppcls INFO: lr_mult_list : [0.5, 0.5, 0.6, 0.6, 0.8] [2022/06/29 15:47:25] ppcls INFO: pretrained_model : ./pretrained/ResNet50_vd_ssld_pretrained [2022/06/29 15:47:25] ppcls INFO: DataLoader : [2022/06/29 15:47:25] ppcls INFO: Eval : [2022/06/29 15:47:25] ppcls INFO: dataset : [2022/06/29 15:47:25] ppcls INFO: cls_label_path : ./dataset/gesture/val_list.txt [2022/06/29 15:47:25] ppcls INFO: image_root : ./dataset/gesture/ [2022/06/29 15:47:25] ppcls INFO: name : ImageNetDataset [2022/06/29 15:47:25] ppcls INFO: transform_ops : [2022/06/29 15:47:25] ppcls INFO: DecodeImage : [2022/06/29 15:47:25] ppcls INFO: channel_first : False [2022/06/29 15:47:25] ppcls INFO: to_rgb : True [2022/06/29 15:47:25] ppcls INFO: ResizeImage : [2022/06/29 15:47:25] ppcls INFO: resize_short : 256 [2022/06/29 15:47:25] ppcls INFO: CropImage : [2022/06/29 15:47:25] ppcls INFO: size : 256 [2022/06/29 15:47:25] ppcls INFO: NormalizeImage : [2022/06/29 15:47:25] ppcls INFO: mean : [0.485, 0.456, 0.406] [2022/06/29 15:47:25] ppcls INFO: order : [2022/06/29 15:47:25] ppcls INFO: scale : 1.0/255.0 [2022/06/29 15:47:25] ppcls INFO: std : [0.229, 0.224, 0.225] [2022/06/29 15:47:25] ppcls INFO: loader : [2022/06/29 15:47:25] ppcls INFO: num_workers : 4 [2022/06/29 15:47:25] ppcls INFO: use_shared_memory : True [2022/06/29 15:47:25] ppcls INFO: sampler : [2022/06/29 15:47:25] ppcls INFO: batch_size : 64 [2022/06/29 15:47:25] ppcls INFO: drop_last : False [2022/06/29 15:47:25] ppcls INFO: name : DistributedBatchSampler [2022/06/29 15:47:25] ppcls INFO: shuffle : False [2022/06/29 15:47:25] ppcls INFO: Train : [2022/06/29 15:47:25] ppcls INFO: dataset : [2022/06/29 15:47:25] ppcls INFO: cls_label_path : ./dataset/gesture/train_list.txt [2022/06/29 15:47:25] ppcls INFO: image_root : ./dataset/gesture/ [2022/06/29 15:47:25] ppcls INFO: name : ImageNetDataset [2022/06/29 15:47:25] ppcls INFO: transform_ops : [2022/06/29 15:47:25] ppcls INFO: DecodeImage : [2022/06/29 15:47:25] ppcls INFO: channel_first : False [2022/06/29 15:47:25] ppcls INFO: to_rgb : True [2022/06/29 15:47:25] ppcls INFO: RandCropImage : [2022/06/29 15:47:25] ppcls INFO: size : 256 [2022/06/29 15:47:25] ppcls INFO: ResizeImage : [2022/06/29 15:47:25] ppcls INFO: resize_short : 256 [2022/06/29 15:47:25] ppcls INFO: RandFlipImage : [2022/06/29 15:47:25] ppcls INFO: flip_code : 1 [2022/06/29 15:47:25] ppcls INFO: NormalizeImage : [2022/06/29 15:47:25] ppcls INFO: mean : [0.485, 0.456, 0.406] [2022/06/29 15:47:25] ppcls INFO: order : [2022/06/29 15:47:25] ppcls INFO: scale : 1.0/255.0 [2022/06/29 15:47:25] ppcls INFO: std : [0.229, 0.224, 0.225] [2022/06/29 15:47:25] ppcls INFO: RandomErasing : [2022/06/29 15:47:25] ppcls INFO: EPSILON : 0.0 [2022/06/29 15:47:25] ppcls INFO: ------------------------------------------------------------ [2022/06/29 15:47:25] ppcls INFO: attempt : 10 [2022/06/29 15:47:25] ppcls INFO: mode : pixel [2022/06/29 15:47:25] ppcls INFO: r1 : 0.3 [2022/06/29 15:47:25] ppcls INFO: sh : 1.0/3.0 [2022/06/29 15:47:25] ppcls INFO: sl : 0.02 [2022/06/29 15:47:25] ppcls INFO: use_log_aspect : True [2022/06/29 15:47:25] ppcls INFO: loader : [2022/06/29 15:47:25] ppcls INFO: num_workers : 4 [2022/06/29 15:47:25] ppcls INFO: use_shared_memory : True [2022/06/29 15:47:25] ppcls INFO: sampler : [2022/06/29 15:47:25] ppcls INFO: batch_size : 32 [2022/06/29 15:47:25] ppcls INFO: drop_last : False [2022/06/29 15:47:25] ppcls INFO: name : DistributedBatchSampler [2022/06/29 15:47:25] ppcls INFO: shuffle : True [2022/06/29 15:47:25] ppcls INFO: Global : [2022/06/29 15:47:25] ppcls INFO: checkpoints : None [2022/06/29 15:47:25] ppcls INFO: device : cpu [2022/06/29 15:47:25] ppcls INFO: epochs : 20 [2022/06/29 15:47:25] ppcls INFO: eval_during_train : True [2022/06/29 15:47:25] ppcls INFO: eval_interval : 1 [2022/06/29 15:47:25] ppcls INFO: image_shape : [3, 224, 224] [2022/06/29 15:47:25] ppcls INFO: output_dir : ./output/gesture/ [2022/06/29 15:47:25] ppcls INFO: pretrained_model : output/gesture/ResNet50_vd/best_model [2022/06/29 15:47:25] ppcls INFO: print_batch_step : 10 [2022/06/29 15:47:25] ppcls INFO: save_inference_dir : ./inference [2022/06/29 15:47:25] ppcls INFO: save_interval : 1 [2022/06/29 15:47:25] ppcls INFO: use_visualdl : False [2022/06/29 15:47:25] ppcls INFO: Infer : [2022/06/29 15:47:25] ppcls INFO: PostProcess : [2022/06/29 15:47:25] ppcls INFO: class_id_map_file : ./dataset/gesture/gesture_label_list.txt [2022/06/29 15:47:25] ppcls INFO: name : Topk [2022/06/29 15:47:25] ppcls INFO: topk : 3 [2022/06/29 15:47:25] ppcls INFO: batch_size : 10 [2022/06/29 15:47:25] ppcls INFO: infer_imgs : /Users/luolongming/Downloads/rose3.jpeg [2022/06/29 15:47:25] ppcls INFO: transforms : [2022/06/29 15:47:25] ppcls INFO: DecodeImage : [2022/06/29 15:47:25] ppcls INFO: channel_first : False [2022/06/29 15:47:25] ppcls INFO: to_rgb : True [2022/06/29 15:47:25] ppcls INFO: ResizeImage : [2022/06/29 15:47:25] ppcls INFO: resize_short : 256 [2022/06/29 15:47:25] ppcls INFO: CropImage : [2022/06/29 15:47:25] ppcls INFO: size : 256 [2022/06/29 15:47:25] ppcls INFO: NormalizeImage : [2022/06/29 15:47:25] ppcls INFO: mean : [0.485, 0.456, 0.406] [2022/06/29 15:47:25] ppcls INFO: order : [2022/06/29 15:47:25] ppcls INFO: scale : 1.0/255.0 [2022/06/29 15:47:25] ppcls INFO: std : [0.229, 0.224, 0.225] [2022/06/29 15:47:25] ppcls INFO: ToCHWImage : None [2022/06/29 15:47:25] ppcls INFO: Loss : [2022/06/29 15:47:25] ppcls INFO: Eval : [2022/06/29 15:47:25] ppcls INFO: CELoss : [2022/06/29 15:47:25] ppcls INFO: weight : 1.0 [2022/06/29 15:47:25] ppcls INFO: Train : [2022/06/29 15:47:25] ppcls INFO: CELoss : [2022/06/29 15:47:25] ppcls INFO: weight : 1.0 [2022/06/29 15:47:25] ppcls INFO: Metric : [2022/06/29 15:47:25] ppcls INFO: Eval : [2022/06/29 15:47:25] ppcls INFO: TopkAcc : [2022/06/29 15:47:25] ppcls INFO: topk : [1, 2, 3] [2022/06/29 15:47:25] ppcls INFO: Train : [2022/06/29 15:47:25] ppcls INFO: TopkAcc : [2022/06/29 15:47:25] ppcls INFO: topk : [1, 2, 3] [2022/06/29 15:47:25] ppcls INFO: Optimizer : [2022/06/29 15:47:25] ppcls INFO: lr : [2022/06/29 15:47:25] ppcls INFO: learning_rate : 0.0125 [2022/06/29 15:47:25] ppcls INFO: name : Cosine [2022/06/29 15:47:25] ppcls INFO: warmup_epoch : 5 [2022/06/29 15:47:25] ppcls INFO: momentum : 0.9 [2022/06/29 15:47:25] ppcls INFO: name : Momentum [2022/06/29 15:47:25] ppcls INFO: regularizer : [2022/06/29 15:47:25] ppcls INFO: coeff : 1e-05 [2022/06/29 15:47:25] ppcls INFO: name : L2 [2022/06/29 15:47:25] ppcls INFO: train with paddle 2.3.0 and device Place(cpu) [{'class_ids': [2, 1, 3], 'scores': [0.79, 0.18891, 0.02109], 'file_name': '/Users/luolongming/Downloads/rose3.jpeg', 'label_names': ['ok', 'yes', 'good']}]