Skip to content

Instantly share code, notes, and snippets.

View calebrob6's full-sized avatar

Caleb Robinson calebrob6

View GitHub Profile
@calebrob6
calebrob6 / ftw-test.ipynb
Created November 18, 2025 06:23
Example running Fields of The World model with TorchGeo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / dinov3_and_anyup.ipynb
Created November 14, 2025 21:22
Notebook showing how to use the AnyUp model to upsample low (spatial) resolution embeddings.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / size_of_embeddings.ipynb
Created November 13, 2025 00:36
Size of embeddings
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / embed.py
Last active September 22, 2025 19:09
Create embeddings from an input GeoTIFF using DINOv3 and save results as an output GeoTIFF.
import argparse
import math
import os
import time
from typing import List, Optional, Sequence, Tuple
import numpy as np
import rasterio
import rasterio.windows
import torch
@calebrob6
calebrob6 / FTW demo application.ipynb
Created August 12, 2025 23:29
Notebook that shows end-to-end example of running a Fields of the World model on Sentinel-2 imagery and joining with CDL labels and MOSAIKS embeddings.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / lbp.py
Created August 3, 2025 02:07
PyTorch local binary pattern histograms
def batch_histogram(data_tensor, num_classes=-1):
"""
From https://discuss.pytorch.org/t/batched-torch-histc/179741
Computes histograms of integral values, even if in batches (as opposed to torch.histc and torch.histogram).
Arguments:
data_tensor: a D1 x ... x D_n torch.LongTensor
num_classes (optional): the number of classes present in data.
If not provided, tensor.max() + 1 is used (an error is thrown if tensor is empty).
Returns:
@calebrob6
calebrob6 / benchmark_sieve.py
Created April 17, 2025 19:15
Script for benchmarking polygonization through gdal command line calls vs. in-memory with rasterio and friends.
#!/usr/bin/env python3
"""
benchmark_sieve.py
Benchmark sieving, polygonizing, and simplifying GeoTIFFs using two methods:
- "gdal": subprocess calls to gdal_sieve.py, gdal_polygonize.py, and ogr2ogr
- "python": pure Python using rasterio.features, shapely, and fiona
"""
import os
@calebrob6
calebrob6 / rcf_segmentation.py
Created March 13, 2025 03:26
A subclass of torchgeo's RCF model that averages features over a given mask instead of the whole input.
class RCFSegmentationFeatures(RCF):
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
"""Forward pass of the RCF model.
Args:
x: a tensor with shape (C, H, W)
y: a tensor with shape (H, W)
Returns:
a tensor of size (``self.num_features``)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / eurosat_few_shot.ipynb
Last active January 13, 2025 22:09
Small experiment showing KNN performance on EuroSAT with MOSAIKS features and different numbers of training samples per class.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.