YunTingZ commited on
Commit
0d84ed0
·
1 Parent(s): 4d20656

Add application file

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -12,14 +12,7 @@ def edge_detection(image, threshold1, threshold2):
12
  edges = cv2.Canny(image, threshold1, threshold2)
13
  return edges
14
 
15
- # 影像修復函數
16
  def image_inpainting(image, mask):
17
- """
18
- 使用 OpenCV 的 inpaint 方法進行影像修復。
19
- :param image: numpy array, 原始影像
20
- :param mask: numpy array, 修復遮罩
21
- :return: numpy array, 修復後影像
22
- """
23
  # 確保影像和遮罩有相同的尺寸
24
  if image.shape[:2] != mask.shape[:2]:
25
  raise ValueError("影像和遮罩的尺寸不一致!")
@@ -65,8 +58,8 @@ def app_interface():
65
  # 影像修復
66
  with gr.Tab("影像修復"):
67
  # 輸入影像與遮罩
68
- inpaint_input = gr.Image(label="上傳影像", type="numpy", tool="editor")
69
- mask_input = gr.Image(label="上傳遮罩 (白色為修復區域)", type="numpy", tool="sketch")
70
 
71
  # 輸出修復後影像
72
  inpaint_output = gr.Image(label="修復後影像")
 
12
  edges = cv2.Canny(image, threshold1, threshold2)
13
  return edges
14
 
 
15
  def image_inpainting(image, mask):
 
 
 
 
 
 
16
  # 確保影像和遮罩有相同的尺寸
17
  if image.shape[:2] != mask.shape[:2]:
18
  raise ValueError("影像和遮罩的尺寸不一致!")
 
58
  # 影像修復
59
  with gr.Tab("影像修復"):
60
  # 輸入影像與遮罩
61
+ inpaint_input = gr.Image(label="上傳影像", type="numpy")
62
+ mask_input = gr.Image(label="上傳遮罩 (白色為修復區域)", type="numpy")
63
 
64
  # 輸出修復後影像
65
  inpaint_output = gr.Image(label="修復後影像")