talhaanwarch/youtube-tutorials

module 'torchmetrics' has no attribute 'IoU'

Opened this issue · 0 comments

Hello, Thanks for the great work :) !

When I tried to create the model :
model = OurModel() checkpoint_callback = ModelCheckpoint(monitor='val_loss',dirpath='checkpoints', filename='file',save_last=True)

I got the following error :

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input [In [25]](vscode-notebook-cell:?execution_count=25%3E), in <cell line: 1>()
----> [1](vscode-notebook-cell:?execution_count=25&line=1) model = OurModel()
     [2](vscode-notebook-cell:?execution_count=25&line=2) checkpoint_callback = ModelCheckpoint(monitor='val_loss',dirpath='checkpoints',
     [3](vscode-notebook-cell:?execution_count=25&line=3)                                         filename='file',save_last=True)

Input [In [24]](vscode-notebook-cell:?execution_count=24%3E), in OurModel.__init__(self)
    [19](vscode-notebook-cell:?execution_count=24&line=19) self.numworker=multiprocessing.cpu_count()//4
    [21](vscode-notebook-cell:?execution_count=24&line=21) self.criterion= smp.losses.DiceLoss(mode='multiclass')
---> [22](vscode-notebook-cell:?execution_count=24&line=22) self.metrics = torchmetrics.IoU(num_classes=n_classes)
    [24](vscode-notebook-cell:?execution_count=24&line=24) self.train_class = MyClass('[./data/](https://vscode-remote+ssh-002dremote-002b133-002e67-002e48-002e145.vscode-resource.vscode-cdn.net/home-asustor/mehieddine/Notebooks2024/data/)', split='train', mode='fine',
    [25](vscode-notebook-cell:?execution_count=24&line=25)                  target_type='semantic',transforms=transform)
    [26](vscode-notebook-cell:?execution_count=24&line=26) self.val_class = MyClass('[./data/](https://vscode-remote+ssh-002dremote-002b133-002e67-002e48-002e145.vscode-resource.vscode-cdn.net/home-asustor/mehieddine/Notebooks2024/data/)', split='val', mode='fine',
    [27](vscode-notebook-cell:?execution_count=24&line=27)                  target_type='semantic',transforms=transform)

AttributeError: module 'torchmetrics' has no attribute 'IoU'

I am using torchmertics-1.3.0