Update the image crate + use the re-exported version. (#1893)
* Update the image crate + use the re-exported version. * Update to using ab_glyph.
This commit is contained in:
parent
0fddec762e
commit
18036c6ccb
|
@ -28,6 +28,7 @@ categories = ["science"]
|
|||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
ab_glyph = "0.2.23"
|
||||
accelerate-src = { version = "0.3.2" }
|
||||
anyhow = { version = "1", features = ["backtrace"] }
|
||||
byteorder = "1.4.3"
|
||||
|
@ -46,8 +47,8 @@ fancy-regex = "0.13.0"
|
|||
gemm = { version = "0.17.0", features = ["wasm-simd128-enable"] }
|
||||
hf-hub = "0.3.0"
|
||||
half = { version = "2.3.1", features = ["num-traits", "use-intrinsics", "rand_distr"] }
|
||||
image = { version = "0.24.7", default-features = false, features = ["jpeg", "png"] }
|
||||
imageproc = { version = "0.23.0", default-features = false }
|
||||
image = { version = "0.25.0", default-features = false, features = ["jpeg", "png"] }
|
||||
imageproc = { version = "0.24.0", default-features = false }
|
||||
intel-mkl-src = { version = "0.8.1", features = ["mkl-static-lp64-iomp"] }
|
||||
libc = { version = "0.2.147" }
|
||||
log = "0.4"
|
||||
|
@ -58,7 +59,6 @@ parquet = { version = "50.0.0" }
|
|||
rand = "0.8.5"
|
||||
rand_distr = "0.4.3"
|
||||
rayon = "1.7.0"
|
||||
rusttype = { version = "0.9", default-features = false }
|
||||
safetensors = "0.4.1"
|
||||
serde = { version = "1.0.171", features = ["derive"] }
|
||||
serde_plain = "1.0.2"
|
||||
|
|
|
@ -42,7 +42,7 @@ clap = { workspace = true }
|
|||
imageproc = { workspace = true }
|
||||
memmap2 = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
rusttype = { workspace = true }
|
||||
ab_glyph = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-chrome = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
|
|
@ -5,7 +5,7 @@ use candle_transformers::models::segformer::{
|
|||
Config, ImageClassificationModel, SemanticSegmentationModel,
|
||||
};
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use image::Rgb;
|
||||
use imageproc::image::Rgb;
|
||||
use imageproc::integral_image::ArrayData;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -99,7 +99,7 @@ pub fn report_detect(
|
|||
let h_ratio = initial_h as f32 / h as f32;
|
||||
let mut img = img.to_rgb8();
|
||||
let font = Vec::from(include_bytes!("roboto-mono-stripped.ttf") as &[u8]);
|
||||
let font = rusttype::Font::try_from_vec(font);
|
||||
let font = ab_glyph::FontRef::try_from_slice(&font).map_err(candle::Error::wrap)?;
|
||||
for (class_index, bboxes_for_class) in bboxes.iter().enumerate() {
|
||||
for b in bboxes_for_class.iter() {
|
||||
println!(
|
||||
|
@ -119,27 +119,28 @@ pub fn report_detect(
|
|||
);
|
||||
}
|
||||
if legend_size > 0 {
|
||||
if let Some(font) = font.as_ref() {
|
||||
imageproc::drawing::draw_filled_rect_mut(
|
||||
&mut img,
|
||||
imageproc::rect::Rect::at(xmin, ymin).of_size(dx as u32, legend_size),
|
||||
image::Rgb([170, 0, 0]),
|
||||
);
|
||||
let legend = format!(
|
||||
"{} {:.0}%",
|
||||
candle_examples::coco_classes::NAMES[class_index],
|
||||
100. * b.confidence
|
||||
);
|
||||
imageproc::drawing::draw_text_mut(
|
||||
&mut img,
|
||||
image::Rgb([255, 255, 255]),
|
||||
xmin,
|
||||
ymin,
|
||||
rusttype::Scale::uniform(legend_size as f32 - 1.),
|
||||
font,
|
||||
&legend,
|
||||
)
|
||||
}
|
||||
imageproc::drawing::draw_filled_rect_mut(
|
||||
&mut img,
|
||||
imageproc::rect::Rect::at(xmin, ymin).of_size(dx as u32, legend_size),
|
||||
image::Rgb([170, 0, 0]),
|
||||
);
|
||||
let legend = format!(
|
||||
"{} {:.0}%",
|
||||
candle_examples::coco_classes::NAMES[class_index],
|
||||
100. * b.confidence
|
||||
);
|
||||
imageproc::drawing::draw_text_mut(
|
||||
&mut img,
|
||||
image::Rgb([255, 255, 255]),
|
||||
xmin,
|
||||
ymin,
|
||||
ab_glyph::PxScale {
|
||||
x: legend_size as f32 - 1.,
|
||||
y: legend_size as f32 - 1.,
|
||||
},
|
||||
&font,
|
||||
&legend,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue