TypeError: object.__new__() .... while creating a Custom Dataset

Hi!
I’m trying to custom my own dataset as in the pytorch tutorial (Datasets & DataLoaders — PyTorch Tutorials 1.12.1+cu102 documentation)

class CustomEmoDataset(Dataset):
    def __int__(self, annotations_file, audio_dir):
        self.annotations = pd.read_csv(annotations_file)
        self.audio_dir = audio_dir

    # i defined __len__ and __getitem__ functions.

ANNOTATIONS_FILE = ".....";
AUDIO_DIR = "...";
    # create object.. 
ied = CustomEmoDataset(ANNOTATIONS_FILE, AUDIO_DIR )

And i’m getting the following error message:

Traceback (most recent call last):

File “/usr/lib/python3.8/typing.py”, line 875, in new
*obj = super().new(cls, *args, *kwds)
TypeError: object.new() takes exactly one argument (the type to instantiate)

But when I use new instead of init as below, it works without error.

    def __new__(cls, annotations_file, audio_dir):
        obj = super().__new__(cls)
        obj.annotations = pd.read_csv(annotations_file)
        obj.audio_dir = audio_dir
        return obj

what could be the reason for this error?

I think you have a typo?
Instead of __int__, try with __init__.

1 Like

it was a good typo )) !:man_facepalming:t2:
Thank you so much :raising_hand_man:t2: