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

I can't run "cars segmentation (camvid).ipynb" example #886

Open
atekgul opened this issue Jun 11, 2024 · 2 comments
Open

I can't run "cars segmentation (camvid).ipynb" example #886

atekgul opened this issue Jun 11, 2024 · 2 comments

Comments

@atekgul
Copy link

atekgul commented Jun 11, 2024

Hi.
As I understand the below code in cars segmentation (camvid).ipynb should be changed.
Because I can't run it. Am I right?
Do you plan to update the examples?

  1. There is no utils under smp.
  • smp.utils.losses.DiceLoss() => smp.losses.DiceLoss()
  • smp.utils.metrics.IOU(threshold=0.5) => smp.metrics_iou_score(tp, fp, fn, tn)
  1. TrainEpoch and ValidEpoch are not valid anymore.

Code:
//Dice/F1 score - https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient
//IoU/Jaccard score - https://en.wikipedia.org/wiki/Jaccard_index

loss = smp.utils.losses.DiceLoss()
metrics = [smp.utils.metrics.IoU(threshold=0.5),]
optimizer = torch.optim.Adam([dict(params=model.parameters(), lr=0.0001),])

//create epoch runners
//it is a simple loop of iterating over dataloader`s samples
train_epoch = smp.utils.train.TrainEpoch(model, loss=loss, metrics=metrics, optimizer=optimizer, device=DEVICE, verbose=True,)

valid_epoch = smp.utils.train.ValidEpoch(model, loss=loss, metrics=metrics, device=DEVICE, verbose=True,)

@qubvel
Copy link
Collaborator

qubvel commented Jun 11, 2024

Hi, thanks for the issue, yes, the utils code is deprecated and going to be removed. I am planning to update example in favor to use PyTorch lightning. As for now you can refer to binary segmentation example.

P.S. utils is still accessible, but should be imported as
from segmentation_models_pytorch import utils

@atekgul
Copy link
Author

atekgul commented Jun 11, 2024

Thanks.

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

2 participants