KingNish commited on
Commit
c8cc221
1 Parent(s): 74b32cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -112,13 +112,11 @@ def process(image, bg):
112
  pred_pil = transforms.ToPILImage()(pred)
113
  mask = pred_pil.resize(image_size)
114
 
115
- if isinstance(bg, str) and bg.startswith("#"):
116
  color_rgb = tuple(int(bg[i:i+2], 16) for i in (1, 3, 5))
117
  background = Image.new("RGBA", image_size, color_rgb + (255,))
118
- elif isinstance(bg, Image.Image):
119
- background = bg.convert("RGBA").resize(image_size)
120
  else:
121
- background = Image.new("RGBA", image_size, (0, 0, 0, 255)) # Default to black background
122
 
123
  # Composite the image onto the background using the mask
124
  image = Image.composite(image, background, mask)
 
112
  pred_pil = transforms.ToPILImage()(pred)
113
  mask = pred_pil.resize(image_size)
114
 
115
+ if bg.startswith("#"):
116
  color_rgb = tuple(int(bg[i:i+2], 16) for i in (1, 3, 5))
117
  background = Image.new("RGBA", image_size, color_rgb + (255,))
 
 
118
  else:
119
+ background = bg.convert("RGBA").resize(image_size)
120
 
121
  # Composite the image onto the background using the mask
122
  image = Image.composite(image, background, mask)