Added entropy threshold as configurable option
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
parent
a8f58a6fc7
commit
d9edd94b99
|
@ -263,7 +263,8 @@ def _ssd_test(args: argparse.Namespace) -> None:
|
||||||
_init_eager_mode()
|
_init_eager_mode()
|
||||||
|
|
||||||
batch_size, image_size, learning_rate, \
|
batch_size, image_size, learning_rate, \
|
||||||
forward_passes_per_image, nr_classes, iou_threshold, dropout_rate, top_k, nr_trajectories, \
|
forward_passes_per_image, nr_classes, iou_threshold, dropout_rate, \
|
||||||
|
entropy_threshold, top_k, nr_trajectories, \
|
||||||
coco_path, output_path, weights_path, ground_truth_path = _ssd_test_get_config_values(args, conf.get_property)
|
coco_path, output_path, weights_path, ground_truth_path = _ssd_test_get_config_values(args, conf.get_property)
|
||||||
|
|
||||||
use_dropout = _ssd_is_dropout(args)
|
use_dropout = _ssd_is_dropout(args)
|
||||||
|
@ -304,6 +305,7 @@ def _ssd_test(args: argparse.Namespace) -> None:
|
||||||
image_size,
|
image_size,
|
||||||
batch_size,
|
batch_size,
|
||||||
forward_passes_per_image,
|
forward_passes_per_image,
|
||||||
|
entropy_threshold,
|
||||||
output_path,
|
output_path,
|
||||||
coco_path,
|
coco_path,
|
||||||
use_dropout,
|
use_dropout,
|
||||||
|
@ -500,7 +502,7 @@ def _ssd_train_get_config_values(config_get: Callable[[str], Union[str, float, i
|
||||||
|
|
||||||
def _ssd_test_get_config_values(args: argparse.Namespace,
|
def _ssd_test_get_config_values(args: argparse.Namespace,
|
||||||
config_get: Callable[[str], Union[str, float, int, bool]]
|
config_get: Callable[[str], Union[str, float, int, bool]]
|
||||||
) -> Tuple[int, int, float, int, int, float, float, int, int,
|
) -> Tuple[int, int, float, int, int, float, float, float, int, int,
|
||||||
str, str, str, str]:
|
str, str, str, str]:
|
||||||
|
|
||||||
batch_size = config_get("Parameters.batch_size")
|
batch_size = config_get("Parameters.batch_size")
|
||||||
|
@ -510,6 +512,7 @@ def _ssd_test_get_config_values(args: argparse.Namespace,
|
||||||
nr_classes = config_get("Parameters.nr_classes")
|
nr_classes = config_get("Parameters.nr_classes")
|
||||||
iou_threshold = config_get("Parameters.ssd_iou_threshold")
|
iou_threshold = config_get("Parameters.ssd_iou_threshold")
|
||||||
dropout_rate = config_get("Parameters.ssd_dropout_rate")
|
dropout_rate = config_get("Parameters.ssd_dropout_rate")
|
||||||
|
entropy_threshold = config_get("Parameters.ssd_entropy_threshold")
|
||||||
top_k = config_get("Parameters.ssd_top_k")
|
top_k = config_get("Parameters.ssd_top_k")
|
||||||
nr_trajectories = config_get("Parameters.nr_trajectories")
|
nr_trajectories = config_get("Parameters.nr_trajectories")
|
||||||
|
|
||||||
|
@ -529,6 +532,7 @@ def _ssd_test_get_config_values(args: argparse.Namespace,
|
||||||
nr_classes,
|
nr_classes,
|
||||||
iou_threshold,
|
iou_threshold,
|
||||||
dropout_rate,
|
dropout_rate,
|
||||||
|
entropy_threshold,
|
||||||
top_k,
|
top_k,
|
||||||
nr_trajectories,
|
nr_trajectories,
|
||||||
#
|
#
|
||||||
|
|
|
@ -59,6 +59,7 @@ _CONFIG_PROPS = {
|
||||||
"ssd_iou_threshold": (float, "0.45"),
|
"ssd_iou_threshold": (float, "0.45"),
|
||||||
"ssd_top_k": (int, "200"),
|
"ssd_top_k": (int, "200"),
|
||||||
"ssd_dropout_rate": (float, "0.5"),
|
"ssd_dropout_rate": (float, "0.5"),
|
||||||
|
"ssd_entropy_threshold": (float, "2.5"),
|
||||||
"nr_trajectories": (int, "-1")
|
"nr_trajectories": (int, "-1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,7 @@ def predict(generator: callable,
|
||||||
image_size: int,
|
image_size: int,
|
||||||
batch_size: int,
|
batch_size: int,
|
||||||
forward_passes_per_image: int,
|
forward_passes_per_image: int,
|
||||||
|
entropy_threshold: float,
|
||||||
output_path: str,
|
output_path: str,
|
||||||
coco_path: str,
|
coco_path: str,
|
||||||
use_dropout: bool,
|
use_dropout: bool,
|
||||||
|
@ -162,6 +163,7 @@ def predict(generator: callable,
|
||||||
batch_size: number of items in every batch
|
batch_size: number of items in every batch
|
||||||
forward_passes_per_image: specifies number of forward passes per image
|
forward_passes_per_image: specifies number of forward passes per image
|
||||||
used by DropoutSSD
|
used by DropoutSSD
|
||||||
|
entropy_threshold: specifies the threshold for the entropy
|
||||||
output_path: the path in which the results should be saved
|
output_path: the path in which the results should be saved
|
||||||
coco_path: the path to the COCO data set
|
coco_path: the path to the COCO data set
|
||||||
use_dropout: if True, multiple forward passes and observations will be used
|
use_dropout: if True, multiple forward passes and observations will be used
|
||||||
|
@ -185,7 +187,8 @@ def predict(generator: callable,
|
||||||
decode_func=functools.partial(
|
decode_func=functools.partial(
|
||||||
_decode_predictions,
|
_decode_predictions,
|
||||||
decode_func=ssd_output_decoder.decode_detections_fast,
|
decode_func=ssd_output_decoder.decode_detections_fast,
|
||||||
image_size=image_size
|
image_size=image_size,
|
||||||
|
entropy_threshold=entropy_threshold
|
||||||
),
|
),
|
||||||
transform_func=functools.partial(
|
transform_func=functools.partial(
|
||||||
_transform_predictions,
|
_transform_predictions,
|
||||||
|
@ -319,12 +322,14 @@ def _predict_vanilla_step(inputs: np.ndarray, model: tf.keras.models.Model) -> n
|
||||||
|
|
||||||
def _decode_predictions(predictions: np.ndarray,
|
def _decode_predictions(predictions: np.ndarray,
|
||||||
decode_func: callable,
|
decode_func: callable,
|
||||||
image_size: int) -> np.ndarray:
|
image_size: int,
|
||||||
|
entropy_threshold: float) -> np.ndarray:
|
||||||
return decode_func(
|
return decode_func(
|
||||||
y_pred=predictions,
|
y_pred=predictions,
|
||||||
img_width=image_size,
|
img_width=image_size,
|
||||||
img_height=image_size,
|
img_height=image_size,
|
||||||
input_coords="corners"
|
input_coords="corners",
|
||||||
|
entropy_threshold=entropy_threshold
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue