-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
513 additions
and
28 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use usls::{ | ||
models::{SamPrompt, SAM}, | ||
Annotator, DataLoader, Options, | ||
}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// encoder | ||
let options_encoder = Options::default() | ||
// .with_cpu() | ||
.with_i00((1, 1, 1).into()) | ||
.with_model("mobile-sam-vit-t-encoder.onnx")?; | ||
|
||
// decoder | ||
let options_decoder = Options::default() | ||
// .with_cpu() | ||
.with_i11((1, 1, 1).into()) | ||
.with_i21((1, 1, 1).into()) | ||
.with_find_contours(true) // find contours or not | ||
.with_model("mobile-sam-vit-t-decoder.onnx")?; | ||
|
||
// build model | ||
let mut model = SAM::new(options_encoder, options_decoder)?; | ||
|
||
// build dataloader | ||
let dl = DataLoader::default() | ||
.with_batch(model.batch() as _) | ||
.load("./assets/truck.jpg")?; | ||
|
||
// build annotator | ||
let annotator = Annotator::default() | ||
.without_bboxes_name(true) | ||
.without_bboxes_conf(true) | ||
.without_mbrs_name(true) | ||
.without_mbrs_conf(true) | ||
.with_saveout("SAM"); | ||
|
||
// run & annotate | ||
for (xs, _paths) in dl { | ||
// prompt | ||
let prompts = vec![ | ||
SamPrompt::default() | ||
// .with_postive_point(774., 366.), // postive point | ||
// .with_negative_point(774., 366.), // negative point | ||
.with_bbox(215., 297., 643., 459.), // bbox | ||
]; | ||
let ys = model.run(&xs, &prompts)?; | ||
annotator.annotate(&xs, &ys); | ||
} | ||
|
||
Ok(()) | ||
} |
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.