rinongal / textual_inversion

MIT License
2.9k stars 277 forks source link

Unable to invert - NameError: name 'trainer' is not defined ; UnpicklingError: invalid load key, 'm'. #62

Closed EladNoy closed 2 years ago

EladNoy commented 2 years ago

I have tried to invert using this command

(ldm) H:\Users\User\PycharmProjects\Art\textual_inversion>python main.py --base configs/latent-diffusion/txt2img-1p4B-finetune.yaml -t --actual_resume models/first_stage_models/kl-f32/config.yaml -n try2 --gpus 0 --data_root MY_input_images/Object_1/ --init_word plane --placeholder_tokens "Object_1"

I'm getting the following errors:

Global seed set to 23 Running on GPUs 0 Loading model from models/first_stage_models/kl-f32/config.yaml Traceback (most recent call last): File "main.py", line 614, in model = load_model_from_config(config, opt.actual_resume) File "main.py", line 26, in load_model_from_config pl_sd = torch.load(ckpt, map_location="cpu") File "H:\anaconda3\envs\ldm\lib\site-packages\torch\serialization.py", line 608, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "H:\anaconda3\envs\ldm\lib\site-packages\torch\serialization.py", line 777, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: invalid load key, 'm'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 826, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined

Any help would be appreciated.

rinongal commented 2 years ago

--actual_resume should be given a path to a pre-trained model checkpoint. You're giving it the path to another configuration file. The placeholder token you are using will also be a problem. It has to be something that the model maps to a single token (for example '*' or '@'). If you want something that can work with more general strings, have a look at the diffusers implementation of our method.

EladNoy commented 2 years ago

Thank you for the quick reply. Should the --actual_resume receive models/ldm/text2img-large/model.ckpt ?

rinongal commented 2 years ago

Yep!

rinongal commented 2 years ago

This seems resolved so I'm closing it to clean up some clutter. Feel free to reopen if you still need help.

EKZERSIS commented 1 year ago

(ldm) C:\Users\ekzer\stable_diffusion\textual_inversion-main>python main.py --base configs/stable-diffusion/v1-finetune.yaml -t --actual_resume models/ldm/text2img-large/modelSD.ckpt -n art --gpus 0, --data_root img/datasets/cat_statue --init_word art --placeholder_tokens "*art cat" --no-test
Global seed set to 23
Running on GPUs 0,
Traceback (most recent call last):
  File "main.py", line 535, in <module>
    model = instantiate_from_config(config.model)
  File "C:\Users\ekzer\stable_diffusion\textual_inversion-main\ldm\util.py", line 85, in instantiate_from_config
    return get_obj_from_str(config["target"])(**config.get("params", dict()))
  File "C:\Users\ekzer\stable_diffusion\textual_inversion-main\ldm\models\diffusion\ddpm.py", line 448, in __init__
    super().__init__(conditioning_key=conditioning_key, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'embedding_reg_weight'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 740, in <module>
    if trainer.global_rank == 0:
NameError: name 'trainer' is not defined
EKZERSIS commented 1 year ago

I have the same problem

rinongal commented 1 year ago

@EKZERSIS See my reply in #84