AaronWu901225 commited on
Commit
e328419
·
verified ·
1 Parent(s): f513d1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -26,10 +26,16 @@ def inpaint_image(image, mask_threshold):
26
  # 根據遮罩閾值生成遮罩
27
  _, mask = cv2.threshold(gray_image, mask_threshold, 255, cv2.THRESH_BINARY)
28
  mask = mask.astype(bool)
 
 
 
 
 
29
  # 使用 biharmonic 方法修復圖像
30
  inpainted = inpaint.inpaint_biharmonic(image, mask, multichannel=True)
31
  return inpainted
32
 
 
33
  # 主應用程式
34
  def app():
35
  with gr.Blocks() as demo:
 
26
  # 根據遮罩閾值生成遮罩
27
  _, mask = cv2.threshold(gray_image, mask_threshold, 255, cv2.THRESH_BINARY)
28
  mask = mask.astype(bool)
29
+
30
+ # 檢查遮罩是否正確
31
+ if not mask.any():
32
+ raise ValueError("遮罩生成失敗,請調整遮罩閾值參數。")
33
+
34
  # 使用 biharmonic 方法修復圖像
35
  inpainted = inpaint.inpaint_biharmonic(image, mask, multichannel=True)
36
  return inpainted
37
 
38
+
39
  # 主應用程式
40
  def app():
41
  with gr.Blocks() as demo: