Skip to content

Commit 5825291

Browse files
committed
fix(image): correct wan2.5/2.6 size presets and wanx-v1 dated aliases
1 parent c4f5bb0 commit 5825291

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

packages/core/src/client/image-routes.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,17 @@ function isSyncEditModel(model: string): boolean {
8383
return startsWithAny(model, SYNC_EDIT_PREFIXES);
8484
}
8585

86+
/** wanx-v1 and dated aliases (e.g. wanx-v1-0521) use the legacy text2image API. */
87+
function isWanxV1Model(model: string): boolean {
88+
return /^wanx-v1(?:-|$)/i.test(model);
89+
}
90+
8691
/** wan2.5 / wan2.2 / wan2.1 / wanx text-to-image models use the legacy prompt API. */
8792
export function isLegacyText2ImageModel(model: string): boolean {
8893
if (model.startsWith("wan2.6-t2i") || model.startsWith("wan2.6-image")) return false;
8994
if (isSyncGenerateModel(model)) return false;
9095
if (/^wan2\.[0-5][^-]*-t2i/i.test(model)) return true;
91-
if (/^wanx-v1$/i.test(model)) return true;
96+
if (isWanxV1Model(model)) return true;
9297
if (/^wanx/i.test(model) && /t2i|text2image/i.test(model)) return true;
9398
return false;
9499
}
@@ -120,7 +125,7 @@ export function resolveImageSizeProfile(model: string): ImageSizeProfile {
120125
) {
121126
return "wan26";
122127
}
123-
if (/^wanx-v1$/i.test(model)) return "wanx-v1";
128+
if (isWanxV1Model(model)) return "wanx-v1";
124129
if (/wan2\.5-i2i/i.test(model)) return "wan25-i2i";
125130
if (isLegacyText2ImageModel(model)) return "wan-legacy";
126131
return "wan26";

packages/core/tests/image-routes.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ test("legacy text2image covers wan2.5/2.2/2.1 t2i and wanx but not wan2.6-t2i/im
2727
expect(isLegacyText2ImageModel("wan2.1-t2i-turbo")).toBe(true);
2828
expect(isLegacyText2ImageModel("wanx2.0-t2i-turbo")).toBe(true);
2929
expect(isLegacyText2ImageModel("wanx-v1")).toBe(true);
30+
expect(isLegacyText2ImageModel("wanx-v1-0521")).toBe(true);
3031
expect(isLegacyText2ImageModel("wan2.6-t2i")).toBe(false);
3132
expect(isLegacyText2ImageModel("wan2.6-image")).toBe(false);
3233
expect(isLegacyText2ImageModel("wan2.7-image")).toBe(false);
@@ -48,6 +49,7 @@ test("size profiles are model-specific, not sync/async", () => {
4849
expect(resolveImageSizeProfile("z-image-turbo")).toBe("z-image");
4950
expect(resolveImageSizeProfile("wan2.6-t2i")).toBe("wan26");
5051
expect(resolveImageSizeProfile("wanx-v1")).toBe("wanx-v1");
52+
expect(resolveImageSizeProfile("wanx-v1-0521")).toBe("wanx-v1");
5153
expect(resolveImageSizeProfile("wan2.5-i2i-preview")).toBe("wan25-i2i");
5254
expect(resolveImageSizeProfile("wan2.2-t2i-plus")).toBe("wan-legacy");
5355
});
@@ -72,6 +74,13 @@ test("resolveImageGenerateApi picks path, input style, and size profile", () =>
7274
sizeProfile: "wanx-v1",
7375
inputStyle: "prompt",
7476
});
77+
expect(resolveImageGenerateApi("wanx-v1-0521")).toMatchObject({
78+
kind: "async-text2image",
79+
path: "/api/v1/services/aigc/text2image/image-synthesis",
80+
inputStyle: "prompt",
81+
useSync: false,
82+
sizeProfile: "wanx-v1",
83+
});
7584
expect(resolveImageGenerateApi("wan2.6-t2i")).toMatchObject({
7685
kind: "async-image-generation",
7786
sizeProfile: "wan26",

packages/runtime/src/utils/image-size.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export const Z_IMAGE_RATIO_MAP: Record<string, string> = {
4646
"2:3": "832*1248",
4747
};
4848

49-
/** wan2.6-t2i / wan2.6-image / wan2.5-t2i — ~1280 class. */
49+
/** wan2.6-t2i / wan2.6-image / wan2.5-t2i — total pixels ≥ 1280*1280. */
5050
export const WAN26_RATIO_MAP: Record<string, string> = {
5151
"1:1": "1280*1280",
52-
"16:9": "1280*720",
53-
"9:16": "720*1280",
52+
"16:9": "1696*960",
53+
"9:16": "960*1696",
5454
"4:3": "1472*1104",
5555
"3:4": "1104*1472",
5656
};

packages/runtime/tests/image-size.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ test("wanx-v1 profile maps 1:1 to 1024*1024", () => {
1515
expect(resolveImageSize("16:9", "wanx-v1")).toBe("1280*720");
1616
});
1717

18+
test("wan26 profile maps 16:9 and 9:16 to ≥1280*1280 total pixels", () => {
19+
expect(resolveImageSize("16:9", "wan26")).toBe("1696*960");
20+
expect(resolveImageSize("9:16", "wan26")).toBe("960*1696");
21+
expect(resolveImageSize("1:1", "wan26")).toBe("1280*1280");
22+
});
23+
1824
test("wan2.5-i2i profile maps 1:1 to 1280*1280", () => {
1925
expect(resolveImageSize("1:1", "wan25-i2i")).toBe("1280*1280");
2026
});

0 commit comments

Comments
 (0)