-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_utils.py
87 lines (80 loc) · 2.55 KB
/
plot_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import glob
import dash_bootstrap_components as dbc
from dash import dcc, html
def get_mask_options():
"""
This function gets the mask options
Returns:
mask_options: List of mask options
"""
mask_files = glob.glob("assets/masks/*.tif")
mask_options = []
for mask_file in mask_files:
mask_options.append({"label": mask_file.split("/")[-1], "value": mask_file})
return mask_options
def parse_contents(index):
"""
This function creates the dash components to display thumbnail images
Args:
index: Index of the dash component
Returns:
dash component
"""
img_card = html.Div(
children=[
dbc.Card(
id={"type": "thumbnail-card", "index": index},
children=[
html.A(
id={"type": "thumbnail-image", "index": index},
children=[
dbc.CardImg(
id={"type": "thumbnail-src", "index": index},
style={
"width": "100%",
"margin": "auto",
"display": "block",
},
bottom=False,
),
],
),
dbc.CardBody(
[
html.P(
id={"type": "thumbnail-name", "index": index},
),
],
),
dcc.Store(
id={"type": "processed-data-store", "index": index}, data=None
),
],
outline=False,
style={"display": "none"},
)
],
)
return img_card
def draw_rows(n_rows, n_cols):
"""
This function display the images per page
Args:
n_rows: Number of rows
n_cols: Number of columns
Returns:
dash component with all the images
"""
n_cols = n_cols
children = []
for j in range(n_rows):
row_child = []
for i in range(n_cols):
row_child.append(
dbc.Col(
parse_contents(j * n_cols + i),
width="{}".format(12 // n_cols),
)
)
children.append(dbc.Row(row_child, className="g-1"))
return children