question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change HoVerNet Model Output from Dict to Tensor

See original GitHub issue

HoVerNet model has three branches and currently each of them are being return with an associated key and all together as a dictionary. This approach is nice since we know what branch we are dealing with with the Enums that are defined; however, it is creating some challenges since this kind of outputs is not common in MONAI, and requires some changes:

  1. HoVerNet Loss function needs to accept dictionary of Tensors (instead of one Tensor) for prediction and target (https://github.com/Project-MONAI/MONAI/pull/5199)
  2. a new PrepareBatch is need to extract all the keys for the target and return a dictionary for target (instead of a tensor)
  3. SuperviseTrainer needs to be updated to accept dictionary as the model outputs
  4. Post process Transforms should implement new additional keys (https://github.com/Project-MONAI/MONAI/pull/5186#discussion_r981308312)

Considering that with this simple change, there is no need for any of the above changes, I am leaning toward making this backward incompatibility and making HoVerNet outputs a tensor where each channel represents output of one branch:

  • first channel: nuclei segmentation (NP branch)
  • second channel: horizontal map (HV branch)
  • third channel: vertical map (HV branch)
  • fourth channel (and any additional channel): classification output (NC branch)

@wyli @Nic-Ma @ericspod @rijobro @JHancox What do you think?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
drbehcommented, Oct 7, 2022

Hi @Nic-Ma, thanks for your questions.

  1. yes, they are all have the same spatial shape
  2. postprocessing can use three of the channels and create a new tensor for instance segmentation.

However, IMO we need more motivation to make a backward incompatible change, so I close this issue, and plan for the afterward changes.

1reaction
drbehcommented, Oct 5, 2022

@wyli @JHancox Thanks for your feedback. I agree with @JHancox, that dictionaries are more elegant [and readable] than tuples in this case. If there is not enough motivation to make it tensor, we continue with the current implementation (dictionaries) and I will close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change HoVerNet Model Output from Dict to Tensor - PullAnswer
HoVerNet model has three branches and currently each of them are being return with an associated key and all together as a dictionary....
Read more >
Training an ML Model (HoVer-Net) - PathML's documentation!
In this notebook, we will train HoVer-Net model to perform nucleus detection and classification, using data from PanNuke dataset.
Read more >
Use dictionary on tensor - python - Stack Overflow
I have my data on a tf.record and dont want to create one everytime I change classes, so trying to modify it in...
Read more >
Issue running code · Issue #12 · vqdang/hover_net - GitHub
I am facing the error of FilenotfoundError for the stats.json file while running the infer.py file. Do I need to train the model...
Read more >
Convert texts into tensors for Deep Learning - Medium
A simple template to convert textual data into tensor format ... conversion of terms in the dictionary into tensors ... The output will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found