rembg로 배경을 제거하는 단 7줄의 파이썬 코드
다니엘가티스 / 렘그
Rembg는 이미지 배경을 제거하는 도구입니다.
렘그





Rembg는 이미지 배경을 제거하는 도구입니다. 그게 다야.


















이 프로젝트가 도움이 되었다면 donation 을(를) 만들어 보십시오.
설치
CPU 지원:
pip install rembg
GPU support:
pip install rembg[gpu]
CLI로 사용
Remove the background from a remote image
curl -s http://input.png | rembg i > output.png
Remove the background from a local file
rembg i path/to/input.png path/to/output.png
Remove the background from all images in a folder
rembg p path/to/input path/to/output
서버로 사용
Start the server
rembg s
And go to:
http://localhost:5000/docs
배경 이미지:https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Gull_portrait_ca_usa.jpg/1280px-Gull_portrait_ca_usa.jpg
배경 없는 이미지:http://localhost:5000/?url=https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Gull_portrait_ca_usa.jpg/1280px-Gull_portrait_ca_usa.jpg
또한 파일을 FormData(multipart/form-data)로 보낼 수 있습니다.<form action="http://localhost:5000" method="post" enctype="multipart/form-data" > <input type="file" name="file" /> <input type="submit" value="upload" /> </form>
용법
…We can run gpu version on Google colab
!pip install rembg[gpu]
GPU 없이 로컬 컴퓨터에서 스크립트를 실행하려면 2개의 패키지를 설치해야 합니다. OpenCV가 있으면 Pillow 대신 사용할 수 있습니다.
pip install rembg
pip install -U Pillow
from rembg import remove
from PIL import Image
input_path = 'input.jpg' # input image path
output_path = 'output.png' # output image path
input = Image.open(input_path) # load image
output = remove(input) # remove background
output.save(output_path) # save image
엄청나게 쉽습니다!!!
Reference
이 문제에 관하여(rembg로 배경을 제거하는 단 7줄의 파이썬 코드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/0xkoji/only-7-lines-python-code-to-remove-background-with-rembg-4g74텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)