Skip to content

Commit

Permalink
crop done
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanklut committed Dec 12, 2023
1 parent d0dfa26 commit dc2e462
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 48 deletions.
108 changes: 108 additions & 0 deletions configs/segmentation/baseline/baseline_ovdr_crop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# python main.py --config configs/segmentation/baseline_ovdr.yaml --tmp_dir /encrypted/tmp
_BASE_: ../segmentation_base.yaml

OUTPUT_DIR: /encrypted/baseline

NAME: ovdr_scaling_test

PREPROCESS:
OVERWRITE: False
DISABLE_CHECK: False

RESIZE:
RESIZE_MODE: "scaling"
SCALING: 0.5
MAX_SIZE: -1

BASELINE:
LINE_WIDTH: 10

INPUT:
RESIZE_MODE: "scaling"
SCALING_TRAIN: 1.0
MAX_SIZE_TRAIN: -1

MAX_SIZE_TEST: -1

FORMAT: RGB

GRAYSCALE:
PROBABILITY: 0.1

BRIGHTNESS:
PROBABILITY: 0.2
MIN_INTENSITY: 0.5
MAX_INTENSITY: 1.5

CONTRAST:
PROBABILITY: 0.2
MIN_INTENSITY: 0.5
MAX_INTENSITY: 1.5

SATURATION:
PROBABILITY: 0.1
MIN_INTENSITY: 0.5
MAX_INTENSITY: 1.5

GAUSSIAN_FILTER:
PROBABILITY: 0.2
MIN_SIGMA: 0.5
MAX_SIGMA: 1.5

HORIZONTAL_FLIP:
PROBABILITY: 0.

VERTICAL_FLIP:
PROBABILITY: 0.

ELASTIC_DEFORMATION:
PROBABILITY: 0.2
ALPHA: 0.1
SIGMA: 0.01

AFFINE:
PROBABILITY: 1.

TRANSLATION:
PROBABILITY: 0.9
STANDARD_DEVIATION: 0.02

ROTATION:
PROBABILITY: 0.9
KAPPA: 30.

SHEAR:
PROBABILITY: 0.9
KAPPA: 20.

SCALE:
PROBABILITY: 0.9
STANDARD_DEVIATION: 0.12

CROP:
ENABLED: True
SIZE: [1024, 1024]
TYPE: absolute

SOLVER:
IMS_PER_BATCH: 2
CHECKPOINT_PERIOD: 25000
BASE_LR: 0.0002
GAMMA: 0.1
STEPS: () #(80000, 120000, 160000)
MAX_ITER: 500000

MODEL:
MODE: baseline

SEM_SEG_HEAD:
NUM_CLASSES: 2

WEIGHTS:

TRAIN:
WEIGHTS:

TEST:
WEIGHTS:
EVAL_PERIOD: 10000
108 changes: 60 additions & 48 deletions datasets/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,35 +951,36 @@ def build_augmentation(cfg: CfgNode, mode: str = "train") -> list[T.Augmentation
if not mode == "train":
return augmentation

# Color augments
augmentation.append(RandomApply(Grayscale(image_format=cfg.INPUT.FORMAT), prob=cfg.INPUT.GRAYSCALE.PROBABILITY))
augmentation.append(
RandomApply(
RandomBrightness(
intensity_min=cfg.INPUT.BRIGHTNESS.MIN_INTENSITY,
intensity_max=cfg.INPUT.BRIGHTNESS.MAX_INTENSITY,
),
prob=cfg.INPUT.BRIGHTNESS.PROBABILITY,
)
)
# Moving pixels

augmentation.append(
RandomApply(
RandomContrast(
intensity_min=cfg.INPUT.CONTRAST.MIN_INTENSITY,
intensity_max=cfg.INPUT.CONTRAST.MAX_INTENSITY,
RandomAffine(
t_stdv=cfg.INPUT.AFFINE.TRANSLATION.STANDARD_DEVIATION,
r_kappa=cfg.INPUT.AFFINE.ROTATION.KAPPA,
sh_kappa=cfg.INPUT.AFFINE.SHEAR.KAPPA,
sc_stdv=cfg.INPUT.AFFINE.SCALE.STANDARD_DEVIATION,
probabilities=(
cfg.INPUT.AFFINE.TRANSLATION.PROBABILITY,
cfg.INPUT.AFFINE.ROTATION.PROBABILITY,
cfg.INPUT.AFFINE.SHEAR.PROBABILITY,
cfg.INPUT.AFFINE.SCALE.PROBABILITY,
),
),
prob=cfg.INPUT.CONTRAST.PROBABILITY,
prob=cfg.INPUT.AFFINE.PROBABILITY,
)
)

augmentation.append(
RandomApply(
RandomSaturation(
intensity_min=cfg.INPUT.SATURATION.MIN_INTENSITY,
intensity_max=cfg.INPUT.SATURATION.MAX_INTENSITY,
RandomElastic(
alpha=cfg.INPUT.ELASTIC_DEFORMATION.ALPHA,
sigma=cfg.INPUT.ELASTIC_DEFORMATION.SIGMA,
),
prob=cfg.INPUT.SATURATION.PROBABILITY,
prob=cfg.INPUT.ELASTIC_DEFORMATION.PROBABILITY,
)
)

augmentation.append(
RandomApply(
RandomGaussianFilter(
Expand Down Expand Up @@ -1010,53 +1011,64 @@ def build_augmentation(cfg: CfgNode, mode: str = "train") -> list[T.Augmentation
)
)

# Orientation

augmentation.append(
RandomApply(
RandomElastic(
alpha=cfg.INPUT.ELASTIC_DEFORMATION.ALPHA,
sigma=cfg.INPUT.ELASTIC_DEFORMATION.SIGMA,
RandomOrientation(
orientation_percentages=cfg.INPUT.ORIENTATION.PERCENTAGES,
),
prob=cfg.INPUT.ELASTIC_DEFORMATION.PROBABILITY,
prob=cfg.INPUT.ORIENTATION.PROBABILITY,
)
)

# Color augments
augmentation.append(
RandomApply(
RandomAffine(
t_stdv=cfg.INPUT.AFFINE.TRANSLATION.STANDARD_DEVIATION,
r_kappa=cfg.INPUT.AFFINE.ROTATION.KAPPA,
sh_kappa=cfg.INPUT.AFFINE.SHEAR.KAPPA,
sc_stdv=cfg.INPUT.AFFINE.SCALE.STANDARD_DEVIATION,
probabilities=(
cfg.INPUT.AFFINE.TRANSLATION.PROBABILITY,
cfg.INPUT.AFFINE.ROTATION.PROBABILITY,
cfg.INPUT.AFFINE.SHEAR.PROBABILITY,
cfg.INPUT.AFFINE.SCALE.PROBABILITY,
),
Grayscale(
image_format=cfg.INPUT.FORMAT,
),
prob=cfg.INPUT.AFFINE.PROBABILITY,
prob=cfg.INPUT.GRAYSCALE.PROBABILITY,
)
)

augmentation.append(
RandomApply(
RandomOrientation(
orientation_percentages=cfg.INPUT.ORIENTATION.PERCENTAGES,
RandomBrightness(
intensity_min=cfg.INPUT.BRIGHTNESS.MIN_INTENSITY,
intensity_max=cfg.INPUT.BRIGHTNESS.MAX_INTENSITY,
),
prob=cfg.INPUT.ORIENTATION.PROBABILITY,
prob=cfg.INPUT.BRIGHTNESS.PROBABILITY,
)
)
augmentation.append(
RandomApply(
RandomContrast(
intensity_min=cfg.INPUT.CONTRAST.MIN_INTENSITY,
intensity_max=cfg.INPUT.CONTRAST.MAX_INTENSITY,
),
prob=cfg.INPUT.CONTRAST.PROBABILITY,
)
)
augmentation.append(
RandomApply(
RandomSaturation(
intensity_min=cfg.INPUT.SATURATION.MIN_INTENSITY,
intensity_max=cfg.INPUT.SATURATION.MAX_INTENSITY,
),
prob=cfg.INPUT.SATURATION.PROBABILITY,
)
)

# augmentation.append(RandomApply(RandomTranslation(t_stdv=cfg.INPUT.AFFINE.TRANSLATION.STANDARD_DEVIATION),
# prob=cfg.INPUT.AFFINE.PROBABILITY * cfg.INPUT.AFFINE.TRANSLATION.PROBABILITY))
# augmentation.append(RandomApply(RandomRotation(r_kappa=cfg.INPUT.AFFINE.ROTATION.KAPPA),
# prob=cfg.INPUT.AFFINE.PROBABILITY * cfg.INPUT.AFFINE.ROTATION.PROBABILITY))
# augmentation.append(RandomApply(RandomShear(sh_kappa=cfg.INPUT.AFFINE.SHEAR.KAPPA),
# prob=cfg.INPUT.AFFINE.PROBABILITY * cfg.INPUT.AFFINE.SHEAR.PROBABILITY))
# augmentation.append(RandomApply(RandomScale(sc_stdv=cfg.INPUT.AFFINE.SCALE.STANDARD_DEVIATION),
# prob=cfg.INPUT.AFFINE.PROBABILITY * cfg.INPUT.AFFINE.SCALE.PROBABILITY))
# Crop
if cfg.INPUT.CROP.ENABLED:
augmentation.append(
RandomCrop_CategoryAreaConstraint(
crop_type=cfg.INPUT.CROP.TYPE,
crop_size=cfg.INPUT.CROP.SIZE,
single_category_max_area=cfg.INPUT.CROP.SINGLE_CATEGORY_MAX_AREA,
)
)

# print(augmentation)
return augmentation


Expand Down

0 comments on commit dc2e462

Please sign in to comment.