Skip to content

Commit 899f650

Browse files
committed
Store data when changing image
1 parent 528f78e commit 899f650

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ def refresh_radio_buttons(click_n, click_p):
4848
return view.refresh_radio_buttons()
4949

5050

51+
def store_data(db, username, shapes):
52+
for shape in shapes:
53+
db.add_annotation(
54+
name=shape.name, username=username,
55+
xy=utils.compute_circle_center(shape.path)
56+
)
57+
58+
5159
@view.app.callback(
5260
[Output('canvas', 'figure'),
5361
Output('radio', 'value'),
@@ -93,8 +101,10 @@ def update_image(clickData, relayoutData, click_n, click_p, click_c, slider_val,
93101
view.fig.layout.yaxis.autorange = 'reversed'
94102
elif button_id == 'next':
95103
ind_image = (ind_image + 1) % len(db.dataset)
104+
store_data(db, username, view.fig.layout.shapes)
96105
elif button_id == 'previous':
97106
ind_image = (ind_image - 1) % len(db.dataset)
107+
store_data(db, username, view.fig.layout.shapes)
98108
return view.make_figure_image(ind_image), view.options[0], ind_image, '[]'
99109

100110
already_labeled = [shape['name'] for shape in shapes]

0 commit comments

Comments
 (0)