Skip to content

Commit 93fe660

Browse files
authored
refactor: ♻️ remove unused array_to_tensor function from preprocessing module (#159)
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
1 parent 7d1c7c3 commit 93fe660

1 file changed

Lines changed: 0 additions & 27 deletions

File tree

src/preprocessing.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -544,33 +544,6 @@ fn image_to_tensor_f16(image: &RgbImage) -> Array4<f16> {
544544
tensor
545545
}
546546

547-
/// Convert a raw HWC u8 array to a normalized NCHW tensor.
548-
///
549-
/// # Arguments
550-
///
551-
/// * `image` - HWC array with shape (H, W, C) and u8 values.
552-
///
553-
/// # Returns
554-
///
555-
/// Array4 with shape (1, C, H, W) and values in [0, 1].
556-
#[must_use]
557-
pub fn array_to_tensor(image: &Array3<u8>) -> Array4<f32> {
558-
let shape = image.shape();
559-
let (height, width, channels) = (shape[0], shape[1], shape[2]);
560-
561-
let mut tensor = Array4::zeros((1, channels, height, width));
562-
563-
for y in 0..height {
564-
for x in 0..width {
565-
for c in 0..channels {
566-
tensor[[0, c, y, x]] = f32::from(image[[y, x, c]]) / 255.0;
567-
}
568-
}
569-
}
570-
571-
tensor
572-
}
573-
574547
/// Convert a `DynamicImage` to an HWC ndarray.
575548
///
576549
/// # Panics

0 commit comments

Comments
 (0)