chengwang96 commited on
Commit
41edbc8
·
1 Parent(s): 97c6ad9

Add application file

Browse files
Files changed (1) hide show
  1. app.py +57 -0
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import pandas as pd
4
+ from PIL import Image, ImageEnhance
5
+
6
+ # 伪造的算法函数,请替换成你自己的模型
7
+ def enhance_image(img):
8
+ enhancer = ImageEnhance.Contrast(img)
9
+ enhanced = enhancer.enhance(1.5)
10
+ return enhanced
11
+
12
+ def diagnose(img):
13
+ # 假数据
14
+ stats = pd.DataFrame({
15
+ "指标": ["增龄斑", "黄斑变性"],
16
+ "结果": ["正常", "异常"],
17
+ "概率": [0.85, 0.15]
18
+ })
19
+ return img, stats
20
+
21
+ def analyze_structure(img):
22
+ # 假数据
23
+ stats = pd.DataFrame({
24
+ "结构": ["血管密度", "分形维数"],
25
+ "数值": [4.12, 1.53]
26
+ })
27
+ return img, stats
28
+
29
+ with gr.Blocks(title="AI眼底影像辅助分析系统") as demo:
30
+ gr.Markdown("## AI眼底影像辅助分析系统")
31
+ with gr.Row():
32
+ # 图像增强模块
33
+ with gr.Column():
34
+ gr.Markdown("### 图像增强模块")
35
+ input_img = gr.Image(label="原始图片", type="pil")
36
+ enhanced_img = gr.Image(label="增强图片")
37
+ enhance_btn = gr.Button("增强图片")
38
+ enhance_btn.click(enhance_image, inputs=input_img, outputs=enhanced_img)
39
+
40
+ with gr.Row():
41
+ # 疾病诊断模块
42
+ with gr.Column():
43
+ gr.Markdown("### 疾病诊断模块")
44
+ diag_img = gr.Image(label="诊断结果图片")
45
+ diag_table = gr.Dataframe(headers=["指标", "结果", "概率"])
46
+ diag_btn = gr.Button("疾病诊断")
47
+ diag_btn.click(diagnose, inputs=input_img, outputs=[diag_img, diag_table])
48
+
49
+ # 结构分析模块
50
+ with gr.Column():
51
+ gr.Markdown("### 结构分析模块")
52
+ struct_img = gr.Image(label="结构分析图片")
53
+ struct_table = gr.Dataframe(headers=["结构", "数值"])
54
+ struct_btn = gr.Button("结构分析")
55
+ struct_btn.click(analyze_structure, inputs=input_img, outputs=[struct_img, struct_table])
56
+
57
+ demo.launch()