From 622fdd5194ba0168d308ab11f67b86c63e5794c4 Mon Sep 17 00:00:00 2001 From: ruri Date: Mon, 2 Dec 2019 20:28:18 +0800 Subject: [PATCH] refine warning in image classification (#4018) * refine warning --- PaddleCV/image_classification/README.md | 2 -- PaddleCV/image_classification/README_en.md | 2 -- PaddleCV/image_classification/eval.py | 7 ++++--- PaddleCV/image_classification/infer.py | 7 +++++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PaddleCV/image_classification/README.md b/PaddleCV/image_classification/README.md index f31f003c..787b8f33 100644 --- a/PaddleCV/image_classification/README.md +++ b/PaddleCV/image_classification/README.md @@ -261,8 +261,6 @@ export FLAGS_fraction_of_gpu_memory_to_use=0.80 python -m paddle.distributed.launch train.py \ --model=ShuffleNetV2_x0_25 \ --batch_size=2048 \ - --class_dim=1000 \ - --image_shape=3,224,224 \ --lr_strategy=cosine_decay_warmup \ --num_epochs=240 \ --lr=0.5 \ diff --git a/PaddleCV/image_classification/README_en.md b/PaddleCV/image_classification/README_en.md index 44425ca8..3494160b 100644 --- a/PaddleCV/image_classification/README_en.md +++ b/PaddleCV/image_classification/README_en.md @@ -256,8 +256,6 @@ export FLAGS_fraction_of_gpu_memory_to_use=0.80 python -m paddle.distributed.launch train.py \ --model=ShuffleNetV2_x0_25 \ --batch_size=2048 \ - --class_dim=1000 \ - --image_shape=3,224,224 \ --lr_strategy=cosine_decay_warmup \ --num_epochs=240 \ --lr=0.5 \ diff --git a/PaddleCV/image_classification/eval.py b/PaddleCV/image_classification/eval.py index dd714cc3..98541b49 100644 --- a/PaddleCV/image_classification/eval.py +++ b/PaddleCV/image_classification/eval.py @@ -52,8 +52,6 @@ add_arg('use_se', bool, True, "Whether to use Squeeze- def eval(args): - image_shape = args.image_shape - model_list = [m for m in dir(models) if "__" not in m] assert args.model in model_list, "{} is not in lists: {}".format(args.model, model_list) @@ -62,8 +60,11 @@ def eval(args): ), "{} doesn't exist, please load right pretrained model path for eval".format( args.pretrained_model) + assert args.image_shape[ + 1] <= args.resize_short_size, "Please check the args:image_shape and args:resize_short_size, The croped size(image_shape[1]) must smaller than or equal to the resized length(resize_short_size) " + image = fluid.data( - name='image', shape=[None] + image_shape, dtype='float32') + name='image', shape=[None] + args.image_shape, dtype='float32') label = fluid.data(name='label', shape=[None, 1], dtype='int64') # model definition diff --git a/PaddleCV/image_classification/infer.py b/PaddleCV/image_classification/infer.py index 7a7ebf3d..5023323b 100644 --- a/PaddleCV/image_classification/infer.py +++ b/PaddleCV/image_classification/infer.py @@ -54,14 +54,17 @@ add_arg('use_se', bool, True, "Whether to use Squeeze- def infer(args): - image_shape = args.image_shape model_list = [m for m in dir(models) if "__" not in m] assert args.model in model_list, "{} is not in lists: {}".format(args.model, model_list) assert os.path.isdir(args.pretrained_model ), "please load right pretrained model path for infer" + + assert args.image_shape[ + 1] <= args.resize_short_size, "Please check the args:image_shape and args:resize_short_size, The croped size(image_shape[1]) must smaller than or equal to the resized length(resize_short_size) " + image = fluid.data( - name='image', shape=[None] + image_shape, dtype='float32') + name='image', shape=[None] + args.image_shape, dtype='float32') if args.model.startswith('EfficientNet'): model = models.__dict__[args.model](is_test=True, -- GitLab