feat: add P-H3-Image generation and editing support (#2272)

This commit is contained in:
leejet authored and GitHub committed 2026-11-04 23:24:51 +08:00
1 parent 984eb0686c
commit 3e92bf990a
18 files changed
+421 -41

No files matched your search

+11 -1
View File
@@ -110,7 +110,7 @@ namespace sd::model_builders {
return false;
}
bool build_vae_runners(const Context& ctx, const VAEOptions& options, VAERunners& runners) {
bool build_vae_runners(const Context& ctx, const VAEOptions& options, VAERunners& runners) try {
const auto* sd_ctx_params = &ctx.params;
const auto& tensor_storage_map = ctx.tensor_storage_map;
const auto version = ctx.version;
@@ -159,6 +159,13 @@ namespace sd::model_builders {
version,
weight_manager);
} else if (find_model_traits(vae_version)->vae_kind == ModelVAEKind::MINIMAX_H3) {
if (version == VERSION_P_H3_IMAGE) {
// The video VAE also loads successfully, but uses different temporal decoding and posterior sampling.
auto proj = tensor_storage_map.find("first_stage_model.decoder.proj_out.weight");
if (proj == tensor_storage_map.end() || proj->second.ne[1] != 768) {
throw std::runtime_error("P-H3-Image requires its single-frame VAE; pass --vae p-h3-image_vae_bf16.safetensors");
}
}
return std::make_shared<MiniMaxH3VAE::MiniMaxH3VideoVAERunner>(ctx.backends.runtime_backend(SDBackendModule::VAE),
tensor_storage_map,
"first_stage_model",
@@ -240,6 +247,9 @@ namespace sd::model_builders {
}
runners = std::move(result);
return true;
} catch (const std::exception& error) {
LOG_ERROR("failed to build VAE runners: %s", error.what());
return false;
}
bool build_control_net_runner(const Context& ctx, std::shared_ptr<ControlNet>& runner) {