Rimjhim Mittal commited on
Commit
9f83a9f
·
1 Parent(s): 711dd93

adding upload options to sidebar

Browse files
Files changed (3) hide show
  1. app.py +23 -11
  2. examples/Simple.json +73 -0
  3. logofinal.jpg +0 -0
app.py CHANGED
@@ -201,14 +201,14 @@ def parameter_form_to_update_model_and_view(mdf_model, parameters, param_inputs,
201
  def upload_file_and_load_to_model():
202
 
203
 
204
- uploaded_file = st.file_uploader("Choose a JSON/YAML/BSON file", type=["json", "yaml", "bson"])
205
  if uploaded_file is not None:
206
  file_content = uploaded_file.getvalue()
207
  file_extension = uploaded_file.name.split('.')[-1].lower()
208
  return load_model_from_content(file_content, file_extension)
209
  col2, col3 = st.columns(2)
210
  with col2:
211
- github_url = st.text_input("Enter GitHub raw file URL:", placeholder="Enter GitHub raw file URL")
212
  if github_url:
213
  try:
214
  response = requests.get(github_url)
@@ -226,13 +226,14 @@ def upload_file_and_load_to_model():
226
  "FN": "./examples/FN.mdf.json",
227
  "States": "./examples/States.json",
228
  "Swicthed RLC Circuit": "./examples/switched_rlc_circuit.json",
 
229
  # "Arrays":"./examples/Arrays.json",
230
  # "RNN":"./examples/RNNs.json",
231
  # "IAF":"./examples/IAFs.json"
232
  "Izhikevich Test":"./examples/IzhikevichTest.mdf.json"
233
  }
234
  with col3:
235
- selected_model = st.selectbox("Choose an example model", list(example_models.keys()), index=None, placeholder="Dont have an MDF Model? Try some sample examples here!")
236
  if selected_model:
237
  return load_mdf_json(example_models[selected_model])
238
 
@@ -260,16 +261,18 @@ def load_model_from_content(file_content, file_extension):
260
  def main():
261
  if "checkbox" not in st.session_state:
262
  st.session_state.checkbox = False
263
- header1, header2 = st.columns([1,12], vertical_alignment="top")
264
- with header1:
265
- st.image("logo.png", width=100)
266
- with header2:
267
- st.title("Welcome to Model Description Format")
268
- st.write("Lets get started! Choose one of the following methods.")
269
  mdf_model = upload_file_and_load_to_model() # controller
270
 
271
  if mdf_model:
272
-
 
 
 
 
 
 
273
  mod_graph = mdf_model.graphs[0]
274
  nodes = mod_graph.nodes
275
  parameters = []
@@ -285,7 +288,16 @@ def main():
285
  param_inputs["Simulation Duration (s)"] = preferred_duration
286
  param_inputs["Time Step (s)"] = preferred_dt
287
  parameter_form_to_update_model_and_view(mdf_model, parameters, param_inputs, mod_graph, nodes)
288
-
 
 
 
 
 
 
 
 
 
289
  if __name__ == "__main__":
290
  main()
291
 
 
201
  def upload_file_and_load_to_model():
202
 
203
 
204
+ uploaded_file = st.sidebar.file_uploader("Choose a JSON/YAML/BSON file", type=["json", "yaml", "bson"])
205
  if uploaded_file is not None:
206
  file_content = uploaded_file.getvalue()
207
  file_extension = uploaded_file.name.split('.')[-1].lower()
208
  return load_model_from_content(file_content, file_extension)
209
  col2, col3 = st.columns(2)
210
  with col2:
211
+ github_url = st.sidebar.text_input("Enter GitHub raw file URL:", placeholder="Enter GitHub raw file URL")
212
  if github_url:
213
  try:
214
  response = requests.get(github_url)
 
226
  "FN": "./examples/FN.mdf.json",
227
  "States": "./examples/States.json",
228
  "Swicthed RLC Circuit": "./examples/switched_rlc_circuit.json",
229
+ "Simple":"./examples/Simple.json",
230
  # "Arrays":"./examples/Arrays.json",
231
  # "RNN":"./examples/RNNs.json",
232
  # "IAF":"./examples/IAFs.json"
233
  "Izhikevich Test":"./examples/IzhikevichTest.mdf.json"
234
  }
235
  with col3:
236
+ selected_model = st.sidebar.selectbox("Choose an example model", list(example_models.keys()), index=None, placeholder="Dont have an MDF Model? Try some sample examples here!")
237
  if selected_model:
238
  return load_mdf_json(example_models[selected_model])
239
 
 
261
  def main():
262
  if "checkbox" not in st.session_state:
263
  st.session_state.checkbox = False
264
+
265
+
 
 
 
 
266
  mdf_model = upload_file_and_load_to_model() # controller
267
 
268
  if mdf_model:
269
+ header1, header2 = st.columns([1, 8], vertical_alignment="top")
270
+ with header1:
271
+ with st.container():
272
+ st.image("logofinal.jpg")
273
+ with header2:
274
+ with st.container():
275
+ st.title("MDF: "+ mdf_model.id)
276
  mod_graph = mdf_model.graphs[0]
277
  nodes = mod_graph.nodes
278
  parameters = []
 
288
  param_inputs["Simulation Duration (s)"] = preferred_duration
289
  param_inputs["Time Step (s)"] = preferred_dt
290
  parameter_form_to_update_model_and_view(mdf_model, parameters, param_inputs, mod_graph, nodes)
291
+ else:
292
+ header1, header2 = st.columns([1, 8], vertical_alignment="top")
293
+ with header1:
294
+ with st.container():
295
+ st.image("logofinal.jpg")
296
+ with header2:
297
+ with st.container():
298
+ st.title("Welcome to Model Description Format")
299
+ st.write("ModECI (Model Exchange and Convergence Initiative) is a multi-investigator collaboration that aims to develop a standardized format for exchanging computational models across diverse software platforms and domains of scientific research and technology development, with a particular focus on neuroscience, Machine Learning and Artificial Intelligence. Refer to https://modeci.org/ for more.")
300
+ st.header("Lets get started! Choose one of the following methods.")
301
  if __name__ == "__main__":
302
  main()
303
 
examples/Simple.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Simple": {
3
+ "format": "ModECI MDF v0.4",
4
+ "generating_application": "Python modeci-mdf v0.4.11",
5
+ "graphs": {
6
+ "simple_example": {
7
+ "nodes": {
8
+ "input_node": {
9
+ "parameters": {
10
+ "input_level": {
11
+ "value": 0.5
12
+ }
13
+ },
14
+ "output_ports": {
15
+ "out_port": {
16
+ "value": "input_level"
17
+ }
18
+ }
19
+ },
20
+ "processing_node": {
21
+ "input_ports": {
22
+ "input_port1": {}
23
+ },
24
+ "parameters": {
25
+ "lin_slope": {
26
+ "value": 0.5
27
+ },
28
+ "lin_intercept": {
29
+ "value": 0
30
+ },
31
+ "log_gain": {
32
+ "value": 3
33
+ },
34
+ "linear_1": {
35
+ "function": "linear",
36
+ "args": {
37
+ "variable0": "input_port1",
38
+ "slope": "lin_slope",
39
+ "intercept": "lin_intercept"
40
+ }
41
+ },
42
+ "logistic_1": {
43
+ "function": "logistic",
44
+ "args": {
45
+ "variable0": "linear_1",
46
+ "gain": "log_gain",
47
+ "bias": 0,
48
+ "offset": 0
49
+ }
50
+ }
51
+ },
52
+ "output_ports": {
53
+ "output_1": {
54
+ "value": "logistic_1"
55
+ }
56
+ }
57
+ }
58
+ },
59
+ "edges": {
60
+ "input_edge": {
61
+ "sender": "input_node",
62
+ "receiver": "processing_node",
63
+ "sender_port": "out_port",
64
+ "receiver_port": "input_port1",
65
+ "parameters": {
66
+ "weight": 0.55
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
logofinal.jpg ADDED