Skip to content

Commit

Permalink
rename inmem to gpu_trans. remoce one_iter.
Browse files Browse the repository at this point in the history
  • Loading branch information
howardhsu committed Sep 25, 2024
1 parent 5aaafd9 commit ee4664b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions config/metaclip_2_5b.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

@dataclass
class b32_fullcc(Config):
one_iter=True
inmem=True
gpu_trans=True
engine="train_one_epoch_ex"
eval_steps=5000
save_frequency=1
Expand Down
2 changes: 1 addition & 1 deletion config/metaclip_400m.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@dataclass
class b32_400m(Config):
inmem=True
gpu_trans=True
engine="train_one_epoch_ex"
eval_steps=5000
save_frequency=1
Expand Down
4 changes: 2 additions & 2 deletions src/open_clip/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def create_model_and_transforms(
pretrained_image: bool = False,
mean: Optional[Tuple[float, ...]] = None,
std: Optional[Tuple[float, ...]] = None,
inmem = False,
gpu_trans = False,
clip_model: str = "CLIP",
):
model = create_model(
Expand All @@ -146,7 +146,7 @@ def create_model_and_transforms(
pretrained_image=pretrained_image,
clip_model=clip_model,
)
preprocess_train = image_transform(model.visual.image_size, is_train=True, mean=mean, std=std, inmem=inmem)
preprocess_train = image_transform(model.visual.image_size, is_train=True, mean=mean, std=std, gpu_trans=gpu_trans)
preprocess_val = image_transform(model.visual.image_size, is_train=False, mean=mean, std=std)
return model, preprocess_train, preprocess_val

Expand Down
4 changes: 2 additions & 2 deletions src/open_clip/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def image_transform(
std: Optional[Tuple[float, ...]] = None,
resize_longest_max: bool = False,
fill_color: int = 0,
inmem = False
gpu_trans = False
):
mean = mean or (0.48145466, 0.4578275, 0.40821073) # OpenAI dataset mean
std = std or (0.26862954, 0.26130258, 0.27577711) # OpenAI dataset std
Expand All @@ -64,7 +64,7 @@ def image_transform(

normalize = Normalize(mean=mean, std=std)
if is_train:
if inmem:
if gpu_trans:
return Compose([
RandomResizedCrop(image_size, scale=(0.9, 1.0), interpolation=InterpolationMode.BICUBIC),
_convert_to_rgb,
Expand Down
2 changes: 1 addition & 1 deletion src/training/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def main(args):
force_quick_gelu=args.force_quick_gelu,
pretrained_image=args.pretrained_image,
mean=mean, std=std,
inmem=hasattr(args, "inmem"),
gpu_trans=hasattr(args, "gpu_trans") and args.gpu_trans,
clip_model=args.clip_model,
)
random_seed(args.seed, args.rank)
Expand Down

0 comments on commit ee4664b

Please sign in to comment.