图片超分辨率处理 - 实现 upscale_image() 单图片超分辨率功能 - 支持所有 16 种 Topaz AI 模型 - 完整的参数验证和模型约束检查 - 多种输出格式支持 (PNG, JPG, TIFF, BMP) - GPU 加速和质量优化 批量图片处理 - 实现 batch_upscale_images() 批量处理功能 - 实现 upscale_directory() 目录批量处理 - 支持递归子目录扫描 - 智能文件格式过滤和识别 - 批量进度跟踪和状态报告 图片格式转换 - 实现 convert_image_format() 格式转换功能 - 实现 batch_convert_images() 批量格式转换 - 支持质量参数控制 - 多种图片格式互转 - 高效的批量处理流水线 图片增强功能 - 实现 resize_image() 传统几何缩放 - 支持宽高比保持选项 - 多种缩放算法支持 - 格式转换集成 - 高质量输出控制 便捷处理函数 - quick_upscale_image() 一键图片放大 - auto_enhance_image() 智能自动增强 - batch_upscale_directory() 批量目录处理 - convert_image() 简单格式转换 - 自动参数选择和优化 智能参数预设 - ImageUpscaleParams::for_photo() 照片增强 - ImageUpscaleParams::for_artwork() 艺术作品 - ImageUpscaleParams::for_screenshot() 截图增强 - ImageUpscaleParams::for_portrait() 人像优化 - 基于图片特征的自动参数选择 文件系统集成 - 智能图片文件发现和过滤 - 支持常见图片格式 (JPG, PNG, TIFF, BMP) - 递归目录遍历功能 - 自动输出文件命名 - 批量操作进度跟踪 完整示例和演示 - 创建 image_processing.rs 综合示例 - 展示所有图片处理场景 - 参数配置和模型选择演示 - 批量处理和格式转换演示 - 便捷函数使用演示 技术特性 - 完整的 Topaz Video AI 集成 - 智能参数验证和错误处理 - 批量处理优化和进度跟踪 - 多格式支持和质量控制 - 异步处理和资源管理 代码质量 - 所有测试通过 (6/6 单元测试 + 1 文档测试) - 完整的错误处理和验证 - 内存安全的资源管理 - 清晰的 API 设计和文档 功能覆盖 - 单图片超分辨率 (16 种模型) - 批量图片处理 (目录/文件列表) - 图片格式转换 (4 种格式) - 传统图片缩放 (几何变换) - 便捷处理函数 (一键操作) - 智能参数预设 (场景优化) 下一步: 开始阶段五 - 便捷接口和优化
TVAI - Topaz Video AI Integration Library
A Rust library for integrating with Topaz Video AI to perform video and image enhancement including super-resolution upscaling and frame interpolation.
Features
- 🎬 Video Super-Resolution: Upscale videos using AI models
- 🎞️ Frame Interpolation: Create smooth slow motion effects
- 🖼️ Image Upscaling: Enhance image resolution and quality
- ⚡ GPU Acceleration: CUDA and hardware encoding support
- 🔧 Multiple AI Models: 16 upscaling and 4 interpolation models
- 📦 Batch Processing: Process multiple files efficiently
- 🎛️ Flexible Configuration: Fine-tune processing parameters
Requirements
- Topaz Video AI installed
- Rust 1.70+
- FFmpeg (included with Topaz Video AI)
- Optional: CUDA-compatible GPU for acceleration
Installation
Add this to your Cargo.toml:
[dependencies]
tvai = "0.1.0"
Quick Start
Video Upscaling
use tvai::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Quick 2x upscaling
quick_upscale_video(
std::path::Path::new("input.mp4"),
std::path::Path::new("output.mp4"),
2.0,
).await?;
Ok(())
}
Image Upscaling
use tvai::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Quick 4x image upscaling
quick_upscale_image(
std::path::Path::new("photo.jpg"),
std::path::Path::new("photo_4x.png"),
4.0,
).await?;
Ok(())
}
Advanced Usage
use tvai::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Detect Topaz installation
let topaz_path = detect_topaz_installation()
.ok_or("Topaz Video AI not found")?;
// Create configuration
let config = TvaiConfig::builder()
.topaz_path(topaz_path)
.use_gpu(true)
.build()?;
// Create processor
let processor = TvaiProcessor::new(config)?;
// Custom upscaling parameters
let params = VideoUpscaleParams {
scale_factor: 2.0,
model: UpscaleModel::Iris3,
compression: 0.0,
blend: 0.1,
quality_preset: QualityPreset::HighQuality,
};
// Process video
let result = processor.upscale_video(
std::path::Path::new("input.mp4"),
std::path::Path::new("output.mp4"),
params,
).await?;
println!("Processing completed in {:?}", result.processing_time);
Ok(())
}
AI Models
Upscaling Models
- Iris v3 - Best general purpose model
- Nyx v3 - Optimized for portraits
- Theia Fidelity v4 - Old content restoration
- Gaia HQ v5 - Game/CG content
- Proteus v4 - Problem footage repair
- And more...
Interpolation Models
- Apollo v8 - High quality interpolation
- Chronos v2 - Animation content
- Apollo Fast v1 - Fast processing
- Chronos Fast v3 - Fast animation
Presets
The library includes optimized presets for common use cases:
// Video presets
let old_video_params = VideoUpscaleParams::for_old_video();
let game_params = VideoUpscaleParams::for_game_content();
let animation_params = VideoUpscaleParams::for_animation();
let portrait_params = VideoUpscaleParams::for_portrait();
// Image presets
let photo_params = ImageUpscaleParams::for_photo();
let artwork_params = ImageUpscaleParams::for_artwork();
let screenshot_params = ImageUpscaleParams::for_screenshot();
System Detection
// Detect Topaz installation
let topaz_path = detect_topaz_installation();
// Check GPU support
let gpu_info = detect_gpu_support();
// Check FFmpeg availability
let ffmpeg_info = detect_ffmpeg();
Error Handling
The library uses the anyhow crate for error handling:
use tvai::*;
match quick_upscale_video(input, output, 2.0).await {
Ok(result) => println!("Success: {:?}", result),
Err(TvaiError::TopazNotFound(path)) => {
eprintln!("Topaz not found at: {}", path);
},
Err(TvaiError::FfmpegError(msg)) => {
eprintln!("FFmpeg error: {}", msg);
},
Err(e) => eprintln!("Other error: {}", e),
}
Development Status
This library is currently in development. The following features are planned:
- Basic project structure
- FFmpeg management
- Core processor framework
- Video upscaling implementation
- Frame interpolation implementation
- Image upscaling implementation
- Batch processing
- Progress callbacks
- Comprehensive testing
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.