latent-diffusion icon indicating copy to clipboard operation
latent-diffusion copied to clipboard

NameError: name 'trainer' is not defined

Open flyfaerss opened this issue 1 year ago • 7 comments

how can I solve this problem?

flyfaerss avatar May 21 '23 08:05 flyfaerss

Hello, did you find any solutions?

usama-axcelerate avatar Jun 01 '23 15:06 usama-axcelerate

Please checkout your execute command and config file. This is my yaml config file.

model:
  base_learning_rate: 2.0e-06
  target: ldm.models.diffusion.ddpm.LatentDiffusion
  params:
    linear_start: 0.0015
    linear_end: 0.0195
    num_timesteps_cond: 1
    log_every_t: 200
    timesteps: 1000
    first_stage_key: image
    image_size: 64
    channels: 3
    monitor: val/loss_simple_ema
    unet_config:
      target: ldm.modules.diffusionmodules.openaimodel.UNetModel
      params:
        image_size: 64
        in_channels: 3
        out_channels: 3
        model_channels: 224
        attention_resolutions:
        # note: this isn\t actually the resolution but
        # the downsampling factor, i.e. this corresnponds to
        # attention on spatial resolution 8,16,32, as the
        # spatial reolution of the latents is 64 for f4
        - 8
        - 4
        - 2
        num_res_blocks: 2
        channel_mult:
        - 1
        - 2
        - 3
        - 4
        num_head_channels: 32
    first_stage_config:
      target: ldm.models.autoencoder.VQModelInterface
      params:
        ckpt_path: models/first_stage_models/vq-f4/model/model.ckpt
        embed_dim: 3
        n_embed: 8192
        ddconfig:
          double_z: false
          z_channels: 3
          resolution: 256
          in_channels: 3
          out_ch: 3
          ch: 128
          ch_mult:
          - 1
          - 2
          - 4
          num_res_blocks: 2
          attn_resolutions: []
          dropout: 0.0
        lossconfig:
          target: torch.nn.Identity
    cond_stage_config: __is_unconditional__
data:
  target: main.DataModuleFromConfig
  params:
    batch_size: 4
    num_workers: 4
    wrap: false
    train:
      target: ldm.data.lsun.LSUNBedroomsTrain
      params:
        size: 256
    validation:
      target: ldm.data.lsun.LSUNBedroomsValidation
      params:
        size: 256


lightning:
  callbacks:
    image_logger:
      target: main.ImageLogger
      params:
        batch_frequency: 70
        max_images: 3
        increase_log_steps: False

  trainer:
    benchmark: True

GrandpaXun242 avatar Jun 24 '23 03:06 GrandpaXun242

Hello, I've checked my execute command and config file, which is the same as yours, but still can't solve this problem. Could you give any more solutions?

wwqy avatar Jun 26 '23 14:06 wwqy

Hello, I've checked my execute command and config file, which is the same as yours, but still can't solve this problem. Could you give any more solutions?

hi,Give me your error information which is showed in terminal.

GrandpaXun242 avatar Jun 26 '23 14:06 GrandpaXun242

I meet the problem since in the main.py, the try: except catch nothing. You should remove the try except first to find the error

ray-lee-94 avatar Aug 18 '23 01:08 ray-lee-94

Facing the same issue for the cin-ldm-vq-f8.yaml config.

cs-mshah avatar Jan 15 '24 11:01 cs-mshah

It might be an issue with this code needing an older pytorch_lightning version. Try installing version 1.6.1 (this may create other problems but should solve this.

nickk124 avatar Apr 26 '24 18:04 nickk124