Skip to content

Instantly share code, notes, and snippets.

View calebrob6's full-sized avatar

Caleb Robinson calebrob6

View GitHub Profile
@calebrob6
calebrob6 / running_stats_in_torch.py
Last active May 28, 2024 07:52
A class for computing online mean and variance of multi-dimensional arrays in PyTorch (i.e. for computing per-channel stats over large image datasets).
import torch
class RunningStatsButFast(torch.nn.Module):
def __init__(self, shape, dims):
"""Initializes the RunningStatsButFast method.
A PyTorch module that can be put on the GPU and calculate the multidimensional
mean and variance of inputs online in a numerically stable way. This is useful
for calculating the channel-wise mean and variance of a big dataset because you
don't have to load the entire dataset into memory.
@calebrob6
calebrob6 / area.ipynb
Created May 8, 2024 02:23
How do the areas of a set of polygons and their rasterized equivalents differ as a function of spatial resolution of the rasterized versions?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / sam_inference.py
Last active May 22, 2024 02:20
Runs inference on large satellite image scenes with SAM models
# Requires the `segment-geospatial` package https://samgeo.gishub.org/
import argparse
import os
import cv2
import numpy as np
import rasterio
import rasterio.features
import rasterio.transform
import rasterio.windows
@calebrob6
calebrob6 / jaccard_test.ipynb
Created February 22, 2024 00:01
Verify the behavior of `smp.losses.JaccardLoss`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / landcover_analysis_tutorial.ipynb
Created November 14, 2023 23:25
Tutorial notebook showing how to calculate the land cover distribution around a point.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / torchgeo_object_detection_example.ipynb
Created October 13, 2023 04:10
Short example of object detection training in 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 / torchgeo_rasterdataset_cog.ipynb
Created October 2, 2023 22:27
Demo that shows how to use TorchGeo to do windowed reading from remote COGs.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / make_legend2.ipynb
Created August 15, 2023 13:49
Another notebook for generating a legend figure from labels and colors
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / ball_sort_puzzle_dfs.ipynb
Last active August 14, 2023 05:14
Solves a game called "ball sort puzzle" using a depth first search.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.