-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `Viewer` for image-show * Add .`with_ixx()` to simplify model building with `Options` * Update `MinOptMax`
- Loading branch information
Showing
42 changed files
with
878 additions
and
1,739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,64 @@ | ||
use usls::{models::YOLO, Annotator, DataLoader, Options, Vision, YOLOTask, YOLOVersion}; | ||
use usls::{ | ||
models::YOLO, Annotator, DataLoader, Device, Options, Viewer, Vision, YOLOTask, YOLOVersion, | ||
}; | ||
|
||
fn main() -> anyhow::Result<()> { | ||
tracing_subscriber::fmt() | ||
.with_max_level(tracing::Level::ERROR) | ||
.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_i00((1, 1, 4).into()) | ||
.with_i02((0, 640, 640).into()) | ||
.with_i03((0, 640, 640).into()) | ||
.with_batch(2) | ||
.with_ixx(0, 2, (416, 640, 800).into()) | ||
.with_ixx(0, 3, (416, 640, 800).into()) | ||
.with_confs(&[0.2]); | ||
let mut model = YOLO::new(options)?; | ||
|
||
// build annotator | ||
let annotator = Annotator::new() | ||
.with_bboxes_thickness(4) | ||
.with_saveout("YOLO-DataLoader"); | ||
|
||
// build dataloader | ||
let dl = DataLoader::new( | ||
// "images/bus.jpg", // remote image | ||
// "images/bus.jpg", // remote image | ||
// "../images", // image folder | ||
// "../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 | ||
// "./assets/bus.jpg", // local image | ||
"../7.mp4", | ||
)? | ||
.with_batch(1) | ||
.build()?; | ||
|
||
// build annotator | ||
let annotator = Annotator::new() | ||
.with_bboxes_thickness(4) | ||
.with_saveout("YOLO-DataLoader"); | ||
let mut viewer = Viewer::new().with_delay(10).with_scale(1.).resizable(true); | ||
|
||
// run | ||
// iteration | ||
for (xs, _) in dl { | ||
// std::thread::sleep(std::time::Duration::from_millis(100)); | ||
let ys = model.forward(&xs, false)?; | ||
annotator.annotate(&xs, &ys); | ||
// 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()?; | ||
|
||
// images -> video | ||
// DataLoader::is2v("runs/YOLO-DataLoader", &["runs", "is2v"], 24)?; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.