diff --git a/scripts/examples/03-Machine-Learning/00-TensorFlow/tf_object_detection.py b/scripts/examples/03-Machine-Learning/00-TensorFlow/tf_object_detection.py index c3a62bf19..fc5f86e2f 100644 --- a/scripts/examples/03-Machine-Learning/00-TensorFlow/tf_object_detection.py +++ b/scripts/examples/03-Machine-Learning/00-TensorFlow/tf_object_detection.py @@ -50,7 +50,7 @@ def fomo_post_process(model, inputs, outputs): n, oh, ow, oc = model.output_shape[0] nms = NMS(ow, oh, inputs[0].roi) for i in range(oc): - img = image.Image(outputs[0], shape=(oh, ow, 1), strides=(i, oc), scale=(255, 0)) + img = image.Image(outputs[0], shape=(oh, ow, 1), strides=(i, oc), scale=(0, 1)) blobs = img.find_blobs( threshold_list, x_stride=1, area_threshold=1, pixels_threshold=1 ) diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index fc9ef0caf..6d3441ab3 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -6379,8 +6379,8 @@ mp_obj_t py_image_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw mp_obj_t *scale; mp_obj_get_array_fixed_n(args[ARG_scale].u_obj, 2, &scale); - float fscale = mp_obj_get_float(scale[0]); - float fadd = mp_obj_get_float(scale[1]); + float fscale = 255.0f / (mp_obj_get_float(scale[1]) - mp_obj_get_float(scale[0])); + float fadd = -mp_obj_get_float(scale[0]) * fscale; if (args[ARG_copy_to_fb].u_bool) { py_helper_set_to_framebuffer(&image);