main.rs 627 B

12345678910111213141516171819202122232425262728
  1. use clap::Parser;
  2. use yolov8_rs::{Args, YOLOv8};
  3. fn main() -> Result<(), Box<dyn std::error::Error>> {
  4. let args = Args::parse();
  5. // 1. load image
  6. let x = image::ImageReader::open(&args.source)?
  7. .with_guessed_format()?
  8. .decode()?;
  9. // 2. model support dynamic batch inference, so input should be a Vec
  10. let xs = vec![x];
  11. // You can test `--batch 2` with this
  12. // let xs = vec![x.clone(), x];
  13. // 3. build yolov8 model
  14. let mut model = YOLOv8::new(args)?;
  15. model.summary(); // model info
  16. // 4. run
  17. let ys = model.run(&xs)?;
  18. println!("{:?}", ys);
  19. Ok(())
  20. }