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

Draw mask callback #999

Merged
merged 44 commits into from Dec 10, 2020
Merged

Conversation

Dokholyan
Copy link
Contributor

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contribution guide?
  • Did you check the code style? catalyst-make-codestyle && catalyst-check-codestyle (pip install -U catalyst-codestyle).
  • Did you make sure to update the docs? We use Google format for all the methods and classes.
  • Did you check the docs with make check-docs?
  • Did you write any new necessary tests?
  • Did you check that your code passes the unit tests pytest . ?
  • Did you add your new functionality to the docs?
  • Did you update the CHANGELOG?

Description

Related Issue

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

PS

  • I know, that I could join slack for pull request discussion.

@Dokholyan
Copy link
Contributor Author

I get a fail with "ModuleNotFoundError: No module named 'skimage'" , but I see it in the requirements. So I don't understand a problem

@pep8speaks
Copy link

pep8speaks commented Nov 16, 2020

Hello @Dokholyan! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-12-10 18:03:57 UTC

bagxi
bagxi previously requested changes Nov 17, 2020
elif activation == "Softmax2d":
self.activation = torch.nn.Softmax2d()
else:
self.activation = lambda x: x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How you feel about replacing lambda with torch.nn.Identity?

def _draw_masks(
self,
writer: SummaryWriter,
image_over_predicted_mask: np.array,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use np.ndarray

self,
writer: SummaryWriter,
image_over_predicted_mask: np.array,
image_over_gt_mask: Optional[np.array],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to set the default value to None?

pred_mask_key: str,
image_key: Optional[str] = None,
gt_mask_key: Optional[str] = None,
mask2show: Optional[List[int]] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tuples can also be used, so it is better to use Optional[Iterable[int]] here

if self.step % self.summary_step == 0:
pred_mask = runner.output[self.pred_mask_key][0]
pred_mask = self.activation(pred_mask)
pred_mask = pred_mask.cpu().detach().numpy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use utils.detach?

@mergify mergify bot dismissed bagxi’s stale review November 18, 2020 16:25

Pull request has been modified.

Copy link
Member

@Scitator Scitator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please

@mergify mergify bot dismissed Scitator’s stale review December 5, 2020 16:41

Pull request has been modified.

@Dokholyan
Copy link
Contributor Author

@Scitator

could you please

  1. Maybe it is better to add Callback here https://github.com/catalyst-team/catalyst/blob/master/docs/api/callbacks.rst ?
  2. I am sorry, I don't understand
  3. Ok, It is my fail
    4)What test you would like to add?)

@Scitator
Copy link
Member

Scitator commented Dec 6, 2020

  1. yup, you are right
  2. just follow the steps in "Before submitting" in the head of this PR
  3. we have such segmentation test - https://github.com/catalyst-team/catalyst/blob/master/tests/_tests_cv_segmentation/config.yml, you could try to add your own callback there

@Scitator Scitator added enhancement New feature or request WIP Pull request is under construction labels Dec 6, 2020
CHANGELOG.md Outdated
@@ -10,7 +10,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Added

- ([#1002](https://github.com/catalyst-team/catalyst/pull/1002))
- a few docs
- DrawMasksCallback ([#999](https://github.com/catalyst-team/catalyst/pull/999))
- a few docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong ordering :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Comment on lines 29 to 31
pred_mask_key: str,
image_key: Optional[str] = None,
gt_mask_key: Optional[str] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it correct, that

  • pred_mask_key comes from runner.output
  • image_key comes from runner.input
  • gt_mask_key comes from runner.input
    ?

could we rename them into

  • output_key (or maybe even output_logits_key)
  • input_image_key
  • input_mask_key
    ?

what do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is correct. predicted mask(logits) we get from "runner.output", image(input) and gt_mask(target) we get from "runner.input". The names are all debatable, if you want other names, I can change them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please rename them?
it would be great if all our callbacks will follow the same naming

Comment on lines +49 to +50
log_name: logging name. If you use several such "callbacks", they
must have different logging names
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need it? by default, we usually have tensorboard logger already for each dataset
could you reuse it?
here is an example, https://github.com/catalyst-team/catalyst/blob/master/catalyst/contrib/callbacks/confusion_matrix_logger.py#L41

Copy link
Contributor Author

@Dokholyan Dokholyan Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is better to save images separately. Since they weigh a lot more than everything else, and sometimes there is a desire to remove them. Secondly, the log-name is the name in the Tensorboard, as a prefix for metrics

bagxi
bagxi previously approved these changes Dec 8, 2020
@mergify mergify bot dismissed stale reviews from bagxi and Scitator December 8, 2020 16:40

Pull request has been modified.

@mergify
Copy link

mergify bot commented Dec 9, 2020

This pull request is now in conflicts. @Dokholyan, could you fix it? 🙏

Comment on lines 29 to 31
pred_mask_key: str,
image_key: Optional[str] = None,
gt_mask_key: Optional[str] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please rename them?
it would be great if all our callbacks will follow the same naming

@mergify mergify bot dismissed Scitator’s stale review December 10, 2020 08:05

Pull request has been modified.

@Scitator Scitator merged commit 1aeabb7 into catalyst-team:master Dec 10, 2020
@smivv
Copy link
Contributor

smivv commented Dec 12, 2020

Hello guys,

What do you think about splitting this callback into two different ones:

  1. Mask plotter on the image (gets image + mask + gt_mask, plot them together and put in another output field).
  2. Image logger to Tensorboard/Wandb/etc (gets whatever image you want and send it to log).

Currently I am starting to use Wandb and the part which corresponds to the image overlaying with mask seems to me quite useful, but without Tensorboard logging.

I consider this could be huge improvement for the granularity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request WIP Pull request is under construction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants