train-CLIP-FT icon indicating copy to clipboard operation
train-CLIP-FT copied to clipboard

`train_dataloader` must be implemented to be used with the Lightning Trainer

Open ShuxunoO opened this issue 1 year ago • 1 comments

hello I am going to train CLIP with my own dataset, but I met a exception :

raise MisconfigurationException("train_dataloader must be implemented to be used with the Lightning Trainer") lightning_fabric.utilities.exceptions.MisconfigurationException: train_dataloader must be implemented to be used with the Lightning Trainer

Where should I define my own "train_dataloader" function and how can I call it?

Could you please give me a template ?

The best wishes!

ShuxunoO avatar Nov 16 '23 03:11 ShuxunoO

I add a function in models/wrapper.py in class CLIPWrapper(pl.LightningModule): ` class CLIPWrapper(pl.LightningModule):

add this function

def train_dataloader(self):
    return self.trainer.datamodule.train_dataloader()

`

and it works!

ShuxunoO avatar Nov 16 '23 09:11 ShuxunoO