fix(image): correct wan2.5/2.6 size presets and wanx-v1 dated aliases

This commit is contained in:
qcq01083097
2026-07-27 21:09:32 +08:00
parent c4f5bb09c6
commit 58252911a8
4 changed files with 25 additions and 5 deletions
+7 -2
View File
@@ -83,12 +83,17 @@ function isSyncEditModel(model: string): boolean {
return startsWithAny(model, SYNC_EDIT_PREFIXES);
}
/** wanx-v1 and dated aliases (e.g. wanx-v1-0521) use the legacy text2image API. */
function isWanxV1Model(model: string): boolean {
return /^wanx-v1(?:-|$)/i.test(model);
}
/** wan2.5 / wan2.2 / wan2.1 / wanx text-to-image models use the legacy prompt API. */
export function isLegacyText2ImageModel(model: string): boolean {
if (model.startsWith("wan2.6-t2i") || model.startsWith("wan2.6-image")) return false;
if (isSyncGenerateModel(model)) return false;
if (/^wan2\.[0-5][^-]*-t2i/i.test(model)) return true;
if (/^wanx-v1$/i.test(model)) return true;
if (isWanxV1Model(model)) return true;
if (/^wanx/i.test(model) && /t2i|text2image/i.test(model)) return true;
return false;
}
@@ -120,7 +125,7 @@ export function resolveImageSizeProfile(model: string): ImageSizeProfile {
) {
return "wan26";
}
if (/^wanx-v1$/i.test(model)) return "wanx-v1";
if (isWanxV1Model(model)) return "wanx-v1";
if (/wan2\.5-i2i/i.test(model)) return "wan25-i2i";
if (isLegacyText2ImageModel(model)) return "wan-legacy";
return "wan26";
+9
View File
@@ -27,6 +27,7 @@ test("legacy text2image covers wan2.5/2.2/2.1 t2i and wanx but not wan2.6-t2i/im
expect(isLegacyText2ImageModel("wan2.1-t2i-turbo")).toBe(true);
expect(isLegacyText2ImageModel("wanx2.0-t2i-turbo")).toBe(true);
expect(isLegacyText2ImageModel("wanx-v1")).toBe(true);
expect(isLegacyText2ImageModel("wanx-v1-0521")).toBe(true);
expect(isLegacyText2ImageModel("wan2.6-t2i")).toBe(false);
expect(isLegacyText2ImageModel("wan2.6-image")).toBe(false);
expect(isLegacyText2ImageModel("wan2.7-image")).toBe(false);
@@ -48,6 +49,7 @@ test("size profiles are model-specific, not sync/async", () => {
expect(resolveImageSizeProfile("z-image-turbo")).toBe("z-image");
expect(resolveImageSizeProfile("wan2.6-t2i")).toBe("wan26");
expect(resolveImageSizeProfile("wanx-v1")).toBe("wanx-v1");
expect(resolveImageSizeProfile("wanx-v1-0521")).toBe("wanx-v1");
expect(resolveImageSizeProfile("wan2.5-i2i-preview")).toBe("wan25-i2i");
expect(resolveImageSizeProfile("wan2.2-t2i-plus")).toBe("wan-legacy");
});
@@ -72,6 +74,13 @@ test("resolveImageGenerateApi picks path, input style, and size profile", () =>
sizeProfile: "wanx-v1",
inputStyle: "prompt",
});
expect(resolveImageGenerateApi("wanx-v1-0521")).toMatchObject({
kind: "async-text2image",
path: "/api/v1/services/aigc/text2image/image-synthesis",
inputStyle: "prompt",
useSync: false,
sizeProfile: "wanx-v1",
});
expect(resolveImageGenerateApi("wan2.6-t2i")).toMatchObject({
kind: "async-image-generation",
sizeProfile: "wan26",
+3 -3
View File
@@ -46,11 +46,11 @@ export const Z_IMAGE_RATIO_MAP: Record<string, string> = {
"2:3": "832*1248",
};
/** wan2.6-t2i / wan2.6-image / wan2.5-t2i — ~1280 class. */
/** wan2.6-t2i / wan2.6-image / wan2.5-t2i — total pixels ≥ 1280*1280. */
export const WAN26_RATIO_MAP: Record<string, string> = {
"1:1": "1280*1280",
"16:9": "1280*720",
"9:16": "720*1280",
"16:9": "1696*960",
"9:16": "960*1696",
"4:3": "1472*1104",
"3:4": "1104*1472",
};
@@ -15,6 +15,12 @@ test("wanx-v1 profile maps 1:1 to 1024*1024", () => {
expect(resolveImageSize("16:9", "wanx-v1")).toBe("1280*720");
});
test("wan26 profile maps 16:9 and 9:16 to ≥1280*1280 total pixels", () => {
expect(resolveImageSize("16:9", "wan26")).toBe("1696*960");
expect(resolveImageSize("9:16", "wan26")).toBe("960*1696");
expect(resolveImageSize("1:1", "wan26")).toBe("1280*1280");
});
test("wan2.5-i2i profile maps 1:1 to 1280*1280", () => {
expect(resolveImageSize("1:1", "wan25-i2i")).toBe("1280*1280");
});