Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

about random_sized_crop confused ? #123

Open
ranjiewwen opened this issue Dec 3, 2020 · 1 comment
Open

about random_sized_crop confused ? #123

ranjiewwen opened this issue Dec 3, 2020 · 1 comment

Comments

@ranjiewwen
Copy link

ranjiewwen commented Dec 3, 2020

i my codebase to train regnetx_200m, i use this function 'random_sized_crop' in transform, while get bad result, train acc get 90%+, while val acc get 50%+
random_sized_crop(image, size=cfg.data.image_size, area_frac=0.08)

when i use torchvision method , training result is normal.

 image = PIL.Image.fromarray(image)
 image = torchvision.transforms.RandomResizedCrop(cfg.data.image_size)(image)
 image = np.array(image)

anyone meet this problem ? i see the source code diff below, i think this shouldn't make so big different.

         # torchvision
        target_area = random.uniform(*scale) * area
        log_ratio = (math.log(ratio[0]), math.log(ratio[1]))
        aspect_ratio = math.exp(random.uniform(*log_ratio))
        # pycls
        target_area = np.random.uniform(area_frac, 1.0) * area
        aspect_ratio = np.random.uniform(3.0 / 4.0, 4.0 / 3.0)
@ranjiewwen
Copy link
Author

when change the code in pycls/datasets/transforms.py , functions: random_sized_crop use torchvision aspect_ratio, training result is right !!! so different result from there ???

 target_area = random.uniform(*(area_frac, 1.0)) * area
 log_ratio = (math.log(3.0 / 4.0), math.log(4.0 / 3.0))
 aspect_ratio = math.exp(random.uniform(*log_ratio))
 # target_area = np.random.uniform(area_frac, 1.0) * area
 # aspect_ratio = np.random.uniform(3.0 / 4.0, 4.0 / 3.0)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant