mixvideo-v2/cargos/tvai-v2/examples/ai_engines_demo.rs

149 lines
7.2 KiB
Rust

use tvai_sdk::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Topaz Video AI SDK - AI Engines Demo");
println!("===================================");
let sdk = TvaiSdk::new();
// Example 1: Animation Enhancement with Artemis
println!("\n1. Animation Enhancement (Artemis AI):");
let animation_template = TemplatePresets::animation_enhance()?;
println!(" Template: {}", animation_template.name);
println!(" Description: {}", animation_template.description);
println!(" AI Engine Flags:");
println!(" Artemis: {}", animation_template.settings.enhance.is_artemis);
println!(" Gaia: {}", animation_template.settings.enhance.is_gaia);
println!(" Theia: {}", animation_template.settings.enhance.is_theia);
println!(" Proteus: {}", animation_template.settings.enhance.is_proteus);
println!(" Iris: {}", animation_template.settings.enhance.is_iris);
let animation_command = sdk.generate_ffmpeg_command(&animation_template, "anime_input.mp4", "anime_enhanced.mp4")?;
println!(" Command:");
println!(" {}", animation_command);
// Example 2: Natural Scene Enhancement with Gaia
println!("\n2. Natural Scene Enhancement (Gaia AI):");
let nature_template = TemplatePresets::natural_scene_enhance()?;
println!(" Template: {}", nature_template.name);
println!(" AI Engine: Gaia (is_gaia: {})", nature_template.settings.enhance.is_gaia);
let nature_command = sdk.generate_ffmpeg_command(&nature_template, "landscape_input.mp4", "landscape_enhanced.mp4")?;
println!(" Command:");
println!(" {}", nature_command);
// Example 3: Detail Recovery with Theia
println!("\n3. Detail Recovery (Theia AI):");
let detail_template = TemplatePresets::detail_recovery()?;
println!(" Template: {}", detail_template.name);
println!(" AI Engine: Theia (is_theia: {})", detail_template.settings.enhance.is_theia);
println!(" Focus Fix Level: {}", detail_template.settings.enhance.focus_fix_level.as_ref().unwrap_or(&"Off".to_string()));
println!(" Second Enhancement: {}", detail_template.settings.enhance.is_second_enhancement.unwrap_or(false));
if let Some(ref fm) = detail_template.settings.filter_manager {
println!(" Second Enhancement Enabled: {}", fm.second_enhancement_enabled);
println!(" Intermediate Resolution: {}", fm.second_enhancement_intermediate_resolution);
}
let detail_command = sdk.generate_ffmpeg_command(&detail_template, "blurry_input.mp4", "detail_recovered.mp4")?;
println!(" Command:");
println!(" {}", detail_command);
// Example 4: Low Light Enhancement with Iris
println!("\n4. Low Light Enhancement (Iris AI):");
let lowlight_template = TemplatePresets::low_light_enhance()?;
println!(" Template: {}", lowlight_template.name);
println!(" AI Engine: Iris (is_iris: {})", lowlight_template.settings.enhance.is_iris);
println!(" Focus Fix Level: {}", lowlight_template.settings.enhance.focus_fix_level.as_ref().unwrap_or(&"Off".to_string()));
let lowlight_command = sdk.generate_ffmpeg_command(&lowlight_template, "dark_input.mp4", "lowlight_enhanced.mp4")?;
println!(" Command:");
println!(" {}", lowlight_command);
// Example 5: General Purpose with Proteus
println!("\n5. General Purpose (Proteus AI):");
let general_template = TemplatePresets::general_purpose_proteus()?;
println!(" Template: {}", general_template.name);
println!(" AI Engine: Proteus (is_proteus: {})", general_template.settings.enhance.is_proteus);
let general_command = sdk.generate_ffmpeg_command(&general_template, "general_input.mp4", "general_enhanced.mp4")?;
println!(" Command:");
println!(" {}", general_command);
// Example 6: Custom Template with AI Engine Selection
println!("\n6. Custom Template with AI Engine Selection:");
let custom_template = TemplateBuilder::new("Custom AI Engine Demo")
.description("Custom template demonstrating AI engine selection")
.enable_enhancement("prob-4")
.enhancement_params(30, 25, 15)
.ai_engine("gaia") // Switch to Gaia for this content
.focus_fix_level("Low") // Add focus fix
.resolution(2560, 1440) // 1440p
.video_codec("libx265", Some(22))
.build()?;
println!(" Template: {}", custom_template.name);
println!(" Selected AI Engine: Gaia");
println!(" Engine Flags:");
println!(" Artemis: {}", custom_template.settings.enhance.is_artemis);
println!(" Gaia: {}", custom_template.settings.enhance.is_gaia);
println!(" Theia: {}", custom_template.settings.enhance.is_theia);
println!(" Proteus: {}", custom_template.settings.enhance.is_proteus);
println!(" Iris: {}", custom_template.settings.enhance.is_iris);
let custom_command = sdk.generate_ffmpeg_command(&custom_template, "input.mp4", "custom_output.mp4")?;
println!(" Command:");
println!(" {}", custom_command);
// Example 7: AI Engine Comparison
println!("\n7. AI Engine Comparison for Same Content:");
let base_params = (25, 20, 10); // denoise, detail, sharpen
// Create templates with different AI engines
let artemis_comp = TemplateBuilder::new("Artemis Comparison")
.enable_enhancement("prob-4")
.enhancement_params(base_params.0, base_params.1, base_params.2)
.ai_engine("artemis")
.build()?;
let gaia_comp = TemplateBuilder::new("Gaia Comparison")
.enable_enhancement("prob-4")
.enhancement_params(base_params.0, base_params.1, base_params.2)
.ai_engine("gaia")
.build()?;
let theia_comp = TemplateBuilder::new("Theia Comparison")
.enable_enhancement("prob-4")
.enhancement_params(base_params.0, base_params.1, base_params.2)
.ai_engine("theia")
.build()?;
let artemis_cmd = sdk.generate_ffmpeg_command(&artemis_comp, "test.mp4", "test_artemis.mp4")?;
let gaia_cmd = sdk.generate_ffmpeg_command(&gaia_comp, "test.mp4", "test_gaia.mp4")?;
let theia_cmd = sdk.generate_ffmpeg_command(&theia_comp, "test.mp4", "test_theia.mp4")?;
println!(" Artemis (Animation optimized):");
println!(" {}", artemis_cmd);
println!("\n Gaia (Natural scenes optimized):");
println!(" {}", gaia_cmd);
println!("\n Theia (Detail recovery optimized):");
println!(" {}", theia_cmd);
println!("\n✅ AI Engines demo completed successfully!");
println!("\nAI Engine Summary:");
println!(" 🎨 Artemis - Best for animation, cartoons, and stylized content");
println!(" 🌿 Gaia - Best for natural scenes, landscapes, and organic content");
println!(" 🔍 Theia - Best for detail recovery, sharpening, and restoration");
println!(" 🌟 Proteus - General purpose, works well with most real-world content");
println!(" 🌙 Iris - Best for low light, noisy, and challenging footage");
println!("\nFeatures Demonstrated:");
println!(" • AI engine flag management");
println!(" • Engine-specific parameter optimization");
println!(" • Focus fix level configuration");
println!(" • Second enhancement with intermediate resolution");
println!(" • Model-specific FFmpeg parameter generation");
Ok(())
}