Closed dokondr closed 6 months ago
Hi @dokondr, thanks for raising an issue!
I'm unable to replicate this issue locally. Could you try installing with pip and using the most recent version of transformers?
pip install -U transformers
Hi @dokondr, thanks for raising an issue!
I'm unable to replicate this issue locally. Could you try installing with pip and using the most recent version of transformers?
pip install -U transformers
Hi amyeroberts!
It solved the problem, many thanks!
I was still getting the same error with,
# Load model directly
from transformers import AutoImageProcessor, AutoModelForObjectDetection
processor = AutoImageProcessor.from_pretrained("microsoft/table-transformer-structure-recognition-v1.1-all")
model = AutoModelForObjectDetection.from_pretrained("microsoft/table-transformer-structure-recognition-v1.1-all")
even after updating transformers to the latest version.
For now the dirty way, is to patch a custom json serialising method - https://stackoverflow.com/a/38764817/4296772
from transformers.models.resnet.configuration_resnet import ResNetConfig
from fastcore import patch_to
from json import JSONEncoder
def _default(self, obj):
return getattr(obj.__class__, "__json__", _default.default)(obj)
_default.default = JSONEncoder().default
JSONEncoder.default = _default
@patch_to(ResNetConfig)
def __json__(self):
return self.to_dict()
@sizhky Could you share your running environment: run transformers-cli env
in the terminal and copy-paste the output?
I'm unable to replicate with the shared snippet running on the development branch
Sorry I have moved on to a different project. You can share more details here if the issue is still relevant
System Info
When loading model: AutoModelForObjectDetection.from_pretrained("microsoft/table-transformer-detection", revision="no_timm")
transformers/configuration_utils.py returns a TypeError: Object of type ResNetConfig is not JSON serializable
This error happens when I run in virtual environment (Win10): torch==2.2.0 torchvision==0.17.0 transformers==4.31.0
And also with latest versions of these libraries.
Yet it does not happen in Conda default environment that was created long ago: torch==2.2.0 torchvision==0.17.0 transformers==4.31.0.dev0
Today when I try: pip install transformers==4.31.0.dev0
I get: ERROR: No matching distribution found for transformers==4.31.0.dev0
So, it looks like 'transformers 4.31.0.dev0' no longer exist. How to solve then TypeError: Object of type ResNetConfig is not JSON serializable ?
Detailed environment info where this error happens
transformers
version: 4.31.0Who can help?
@amyeroberts
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
import torch from torchvision import transforms from transformers import AutoModelForObjectDetection
model = AutoModelForObjectDetection.from_pretrained("microsoft/table-transformer-detection", revision="no_timm")
Expected behavior
"microsoft/table-transformer-detection" model should load without errors