Skip to content

Commit

Permalink
Store data when changing image
Browse files Browse the repository at this point in the history
  • Loading branch information
jeylau committed Jun 5, 2020
1 parent 528f78e commit 899f650
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def refresh_radio_buttons(click_n, click_p):
return view.refresh_radio_buttons()


def store_data(db, username, shapes):
for shape in shapes:
db.add_annotation(
name=shape.name, username=username,
xy=utils.compute_circle_center(shape.path)
)


@view.app.callback(
[Output('canvas', 'figure'),
Output('radio', 'value'),
Expand Down Expand Up @@ -93,8 +101,10 @@ def update_image(clickData, relayoutData, click_n, click_p, click_c, slider_val,
view.fig.layout.yaxis.autorange = 'reversed'
elif button_id == 'next':
ind_image = (ind_image + 1) % len(db.dataset)
store_data(db, username, view.fig.layout.shapes)
elif button_id == 'previous':
ind_image = (ind_image - 1) % len(db.dataset)
store_data(db, username, view.fig.layout.shapes)
return view.make_figure_image(ind_image), view.options[0], ind_image, '[]'

already_labeled = [shape['name'] for shape in shapes]
Expand Down

0 comments on commit 899f650

Please sign in to comment.