update interpolate
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
use aha::utils::interpolate::interpolate_nearest_1d;
|
||||
use anyhow::Result;
|
||||
use candle_core::Tensor;
|
||||
|
||||
#[test]
|
||||
fn interpolate_test() -> Result<()> {
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda --test interpolate interpolate_test -r -- --nocapture
|
||||
let device = &candle_core::Device::Cpu;
|
||||
let input = Tensor::arange(0.0f32, 10.0f32, device)?;
|
||||
let input_1d = input.reshape((1, 1, 10))?;
|
||||
println!("input_1d: {}", input_1d);
|
||||
let x_nearest_1d = interpolate_nearest_1d(&input_1d, 20)?;
|
||||
println!("x_nearest_1d: {}", x_nearest_1d);
|
||||
// let x_linear_1d = interpolate_linear_1d(&input_1d, 10, Some(true))?;
|
||||
// println!("x_linear_1d: {}", x_linear_1d);
|
||||
// let input_2d = input.reshape((1, 1, 10, 10))?;
|
||||
// println!("input_2d: {}", input_2d);
|
||||
// let x_nearest_2d = interpolate_nearest_2d(&input_2d, (10, 10))?;
|
||||
// println!("x_nearest_2d: {}", x_nearest_2d);
|
||||
// let x_bilinear = interpolate_bilinear(&input_2d, (5, 5), Some(true), Some(false))?;
|
||||
// println!("x_bilinear: {}", x_bilinear);
|
||||
// let x_bicubic = interpolate_bicubic(&input_2d, (5, 5), Some(false), Some(true))?;
|
||||
// // let x_bicubic = interpolate_bicubic_standard(&input_2d, (5, 5), None)?;
|
||||
|
||||
// println!("x_bicubic: {}", x_bicubic);
|
||||
Ok(())
|
||||
}
|
||||
+29
-21
@@ -5,11 +5,11 @@
|
||||
// use std::io::{Read, Seek};
|
||||
// use std::{io::Cursor, time::Instant};
|
||||
|
||||
use aha::utils::load_tensor_from_pt;
|
||||
use aha::utils::interpolate::interpolate_nearest_2d;
|
||||
// use aha_openai_dive::v1::resources::chat::ChatCompletionParameters;
|
||||
use anyhow::Result;
|
||||
// use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use candle_core::Shape;
|
||||
use candle_core::Tensor;
|
||||
// use sentencepiece::SentencePieceProcessor;
|
||||
// use zip::ZipArchive;
|
||||
|
||||
@@ -17,25 +17,33 @@ use candle_core::Shape;
|
||||
fn messy_test() -> Result<()> {
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda messy_test -r -- --nocapture
|
||||
let device = &candle_core::Device::Cpu;
|
||||
let save_dir: String =
|
||||
aha::utils::get_default_save_dir().ok_or(anyhow::anyhow!("Failed to get save dir"))?;
|
||||
let model_path = format!("{}/IndexTeam/IndexTTS-2/", save_dir);
|
||||
let emo_matrix_path = model_path.clone() + "/feat2.pt";
|
||||
let t_emo = load_tensor_from_pt(
|
||||
&emo_matrix_path,
|
||||
"feat2/data/0",
|
||||
Shape::from_dims(&[73, 1280]),
|
||||
device,
|
||||
)?;
|
||||
println!("t_emo: {}", t_emo);
|
||||
let skp_matrix_path = model_path + "/feat1.pt";
|
||||
let t_skp = load_tensor_from_pt(
|
||||
&skp_matrix_path,
|
||||
"feat1/data/0",
|
||||
Shape::from_dims(&[73, 192]),
|
||||
device,
|
||||
)?;
|
||||
println!("t_skp: {}", t_skp);
|
||||
let input = Tensor::arange(0.0f32, 25.0f32, device)?.reshape((1, 1, 5, 5))?;
|
||||
println!("input: {}", input);
|
||||
let x_nearest = interpolate_nearest_2d(&input, (10, 10))?;
|
||||
println!("x_nearest: {}", x_nearest);
|
||||
// let input = Tensor::arange(0.0f32, 25.0f32, device)?.reshape((1, 5, 5))?;
|
||||
// println!("input: {}", input);
|
||||
// let x_nearest = interpolate_nearest_1d(&input, 10)?;
|
||||
// println!("x_nearest: {}", x_nearest);
|
||||
// let save_dir: String =
|
||||
// aha::utils::get_default_save_dir().ok_or(anyhow::anyhow!("Failed to get save dir"))?;
|
||||
// let model_path = format!("{}/IndexTeam/IndexTTS-2/", save_dir);
|
||||
// let emo_matrix_path = model_path.clone() + "/feat2.pt";
|
||||
// let t_emo = load_tensor_from_pt(
|
||||
// &emo_matrix_path,
|
||||
// "feat2/data/0",
|
||||
// Shape::from_dims(&[73, 1280]),
|
||||
// device,
|
||||
// )?;
|
||||
// println!("t_emo: {}", t_emo);
|
||||
// let skp_matrix_path = model_path + "/feat1.pt";
|
||||
// let t_skp = load_tensor_from_pt(
|
||||
// &skp_matrix_path,
|
||||
// "feat1/data/0",
|
||||
// Shape::from_dims(&[73, 192]),
|
||||
// device,
|
||||
// )?;
|
||||
// println!("t_skp: {}", t_skp);
|
||||
// let file = File::open(emo_matrix_path)?;
|
||||
// let mut archive = ZipArchive::new(file)?;
|
||||
// // 列出所有文件(调试用)
|
||||
|
||||
@@ -7,7 +7,7 @@ use rocket::futures::StreamExt;
|
||||
|
||||
#[test]
|
||||
fn deepseek_ocr_generate() -> Result<()> {
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda deepseek_ocr_generate -r -- --nocapture
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda --test test_deepseek_ocr deepseek_ocr_generate -r -- --nocapture
|
||||
let message = r#"
|
||||
{
|
||||
"model": "deepseek-ocr",
|
||||
|
||||
@@ -7,7 +7,7 @@ use rocket::futures::StreamExt;
|
||||
|
||||
#[test]
|
||||
fn hunyuan_ocr_generate() -> Result<()> {
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda hunyuan_ocr_generate -r -- --nocapture
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda --test test_hunyuan_ocr hunyuan_ocr_generate -r -- --nocapture
|
||||
let message = r#"
|
||||
{
|
||||
"model": "hunyuan-ocr",
|
||||
|
||||
@@ -7,7 +7,7 @@ use rocket::futures::StreamExt;
|
||||
|
||||
#[test]
|
||||
fn paddleocr_vl_generate() -> Result<()> {
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda paddleocr_vl_generate -r -- --nocapture
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda --test test_paddleocr_vl paddleocr_vl_generate -r -- --nocapture
|
||||
let message = r#"
|
||||
{
|
||||
"model": "paddleocr_vl",
|
||||
@@ -19,7 +19,7 @@ fn paddleocr_vl_generate() -> Result<()> {
|
||||
"type": "image",
|
||||
"image_url":
|
||||
{
|
||||
"url": "https://www.qqxiuzi.cn/zh/shouxie-shufa/welcome.png"
|
||||
"url": "file://./assets/img/ocr_test1.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use anyhow::Result;
|
||||
|
||||
#[test]
|
||||
fn rmbg2_0_generate() -> Result<()> {
|
||||
// test with cuda: RUST_BACKTRACE=1 cargo test -F cuda rmbg2_0_generate -r -- --nocapture
|
||||
// test with cuda: RUST_BACKTRACE=1 cargo test -F cuda --test test_rmbg2_0 rmbg2_0_generate -r -- --nocapture
|
||||
|
||||
let save_dir =
|
||||
aha::utils::get_default_save_dir().ok_or(anyhow::anyhow!("Failed to get save dir"))?;
|
||||
|
||||
Reference in New Issue
Block a user