-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: start moving stuff off parcel
- Loading branch information
1 parent
8aab523
commit d738b17
Showing
14 changed files
with
17 additions
and
17 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ fn mnist_5() -> ort::Result<()> { | |
|
||
let mut session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level3)? | ||
.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/mnist.onnx") | ||
.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/mnist.onnx") | ||
.expect("Could not download model from file"); | ||
|
||
// Load image and resize to model's shape, converting to RGB format | ||
|
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 |
---|---|---|
|
@@ -38,7 +38,7 @@ async fn main() -> anyhow::Result<()> { | |
let session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level1)? | ||
.with_intra_threads(4)? | ||
.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/gpt2.onnx")?; | ||
.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/gpt2.onnx")?; | ||
|
||
// Load the tokenizer and encode the prompt into a sequence of tokens. | ||
let tokenizer = Tokenizer::from_file(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("tokenizer.json")).unwrap(); | ||
|
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ fn main() -> anyhow::Result<()> { | |
.commit()?; | ||
|
||
let mut session = | ||
Session::builder()?.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/modnet_photographic_portrait_matting.onnx")?; | ||
Session::builder()?.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/modnet_photographic_portrait_matting.onnx")?; | ||
|
||
let original_img = image::open(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("photo.jpg")).unwrap(); | ||
let (img_width, img_height) = (original_img.width(), original_img.height()); | ||
|
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 |
---|---|---|
|
@@ -38,7 +38,7 @@ fn main() -> ort::Result<()> { | |
let mut session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level1)? | ||
.with_intra_threads(1)? | ||
.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/gpt2.onnx")?; | ||
.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/gpt2.onnx")?; | ||
|
||
// Load the tokenizer and encode the prompt into a sequence of tokens. | ||
let tokenizer = Tokenizer::from_file(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("tokenizer.json")).unwrap(); | ||
|
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 |
---|---|---|
|
@@ -16,7 +16,7 @@ fn main() -> ort::Result<()> { | |
.commit()?; | ||
|
||
let mut session = | ||
Session::builder()?.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/modnet_photographic_portrait_matting.onnx")?; | ||
Session::builder()?.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/modnet_photographic_portrait_matting.onnx")?; | ||
|
||
let original_img = image::open(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("photo.jpg")).unwrap(); | ||
let (img_width, img_height) = (original_img.width(), original_img.height()); | ||
|
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ fn main() -> ort::Result<()> { | |
let mut session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level1)? | ||
.with_intra_threads(1)? | ||
.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/all-MiniLM-L6-v2.onnx")?; | ||
.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/all-MiniLM-L6-v2.onnx")?; | ||
|
||
// Load the tokenizer and encode the text. | ||
let tokenizer = Tokenizer::from_file(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("tokenizer.json")).unwrap(); | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ pip install -i https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/O | |
|
||
We're installing the CPU version of the `onnxruntime-training` & `torch` packages because we only need to use Python to *create* the initial graph which will be used for training. Run `python tools/train-data/mini-clm.py` from the root directory of the `ort` repo to create the training artifacts. | ||
|
||
Next, we need to convert our dataset into tokens to feed the model. This can be achieved by downloading the `oshicats-v2.jsonl` file from the OshiChats v2 dataset and running `cargo run -p example-training --example pretokenize -- ~/oshichats-v2.jsonl`, or if you (rightfully) don't wish to waste 30 GB worth of disk space and bandwidth on brainrot, you may download a [1 MB pre-tokenized subset of the dataset](https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_data/dataset.bin). Make sure `dataset.bin` is in the root of the `ort` repo. | ||
Next, we need to convert our dataset into tokens to feed the model. This can be achieved by downloading the `oshicats-v2.jsonl` file from the OshiChats v2 dataset and running `cargo run -p example-training --example pretokenize -- ~/oshichats-v2.jsonl`, or if you (rightfully) don't wish to waste 30 GB worth of disk space and bandwidth on brainrot, you may download a [1 MB pre-tokenized subset of the dataset](https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/train-clm-dataset.bin) (make sure `train-clm-dataset.bin` is in the root of the `ort` repo). | ||
|
||
Finally, we can train our model! Run `cargo run -p example-training --example train-clm` to start training. If you have an NVIDIA GPU, add `--features cuda` to enable CUDA, though it's not required and you can train directly on CPU instead. **This will use ~8 GB of (V)RAM!** You can lower the memory usage by adjusting the `BATCH_SIZE` and `SEQUENCE_LENGTH` constants in `train-clm.rs`, though note that changing the batch size may require adjustments to the learning rate. | ||
|
||
|
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ fn union(box1: &BoundingBox, box2: &BoundingBox) -> f32 { | |
((box1.x2 - box1.x1) * (box1.y2 - box1.y1)) + ((box2.x2 - box2.x1) * (box2.y2 - box2.y1)) - intersection(box1, box2) | ||
} | ||
|
||
const YOLOV8M_URL: &str = "https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/yolov8m.onnx"; | ||
const YOLOV8M_URL: &str = "https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/yolov8m.onnx"; | ||
|
||
#[rustfmt::skip] | ||
const YOLOV8_CLASS_LABELS: [&str; 80] = [ | ||
|
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 |
---|---|---|
|
@@ -257,7 +257,7 @@ mod tests { | |
#[test] | ||
#[cfg(all(feature = "ndarray", feature = "fetch-models"))] | ||
fn test_mnist_input_bound() -> Result<()> { | ||
let mut session = Session::builder()?.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/mnist.onnx")?; | ||
let mut session = Session::builder()?.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/mnist.onnx")?; | ||
|
||
let array = get_image(); | ||
|
||
|
@@ -275,7 +275,7 @@ mod tests { | |
#[test] | ||
#[cfg(all(feature = "ndarray", feature = "fetch-models"))] | ||
fn test_mnist_input_output_bound() -> Result<()> { | ||
let mut session = Session::builder()?.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/mnist.onnx")?; | ||
let mut session = Session::builder()?.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/mnist.onnx")?; | ||
|
||
let array = get_image(); | ||
|
||
|
@@ -295,7 +295,7 @@ mod tests { | |
#[test] | ||
#[cfg(all(feature = "ndarray", feature = "fetch-models"))] | ||
fn test_send_iobinding() -> Result<()> { | ||
let mut session = Session::builder()?.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/mnist.onnx")?; | ||
let mut session = Session::builder()?.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/mnist.onnx")?; | ||
|
||
let array = get_image(); | ||
|
||
|
@@ -320,7 +320,7 @@ mod tests { | |
#[test] | ||
#[cfg(all(feature = "ndarray", feature = "fetch-models"))] | ||
fn test_mnist_clear_bounds() -> Result<()> { | ||
let mut session = Session::builder()?.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/mnist.onnx")?; | ||
let mut session = Session::builder()?.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/mnist.onnx")?; | ||
|
||
let array = get_image(); | ||
|
||
|
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ fn mnist_5() -> ort::Result<()> { | |
let mut session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level1)? | ||
.with_intra_threads(1)? | ||
.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/mnist.onnx") | ||
.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/mnist.onnx") | ||
.expect("Could not download model from file"); | ||
|
||
let input0_shape = { | ||
|
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 |
---|---|---|
|
@@ -23,7 +23,7 @@ fn squeezenet_mushroom() -> ort::Result<()> { | |
let mut session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level1)? | ||
.with_intra_threads(1)? | ||
.commit_from_url("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/squeezenet.onnx") | ||
.commit_from_url("https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/squeezenet.onnx") | ||
.expect("Could not download model from file"); | ||
|
||
let class_labels = get_imagenet_labels()?; | ||
|