Deci-AI / super-gradients

Easily train or fine-tune SOTA computer vision models with one open source training library. The home of Yolo-NAS.
https://www.supergradients.com
Apache License 2.0
4.43k stars 481 forks source link

DiceLoss is unknown object type #2000

Open james-imi opened 1 month ago

james-imi commented 1 month ago

🐛 Describe the bug

Getting this error if loss is DiceLoss

    result = train(exp_name, params)
  File "/home/ubuntu/super-gradients/train_segm_opt.py", line 163, in train
    trainer.train(model=model, training_params=default_params, train_loader=train_dataloader, valid_loader=val_dataloader)
  File "/opt/conda/envs/nas/lib/python3.9/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 1270, in train
    self.criterion = LossesFactory().get({self.training_params.loss: self.training_params.criterion_params})
  File "/opt/conda/envs/nas/lib/python3.9/site-packages/super_gradients/common/factories/base_factory.py", line 70, in get
    raise UnknownTypeException(_type, list(self.type_dict.keys()))
super_gradients.common.exceptions.factory_exceptions.UnknownTypeException: Unknown object type: DiceLoss in configuration. valid types are: ['MSE', 'mse', '_deprecated_objects', 'KDLogitsLoss', 'kd_loss', 'CrossEntropyLoss', 'cross_entropy', 'RSquaredLoss', 'r_squared_loss', 'ShelfNetOHEMLoss', 'shelfnet_ohem_loss', 'ShelfNetSemanticEncodingLoss', 'shelfnet_se_loss', 'YoloXDetectionLoss', 'yolox_loss', 'YoloXFastDetectionLoss', 'yolox_fast_loss', 'SSDLoss', 'ssd_loss', 'BCEDiceLoss', 'bce_dice_loss', 'DiceCEEdgeLoss', 'dice_ce_edge_loss', 'PPYoloELoss', 'ppyoloe_loss', 'DEKRLoss', 'dekr_loss', 'STDCLoss', 'stdc_loss', 'RescoringLoss', 'rescoring_loss', 'YoloNASPoseLoss']

Versions

latest

BloodAxe commented 1 month ago

It seems DiceLoss is missing register decorator for some reason. Thanks for reporting about that. May I ask - are you using some colab notebook with this loss or something else? Trying to understand how did you came up with with loss.

james-imi commented 1 month ago

just my own notebook. also, by looking at your code. the Losses does not have DiceLoss in there