Skip to content
Snippets Groups Projects
Commit 721f499d authored by Laurence Brandenberger's avatar Laurence Brandenberger
Browse files

update dashboard.

parent 8b0da0c2
No related branches found
No related tags found
2 merge requests!30Class textbox,!29Web app labelling backend
Pipeline #16979 failed
...@@ -19,7 +19,7 @@ app = dash.Dash(__name__, external_stylesheets=external_stylesheets) ...@@ -19,7 +19,7 @@ app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([ app.layout = html.Div([
# storage # storage
dcc.Store(id='session', storage_type='session'), dcc.Store(id='session', storage_type='memory'),
# html.Div([ # html.Div([
# html.Button(id="start-button",n_clicks=0, children='Start') # html.Button(id="start-button",n_clicks=0, children='Start')
# ],id="start-page"), # ],id="start-page"),
...@@ -37,13 +37,16 @@ app.layout = html.Div([ ...@@ -37,13 +37,16 @@ app.layout = html.Div([
html.Div([ html.Div([
html.Div([ html.Div([
html.H3("Validation"), html.H3("Validation"),
html.Div([html.Pre("File ID:",className="label"), html.Div([html.Pre("Year:",className="label"),
html.Pre("11000103",className="value",id="file-id"), html.Pre("",className="value",id="year"),
html.Pre("Year:",className="label"), html.Pre("File ID:",className="label"),
html.Pre("1995",className="value",id="year"),],className="meta-container"), html.Pre("",className="value",id="file-id"),
html.Pre("Page ID:",className="label"),
html.Pre("",className="value",id="page-id"),
],className="meta-container"),
html.Div([ html.Div([
html.Button(id="skip-button",n_clicks=0, children='Skip',style={"marginRight":"1rem"}), html.Button(id="skip-button",n_clicks=0, children='Skip',style={"marginRight":"1rem","display":"none"}),
html.Button(id='commit-button', n_clicks=0, children='Commit',style={"backgroundColor":"rgba(0,126,255,.08)","color":"#007eff"}) html.Button(id='commit-button', n_clicks=0, children='Commit',style={"backgroundColor":"rgba(0,126,255,.08)","color":"#007eff"})
]) ])
]), ]),
......
...@@ -35,7 +35,6 @@ def boxes_to_list(bboxes): ...@@ -35,7 +35,6 @@ def boxes_to_list(bboxes):
return box_list return box_list
def setup(app): def setup(app):
@app.callback( @app.callback(
Output("canvas","categories"), Output("canvas","categories"),
...@@ -47,20 +46,38 @@ def setup(app): ...@@ -47,20 +46,38 @@ def setup(app):
return [cat] return [cat]
return cat return cat
@app.callback( @app.callback(
Output("session","data"), Output("session","data"),
[Input("skip-button","n_clicks")] [Input("skip-button","n_clicks")],
[State("session","data")]
) )
def skip(n_clicks): def skip(n_clicks,past_data):
if n_clicks is None: if n_clicks is None or n_clicks<1:
raise PreventUpdate return past_data
print("Next page...") print("Next page...")
image,labelled_bboxes,metaData = exhaustive_labelling.load_nextPageToLabel() image,labelled_bboxes,metaData = exhaustive_labelling.load_nextPageToLabel()
return json.dumps({"image":image_to_byte(image),"boxes":boxes_to_list(labelled_bboxes),"meta":serialize_obj(metaData)}) return json.dumps({"image":image_to_byte(image),"boxes":boxes_to_list(labelled_bboxes),"meta":serialize_obj(metaData)})
@app.callback(
Output("file-id","children"),
[Input("session","data")]
)
def update_file_id(data):
return json.loads(data).get("meta",{}).get("file_id","")
@app.callback(
Output("page-id","children"),
[Input("session","data")]
)
def update_page_id(data):
return json.loads(data).get("meta",{}).get("page_id","")
@app.callback(
Output("year","children"),
[Input("session","data")]
)
def update_year(data):
return json.loads(data).get("meta",{}).get("year","")
@app.callback( @app.callback(
Output("skip-button","n_clicks"), Output("skip-button","n_clicks"),
...@@ -71,19 +88,17 @@ def setup(app): ...@@ -71,19 +88,17 @@ def setup(app):
State("skip-button","n_clicks")] State("skip-button","n_clicks")]
) )
def commit(n_clicks,cutoff,session,data,n_clicks_state): def commit(n_clicks,cutoff,session,data,n_clicks_state):
print("Commiting...") if (n_clicks<1 or n_clicks is None):
return n_clicks_state + 1
meta = json.loads(session)["meta"] meta = json.loads(session)["meta"]
m_entry = [] m_entry = []
for entry in data: for entry in data:
if entry["pred"]>cutoff: if entry["pred"]>cutoff:
entry["prob"] = 1 entry["prob"] = 1
else: else:
entry["prob"] = 0 entry["prob"] = 0
del entry["pred"] del entry["pred"]
m_entry.append(entry) m_entry.append(entry)
print("entry",m_entry)
if len(m_entry): if len(m_entry):
exhaustive_labelling.save_labelledPage(m_entry,meta) exhaustive_labelling.save_labelledPage(m_entry,meta)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment