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 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 |
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 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: |
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.
NewerOlder