AniPortrait icon indicating copy to clipboard operation
AniPortrait copied to clipboard

OSError: It looks like the config file at './pretrained_model/wav2vec2-base-960h/config.json' is not a valid JSON file.

Open maximofn opened this issue 1 year ago • 4 comments

I have downloaded wav2vec2-base-960h/config.json from https://huggingface.co/facebook/wav2vec2-base-960h/blob/main/config.json, execute python -m scripts.app and get this error

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py", line 659, in _get_config_dict
    config_dict = cls._dict_from_json_file(resolved_config_file)
  File "/usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py", line 751, in _dict_from_json_file
    return json.loads(text)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/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 "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/AniPortrait/scripts/app.py", line 43, in <module>
    a2m_model = Audio2MeshModel(audio_infer_config['a2m_model'])
  File "/AniPortrait/src/audio_models/model.py", line 25, in __init__
    self.audio_encoder_config = Wav2Vec2Config.from_pretrained(model_path, local_files_only=True)
  File "/usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py", line 547, in from_pretrained
    config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py", line 574, in get_config_dict
    config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py", line 662, in _get_config_dict
    raise EnvironmentError(
OSError: It looks like the config file at './pretrained_model/wav2vec2-base-960h/config.json' is not a valid JSON file.

maximofn avatar Apr 13 '24 06:04 maximofn

Have you tried changing this to the exact path in your environment? ./pretrained_model/wav2vec2-base-960h/config.json

G-force78 avatar Apr 13 '24 07:04 G-force78

It is not a path problem, I have put the json in ./pretrained_model/wav2vec2-base-960h/. I even added in /usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py, in line 659 this

            with open(resolved_config_file, "r", encoding="utf-8") as reader:
                print(reader.read())

And print what is inside the json. So it is not a path problem

maximofn avatar Apr 13 '24 08:04 maximofn

I ran it in a docker which is documented here https://github.com/maximofn/aniPortrait_docker, in case you want to take a better look at it

maximofn avatar Apr 13 '24 09:04 maximofn

You can check with the following steps:

  1. make sure pretrained_model/wav2vec2-base-960h/config.json is complete
  2. make ure pretrained_model/wav2vec2-base-960h is complete, or you can manual download wav2vec2-base-960h
  3. update the veision of json

Zejun-Yang avatar Apr 15 '24 02:04 Zejun-Yang

Thank you, I fixed the error.

The problem was that I was downloading the json like this wget https://huggingface.co/facebook/wav2vec2-base-960h/blob/main/config.json and now I download it like this wget -q https://huggingface.co/facebook/wav2vec2-base-960h/raw/main/config.json.

That is, I changed blob to raw.

maximofn avatar May 03 '24 05:05 maximofn