77 import marimo as mo
88
99
10- @app .cell ( hide_code = True )
10+ @app .cell
1111async def _ ():
1212 import sys
1313
@@ -18,15 +18,17 @@ async def _():
1818 import seaborn as sns
1919 else :
2020 import seaborn as sns
21- return ( sns ,)
21+ return sns , sys
2222
2323
2424@app .cell (hide_code = True )
2525def _ ():
2626 import base64
27+ import time
28+ import zipfile
29+ import requests
2730 from pathlib import Path
2831 from io import BytesIO
29- import time
3032 from pickle import dump
3133
3234 import numpy as np
@@ -58,7 +60,9 @@ def _():
5860 np ,
5961 pd ,
6062 plt ,
63+ requests ,
6164 rescale_intensity ,
65+ zipfile ,
6266 )
6367
6468
@@ -70,7 +74,7 @@ def _():
7074
7175 **Mallory Wittwer** (Presenter)
7276
73- [↗️ Repository]()
77+ [↗️ Repository](https://github.com/EPFL-Center-for-Imaging/vision-workshop )
7478
7579 ---
7680
@@ -151,16 +155,35 @@ def _():
151155
152156
153157@app .cell
154- def _ ():
155- dataset_path = mo .notebook_location () / "public" / "dataset"
158+ def _ (Path ):
159+ dataset_path = Path ("public" ) / "dataset"
160+ return (dataset_path ,)
156161
162+
163+ @app .cell
164+ def _ (Path , dataset_path , requests , sys , zipfile ):
165+ if "pyodide" in sys .modules :
166+ # Unzip the dataset from the public folder
167+ zip_path = Path ("public" ) / "dataset.zip"
168+ url = mo .notebook_location () / "public" / "dataset.zip"
169+ if not dataset_path .exists ():
170+ r = requests .get (str (url ))
171+ r .raise_for_status ()
172+ zip_path .write_bytes (r .content )
173+ with zipfile .ZipFile (zip_path , "r" ) as zf :
174+ zf .extractall (dataset_path )
175+ return
176+
177+
178+ @app .cell
179+ def _ (dataset_path ):
157180 path_exists = "✅ yes" if dataset_path .exists () else "❌ no"
158181
159182 mo .vstack ([
160183 mo .md (f"Dataset path: **{ str (dataset_path .resolve ())} **" ),
161184 mo .md (f"Path exists: **{ path_exists } **" )
162185 ])
163- return ( dataset_path ,)
186+ return
164187
165188
166189@app .cell (hide_code = True )
0 commit comments