diff --git a/ppcls/configs/Pedestrian/strong_baseline_baseline.yaml b/ppcls/configs/Pedestrian/strong_baseline_baseline.yaml index a0cc1fb18..a0395f3b1 100644 --- a/ppcls/configs/Pedestrian/strong_baseline_baseline.yaml +++ b/ppcls/configs/Pedestrian/strong_baseline_baseline.yaml @@ -71,6 +71,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - RandFlipImage: flip_code: 1 - Pad: @@ -101,6 +102,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - ToTensor: - Normalize: mean: [0.485, 0.456, 0.406] @@ -124,6 +126,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - ToTensor: - Normalize: mean: [0.485, 0.456, 0.406] diff --git a/ppcls/configs/Pedestrian/strong_baseline_m1.yaml b/ppcls/configs/Pedestrian/strong_baseline_m1.yaml index 1f8c12895..ef4b605ae 100644 --- a/ppcls/configs/Pedestrian/strong_baseline_m1.yaml +++ b/ppcls/configs/Pedestrian/strong_baseline_m1.yaml @@ -90,6 +90,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - RandFlipImage: flip_code: 1 - Pad: @@ -126,6 +127,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - ToTensor: - Normalize: mean: [0.485, 0.456, 0.406] @@ -149,6 +151,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - ToTensor: - Normalize: mean: [0.485, 0.456, 0.406] diff --git a/ppcls/configs/Pedestrian/strong_baseline_m1_centerloss.yaml b/ppcls/configs/Pedestrian/strong_baseline_m1_centerloss.yaml index 4c6fce2a4..6c14bb209 100644 --- a/ppcls/configs/Pedestrian/strong_baseline_m1_centerloss.yaml +++ b/ppcls/configs/Pedestrian/strong_baseline_m1_centerloss.yaml @@ -64,7 +64,7 @@ Loss: weight: 0.0005 num_classes: *class_num feat_dim: *feat_dim - feat_from: "backbone" + feature_from: "backbone" Eval: - CELoss: weight: 1.0 @@ -101,6 +101,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - RandFlipImage: flip_code: 1 - Pad: @@ -137,6 +138,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - ToTensor: - Normalize: mean: [0.485, 0.456, 0.406] @@ -160,6 +162,7 @@ DataLoader: - ResizeImage: size: [128, 256] return_numpy: False + backend: "pil" - ToTensor: - Normalize: mean: [0.485, 0.456, 0.406] diff --git a/ppcls/data/preprocess/__init__.py b/ppcls/data/preprocess/__init__.py index fc52c1f67..62066016a 100644 --- a/ppcls/data/preprocess/__init__.py +++ b/ppcls/data/preprocess/__init__.py @@ -25,6 +25,7 @@ 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 RandCropImageV2 from ppcls.data.preprocess.ops.operators import RandFlipImage from ppcls.data.preprocess.ops.operators import NormalizeImage from ppcls.data.preprocess.ops.operators import ToCHWImage diff --git a/ppcls/data/preprocess/ops/operators.py b/ppcls/data/preprocess/ops/operators.py index e6be4b2bb..0b137b526 100644 --- a/ppcls/data/preprocess/ops/operators.py +++ b/ppcls/data/preprocess/ops/operators.py @@ -63,6 +63,8 @@ class UnifiedResize(object): resample = random.choice(resample) if isinstance(src, np.ndarray): pil_img = Image.fromarray(src) + else: + pil_img = src pil_img = pil_img.resize(size, resample) if return_numpy: return np.asarray(pil_img) diff --git a/ppcls/engine/engine.py b/ppcls/engine/engine.py index a1dfe6de5..f91a96d1f 100644 --- a/ppcls/engine/engine.py +++ b/ppcls/engine/engine.py @@ -254,8 +254,9 @@ class Engine(object): world_size = dist.get_world_size() self.config["Global"]["distributed"] = world_size != 1 if self.mode == "train": - std_gpu_num = 8 if self.config["Optimizer"][ - "name"] == "AdamW" else 4 + std_gpu_num = 8 if isinstance( + self.config["Optimizer"], + dict) and self.config["Optimizer"]["name"] == "AdamW" else 4 if world_size != std_gpu_num: msg = f"The training strategy provided by PaddleClas is based on {std_gpu_num} gpus. But the number of gpu is {world_size} in current training. Please modify the stategy (learning rate, batch size and so on) if use this config to train." logger.warning(msg)