Interesting background removal tool Rembg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rembg import remove | |
from rembg.session_factory import new_session | |
# for the small model | |
#remove(input, session=new_session("u2netp")) | |
#remove(input, session=new_session("u2net_human_seg")) | |
import cv2 | |
from google.colab.patches import cv2_imshow | |
input_path = '3_Sample.jpg' | |
output_path = 'output.png' | |
#input = cv2.imread(input_path) | |
#output = remove(input) | |
#cv2.imwrite(output_path, output) | |
from rembg import remove | |
from PIL import Image | |
input = Image.open(input_path) | |
output = remove(input) | |
#output.save(output_path) | |
remove(input, session=new_session("u2net_human_seg")) | |
output = remove(input) | |
output.save(output_path) | |
import cv2 | |
img = cv2.imread('output.png', cv2.IMREAD_UNCHANGED) | |
cv2_imshow(img) |
Keep Exploring!!!
No comments:
Post a Comment