提交 1c31010b 编写于 作者: H HydrogenSulfate

refine code

上级 16f910b4
...@@ -71,6 +71,7 @@ DataLoader: ...@@ -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: ...@@ -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: ...@@ -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]
......
...@@ -90,6 +90,7 @@ DataLoader: ...@@ -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: ...@@ -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: ...@@ -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]
......
...@@ -64,7 +64,7 @@ Loss: ...@@ -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: ...@@ -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: ...@@ -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: ...@@ -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]
......
...@@ -25,6 +25,7 @@ from ppcls.data.preprocess.ops.operators import DecodeImage ...@@ -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
......
...@@ -63,6 +63,8 @@ class UnifiedResize(object): ...@@ -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)
......
...@@ -254,8 +254,9 @@ class Engine(object): ...@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册