refactor: move example data to respective folders

This commit is contained in:
Carson M.
2023-11-12 23:18:22 -06:00
parent 073513b68c
commit e5d8b6daae
4 changed files with 8 additions and 3 deletions

View File

@@ -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<_>>();

View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

@@ -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));