chengwang96 commited on
Commit
d70a23e
·
1 Parent(s): 1db65f3

update function 1

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. app.py +9 -11
  2. {f1_input → seg_input}/1.png +0 -0
  3. {f1_input → seg_input}/10.png +0 -0
  4. {f1_input → seg_input}/11.png +0 -0
  5. {f1_input → seg_input}/12.png +0 -0
  6. {f1_input → seg_input}/13.png +0 -0
  7. {f1_input → seg_input}/14.png +0 -0
  8. {f1_input → seg_input}/15.png +0 -0
  9. {f1_input → seg_input}/16.png +0 -0
  10. {f1_input → seg_input}/17.png +0 -0
  11. {f1_input → seg_input}/18.png +0 -0
  12. {f1_input → seg_input}/19.png +0 -0
  13. {f1_input → seg_input}/2.png +0 -0
  14. {f1_input → seg_input}/20.png +0 -0
  15. {f1_input → seg_input}/21.png +0 -0
  16. {f1_input → seg_input}/22.png +0 -0
  17. {f1_input → seg_input}/23.png +0 -0
  18. {f1_input → seg_input}/24.png +0 -0
  19. {f1_input → seg_input}/25.png +0 -0
  20. {f1_input → seg_input}/26.png +0 -0
  21. {f1_input → seg_input}/27.png +0 -0
  22. {f1_input → seg_input}/28.png +0 -0
  23. {f1_input → seg_input}/29.png +0 -0
  24. {f1_input → seg_input}/3.png +0 -0
  25. {f1_input → seg_input}/30.png +0 -0
  26. {f1_input → seg_input}/4.png +0 -0
  27. {f1_input → seg_input}/5.png +0 -0
  28. {f1_input → seg_input}/6.png +0 -0
  29. {f1_input → seg_input}/7.png +0 -0
  30. {f1_input → seg_input}/8.png +0 -0
  31. {f1_input → seg_input}/9.png +0 -0
  32. {f1_output → seg_output}/1.png +0 -0
  33. {f1_output → seg_output}/10.png +0 -0
  34. {f1_output → seg_output}/11.png +0 -0
  35. {f1_output → seg_output}/12.png +0 -0
  36. {f1_output → seg_output}/13.png +0 -0
  37. {f1_output → seg_output}/14.png +0 -0
  38. {f1_output → seg_output}/15.png +0 -0
  39. {f1_output → seg_output}/16.png +0 -0
  40. {f1_output → seg_output}/17.png +0 -0
  41. {f1_output → seg_output}/18.png +0 -0
  42. {f1_output → seg_output}/19.png +0 -0
  43. {f1_output → seg_output}/2.png +0 -0
  44. {f1_output → seg_output}/20.png +0 -0
  45. {f1_output → seg_output}/21.png +0 -0
  46. {f1_output → seg_output}/22.png +0 -0
  47. {f1_output → seg_output}/23.png +0 -0
  48. {f1_output → seg_output}/24.png +0 -0
  49. {f1_output → seg_output}/25.png +0 -0
  50. {f1_output → seg_output}/26.png +0 -0
app.py CHANGED
@@ -5,18 +5,18 @@ import random
5
 
6
  # ========== 配置图片路径 ==========
7
  # 图像增强
8
- ENHANCE_INPUT_DIR = "f1_input"
9
- ENHANCE_OUTPUT_DIR = "f1_output"
10
- ENHANCE_IMG_NAMES = [f"{i}.png" for i in range(1, 613)] # 1.png ~ 612.png
11
 
12
  # 分割
13
  SEG_INPUT_DIR = "seg_input"
14
  SEG_OUTPUT_DIR = "seg_output"
15
- SEG_IMG_NAMES = [f"{i}.png" for i in range(1, 6)] # 1.png ~ 5.png
16
 
17
  # 诊断
18
  DIAG_INPUT_DIR = "diag_input"
19
- DIAG_IMG_NAMES = [f"{i}.png" for i in range(1, 6)] # 1.png ~ 5.png
20
 
21
  # Kvasir 类别
22
  KVASIR_CLASSES = [
@@ -38,7 +38,6 @@ def open_img(img_path):
38
  return Image.new("RGB", (256, 256), (200, 200, 200))
39
  return Image.open(img_path)
40
 
41
- # 图像增强模块
42
  def show_enhance_input(img_name):
43
  path = os.path.join(ENHANCE_INPUT_DIR, img_name)
44
  return open_img(path)
@@ -47,7 +46,6 @@ def enhance_demo(img_name):
47
  path = os.path.join(ENHANCE_OUTPUT_DIR, img_name)
48
  return open_img(path)
49
 
50
- # 图像分割模块
51
  def show_seg_input(img_name):
52
  path = os.path.join(SEG_INPUT_DIR, img_name)
53
  return open_img(path)
@@ -56,7 +54,6 @@ def segment_demo(img_name):
56
  path = os.path.join(SEG_OUTPUT_DIR, img_name)
57
  return open_img(path)
58
 
59
- # 疾病诊断模块
60
  def show_diag_input(img_name):
61
  path = os.path.join(DIAG_INPUT_DIR, img_name)
62
  return open_img(path)
@@ -70,14 +67,15 @@ def diagnose_demo(img_name):
70
  with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
71
  gr.Markdown("## AI内窥镜影像辅助分析系统")
72
 
73
- # 上方:图像增强模块
74
  with gr.Row():
75
  with gr.Column():
76
  gr.Markdown("### 图像增强模块")
77
  enhance_select = gr.Dropdown(choices=ENHANCE_IMG_NAMES, value=ENHANCE_IMG_NAMES[0], label="选择样例图片", filterable=True)
78
- enhance_input_img = gr.Image(label="原始图片", interactive=False)
 
 
79
  enhance_btn = gr.Button("增强图片")
80
- enhance_output_img = gr.Image(label="增强结果图片", interactive=False)
81
 
82
  # 选择图片自动显示原图
83
  enhance_select.change(fn=show_enhance_input, inputs=enhance_select, outputs=enhance_input_img)
 
5
 
6
  # ========== 配置图片路径 ==========
7
  # 图像增强
8
+ ENHANCE_INPUT_DIR = "sr_input"
9
+ ENHANCE_OUTPUT_DIR = "sr_output"
10
+ ENHANCE_IMG_NAMES = [f"{i}.png" for i in range(1, 30)]
11
 
12
  # 分割
13
  SEG_INPUT_DIR = "seg_input"
14
  SEG_OUTPUT_DIR = "seg_output"
15
+ SEG_IMG_NAMES = [f"{i}.png" for i in range(1, 30)]
16
 
17
  # 诊断
18
  DIAG_INPUT_DIR = "diag_input"
19
+ DIAG_IMG_NAMES = [f"{i}.png" for i in range(1, 30)]
20
 
21
  # Kvasir 类别
22
  KVASIR_CLASSES = [
 
38
  return Image.new("RGB", (256, 256), (200, 200, 200))
39
  return Image.open(img_path)
40
 
 
41
  def show_enhance_input(img_name):
42
  path = os.path.join(ENHANCE_INPUT_DIR, img_name)
43
  return open_img(path)
 
46
  path = os.path.join(ENHANCE_OUTPUT_DIR, img_name)
47
  return open_img(path)
48
 
 
49
  def show_seg_input(img_name):
50
  path = os.path.join(SEG_INPUT_DIR, img_name)
51
  return open_img(path)
 
54
  path = os.path.join(SEG_OUTPUT_DIR, img_name)
55
  return open_img(path)
56
 
 
57
  def show_diag_input(img_name):
58
  path = os.path.join(DIAG_INPUT_DIR, img_name)
59
  return open_img(path)
 
67
  with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
68
  gr.Markdown("## AI内窥镜影像辅助分析系统")
69
 
70
+ # 上方:图像增强模块(输入和输出在一行)
71
  with gr.Row():
72
  with gr.Column():
73
  gr.Markdown("### 图像增强模块")
74
  enhance_select = gr.Dropdown(choices=ENHANCE_IMG_NAMES, value=ENHANCE_IMG_NAMES[0], label="选择样例图片", filterable=True)
75
+ with gr.Row():
76
+ enhance_input_img = gr.Image(label="原始图片", interactive=False)
77
+ enhance_output_img = gr.Image(label="增强结果图片", interactive=False)
78
  enhance_btn = gr.Button("增强图片")
 
79
 
80
  # 选择图片自动显示原图
81
  enhance_select.change(fn=show_enhance_input, inputs=enhance_select, outputs=enhance_input_img)
{f1_input → seg_input}/1.png RENAMED
File without changes
{f1_input → seg_input}/10.png RENAMED
File without changes
{f1_input → seg_input}/11.png RENAMED
File without changes
{f1_input → seg_input}/12.png RENAMED
File without changes
{f1_input → seg_input}/13.png RENAMED
File without changes
{f1_input → seg_input}/14.png RENAMED
File without changes
{f1_input → seg_input}/15.png RENAMED
File without changes
{f1_input → seg_input}/16.png RENAMED
File without changes
{f1_input → seg_input}/17.png RENAMED
File without changes
{f1_input → seg_input}/18.png RENAMED
File without changes
{f1_input → seg_input}/19.png RENAMED
File without changes
{f1_input → seg_input}/2.png RENAMED
File without changes
{f1_input → seg_input}/20.png RENAMED
File without changes
{f1_input → seg_input}/21.png RENAMED
File without changes
{f1_input → seg_input}/22.png RENAMED
File without changes
{f1_input → seg_input}/23.png RENAMED
File without changes
{f1_input → seg_input}/24.png RENAMED
File without changes
{f1_input → seg_input}/25.png RENAMED
File without changes
{f1_input → seg_input}/26.png RENAMED
File without changes
{f1_input → seg_input}/27.png RENAMED
File without changes
{f1_input → seg_input}/28.png RENAMED
File without changes
{f1_input → seg_input}/29.png RENAMED
File without changes
{f1_input → seg_input}/3.png RENAMED
File without changes
{f1_input → seg_input}/30.png RENAMED
File without changes
{f1_input → seg_input}/4.png RENAMED
File without changes
{f1_input → seg_input}/5.png RENAMED
File without changes
{f1_input → seg_input}/6.png RENAMED
File without changes
{f1_input → seg_input}/7.png RENAMED
File without changes
{f1_input → seg_input}/8.png RENAMED
File without changes
{f1_input → seg_input}/9.png RENAMED
File without changes
{f1_output → seg_output}/1.png RENAMED
File without changes
{f1_output → seg_output}/10.png RENAMED
File without changes
{f1_output → seg_output}/11.png RENAMED
File without changes
{f1_output → seg_output}/12.png RENAMED
File without changes
{f1_output → seg_output}/13.png RENAMED
File without changes
{f1_output → seg_output}/14.png RENAMED
File without changes
{f1_output → seg_output}/15.png RENAMED
File without changes
{f1_output → seg_output}/16.png RENAMED
File without changes
{f1_output → seg_output}/17.png RENAMED
File without changes
{f1_output → seg_output}/18.png RENAMED
File without changes
{f1_output → seg_output}/19.png RENAMED
File without changes
{f1_output → seg_output}/2.png RENAMED
File without changes
{f1_output → seg_output}/20.png RENAMED
File without changes
{f1_output → seg_output}/21.png RENAMED
File without changes
{f1_output → seg_output}/22.png RENAMED
File without changes
{f1_output → seg_output}/23.png RENAMED
File without changes
{f1_output → seg_output}/24.png RENAMED
File without changes
{f1_output → seg_output}/25.png RENAMED
File without changes
{f1_output → seg_output}/26.png RENAMED
File without changes