diff --git a/PaddleCV/image_classification/README.md b/PaddleCV/image_classification/README.md index f31f003cb6a962c889c6aa586303ce308f3ce718..787b8f33ecc8b0bb0eadc4cb877dc886c9173743 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 44425ca808cbb419b7a1d7b5295ab83c3c10cf4e..3494160bf614fe4944c7b542d6f9392b3c8fa2a9 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 dd714cc3b79aeafe9beda56a9194874ad8cd4594..98541b49c5d8fae6257bcb1087b425dd83372358 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 7a7ebf3d7acbadaef99fcdea0ac53adc46a19e86..5023323bc1569b652f4961649a73fec8236383af 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,