diff --git a/core/algorithm/el_algorithm_yolo_world.cpp b/core/algorithm/el_algorithm_yolo_world.cpp index 7916dd9c..67028c1a 100644 --- a/core/algorithm/el_algorithm_yolo_world.cpp +++ b/core/algorithm/el_algorithm_yolo_world.cpp @@ -244,12 +244,6 @@ inline void AlgorithmYOLOWorld::init() { _output_quant_params[i] = this->__p_engine->get_output_quant_param(i); } - _scaled_strides.reserve(_anchor_strides.size()); - for (const auto& anchor_stride : _anchor_strides) { - _scaled_strides.emplace_back(std::make_pair(static_cast(anchor_stride.stride) * _w_scale, - static_cast(anchor_stride.stride) * _h_scale)); - } - for (size_t i = 0; i < _outputs; ++i) { // assuimg all outputs has 3 dims and the first dim is 1 (actual validation is done in is_model_valid) auto dim_1 = _output_shapes[i].dims[1]; @@ -288,8 +282,20 @@ inline void AlgorithmYOLOWorld::init() { } el_err_code_t AlgorithmYOLOWorld::run(ImageType* input) { - _w_scale = static_cast(input->width) / static_cast(_input_img.width); - _h_scale = static_cast(input->height) / static_cast(_input_img.height); + auto w_scale = static_cast(input->width) / static_cast(_input_img.width); + auto h_scale = static_cast(input->height) / static_cast(_input_img.height); + + if (w_scale != _w_scale || h_scale != _h_scale) [[unlikely]] { + _w_scale = w_scale; + _h_scale = h_scale; + + _scaled_strides.resize(_anchor_strides.size()); + size_t i = 0; + for (const auto& anchor_stride : _anchor_strides) { + const auto s = static_cast(anchor_stride.stride); + _scaled_strides[i++] = std::make_pair(s * _w_scale, s * _h_scale); + } + } // TODO: image type conversion before underlying_run, because underlying_run doing a type erasure return underlying_run(input); diff --git a/porting/himax/we2/el_config_porting.h b/porting/himax/we2/el_config_porting.h index 3f4c9357..9802c1b8 100644 --- a/porting/himax/we2/el_config_porting.h +++ b/porting/himax/we2/el_config_porting.h @@ -44,7 +44,7 @@ #endif #endif -#define CONFIG_EL_DEBUG 0 // use 0 to make firmware generator happy +#define CONFIG_EL_DEBUG 1 // use 1 to make firmware generator happy #define CONFIG_EL_DEBUG_COLOR 0 #define CONFIG_EL_HAS_FREERTOS_SUPPORT 1 #define SSCMA_REPL_EXECUTOR_PRIO 2