# modnet **Repository Path**: wanzigg/modnet ## Basic Information - **Project Name**: modnet - **Description**: 使用ModNet整合的人像抠图库 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-04-30 - **Last Updated**: 2025-04-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # modnet 依赖库打包 #### 安装 - **直接安装** - [modnet-0.1.0-py3-none-any.whl](https://gitee.com/desyang-hub/modnet/releases/download/v1.0/modnet-0.1.0-py3-none-any.whl) ``` bash pip install modnet-0.0.1-py3-none-any.whl ``` - **下载代码二次开发** - 下载所需的模型文件 [modnet_photographic_portrait_matting.onnx](https://gitee.com/desyang-hub/modnet/releases/download/v1.0/modnet_photographic_portrait_matting.onnx), 置于 modnet/pretrained/ ``` bash pip install -r requirements.txt ``` - 见打包教程 #### 打包教程 ``` bash python3 setup.py sdist bdist_wheel ``` #### 使用说明 ``` python import modnet import numpy as np from PIL import Image img_path = '1661925747887925.jpg' im = np.array(Image.open(img_path)) res = modnet.get_transparent_image(im) # 将 res 转换为 PIL 图像 if res.ndim == 2: # 灰度图像 img = Image.fromarray(res.astype(np.uint8), 'L') elif res.ndim == 3: # 彩色图像 img = Image.fromarray(res.astype(np.uint8)) # 保存图像 img.save('./test_out1.png') ```