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
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ class Global_Var(): ...@@ -27,6 +27,7 @@ class Global_Var():
data_loaded = None data_loaded = None
db = None db = None
updateInterval = 1.0 # 1 second updateInterval = 1.0 # 1 second
InputPerEpoch = 1
stepMax = 0 stepMax = 0
Max = 0 Max = 0
nbrClasses = 0 nbrClasses = 0
......
...@@ -32,7 +32,7 @@ class callbacks(callbacksOp): ...@@ -32,7 +32,7 @@ class callbacks(callbacksOp):
try: try:
def processGeneralGraph(data, sliderValue, generalGraphFilter, generalLayerFilter): def processGeneralGraph(data, sliderValue, generalGraphFilter, generalLayerFilter, Epoch):
""" Create general graph components. """ Create general graph components.
Args: Args:
...@@ -40,6 +40,7 @@ class callbacks(callbacksOp): ...@@ -40,6 +40,7 @@ class callbacks(callbacksOp):
sliderValue (int): value of the slider sliderValue (int): value of the slider
generalGraphFilter (list): actual filter of GeneralGraph visualization generalGraphFilter (list): actual filter of GeneralGraph visualization
generalLayerFilter (list): selected layers for GeneralGraph visualization generalLayerFilter (list): selected layers for GeneralGraph visualization
Epoch (int): Epoch number
Returns: Returns:
general graph content general graph content
...@@ -205,6 +206,15 @@ class callbacks(callbacksOp): ...@@ -205,6 +206,15 @@ class callbacks(callbacksOp):
"width": 2}, "width": 2},
),row=1, col=1) ),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 return fig
except Exception: except Exception:
...@@ -406,8 +416,8 @@ class callbacks(callbacksOp): ...@@ -406,8 +416,8 @@ class callbacks(callbacksOp):
@app.callback( @app.callback(
[Output("general-graph", "figure") [Output("general-graph", "figure")
], [Input("v-step", "children")], ], [Input("v-step", "children")],
[State("interval", "value"), State("GeneralGraphFilter", "value"), State("GeneralLayerFilter", "value"), State('general-graph-switch', 'on')]) [State("interval", "value"), State("GeneralGraphFilter", "value"), State("GeneralLayerFilter", "value"), State('general-graph-switch', 'on'),State("InputPerEpoch","value")])
def progressGeneralGraph(sliderValue, updateInterval, generalGraphFilter, generalLayerFilter, generalGraphSwitchIsOn): def progressGeneralGraph(sliderValue, updateInterval, generalGraphFilter, generalLayerFilter, generalGraphSwitchIsOn,InputPerEpoch):
""" Update the general graph. """ Update the general graph.
Args: Args:
...@@ -416,6 +426,7 @@ class callbacks(callbacksOp): ...@@ -416,6 +426,7 @@ class callbacks(callbacksOp):
generalGraphFilter (list): actual filter of GeneralGraph visualization generalGraphFilter (list): actual filter of GeneralGraph visualization
generalLayerFilter (list): selected layers for GeneralGraph visualization generalLayerFilter (list): selected layers for GeneralGraph visualization
generalGraphSwitchIsOn (bool): general graph switch value generalGraphSwitchIsOn (bool): general graph switch value
InputPerEpoch (int): Number of inputs per epoch
Raises: Raises:
no_update: in case we don't want to update the content we rise this execption no_update: in case we don't want to update the content we rise this execption
...@@ -424,6 +435,11 @@ class callbacks(callbacksOp): ...@@ -424,6 +435,11 @@ class callbacks(callbacksOp):
content of the graph that contains general information on the network activity content of the graph that contains general information on the network activity
""" """
if generalGraphSwitchIsOn: 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]: if len(super.xAxisLabel) > 0 and "["+g.getLabelTime(g.updateInterval, sliderValue)+","+g.getLabelTime(g.updateInterval, sliderValue+1)+"]" == super.xAxisLabel[-1]:
return no_update return no_update
...@@ -436,7 +452,7 @@ class callbacks(callbacksOp): ...@@ -436,7 +452,7 @@ class callbacks(callbacksOp):
None, sliderValue, generalGraphFilter, generalLayerFilter) None, sliderValue, generalGraphFilter, generalLayerFilter)
else: else:
generalGraph = processGeneralGraph( generalGraph = processGeneralGraph(
generalData, sliderValue, generalGraphFilter, generalLayerFilter) generalData, sliderValue, generalGraphFilter, generalLayerFilter,labelData)
return [generalGraph] return [generalGraph]
...@@ -447,7 +463,7 @@ class callbacks(callbacksOp): ...@@ -447,7 +463,7 @@ class callbacks(callbacksOp):
generalData = GeneralModuleData( generalData = GeneralModuleData(
int(sliderValue)*float(updateInterval), generalGraphFilter, generalLayerFilter) int(sliderValue)*float(updateInterval), generalGraphFilter, generalLayerFilter)
generalGraph = processGeneralGraph( generalGraph = processGeneralGraph(
generalData, int(sliderValue), generalGraphFilter, generalLayerFilter) generalData, int(sliderValue), generalGraphFilter, generalLayerFilter,labelData)
return [generalGraph] return [generalGraph]
else: else:
return no_update return no_update
...@@ -737,6 +753,7 @@ class callbacks(callbacksOp): ...@@ -737,6 +753,7 @@ class callbacks(callbacksOp):
L = dict({i["_id"]: i["C"] for i in labels}) L = dict({i["_id"]: i["C"] for i in labels})
print(timestamp, interval, Max)
return [L, Max] return [L, Max]
def getSpike(timestamp, interval, layer, perNeuron): def getSpike(timestamp, interval, layer, perNeuron):
......
...@@ -158,7 +158,11 @@ class layout(layoutOp): ...@@ -158,7 +158,11 @@ class layout(layoutOp):
value=[str(i) for i in ( value=[str(i) for i in (
i["layer"] for i in self.g.LayersNeuronsInfo)], i["layer"] for i in self.g.LayersNeuronsInfo)],
multi=True, 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="col-12")
], className="d-flex"), ], 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"), 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): ...@@ -206,6 +210,8 @@ class layout(layoutOp):
id='cytoscape-compound', id='cytoscape-compound',
layout={'name': 'preset'}, layout={'name': 'preset'},
boxSelectionEnabled=False, boxSelectionEnabled=False,
#panningEnabled= False,
responsive=True,
style={'width': '100%', style={'width': '100%',
'height': '100%'}, 'height': '100%'},
stylesheet=[ stylesheet=[
...@@ -308,7 +314,7 @@ class layout(layoutOp): ...@@ -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={ 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"}), "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={ 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"}) ], className="col-12", style={"marginRight": "0px", "marginLeft": "0px", "paddingRight": "0px", "paddingLeft": "0px"})
], style={"background": "rgb(68, 71, 99)"}), ], style={"background": "rgb(68, 71, 99)"}),
dbc.Container([ dbc.Container([
......
...@@ -68,6 +68,7 @@ class spark(sparkOp): ...@@ -68,6 +68,7 @@ class spark(sparkOp):
self.g.labelsExistance = True self.g.labelsExistance = True
M = max(M, pymongo.collection.Collection( M = max(M, pymongo.collection.Collection(
self.g.db, 'labels').find_one(sort=[("T", -1)])["T"]) self.g.db, 'labels').find_one(sort=[("T", -1)])["T"])
self.g.InputPerEpoch = pymongo.collection.Collection(self.g.db, 'labels').count_documents({})
else: else:
print("No labels") print("No labels")
......
...@@ -21,7 +21,7 @@ ...@@ -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-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=" <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> 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> </div></nav>
<!-- End NavBar --> <!-- End NavBar -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment