4、代码实现(开发者)
使用开源模型:
U^2Net(https://github.com/NathanUA/U2Net)
RemBG(Python库):
python
from rembg import remove
input_path = input.png
output_path = output.png
with open(input_path, rb) as f:
result = remove(f.read())
with open(output_path, wb) as f:
f.write(result)