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.
@51N84D (and good reading for @tianyu-z and @melisandeteng):
Always run black formatter on your code, you can formatOnSave in vscode's settings. It's better for you, it's better practice, it's easier to read your code when working in teams. Standardization helps reduce error-rate
Always put code that is to be executed under and
if __name__ == "__main__"
statement. This prevents your code from running when not specifically asked to. For instance, if another scripts imports a function from it.max() takes a
key=
argument that lets you specify how you want to compute the "value" of an item in an iterable. using it speeds up x3 the processing time required to find the largest contour. It's minor as it only took 1.5 micro-sec in the first place mut it may matter in another piece of coderestricting the overall area (see comments
1.
and2.
) speeds up x3 the computation of decayed mask values ; it may become usable in production then :)initial code had a typo where you saved
mask
and notsmooth_mask
pathlib.Path
already has built-in the tools to check if a dir exists or not, and create it