Skip to content

Commit

Permalink
Improve the speed of resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamjamjon committed May 11, 2024
1 parent 64ca7e7 commit 236f758
Show file tree
Hide file tree
Showing 38 changed files with 298 additions and 123 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ imageproc = { version = "0.24" }
ab_glyph = "0.2.23"
geo = "0.28.0"
prost = "0.12.4"
human_bytes = "0.4.3"
human_bytes = "0.4.3"
fast_image_resize = "3.0.4"
Binary file added assets/liuyifei.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/portrait.jpg
Binary file not shown.
6 changes: 3 additions & 3 deletions examples/db/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 4, 8).into())
.with_i02((608, 960, 1280).into())
.with_i03((608, 960, 1280).into())
// .with_trt(0)
.with_confs(&[0.4])
.with_min_width(5.0)
.with_min_height(12.0)
// .with_trt(0)
.with_model("ppocr-v4-db-dyn.onnx")?;

let mut model = DB::new(&options)?;
let mut model = DB::new(options)?;

// load image
let x = vec![
DataLoader::try_read("./assets/db.png")?,
// DataLoader::try_read("./assets/2.jpg")?,
DataLoader::try_read("./assets/2.jpg")?,
];

// run
Expand Down
2 changes: 1 addition & 1 deletion examples/depth-anything/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 8).into())
.with_i02((384, 512, 1024).into())
.with_i03((384, 512, 1024).into());
let mut model = DepthAnything::new(&options)?;
let mut model = DepthAnything::new(options)?;

// load
let x = vec![DataLoader::try_read("./assets/2.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/dinov2/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 1).into())
.with_i02((224, 224, 224).into())
.with_i03((224, 224, 224).into());
let _model = Dinov2::new(&options)?;
let _model = Dinov2::new(options)?;
println!("TODO...");

// query from vector
Expand Down
2 changes: 1 addition & 1 deletion examples/face-parsing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// .with_trt(0)
// .with_fp16(true)
.with_confs(&[0.5]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/nini.png")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/fastsam/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.4]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
Expand Down
Binary file modified examples/modnet/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/modnet/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 4).into())
.with_i02((416, 512, 800).into())
.with_i03((416, 512, 800).into());
let mut model = MODNet::new(&options)?;
let mut model = MODNet::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/portrait.jpg")?];
let x = vec![DataLoader::try_read("./assets/liuyifei.png")?];

// run
let y = model.run(&x)?;
Expand Down
4 changes: 2 additions & 2 deletions examples/rtdetr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("rtdetr-l-f16.onnx")?
.with_confs(&[0.4, 0.15]) // person: 0.4, others: 0.15
.with_confs(&[0.4, 0.15])
.with_names(&coco::NAMES_80);
let mut model = RTDETR::new(&options)?;
let mut model = RTDETR::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/rtmo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_nk(17)
.with_confs(&[0.3])
.with_kconfs(&[0.5]);
let mut model = RTMO::new(&options)?;
let mut model = RTMO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/svtr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_confs(&[0.2])
.with_vocab("ppocr_rec_vocab.txt")?
.with_model("ppocr-v4-svtr-ch-dyn.onnx")?;
let mut model = SVTR::new(&options)?;
let mut model = SVTR::new(options)?;

// load images
let dl = DataLoader::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/yolo-world/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 4).into())
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.3]) // shoes: 0.2
.with_confs(&[0.3])
.with_profile(false);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/yolop/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_model("yolopv2-dyn-480x800.onnx")?
.with_i00((1, 1, 8).into())
.with_confs(&[0.3]);
let mut model = YOLOPv2::new(&options)?;
let mut model = YOLOPv2::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/car.jpg")?];
Expand Down
9 changes: 4 additions & 5 deletions examples/yolov5/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_anchors_first(true)
.with_yolo_task(YOLOTask::Segment)
.with_model("yolov5s-seg.onnx")?
.with_trt(0)
.with_fp16(true)
// .with_trt(0)
// .with_fp16(true)
.with_i00((1, 1, 4).into())
.with_i02((224, 640, 800).into())
.with_i03((224, 640, 800).into())
.with_dry_run(3);
let mut model = YOLO::new(&options)?;
.with_i03((224, 640, 800).into());
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
Expand Down
Binary file modified examples/yolov8-face/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/yolov8-face/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.15]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/kids.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/yolov8-falldown/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use usls::{models::YOLO, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default().with_model("yolov8-falldown-f16.onnx")?;
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/falldown.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/yolov8-head/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use usls::{models::YOLO, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default().with_model("yolov8-head-f16.onnx")?;
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/kids.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion examples/yolov8-trash/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = Options::default()
.with_model("yolov8-plastic-bag-f16.onnx")?
.with_names(&["trash"]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/trash.jpg")?];
Expand Down
10 changes: 5 additions & 5 deletions examples/yolov8/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// .with_model("yolov8m-seg-dyn.onnx")?
// .with_model("yolov8m-obb-dyn.onnx")?
// .with_model("yolov8m-oiv7-dyn.onnx")?
.with_trt(0)
// .with_trt(0)
// .with_fp16(true)
// .with_coreml(0)
// .with_cuda(3)
.with_i00((1, 1, 4).into())
.with_i02((224, 640, 800).into())
.with_i03((224, 640, 800).into())
.with_confs(&[0.4, 0.15]) // person: 0.4, others: 0.15
.with_confs(&[0.4, 0.15]) // class 0: 0.4, others: 0.15
.with_names2(&coco::KEYPOINTS_NAMES_17)
.with_dry_run(10)
.with_profile(false);
let mut model = YOLO::new(&options)?;
// .with_dry_run(10)
.with_profile(true);
let mut model = YOLO::new(options)?;

// build dataloader
let dl = DataLoader::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/yolov9/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 4).into())
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.4, 0.15]); // person: 0.4, others: 0.15
let mut model = YOLO::new(&options)?;
.with_confs(&[0.4, 0.15]);
let mut model = YOLO::new(options)?;

// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
Expand Down
2 changes: 1 addition & 1 deletion src/core/annotator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl Annotator {

// keypoint
let color = match &self.keypoints_palette {
None => self.get_color(i + 10),
None => self.get_color(i),
Some(keypoints_palette) => keypoints_palette[i],
};
imageproc::drawing::draw_filled_circle_mut(
Expand Down
Loading

0 comments on commit 236f758

Please sign in to comment.