This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_if_scene_is_cloudy_at_box(item: pystac.Item, box: shapely.geometry.Polygon): | |
"""Uses the S2 Scene Classification Layer (SCL) to determine if a S2 L2A scene is cloudy at a given bbox. | |
Args: | |
item (pystac.Item): The S2 L2A item to check | |
box (shapely.geometry.Polygon): The geometry to check (should be EPSG:4326) | |
Returns: | |
float: The fraction of the box that is classified as "Cloud medium probability" + "Cloud high probability" | |
""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
NewerOlder