fmt
This commit is contained in:
parent
3be68fcccf
commit
ebdbe13f26
4 changed files with 24 additions and 17 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -70,7 +70,9 @@ struct Args {
|
||||||
#[show_image::main]
|
#[show_image::main]
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
fmt()
|
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)
|
.with_writer(std::io::stderr)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
|
|
@ -113,17 +115,17 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
debug_mode(&img, &result_rgba)?;
|
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 {
|
} else {
|
||||||
debug!("Writing output image to stdout (PNG)");
|
if let Some(output_file) = output_file {
|
||||||
let mut buffer = Cursor::new(Vec::new());
|
result_rgba.save(&output_file)?;
|
||||||
result_rgba.write_to(&mut buffer, image::ImageFormat::Png)?;
|
info!(path = %output_file.display(), "Wrote output image to file");
|
||||||
let mut stdout = stdout().lock();
|
} else {
|
||||||
stdout.write_all(&buffer.into_inner())?;
|
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 {
|
Command::Batch {
|
||||||
|
|
|
||||||
|
|
@ -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.
|
// Only emit every 10% to avoid log spam while still giving feedback.
|
||||||
if progress >= last_reported_pct + 10 {
|
if progress >= last_reported_pct + 10 {
|
||||||
last_reported_pct = progress - (progress % 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"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,7 @@ pub fn apply_mask(original: &DynamicImage, mask: &GrayImage) -> Result<RgbaImage
|
||||||
if mask_width != orig_width || mask_height != orig_height {
|
if mask_width != orig_width || mask_height != orig_height {
|
||||||
debug!(
|
debug!(
|
||||||
mask_width,
|
mask_width,
|
||||||
mask_height,
|
mask_height, orig_width, orig_height, "Resizing mask to match original image"
|
||||||
orig_width,
|
|
||||||
orig_height,
|
|
||||||
"Resizing mask to match original image"
|
|
||||||
);
|
);
|
||||||
std::borrow::Cow::Owned(image::imageops::resize(
|
std::borrow::Cow::Owned(image::imageops::resize(
|
||||||
mask,
|
mask,
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,10 @@ pub trait Session {
|
||||||
|
|
||||||
let preprocess_start = Instant::now();
|
let preprocess_start = Instant::now();
|
||||||
let input = self.normalize(img)?;
|
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 apply_sigmoid = self.apply_sigmoid();
|
||||||
|
|
||||||
let input_name = self.input_name().to_string();
|
let input_name = self.input_name().to_string();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue