Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments to set RGB mean std for IC #1546

Merged
merged 3 commits into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/sparseml/pytorch/torchvision/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def load_data(traindir, valdir, args):
traindir,
presets.ClassificationPresetTrain(
crop_size=train_crop_size,
mean=args.rgb_mean,
std=args.rgb_std,
interpolation=interpolation,
auto_augment_policy=auto_augment_policy,
random_erase_prob=random_erase_prob,
Expand All @@ -289,6 +291,8 @@ def load_data(traindir, valdir, args):
else:
preprocessing = presets.ClassificationPresetEval(
crop_size=val_crop_size,
mean=args.rgb_mean,
std=args.rgb_std,
resize_size=val_resize_size,
interpolation=interpolation,
)
Expand Down Expand Up @@ -1212,6 +1216,26 @@ def new_func(*args, **kwargs):
"Note: Will be read from the checkpoint if not specified"
),
)
@click.option(
"--rgb-mean",
nargs=3,
default=(0.485, 0.456, 0.406),
type=float,
help=(
"RGB mean values used to shift input RGB values; "
"Note: Will use ImageNet values if not specified."
),
)
@click.option(
"--rgb-std",
default=(0.229, 0.224, 0.225),
nargs=3,
type=float,
help=(
"RGB standard-deviation values used to normalize input RGB values; "
"Note: Will use ImageNet values if not specified."
),
)
@click.pass_context
def cli(ctx, **kwargs):
"""
Expand Down