Skip to content

Commit

Permalink
Merge branch 'dev' into randfgcrop
Browse files Browse the repository at this point in the history
  • Loading branch information
Can-Zhao authored Jun 1, 2022
2 parents bbe2d56 + 38b7943 commit 5aec41d
Show file tree
Hide file tree
Showing 49 changed files with 2,400 additions and 135 deletions.
5 changes: 5 additions & 0 deletions docs/source/apps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ Applications
`Detection`
-----------

`Hard Negative Sampler`
~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: monai.apps.detection.utils.hard_negative_sampler
:members:

`RetinaNet`
~~~~~~~~~~~
.. automodule:: monai.apps.detection.networks.retinanet_network
Expand Down
1 change: 1 addition & 0 deletions docs/source/bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Model Bundle
.. autofunction:: run
.. autofunction:: verify_metadata
.. autofunction:: verify_net_in_out
.. autofunction:: init_bundle
7 changes: 4 additions & 3 deletions docs/source/mb_specification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,22 @@ The format for tensors used as inputs and outputs can be used to specify semanti
* **latent**: ND tensor of data from the latent space from some layer of a network
* **gradient**: ND tensor of gradients from some layer of a network

Spatial shape definition can be complex for models accepting inputs of varying shapes, especially if there are specific conditions on what those shapes can be. Shapes are specified as lists of either positive integers for fixed sizes or strings containing expressions defining the condition a size depends on. This can be "*" to mean any size, or use an expression with Python mathematical operators and one character variables to represent dependence on an unknown quantity. For example, "2**n" represents a size which must be a power of 2, "2**n*m" must be a multiple of a power of 2. Variables are shared between dimension expressions, so a spatial shape of `["2**n", "2**n"]` states that the dimensions must be the same powers of 2 given by `n`.
Spatial shape definition can be complex for models accepting inputs of varying shapes, especially if there are specific conditions on what those shapes can be. Shapes are specified as lists of either positive integers for fixed sizes or strings containing expressions defining the condition a size depends on. This can be "*" to mean any size, or use an expression with Python mathematical operators and one character variables to represent dependence on an unknown quantity. For example, "2**p" represents a size which must be a power of 2, "2**p*n" must be a multiple of a power of 2. Variables are shared between dimension expressions, a spatial shape example: `["*", "16*n", "2**p*n"]`.

A JSON schema for this file can be found at https://github.com/Project-MONAI/MONAI/blob/3049e280f2424962bb2a69261389fcc0b98e0036/monai/apps/mmars/schema/metadata.json
The download link of a JSON schema to verify this file can be found within it with key "schema".

An example JSON metadata file:

::

{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
"version": "0.1.0",
"changelog": {
"0.1.0": "complete the model package",
"0.0.1": "initialize the model package structure"
},
"monai_version": "0.8.0",
"monai_version": "0.9.0",
"pytorch_version": "1.10.0",
"numpy_version": "1.21.2",
"optional_packages_version": {"nibabel": "3.2.1"},
Expand Down
40 changes: 40 additions & 0 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ Intensity
:members:
:special-members: __call__


`ForegroundMask`
""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/ForegroundMask.png
:alt: example of ForegroundMask
.. autoclass:: ForegroundMask
:members:
:special-members: __call__

IO
^^

Expand Down Expand Up @@ -737,6 +746,18 @@ Spatial
:members:
:special-members: __call__

`GridPatch`
"""""""""""
.. autoclass:: GridPatch
:members:
:special-members: __call__

`RandGridPatch`
"""""""""""""""
.. autoclass:: RandGridPatch
:members:
:special-members: __call__

`GridSplit`
"""""""""""
.. autoclass:: GridSplit
Expand Down Expand Up @@ -1327,6 +1348,13 @@ Intensity (Dict)
:members:
:special-members: __call__

`ForegroundMaskd`
"""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/ForegroundMaskd.png
:alt: example of ForegroundMaskd
.. autoclass:: ForegroundMaskd
:members:
:special-members: __call__

IO (Dict)
^^^^^^^^^
Expand Down Expand Up @@ -1513,6 +1541,18 @@ Spatial (Dict)
:members:
:special-members: __call__

`GridPatchd`
""""""""""""
.. autoclass:: GridPatchd
:members:
:special-members: __call__

`RandGridPatchd`
""""""""""""""""
.. autoclass:: RandGridPatchd
:members:
:special-members: __call__

`GridSplitd`
""""""""""""
.. autoclass:: GridSplitd
Expand Down
4 changes: 2 additions & 2 deletions monai/apps/detection/networks/retinanet_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(
self.num_classes = num_classes
self.num_anchors = num_anchors

def forward(self, x: Union[List[Tensor], Tensor]) -> List[Tensor]:
def forward(self, x: List[Tensor]) -> List[Tensor]:
"""
It takes a list of feature maps as inputs, and outputs a list of classification maps.
Each output classification map has same spatial size with the corresponding input feature map,
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self, in_channels: int, num_anchors: int, spatial_dims: int):
torch.nn.init.normal_(layer.weight, std=0.01) # type: ignore
torch.nn.init.zeros_(layer.bias) # type: ignore

def forward(self, x: Union[List[Tensor], Tensor]) -> List[Tensor]:
def forward(self, x: List[Tensor]) -> List[Tensor]:
"""
It takes a list of feature maps as inputs, and outputs a list of box regression maps.
Each output box regression map has same spatial size with the corresponding input feature map,
Expand Down
3 changes: 2 additions & 1 deletion monai/apps/detection/utils/anchor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def grid_anchors(self, grid_sizes: List[List[int]], strides: List[List[Tensor]])
"""
anchors = []
cell_anchors = self.cell_anchors
assert cell_anchors is not None
if cell_anchors is None:
raise AssertionError

if not (len(grid_sizes) == len(strides) == len(cell_anchors)):
raise ValueError(
Expand Down
Loading

0 comments on commit 5aec41d

Please sign in to comment.