Skip to content

Commit

Permalink
Update MinOptMax
Browse files Browse the repository at this point in the history
  • Loading branch information
jamjamjon committed Sep 27, 2024
1 parent f7e8b13 commit 540e7f7
Show file tree
Hide file tree
Showing 21 changed files with 507 additions and 198 deletions.
19 changes: 9 additions & 10 deletions examples/dataloader/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use usls::{
models::YOLO, Annotator, DataLoader, Key, Options, Viewer, Vision, YOLOTask, YOLOVersion,
models::YOLO, Annotator, DataLoader, Device, Options, Viewer, Vision, YOLOTask, YOLOVersion,
};

fn main() -> anyhow::Result<()> {
Expand All @@ -8,12 +8,11 @@ fn main() -> anyhow::Result<()> {
.init();

let options = Options::new()
.with_cuda(0)
.with_device(Device::Cuda(0))
.with_model("yolo/v8-m-dyn.onnx")?
.with_yolo_version(YOLOVersion::V8)
.with_yolo_task(YOLOTask::Detect)
.with_batch(2)
// .with_ixx(0, 0, (1, 2, 8).into())
.with_ixx(0, 2, (416, 640, 800).into())
.with_ixx(0, 3, (416, 640, 800).into())
.with_confs(&[0.2]);
Expand All @@ -31,13 +30,13 @@ fn main() -> anyhow::Result<()> {
// "../demo.mp4", // local video
// "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", // remote video
// "rtsp://admin:[email protected]:554/h265/ch1/", // rtsp h264 stream
"./assets/bus.jpg", // local image
// "../7.mp4",
// "./assets/bus.jpg", // local image
"../7.mp4",
)?
.with_batch(1)
.build()?;

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

// iteration
for (xs, _) in dl {
Expand All @@ -48,13 +47,13 @@ fn main() -> anyhow::Result<()> {
// show image
viewer.imshow(&images_plotted)?;

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

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

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

// finish video write
Expand Down
2 changes: 1 addition & 1 deletion examples/yolo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn main() -> Result<()> {
} else if args.trt {
let options = options.with_trt(args.device_id);
if args.half {
options.with_fp16(true)
options.with_trt_fp16(true)
} else {
options
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/device.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Device {
Auto(usize), // TODO
Auto(usize),
Cpu(usize),
Cuda(usize),
Trt(usize),
Expand Down
Loading

0 comments on commit 540e7f7

Please sign in to comment.