rinongal / textual_inversion

MIT License
2.93k stars 281 forks source link

Error when running Inversion script #154

Open macrocredit opened 1 year ago

macrocredit commented 1 year ago

Hi - When running the inversion script I have the following error:

python3 main.py --base configs/latent-diffusion/txt2img-1p4B-finetune.yaml -t --actual_resume /scratch/xyz/textual_inversion/models/ldm/text2img-large/model.ckpt -n run_2 --gpus 0,1,2,3 --data_root /scratch/xyz/textual_inversion/img/datasets/cat_statue --init_word cat"

I got the following error: raise MisconfigurationException(f"No {loader_name}() method defined to run Trainer.{trainer_method}.") pytorch_lightning.utilities.exceptions.MisconfigurationException: No test_dataloader() method defined to run Trainer.test.

This is under this line:

_if not opt.notest and not trainer.interrupted:
trainer.test(model, data)

Is there any lead to remedy this error? Thanks.

rinongal commented 1 year ago

Is this happening after your training is done? Do you still get the output images / checkpoints?

hanikh commented 1 year ago

I got the same error. it happened before the training process got started.

rinongal commented 1 year ago

@hanikh I can't seem to reproduce this with my current setup. Can you try re-running with the --no-test flag and let me know if that helps?

justinday123 commented 1 year ago

i got the same issue. it happened at training process(actually, it happened at 48th epoch).

justinday123 commented 1 year ago

@rinongal when i run with the --no-test flag, it stops at the same point(48th epoch)

rinongal commented 1 year ago

@justinday123 Can you try modifying your config file by copying validation block and changing it's name to test? So your data block would look something like this:

data:
  target: main.DataModuleFromConfig
  params:
    batch_size: 2
    num_workers: 2
    wrap: false
    train:
      target: ldm.data.personalized.PersonalizedBase
      params:
        size: 512
        set: train
        per_image_tokens: false
        repeats: 100
    validation:
      target: ldm.data.personalized.PersonalizedBase
      params:
        size: 512
        set: val
        per_image_tokens: false
        repeats: 10
    test:
      target: ldm.data.personalized.PersonalizedBase
      params:
        size: 512
        set: val
        per_image_tokens: false
        repeats: 10

If that doesn't help, could you let me know what versions of pytorch, pytorch lightning, transformers and xformers you are using? And if possible, please give me the full error stack trace.

J-1nn commented 1 month ago

@justinday123 Can you try modifying your config file by copying validation block and changing it's name to test? So your data block would look something like this:

data:
  target: main.DataModuleFromConfig
  params:
    batch_size: 2
    num_workers: 2
    wrap: false
    train:
      target: ldm.data.personalized.PersonalizedBase
      params:
        size: 512
        set: train
        per_image_tokens: false
        repeats: 100
    validation:
      target: ldm.data.personalized.PersonalizedBase
      params:
        size: 512
        set: val
        per_image_tokens: false
        repeats: 10
    test:
      target: ldm.data.personalized.PersonalizedBase
      params:
        size: 512
        set: val
        per_image_tokens: false
        repeats: 10

If that doesn't help, could you let me know what versions of pytorch, pytorch lightning, transformers and xformers you are using? And if possible, please give me the full error stack trace.

After modifying the config file as you mentioned above, I got the following error:

Traceback (most recent call last): File "/mnt/data2/jinxiaochuan/Project/erase_verify/textual_inversion-main/main.py", line 752, in data.prepare_data() File "/home/jinxiaochuan/anaconda3/envs/receler/lib/python3.8/site-packages/pytorch_lightning/core/datamodule.py", line 474, in wrapped_fn fn(*args, kwargs) File "/mnt/data2/jinxiaochuan/Project/erase_verify/textual_inversion-main/main.py", line 236, in prepare_data instantiate_from_config(data_cfg) File "/mnt/data2/jinxiaochuan/Project/erase_verify/textual_inversion-main/ldm/util.py", line 85, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict()), **kwargs) TypeError: init() missing 1 required positional argument: 'data_root'