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