-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Make the flexible unet more extensible to different backbones #5038
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
Merged
+465
−75
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
d9c6fc6
add a register and a base encoder class for flexible unet.
binliunls c66f5fd
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls 2fce71c
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls 01103a9
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls f8ccee2
add first version encoder.
binliunls 0d6470c
add first version registry
binliunls d0e01cc
add encoder and registry to __init__
binliunls b74bfa9
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls 86d3d91
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls dc0593d
add efficient as encoder for flexible unet
binliunls 5e6e66d
fix the type hints for BasicEncoder
binliunls fe719a2
move registry to this file and update the flexible unet for convenien…
binliunls a33bde3
delete some legacy code
binliunls c5804a5
fix the wrong var name
binliunls ad6ba66
fix type hints issue
binliunls 991c6bb
mv encoder to blocks dir
binliunls 2e9185a
remove registry file
binliunls b3384a5
change function name of BasicEncoder
binliunls e2dc003
add comments
binliunls d0edb6c
add backbone to nets init
binliunls 9dc07fd
update comment
binliunls e3c9cc1
update comment of efficientnet
binliunls 8bb63d5
update comment and add assertion for encoder parameters
binliunls 0f7097a
Merge branch 'dev' into 5011-flexible-unet
binliunls 6f44b78
add resnet encoder to unitest
binliunls 2538541
fix test case code format
binliunls 18e6559
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls b42eb01
Merge branch '5011-flexible-unet' of https://github.com/binliunls/MON…
binliunls 46a5a50
add raising NotImplementedError in abstractmethod
binliunls 1010ce8
update method name of BasicEncoder and corresponding files
binliunls 56b3332
change assert logic in flexible unet to raise error
binliunls fc2f40a
fix the fstring problem
binliunls 8015536
changeflexible unet unitest according to basic encoder.
binliunls d2c407d
fix the string too long problem
binliunls 79d7483
fix the long string bug in windows
binliunls 7fae98c
Merge branch 'Project-MONAI:dev' into 5011-flexible-unet
binliunls b7e3363
change BasicEncoder to BaseEncoder and fix a typo problem
binliunls 81eb1c9
fix efficientnet string error
binliunls ad55efa
add string type input to Register in FlexibleUnet
binliunls c9ba58b
Merge branch 'dev' into 5011-flexible-unet
binliunls 0fc2e3f
fix long string in flexible_unet
binliunls 40e0090
Merge branch '5011-flexible-unet' of https://github.com/binliunls/MON…
binliunls d981093
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 77bcc3a
[MONAI] code formatting
monai-bot adac4eb
fix the format problem
binliunls 9c2216d
Merge branch '5011-flexible-unet' of https://github.com/binliunls/MON…
binliunls f2f9170
add the 2x output constrain to docstring of flexibleunet and its regi…
binliunls 92bb7a2
modify name of base encoder methods, flexible unet register and flexi…
binliunls a1375c2
add a alias name for FlexibleUNet
binliunls 3942fa6
change name of flexible unet backbon
binliunls c2af31a
Merge branch 'dev' into 5011-flexible-unet
wyli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Copyright (c) MONAI Consortium | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from abc import ABCMeta, abstractmethod | ||
| from typing import Dict, List, Tuple | ||
|
|
||
| __all__ = ["BaseEncoder"] | ||
|
|
||
|
|
||
| class BaseEncoder(metaclass=ABCMeta): | ||
| """ | ||
| Abstract class defines interface of encoders in flexible unet. | ||
| Encoders in flexible unet must derive from this class. Each interface method | ||
| should return a list containing relative information about a series of newtworks | ||
| defined by encoder. For example, the efficient-net encoder implement 10 basic | ||
| network structures in one encoder. When calling `get_encoder_name_string_list` | ||
| function, a string list like ["efficientnet-b0", "efficientnet-b1" ... "efficientnet-l2"] | ||
| should be returned. | ||
| """ | ||
|
|
||
| @classmethod | ||
| @abstractmethod | ||
| def get_encoder_parameters(cls) -> List[Dict]: | ||
| """ | ||
| Get parameter list to initialize encoder networks. | ||
| Each parameter dict must have `spatial_dims`, `in_channels` | ||
| and `pretrained` parameters. | ||
| The reason that this function should return a list is that a | ||
| series of encoders can be implemented by one encoder class | ||
| given different initialization parameters. Each parameter dict | ||
| in return list should be able to initialize a unique encoder. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @classmethod | ||
| @abstractmethod | ||
| def num_channels_per_output(cls) -> List[Tuple[int, ...]]: | ||
| """ | ||
| Get number of output features' channels. | ||
| The reason that this function should return a list is that a | ||
| series of encoders can be implemented by one encoder class | ||
| given different initialization parameters. And it is possible | ||
| that different encoders have different output feature map | ||
| channels. Therefore a list of output feature map channel tuples | ||
| corresponding to each encoder should be returned by this method. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @classmethod | ||
| @abstractmethod | ||
| def num_outputs(cls) -> List[int]: | ||
| """ | ||
| Get number of outputs of encoder. | ||
| The reason that this function should return a list is that a | ||
| series of encoders can be implemented by one encoder class | ||
| given different initialization parameters. And it is possible | ||
| that different encoders have different output feature numbers. | ||
| Therefore a list of output feature numbers corresponding to | ||
| each encoder should be returned by this method. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @classmethod | ||
| @abstractmethod | ||
| def get_encoder_names(cls) -> List[str]: | ||
| """ | ||
| Get the name string of encoders which will be used to initialize | ||
| flexible unet. | ||
| The reason that this function should return a list is that a | ||
| series of encoders can be implemented by one encoder class | ||
| given different initialization parameters. And a name string is | ||
| the key to each encoder in flexible unet backbone registry. | ||
| Therefore this method should return every encoder name that needs | ||
| to be registed in flexible unet. | ||
| """ | ||
| raise NotImplementedError | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.