| 648 | } |
| 649 | |
| 650 | async fn run_worker(ctx: &mut Context) -> Result<()> { |
| 651 | match ctx.args.model_type { |
| 652 | ModelType::TextModel => { |
| 653 | cake_core::dispatch_text_model!(ctx.text_model_arch, ctx, Worker) |
| 654 | } |
| 655 | ModelType::ImageModel => match ctx.args.image_model_arch { |
| 656 | ImageModelArch::SD => { |
| 657 | Worker::<cake_core::models::sd::SD>::new(ctx) |
| 658 | .await? |
| 659 | .run() |
| 660 | .await |
| 661 | } |
| 662 | #[cfg(feature = "flux")] |
| 663 | ImageModelArch::Flux => { |
| 664 | Worker::<cake_core::models::flux::FluxGen>::new(ctx) |
| 665 | .await? |
| 666 | .run() |
| 667 | .await |
| 668 | } |
| 669 | #[cfg(feature = "flux")] |
| 670 | ImageModelArch::Flux1 => { |
| 671 | Worker::<cake_core::models::flux::Flux1Gen>::new(ctx) |
| 672 | .await? |
| 673 | .run() |
| 674 | .await |
| 675 | } |
| 676 | #[allow(unreachable_patterns)] |
| 677 | _ => anyhow::bail!( |
| 678 | "no image model feature enabled for architecture {:?}", |
| 679 | ctx.args.image_model_arch |
| 680 | ), |
| 681 | } |
| 682 | ModelType::AudioModel => { |
| 683 | // VibeVoice LM layers are standard Transformer blocks — use Qwen2 worker |
| 684 | // (Transformer::load is architecture-agnostic, works for any model's layers) |
| 685 | #[cfg(feature = "qwen2")] |
| 686 | { |
| 687 | Worker::<cake_core::models::qwen2::Qwen2>::new(ctx) |
| 688 | .await? |
| 689 | .run() |
| 690 | .await |
| 691 | } |
| 692 | #[cfg(not(feature = "qwen2"))] |
| 693 | anyhow::bail!("AudioModel workers require the qwen2 feature") |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | /// Resolve a model path, downloading from HuggingFace if it looks like a repo ID. |
| 699 | fn resolve_model_path(model: &str) -> Result<PathBuf> { |