AaronWu901225 commited on
Commit
96c568f
·
verified ·
1 Parent(s): ca85123

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -37,7 +37,7 @@ def app():
37
  # 邊緣檢測功能
38
  with gr.Tab("邊緣檢測"):
39
  with gr.Row():
40
- input_image = gr.Image(label="輸入圖片", value="simple_plain_pikachu_by_titanplakinside_dexx027.png") # 範例圖片
41
  edge_result = gr.Image(label="邊緣檢測結果")
42
  with gr.Row():
43
  threshold1 = gr.Slider(0, 255, value=100, step=1, label="閾值1")
@@ -48,18 +48,21 @@ def app():
48
  inputs=[input_image, threshold1, threshold2],
49
  outputs=edge_result
50
  )
 
51
  gr.Examples(
52
- examples=["simple_plain_pikachu_by_titanplakinside_dexx027.png"],
53
- inputs=[input_image],
54
- outputs=[edge_result],
55
- fn=lambda img: edge_detection(img, 100, 200),
56
- label="測試範例"
 
 
57
  )
58
 
59
  # 圖像分割功能
60
  with gr.Tab("圖像分割"):
61
  with gr.Row():
62
- input_image = gr.Image(label="輸入圖片", value="simple_plain_pikachu_by_titanplakinside_dexx027.png") # 範例圖片
63
  seg_result = gr.Image(label="分割結果")
64
  with gr.Row():
65
  compactness = gr.Slider(0.1, 100, value=10, step=0.1, label="分割緊湊度")
@@ -70,17 +73,19 @@ def app():
70
  outputs=seg_result
71
  )
72
  gr.Examples(
73
- examples=["simple_plain_pikachu_by_titanplakinside_dexx027.png"],
74
- inputs=[input_image],
75
- outputs=[seg_result],
76
- fn=lambda img: image_segmentation(img, 10),
77
- label="測試範例"
 
 
78
  )
79
 
80
  # 顏色範圍調整功能
81
  with gr.Tab("顏色範圍調整"):
82
  with gr.Row():
83
- input_image = gr.Image(label="輸入圖片", value="simple_plain_pikachu_by_titanplakinside_dexx027.png") # 範例圖片
84
  adjusted_result = gr.Image(label="調整後的圖片")
85
  with gr.Row():
86
  r_min = gr.Slider(0, 255, value=50, step=1, label="R 最小值")
@@ -96,11 +101,13 @@ def app():
96
  outputs=adjusted_result
97
  )
98
  gr.Examples(
99
- examples=["simple_plain_pikachu_by_titanplakinside_dexx027.png"],
100
- inputs=[input_image],
101
- outputs=[adjusted_result],
102
- fn=lambda img: adjust_color(img, 50, 200, 50, 200, 50, 200),
103
- label="測試範例"
 
 
104
  )
105
 
106
  return demo
 
37
  # 邊緣檢測功能
38
  with gr.Tab("邊緣檢測"):
39
  with gr.Row():
40
+ input_image = gr.Image(label="輸入圖片")
41
  edge_result = gr.Image(label="邊緣檢測結果")
42
  with gr.Row():
43
  threshold1 = gr.Slider(0, 255, value=100, step=1, label="閾值1")
 
48
  inputs=[input_image, threshold1, threshold2],
49
  outputs=edge_result
50
  )
51
+ # 顯示範例圖片和直接測試結果
52
  gr.Examples(
53
+ examples=[
54
+ ["simple_plain_pikachu_by_titanplakinside_dexx027.png", 100, 200]
55
+ ],
56
+ inputs=[input_image, threshold1, threshold2],
57
+ outputs=edge_result,
58
+ fn=edge_detection,
59
+ cache_examples=True
60
  )
61
 
62
  # 圖像分割功能
63
  with gr.Tab("圖像分割"):
64
  with gr.Row():
65
+ input_image = gr.Image(label="輸入圖片")
66
  seg_result = gr.Image(label="分割結果")
67
  with gr.Row():
68
  compactness = gr.Slider(0.1, 100, value=10, step=0.1, label="分割緊湊度")
 
73
  outputs=seg_result
74
  )
75
  gr.Examples(
76
+ examples=[
77
+ ["simple_plain_pikachu_by_titanplakinside_dexx027.png", 10]
78
+ ],
79
+ inputs=[input_image, compactness],
80
+ outputs=seg_result,
81
+ fn=image_segmentation,
82
+ cache_examples=True
83
  )
84
 
85
  # 顏色範圍調整功能
86
  with gr.Tab("顏色範圍調整"):
87
  with gr.Row():
88
+ input_image = gr.Image(label="輸入圖片")
89
  adjusted_result = gr.Image(label="調整後的圖片")
90
  with gr.Row():
91
  r_min = gr.Slider(0, 255, value=50, step=1, label="R 最小值")
 
101
  outputs=adjusted_result
102
  )
103
  gr.Examples(
104
+ examples=[
105
+ ["simple_plain_pikachu_by_titanplakinside_dexx027.png", 50, 200, 50, 200, 50, 200]
106
+ ],
107
+ inputs=[input_image, r_min, r_max, g_min, g_max, b_min, b_max],
108
+ outputs=adjusted_result,
109
+ fn=adjust_color,
110
+ cache_examples=True
111
  )
112
 
113
  return demo