Converts an encoded location to an actual box placement with the provided box priors.
| 212 | // Converts an encoded location to an actual box placement with the provided |
| 213 | // box priors. |
| 214 | void DecodeLocation(const float* encoded_location, const float* box_priors, |
| 215 | float* decoded_location) { |
| 216 | bool non_zero = false; |
| 217 | for (int i = 0; i < 4; ++i) { |
| 218 | const float curr_encoding = encoded_location[i]; |
| 219 | non_zero = non_zero || curr_encoding != 0.0f; |
| 220 | |
| 221 | const float mean = box_priors[i * 2]; |
| 222 | const float std_dev = box_priors[i * 2 + 1]; |
| 223 | |
| 224 | float currentLocation = curr_encoding * std_dev + mean; |
| 225 | |
| 226 | currentLocation = std::max(currentLocation, 0.0f); |
| 227 | currentLocation = std::min(currentLocation, 1.0f); |
| 228 | decoded_location[i] = currentLocation; |
| 229 | } |
| 230 | |
| 231 | if (!non_zero) { |
| 232 | LOG(WARNING) << "No non-zero encodings; check log for inference errors."; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | float DecodeScore(float encoded_score) { |
| 237 | return 1 / (1 + std::exp(-encoded_score)); |
no test coverage detected