Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 9e10c54

Browse files
committed
Switch to multi-page app
1 parent d50103d commit 9e10c54

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

Procfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
web: gunicorn correct_segmentation:server
2-
manuel: gunicorn app_seg:server
1+
web: gunicorn index:server

app_seg.py renamed to app1_seg.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from dash_canvas.utils.plot_utils import image_with_contour
1717
from dash_canvas.utils.io_utils import image_string_to_PILImage
1818

19+
from app import app
20+
1921
# Image to segment and shape parameters
2022
filename = 'https://upload.wikimedia.org/wikipedia/commons/e/e4/Mitochondria%2C_mammalian_lung_-_TEM_%282%29.jpg'
2123
img = io.imread(filename, as_gray=True)
@@ -26,18 +28,18 @@
2628

2729

2830
# ------------------ App definition ---------------------
29-
31+
"""
3032
app = dash.Dash(__name__)
3133
3234
server = app.server
3335
3436
app.css.append_css({
3537
'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'
3638
})
39+
"""
3740

3841

39-
40-
app.layout = html.Div([
42+
layout = html.Div([
4143
html.Div([
4244
html.Div([
4345
html.H2(children='Segmentation tool'),

correct_segmentation.py renamed to app2_correct_segmentation.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from dash_canvas.utils.io_utils import image_string_to_PILImage, array_to_data_url
1616
from dash_canvas.utils.image_processing_utils import modify_segmentation
1717

18+
from app import app
19+
1820
# Image to segment and shape parameters
1921
filename = 'https://upload.wikimedia.org/wikipedia/commons/1/1b/HumanChromosomesChromomycinA3.jpg'
2022
img = io.imread(filename, as_gray=True)
@@ -29,21 +31,12 @@
2931
canvas_width = 500
3032
canvas_height = round(height * canvas_width / width)
3133
scale = canvas_width / width
32-
print(scale, canvas_height)
3334

3435
# ------------------ App definition ---------------------
3536

36-
app = dash.Dash(__name__)
37-
38-
server = app.server
39-
40-
app.css.append_css({
41-
'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'
42-
})
43-
4437

4538

46-
app.layout = html.Div([
39+
layout = html.Div([
4740
html.Div([
4841
html.H3(children='Manual correction of automatic segmentation'),
4942
dcc.Markdown('''
@@ -92,7 +85,7 @@
9285
], className="four columns"),
9386
html.Div([
9487
dash_canvas.DashCanvas(
95-
id='canvas',
88+
id='canvas_',
9689
label='my-label',
9790
width=canvas_width,
9891
height=canvas_height,
@@ -106,11 +99,11 @@
10699

107100
# ----------------------- Callbacks -----------------------------
108101
@app.callback(Output('cache', 'data'),
109-
[Input('canvas', 'trigger'),],
110-
[State('canvas', 'json_data'),
111-
State('canvas', 'scale'),
112-
State('canvas', 'height'),
113-
State('canvas', 'width'),
102+
[Input('canvas_', 'trigger'),],
103+
[State('canvas_', 'json_data'),
104+
State('canvas_', 'scale'),
105+
State('canvas_', 'height'),
106+
State('canvas_', 'width'),
114107
State('cache', 'data'),
115108
State('mode', 'value')])
116109
def update_segmentation(toggle, string, s, h, w, children, mode):
@@ -125,7 +118,7 @@ def update_segmentation(toggle, string, s, h, w, children, mode):
125118
return new_labels
126119

127120

128-
@app.callback(Output('canvas', 'image_content'),
121+
@app.callback(Output('canvas_', 'image_content'),
129122
[Input('cache', 'data')])
130123
def update_figure(labs):
131124
new_labels = np.array(labs)
@@ -154,7 +147,7 @@ def save_segmentation(labs, save_mode):
154147
uri = array_to_data_url(new_labels, dtype=np.uint8)
155148
return uri
156149

157-
@app.callback(Output('canvas', 'tool'),
150+
@app.callback(Output('canvas_', 'tool'),
158151
[Input('tool', 'value')])
159152
def change_tool(tool_value):
160153
return tool_value

0 commit comments

Comments
 (0)