Skip to content

Commit

Permalink
Merge pull request #3 from DARPA-CRITICALMAAS/cmaas_utils
Browse files Browse the repository at this point in the history
Test suite for verification
  • Loading branch information
abodeuis authored Jun 6, 2024
2 parents 3bb8baf + 8dd4c38 commit c01c503
Show file tree
Hide file tree
Showing 25 changed files with 1,538 additions and 348 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# File extensions to ignore
*.pyc
*.log
*.old
*.DS_Store

# Directories to ignore
[Tt]estdata
[Dd]ata
[Oo]utput
[Rr]esults
[Ll]ogs
[Tt]ools
[Tt]mp
tests/logs
tests/uncommited_data
__pycache__
.pytest_cache
.vscode
.ruff_cache


# virtual environments
venv




23 changes: 20 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
numpy
pandas
rasterio
opencv-python
pandas
numpy
rich
pytest
matplotlib

--extra-index-url https://test.pypi.org/simple/
cmaas_utils>=0.1.9
#cmaas_utils packages
pydantic
git+https://github.com/DARPA-CRITICALMAAS/[email protected]+draft

# USGS grading metric requirements
joblib
tqdm
joblib
jupyter

# For development testing
pytest
pytest-cov
ruff
Empty file added src/__init__.py
Empty file.
205 changes: 137 additions & 68 deletions src/grading.py

Large diffs are not rendered by default.

118 changes: 0 additions & 118 deletions src/io.py

This file was deleted.

15 changes: 15 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
'reset' : "\x1b[0m",
}

class RichHandler(logging.Handler):
def __init__(self, progress):
super().__init__()
self.progress = progress

def emit(self, record):
self.progress.console.print(record.getMessage())

class ColoredConsoleFormatter(logging.Formatter):
LEVEL_COLORS = {
logging.DEBUG: ANSI_CODES['cyan'],
Expand Down Expand Up @@ -77,6 +85,13 @@ def start_logger(logger_name, filepath, log_level=logging.INFO, console_log_leve

return log

def swap_console_handler(log, handler):
orig_handler = log.handlers[1]
handler.setLevel(orig_handler.level)
handler.setFormatter(orig_handler.formatter)
log.handlers[1] = handler
return orig_handler

def boundingBox(array):
min_xy = [min(array, key=lambda x: (x[0]))[0], min(array, key=lambda x: (x[1]))[1]]
max_xy = [max(array, key=lambda x: (x[0]))[0], max(array, key=lambda x: (x[1]))[1]]
Expand Down
Empty file added tests/__init__.py
Empty file.
74 changes: 74 additions & 0 deletions tests/data/legends/mock_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"version": "5.0.1",
"flags": {},
"shapes": [
{
"label": "2_pt",
"points": [
[
79.0,
25.0
],
[
91.0,
34.0
]
],
"group_id": null,
"shape_type": "rectangle",
"flags": {}
},
{
"label": "3_pt",
"points": [
[
80.0,
36.0
],
[
89.0,
48.0
]
],
"group_id": null,
"shape_type": "rectangle",
"flags": {}
},
{
"label": "L_poly",
"points": [
[
75.0,
2.0
],
[
95.0,
12.0
]
],
"group_id": null,
"shape_type": "rectangle",
"flags": {}
},
{
"label": "TZ_poly",
"points": [
[
75.0,
14.0
],
[
95.0,
24.0
]
],
"group_id": null,
"shape_type": "rectangle",
"flags": {}
}
],
"imagePath": "mock_map.tif",
"imageData": null,
"imageHeight": 100,
"imageWidth": 100
}
Binary file added tests/data/map_images/mock_map.tif
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/data/mock_map_results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
,Map,Feature,F1 Score,Precision,Recall,IoU Score,USGS F1 Score,USGS Precision,USGS Recall,Mean matched distance Points,Matched Points,Unmatched Points,Missing Points
0,mock_map,mock_map_TZ_poly,0.9177215189873417,1.0,0.847953216374269,0.847953216374269,0.905625,1.0,0.8275271273557966,,,,
1,mock_map,mock_map_3_pt,0.848584707450122,0.7425116190188568,0.9900154920251424,,0.848584707450122,0.7425116190188568,0.9900154920251424,,3.0,1.0,0.0
2,mock_map,mock_map_L_poly,0.9778021375719375,0.9845474613686535,0.9711486118671747,0.95656836461126,0.957057127269893,0.9690656565656564,0.945342571208622,,,,
3,mock_map,mock_map_2_pt,0.99,0.99,0.99,,0.99,0.99,0.99,,1.0,0.0,0.0
Binary file added tests/data/pred_segmentations/mock_map_2_pt.tif
Binary file not shown.
Binary file added tests/data/pred_segmentations/mock_map_3_pt.tif
Binary file not shown.
Binary file added tests/data/pred_segmentations/mock_map_L_poly.tif
Binary file not shown.
Binary file added tests/data/pred_segmentations/mock_map_TZ_poly.tif
Binary file not shown.
Binary file added tests/data/true_segmentations/mock_map_2_pt.tif
Binary file not shown.
Binary file added tests/data/true_segmentations/mock_map_3_pt.tif
Binary file not shown.
Binary file added tests/data/true_segmentations/mock_map_L_poly.tif
Binary file not shown.
Binary file added tests/data/true_segmentations/mock_map_TZ_poly.tif
Binary file not shown.
Loading

0 comments on commit c01c503

Please sign in to comment.