Setup + Read GeoTIFF Satellite Data
Steps 1–2 of the CEAMLS guide. Stand up the cloud workspace, download the xBD dataset (51 GB compressed), and read 16-bit GeoTIFF tiles with Rasterio.
/content/ resets each session.Create the Google Drive project folder
python1# Open drive.google.com → New → Folder2# Name it: ceamls-project3# Inside it, create subfolders:4# data/ notebooks/ results/ patches/
Plain-English explanation
Every student creates the same folder layout in their own Drive so notebooks and paths line up.
Why it matters
Colab notebooks reference '/content/drive/MyDrive/ceamls-project/...'. If the folder layout differs across students, every shared notebook breaks on path errors.
Line by line
ceamls-project/Top-level project root, mounted at /content/drive/MyDrive/ceamls-project in Colab.data/Holds the extracted xBD GeoTIFF tiles and JSON labels.notebooks/All .ipynb files and Python modules (dataset.py, metrics.py).results/Trained model weights, ONNX exports, confusion matrices, plots.
Enable the Colab GPU runtime
python1# In Colab: Runtime → Change runtime type → T4 GPU → Save2import torch3print('CUDA available:', torch.cuda.is_available())4print('Device:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU')
Plain-English explanation
Free Colab gives you an NVIDIA T4 GPU. Training the baseline CNN+UNet on CPU would take days; on T4 it takes hours.
Why it matters
The xBD dataset has 850k patches. Each training epoch needs ~10⁹ FLOPs per patch; only GPU makes that tractable in a summer project.
Common errors
Register on xBD and download the 51 GB dataset
python1# 1. Go to https://xview2.org/dataset → Register2# 2. Download all 7 parts (~7.3 GB each) to your Windows PC3# 3. Upload all 7 .tar.gz parts to Drive → ceamls-project/data/4# 4. Then in Colab, combine and extract:5!cat /content/drive/MyDrive/ceamls-project/data/xview2_*.tar.gz \6 > /content/drive/MyDrive/ceamls-project/data/combined.tar.gz7!tar -xzf /content/drive/MyDrive/ceamls-project/data/combined.tar.gz \8 -C /content/drive/MyDrive/ceamls-project/data/
Plain-English explanation
xBD is the official Department-of-Defense satellite damage dataset: 18,336 pre/post image pairs covering 6 disaster types.
Why it matters
The dataset is split into 7 parts because a single 51 GB upload would time out. cat concatenates them back into one archive before extraction.
Common errors
Install Rasterio and read a GeoTIFF
python1!pip install rasterio --quiet2from google.colab import drive3drive.mount('/content/drive')45import rasterio6import numpy as np78path = '/content/drive/MyDrive/ceamls-project/data/train/images/hurricane-harvey_00000000_post_disaster.tif'9with rasterio.open(path) as src:10 print('Channels:', src.count)11 print('Size:', src.width, 'x', src.height)12 print('Dtype:', src.dtypes[0])13 print('CRS:', src.crs)14 img = src.read([5, 3, 2]) # bands 5,3,2 ≈ true colour R,G,B15 img = img.astype(np.float32) / 65535.016 img = np.transpose(img, (1, 2, 0)) # (H, W, 3)17print('Shape ready for display:', img.shape)
Plain-English explanation
Rasterio is the geospatial-aware image reader. It preserves 16-bit precision and the CRS (coordinate reference system) — cv2 throws both away.
Why it matters
xBD stores 8 spectral bands at 16-bit; bands 5/3/2 form the natural-colour RGB triplet. Dividing by 65535 converts to [0,1] floats ready for PyTorch.
Line by line
src.read([5,3,2])Read three specific bands; returns a (3, H, W) array./65535.0Max 16-bit value; normalises to [0,1] without clipping.np.transpose(...)Rasterio uses (C,H,W); matplotlib/PyTorch viewers use (H,W,C).src.crsCoordinate reference system (e.g. EPSG:32615) — what you'd lose with cv2.imread.
Common errors
Why use Rasterio instead of cv2.imread() for xBD .tif files?
Build the pre/post pair index CSV
python1import os, glob, pandas as pd23IMG_DIR = '/content/drive/MyDrive/ceamls-project/data/train/images'4LBL_DIR = '/content/drive/MyDrive/ceamls-project/data/train/labels'56pre_imgs = sorted(glob.glob(f'{IMG_DIR}/*_pre_disaster.tif'))7post_imgs = [p.replace('_pre_', '_post_') for p in pre_imgs]8pre_lbls = [p.replace(IMG_DIR, LBL_DIR).replace('.tif', '.json') for p in pre_imgs]9post_lbls = [p.replace('_pre_', '_post_') for p in pre_lbls]1011meta = pd.DataFrame({12 'event': [os.path.basename(p).split('_')[0] for p in pre_imgs],13 'pre_img': pre_imgs,14 'post_img': post_imgs,15 'pre_lbl': pre_lbls,16 'post_lbl': post_lbls,17})18meta.to_csv('/content/drive/MyDrive/ceamls-project/data/pairs.csv', index=False)19print('Pairs found:', len(meta))20print(meta['event'].value_counts())
Plain-English explanation
One row per (pre, post) image pair — 18,336 in total across 6 disaster events.
Why it matters
S2 (baseline) and S3 (Siamese, ViT) all load data through this CSV. A single source of truth keeps the splits identical across teammates.