From bdc2bed93cc9d44f44e6712b5dc83d4b36b83fee Mon Sep 17 00:00:00 2001 From: mosure Date: Fri, 8 Mar 2024 19:40:25 -0600 Subject: [PATCH] fix: lint --- src/models/modnet.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/models/modnet.rs b/src/models/modnet.rs index f8b4d77..4900494 100644 --- a/src/models/modnet.rs +++ b/src/models/modnet.rs @@ -20,13 +20,13 @@ pub fn modnet_output_to_luma_image( let height = shape[2]; let tensor_data = ArrayView4::from_shape((1, 1, height, width), data.as_slice().unwrap()) - .expect("Failed to create ArrayView4 from shape and data"); + .expect("failed to create ArrayView4 from shape and data"); let mut imgbuf = ImageBuffer::, Vec>::new(width as u32, height as u32); for y in 0..height { for x in 0..width { - let pixel_value = tensor_data[(0, 0, y as usize, x as usize)]; + let pixel_value = tensor_data[(0, 0, y, x)]; let pixel_value = (pixel_value.clamp(0.0, 1.0) * 255.0) as u8; imgbuf.put_pixel(x as u32, y as u32, Luma([pixel_value])); } @@ -104,9 +104,7 @@ fn image_to_ndarray(img: &RgbImage) -> Array4 { .expect("failed to create ndarray from image raw data"); // rearrange the dimensions from [height, width, channels] to [1, channels, height, width] - let arr = arr.permuted_axes([2, 0, 1]).insert_axis(Axis(0)); - - arr + arr.permuted_axes([2, 0, 1]).insert_axis(Axis(0)) } fn resize_image(image: &DynamicImage, x_scale: f32, y_scale: f32) -> RgbImage {