-
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.
- Loading branch information
Showing
71 changed files
with
673 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Quick Start | ||
|
||
```shell | ||
cargo run -r -F cuda --example beit -- --device cuda --dtype fp16 | ||
``` | ||
|
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,47 @@ | ||
use usls::{models::ImageClassifier, Annotator, DataLoader, Options}; | ||
|
||
#[derive(argh::FromArgs)] | ||
/// Example | ||
struct Args { | ||
/// dtype | ||
#[argh(option, default = "String::from(\"auto\")")] | ||
dtype: String, | ||
|
||
/// device | ||
#[argh(option, default = "String::from(\"cpu:0\")")] | ||
device: String, | ||
|
||
/// source image | ||
#[argh( | ||
option, | ||
default = "vec![ | ||
String::from(\"images/dog.jpg\"), | ||
String::from(\"images/siamese.png\"), | ||
String::from(\"images/ailurus-fulgens.jpg\"), | ||
]" | ||
)] | ||
source: Vec<String>, | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let args: Args = argh::from_env(); | ||
|
||
// build model | ||
let options = Options::beit_base() | ||
.with_model_dtype(args.dtype.as_str().try_into()?) | ||
.with_model_device(args.device.as_str().try_into()?) | ||
.commit()?; | ||
let mut model = ImageClassifier::try_from(options)?; | ||
|
||
// load images | ||
let xs = DataLoader::try_read_batch(&args.source)?; | ||
|
||
// run | ||
let ys = model.forward(&xs)?; | ||
|
||
// annotate | ||
let annotator = Annotator::default().with_saveout(model.spec()); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Quick Start | ||
|
||
```shell | ||
cargo run -r -F cuda --example convnext -- --device cuda --dtype fp16 | ||
``` | ||
|
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,47 @@ | ||
use usls::{models::ImageClassifier, Annotator, DataLoader, Options}; | ||
|
||
#[derive(argh::FromArgs)] | ||
/// Example | ||
struct Args { | ||
/// dtype | ||
#[argh(option, default = "String::from(\"auto\")")] | ||
dtype: String, | ||
|
||
/// device | ||
#[argh(option, default = "String::from(\"cpu:0\")")] | ||
device: String, | ||
|
||
/// source image | ||
#[argh( | ||
option, | ||
default = "vec![ | ||
String::from(\"images/dog.jpg\"), | ||
String::from(\"images/siamese.png\"), | ||
String::from(\"images/ailurus-fulgens.jpg\"), | ||
]" | ||
)] | ||
source: Vec<String>, | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let args: Args = argh::from_env(); | ||
|
||
// build model | ||
let options = Options::convnext_v2_atto() | ||
.with_model_dtype(args.dtype.as_str().try_into()?) | ||
.with_model_device(args.device.as_str().try_into()?) | ||
.commit()?; | ||
let mut model = ImageClassifier::try_from(options)?; | ||
|
||
// load images | ||
let xs = DataLoader::try_read_batch(&args.source)?; | ||
|
||
// run | ||
let ys = model.forward(&xs)?; | ||
|
||
// annotate | ||
let annotator = Annotator::default().with_saveout(model.spec()); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Quick Start | ||
|
||
```shell | ||
cargo run -r --example d-fine | ||
``` |
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,6 +1,7 @@ | ||
## Quick Start | ||
|
||
```shell | ||
cargo run -r --example dfine | ||
cargo run -r --example deim | ||
``` | ||
|
||
|
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,23 @@ | ||
use anyhow::Result; | ||
use usls::{models::RTDETR, Annotator, DataLoader, Options}; | ||
|
||
fn main() -> Result<()> { | ||
// options | ||
let options = Options::deim_dfine_s_coco().commit()?; | ||
let mut model = RTDETR::new(options)?; | ||
|
||
// load | ||
let x = [DataLoader::try_read("./assets/bus.jpg")?]; | ||
|
||
// run | ||
let y = model.forward(&x)?; | ||
println!("{:?}", y); | ||
|
||
// annotate | ||
let annotator = Annotator::default() | ||
.with_bboxes_thickness(3) | ||
.with_saveout(model.spec()); | ||
annotator.annotate(&x, &y); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Quick Start | ||
|
||
```shell | ||
cargo run -r -F cuda --example deit -- --device cuda --dtype fp16 | ||
``` | ||
|
||
|
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,47 @@ | ||
use usls::{models::ImageClassifier, Annotator, DataLoader, Options}; | ||
|
||
#[derive(argh::FromArgs)] | ||
/// Example | ||
struct Args { | ||
/// dtype | ||
#[argh(option, default = "String::from(\"auto\")")] | ||
dtype: String, | ||
|
||
/// device | ||
#[argh(option, default = "String::from(\"cpu:0\")")] | ||
device: String, | ||
|
||
/// source image | ||
#[argh( | ||
option, | ||
default = "vec![ | ||
String::from(\"images/dog.jpg\"), | ||
String::from(\"images/siamese.png\"), | ||
String::from(\"images/ailurus-fulgens.jpg\"), | ||
]" | ||
)] | ||
source: Vec<String>, | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let args: Args = argh::from_env(); | ||
|
||
// build model | ||
let options = Options::deit_tiny_distill() | ||
.with_model_dtype(args.dtype.as_str().try_into()?) | ||
.with_model_device(args.device.as_str().try_into()?) | ||
.commit()?; | ||
let mut model = ImageClassifier::try_from(options)?; | ||
|
||
// load images | ||
let xs = DataLoader::try_read_batch(&args.source)?; | ||
|
||
// run | ||
let ys = model.forward(&xs)?; | ||
|
||
// annotate | ||
let annotator = Annotator::default().with_saveout(model.spec()); | ||
annotator.annotate(&xs, &ys); | ||
|
||
Ok(()) | ||
} |
2 changes: 1 addition & 1 deletion
2
examples/image-classification/README.md → examples/fastvit/README.md
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use usls::{models::ImageClassifier, Annotator, DataLoader, Options}; | ||
|
||
#[derive(argh::FromArgs)] | ||
/// Example | ||
struct Args { | ||
/// dtype | ||
#[argh(option, default = "String::from(\"auto\")")] | ||
dtype: String, | ||
|
||
/// device | ||
#[argh(option, default = "String::from(\"cpu:0\")")] | ||
device: String, | ||
|
||
/// source image | ||
#[argh( | ||
option, | ||
default = "vec![ | ||
String::from(\"images/dog.jpg\"), | ||
String::from(\"images/siamese.png\"), | ||
String::from(\"images/ailurus-fulgens.jpg\"), | ||
]" | ||
)] | ||
source: Vec<String>, | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let args: Args = argh::from_env(); | ||
|
||
// build model | ||
let options = Options::fastvit_t8_distill() | ||
.with_model_dtype(args.dtype.as_str().try_into()?) | ||
.with_model_device(args.device.as_str().try_into()?) | ||
.commit()?; | ||
let mut model = ImageClassifier::try_from(options)?; | ||
|
||
// load images | ||
let xs = DataLoader::try_read_batch(&args.source)?; | ||
|
||
// run | ||
let ys = model.forward(&xs)?; | ||
|
||
// results | ||
for (i, y) in ys.iter().enumerate() { | ||
println!("{}: {:?}", i, y); | ||
} | ||
|
||
// annotate | ||
let annotator = Annotator::default().with_saveout(model.spec()); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Quick Start | ||
|
||
```shell | ||
cargo run -r -F cuda --example mobileone -- --device cuda --dtype fp16 | ||
``` | ||
|
||
|
||
```shell | ||
0: Y { Probs: { Top5: [(263, 0.6109131, Some("Pembroke, Pembroke Welsh corgi")), (264, 0.2062352, Some("Cardigan, Cardigan Welsh corgi")), (231, 0.028572788, Some("collie")), (273, 0.015174894, Some("dingo, warrigal, warragal, Canis dingo")), (248, 0.014367299, Some("Eskimo dog, husky"))] } } | ||
1: Y { Probs: { Top5: [(284, 0.9907692, Some("siamese cat, Siamese")), (285, 0.0015794479, Some("Egyptian cat")), (174, 0.0015189401, Some("Norwegian elkhound, elkhound")), (225, 0.00031838714, Some("malinois")), (17, 0.00027021166, Some("jay"))] } } | ||
2: Y { Probs: { Top5: [(387, 0.94238573, Some("lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens")), (368, 0.0029994072, Some("gibbon, Hylobates lar")), (277, 0.0016564301, Some("red fox, Vulpes vulpes")), (356, 0.0015081967, Some("weasel")), (295, 0.001427932, Some("American black bear, black bear, Ursus americanus, Euarctos americanus"))] } } | ||
|
||
``` |
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.