Skip to content

Commit

Permalink
feat: implement ROI testing
Browse files Browse the repository at this point in the history
  • Loading branch information
swankaws committed May 28, 2024
1 parent 1a4f645 commit 50102a5
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.iml
*.DS_Store
*.tox
tox*.yaml
*.idea
*venv
*aggregated_results.txt
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
types: [file, python]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
args: ["--ignore=E203,W503,W605", "--max-line-length=125"]
Expand Down
3 changes: 3 additions & 0 deletions bin/process_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def main():
parser.add_argument("--region", help="AWS region OSML is deployed to.", type=str, default=default_region)
parser.add_argument("--account", help="AWS account OSML is deployed to.", type=str, default=default_account)
parser.add_argument("--endpoint_type", help="Type of model endpoint to test, sm or http.", type=str, default="sm")
parser.add_argument("--region-of-interest", help="Region of Interest for detections", type=str, default="")
args = parser.parse_args()

# standard test images deployed by CDK
Expand Down Expand Up @@ -91,6 +92,8 @@ def main():
os.environ["TILE_OVERLAP"] = args.tile_overlap
if args.feature_selection_options:
os.environ["FEATURE_SELECTION_OPTIONS"] = args.feature_selection_options
if args.region_of_interest:
os.environ["REGION_OF_INTEREST"] = args.region_of_interest

# determine whether we are running output validation testing
if args.skip_integ:
Expand Down
2 changes: 1 addition & 1 deletion src/aws/osml/process_image/test_process_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_process_image() -> None:
:return: None
"""
# Launch our image request and validate it completes
run_model_on_image(sqs_client(), OSMLConfig.TARGET_MODEL, kinesis_client())
run_model_on_image(sqs_client(), OSMLConfig.TARGET_MODEL, "SM_ENDPOINT", kinesis_client())
10 changes: 8 additions & 2 deletions src/aws/osml/utils/integ_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run_model_on_image(

# Get the current Kinesis shard iterator to listen to for results since our start time
shard_iter = get_kinesis_shard(kinesis_client)

logging.info(f"Image processing request: {image_processing_request}")
# Submit the image request to the SQS queue
queue_image_processing_job(sqs_client, image_processing_request)

Expand Down Expand Up @@ -183,8 +183,13 @@ def validate_features_match(
max_retries = 24
retry_interval = 5
done = False
use_roi = ""

if OSMLConfig.REGION_OF_INTEREST is not None:
use_roi = ".roi"

result_file = f"./src/data/{OSMLConfig.TARGET_MODEL}.{OSMLConfig.TARGET_IMAGE.split('/')[-1]}.geojson"
result_file = f"./src/data/{OSMLConfig.TARGET_MODEL}.{OSMLConfig.TARGET_IMAGE.split('/')[-1]}{use_roi}.geojson"
logging.info(f"Validating against {result_file}")
with open(result_file, "r") as geojson_file:
expected_features = geojson.load(geojson_file)["features"]

Expand Down Expand Up @@ -436,6 +441,7 @@ def build_image_processing_request(endpoint: str, endpoint_type: str, image_url:
"imageProcessorTileFormat": OSMLConfig.TILE_FORMAT,
"imageProcessorTileCompression": OSMLConfig.TILE_COMPRESSION,
"featureSelectionOptions": OSMLConfig.FEATURE_SELECTION_OPTIONS,
"regionOfInterest": OSMLConfig.REGION_OF_INTEREST,
}

return image_processing_request
Expand Down
1 change: 1 addition & 0 deletions src/aws/osml/utils/osml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class OSMLConfig:
"FEATURE_SELECTION_OPTIONS",
'{"algorithm": "NMS", "iou_threshold": 0.75, "skip_box_threshold": 0.0001, "sigma": .1}',
)
REGION_OF_INTEREST: str = os.environ.get("REGION_OF_INTEREST")


@dataclass
Expand Down
1 change: 1 addition & 0 deletions src/data/aircraft.large.tif.roi.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/data/aircraft.tile.tif.roi.geojson

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ envlist =

# Pre distribution checks for the package
twine
requires = tox-conda
requires =
tox-conda
setuptools
skip_missing_interpreters = False

[testenv]
Expand Down

0 comments on commit 50102a5

Please sign in to comment.