mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 13:34:13 +03:00
fix formatting
This commit is contained in:
parent
6ee36d6ffc
commit
f5f84a3c53
@ -114,9 +114,7 @@ class EdgeTpuTfl(DetectionApi):
|
|||||||
# to differentiate from (not used) max score tensor
|
# to differentiate from (not used) max score tensor
|
||||||
output_classes_index = i
|
output_classes_index = i
|
||||||
if output_boxes_index is None or output_classes_index is None:
|
if output_boxes_index is None or output_classes_index is None:
|
||||||
logger.warning(
|
logger.warning("Unrecognized model output, unexpected tensor shapes.")
|
||||||
"Unrecognized model output, unexpected tensor shapes."
|
|
||||||
)
|
|
||||||
output_classes_index = (
|
output_classes_index = (
|
||||||
0
|
0
|
||||||
if (output_boxes_index is None or output_classes_index == 1)
|
if (output_boxes_index is None or output_classes_index == 1)
|
||||||
@ -127,17 +125,13 @@ class EdgeTpuTfl(DetectionApi):
|
|||||||
scores_details = self.tensor_output_details[output_classes_index]
|
scores_details = self.tensor_output_details[output_classes_index]
|
||||||
classes_count = scores_details["shape"][2]
|
classes_count = scores_details["shape"][2]
|
||||||
self.scores_tensor_index = scores_details["index"]
|
self.scores_tensor_index = scores_details["index"]
|
||||||
self.scores_scale, self.scores_zero_point = scores_details[
|
self.scores_scale, self.scores_zero_point = scores_details["quantization"]
|
||||||
"quantization"
|
|
||||||
]
|
|
||||||
# calculate the quantized version of the min_score
|
# calculate the quantized version of the min_score
|
||||||
self.min_score_quantized = int(
|
self.min_score_quantized = int(
|
||||||
(self.min_logit_value / self.scores_scale) + self.scores_zero_point
|
(self.min_logit_value / self.scores_scale) + self.scores_zero_point
|
||||||
)
|
)
|
||||||
self.logit_shift_to_positive_values = (
|
self.logit_shift_to_positive_values = (
|
||||||
max(
|
max(0, math.ceil((128 + self.scores_zero_point) * self.scores_scale))
|
||||||
0, math.ceil((128 + self.scores_zero_point) * self.scores_scale)
|
|
||||||
)
|
|
||||||
+ 1
|
+ 1
|
||||||
) # round up
|
) # round up
|
||||||
|
|
||||||
@ -245,9 +239,7 @@ class EdgeTpuTfl(DetectionApi):
|
|||||||
scores_output_quantized = self.interpreter.get_tensor(
|
scores_output_quantized = self.interpreter.get_tensor(
|
||||||
self.scores_tensor_index
|
self.scores_tensor_index
|
||||||
)[0] # (2100, NC)
|
)[0] # (2100, NC)
|
||||||
max_scores_quantized = np.max(
|
max_scores_quantized = np.max(scores_output_quantized, axis=1) # (2100,)
|
||||||
scores_output_quantized, axis=1
|
|
||||||
) # (2100,)
|
|
||||||
mask = max_scores_quantized >= self.min_score_quantized # (2100,)
|
mask = max_scores_quantized >= self.min_score_quantized # (2100,)
|
||||||
|
|
||||||
if not np.any(mask):
|
if not np.any(mask):
|
||||||
@ -277,9 +269,7 @@ class EdgeTpuTfl(DetectionApi):
|
|||||||
# Softmax over the 16 bins
|
# Softmax over the 16 bins
|
||||||
dfl_max = np.max(dfl_distributions, axis=2, keepdims=True)
|
dfl_max = np.max(dfl_distributions, axis=2, keepdims=True)
|
||||||
dfl_exp = np.exp(dfl_distributions - dfl_max)
|
dfl_exp = np.exp(dfl_distributions - dfl_max)
|
||||||
dfl_probs = dfl_exp / np.sum(
|
dfl_probs = dfl_exp / np.sum(dfl_exp, axis=2, keepdims=True) # (N, 4, 16)
|
||||||
dfl_exp, axis=2, keepdims=True
|
|
||||||
) # (N, 4, 16)
|
|
||||||
|
|
||||||
# Weighted sum: (N, 4, 16) * (16,) -> (N, 4)
|
# Weighted sum: (N, 4, 16) * (16,) -> (N, 4)
|
||||||
distances = np.einsum("pcr,r->pc", dfl_probs, self.project)
|
distances = np.einsum("pcr,r->pc", dfl_probs, self.project)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user