Closed rominasilvera closed 7 months ago
Hi, rominasilvera. Black is the default background color, because it's (0, 0, 0) in RGB mode. If you want to change the background color, please use the code below,
output = remove(input, bgcolor=(255, 255, 255, 255))
See more from here https://github.com/danielgatis/rembg/blob/main/USAGE.md
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
When trying to remove a JPG's background, the returned output is the same picture but the background is painted in black, instead of transparent or white.
Importing modules
from rembg import remove
from PIL import Image
import numpy as np
Setting path and reading image
input_path = ".venv/Scripts/fotos_exp/AAB_0001.JPG"
input_image = Image.open(input_path)
Visualising image
input = Image.open(input_path)
print(input.format, input.size, input.mode) # JPEG (2896, 1944) RGB
input.show()
Conversion and saving output file
input_array = np.array(input_image)
output_array = remove(input_array)
output_image = Image.fromarray(output_array)
output_image = output_image.convert('RGB')
output_image.save('.venv/Scripts/output_image.png')
I also tried another method, which consists on not transforming to numpy.array:
output = remove(input)
output.show()
The output was the sameVersions:
pillow 10.2.0
rembg 2.0.53