Allow zero detection images to pass through the pipeline implicitly
Browse files- scoutbot/__init__.py +1 -1
- scoutbot/agg/__init__.py +5 -0
- scoutbot/loc/__init__.py +11 -1
- scoutbot/wic/__init__.py +5 -0
scoutbot/__init__.py
CHANGED
|
@@ -56,7 +56,7 @@ log = utils.init_logging()
|
|
| 56 |
|
| 57 |
from scoutbot import agg, loc, tile, wic # NOQA
|
| 58 |
|
| 59 |
-
VERSION = '0.1.
|
| 60 |
version = VERSION
|
| 61 |
__version__ = VERSION
|
| 62 |
|
|
|
|
| 56 |
|
| 57 |
from scoutbot import agg, loc, tile, wic # NOQA
|
| 58 |
|
| 59 |
+
VERSION = '0.1.11'
|
| 60 |
version = VERSION
|
| 61 |
__version__ = VERSION
|
| 62 |
|
scoutbot/agg/__init__.py
CHANGED
|
@@ -172,8 +172,13 @@ def compute(
|
|
| 172 |
"""
|
| 173 |
from scoutbot.agg.py_cpu_nms import py_cpu_nms
|
| 174 |
|
|
|
|
|
|
|
| 175 |
log.info(f'Aggregating {len(tile_grids)} tiles onto {img_shape} canvas')
|
| 176 |
|
|
|
|
|
|
|
|
|
|
| 177 |
# Demosaic tile detection results and aggregate across the image
|
| 178 |
detects = demosaic(img_shape, tile_grids, loc_outputs)
|
| 179 |
|
|
|
|
| 172 |
"""
|
| 173 |
from scoutbot.agg.py_cpu_nms import py_cpu_nms
|
| 174 |
|
| 175 |
+
assert len(tile_grids) == len(loc_outputs)
|
| 176 |
+
|
| 177 |
log.info(f'Aggregating {len(tile_grids)} tiles onto {img_shape} canvas')
|
| 178 |
|
| 179 |
+
if len(tile_grids) == 0:
|
| 180 |
+
return []
|
| 181 |
+
|
| 182 |
# Demosaic tile detection results and aggregate across the image
|
| 183 |
detects = demosaic(img_shape, tile_grids, loc_outputs)
|
| 184 |
|
scoutbot/loc/__init__.py
CHANGED
|
@@ -100,6 +100,8 @@ def pre(inputs):
|
|
| 100 |
- list of transformed image data.
|
| 101 |
- list of each tile's original size.
|
| 102 |
"""
|
|
|
|
|
|
|
| 103 |
transform = torchvision.transforms.ToTensor()
|
| 104 |
|
| 105 |
data = []
|
|
@@ -132,7 +134,10 @@ def predict(data, fill=True):
|
|
| 132 |
"""
|
| 133 |
onnx_model = fetch()
|
| 134 |
|
| 135 |
-
log.info(f'Running
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
ort_session = ort.InferenceSession(
|
| 138 |
onnx_model, providers=['CUDAExecutionProvider', 'CPUExecutionProvider']
|
|
@@ -190,6 +195,11 @@ def post(preds, sizes, loc_thresh=LOC_THRESH, nms_thresh=NMS_THRESH):
|
|
| 190 |
Returns:
|
| 191 |
list ( list ( dict ) ): nested list of Localizer predictions
|
| 192 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
postprocess = Compose(
|
| 194 |
[
|
| 195 |
GetBoundingBoxes(NUM_CLASSES, ANCHORS, loc_thresh),
|
|
|
|
| 100 |
- list of transformed image data.
|
| 101 |
- list of each tile's original size.
|
| 102 |
"""
|
| 103 |
+
assert len(inputs) > 0
|
| 104 |
+
|
| 105 |
transform = torchvision.transforms.ToTensor()
|
| 106 |
|
| 107 |
data = []
|
|
|
|
| 134 |
"""
|
| 135 |
onnx_model = fetch()
|
| 136 |
|
| 137 |
+
log.info(f'Running LOC inference on {len(data)} tiles')
|
| 138 |
+
|
| 139 |
+
if len(data) == 0:
|
| 140 |
+
return []
|
| 141 |
|
| 142 |
ort_session = ort.InferenceSession(
|
| 143 |
onnx_model, providers=['CUDAExecutionProvider', 'CPUExecutionProvider']
|
|
|
|
| 195 |
Returns:
|
| 196 |
list ( list ( dict ) ): nested list of Localizer predictions
|
| 197 |
"""
|
| 198 |
+
assert len(preds) == len(sizes)
|
| 199 |
+
|
| 200 |
+
if len(preds) == 0:
|
| 201 |
+
return []
|
| 202 |
+
|
| 203 |
postprocess = Compose(
|
| 204 |
[
|
| 205 |
GetBoundingBoxes(NUM_CLASSES, ANCHORS, loc_thresh),
|
scoutbot/wic/__init__.py
CHANGED
|
@@ -80,6 +80,8 @@ def pre(inputs):
|
|
| 80 |
Returns:
|
| 81 |
list ( list ( list ( list ( float ) ) ) ): list of transformed image data
|
| 82 |
"""
|
|
|
|
|
|
|
| 83 |
transform = _init_transforms()
|
| 84 |
dataset = ImageFilePathList(inputs, transform=transform)
|
| 85 |
dataloader = torch.utils.data.DataLoader(
|
|
@@ -109,6 +111,9 @@ def predict(data, fill=False):
|
|
| 109 |
|
| 110 |
log.info(f'Running WIC inference on {len(data)} tiles')
|
| 111 |
|
|
|
|
|
|
|
|
|
|
| 112 |
ort_session = ort.InferenceSession(
|
| 113 |
onnx_model, providers=['CUDAExecutionProvider', 'CPUExecutionProvider']
|
| 114 |
)
|
|
|
|
| 80 |
Returns:
|
| 81 |
list ( list ( list ( list ( float ) ) ) ): list of transformed image data
|
| 82 |
"""
|
| 83 |
+
assert len(inputs) > 0
|
| 84 |
+
|
| 85 |
transform = _init_transforms()
|
| 86 |
dataset = ImageFilePathList(inputs, transform=transform)
|
| 87 |
dataloader = torch.utils.data.DataLoader(
|
|
|
|
| 111 |
|
| 112 |
log.info(f'Running WIC inference on {len(data)} tiles')
|
| 113 |
|
| 114 |
+
if len(data) == 0:
|
| 115 |
+
return []
|
| 116 |
+
|
| 117 |
ort_session = ort.InferenceSession(
|
| 118 |
onnx_model, providers=['CUDAExecutionProvider', 'CPUExecutionProvider']
|
| 119 |
)
|