rslearn.train.tasks.task¶
task ¶
Training tasks.
Task ¶
Represents an ML task like object detection or segmentation.
A task specifies how raster or vector data should be processed into inputs and targets that can be passed to models. It also specifies evaluation functions for computing metrics comparing targets/outputs.
Source code in rslearn/train/tasks/task.py
process_inputs ¶
process_inputs(raw_inputs: dict[str, RasterImage | list[Feature]], metadata: SampleMetadata, load_targets: bool = True) -> tuple[dict[str, Any], dict[str, Any]]
Processes the data into targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_inputs
|
dict[str, RasterImage | list[Feature]]
|
raster or vector data to process |
required |
metadata
|
SampleMetadata
|
metadata about the patch being read |
required |
load_targets
|
bool
|
whether to load the targets or only inputs |
True
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any]]
|
tuple (input_dict, target_dict) containing the processed inputs and targets that are compatible with both metrics and loss functions |
Source code in rslearn/train/tasks/task.py
process_output ¶
process_output(raw_output: Any, metadata: SampleMetadata) -> NDArray[Any] | list[Feature] | dict[str, Any]
Processes an output into raster or vector data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_output
|
Any
|
the output from prediction head. |
required |
metadata
|
SampleMetadata
|
metadata about the patch being read |
required |
Returns:
| Type | Description |
|---|---|
NDArray[Any] | list[Feature] | dict[str, Any]
|
raster data, vector data, or multi-task dictionary output. |
Source code in rslearn/train/tasks/task.py
visualize ¶
visualize(input_dict: dict[str, Any], target_dict: dict[str, Any] | None, output: Any) -> dict[str, NDArray[Any]]
Visualize the outputs and targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dict
|
dict[str, Any]
|
the input dict from process_inputs |
required |
target_dict
|
dict[str, Any] | None
|
the target dict from process_inputs |
required |
output
|
Any
|
the prediction |
required |
Returns:
| Type | Description |
|---|---|
dict[str, NDArray[Any]]
|
a dictionary mapping image name to visualization image |
Source code in rslearn/train/tasks/task.py
BasicTask ¶
Bases: Task
A task that provides some support for creating visualizations.
Source code in rslearn/train/tasks/task.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
visualize ¶
visualize(input_dict: dict[str, Any], target_dict: dict[str, Any] | None, output: Any) -> dict[str, NDArray[Any]]
Visualize the outputs and targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dict
|
dict[str, Any]
|
the input dict from process_inputs |
required |
target_dict
|
dict[str, Any] | None
|
the target dict from process_inputs |
required |
output
|
Any
|
the prediction |
required |
Returns:
| Type | Description |
|---|---|
dict[str, NDArray[Any]]
|
a dictionary mapping image name to visualization image |