FixError: TypeError: Size should be int or sequence. Got <class 'dict'>

177 views Asked by At

I am trying to load the eurosat dataset fro image classification. When I am importing the data it is getting stored as a dict. When I am trying to apply basic augmentation like Resize using the Auto Feature Extractor from transformers I am getting the following error. Size should be int or sequence. Got <class 'dict'> Can anyone please help in fixing this!

dataset = load_dataset("imagefolder", data_dir="/content/drive/MyDrive/datasets/EuroSAT_RGB/")


feature_extractor = AutoFeatureExtractor.from_pretrained(model_checkpoint) #model= microsoft/swin-tiny-patch4-window7-224
feature_extractor

val_transforms = Compose(
        [
            Resize(feature_extractor.size),  #getting the error popped here
            CenterCrop(feature_extractor.size),
            ToTensor(),
            normalize,
        ]
    )
1

There are 1 answers

0
monistar On

I think it might be too late to respond, but I also faced this error. By installing a different version of the Transformer, I managed to resolve this error.

pip install -q transformers==4.23.1