mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 23:55:38 +00:00
Fix rgba bug when resizing (#26)
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "usls"
|
name = "usls"
|
||||||
version = "0.0.5"
|
version = "0.0.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A Rust library integrated with ONNXRuntime, providing a collection of ML models."
|
description = "A Rust library integrated with ONNXRuntime, providing a collection of ML models."
|
||||||
repository = "https://github.com/jamjamjon/usls"
|
repository = "https://github.com/jamjamjon/usls"
|
||||||
@ -38,7 +38,7 @@ walkdir = { version = "2.5.0" }
|
|||||||
tokenizers = { version = "0.15.2" }
|
tokenizers = { version = "0.15.2" }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
indicatif = "0.17.8"
|
indicatif = "0.17.8"
|
||||||
image = "0.25.1"
|
image = "0.25.2"
|
||||||
imageproc = { version = "0.24" }
|
imageproc = { version = "0.24" }
|
||||||
ab_glyph = "0.2.23"
|
ab_glyph = "0.2.23"
|
||||||
geo = "0.28.0"
|
geo = "0.28.0"
|
||||||
|
@ -92,7 +92,7 @@ impl DataLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_read<P: AsRef<Path>>(path: P) -> Result<DynamicImage> {
|
pub fn try_read<P: AsRef<Path>>(path: P) -> Result<DynamicImage> {
|
||||||
let img = image::io::Reader::open(&path)
|
let img = image::ImageReader::open(&path)
|
||||||
.map_err(|_| anyhow!("Failed to open image at {:?}", path.as_ref()))?
|
.map_err(|_| anyhow!("Failed to open image at {:?}", path.as_ref()))?
|
||||||
.decode()
|
.decode()
|
||||||
.map_err(|_| anyhow!("Failed to decode image at {:?}", path.as_ref()))?
|
.map_err(|_| anyhow!("Failed to decode image at {:?}", path.as_ref()))?
|
||||||
|
@ -223,7 +223,7 @@ impl Ops<'_> {
|
|||||||
let (mut resizer, options) = Self::build_resizer_filter(filter)?;
|
let (mut resizer, options) = Self::build_resizer_filter(filter)?;
|
||||||
for (idx, x) in xs.iter().enumerate() {
|
for (idx, x) in xs.iter().enumerate() {
|
||||||
let buffer = if x.dimensions() == (width, height) {
|
let buffer = if x.dimensions() == (width, height) {
|
||||||
x.to_rgba8().into_raw()
|
x.to_rgb8().into_raw()
|
||||||
} else {
|
} else {
|
||||||
let mut dst_image = Image::new(width, height, PixelType::U8x3);
|
let mut dst_image = Image::new(width, height, PixelType::U8x3);
|
||||||
resizer.resize(x, &mut dst_image, &options)?;
|
resizer.resize(x, &mut dst_image, &options)?;
|
||||||
@ -251,7 +251,7 @@ impl Ops<'_> {
|
|||||||
for (idx, x) in xs.iter().enumerate() {
|
for (idx, x) in xs.iter().enumerate() {
|
||||||
let (w0, h0) = x.dimensions();
|
let (w0, h0) = x.dimensions();
|
||||||
let buffer = if w0 == width && h0 == height {
|
let buffer = if w0 == width && h0 == height {
|
||||||
x.to_rgba8().into_raw()
|
x.to_rgb8().into_raw()
|
||||||
} else {
|
} else {
|
||||||
let (w, h) = match resize_by {
|
let (w, h) = match resize_by {
|
||||||
"auto" => {
|
"auto" => {
|
||||||
|
Reference in New Issue
Block a user