Skip to content

v0.0.16

Compare
Choose a tag to compare
@jamjamjon jamjamjon released this 28 Sep 02:46
· 9 commits to main since this release
f2c4593

What's Changed

More Detailed

  • Add with_device() for Options. Now you can use:

    let options = Options::new().with_device(Device::Cuda(2));
    
    // or
    let options = Options::new().with_cuda(2);
  • Add .with_ixx to simplify model building with Options.

    // before
    let options = Options::new()
        .with_i00((1, 2, 4).into())
        .with_i02((416, 640, 800).into())
        .with_i03((416, 640, 800).into());
    
    // now
    let options = Options::new()
      .with_ixx(0, 0, (1, 2, 4).into())
      .with_ixx(0, 2, (416, 640, 800).into())
      .with_ixx(0, 3, (416, 640, 800).into());

    Note: The above only applies to models with dynamic shapes. If your model does not have dynamic shapes, you do not need to call this interface. Additionally, if you are not using TensorRT, you can modify .with_ixx(0, 0, (1, 2, 4).into()) to .with_ixx(0, 0, 2.into()), or you can use .with_batch_size(2) to uniformly set the batch size for all inputs.

  • Update MinOptMax struct. Data type changed from isize to usize. You can create it like:

    let default_mom = MinOptMax::default(); // min = opt = max = 1
    let ones_mom = MinOptMax::ones(); // min = opt = max = 1
    let zeros_mom = MinOptMax::zeros(); // min = opt = max = 0
    let from_i32: MinOptMax = MinOptMax::from(-5); // min = opt = max = 0
    let from_i64: MinOptMax = MinOptMax::from(-3); // min = opt = max = 0
    let from_u32: MinOptMax = MinOptMax::from(4u32); // min = opt = max = 4
    let from_u64: MinOptMax = MinOptMax::from(7u64); // min = opt = max = 7
    let from_usize: MinOptMax = MinOptMax::from(10); // min = opt = max = 10
    let from_isize: MinOptMax = MinOptMax::from(-1isize); // min = opt = max = 0
    let from_f32: MinOptMax = MinOptMax::from(-2.0); // min = opt = max = 0
    let from_f64: MinOptMax = MinOptMax::from(3.9); // min = opt = max = 4
    let tuple_mom: MinOptMax = MinOptMax::from((1, 2, 3)); // min = 1, opt = 2, max = 3
    let array_mom: MinOptMax = [1, 2, 3].into(); // min = 1, opt = 2, max = 3
  • Add Viewer for image displaying and video saving

let mut viewer = Viewer::new().with_delay(10).with_scale(1.).resizable(true);

// iteration
for (xs, _) in dl {
    // inference & annotate
    let ys = model.run(&xs)?;
    let images_plotted = annotator.plot(&xs, &ys, false)?;

    // show image
    viewer.imshow(&images_plotted)?;

    // check out window and key event
    if !viewer.is_open() || viewer.is_key_pressed(usls::Key::Escape) {
        break;
    }

    // write video
    viewer.write_batch(&images_plotted)?;
}

// finish video write
viewer.finish_write()?;