- HumanSeg_lite is based on ShuffleNetV2 network. The network size is only 541K. It is suitable for selfie portrait segmentation and can be segmented in real time on the mobile terminal.
- For more information, please refer to:[humanseg_lite](https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.2/contrib/HumanSeg)
## II. Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0
- ### 2、Installation
- ```shell
$ hub install humanseg_lite
```
- In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md)
* images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
* paths (list\[str\]): image path;
* batch\_size (int): batch size;
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
* visualization (bool): Whether to save the results as picture files;
* output\_dir (str): save path of images, humanseg_lite_output by default.
- **Return**
* res (list\[dict\]): The list of recognition results, where each element is dict and each field is:
* save\_path (str, optional): Save path of the result;
* data (numpy.ndarray): The result of portrait segmentation.
```python
def video_stream_segment(self,
frame_org,
frame_id,
prev_gray,
prev_cfd,
use_gpu=False):
```
- Prediction API, used to segment video portraits frame by frame.
- **Parameter**
* frame_org (numpy.ndarray): single frame for prediction,ndarray.shape is in the format [H, W, C], BGR;
* frame_id (int): The number of the current frame;
* prev_gray (numpy.ndarray): Grayscale image of the previous network input;
* prev_cfd (numpy.ndarray): The fusion image from optical flow and the prediction result from previous frame.
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- **Return**
* img_matting (numpy.ndarray): The result of portrait segmentation;
* cur_gray (numpy.ndarray): Grayscale image of the current network input;
* optflow_map (numpy.ndarray): The fusion image from optical flow and the prediction result from current frame.
```python
def video_segment(self,
video_path=None,
use_gpu=False,
save_dir='humanseg_lite_video_result'):
```
- Prediction API to produce video segmentation result.
- **Parameter**
* video\_path (str): Video path for segmentation。If None, the video will be obtained from the local camera, and a window will display the online segmentation result.
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- HumanSeg_mobile is based on HRNet_w18_small_v1 network. The network size is only 5.8M. It is suitable for selfie portrait segmentation and can be segmented in real time on the mobile terminal.
- For more information, please refer to:[humanseg_mobile](https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.2/contrib/HumanSeg)
## II. Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0
- ### 2、Installation
- ```shell
$ hub install humanseg_mobile
```
- In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md)
* images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
* paths (list\[str\]): image path;
* batch\_size (int): batch size;
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
* visualization (bool): Whether to save the results as picture files;
* output\_dir (str): save path of images, humanseg_mobile_output by default.
- **Return**
* res (list\[dict\]): The list of recognition results, where each element is dict and each field is:
* save\_path (str, optional): Save path of the result;
* data (numpy.ndarray): The result of portrait segmentation.
```python
def video_stream_segment(self,
frame_org,
frame_id,
prev_gray,
prev_cfd,
use_gpu=False):
```
- Prediction API, used to segment video portraits frame by frame.
- **Parameter**
* frame_org (numpy.ndarray): single frame for prediction,ndarray.shape is in the format [H, W, C], BGR;
* frame_id (int): The number of the current frame;
* prev_gray (numpy.ndarray): Grayscale image of the previous network input;
* prev_cfd (numpy.ndarray): The fusion image from optical flow and the prediction result from previous frame.
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- **Return**
* img_matting (numpy.ndarray): The result of portrait segmentation;
* cur_gray (numpy.ndarray): Grayscale image of the current network input;
* optflow_map (numpy.ndarray): The fusion image from optical flow and the prediction result from current frame.
```python
def video_segment(self,
video_path=None,
use_gpu=False,
save_dir='humanseg_mobile_video_result'):
```
- Prediction API to produce video segmentation result.
- **Parameter**
* video\_path (str): Video path for segmentation。If None, the video will be obtained from the local camera, and a window will display the online segmentation result.
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
* images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
* paths (list\[str\]): image path;
* batch\_size (int): batch size;
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
* visualization (bool): Whether to save the results as picture files;
* output\_dir (str): save path of images, humanseg_server_output by default.
- **Return**
* res (list\[dict\]): The list of recognition results, where each element is dict and each field is:
* save\_path (str, optional): Save path of the result;
* data (numpy.ndarray): The result of portrait segmentation.
```python
def video_stream_segment(self,
frame_org,
frame_id,
prev_gray,
prev_cfd,
use_gpu=False):
```
- Prediction API, used to segment video portraits frame by frame.
- **Parameter**
* frame_org (numpy.ndarray): single frame for prediction,ndarray.shape is in the format [H, W, C], BGR;
* frame_id (int): The number of the current frame;
* prev_gray (numpy.ndarray): Grayscale image of the previous network input;
* prev_cfd (numpy.ndarray): The fusion image from optical flow and the prediction result from previous frame.
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- **Return**
* img_matting (numpy.ndarray): The result of portrait segmentation;
* cur_gray (numpy.ndarray): Grayscale image of the current network input;
* optflow_map (numpy.ndarray): The fusion image from optical flow and the prediction result from current frame.
```python
def video_segment(self,
video_path=None,
use_gpu=False,
save_dir='humanseg_server_video_result'):
```
- Prediction API to produce video segmentation result.
- **Parameter**
* video\_path (str): Video path for segmentation。If None, the video will be obtained from the local camera, and a window will display the online segmentation result.
* use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**