refine code

pull/1819/head
HydrogenSulfate 2022-05-05 20:28:59 +08:00
parent 16f910b451
commit 1c31010b14
6 changed files with 16 additions and 3 deletions

View File

@ -71,6 +71,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- RandFlipImage: - RandFlipImage:
flip_code: 1 flip_code: 1
- Pad: - Pad:
@ -101,6 +102,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- ToTensor: - ToTensor:
- Normalize: - Normalize:
mean: [0.485, 0.456, 0.406] mean: [0.485, 0.456, 0.406]
@ -124,6 +126,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- ToTensor: - ToTensor:
- Normalize: - Normalize:
mean: [0.485, 0.456, 0.406] mean: [0.485, 0.456, 0.406]

View File

@ -90,6 +90,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- RandFlipImage: - RandFlipImage:
flip_code: 1 flip_code: 1
- Pad: - Pad:
@ -126,6 +127,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- ToTensor: - ToTensor:
- Normalize: - Normalize:
mean: [0.485, 0.456, 0.406] mean: [0.485, 0.456, 0.406]
@ -149,6 +151,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- ToTensor: - ToTensor:
- Normalize: - Normalize:
mean: [0.485, 0.456, 0.406] mean: [0.485, 0.456, 0.406]

View File

@ -64,7 +64,7 @@ Loss:
weight: 0.0005 weight: 0.0005
num_classes: *class_num num_classes: *class_num
feat_dim: *feat_dim feat_dim: *feat_dim
feat_from: "backbone" feature_from: "backbone"
Eval: Eval:
- CELoss: - CELoss:
weight: 1.0 weight: 1.0
@ -101,6 +101,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- RandFlipImage: - RandFlipImage:
flip_code: 1 flip_code: 1
- Pad: - Pad:
@ -137,6 +138,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- ToTensor: - ToTensor:
- Normalize: - Normalize:
mean: [0.485, 0.456, 0.406] mean: [0.485, 0.456, 0.406]
@ -160,6 +162,7 @@ DataLoader:
- ResizeImage: - ResizeImage:
size: [128, 256] size: [128, 256]
return_numpy: False return_numpy: False
backend: "pil"
- ToTensor: - ToTensor:
- Normalize: - Normalize:
mean: [0.485, 0.456, 0.406] mean: [0.485, 0.456, 0.406]

View File

@ -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 ResizeImage
from ppcls.data.preprocess.ops.operators import CropImage from ppcls.data.preprocess.ops.operators import CropImage
from ppcls.data.preprocess.ops.operators import RandCropImage 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 RandFlipImage
from ppcls.data.preprocess.ops.operators import NormalizeImage from ppcls.data.preprocess.ops.operators import NormalizeImage
from ppcls.data.preprocess.ops.operators import ToCHWImage from ppcls.data.preprocess.ops.operators import ToCHWImage

View File

@ -63,6 +63,8 @@ class UnifiedResize(object):
resample = random.choice(resample) resample = random.choice(resample)
if isinstance(src, np.ndarray): if isinstance(src, np.ndarray):
pil_img = Image.fromarray(src) pil_img = Image.fromarray(src)
else:
pil_img = src
pil_img = pil_img.resize(size, resample) pil_img = pil_img.resize(size, resample)
if return_numpy: if return_numpy:
return np.asarray(pil_img) return np.asarray(pil_img)

View File

@ -254,8 +254,9 @@ class Engine(object):
world_size = dist.get_world_size() world_size = dist.get_world_size()
self.config["Global"]["distributed"] = world_size != 1 self.config["Global"]["distributed"] = world_size != 1
if self.mode == "train": if self.mode == "train":
std_gpu_num = 8 if self.config["Optimizer"][ std_gpu_num = 8 if isinstance(
"name"] == "AdamW" else 4 self.config["Optimizer"],
dict) and self.config["Optimizer"]["name"] == "AdamW" else 4
if world_size != std_gpu_num: 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." 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) logger.warning(msg)