-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: YdrMaster <ydrml@hotmail.com>
- Loading branch information
Showing
8 changed files
with
106 additions
and
14 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ members = [ | |
"models/llama/ascend", | ||
|
||
"models/clip/common", | ||
"models/clip/common-cpu", | ||
] | ||
resolver = "2" | ||
|
||
|
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,15 @@ | ||
[package] | ||
name = "clip-cpu" | ||
version = "0.0.0" | ||
edition = "2021" | ||
authors = ["YdrMaster <ydrml@hotmail.com>"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clip.path = "../common" | ||
operators = { workspace = true, features = ["common-cpu"] } | ||
|
||
[dev-dependencies] | ||
test-utils.workspace = true | ||
gguf.workspace = true |
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,2 @@ | ||
#[cfg(test)] | ||
mod test_infer; |
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,40 @@ | ||
use clip::{ClipMeta, ClipStorage, Image}; | ||
use gguf::GGufModel; | ||
use std::time::Instant; | ||
use test_utils::Inference; | ||
|
||
#[test] | ||
fn test_infer() { | ||
let Some(Inference { model, .. }) = Inference::load() else { | ||
return; | ||
}; | ||
let Some(picture) = test_utils::image() else { | ||
return; | ||
}; | ||
|
||
let gguf = GGufModel::read(model.iter().map(|s| &**s)); | ||
let storage = ClipStorage::from_gguf(&gguf); | ||
let meta = &storage.meta; | ||
println!("{meta:#?}"); | ||
|
||
let &ClipMeta { | ||
dt_embd, | ||
|
||
d_image, | ||
d_patch, | ||
|
||
image_mean, | ||
image_std, | ||
.. | ||
} = meta; | ||
|
||
let time = Instant::now(); | ||
let image = Image::load(picture); | ||
println!("load image {:?}", time.elapsed()); | ||
|
||
let time = Instant::now(); | ||
let _slices = image | ||
.slice_uhd(9, d_image, d_patch) | ||
.normalize(dt_embd, image_mean, image_std); | ||
println!("slice image {:?}", time.elapsed()); | ||
} |
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