tori29umai commited on
Commit
bf64d66
·
verified ·
1 Parent(s): 1630a37

Update utils/image_utils.py

Browse files
Files changed (1) hide show
  1. utils/image_utils.py +2 -10
utils/image_utils.py CHANGED
@@ -14,17 +14,9 @@ def background_removal(input_image_path):
14
  return None
15
 
16
  # 背景除去処理
17
- rgba_image = remove(input_image).convert("RGBA")
18
- rgba_np = np.array(rgba_image)
19
- alpha_channel = rgba_np[:, :, 3] / 255.0 # アルファを0~1の範囲に正規化
20
-
21
- # 白背景の生成
22
- background = np.ones_like(rgba_np[:, :, :3], dtype=np.uint8) * 255 # 白背景
23
-
24
- # アルファブレンドを行い、透明部分を白と合成
25
- result = (foreground * alpha_channel[:, :, None] + background * (1 - alpha_channel[:, :, None])).astype(np.uint8)
26
 
27
- return Image.fromarray(result)
28
 
29
  def resize_image_aspect_ratio(image):
30
  # 元の画像サイズを取得
 
14
  return None
15
 
16
  # 背景除去処理
17
+ result = remove(input_image)
 
 
 
 
 
 
 
 
18
 
19
+ return result
20
 
21
  def resize_image_aspect_ratio(image):
22
  # 元の画像サイズを取得