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

Speedup #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Speedup #1

wants to merge 5 commits into from

Conversation

vict0rsch
Copy link
Contributor

@vict0rsch vict0rsch commented Apr 24, 2020

@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 code

  • restricting the overall area (see comments 1. and 2.) 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 not smooth_mask

  • pathlib.Path already has built-in the tools to check if a dir exists or not, and create it

@vict0rsch
Copy link
Contributor Author

Speed up however depends on the topology of the mask and falls down to ~ 30% speedup in some cases :( I'll try to look at why

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.

1 participant