Roland Ding commited on
Commit
8f97e9b
·
1 Parent(s): 7564bac

check point before switch branch

Browse files

modified: .gitignore
modified: __pycache__/supplier.cpython-310.pyc
modified: app.py
deleted: ui_studies.py
deleted: ui_study.py
new file: ui_summary.py

Files changed (6) hide show
  1. .gitignore +3 -0
  2. __pycache__/supplier.cpython-310.pyc +0 -0
  3. app.py +11 -20
  4. ui_studies.py +0 -42
  5. ui_study.py +0 -105
  6. ui_summary.py +62 -0
.gitignore CHANGED
@@ -6,6 +6,9 @@
6
  .prompts
7
  .vscode
8
 
 
 
 
9
  sandbox.ipynb
10
  dump.ipynb
11
  test.ipynb
 
6
  .prompts
7
  .vscode
8
 
9
+ *.pyc
10
+ *.csv
11
+
12
  sandbox.ipynb
13
  dump.ipynb
14
  test.ipynb
__pycache__/supplier.cpython-310.pyc CHANGED
Binary files a/__pycache__/supplier.cpython-310.pyc and b/__pycache__/supplier.cpython-310.pyc differ
 
app.py CHANGED
@@ -1,5 +1,3 @@
1
- # search_logic = gr.Interface(text_analysis,input="text",outputs="highlight",title="High light")
2
-
3
  # first layer extraction(text)
4
  # second layer extraction(first layer output)
5
  # third layer extraction(first layer outputs aggregated, second layer outputs aggregated)
@@ -10,33 +8,26 @@ import gradio as gr
10
  from cloud_db import *
11
  from supplier import *
12
  from utility import *
 
13
 
14
- from ui_study import *
15
- from ui_studies import *
16
- # from application import app_data
17
 
18
 
19
  examples = []
 
20
 
21
- @terminal_print
22
- def init_demo():
23
- '''
24
- initialize the demo data
25
- '''
26
- study_page = init_study_page()
27
- studies_page = init_studies_page()
28
-
29
- return gr.TabbedInterface(
30
- [study_page,studies_page],
31
- ["Clinical Study","Studies"],
32
- theme = gr.themes.Soft(primary_hue="sky",secondary_hue="orange"),
33
- css = "footer {visibility: hidden}",
34
- title="AMRA AI Medi Reader")
35
 
36
  def refresh_data():
37
  return
38
 
39
  if __name__ == "__main__":
40
  init_app_data()
41
- demo = init_demo()
42
  demo.launch()
 
 
 
1
  # first layer extraction(text)
2
  # second layer extraction(first layer output)
3
  # third layer extraction(first layer outputs aggregated, second layer outputs aggregated)
 
8
  from cloud_db import *
9
  from supplier import *
10
  from utility import *
11
+ from features import init_app_data
12
 
13
+ from ui_summary import *
 
 
14
 
15
 
16
  examples = []
17
+ # app_theme = gr.themes.Base(neutral_hue="blue")
18
 
19
+ demo = gr.TabbedInterface(
20
+ [summary_page],
21
+ ["Summary"],
22
+ theme = gr.themes.Soft(primary_hue="sky",secondary_hue="orange"),
23
+ title="AMRA AI Medi Reader",
24
+ css = "footer {visibility: hidden}",
25
+ )
26
+ # )
 
 
 
 
 
 
27
 
28
  def refresh_data():
29
  return
30
 
31
  if __name__ == "__main__":
32
  init_app_data()
 
33
  demo.launch()
ui_studies.py DELETED
@@ -1,42 +0,0 @@
1
- import gradio as gr
2
-
3
- from application import *
4
- from features import init_app_data
5
- from utility import terminal_print
6
-
7
- def refresh():
8
- init_app_data()
9
- '''
10
- refresh the literature report.
11
- '''
12
- return create_md_tables(app_data["articles"])
13
-
14
-
15
- def create_md_tables(articles):
16
- '''
17
- create markdown tables for the articles.
18
- '''
19
- md_text = ""
20
- md_text += "| Domain | File Name | Upload Time | Device |\n| --- | --- | --- | --- |\n"
21
-
22
- for article in articles:
23
- md_table = f"| {article['domain']} | {article['name']} | {article['upload_time']} | {default_region} |\n"
24
- md_text += md_table
25
-
26
- return md_text
27
-
28
- @terminal_print
29
- def init_studies_page():
30
- with gr.Blocks() as studies_page:
31
- with gr.Row():
32
- gr.Markdown("## Article Lists")
33
- btn_refresh = gr.Button(value="Refresh",variant="primary")
34
- gr.HTML("<hr>")
35
-
36
- article_list = gr.Markdown("")
37
-
38
- btn_refresh.click(
39
- fn=refresh,
40
- outputs=[article_list]
41
- )
42
- return studies_page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui_study.py DELETED
@@ -1,105 +0,0 @@
1
- import gradio as gr
2
-
3
- from utility import *
4
- from application import *
5
- from features import *
6
-
7
- def reset():
8
- '''
9
- reset gradio input and output features in this page.
10
- '''
11
- return (
12
- gr.Radio.update(value=anatomic_domains[-1]),
13
- gr.Files.update(value=None),
14
- gr.TextArea.update(value=""),
15
- gr.Markdown.update(value=""),
16
- gr.Markdown.update(value="")
17
- )
18
-
19
- # complete user interfaces
20
- @terminal_print
21
- def init_study_page():
22
- with gr.Blocks() as study_page:
23
- # user control panel
24
- with gr.Row(equal_height=False):
25
- with gr.Column():
26
- gr.Markdown("## Studies")
27
- gr.HTML("<hr>")
28
-
29
- upload_study = gr.File(label="Upload a clinical study report",type="file",file_count="multiple")
30
-
31
-
32
- with gr.Column():
33
- domain = gr.Radio(label="Anatomical Region",choices=anatomic_domains,value=default_region)
34
- input_study = gr.TextArea(label="Or paste a clinical study report content",placeholder="Paste content here...",lines=5)
35
- with gr.Row():
36
- btn_reset = gr.Button(value="Reset",variant="stop")
37
- btn_add_study = gr.Button(value="Add",variant="primary")
38
-
39
- gr.HTML("<hr>")
40
- with gr.Row():
41
- gr.Markdown("## Literature Report")
42
-
43
- gr.HTML("<hr>")
44
- with gr.Row(equal_height=False):
45
- with gr.Column():
46
- dropdown = gr.Dropdown(label="Select a literature report",choices=app_data["articles"].keys())
47
- with gr.Column():
48
- with gr.Row():
49
- btn_get_article = gr.Button(value="Get",variant="primary")
50
- btn_refresh = gr.Button(value="Refresh",variant="primary")
51
-
52
- gr.HTML("<hr>")
53
- # extraction outcome panel
54
- with gr.Row(equal_height=False):
55
- with gr.Column():
56
- overview = gr.Markdown("")
57
- with gr.Column():
58
- # tables = gr.Markdown("")
59
- detail_views = gr.Markdown("")
60
-
61
- # control element definition
62
- btn_get_article.click(
63
- get_existing_article,
64
- inputs=[
65
- dropdown,
66
- ],
67
- outputs=[
68
- overview,
69
- detail_views,
70
- ]
71
- )
72
-
73
- btn_reset.click(
74
- reset,
75
- outputs=[
76
- domain,
77
- upload_study,
78
- input_study,
79
- overview,
80
- detail_views,
81
- ]
82
- )
83
-
84
- btn_add_study.click(
85
- process_study,
86
- inputs=[
87
- domain,
88
- upload_study,
89
- input_study,
90
- ],
91
- outputs=[
92
- overview,
93
- detail_views,
94
- # tables
95
- ],
96
- )
97
-
98
- btn_refresh.click(
99
- refresh,
100
- outputs=[
101
- overview,
102
- detail_views,
103
- ],
104
- )
105
- return study_page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui_summary.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from utility import *
4
+ from application import *
5
+ from features import init_app_data # , add_device, remove_device, get_device
6
+
7
+ def reset():
8
+ return (
9
+ gr.Textbox.update(value=""),
10
+ gr.Textbox.update(value=""),
11
+ gr.TextArea.update(value=""),
12
+ gr.TextArea.update(value=""),
13
+ gr.TextArea.update(value=""),
14
+ gr.Markdown.update(value="")
15
+ )
16
+
17
+ def refresh():
18
+ init_app_data()
19
+ '''
20
+ refresh the literature report.
21
+ '''
22
+ return create_md_tables(app_data["devices"]), gr.Dropdown.update(choices=[d["device_name"] for d in app_data["devices"]])
23
+
24
+ with gr.Blocks() as summary_page:
25
+ with gr.Row():
26
+ with gr.Column():
27
+ gr.Markdown("## Summary")
28
+ gr.HTML("<hr>")
29
+ select_device = gr.Dropdown(
30
+ choices=[d["device_name"] for d in app_data["devices"]],
31
+ value=None,
32
+ label="Select Device",
33
+ interactive=True
34
+ )
35
+ gr.HTML("<hr>")
36
+
37
+ # btn_reset.click(
38
+ # fn=reset,
39
+ # outputs=[
40
+ # device_name,
41
+ # device_type,
42
+ # intended_use,
43
+ # indications,
44
+ # contraindications,
45
+ # details
46
+ # ])
47
+
48
+ # show the list of devices in the database
49
+ with gr.Column(scale=2):
50
+ gr.Markdown("## Summary")
51
+ btn_refresh = gr.Button(value="Refresh",variant="primary")
52
+ gr.HTML("<hr>")
53
+
54
+ device_list = gr.Markdown("")
55
+
56
+ btn_refresh.click(
57
+ fn=refresh,
58
+ outputs=[
59
+ device_list,
60
+ select_device
61
+ ]
62
+ )