diff --git a/src/Global_Var.py b/src/Global_Var.py index 747e8cb3474dcd68a908450b0d34de2a36c34df8..67fc12f21ad815bbe699f6687580ba9e7a9c730b 100755 --- a/src/Global_Var.py +++ b/src/Global_Var.py @@ -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 diff --git a/src/Modules/General/callbacks.py b/src/Modules/General/callbacks.py index 75bd78d9f1b2596813d65249179a94ce2ed56613..ff68593ff820d1ef42c301f31c0a90e94acc5a0c 100755 --- a/src/Modules/General/callbacks.py +++ b/src/Modules/General/callbacks.py @@ -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): diff --git a/src/Modules/General/layout.py b/src/Modules/General/layout.py index 446c73d2971eaaa080f5664d1a6909cc81756992..dedc4e1365b7e8e9c57de8eb4a099d0365437c77 100755 --- a/src/Modules/General/layout.py +++ b/src/Modules/General/layout.py @@ -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([ diff --git a/src/Modules/General/spark.py b/src/Modules/General/spark.py index eb175ab21d45eba707a0eedd9a5c2eb12e83e735..f57c6a39b223331c1f14e2185a95ce999fed5573 100755 --- a/src/Modules/General/spark.py +++ b/src/Modules/General/spark.py @@ -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") diff --git a/src/templates/index.html b/src/templates/index.html index 61fd8e2b66888a7b3d6d9d9c43588cda6981e354..b7aca40929a506694ce31acc0cef78583f045191 100755 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -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 -->