Skip to content
Snippets Groups Projects
Commit 22b50bdc authored by Hammouda Elbez's avatar Hammouda Elbez :computer:
Browse files

Fix layout and added Current Epoch info

parent c1b4b37f
Branches
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@ class Global_Var():
data_loaded = None
db = None
updateInterval = 1.0 # 1 second
InputPerEpoch = 1
stepMax = 0
Max = 0
nbrClasses = 0
......
......@@ -32,7 +32,7 @@ class callbacks(callbacksOp):
try:
def processGeneralGraph(data, sliderValue, generalGraphFilter, generalLayerFilter):
def processGeneralGraph(data, sliderValue, generalGraphFilter, generalLayerFilter, Epoch):
""" Create general graph components.
Args:
......@@ -40,6 +40,7 @@ class callbacks(callbacksOp):
sliderValue (int): value of the slider
generalGraphFilter (list): actual filter of GeneralGraph visualization
generalLayerFilter (list): selected layers for GeneralGraph visualization
Epoch (int): Epoch number
Returns:
general graph content
......@@ -205,6 +206,15 @@ class callbacks(callbacksOp):
"width": 2},
),row=1, col=1)
fig.add_annotation(dict(font=dict(color='rgb(68, 71, 99)',size=15),
x=0,
y=-0.12,
showarrow=False,
text="Epoch "+str(Epoch) if Epoch != -1 else "",
textangle=0,
xanchor='left',
xref="paper",
yref="paper"))
return fig
except Exception:
......@@ -406,8 +416,8 @@ class callbacks(callbacksOp):
@app.callback(
[Output("general-graph", "figure")
], [Input("v-step", "children")],
[State("interval", "value"), State("GeneralGraphFilter", "value"), State("GeneralLayerFilter", "value"), State('general-graph-switch', 'on')])
def progressGeneralGraph(sliderValue, updateInterval, generalGraphFilter, generalLayerFilter, generalGraphSwitchIsOn):
[State("interval", "value"), State("GeneralGraphFilter", "value"), State("GeneralLayerFilter", "value"), State('general-graph-switch', 'on'),State("InputPerEpoch","value")])
def progressGeneralGraph(sliderValue, updateInterval, generalGraphFilter, generalLayerFilter, generalGraphSwitchIsOn,InputPerEpoch):
""" Update the general graph.
Args:
......@@ -416,6 +426,7 @@ class callbacks(callbacksOp):
generalGraphFilter (list): actual filter of GeneralGraph visualization
generalLayerFilter (list): selected layers for GeneralGraph visualization
generalGraphSwitchIsOn (bool): general graph switch value
InputPerEpoch (int): Number of inputs per epoch
Raises:
no_update: in case we don't want to update the content we rise this execption
......@@ -424,6 +435,11 @@ class callbacks(callbacksOp):
content of the graph that contains general information on the network activity
"""
if generalGraphSwitchIsOn:
labelData = getNetworkInput(int(sliderValue)*float(updateInterval), g.updateInterval)
if labelData != None:
labelData = (labelData[1] // InputPerEpoch)+1 if (labelData[1] % InputPerEpoch) != 0 else (labelData[1] // InputPerEpoch)
else:
labelData = -1
if len(super.xAxisLabel) > 0 and "["+g.getLabelTime(g.updateInterval, sliderValue)+","+g.getLabelTime(g.updateInterval, sliderValue+1)+"]" == super.xAxisLabel[-1]:
return no_update
......@@ -436,7 +452,7 @@ class callbacks(callbacksOp):
None, sliderValue, generalGraphFilter, generalLayerFilter)
else:
generalGraph = processGeneralGraph(
generalData, sliderValue, generalGraphFilter, generalLayerFilter)
generalData, sliderValue, generalGraphFilter, generalLayerFilter,labelData)
return [generalGraph]
......@@ -447,7 +463,7 @@ class callbacks(callbacksOp):
generalData = GeneralModuleData(
int(sliderValue)*float(updateInterval), generalGraphFilter, generalLayerFilter)
generalGraph = processGeneralGraph(
generalData, int(sliderValue), generalGraphFilter, generalLayerFilter)
generalData, int(sliderValue), generalGraphFilter, generalLayerFilter,labelData)
return [generalGraph]
else:
return no_update
......@@ -737,6 +753,7 @@ class callbacks(callbacksOp):
L = dict({i["_id"]: i["C"] for i in labels})
print(timestamp, interval, Max)
return [L, Max]
def getSpike(timestamp, interval, layer, perNeuron):
......
......@@ -158,7 +158,11 @@ class layout(layoutOp):
value=[str(i) for i in (
i["layer"] for i in self.g.LayersNeuronsInfo)],
multi=True,
style={"minWidth": "20%","marginLeft": "5px", "textAlign": "start"})], className="d-flex", style={"paddingLeft": "20px", 'width': '100%'})
style={"minWidth": "20%","marginLeft": "5px", "textAlign": "start"}),
# Epoch value
html.P("Input/Epoch: ", style={
"textAlign": "start", "marginLeft": "20px", "marginTop": "4px"}),
dbc.Input(type="number", id="InputPerEpoch", value=self.g.InputPerEpoch, min=100, step=100, style={"width": "auto","marginLeft": "10px", "textAlign": "start"})], className="d-flex", style={"paddingLeft": "20px", 'width': '100%'})
], className="col-12")
], className="d-flex"),
html.Div([dcc.Graph(id='general-graph', config={"displaylogo": False})])], className="col-lg-9 col-sm-12 col-xs-12" if(self.g.labelsExistance) else "col-lg-12 col-sm-12 col-xs-12"),
......@@ -206,6 +210,8 @@ class layout(layoutOp):
id='cytoscape-compound',
layout={'name': 'preset'},
boxSelectionEnabled=False,
#panningEnabled= False,
responsive=True,
style={'width': '100%',
'height': '100%'},
stylesheet=[
......@@ -308,7 +314,7 @@ class layout(layoutOp):
html.Div([html.A("Information", target="_blank", rel="noopener noreferrer", href="https://gitlab.univ-lille.fr/bioinsp/VS2N", style={
"color": "rgb(217, 220, 255)"})], className="col-sm-2 col-lg-2 align-self-center", style={"position": "fixed", "textAlign": "start"}),
html.Div([html.A("Log Out", href="/logout", style={"color": "rgb(217, 220, 255)"})], className="col-sm-2 col-lg-2 align-self-center", style={
"position": "fixed", "right": "0px", "textAlign": "end"})
"position": "fixed", "right": "10px", "textAlign": "end"})
], className="col-12", style={"marginRight": "0px", "marginLeft": "0px", "paddingRight": "0px", "paddingLeft": "0px"})
], style={"background": "rgb(68, 71, 99)"}),
dbc.Container([
......
......@@ -68,6 +68,7 @@ class spark(sparkOp):
self.g.labelsExistance = True
M = max(M, pymongo.collection.Collection(
self.g.db, 'labels').find_one(sort=[("T", -1)])["T"])
self.g.InputPerEpoch = pymongo.collection.Collection(self.g.db, 'labels').count_documents({})
else:
print("No labels")
......
......@@ -21,7 +21,7 @@
<div class="col-12"><a class="navbar-brand" href="#" style="width: 100%;text-align: center;">VS2N</a></div>
<div class="col-sm-2 col-lg-2 align-self-center" style="position: fixed;text-align: start;"><a href="https://gitlab.univ-lille.fr/bioinsp/VS2N" style="
color: rgb(217, 220, 255);" target="_blank" rel="noopener noreferrer">Information</a></div>
<div class="col-sm-2 col-lg-2 align-self-center" style="position: fixed;right:0px;text-align: end;"><a href="{{url_for('logout')}}" style="color: rgb(217, 220, 255);">Log Out</a></div>
<div class="col-sm-2 col-lg-2 align-self-center" style="position: fixed;right:10px;text-align: end;"><a href="{{url_for('logout')}}" style="color: rgb(217, 220, 255);">Log Out</a></div>
</div></nav>
<!-- End NavBar -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment