forSubAnony
commited on
Commit
•
8222fd4
1
Parent(s):
99405c7
"v1"
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +1 -0
- app.py +82 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/13gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/14gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/15gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/16gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/17gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/18gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/19gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/20gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/21gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/annotations/23gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/13img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/14img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/15img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/16img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/17img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/18img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/19img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/20img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/21img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/test/images/23img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/0gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/10gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/11gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/12gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/1gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/22gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/24gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/25gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/26gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/27gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/28gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/29gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/2gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/3gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/4gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/5gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/6gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/7gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/8gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/annotations/9gt.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/0img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/10img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/11img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/12img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/1img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/22img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/24img.png +0 -0
- dataset_curvilinear/angiography/CHUAC/training/images/25img.png +0 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pretrain_weights/
|
app.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from feature_combiner import FeatureCombiner
|
3 |
+
from pipeline import Pipeline_demo
|
4 |
+
# 数据集选择字典
|
5 |
+
DATASETS = {
|
6 |
+
"angiography.CHUAC": "CHUAC dataset",
|
7 |
+
"angiography.DCA1": "DCA1 dataset",
|
8 |
+
"angiography.XCAD": "XCAD dataset",
|
9 |
+
"retina.DRIVE": "DRIVE dataset",
|
10 |
+
"retina.CHASEDB1": "CHASEDB1 dataset",
|
11 |
+
"crack.Crack500": "Crack500 dataset"
|
12 |
+
}
|
13 |
+
|
14 |
+
JSON_FILES = {
|
15 |
+
"crack":"dataset_curvilinear/crack/crack.json",
|
16 |
+
"angiography":"dataset_curvilinear/angiography/angiography.json",
|
17 |
+
"retina":"dataset_curvilinear/retina/retina.json"
|
18 |
+
}
|
19 |
+
|
20 |
+
is_cpu= True
|
21 |
+
pipeline_demo = Pipeline_demo(is_cpu=is_cpu)
|
22 |
+
|
23 |
+
def generate_prompts(dataset):
|
24 |
+
"""
|
25 |
+
根据选择的数据集生成prompts。
|
26 |
+
返回semantic map prompt和image prompt。
|
27 |
+
"""
|
28 |
+
|
29 |
+
json_index = dataset.split(".")[0]
|
30 |
+
json_file = JSON_FILES[json_index]
|
31 |
+
fc = FeatureCombiner(json_file, DATASETS[dataset])
|
32 |
+
caption_seg, caption_img = fc.combine()
|
33 |
+
return caption_seg, caption_img
|
34 |
+
|
35 |
+
def generate_semantic_map(semantic_map_prompt):
|
36 |
+
"""
|
37 |
+
根据semantic map prompt生成semantic map。
|
38 |
+
返回semantic map的图像。
|
39 |
+
"""
|
40 |
+
# 示例函数体,你需要填充实际的图像生成逻辑
|
41 |
+
return pipeline_demo.generate_semantic_map(semantic_map_prompt)
|
42 |
+
|
43 |
+
|
44 |
+
def generate_image(image_prompt,semantic_map_image):
|
45 |
+
"""
|
46 |
+
根据image prompt生成图像。
|
47 |
+
返回生成的图像。
|
48 |
+
"""
|
49 |
+
# 示例函数体,你需要填充实际的图像生成逻辑
|
50 |
+
return pipeline_demo.generate_image(image_prompt, semantic_map_image)
|
51 |
+
|
52 |
+
with gr.Blocks() as demo:
|
53 |
+
gr.Markdown("# DEMO for Expanding Curvilinear Object Segmentation datasets")
|
54 |
+
with gr.Row():
|
55 |
+
with gr.Column(scale=1):
|
56 |
+
dataset_dropdown = gr.Dropdown(label="Select Dataset", choices=list(DATASETS.keys()),value="crack.Crack500")
|
57 |
+
generate_prompts_button = gr.Button("1. Generate Prompts")
|
58 |
+
gr.Markdown("""
|
59 |
+
#### Process:
|
60 |
+
1. Generate Prompts
|
61 |
+
2. Generate Semantic Map based on the prompt
|
62 |
+
3. Generate Image based on the prompt and Semantic Map
|
63 |
+
NOTE: The time it takes for the CPU provided by Huggingface to complete the generation is too long. It is recommended that users modify is_cpu=False in app.py to deploy on their own devices.
|
64 |
+
""")
|
65 |
+
with gr.Column(scale=2):
|
66 |
+
semantic_map_prompt_text = gr.Textbox(label="Semantic Map Prompt", lines=5, placeholder="Semantic map prompt will be shown here...", interactive=True)
|
67 |
+
image_prompt_text = gr.Textbox(label="Image Prompt", lines=5, placeholder="Image prompt will be shown here...", interactive=True)
|
68 |
+
|
69 |
+
with gr.Row():
|
70 |
+
with gr.Column(scale=1):
|
71 |
+
generate_semantic_map_button = gr.Button("2. Generate Semantic Map")
|
72 |
+
semantic_map_image = gr.Image(width=512, height=512, label="Semantic Map",interactive=False)
|
73 |
+
with gr.Column(scale=1):
|
74 |
+
generate_image_button = gr.Button("3. Generate Image")
|
75 |
+
generated_image = gr.Image(width=512, height=512, label="Generated Image")
|
76 |
+
|
77 |
+
# 绑定函数
|
78 |
+
generate_prompts_button.click(generate_prompts, inputs=[dataset_dropdown], outputs=[semantic_map_prompt_text, image_prompt_text])
|
79 |
+
generate_semantic_map_button.click(generate_semantic_map, inputs=[semantic_map_prompt_text], outputs=[semantic_map_image])
|
80 |
+
generate_image_button.click(generate_image, inputs=[image_prompt_text,semantic_map_image], outputs=[generated_image])
|
81 |
+
|
82 |
+
demo.launch()
|
dataset_curvilinear/angiography/CHUAC/test/annotations/13gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/14gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/15gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/16gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/17gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/18gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/19gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/20gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/21gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/annotations/23gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/13img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/14img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/15img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/16img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/17img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/18img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/19img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/20img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/21img.png
ADDED
dataset_curvilinear/angiography/CHUAC/test/images/23img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/0gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/10gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/11gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/12gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/1gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/22gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/24gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/25gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/26gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/27gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/28gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/29gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/2gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/3gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/4gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/5gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/6gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/7gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/8gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/annotations/9gt.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/0img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/10img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/11img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/12img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/1img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/22img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/24img.png
ADDED
dataset_curvilinear/angiography/CHUAC/training/images/25img.png
ADDED