Getting runtime error after successfully running a couple times
I was playing around and entered a couple prompts successfully but at some point it stopped working and I'm getting following stacktrace:
(ldm) C:\SoftwareDevelopment\StabilityAI\stable-diffusion>python optimizedSD/optimized_txt2img.py --prompt "david beckam, oil_painting, headshot" --H 100 --W 100 --n_iter 1 --n_samples 1 --ddim_steps
50 --skip_grid --turbo --precision full
Global seed set to 475985
Loading model from models/ldm/stable-diffusion-v1/model.ckpt
Global Step: 470000
UNet: Running in eps-prediction mode
CondStage: Running in eps-prediction mode
Traceback (most recent call last):
File "C:\miniconda3\envs\ldm\lib\site-packages\transformers\configuration_utils.py", line 650, in _get_config_dict
config_dict = cls._dict_from_json_file(resolved_config_file)
File "C:\miniconda3\envs\ldm\lib\site-packages\transformers\configuration_utils.py", line 734, in _dict_from_json_file
return json.loads(text)
File "C:\miniconda3\envs\ldm\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\miniconda3\envs\ldm\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\miniconda3\envs\ldm\lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 88 column 3 (char 2317)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "txt2img.py", line 211, in <module>
modelCS = instantiate_from_config(config.modelCondStage)
File "c:\softwaredevelopment\stabilityai\stable-diffusion\ldm\util.py", line 85, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "c:\softwaredevelopment\stabilityai\stable-diffusion\optimizedSD\ddpm.py", line 262, in __init__
self.instantiate_cond_stage(cond_stage_config)
File "c:\softwaredevelopment\stabilityai\stable-diffusion\optimizedSD\ddpm.py", line 282, in instantiate_cond_stage
model = instantiate_from_config(config)
File "c:\softwaredevelopment\stabilityai\stable-diffusion\ldm\util.py", line 85, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "c:\softwaredevelopment\stabilityai\stable-diffusion\ldm\modules\encoders\modules.py", line 142, in __init__
self.transformer = CLIPTextModel.from_pretrained(version)
File "C:\miniconda3\envs\ldm\lib\site-packages\transformers\modeling_utils.py", line 1764, in from_pretrained
config, model_kwargs = cls.config_class.from_pretrained(
File "C:\miniconda3\envs\ldm\lib\site-packages\transformers\models\clip\configuration_clip.py", line 126, in from_pretrained
config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
File "C:\miniconda3\envs\ldm\lib\site-packages\transformers\configuration_utils.py", line 553, in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
File "C:\miniconda3\envs\ldm\lib\site-packages\transformers\configuration_utils.py", line 652, in _get_config_dict
raise EnvironmentError(
OSError: It looks like the config file at 'C:\Users\STUDIUM/.cache\huggingface\transformers\9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142' is not a valid JSON file.
Also started having this suddenly. I thought that stable-diffusion was ran mostly offline so I'm very surprised to have these issues all of a sudden. https://www.reddit.com/r/StableDiffusion/comments/xa1x6c/help_stablediffusion_running_into_weird_cache/
Exactly the same
This can be worked around in the meantime by manually editing the file in question and removing two trailing commas in two dict objects (one on line 87, one on line 169)
Clearing the hugging face cache does not help suprasingly
This can be worked around in the meantime by manually editing the file in question and removing two trailing commas in two dict objects (one on line 87, one on line 169)
Which file? Could you please share a snippet from the lines in question? Thanks beforehand
https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/config.json has JSON error. I copied it to https://jsonlint.com/ and it detects 2 last-comma problem.
for quick fix, directly editing …/.cache/huggingface/transformers/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142 to solve it locally.
This can be worked around in the meantime by manually editing the file in question and removing two trailing commas in two dict objects (one on line 87, one on line 169)
Which file? Could you please share a snippet from the lines in question? Thanks beforehand
It will be in the file listed after:
OSError: It looks like the config file at
You'll see an unneeded comma at 87 and 169 like:
"num_hidden_layers": 12,
"projection_dim": 768,
},
Remove it:
"num_hidden_layers": 12,
"projection_dim": 768
},
Sorry for the newbie questions, but how do I edit a file that is linked online? Do I have to change the link from
{"url": "https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/config.json", "etag": "\"fd2437b2c4b8d8c50bf8ce1cde84c286ed279f6c\""}
To local?
Like
{"url": "C:\Users\Crag\.cache\huggingface\transformers\config.json", "etag": "\"fd2437b2c4b8d8c50bf8ce1cde84c286ed279f6c\""}

Thanks, went to run some prompts today and just started messing up. Cleared out my whole repo thinking I'd broke something.
@Cragsand
you can see 3 files in cache folder , no extension, json extension, lock extention.
file named .json is metadata about the cache, you will edit no-extension file.
May I know why a offline project is getting broken by an online change? Someone clarify please. PS: I see the fix is already in PR.

Thank you for taking the time to explaining. I edited this one removing the JSON formatting error but its still throwing errors:

Thank you for taking the time to explaining. I edited this one removing the JSON formatting error but its still throwing errors:
There are 2 formatting errors. Try fixing the other one. It worked for me
The erros are the commas at lines 87 and 169
THANK YOU! For fellow noobs you have to remove the commas here and here in the cached file named "9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142" without any file extension

question... i thought stable diffusion was 100% offline? why the sudden global JSON error?
Also opened a PR on the transformers repo to improve the error message a bit in case something like this happens again.
Interesting, not sure why this could happen as it is local
Any word on an elegant actual workaround (in code, so we don't have to tell our users "just delete this line in this obscure file in your computer")? Perhaps we should modify the code to expect json5 or yaml? https://stackoverflow.com/questions/52636846/python-cant-parse-json-with-extra-trailing-comma but that seems like a terrible solution when the real solution is to just not populate it with trailing comma.
Where exactly is the code that introduces this nuisance of a trailing comma?
removing some comment from rapidly copied animation parameters solved the stack overflow and error message for me. rotation_3d_y = "0: (0.25sin(23.141t/250))"#@param {type:"string"} -->spat error rotation_3d_y = 0: (0.25sin(23.141t/250)) --> purred like a cat had a " in the comment, brandonizing all the following variables.