Spaces:
Runtime error
Runtime error
converting mask to rgb
Browse files- .gitignore +1 -0
- server.py +4 -1
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
node/
|
server.py
CHANGED
@@ -118,6 +118,7 @@ async def recolor(file: UploadFile = File(...), colors: str = Form(...), model:
|
|
118 |
ColorReplacer.recolor_selected_area(image_np, colors[0], colors[1])
|
119 |
elif method == "ColorMask":
|
120 |
print('ColorMask started')
|
|
|
121 |
ColorMask.create_mask(image_np, colors[0])
|
122 |
|
123 |
#mask image:
|
@@ -131,10 +132,12 @@ async def recolor(file: UploadFile = File(...), colors: str = Form(...), model:
|
|
131 |
print('image_np', image_np.size)
|
132 |
if mask_image.size != result_image.size:
|
133 |
mask_image = mask_image.resize(result_image.size)
|
|
|
|
|
134 |
mask_np = np.array(mask_image)
|
135 |
|
136 |
# Create a new image array based on the mask
|
137 |
-
new_image_np = np.where(mask_np ==
|
138 |
|
139 |
# Save the new image
|
140 |
new_image = Image.fromarray(new_image_np)
|
|
|
118 |
ColorReplacer.recolor_selected_area(image_np, colors[0], colors[1])
|
119 |
elif method == "ColorMask":
|
120 |
print('ColorMask started')
|
121 |
+
print(colors)
|
122 |
ColorMask.create_mask(image_np, colors[0])
|
123 |
|
124 |
#mask image:
|
|
|
132 |
print('image_np', image_np.size)
|
133 |
if mask_image.size != result_image.size:
|
134 |
mask_image = mask_image.resize(result_image.size)
|
135 |
+
|
136 |
+
mask_image = mask_image.convert('RGB')
|
137 |
mask_np = np.array(mask_image)
|
138 |
|
139 |
# Create a new image array based on the mask
|
140 |
+
new_image_np = np.where(mask_np == 0, result_np, image_np)
|
141 |
|
142 |
# Save the new image
|
143 |
new_image = Image.fromarray(new_image_np)
|