update readme
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
## 特性
|
## 特性
|
||||||
* 🚀 高性能推理 - 基于 Candle 框架,提供高效的张量计算和模型推理
|
* 🚀 高性能推理 - 基于 Candle 框架,提供高效的张量计算和模型推理
|
||||||
* 🎯 多模型支持 - 集成视觉、语言和多模态模型
|
* 🎯 多模型支持 - 集成视觉、语言和语音多模态模型
|
||||||
* 🔧 易于使用 - 简洁的 API 设计,快速上手
|
* 🔧 易于使用 - 简洁的 API 设计,快速上手
|
||||||
* 🛡️ 内存安全 - 得益于 Rust 的所有权系统,确保内存安全
|
* 🛡️ 内存安全 - 得益于 Rust 的所有权系统,确保内存安全
|
||||||
* 📦 轻量级 - 最小化依赖,编译产物小巧
|
* 📦 轻量级 - 最小化依赖,编译产物小巧
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
aha = { git = "https://github.com/jhqxxx/aha.git" }
|
aha = { git = "https://github.com/jhqxxx/aha.git" }
|
||||||
|
|
||||||
# 启用 CUDA 支持(可选)
|
# 启用 CUDA 支持(可选)
|
||||||
candle-inference = { git = "https://github.com/jhqxxx/aha.git", features = ["cuda"] }
|
aha = { git = "https://github.com/jhqxxx/aha.git", features = ["cuda"] }
|
||||||
|
|
||||||
# 启用Flash Attention 支持(可选)
|
# 启用Flash Attention 支持(可选)
|
||||||
candle-inference = { git = "https://github.com/your-username/your-repo.git", features = ["cuda", "flash-attn"] }
|
aha = { git = "https://github.com/jhqxxx/aha.git", features = ["cuda", "flash-attn"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 从源码构建运行测试
|
### 从源码构建运行测试
|
||||||
@@ -49,6 +49,36 @@ cargo test -F cuda,flash-attn minicpm_generate -- --nocapture
|
|||||||
cargo test -F cuda,flash-attn voxcpm_generate -- --nocapture
|
cargo test -F cuda,flash-attn voxcpm_generate -- --nocapture
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
### VoxCPM示例
|
||||||
|
```rust
|
||||||
|
use aha::models::voxcpm::generate::VoxCPMGenerate;
|
||||||
|
use aha::utils::audio_utils::save_wav;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
let model_path = "xxx/openbmb/VoxCPM-0.5B/";
|
||||||
|
|
||||||
|
let mut voxcpm_generate = VoxCPMGenerate::init(model_path, None, None)?;
|
||||||
|
|
||||||
|
let generate = voxcpm_generate.generate(
|
||||||
|
"太阳当空照,花儿对我笑,小鸟说早早早".to_string(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
2,
|
||||||
|
100,
|
||||||
|
10,
|
||||||
|
2.0,
|
||||||
|
false,
|
||||||
|
6.0,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let _ = save_wav(&generate, "voxcpm.wav")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## 开发
|
## 开发
|
||||||
### 项目结构
|
### 项目结构
|
||||||
```text
|
```text
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl VoxCPMGenerate {
|
|||||||
let config: VoxCPMConfig = serde_json::from_slice(&std::fs::read(config_path)?)?;
|
let config: VoxCPMConfig = serde_json::from_slice(&std::fs::read(config_path)?)?;
|
||||||
let cfg_dtype = config.dtype.as_str();
|
let cfg_dtype = config.dtype.as_str();
|
||||||
let model_list = find_type_files(path, "pth")?;
|
let model_list = find_type_files(path, "pth")?;
|
||||||
println!(" pth model_list: {:?}", model_list);
|
// println!(" pth model_list: {:?}", model_list);
|
||||||
let mut dict_to_hashmap = HashMap::new();
|
let mut dict_to_hashmap = HashMap::new();
|
||||||
let mut vae_dtype = candle_core::DType::F32;
|
let mut vae_dtype = candle_core::DType::F32;
|
||||||
for m in model_list {
|
for m in model_list {
|
||||||
@@ -46,7 +46,7 @@ impl VoxCPMGenerate {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let model_list = find_type_files(path, "bin")?;
|
let model_list = find_type_files(path, "bin")?;
|
||||||
println!(" bin model_list: {:?}", model_list);
|
// println!(" bin model_list: {:?}", model_list);
|
||||||
dict_to_hashmap = HashMap::new();
|
dict_to_hashmap = HashMap::new();
|
||||||
let mut m_dtype = get_dtype(dtype, cfg_dtype);
|
let mut m_dtype = get_dtype(dtype, cfg_dtype);
|
||||||
for m in model_list {
|
for m in model_list {
|
||||||
|
|||||||
Reference in New Issue
Block a user