Repository navigation
BUG: Fixed Performance Issue In semantic_segmentor.py - #313
Merged
Merged
Conversation
Moved function self._precess_predictions() out of for loop which was causing major (unnecessary) performance loss for segmentation prediction - especially on larger images/wsi (now up to 12x faster)
…e-semantic_segmentor.py
shaneahmed
reviewed
Mar 7, 2022
shaneahmed
reviewed
Mar 7, 2022
Codecov Report
@@ Coverage Diff @@
## develop #313 +/- ##
===========================================
+ Coverage 99.82% 99.84% +0.02%
===========================================
Files 53 55 +2
Lines 5004 5173 +169
Branches 823 878 +55
===========================================
+ Hits 4995 5165 +170
Misses 2 2
+ Partials 7 6 -1
Continue to review full report at Codecov.
|
…om/TIA-Lab/tiatoolbox into fix-performance-semantic-segmentor
shaneahmed
approved these changes
Mar 14, 2022
shaneahmed
left a comment
Member
There was a problem hiding this comment.
Thanks @vqdang
I will merge once @simongraham has approved it.
simongraham
approved these changes
Apr 8, 2022
Contributor
|
@vqdang thank you a lot for implementing the fix. Great work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carry on from #285 with a dedicated branch for this fix.
Linked to #287
Check list:
@ByteHexler To add clarification on the origin of this performance issue.
tiatoolbox/tiatoolbox/models/engine/semantic_segmentor.py
Lines 670 to 673 in ca0ece6
self._process_predictionsis called every timecum_outputis updated. We will processn**2time compared to the normalntimes. As such, depending on the size of the WSI, this can lead to a significant slowdown, and potentially crash the system because many machines won't be able to hold an entire WSI in the memory. In the initial design, we assumed thattiatoolbox/tiatoolbox/models/engine/semantic_segmentor.py
Line 681 in ca0ece6
tiatoolbox/tiatoolbox/models/engine/semantic_segmentor.py
Line 736 in ca0ece6
free_prediction=Truewill free up the prediction in place, however, this did not work as expected.