Skip to content

Instantly share code, notes, and snippets.

View lewfish's full-sized avatar

Lewis Fishgold lewfish

  • Philadelphia, PA
View GitHub Profile

this is a fake CLA for testing purposes

./output/
├── bundle
│ └── model-bundle.zip
├── eval
│ └── eval.json
├── Makefile
├── pipeline-config.json
├── predict
│ └── 6_12
│ └── labels.tif
backend_config = PyTorchSemanticSegmentationConfig(
data=data_config,
model=SemanticSegmentationModelConfig(
external_def=ExternalModuleConfig(
github_repo='AdeelH/pytorch-fpn:0.2',
name='fpn',
entrypoint='make_fpn_resnet',
entrypoint_kwargs={
'name': 'resnet50',
'fpn_type': 'panoptic',
aug_transform = A.Compose([
A.Flip(),
A.ShiftScaleRotate(),
A.OneOf([
A.RGBShift(),
A.ToGray(),
A.ToSepia(),
]),
A.OneOf([
A.RandomBrightness(),
@lewfish
lewfish / aoi.py
Last active December 2, 2021 15:46
train_scene = SceneConfig(
id='2_10',
raster_source=RasterioSourceConfig(uris=['./2_10_RGBIR.tif']),
label_source=SemanticSegmentationLabelSourceConfig(
rgb_class_config=class_config,
raster_source=RasterioSourceConfig(uris=['./2_10_label.tif'])),
aoi_uris=['./2_10_aoi.json'])
data_config = SemanticSegmentationGeoDataConfig(
scene_dataset=dataset_config,
# read 200 randomly located chips of size 300x300 from the scene
window_opts=GeoDataWindowConfig(
method=GeoDataWindowMethod.random,
size=300,
size_lims=(200, 400),
max_windows=200))
train_scene = SceneConfig(
id='2_10',
raster_source=RasterioSourceConfig(
# include all 4 bands in the channel_order
uris=['./2_10_RGBIR.tif'], channel_order=[0, 1, 2, 3]),
label_source=SemanticSegmentationLabelSourceConfig(
rgb_class_config=class_config,
raster_source=RasterioSourceConfig(uris=['./2_10_label.tif'])))
...
val_scene = SceneConfig(
label_store=SemanticSegmentationLabelStoreConfig(
rgb=True,
vector_output=[
PolygonVectorOutputConfig(class_id=i)
for i in range(len(class_config))
]),
smooth_output=True,
smooth_as_uint8=True)
from rastervision.pipeline.runner import *
from rastervision.core.rv_pipeline import *
from rastervision.core.data import *
from rastervision.pytorch_backend import *
from rastervision.pytorch_learner import *
def get_config(runner: Runner, root_uri: str) -> SemanticSegmentationConfig:
# specify class names and corresponding colors in the label rasters
class_config = ClassConfig(
import boto3
from pystac import STAC_IO
from pystac import Catalog, LabelItem
from shapely.geometry import box
def setup_stac_s3():
def my_read_method(uri):
parsed = urlparse(uri)
if parsed.scheme == 's3':
bucket = parsed.netloc