Spaces:
Sleeping
Sleeping
artelabsuper
commited on
Commit
·
7672122
1
Parent(s):
85993f4
memory lose fixed
Browse files
app.py
CHANGED
|
@@ -5,6 +5,9 @@ import torch
|
|
| 5 |
from utils import *
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
# Load Model
|
| 9 |
# @title Load pretrained weights
|
| 10 |
|
|
@@ -54,6 +57,7 @@ st.markdown('or use a demo sample')
|
|
| 54 |
if st.button('sample 1'):
|
| 55 |
sample_path = 'demo_data/lombardia'
|
| 56 |
|
|
|
|
| 57 |
if sample_path is not None:
|
| 58 |
st.markdown(f'elaborating {sample_path}...')
|
| 59 |
|
|
@@ -145,9 +149,12 @@ if sample_path is not None:
|
|
| 145 |
st.markdown('End prediction')
|
| 146 |
|
| 147 |
folder = "demo_data/results/seg_maps/example-lombardia/2"
|
| 148 |
-
paths = os.listdir(folder)
|
| 149 |
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
file_path = os.path.join(folder, file_picker)
|
| 153 |
print(file_path)
|
|
@@ -158,4 +165,3 @@ if sample_path is not None:
|
|
| 158 |
fig, ax = plt.subplots()
|
| 159 |
ax.imshow(target)
|
| 160 |
st.pyplot(fig)
|
| 161 |
-
|
|
|
|
| 5 |
from utils import *
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
|
| 8 |
+
if not hasattr(st, 'paths'):
|
| 9 |
+
st.paths = None
|
| 10 |
+
|
| 11 |
# Load Model
|
| 12 |
# @title Load pretrained weights
|
| 13 |
|
|
|
|
| 57 |
if st.button('sample 1'):
|
| 58 |
sample_path = 'demo_data/lombardia'
|
| 59 |
|
| 60 |
+
paths = None
|
| 61 |
if sample_path is not None:
|
| 62 |
st.markdown(f'elaborating {sample_path}...')
|
| 63 |
|
|
|
|
| 149 |
st.markdown('End prediction')
|
| 150 |
|
| 151 |
folder = "demo_data/results/seg_maps/example-lombardia/2"
|
| 152 |
+
st.paths = os.listdir(folder)
|
| 153 |
|
| 154 |
+
if st.paths is not None:
|
| 155 |
+
folder = "demo_data/results/seg_maps/example-lombardia/2"
|
| 156 |
+
file_picker = st.selectbox("Select day predict (annual is patch-pred-nn.tif)",
|
| 157 |
+
st.paths, index=st.paths.index('patch-pred-nn.tif'))
|
| 158 |
|
| 159 |
file_path = os.path.join(folder, file_picker)
|
| 160 |
print(file_path)
|
|
|
|
| 165 |
fig, ax = plt.subplots()
|
| 166 |
ax.imshow(target)
|
| 167 |
st.pyplot(fig)
|
|
|