Rimjhim Mittal commited on
Commit ·
c00b6ca
1
Parent(s): 9f83a9f
making sure other upload options dont disappear
Browse files
app.py
CHANGED
|
@@ -202,24 +202,7 @@ 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 |
-
|
| 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)
|
| 215 |
-
response.raise_for_status()
|
| 216 |
-
file_content = response.content
|
| 217 |
-
file_extension = github_url.split('.')[-1].lower()
|
| 218 |
-
return load_model_from_content(file_content, file_extension)
|
| 219 |
-
except requests.RequestException as e:
|
| 220 |
-
st.error(f"Error loading file from GitHub: {e}")
|
| 221 |
-
return None
|
| 222 |
-
|
| 223 |
example_models = {
|
| 224 |
"Newton Cooling Model": "./examples/NewtonCoolingModel.json",
|
| 225 |
# "ABCD": "./examples/ABCD.json",
|
|
@@ -229,13 +212,30 @@ def upload_file_and_load_to_model():
|
|
| 229 |
"Simple":"./examples/Simple.json",
|
| 230 |
# "Arrays":"./examples/Arrays.json",
|
| 231 |
# "RNN":"./examples/RNNs.json",
|
| 232 |
-
|
| 233 |
"Izhikevich Test":"./examples/IzhikevichTest.mdf.json"
|
| 234 |
}
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
|
| 241 |
|
|
|
|
| 202 |
|
| 203 |
|
| 204 |
uploaded_file = st.sidebar.file_uploader("Choose a JSON/YAML/BSON file", type=["json", "yaml", "bson"])
|
| 205 |
+
github_url = st.sidebar.text_input("Enter GitHub raw file URL:", placeholder="Enter GitHub raw file URL")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
example_models = {
|
| 207 |
"Newton Cooling Model": "./examples/NewtonCoolingModel.json",
|
| 208 |
# "ABCD": "./examples/ABCD.json",
|
|
|
|
| 212 |
"Simple":"./examples/Simple.json",
|
| 213 |
# "Arrays":"./examples/Arrays.json",
|
| 214 |
# "RNN":"./examples/RNNs.json",
|
| 215 |
+
"IAF":"./examples/IAFs.json",
|
| 216 |
"Izhikevich Test":"./examples/IzhikevichTest.mdf.json"
|
| 217 |
}
|
| 218 |
+
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!")
|
| 219 |
+
|
| 220 |
+
if uploaded_file is not None:
|
| 221 |
+
file_content = uploaded_file.getvalue()
|
| 222 |
+
file_extension = uploaded_file.name.split('.')[-1].lower()
|
| 223 |
+
return load_model_from_content(file_content, file_extension)
|
| 224 |
+
|
| 225 |
+
if github_url:
|
| 226 |
+
try:
|
| 227 |
+
response = requests.get(github_url)
|
| 228 |
+
response.raise_for_status()
|
| 229 |
+
file_content = response.content
|
| 230 |
+
file_extension = github_url.split('.')[-1].lower()
|
| 231 |
+
return load_model_from_content(file_content, file_extension)
|
| 232 |
+
except requests.RequestException as e:
|
| 233 |
+
st.error(f"Error loading file from GitHub: {e}")
|
| 234 |
+
return None
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
if selected_model:
|
| 238 |
+
return load_mdf_json(example_models[selected_model])
|
| 239 |
|
| 240 |
|
| 241 |
|