Skip to content

[feat] Adding camvid segmentation multiclass as an example #922

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

Merged

Conversation

TimbusCalin
Copy link
Contributor

@TimbusCalin TimbusCalin commented Sep 7, 2024

  • Multiclass semantic segmentation example on all classes
  • Background class is added as an additional class
  • Initial PyTorch Lightning example is maintained, adapted in accordance with multiclass

Fixes: #911

@qubvel
Copy link
Collaborator

qubvel commented Sep 7, 2024

Hi @TimbusCalin, thanks a lot for your contribution! Looks great overall and it's pretty close to being merged, here are just a few minor comments:

  1. Remove commented code or replace it with comments / assertations
# Specify classes only if necessary
# CLASSES = ['road','car']
# Debugging unique values and type of mask
# print(f"Mask dtype after casting: {mask.dtype}, unique values: {torch.unique(mask)}, shape: {mask.shape}")
# Debugging logits shape
# print(f"Logits mask shape: {logits_mask.shape}")

maybe somewhere else

  1. It would also be cool to add metric computation per class, if you have time and know how to do that :) but that's optional

@abdksyed
Copy link

abdksyed commented Sep 9, 2024

I think the OUT_CLASSES should be equal to length of CLASSES. Since the background(unlabelled) classes is already included in the CLASSES list.

OUT_CLASSES = len(train_dataset.CLASSES) + 1

This should be in case when no class is specified.

OUT_CLASSES = len(train_dataset.CLASSES)

The +1 will happen when the user specifies a list of classes, at that point we will have to use the provided len(class_list) + 1.

@TimbusCalin
Copy link
Contributor Author

TimbusCalin commented Sep 9, 2024

Hello @abdksyed @qubvel.

I am fine with this approach that @abdksyed mentioned, to integrate my PR now, and I will let @abdksyed do the class-metrics-wise function now, once the PR is integrated; glad that we synchronized on this.

@abdksyed You are right, that's why I updated it accordingly in this commit here aa8226c

@abdksyed
Copy link

abdksyed commented Sep 9, 2024

Hello @abdksyed @qubvel.

I am fine with this approach that @abdksyed mentioned, to integrate my PR now, and I will let @abdksyed do the class-metrics-wise function now, once the PR is integrated; glad that we synchronized on this.

@abdksyed You are right, that's why I updated it accordingly in this commit here aa8226c

Oh sorry, I missed your last commit. Apologies

@TimbusCalin
Copy link
Contributor Author

@abdksyed no issue, another pair of (good!) eyes is always necessary and welcome!

@TimbusCalin
Copy link
Contributor Author

@qubvel I guess the dillema is solved. We can integrate if you have no other remarks.

@qubvel qubvel merged commit ccccadd into qubvel-org:main Sep 10, 2024
@qubvel
Copy link
Collaborator

qubvel commented Sep 10, 2024

Thanks for your contribution!

@sajeedmehrab
Copy link

@abdksyed Do you have an example for how we can compute the class-wise miou?

@abdksyed
Copy link

abdksyed commented Nov 8, 2024

@sajeedmehrab
I use the torchmetrics. You can give the per_class as True to get class wise iou.

@qubvel
Copy link
Collaborator

qubvel commented Nov 8, 2024

Would appreciate if you contribute torch metrics example 😊

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

Successfully merging this pull request may close these issues.

Add multiclass fine-tuning example
4 participants