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

There is no instantiate_lrscheduler_from_config function in vidtok.modules.util. #7

Open
HuaizeLiu opened this issue Jan 3, 2025 · 4 comments

Comments

@HuaizeLiu
Copy link

Image

There is no instantiate_lrscheduler_from_config function in vidtok.modules.util.

@wangyuchi369
Copy link
Contributor

Hi, you can manually add these codes to vidtok/modules/util.py, and we will update our code accordingly. Thank you for raising this issue.

from torch.optim.lr_scheduler import _LRScheduler, LambdaLR, StepLR

def instantiate_lrscheduler_from_config(optimizer, config, name='main-LR'):
    assert 'target' in config, 'Expected key `target` to instantiate.'
    if ('torch.optim' in config.target) or ('timm.scheduler' in config.target):
        scheduler = get_obj_from_str(config["target"])(optimizer, **config.get("params", dict()))
        lr_scheduler = {
            'scheduler': scheduler,
            'name': name
            }
    else:
        scheduler_init = instantiate_from_config(config)
        scheduler = LambdaLR(optimizer, lr_lambda=scheduler_init.schedule)
        lr_scheduler = {
            'scheduler': LambdaLR(optimizer, lr_lambda=scheduler_init.schedule),
            'name': name,
            'interval': 'step',
            'frequency': 1
            }
    return scheduler

@HuaizeLiu
Copy link
Author

Thank you very much for your reply. I have another question: there is no ImageLogger class in vidtok.modules.logger.

@HuaizeLiu
Copy link
Author

Image
in configs/vidtwin/vidtwin_structure_7_7_8_dynamics_7_8.yaml

@wangyuchi369
Copy link
Contributor

Thank you for the reminder. You can simply use the logger from other YAML files in VidTok, like this:

  callbacks:
    image_logger:
      target: vidtok.modules.logger.ImageVideoLogger
      params:
        disabled: false
        rescale: true
        enable_autocast: false
        batch_frequency: 5000
        max_samples: 2
        increase_log_steps: false
        log_first_step: false
        log_before_first_step: false
        log_images_kwargs:
          n_rows: 16

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

No branches or pull requests

2 participants