[bug] Object of type ResNetConfig is not JSON serializable

#1
by lparolari - opened

Hi, I copied the snippet provided in the readme and just execute it.
This line

model = DeformableDetrForObjectDetection.from_pretrained("facebook/deformable-detr-detic")

raises a TypeError

TypeError: Object of type ResNetConfig is not JSON serializable

Could you please help me? Thanks!

Stacktrace:

Traceback (most recent call last):
  File "/home/lparolari/Projects/blendvg/deitc.py", line 14, in <module>
    model = DeformableDetrForObjectDetection.from_pretrained("facebook/deformable-detr-detic")
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2175, in from_pretrained
    config, model_kwargs = cls.config_class.from_pretrained(
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/site-packages/transformers/configuration_utils.py", line 553, in from_pretrained
    return cls.from_dict(config_dict, **kwargs)
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/site-packages/transformers/configuration_utils.py", line 720, in from_dict
    logger.info(f"Model config {config}")
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/site-packages/transformers/configuration_utils.py", line 752, in __repr__
    return f"{self.__class__.__name__} {self.to_json_string()}"
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/site-packages/transformers/configuration_utils.py", line 824, in to_json_string
    return json.dumps(config_dict, indent=2, sort_keys=True) + "\n"
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/home/lparolari/.miniconda3/envs/weakvg++/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ResNetConfig is not JSON serializable

Sign up or log in to comment