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

NameError: name 'trainer' is not defined #99

Open
wenkfjsf opened this issue Oct 15, 2024 · 2 comments
Open

NameError: name 'trainer' is not defined #99

wenkfjsf opened this issue Oct 15, 2024 · 2 comments

Comments

@wenkfjsf
Copy link

bash scripts/finetune_real.sh "cat" data/cat real_reg/samples_cat cat finetune_addtoken.yaml '/media/nlp/data/custom-diffusion/stable-diffusion-v-1-4-original/sd-v1-4.ckpt'
cat
data/cat
real_reg/samples_cat
cat
finetune_addtoken.yaml
/media/nlp/data/custom-diffusion/stable-diffusion-v-1-4-original/sd-v1-4.ckpt
Traceback (most recent call last):
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/requests/models.py", line 974, in json
return complexjson.loads(self.text, **kwargs)
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "src/retrieve.py", line 92, in
retrieve(args.target_name, args.outpath, args.num_class_images)
File "src/retrieve.py", line 28, in retrieve
results = client.query(text=target_name)
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/clip_retrieval/clip_client.py", line 84, in query
return self.search_knn_api(text=text)
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/clip_retrieval/clip_client.py", line 131, in search_knn_api
return requests.post(
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/requests/models.py", line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Global seed set to 23
Running on GPUs 0,1
CustomDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Traceback (most recent call last):
File "train.py", line 764, in
st = torch.load(opt.resume_from_checkpoint_custom, map_location='cpu')["state_dict"]
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 713, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 920, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, 'v'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "train.py", line 987, in
if trainer.global_rank == 0:
NameError: name 'trainer' is not defined
I encountered the above problem while implementing the code and asked for an answer

@wj7486
Copy link

wj7486 commented Dec 16, 2024

I encountered the same problem, have you solved it

bash scripts/finetune_real.sh "cat" data/cat real_reg/samples_cat cat finetune_addtoken.yaml '/media/nlp/data/custom-diffusion/stable-diffusion-v-1-4-original/sd-v1-4.ckpt' cat data/cat real_reg/samples_cat cat finetune_addtoken.yaml /media/nlp/data/custom-diffusion/stable-diffusion-v-1-4-original/sd-v1-4.ckpt Traceback (most recent call last): File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/requests/models.py", line 974, in json return complexjson.loads(self.text, **kwargs) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "src/retrieve.py", line 92, in retrieve(args.target_name, args.outpath, args.num_class_images) File "src/retrieve.py", line 28, in retrieve results = client.query(text=target_name) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/clip_retrieval/clip_client.py", line 84, in query return self.search_knn_api(text=text) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/clip_retrieval/clip_client.py", line 131, in search_knn_api return requests.post( File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/requests/models.py", line 978, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) Global seed set to 23 Running on GPUs 0,1 CustomDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Traceback (most recent call last): File "train.py", line 764, in st = torch.load(opt.resume_from_checkpoint_custom, map_location='cpu')["state_dict"] File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 713, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 920, in _legacy_load magic_number = pickle_module.load(f, **pickle_load_args) _pickle.UnpicklingError: invalid load key, 'v'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 987, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined I encountered the above problem while implementing the code and asked for an answer

@HHanTheKing
Copy link

I encountered the same problem, have you solved it

bash scripts/finetune_real.sh "cat" data/cat real_reg/samples_cat cat finetune_addtoken.yaml '/media/nlp/data/custom-diffusion/stable-diffusion-v-1-4-original/sd-v1-4.ckpt' cat data/cat real_reg/samples_cat cat finetune_addtoken.yaml /media/nlp/data/custom-diffusion/stable-diffusion-v-1-4-original/sd-v1-4.ckpt Traceback (most recent call last): File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/requests/models.py", line 974, in json return complexjson.loads(self.text, **kwargs) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "src/retrieve.py", line 92, in retrieve(args.target_name, args.outpath, args.num_class_images) File "src/retrieve.py", line 28, in retrieve results = client.query(text=target_name) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/clip_retrieval/clip_client.py", line 84, in query return self.search_knn_api(text=text) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/clip_retrieval/clip_client.py", line 131, in search_knn_api return requests.post( File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/requests/models.py", line 978, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) Global seed set to 23 Running on GPUs 0,1 CustomDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Traceback (most recent call last): File "train.py", line 764, in st = torch.load(opt.resume_from_checkpoint_custom, map_location='cpu')["state_dict"] File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 713, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "/home/nlp/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 920, in _legacy_load magic_number = pickle_module.load(f, **pickle_load_args) _pickle.UnpicklingError: invalid load key, 'v'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "train.py", line 987, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined I encountered the above problem while implementing the code and asked for an answer

ME TOO! Have you solved it?

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

3 participants