11"""
22Source url: https://github.com/OPHoperHPO/image-background-remove-tool
3+
34Author: Nikita Selin (OPHoperHPO)[https://github.com/OPHoperHPO].
5+
46License: Apache License 2.0
57"""
68import pathlib
@@ -29,14 +31,14 @@ def __init__(
2931 fp16 : bool = False ,
3032 ):
3133 """
32- Initialize the DeepLabV3 model
34+ Initialize the ` DeepLabV3` model
3335
3436 Args:
35- device: processing device
36- input_image_size: input image size
37- batch_size: the number of images that the neural network processes in one run
38- load_pretrained: loading pretrained model
39- fp16: use half precision
37+ device (Literal[cpu, cuda], default=cpu) : processing device
38+ input_image_size () : input image size
39+ batch_size (int, default=10) : the number of images that the neural network processes in one run
40+ load_pretrained (bool, default=True) : loading pretrained model
41+ fp16 (bool, default=False) : use half precision
4042
4143 """
4244 self .device = device
@@ -69,9 +71,7 @@ def to(self, device: str):
6971 Moves neural network to specified processing device
7072
7173 Args:
72- device (:class:`torch.device`): the desired device.
73- Returns:
74- None
74+ device (Literal[cpu, cuda]): the desired device.
7575
7676 """
7777 self .network .to (device )
@@ -81,10 +81,10 @@ def data_preprocessing(self, data: PIL.Image.Image) -> torch.Tensor:
8181 Transform input image to suitable data format for neural network
8282
8383 Args:
84- data: input image
84+ data (PIL.Image.Image) : input image
8585
8686 Returns:
87- input for neural network
87+ torch.Tensor: input for neural network
8888
8989 """
9090 copy = data .copy ()
@@ -93,18 +93,18 @@ def data_preprocessing(self, data: PIL.Image.Image) -> torch.Tensor:
9393
9494 @staticmethod
9595 def data_postprocessing (
96- data : torch .tensor , original_image : PIL .Image .Image
96+ data : torch .Tensor , original_image : PIL .Image .Image
9797 ) -> PIL .Image .Image :
9898 """
9999 Transforms output data from neural network to suitable data
100100 format for using with other components of this framework.
101101
102102 Args:
103- data: output data from neural network
104- original_image: input image which was used for predicted data
103+ data (torch.Tensor) : output data from neural network
104+ original_image (PIL.Image.Image) : input image which was used for predicted data
105105
106106 Returns:
107- Segmentation mask as PIL Image instance
107+ PIL.Image.Image: Segmentation mask as ` PIL Image` instance
108108
109109 """
110110 return (
@@ -115,13 +115,13 @@ def __call__(
115115 self , images : List [Union [str , pathlib .Path , PIL .Image .Image ]]
116116 ) -> List [PIL .Image .Image ]:
117117 """
118- Passes input images though neural network and returns segmentation masks as PIL.Image.Image instances
118+ Passes input images though neural network and returns segmentation masks as ` PIL.Image.Image` instances
119119
120120 Args:
121- images: input images
121+ images (List[Union[str, pathlib.Path, PIL.Image.Image]]) : input images
122122
123123 Returns:
124- segmentation masks as for input images, as PIL.Image.Image instances
124+ List[PIL.Image.Image]: segmentation masks as for input images, as ` PIL.Image.Image` instances
125125
126126 """
127127 collect_masks = []
0 commit comments