Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. minor fixes #1984

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"python.dataScience.jupyterServerURI": "http://localhost:8888/?token=8a748bee8b02072f3212cf087d8497af6bb0d1598de505ca"
}
"python.dataScience.jupyterServerURI": "http://localhost:8888/?token=8a748bee8b02072f3212cf087d8497af6bb0d1598de505ca",
"[python]": {
"editor.defaultFormatter": "eeyore.yapf"
}
}
1 change: 0 additions & 1 deletion rastervision_core/rastervision/core/analyzer/analyzer.py
Original file line number Diff line number Diff line change
@@ -13,4 +13,3 @@ class Analyzer(ABC):
@abstractmethod
def process(self, scenes: List[Scene], tmp_dir: str):
"""Process scenes and save result."""
pass
5 changes: 0 additions & 5 deletions rastervision_core/rastervision/core/backend/backend.py
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ class SampleWriter(AbstractContextManager):
@abstractmethod
def write_sample(self, sample: 'DataSample'):
"""Writes a single sample."""
pass


class Backend(ABC):
@@ -30,7 +29,6 @@ class Backend(ABC):
@abstractmethod
def get_sample_writer(self):
"""Returns a SampleWriter for this Backend."""
pass

@abstractmethod
def train(self):
@@ -39,7 +37,6 @@ def train(self):
This should download chips created by the SampleWriter, train the model, and
then saving it to disk.
"""
pass

@abstractmethod
def load_model(self, uri: Optional[str] = None):
@@ -48,7 +45,6 @@ def load_model(self, uri: Optional[str] = None):
Args:
uri: Optional URI to load the model from.
"""
pass

@abstractmethod
def predict_scene(self, scene: 'Scene', chip_sz: int,
@@ -61,4 +57,3 @@ def predict_scene(self, scene: 'Scene', chip_sz: int,
Return:
Labels object containing predictions
"""
pass
Original file line number Diff line number Diff line change
@@ -167,7 +167,6 @@ def _map_to_pixel(self, point: Tuple[float, float]) -> Tuple[int, int]:
Returns:
Tuple[int, int]: (x, y) tuple in pixel coordinates.
"""
pass

@abstractmethod
def _pixel_to_map(self, point: Tuple[float, float]) -> Tuple[float, float]:
@@ -180,4 +179,3 @@ def _pixel_to_map(self, point: Tuple[float, float]) -> Tuple[float, float]:
Returns:
Tuple[float, float]: (x, y) tuple in map coordinates (eg. lon/lat).
"""
pass
4 changes: 0 additions & 4 deletions rastervision_core/rastervision/core/data/label/labels.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ def __add__(self, other: 'Labels'):

Returns a concatenation of this and the other labels.
"""
pass

@abstractmethod
def filter_by_aoi(self, aoi_polygons: List['Polygon']) -> 'Labels':
@@ -31,7 +30,6 @@ def filter_by_aoi(self, aoi_polygons: List['Polygon']) -> 'Labels':
aoi_polygons: List of AOI polygons to filter by, in pixel
coordinates.
"""
pass

@abstractmethod
def __eq__(self, other: 'Labels'):
@@ -49,7 +47,6 @@ def make_empty(cls) -> 'Labels':
Labels: An object of the Label subclass on which this method is
called.
"""
pass

@classmethod
def from_predictions(cls, windows: Iterable['Box'],
@@ -80,4 +77,3 @@ def from_predictions(cls, windows: Iterable['Box'],
@abstractmethod
def save(self, uri: str) -> None:
"""Save to file."""
pass
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ def __init__(self, extent: Box, num_classes: int, dtype: np.dtype):
def __add__(self, other: 'SemanticSegmentationLabels'
) -> 'SemanticSegmentationLabels':
"""Merge self with other labels."""
pass

def __setitem__(self, window: Box, values: np.ndarray) -> None:
"""Set labels for the given window."""
@@ -44,17 +43,14 @@ def __setitem__(self, window: Box, values: np.ndarray) -> None:
@abstractmethod
def __delitem__(self, window: Box) -> None:
"""Delete labels for the given window."""
pass

@abstractmethod
def __getitem__(self, window: Box) -> np.ndarray:
"""Get labels for the given window."""
pass

@abstractmethod
def add_window(self, window: Box, values: np.ndarray) -> List[Box]:
"""Set labels for the given window."""
pass

@abstractmethod
def get_label_arr(self, window: Box,
@@ -64,7 +60,6 @@ def get_label_arr(self, window: Box,
Note: The returned array is not guaranteed to be the same size as the
input window.
"""
pass

def get_windows(self, **kwargs) -> List[Box]:
"""Generate sliding windows over the local extent.
@@ -109,7 +104,6 @@ def mask_fill(self, window: Box, mask: np.ndarray,
"""Given a window and a binary mask, set all the pixels in the window
for which the mask is ON to the fill_value.
"""
pass

def _filter_window_by_aoi(self, window: Box, aoi_polygons: List['Polygon'],
null_class_id: int) -> None:
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import TYPE_CHECKING, Any, Optional
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod

from rastervision.core.box import Box
from rastervision.core.data.utils import parse_array_slices_2d
@@ -28,21 +28,21 @@ def get_labels(self, window: Optional['Box'] = None) -> 'Labels':
Labels overlapping with window. If window is None, returns all
labels.
"""
pass

@property
def extent(self) -> 'Box':
"""Extent of the ``LabelSource``."""
return self.bbox.extent

@abstractproperty
@property
@abstractmethod
def bbox(self) -> 'Box':
"""Bounding box applied to the source."""
pass

@abstractproperty
@property
@abstractmethod
def crs_transformer(self) -> 'CRSTransformer':
pass
"""Associated :class:`.CRSTransformer`."""

@abstractmethod
def set_bbox(self, extent: 'Box') -> None:
@@ -53,7 +53,6 @@ def set_bbox(self, extent: 'Box') -> None:
Args:
extent (Box): User-specified extent in pixel coordinates.
"""
pass

def __getitem__(self, key: Any) -> Any:
if isinstance(key, Box):
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import TYPE_CHECKING, Optional
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod

if TYPE_CHECKING:
from rastervision.core.box import Box
@@ -17,20 +17,20 @@ def save(self, labels):
labels - Labels to be saved, the type of which will be dependent on the type
of pipeline.
"""
pass

@abstractmethod
def get_labels(self):
"""Loads Labels from this label store."""
pass

@abstractproperty
@property
@abstractmethod
def bbox(self) -> Optional['Box']:
pass
"""Bounding box applied to the source."""

@abstractproperty
@property
@abstractmethod
def crs_transformer(self) -> 'CRSTransformer':
pass
"""Associated :class:`.CRSTransformer`."""

@abstractmethod
def set_bbox(self, extent: 'Box') -> None:
@@ -41,4 +41,3 @@ def set_bbox(self, extent: 'Box') -> None:
Args:
extent (Box): User-specified extent in pixel coordinates.
"""
pass
Original file line number Diff line number Diff line change
@@ -250,7 +250,7 @@ def save(self,
self.write_smooth_raster_output(out_profile, scores_path,
hits_path, labels)

if self.vector_outputs is not None:
if self.vector_outputs:
vector_output_dir = get_local_path(self.vector_output_uri,
self.tmp_dir)
self.write_vector_outputs(labels, vector_output_dir)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import TYPE_CHECKING, Any, List, Optional, Tuple
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod

import numpy as np
from skimage.transform import resize
@@ -65,10 +65,10 @@ def shape(self) -> Tuple[int, int, int]:
H, W = self.bbox.size
return H, W, self.num_channels

@abstractproperty
@property
@abstractmethod
def dtype(self) -> 'np.dtype':
"""``numpy.dtype`` of the chips read from this source."""
pass

@property
def bbox(self) -> 'Box':
@@ -80,10 +80,10 @@ def extent(self) -> 'Box':
"""Extent of the ``RasterSource``."""
return self.bbox.extent

@abstractproperty
@property
@abstractmethod
def crs_transformer(self) -> 'CRSTransformer':
"""Associated :class:`.CRSTransformer`."""
pass

def set_bbox(self, bbox: 'Box') -> None:
"""Set self.bbox to the given value.
@@ -109,7 +109,6 @@ def _get_chip(self,
Returns:
[height, width, channels] numpy array
"""
pass

def __getitem__(self, key: Any) -> 'np.ndarray':
if isinstance(key, Box):
Original file line number Diff line number Diff line change
@@ -23,4 +23,3 @@ def transform(self, chip: 'np.ndarray',
Returns:
(np.ndarray): Array of shape (..., H, W, C)
"""
pass
Original file line number Diff line number Diff line change
@@ -104,7 +104,6 @@ def get_geoms(self,
@abstractmethod
def _get_geojson(self) -> dict:
"""Return raw GeoJSON."""
pass

def get_dataframe(self,
window: Optional[Box] = None,
Original file line number Diff line number Diff line change
@@ -38,4 +38,3 @@ def transform(self,
Returns:
dict: Transformed GeoJSON.
"""
pass
Original file line number Diff line number Diff line change
@@ -151,4 +151,3 @@ def compute(self, ground_truth_labels, prediction_labels):
ground_truth_labels: Ground Truth labels to evaluate against.
prediction_labels: The predicted labels to evaluate.
"""
pass
Original file line number Diff line number Diff line change
@@ -5,5 +5,3 @@
@register_config('classification_evaluator')
class ClassificationEvaluatorConfig(EvaluatorConfig):
"""Configure a :class:`.ClassificationEvaluator`."""

pass
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ def merge(self, other):
This is used to average metrics over scenes. Merges by taking a
weighted average (by gt_count) of the metrics.
"""
pass

@abstractmethod
def to_json(self) -> dict:
3 changes: 0 additions & 3 deletions rastervision_core/rastervision/core/evaluation/evaluator.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ def process(self, scenes: Iterable['Scene']) -> None:
Args:
scenes (Iterable[Scene]): Scenes to evaluate.
"""
pass

@abstractmethod
def evaluate_scene(self, scene: 'Scene') -> Any:
@@ -30,7 +29,6 @@ def evaluate_scene(self, scene: 'Scene') -> Any:
Returns:
ClassificationEvaluation: The evaluation.
"""
pass

@abstractmethod
def evaluate_predictions(self, ground_truth: 'Labels',
@@ -44,4 +42,3 @@ def evaluate_predictions(self, ground_truth: 'Labels',
Returns:
Any: The evaluation.
"""
pass
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import logging

import numpy as np
from numpy.random import random_sample

from rastervision.core.box import Box
from rastervision.core.rv_pipeline.rv_pipeline import RVPipeline
@@ -80,7 +81,7 @@ def should_use_window(window: Box) -> bool:
window, co.target_count_threshold, co.target_class_ids)
if is_positive:
return True
keep_negative = np.random.sample() < co.negative_survival_prob
keep_negative = random_sample() < co.negative_survival_prob
return keep_negative

if co.window_method == SemanticSegmentationWindowMethod.sliding:
4 changes: 0 additions & 4 deletions rastervision_pipeline/rastervision/pipeline/config.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@

class ConfigError(ValueError):
"""Exception raised for invalid configuration."""
pass


class Config(BaseModel):
@@ -50,23 +49,20 @@ def update(self, *args, **kwargs):
example, setting default values as a function of the values of other
fields. The arguments to this method will vary depending on the type of Config.
"""
pass

def build(self):
"""Build an instance of the corresponding type of object using this config.

For example, BackendConfig will build a Backend object. The arguments to this
method will vary depending on the type of Config.
"""
pass

def validate_config(self):
"""Validate fields that should be checked after update is called.

This is to complement the builtin validation that Pydantic performs at the time
of object construction.
"""
pass

def revalidate(self):
"""Re-validate an instantiated Config.
Loading