kigison commited on
Commit
3430d49
·
verified ·
1 Parent(s): bf660d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -8
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
4
- from skimage import io, color, restoration
5
 
6
  # 圖像分割功能
7
  def image_segmentation(image):
@@ -21,12 +20,6 @@ def image_inpainting(image, mask):
21
  inpainted = cv2.inpaint(image, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
22
  return inpainted
23
 
24
- # 示例圖片列表
25
- example_images = [
26
- ("example1.jpg", "測試圖片 1"),
27
- ("example2.jpg", "測試圖片 2"),
28
- ]
29
-
30
  # 定義 Gradio 接口
31
  def main_interface(image, task, param1=50, param2=150, mask=None):
32
  if task == "Image Segmentation":
@@ -47,7 +40,7 @@ with gr.Blocks() as app:
47
  task = gr.Radio(["Image Segmentation", "Edge Detection", "Image Inpainting"], label="選擇功能")
48
  param1 = gr.Slider(0, 200, value=50, step=1, label="參數 1 (Edge Detection Threshold 1)")
49
  param2 = gr.Slider(0, 200, value=150, step=1, label="參數 2 (Edge Detection Threshold 2)")
50
- mask_input = gr.Image(label="上傳遮罩 (僅適用於 Image Inpainting)", type="numpy", optional=True)
51
  submit_button = gr.Button("執行")
52
  with gr.Column():
53
  output_image = gr.Image(label="輸出結果")
 
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
 
4
 
5
  # 圖像分割功能
6
  def image_segmentation(image):
 
20
  inpainted = cv2.inpaint(image, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
21
  return inpainted
22
 
 
 
 
 
 
 
23
  # 定義 Gradio 接口
24
  def main_interface(image, task, param1=50, param2=150, mask=None):
25
  if task == "Image Segmentation":
 
40
  task = gr.Radio(["Image Segmentation", "Edge Detection", "Image Inpainting"], label="選擇功能")
41
  param1 = gr.Slider(0, 200, value=50, step=1, label="參數 1 (Edge Detection Threshold 1)")
42
  param2 = gr.Slider(0, 200, value=150, step=1, label="參數 2 (Edge Detection Threshold 2)")
43
+ mask_input = gr.Image(label="上傳遮罩 (僅適用於 Image Inpainting)", type="numpy", value=None)
44
  submit_button = gr.Button("執行")
45
  with gr.Column():
46
  output_image = gr.Image(label="輸出結果")