mirror of
https://github.com/pykeio/ort
synced 2026-04-25 16:34:55 +02:00
refactor: move example data to respective folders
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use std::io::{self, Write};
|
||||
use std::{
|
||||
io::{self, Write},
|
||||
path::Path
|
||||
};
|
||||
|
||||
use ndarray::{array, concatenate, s, Array1, Axis};
|
||||
use ort::{download::language::machine_comprehension::GPT2, inputs, CUDAExecutionProvider, Environment, GraphOptimizationLevel, SessionBuilder, Tensor};
|
||||
@@ -26,7 +29,7 @@ fn main() -> ort::Result<()> {
|
||||
.with_intra_threads(1)?
|
||||
.with_model_downloaded(GPT2::GPT2LmHead)?;
|
||||
|
||||
let tokenizer = Tokenizer::from_file("tests/data/gpt2-tokenizer.json").unwrap();
|
||||
let tokenizer = Tokenizer::from_file(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("tokenizer.json")).unwrap();
|
||||
let tokens = tokenizer.encode(PROMPT, false).unwrap();
|
||||
let tokens = tokens.get_ids().iter().map(|i| *i as i64).collect::<Vec<_>>();
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
@@ -1,5 +1,7 @@
|
||||
#![allow(clippy::manual_retain)]
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use image::{imageops::FilterType, GenericImageView};
|
||||
use ndarray::{s, Array, Axis};
|
||||
use ort::{inputs, CUDAExecutionProvider, Environment, SessionBuilder, SessionOutputs};
|
||||
@@ -40,7 +42,7 @@ const YOLOV8_CLASS_LABELS: [&str; 80] = [
|
||||
fn main() -> ort::Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let original_img = image::open("tests/data/baseball.jpg").unwrap();
|
||||
let original_img = image::open(Path::new(env!("CARGO_MANIFEST_DIR")).join("data").join("baseball.jpg")).unwrap();
|
||||
let (img_width, img_height) = (original_img.width(), original_img.height());
|
||||
let img = original_img.resize_exact(640, 640, FilterType::CatmullRom);
|
||||
let mut input = Array::zeros((1, 3, 640, 640));
|
||||
|
||||
Reference in New Issue
Block a user