Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] What's wrong with the initialize function in classes #1592

Open
sceddd opened this issue Oct 26, 2024 · 0 comments
Open

[Docs] What's wrong with the initialize function in classes #1592

sceddd opened this issue Oct 26, 2024 · 0 comments

Comments

@sceddd
Copy link

sceddd commented Oct 26, 2024

📚 The doc issue

I have no idea how to create a custom datasets in mmengine with init method, i tried to create a fewshot dataset like this
Error

@DATASETS.register_module()
class FewShotDatasetLVISV1Dataset(BatchShapePolicyDataset, LVISDataset):

    METAINFO = {
        'classes': ('object',),
        'palette': [(220, 20, 60)]
    }

    def __init__(self, num_shot=5, repeat=False, *args, **kwargs):
        super().__init__(*args, **kwargs)
        print('FewShotDatasetLVISV1Dataset')
        print(num_shot)

        print("self num",self.num_shot)
        self.repeat = repeat

Correct

@DATASETS.register_module()
class FewShotDatasetLVISV1Dataset(BatchShapePolicyDataset, LVISDataset):

    METAINFO = {
        'classes': ('object',),
        'palette': [(220, 20, 60)]
    }

    def __init__(self, num_shot=5, repeat=False, *args, **kwargs):
        print('FewShotDatasetLVISV1Dataset')
        print(num_shot)
        print("self num",self.num_shot)
        self.repeat = repeat
        super().__init__(*args, **kwargs)

why it only run the super().init(*args, **kwargs) but don't continue with the rest of initialize block? And I realize that I have to implement the variables first before run the super class implementation, why the logic is so confuse? and no docs talking about it. I think you should create one for this annoying error.

Suggest a potential alternative/fix

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant