This commit is contained in:
Matthew Deville 2026-04-23 14:28:19 +02:00
parent 3be68fcccf
commit ebdbe13f26
4 changed files with 24 additions and 17 deletions

View file

@ -70,7 +70,9 @@ struct Args {
#[show_image::main]
fn main() -> Result<(), Box<dyn Error>> {
fmt()
.with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")))
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
)
.with_writer(std::io::stderr)
.init();
@ -113,17 +115,17 @@ fn main() -> Result<(), Box<dyn Error>> {
if debug {
debug_mode(&img, &result_rgba)?;
}
if let Some(output_file) = output_file {
result_rgba.save(&output_file)?;
info!(path = %output_file.display(), "Wrote output image to file");
} else {
debug!("Writing output image to stdout (PNG)");
let mut buffer = Cursor::new(Vec::new());
result_rgba.write_to(&mut buffer, image::ImageFormat::Png)?;
let mut stdout = stdout().lock();
stdout.write_all(&buffer.into_inner())?;
if let Some(output_file) = output_file {
result_rgba.save(&output_file)?;
info!(path = %output_file.display(), "Wrote output image to file");
} else {
debug!("Writing output image to stdout (PNG)");
let mut buffer = Cursor::new(Vec::new());
result_rgba.write_to(&mut buffer, image::ImageFormat::Png)?;
let mut stdout = stdout().lock();
stdout.write_all(&buffer.into_inner())?;
}
}
}
Command::Batch {

View file

@ -68,7 +68,12 @@ fn download_file(url: &str, dest: &Path) -> Result<(), Box<dyn Error>> {
// Only emit every 10% to avoid log spam while still giving feedback.
if progress >= last_reported_pct + 10 {
last_reported_pct = progress - (progress % 10);
debug!(percent = last_reported_pct, downloaded, total = total_size, "Download progress");
debug!(
percent = last_reported_pct,
downloaded,
total = total_size,
"Download progress"
);
}
}
}

View file

@ -16,10 +16,7 @@ pub fn apply_mask(original: &DynamicImage, mask: &GrayImage) -> Result<RgbaImage
if mask_width != orig_width || mask_height != orig_height {
debug!(
mask_width,
mask_height,
orig_width,
orig_height,
"Resizing mask to match original image"
mask_height, orig_width, orig_height, "Resizing mask to match original image"
);
std::borrow::Cow::Owned(image::imageops::resize(
mask,

View file

@ -109,7 +109,10 @@ pub trait Session {
let preprocess_start = Instant::now();
let input = self.normalize(img)?;
debug!(elapsed_ms = preprocess_start.elapsed().as_millis() as u64, "Preprocessing complete");
debug!(
elapsed_ms = preprocess_start.elapsed().as_millis() as u64,
"Preprocessing complete"
);
let apply_sigmoid = self.apply_sigmoid();
let input_name = self.input_name().to_string();