Skip to content

Commit

Permalink
too slow
Browse files Browse the repository at this point in the history
  • Loading branch information
jamjamjon committed Sep 10, 2024
1 parent fa91bd0 commit 62f190c
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 283 deletions.
4 changes: 1 addition & 3 deletions examples/clip/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let feats_text = model.encode_texts(&texts)?; // [n, ndim]

// load image
let dl = DataLoader::default()
.with_batch(model.batch_visual())
.load("./examples/clip/images")?;
let dl = DataLoader::new("./examples/clip/images")?.build()?;

// loop
for (images, paths) in dl {
Expand Down
4 changes: 1 addition & 3 deletions examples/svtr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut model = SVTR::new(options)?;

// load images
let dl = DataLoader::default()
.with_batch(1)
.load("./examples/svtr/images")?;
let dl = DataLoader::new("./examples/svtr/images")?.build()?;

// run
for (xs, paths) in dl {
Expand Down
51 changes: 21 additions & 30 deletions examples/videos/main.rs
Original file line number Diff line number Diff line change
@@ -1,56 +1,47 @@
#![allow(unused)]

use usls::{
models::YOLO, Annotator, DataLoader, Options, Vision, YOLOTask, YOLOVersion, COCO_SKELETONS_16,
};
use usls::{models::YOLO, Annotator, DataLoader, Options, Vision, YOLOTask, YOLOVersion};

fn main() -> anyhow::Result<()> {
// let options = Options::default()
// .with_cuda(0)
// .with_model("yolo/v8-m-pose-dyn.onnx")?
// .with_model("yolo/v8-n-dyn.onnx")?
// .with_yolo_version(YOLOVersion::V8)
// .with_yolo_task(YOLOTask::Pose)
// .with_yolo_task(YOLOTask::Detect)
// .with_i00((1, 1, 4).into())
// .with_i02((0, 640, 640).into())
// .with_i03((0, 640, 640).into())
// .with_confs(&[0.2, 0.15]);
// .with_confs(&[0.2]);
// let mut model = YOLO::new(options)?;

// // build annotator
// let annotator = Annotator::default()
// .with_skeletons(&COCO_SKELETONS_16)
// .with_bboxes_thickness(4)
// .with_saveout("YOLO-Video-Stream");

// build dataloader
// let dl = DataLoader::new(
// // "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
// // "rtsp://stream.pchome.com.tw/pc/pcmedia/1080p.mp4",
// // "rtsp://185.107.232.253:554/live/stream",
// // "/home/qweasd/Desktop/SourceVideos/3.mp4",
// "./assets/bus.jpg",
// // "/home/qweasd/Desktop/coco/val2017/images/test",
// // "https://github.com/jamjamjon/assets/releases/download/images/bus.jpg",
// )?
// .with_batch(1);

// // run
// for (xs, _paths) in dl {
// let ys = model.forward(&xs, false)?;
// annotator.annotate(&xs, &ys);
// }

// let image = DataLoader::try_read("images/car.jpg")?;
let mut dl = DataLoader::new(
// "https://github.com/jamjamjon/assets/releases/download/images/bus.jpg",
"/home/qweasd/Desktop/SourceVideos/3.mp4",
// "/home/qweasd/Desktop/coco/val2017/images/test",
// "rtsp://admin:[email protected]:554/h265/ch1/",
// "rtsp://admin:[email protected]:554/h264/ch1/",
// "/home/qweasd/Desktop/coco/val2017/images/val2017",
// "../hall.mp4",
// "./assets/bus.jpg",
// "image/cat.jpg",
// "../set-negs",
"/home/qweasd/Desktop/SourceVideos/3.mp4", // 400-800 us,, 40ms
// "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", // ~2ms , 120us
)?
.with_batch(4);
dl.commit();
.with_batch(1)
.build()?;

// println!("Current buffer size: {}", dl.buffer_size());
// let mut t0 = std::time::Instant::now();
for (xs, _paths) in dl {
println!("xs: {:?} | {:?}", xs.len(), _paths);
// let t1 = std::time::Instant::now();
// println!("OOOO: {:?}", t1 - t0);
// t0 = t1;
// println!("xs: {:?} | {:?}", xs.len(), _paths);
// let ys = model.forward(&xs, false)?;
// annotator.annotate(&xs, &ys);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/yolo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ fn main() -> Result<()> {
let mut model = YOLO::new(options)?;

// build dataloader
let dl = DataLoader::default()
let dl = DataLoader::new(&args.source)?
.with_batch(model.batch() as _)
.load(args.source)?;
.build()?;

// build annotator
let annotator = Annotator::default()
Expand Down
Loading

0 comments on commit 62f190c

Please sign in to comment.