Getting model output as nan

I am working on Melanoma Classification task where I have to classify the patients into two categories on the basis of their skin images. I have used efficientnetb3 model (pretrained) with minor transformations. But I am getting nan as the model output while training. What could be the possible reasons?

class MelanomaDataset(Dataset):

    def __init__(self, dataframe, image_dir, transforms = None):
        self.dataframe = dataframe
        self.image_dir = image_dir
        self.transforms = transforms

    def __len__(self):
        return self.dataframe.shape[0]

    def __getitem__(self, idx):
        img_name = '{}.png'.format(self.dataframe.iloc[idx, 0])
        fullname = self.image_dir + img_name
        image = cv2.imread(fullname)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

        num = self.dataframe.loc[:,'target'].iloc[idx]
        label = np.asarray(int_to_label[num])

        if self.transforms:
            image = self.transforms(image = image)['image']

        return image, label

Could you post the model definition as well as the training routine?
If you suspect that the data loading might be faulty, you could add torch.is_finite(data) inside the training loop to check that no input contains NaNs or Infs.

I have used pretrained model from timm and have used Stratified K-fold. The input are images on which I have applied augmentations, Horizontal Flip, Vertical Flip, Centre Crop and Normalization