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

Commit

Permalink
Switch to multi-page app
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelle committed Jan 13, 2019
1 parent d50103d commit 9e10c54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
3 changes: 1 addition & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
web: gunicorn correct_segmentation:server
manuel: gunicorn app_seg:server
web: gunicorn index:server
8 changes: 5 additions & 3 deletions app_seg.py → app1_seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from dash_canvas.utils.plot_utils import image_with_contour
from dash_canvas.utils.io_utils import image_string_to_PILImage

from app import app

# Image to segment and shape parameters
filename = 'https://upload.wikimedia.org/wikipedia/commons/e/e4/Mitochondria%2C_mammalian_lung_-_TEM_%282%29.jpg'
img = io.imread(filename, as_gray=True)
Expand All @@ -26,18 +28,18 @@


# ------------------ App definition ---------------------

"""
app = dash.Dash(__name__)
server = app.server
app.css.append_css({
'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'
})
"""



app.layout = html.Div([
layout = html.Div([
html.Div([
html.Div([
html.H2(children='Segmentation tool'),
Expand Down
29 changes: 11 additions & 18 deletions correct_segmentation.py → app2_correct_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from dash_canvas.utils.io_utils import image_string_to_PILImage, array_to_data_url
from dash_canvas.utils.image_processing_utils import modify_segmentation

from app import app

# Image to segment and shape parameters
filename = 'https://upload.wikimedia.org/wikipedia/commons/1/1b/HumanChromosomesChromomycinA3.jpg'
img = io.imread(filename, as_gray=True)
Expand All @@ -29,21 +31,12 @@
canvas_width = 500
canvas_height = round(height * canvas_width / width)
scale = canvas_width / width
print(scale, canvas_height)

# ------------------ App definition ---------------------

app = dash.Dash(__name__)

server = app.server

app.css.append_css({
'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'
})



app.layout = html.Div([
layout = html.Div([
html.Div([
html.H3(children='Manual correction of automatic segmentation'),
dcc.Markdown('''
Expand Down Expand Up @@ -92,7 +85,7 @@
], className="four columns"),
html.Div([
dash_canvas.DashCanvas(
id='canvas',
id='canvas_',
label='my-label',
width=canvas_width,
height=canvas_height,
Expand All @@ -106,11 +99,11 @@

# ----------------------- Callbacks -----------------------------
@app.callback(Output('cache', 'data'),
[Input('canvas', 'trigger'),],
[State('canvas', 'json_data'),
State('canvas', 'scale'),
State('canvas', 'height'),
State('canvas', 'width'),
[Input('canvas_', 'trigger'),],
[State('canvas_', 'json_data'),
State('canvas_', 'scale'),
State('canvas_', 'height'),
State('canvas_', 'width'),
State('cache', 'data'),
State('mode', 'value')])
def update_segmentation(toggle, string, s, h, w, children, mode):
Expand All @@ -125,7 +118,7 @@ def update_segmentation(toggle, string, s, h, w, children, mode):
return new_labels


@app.callback(Output('canvas', 'image_content'),
@app.callback(Output('canvas_', 'image_content'),
[Input('cache', 'data')])
def update_figure(labs):
new_labels = np.array(labs)
Expand Down Expand Up @@ -154,7 +147,7 @@ def save_segmentation(labs, save_mode):
uri = array_to_data_url(new_labels, dtype=np.uint8)
return uri

@app.callback(Output('canvas', 'tool'),
@app.callback(Output('canvas_', 'tool'),
[Input('tool', 'value')])
def change_tool(tool_value):
return tool_value
Expand Down

0 comments on commit 9e10c54

Please sign in to comment.