Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(video): Wan 2.2 TI2V-5B - one model for faithful T2V AND I2V, in-app install

purple8d5a43391fa6
diff --git a/src/api/__tests__/app-wide-smoke.test.ts b/src/api/__tests__/app-wide-smoke.test.ts
index a8074dbc..29ad6f37 100644
--- a/src/api/__tests__/app-wide-smoke.test.ts
+++ b/src/api/__tests__/app-wide-smoke.test.ts
@@ -48,7 +48,7 @@ function fullNodes(): CategorizedNodes {
'EmptyLatentImage', 'EmptySD3LatentImage', 'EmptyFlux2LatentImage',
'EmptyHunyuanLatentVideo', 'EmptyLTXVLatentVideo',
'EmptyMochiLatentVideo', 'EmptyCosmosLatentVideo',
- 'CogVideoXEmptyLatents',
+ 'CogVideoXEmptyLatents', 'Wan22ImageToVideoLatent',
],
textEncoders: ['CLIPTextEncode', 'ConditioningZeroOut', 'CogVideoXTextEncode', 'PyramidFlowTextEncode', 'AllegroTextEncode'],
decoders: ['VAEDecode', 'CogVideoXVAEDecode', 'PyramidFlowDecode', 'AllegroDecoder'],
diff --git a/src/api/__tests__/comfyui-bundles.test.ts b/src/api/__tests__/comfyui-bundles.test.ts
index f6247f30..db6246f3 100644
--- a/src/api/__tests__/comfyui-bundles.test.ts
+++ b/src/api/__tests__/comfyui-bundles.test.ts
@@ -7,9 +7,10 @@ describe('Video Bundle Definitions', () => {
bundles = getVideoBundles()
})
- it('has 13 video bundles', () => {
- // 14 original - Allegro (diffusers only) + CogVideoX 2B replaced by 5B I2V
- expect(bundles.length).toBe(13)
+ it('has 14 video bundles', () => {
+ // 14 original - Allegro (diffusers only) + CogVideoX 2B replaced by 5B I2V,
+ // + Wan 2.2 TI2V-5B (unified T2V/I2V, 2026-06-11)
+ expect(bundles.length).toBe(14)
})
it('every bundle has required fields', () => {
@@ -64,10 +65,11 @@ describe('Video Bundle Definitions', () => {
it('I2V bundles have i2v: true', () => {
const i2vBundles = bundles.filter(b => b.i2v)
- expect(i2vBundles.length).toBe(3) // SVD + FramePack + CogVideoX 5B I2V
+ expect(i2vBundles.length).toBe(4) // SVD + FramePack + CogVideoX 5B I2V + Wan 2.2 TI2V-5B
const i2vNames = i2vBundles.map(b => b.name)
expect(i2vNames.some(n => n.includes('SVD'))).toBe(true)
expect(i2vNames.some(n => n.includes('FramePack'))).toBe(true)
+ expect(i2vNames.some(n => n.includes('Wan 2.2'))).toBe(true)
})
it('LTX bundle has workflow "ltx" not "wan"', () => {
@@ -77,7 +79,7 @@ describe('Video Bundle Definitions', () => {
})
it('every workflow type is a known strategy', () => {
- const knownWorkflows = ['wan', 'hunyuan', 'ltx', 'animatediff', 'cogvideo', 'framepack',
+ const knownWorkflows = ['wan', 'wan22', 'hunyuan', 'ltx', 'animatediff', 'cogvideo', 'framepack',
'svd', 'mochi', 'cosmos', 'pyramidflow', 'allegro']
for (const b of bundles) {
expect(knownWorkflows).toContain(b.workflow)
diff --git a/src/api/__tests__/comfyui-integration.test.ts b/src/api/__tests__/comfyui-integration.test.ts
index 24dfe019..e6aae1d9 100644
--- a/src/api/__tests__/comfyui-integration.test.ts
+++ b/src/api/__tests__/comfyui-integration.test.ts
@@ -28,7 +28,7 @@ function allNodesAvailable(): CategorizedNodes {
'EmptyLatentImage', 'EmptySD3LatentImage', 'EmptyFlux2LatentImage',
'EmptyHunyuanLatentVideo', 'EmptyLTXVLatentVideo',
'EmptyMochiLatentVideo', 'EmptyCosmosLatentVideo',
- 'CogVideoXEmptyLatents',
+ 'CogVideoXEmptyLatents', 'Wan22ImageToVideoLatent',
],
textEncoders: ['CLIPTextEncode', 'CogVideoXTextEncode', 'PyramidFlowTextEncode', 'AllegroTextEncode'],
decoders: ['VAEDecode', 'CogVideoXVAEDecode', 'PyramidFlowDecode', 'AllegroDecoder'],
@@ -60,7 +60,7 @@ describe('Full Pipeline: Bundle → Strategy for all 14 video bundles', () => {
// 3. Map workflow to ModelType for strategy detection
const workflowToModelType: Record<string, string> = {
- wan: 'wan', hunyuan: 'hunyuan', ltx: 'ltx', animatediff: 'sd15',
+ wan: 'wan', wan22: 'wan22', hunyuan: 'hunyuan', ltx: 'ltx', animatediff: 'sd15',
cogvideo: 'cogvideo', framepack: 'framepack', svd: 'svd',
mochi: 'mochi', cosmos: 'cosmos', pyramidflow: 'pyramidflow', allegro: 'allegro',
}
@@ -78,7 +78,7 @@ describe('Bundle consistency checks', () => {
const bundles = getVideoBundles()
it('all video bundle workflows map to video model types', () => {
- const videoWorkflows = ['wan', 'hunyuan', 'ltx', 'animatediff', 'cogvideo', 'framepack', 'svd', 'mochi', 'cosmos', 'pyramidflow', 'allegro']
+ const videoWorkflows = ['wan', 'wan22', 'hunyuan', 'ltx', 'animatediff', 'cogvideo', 'framepack', 'svd', 'mochi', 'cosmos', 'pyramidflow', 'allegro']
for (const b of bundles) {
expect(videoWorkflows).toContain(b.workflow)
}
@@ -98,7 +98,7 @@ describe('Bundle consistency checks', () => {
it('native bundles (no customNodes) use native ComfyUI strategies', () => {
const nativeBundles = bundles.filter(b => !b.customNodes || b.customNodes.length === 0)
- const nativeWorkflows = ['wan', 'hunyuan', 'ltx', 'svd', 'mochi', 'cosmos']
+ const nativeWorkflows = ['wan', 'wan22', 'hunyuan', 'ltx', 'svd', 'mochi', 'cosmos']
for (const b of nativeBundles) {
expect(nativeWorkflows).toContain(b.workflow)
}
@@ -124,6 +124,7 @@ describe('Model filename classification consistency', () => {
// For each bundle, the main model file should classify to the right type
const workflowToExpectedClassification: Record<string, string[]> = {
wan: ['wan'],
+ wan22: ['wan22'],
hunyuan: ['hunyuan'],
ltx: ['ltx'],
mochi: ['mochi'],
diff --git a/src/api/__tests__/wan22-workflow.test.ts b/src/api/__tests__/wan22-workflow.test.ts
new file mode 100644
index 00000000..faa44637
--- /dev/null
+++ b/src/api/__tests__/wan22-workflow.test.ts
@@ -0,0 +1,200 @@
+/**
+ * Wan 2.2 TI2V-5B — unified text+image-to-video (David 2026-06-11: "wan 2.2
+ * komplett in app … dann ausgiebig testen").
+ *
+ * Wan 2.2 5B is ONE model that does both T2V and I2V via Wan22ImageToVideoLatent
+ * (an OPTIONAL start_image switches the mode). It needs its own VAE (wan2.2_vae —
+ * higher compression than 2.1) and the shared UMT5 text encoder. These tests pin:
+ * - classification / dual-capability routing (classifyModel, isI2VModel, isT2VCapable)
+ * - the strategy gate (needs the Wan22ImageToVideoLatent node)
+ * - the built graph for BOTH modes (start_image only on I2V; faithful ImageScale)
+ * - the length grid (4k+1) and the I2V resolution picker
+ *
+ * Run: npx vitest run src/api/__tests__/wan22-workflow.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+vi.mock('../comfyui-nodes', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../comfyui-nodes')>()
+ return { ...actual, getAllNodeInfo: vi.fn() }
+})
+
+import { buildDynamicWorkflow, determineStrategy, snapWanLength } from '../dynamic-workflow'
+import { categorizeNodes, getAllNodeInfo, type CategorizedNodes } from '../comfyui-nodes'
+import { classifyModel, isI2VModel, isT2VCapable } from '../comfyui'
+import { resolveI2VResolution } from '../vram-handoff'
+
+// Minimal /object_info for a ComfyUI that can run Wan 2.2 5B.
+const WAN22_NODES = {
+ UNETLoader: { input: { required: { unet_name: [['wan2.2_ti2v_5B_fp16.safetensors']] } } },
+ CLIPLoader: { input: { required: { clip_name: [['umt5_xxl_fp8_e4m3fn_scaled.safetensors']] } } },
+ VAELoader: { input: { required: { vae_name: [['wan2.2_vae.safetensors']] } } },
+ Wan22ImageToVideoLatent: { input: { required: { vae: ['VAE'], width: ['INT'], height: ['INT'], length: ['INT'], batch_size: ['INT'] }, optional: { start_image: ['IMAGE', {}] } } },
+ ModelSamplingSD3: { input: { required: { model: ['MODEL'], shift: ['FLOAT'] } } },
+ KSampler: { input: { required: {} } },
+ CLIPTextEncode: { input: { required: {} } },
+ VAEDecode: { input: { required: {} } },
+ ImageScale: { input: { required: {} } },
+ LoadImage: { input: { required: {} } },
+ VHS_VideoCombine: { input: { required: {} } },
+}
+
+const wan22Params = {
+ model: 'wan2.2_ti2v_5B_fp16.safetensors',
+ prompt: 'a red apple on a white plate', negativePrompt: '',
+ sampler: 'euler', scheduler: 'simple',
+ steps: 30, cfgScale: 5, width: 1024, height: 576, seed: 42, batchSize: 1,
+ frames: 49, fps: 24,
+}
+
+type WfNode = { class_type: string; inputs: Record<string, any> }
+const nodeOf = (wf: Record<string, any>, klass: string): [string, WfNode] | undefined =>
+ (Object.entries(wf) as [string, WfNode][]).find(([, n]) => n.class_type === klass)
+const nodesOf = (wf: Record<string, any>, klass: string): [string, WfNode][] =>
+ (Object.entries(wf) as [string, WfNode][]).filter(([, n]) => n.class_type === klass)
+
+describe('classifyModel — Wan 2.2 vs 2.1', () => {
+ it('classifies the TI2V-5B file as wan22', () => {
+ expect(classifyModel('wan2.2_ti2v_5B_fp16.safetensors')).toBe('wan22')
+ })
+ it('matches the various 2.2 spellings', () => {
+ expect(classifyModel('Wan2.2-TI2V-5B.safetensors')).toBe('wan22')
+ expect(classifyModel('wan2_2_ti2v_5b.gguf')).toBe('wan22')
+ expect(classifyModel('wan22_5b_q8.gguf')).toBe('wan22')
+ })
+ it('does NOT misfire on Wan 2.1 (regression guard)', () => {
+ expect(classifyModel('wan2.1_t2v_1.3B_bf16.safetensors')).toBe('wan')
+ expect(classifyModel('wan2.1_t2v_14B_fp8.safetensors')).toBe('wan')
+ })
+})
+
+describe('dual-capability predicates', () => {
+ it('Wan 2.2 is BOTH I2V-capable and T2V-capable', () => {
+ const f = 'wan2.2_ti2v_5B_fp16.safetensors'
+ expect(isI2VModel(f)).toBe(true) // shows up in the I2V picker list
+ expect(isT2VCapable(f)).toBe(true) // AND stays in the T2V picker list
+ })
+ it('Wan 2.1 is T2V-only (not an I2V model)', () => {
+ expect(isI2VModel('wan2.1_t2v_14B_fp8.safetensors')).toBe(false)
+ expect(isT2VCapable('wan2.1_t2v_14B_fp8.safetensors')).toBe(true)
+ })
+ it('SVD / FramePack stay I2V-ONLY (excluded from T2V)', () => {
+ expect(isT2VCapable('svd_xt_1_1.safetensors')).toBe(false)
+ expect(isT2VCapable('FramePackI2V_HY_fp8_e4m3fn.safetensors')).toBe(false)
+ })
+})
+
+describe('snapWanLength — 4k+1 grid (Wan 2.2 VAE temporal stride 4)', () => {
+ it('snaps common durations at 24 fps to the nearest valid length', () => {
+ expect(snapWanLength(48)).toBe(49) // 2 s
+ expect(snapWanLength(72)).toBe(73) // 3 s
+ expect(snapWanLength(120)).toBe(121) // 5 s
+ expect(snapWanLength(168)).toBe(169) // 7 s
+ })
+ it('already-valid lengths pass through; tiny values floor to 5', () => {
+ expect(snapWanLength(49)).toBe(49)
+ expect(snapWanLength(1)).toBe(5)
+ expect(snapWanLength(0)).toBe(5)
+ })
+ it('every result satisfies (length - 1) % 4 === 0', () => {
+ for (const f of [13, 30, 47, 50, 99, 150, 200]) {
+ expect((snapWanLength(f) - 1) % 4).toBe(0)
+ }
+ })
+})
+
+describe('determineStrategy — wan22 gate', () => {
+ const full: CategorizedNodes = categorizeNodes(WAN22_NODES as never)
+ const models = { checkpoints: [], unets: [], vaes: [], clips: [], loras: [], controlnets: [], ipadapters: [], motionModels: [] }
+
+ it('routes to wan22 when UNET + CLIP + VAE + Wan22ImageToVideoLatent are present', () => {
+ const r = determineStrategy('wan22', true, full, models as never)
+ expect(r.strategy).toBe('wan22')
+ })
+ it('is unavailable (with an update hint) when the Wan 2.2 latent node is missing', () => {
+ const noLatent: CategorizedNodes = { ...full, latentInit: full.latentInit.filter(n => n !== 'Wan22ImageToVideoLatent') }
+ const r = determineStrategy('wan22', true, noLatent, models as never)
+ expect(r.strategy).toBe('unavailable')
+ expect(r.reason).toMatch(/Wan22ImageToVideoLatent|Update ComfyUI/i)
+ })
+})
+
+describe('buildDynamicWorkflow — Wan 2.2 graph', () => {
+ beforeEach(() => {
+ vi.mocked(getAllNodeInfo).mockResolvedValue(WAN22_NODES as never)
+ })
+
+ it('T2V (no inputImage): Wan22 latent has NO start_image, uses the 2.2 VAE + UMT5', async () => {
+ const wf = await buildDynamicWorkflow({ ...wan22Params } as never)
+
+ const latent = nodeOf(wf, 'Wan22ImageToVideoLatent')!
+ expect(latent).toBeDefined()
+ expect(latent[1].inputs.start_image).toBeUndefined() // T2V: no still
+ expect(latent[1].inputs.length).toBe(49)
+ expect(latent[1].inputs.batch_size).toBe(1)
+
+ const vae = nodeOf(wf, 'VAELoader')!
+ expect(vae[1].inputs.vae_name).toBe('wan2.2_vae.safetensors')
+ const clip = nodeOf(wf, 'CLIPLoader')!
+ expect(clip[1].inputs.clip_name).toBe('umt5_xxl_fp8_e4m3fn_scaled.safetensors')
+ expect(clip[1].inputs.type).toBe('wan')
+
+ // No image nodes on the T2V path.
+ expect(nodeOf(wf, 'LoadImage')).toBeUndefined()
+ expect(nodeOf(wf, 'ImageScale')).toBeUndefined()
+ })
+
+ it('T2V wires the sampler through ModelSamplingSD3 (Wan shift)', async () => {
+ const wf = await buildDynamicWorkflow({ ...wan22Params } as never)
+ const [shiftId, shift] = nodeOf(wf, 'ModelSamplingSD3')!
+ expect(shift.inputs.shift).toBe(8.0)
+ const [unetId] = nodeOf(wf, 'UNETLoader')!
+ expect(shift.inputs.model).toEqual([unetId, 0])
+ const sampler = nodeOf(wf, 'KSampler')![1]
+ expect(sampler.inputs.model).toEqual([shiftId, 0]) // sampler reads the shifted model
+ })
+
+ it('I2V (inputImage set): LoadImage → ImageScale(crop center) → Wan22 start_image', async () => {
+ const wf = await buildDynamicWorkflow({ ...wan22Params, inputImage: 'lu_apple_input.png' } as never)
+
+ const load = nodeOf(wf, 'LoadImage')!
+ expect(load[1].inputs.image).toBe('lu_apple_input.png')
+ const [scaleId, scale] = nodeOf(wf, 'ImageScale')!
+ expect(scale.inputs.crop).toBe('center') // aspect-fill, no squish
+ expect(scale.inputs.image).toEqual([load[0], 0])
+
+ const latent = nodeOf(wf, 'Wan22ImageToVideoLatent')![1]
+ expect(latent.inputs.start_image).toEqual([scaleId, 0]) // the still drives the opening frame
+ })
+
+ it('snaps off-grid duration + dims (120 frames → 121, 1000×570 → /32)', async () => {
+ const wf = await buildDynamicWorkflow({ ...wan22Params, frames: 120, width: 1000, height: 570 } as never)
+ const latent = nodeOf(wf, 'Wan22ImageToVideoLatent')![1]
+ expect(latent.inputs.length).toBe(121)
+ expect(latent.inputs.width % 32).toBe(0)
+ expect(latent.inputs.height % 32).toBe(0)
+ })
+
+ it('produces a video output node (VHS preferred when present)', async () => {
+ const wf = await buildDynamicWorkflow({ ...wan22Params } as never)
+ expect(nodesOf(wf, 'VHS_VideoCombine').length).toBe(1)
+ })
+})
+
+describe('resolveI2VResolution — wan22', () => {
+ it('landscape source keeps aspect, caps long edge at 1024, snaps to 32', () => {
+ const r = resolveI2VResolution('wan22', 1920, 1080)
+ expect(r.width).toBe(1024)
+ expect(r.height).toBe(576)
+ expect(r.width % 32).toBe(0)
+ expect(r.height % 32).toBe(0)
+ })
+ it('portrait source stays portrait', () => {
+ const r = resolveI2VResolution('wan22', 1080, 1920)
+ expect(r.height).toBeGreaterThan(r.width)
+ expect(r.height).toBe(1024)
+ })
+ it('unprobed (0×0) falls back to a 16:9 landscape default', () => {
+ expect(resolveI2VResolution('wan22', 0, 0)).toEqual({ width: 1024, height: 576 })
+ })
+})
diff --git a/src/api/comfyui-nodes.ts b/src/api/comfyui-nodes.ts
index c9721ab8..49f38416 100644
--- a/src/api/comfyui-nodes.ts
+++ b/src/api/comfyui-nodes.ts
@@ -125,6 +125,8 @@ export function categorizeNodes(allNodes: Record<string, NodeMetadata>): Categor
EmptyMochiLatentVideo: 'latentInit',
EmptyCosmosLatentVideo: 'latentInit',
CogVideoXEmptyLatents: 'latentInit',
+ // Wan 2.2 TI2V-5B unified latent (optional start_image → I2V, absent → T2V)
+ Wan22ImageToVideoLatent: 'latentInit',
// Conditioning
ConditioningZeroOut: 'textEncoders',
// Text encoding
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 19a800e2..5cf81d56 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -111,7 +111,7 @@ export function extractComfyOutputFiles(nodeOutput: unknown): ComfyUIOutput[] {
return found
}
-export type ModelType = 'flux' | 'flux2' | 'zimage' | 'ernie_image' | 'sdxl' | 'sd15' | 'wan' | 'hunyuan' | 'ltx' | 'mochi' | 'cosmos' | 'cogvideo' | 'svd' | 'framepack' | 'pyramidflow' | 'allegro' | 'unknown'
+export type ModelType = 'flux' | 'flux2' | 'zimage' | 'ernie_image' | 'sdxl' | 'sd15' | 'wan' | 'wan22' | 'hunyuan' | 'ltx' | 'mochi' | 'cosmos' | 'cogvideo' | 'svd' | 'framepack' | 'pyramidflow' | 'allegro' | 'unknown'
export type VideoBackend = 'wan' | 'animatediff' | 'none'
export interface ClassifiedModel {
@@ -155,6 +155,10 @@ export function classifyModel(name: string | null | undefined): ModelType {
if (lower.includes('allegro')) return 'allegro'
if (lower.includes('svd') || lower.includes('stable-video-diffusion')) return 'svd'
if (lower.includes('pyramid') && (lower.includes('flow') || lower.includes('dit'))) return 'pyramidflow'
+ // Wan 2.2 TI2V-5B — unified text+image-to-video. Detect BEFORE the generic Wan
+ // match: it needs its own latent node (Wan22ImageToVideoLatent), the Wan 2.2 VAE
+ // and the dual T2V/I2V path, none of which the Wan 2.1 'unet_video' strategy has.
+ if (lower.includes('ti2v') || lower.includes('wan2.2') || lower.includes('wan2_2') || lower.includes('wan22')) return 'wan22'
if (lower.includes('wan')) return 'wan'
if (lower.includes('hunyuan')) return 'hunyuan'
if (lower.includes('ltx')) return 'ltx'
@@ -190,14 +194,34 @@ export function isImageModelType(type: ModelType): boolean {
}
export function isVideoModelType(type: ModelType): boolean {
- return type === 'wan' || type === 'hunyuan' || type === 'ltx' || type === 'mochi' || type === 'cosmos'
+ return type === 'wan' || type === 'wan22' || type === 'hunyuan' || type === 'ltx' || type === 'mochi' || type === 'cosmos'
|| type === 'cogvideo' || type === 'svd' || type === 'framepack' || type === 'pyramidflow' || type === 'allegro'
}
-/** Check if a model filename is an Image-to-Video model (needs input image) */
+/**
+ * Can this model accept a source still (image-to-video)? True for explicit i2v
+ * tags, SVD, FramePack, and Wan 2.2 TI2V (which is dual T2V/I2V). Used to build
+ * the I2V picker list and to route an inputImage to the I2V branch.
+ */
export function isI2VModel(name: string): boolean {
const lower = name.toLowerCase()
return lower.includes('i2v') || lower.includes('svd') || lower.includes('framepack')
+ || lower.includes('ti2v') || lower.includes('wan2.2') || lower.includes('wan2_2') || lower.includes('wan22')
+}
+
+/**
+ * Can this model do TEXT-to-video (no source image required)? Everything EXCEPT
+ * the I2V-ONLY checkpoints: SVD and FramePack load via image-only/wrapper loaders,
+ * and a CogVideoX *I2V* checkpoint needs a still — none can run a T2V graph. Wan 2.2
+ * TI2V is dual-capable, so it stays in the T2V list too (the `ti2v`/`wan2.2` guard
+ * wins over the generic `i2v` substring). Keeps wan22 selectable for both modes.
+ */
+export function isT2VCapable(name: string): boolean {
+ const lower = name.toLowerCase()
+ if (lower.includes('ti2v') || lower.includes('wan2.2') || lower.includes('wan2_2') || lower.includes('wan22')) return true
+ if (lower.includes('svd') || lower.includes('framepack')) return false
+ if (lower.includes('i2v')) return false
+ return true
}
// ─── Default generation parameters per model type ───
@@ -215,6 +239,10 @@ export interface ModelTypeDefaults {
export const MODEL_TYPE_DEFAULTS: Record<string, ModelTypeDefaults> = {
wan: { steps: 30, cfg: 6.0, sampler: 'euler', scheduler: 'normal', width: 832, height: 480, frames: 81, fps: 16 },
+ // Wan 2.2 TI2V-5B — native 1280×704 @ 24 fps, unified T2V/I2V. Default to a
+ // VRAM-/speed-friendly 1024×576 16:9 on 12 GB cards (native res is still available
+ // by setting width/height); 49 frames ≈ 2 s, the duration matrix runs up to ~7 s.
+ wan22: { steps: 30, cfg: 5.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 576, frames: 49, fps: 24 },
hunyuan: { steps: 30, cfg: 6.0, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 45, fps: 24 },
ltx: { steps: 20, cfg: 3.0, sampler: 'euler', scheduler: 'normal', width: 768, height: 512, frames: 97, fps: 24 },
mochi: { steps: 30, cfg: 4.5, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 84, fps: 24 },
diff --git a/src/api/discover.ts b/src/api/discover.ts
index ff9afbce..1caa503a 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -318,6 +318,14 @@ export const COMPONENT_REGISTRY: Record<string, ComponentRequirements> = {
clip: { patterns: ['umt5', 'wan'], downloadName: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors', downloadUrl: 'https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors', subfolder: 'text_encoders' },
needsSeparateVAE: true, needsSeparateCLIP: true,
},
+ wan22: {
+ loader: 'UNETLoader',
+ // Wan 2.2 5B uses its OWN VAE (higher compression than 2.1). Prefer the 2.2 file;
+ // 'wan' fallback covers a 2.1 VAE only as a last resort. CLIP is the shared UMT5.
+ vae: { patterns: ['wan2.2', 'wan2_2'], downloadName: 'wan2.2_vae.safetensors', downloadUrl: 'https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/vae/wan2.2_vae.safetensors', subfolder: 'vae' },
+ clip: { patterns: ['umt5', 'wan'], downloadName: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors', downloadUrl: 'https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors', subfolder: 'text_encoders' },
+ needsSeparateVAE: true, needsSeparateCLIP: true,
+ },
hunyuan: {
loader: 'UNETLoader',
vae: { patterns: ['hunyuanvideo', 'hunyuan'], downloadName: 'hunyuanvideo15_vae_fp16.safetensors', downloadUrl: 'https://huggingface.co/Comfy-Org/HunyuanVideo_1.5_repackaged/resolve/main/split_files/vae/hunyuanvideo15_vae_fp16.safetensors', subfolder: 'vae' },
@@ -1332,6 +1340,42 @@ export function getVideoBundles(): ModelBundle[] {
},
],
},
+ {
+ name: 'Wan 2.2 — TI2V 5B (Image + Text to Video)',
+ description: 'Wan 2.2 TI2V-5B — ONE model for both text-to-video and faithful image-to-video (the clip opens on your source image). Native 1280×704 @ 24 fps, smooth 2–7 s clips. The best-quality video model that fits 12 GB.',
+ tags: ['Wan 2.2', '720p', 'I2V', 'T2V', 'Quality'],
+ uncensored: true,
+ verified: true,
+ i2v: true,
+ hot: true,
+ totalSizeGB: 16.9,
+ vramRequired: '12+ GB',
+ workflow: 'wan22',
+ url: 'https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged',
+ files: [
+ {
+ name: 'Wan 2.2 TI2V 5B Model (FP16)',
+ description: 'The unified text + image-to-video model.',
+ pulls: '', tags: ['Model', '~9.3 GB'], updated: 'New',
+ downloadUrl: 'https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_ti2v_5B_fp16.safetensors',
+ filename: 'wan2.2_ti2v_5B_fp16.safetensors', subfolder: 'diffusion_models', sizeGB: 9.3,
+ },
+ {
+ name: 'Wan 2.2 VAE',
+ description: 'Required video encoder/decoder — the 2.2 VAE (NOT the 2.1 VAE: higher compression, different latent shape).',
+ pulls: '', tags: ['VAE', '~1.3 GB'], updated: 'New',
+ downloadUrl: 'https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/vae/wan2.2_vae.safetensors',
+ filename: 'wan2.2_vae.safetensors', subfolder: 'vae', sizeGB: 1.3,
+ },
+ {
+ name: 'Wan CLIP (UMT5-XXL FP8)',
+ description: 'Required text encoder — shared with Wan 2.1, so it is skipped if already installed.',
+ pulls: '', tags: ['CLIP', '6.3 GB'], updated: '',
+ downloadUrl: 'https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors',
+ filename: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors', subfolder: 'text_encoders', sizeGB: 6.3,
+ },
+ ],
+ },
{
name: 'HunyuanVideo 1.5 T2V FP8 (High Quality)',
description: 'Tencent HunyuanVideo 1.5 — excellent temporal consistency and visual quality. 480p text-to-video with CFG distillation.',
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index 15031b2c..6bc2554e 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -45,6 +45,7 @@ export type WorkflowStrategy =
| 'unet_zimage' // Z-Image: UNETLoader + CLIPLoader(qwen_image) + VAELoader + EmptySD3LatentImage
| 'unet_ernie_image' // ERNIE-Image: UNETLoader + CLIPLoader(flux2) + VAELoader + EmptyFlux2LatentImage + ConditioningZeroOut
| 'unet_video' // Wan/Hunyuan: UNETLoader + CLIPLoader + VAELoader + EmptyHunyuanLatentVideo
+ | 'wan22' // Wan 2.2 TI2V-5B: UNET + CLIP + Wan 2.2 VAE + Wan22ImageToVideoLatent (unified T2V/I2V)
| 'unet_ltx' // LTX Video: UNETLoader + CLIPLoader + EmptyLTXVLatentVideo
| 'unet_mochi' // Mochi: UNETLoader + CLIPLoader + VAELoader + EmptyMochiLatentVideo
| 'unet_cosmos' // Cosmos: UNETLoader + CLIPLoader(oldt5) + VAELoader + EmptyCosmosLatentVideo
@@ -123,6 +124,18 @@ export function determineStrategy(
return { strategy: 'unavailable', reason: 'LTX Video requires UNETLoader + CLIPLoader nodes' }
}
+ // Wan 2.2 TI2V-5B → UNET + CLIP + Wan 2.2 VAE + Wan22ImageToVideoLatent (T2V & I2V)
+ if (modelType === 'wan22') {
+ const hasWan22Latent = nodes.latentInit.includes('Wan22ImageToVideoLatent')
+ if (hasUNET && hasCLIPLoader && hasVAELoader && hasWan22Latent) {
+ return { strategy: 'wan22', reason: 'Wan 2.2 TI2V-5B → UNETLoader + Wan22ImageToVideoLatent (unified T2V/I2V)' }
+ }
+ return {
+ strategy: 'unavailable',
+ reason: 'Wan 2.2 TI2V-5B needs the Wan22ImageToVideoLatent node (ComfyUI ≥ v0.3.46). Update ComfyUI, then try again.',
+ }
+ }
+
// Wan / Hunyuan → UNET-based with video latent
if (modelType === 'wan' || modelType === 'hunyuan') {
if (hasUNET && hasCLIPLoader && hasVAELoader) {
@@ -364,6 +377,9 @@ export async function buildDynamicWorkflow(
if (strategy === 'svd') {
return buildSVDWorkflow(params as VideoParams, seed, nodes)
}
+ if (strategy === 'wan22') {
+ return buildWan22Workflow(params as VideoParams, seed, nodes)
+ }
if (strategy === 'framepack') {
return buildFramePackWorkflow(params as VideoParams, seed, nodes)
}
@@ -923,6 +939,83 @@ function buildSVDWorkflow(params: VideoParams, seed: number, nodes: CategorizedN
return workflow
}
+/**
+ * Snap a frame count to Wan 2.2's length grid. The Wan 2.2 VAE has a temporal
+ * stride of 4, so `Wan22ImageToVideoLatent.length` must be 4k+1 (…45, 49, 53…).
+ * An off-grid length makes ComfyUI error or silently drop the tail frame.
+ * Exported + pure for the unit tests and the vram-handoff duration math.
+ */
+export function snapWanLength(frames: number): number {
+ const f = Number.isFinite(frames) ? Math.round(frames) : 49
+ const k = Math.max(1, Math.round((f - 1) / 4))
+ return k * 4 + 1
+}
+
+/**
+ * Wan 2.2 TI2V-5B — one model, both modes. `Wan22ImageToVideoLatent` takes an
+ * OPTIONAL `start_image`: present → image-to-video (the clip opens on the source
+ * still), absent → text-to-video. Uses the Wan 2.2 VAE (NOT the 2.1 VAE — the 2.2
+ * VAE has 16× spatial / 4× temporal compression, a different latent shape) and the
+ * shared UMT5-XXL text encoder. `ModelSamplingSD3` applies Wan's sampling shift.
+ *
+ * I2V faithfulness (David 2026-06-11): an `ImageScale(crop:center)` aspect-fills
+ * the source into the generation size, so the first frame matches the still
+ * instead of being squished — the same fix proven on the SVD path.
+ */
+function buildWan22Workflow(params: VideoParams, seed: number, nodes: CategorizedNodes): Record<string, any> {
+ const workflow: Record<string, any> = {}
+ let n = 1
+
+ // Wan 2.2 dims snap to 32 (VAE spatial grid); length to 4k+1 (temporal stride 4).
+ const snap32 = (v: number | undefined, def: number) => Math.max(64, Math.round(((v && v > 0) ? v : def) / 32) * 32)
+ const width = snap32(params.width, 1024)
+ const height = snap32(params.height, 576)
+ const length = snapWanLength(params.frames || 49)
+
+ const unetId = String(n++)
+ const clipId = String(n++)
+ const vaeId = String(n++)
+ const posId = String(n++)
+ const negId = String(n++)
+
+ workflow[unetId] = { class_type: 'UNETLoader', inputs: { unet_name: params.model, weight_dtype: 'default' } }
+ workflow[clipId] = { class_type: 'CLIPLoader', inputs: { clip_name: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors', type: 'wan', device: 'default' } }
+ workflow[vaeId] = { class_type: 'VAELoader', inputs: { vae_name: 'wan2.2_vae.safetensors' } }
+ workflow[posId] = { class_type: 'CLIPTextEncode', inputs: { text: params.prompt, clip: [clipId, 0] } }
+ workflow[negId] = { class_type: 'CLIPTextEncode', inputs: { text: params.negativePrompt || '', clip: [clipId, 0] } }
+
+ // Wan's recommended sampling shift. ModelSamplingSD3 is a core node (ships since
+ // SD3), so the sampler reads from it to match the official 5B workflow's motion.
+ const shiftId = String(n++)
+ workflow[shiftId] = { class_type: 'ModelSamplingSD3', inputs: { model: [unetId, 0], shift: 8.0 } }
+
+ // Unified latent: a start_image is attached ONLY for an I2V request.
+ const latentInputs: Record<string, any> = { vae: [vaeId, 0], width, height, length, batch_size: 1 }
+ if (params.inputImage) {
+ const imageId = String(n++)
+ const scaleId = String(n++)
+ workflow[imageId] = { class_type: 'LoadImage', inputs: { image: params.inputImage } }
+ workflow[scaleId] = { class_type: 'ImageScale', inputs: { image: [imageId, 0], upscale_method: 'lanczos', width, height, crop: 'center' } }
+ latentInputs.start_image = [scaleId, 0]
+ }
+ const latentId = String(n++)
+ workflow[latentId] = { class_type: 'Wan22ImageToVideoLatent', inputs: latentInputs }
+
+ const samplerId = String(n++)
+ workflow[samplerId] = {
+ class_type: 'KSampler',
+ inputs: {
+ model: [shiftId, 0], positive: [posId, 0], negative: [negId, 0], latent_image: [latentId, 0],
+ seed, steps: params.steps, cfg: params.cfgScale, sampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,
+ },
+ }
+ const decodeId = String(n++)
+ workflow[decodeId] = { class_type: 'VAEDecode', inputs: { samples: [samplerId, 0], vae: [vaeId, 0] } }
+
+ addVideoOutput(workflow, n, decodeId, params.fps, nodes, params.prompt)
+ return workflow
+}
+
function buildFramePackWorkflow(params: VideoParams, seed: number, nodes: CategorizedNodes): Record<string, any> {
const workflow: Record<string, any> = {}
let n = 1
diff --git a/src/api/vram-handoff.ts b/src/api/vram-handoff.ts
index 0bddac50..5ae161a0 100644
--- a/src/api/vram-handoff.ts
+++ b/src/api/vram-handoff.ts
@@ -59,6 +59,7 @@ import {
getImageUrl,
classifyModel,
isI2VModel,
+ isT2VCapable,
uploadImage,
buildTxt2VidWorkflow,
snapToVideoGrid,
@@ -590,11 +591,12 @@ async function runHandoff(kind: 'image' | 'video', args: VramHandoffArgs): Promi
}
videoBackend = backend
} else {
- // Text-to-video must NOT pick an image-to-video-only checkpoint (SVD /
+ // Text-to-video must NOT pick an image-to-video-ONLY checkpoint (SVD /
// FramePack) — those load via ImageOnlyCheckpointLoader, so feeding one
// into a Wan/UNet T2V workflow yields ComfyUI "UNETLoader: value not in
- // list" (gemma4 live, scenario 3c). Prefer a real T2V model.
- const t2vModels = models.filter((m) => !isI2VModel(m.name))
+ // list" (gemma4 live, scenario 3c). isT2VCapable keeps Wan 2.2 TI2V (dual
+ // T2V/I2V) in the list while still excluding the I2V-only checkpoints.
+ const t2vModels = models.filter((m) => isT2VCapable(m.name))
if (t2vModels.length === 0 || backend === 'none') {
emitHandoff('error', { kind, detail: 'no text-to-video model installed' })
return 'Error: No text-to-video model installed. Download one from Models → Discover (e.g. "Wan 2.1 — 1.3B (Lightweight)" for 8-10 GB VRAM or "HunyuanVideo 1.5 T2V FP8" for 12+ GB) — or generate an image first and animate it with an I2V model like "SVD-XT 1.1".'
@@ -887,6 +889,77 @@ async function generateVideo(
// Capability-aware (decision 2): real per-model limits/enums from ComfyUI.
const caps = await fetchCaps(model, 'video')
+ // ── Wan 2.2 TI2V-5B: one model, both modes ─────────────────────
+ // Wan22ImageToVideoLatent takes an OPTIONAL start_image, so a single dynamic
+ // path serves text-to-video (no still) AND image-to-video (still → the clip
+ // opens on it). Handle it HERE, before the SVD/FramePack I2V branch — wan22 now
+ // matches isI2VModel(), but that branch's 25-frame / 8-fps tuning would butcher
+ // it (wan22 is 24 fps, up to ~7 s). buildDynamicWorkflow routes to buildWan22.
+ if (type === 'wan22') {
+ const { buildDynamicWorkflow } = await import('./dynamic-workflow')
+ const d = MODEL_TYPE_DEFAULTS.wan22
+ const av = args as Record<string, unknown>
+
+ // Optional source still (I2V). A wrong/hallucinated name falls back to the
+ // last image LU produced this session — same recovery as the SVD path.
+ let inputImage: string | undefined
+ let srcW = 0
+ let srcH = 0
+ if (typeof args.inputImage === 'string' && args.inputImage) {
+ let resolved: ResolvedInputImage
+ try {
+ resolved = await resolveInputImage(args.inputImage)
+ } catch (e) {
+ if (_lastImageFilename) {
+ log.warn('vram_handoff.i2v_input_fallback', { bad: String(args.inputImage), fallback: _lastImageFilename })
+ resolved = await resolveInputImage(_lastImageFilename)
+ } else {
+ throw e
+ }
+ }
+ inputImage = resolved.name
+ srcW = resolved.width
+ srcH = resolved.height
+ }
+
+ const frameRej = videoFrameReject(model, args, caps)
+ if (frameRej) return frameRej
+ // 24 fps native; up to ~7 s (169 frames). resolveClip honors `seconds`/`frames`.
+ const vMax = caps?.frameRange?.max ?? 169
+ const { frames, fps } = resolveClip(args, { defFps: d.fps, defFrames: d.frames, maxFrames: vMax })
+ const tun = resolveTunables(args, caps, { steps: d.steps, cfg: d.cfg, sampler: d.sampler, scheduler: d.scheduler })
+ if (tun.reject) return `Cannot generate: ${tun.reject}`
+
+ // I2V → resolution from the source aspect (faithful framing); T2V → model default.
+ const base = inputImage ? resolveI2VResolution('wan22', srcW, srcH) : { width: d.width, height: d.height }
+ const snapped = snapToVideoGrid(clampInt(av.width, base.width, 64, 2048), clampInt(av.height, base.height, 64, 2048))
+ const seed = (typeof av.seed === 'number' && Number.isFinite(av.seed)) ? Math.floor(av.seed) : -1
+
+ const workflow = await buildDynamicWorkflow(
+ {
+ prompt,
+ negativePrompt: typeof args.negativePrompt === 'string' ? args.negativePrompt : '',
+ model,
+ sampler: tun.sampler,
+ scheduler: tun.scheduler,
+ steps: tun.steps,
+ cfgScale: tun.cfg,
+ width: snapped.width,
+ height: snapped.height,
+ seed,
+ batchSize: 1,
+ frames,
+ fps,
+ ...(inputImage ? { inputImage } : {}),
+ },
+ type,
+ )
+ log.info('vram_handoff.video.submit', { model, mode: inputImage ? 'i2v' : 't2v', wan22: true })
+ const promptId = await submitWorkflow(workflow)
+ log.info('vram_handoff.video.submitted', { promptId })
+ return await pollAndExtract(promptId, prompt, label('video'), getVideoTimeoutMs())
+ }
+
// ── Image-to-video (SVD / FramePack) ───────────────────────────
// Resolve the still into ComfyUI's input folder and route through the
// dynamic builder's I2V strategy. Conservative size + low frame count keep
@@ -1270,13 +1343,28 @@ export function resolveI2VResolution(
): { width: number; height: number } {
const landscapeDefault = { width: 1024, height: 576 }
if (!srcW || !srcH || srcW <= 0 || srcH <= 0) {
- return type === 'svd' ? landscapeDefault : { width: 768, height: 768 }
+ return (type === 'svd' || type === 'wan22') ? landscapeDefault : { width: 768, height: 768 }
}
const aspect = srcW / srcH
if (type === 'svd') {
// Square is closer to landscape than portrait; center-crop handles the rest.
return aspect >= 0.95 ? { width: 1024, height: 576 } : { width: 576, height: 1024 }
}
+ if (type === 'wan22') {
+ // Wan 2.2 5B trains at 1280×704 / 704×1280. Keep the SOURCE aspect (faithful
+ // framing), cap the long edge at 1024 for sane 12 GB speed, snap to 32 (the
+ // Wan 2.2 latent grid). An ImageScale(crop:center) in the builder fills it.
+ const cap = 1024
+ let w = srcW
+ let h = srcH
+ if (Math.max(w, h) > cap) {
+ const s = cap / Math.max(w, h)
+ w = Math.round(w * s)
+ h = Math.round(h * s)
+ }
+ const snap = (v: number) => Math.max(64, Math.round(v / 32) * 32)
+ return { width: snap(w), height: snap(h) }
+ }
// FramePack / others: keep the real aspect, snap to a 16-multiple, cap the
// long edge so a 12 GB card stays safe.
const cap = 768
diff --git a/src/components/create/ParamPanel.tsx b/src/components/create/ParamPanel.tsx
index b3cf98cc..d97627e4 100644
--- a/src/components/create/ParamPanel.tsx
+++ b/src/components/create/ParamPanel.tsx
@@ -46,9 +46,11 @@ const TYPE_BADGE: Record<ModelType, { label: string; color: string }> = {
flux: { label: 'FLUX', color: 'bg-purple-500/15 text-purple-300' },
flux2: { label: 'FLUX 2', color: 'bg-purple-500/15 text-purple-300' },
zimage: { label: 'Z-Image', color: 'bg-rose-500/15 text-rose-300' },
+ ernie_image: { label: 'ERNIE', color: 'bg-sky-500/15 text-sky-300' },
sdxl: { label: 'SDXL', color: 'bg-blue-500/15 text-blue-300' },
sd15: { label: 'SD 1.5', color: 'bg-green-500/15 text-green-300' },
wan: { label: 'Wan', color: 'bg-orange-500/15 text-orange-300' },
+ wan22: { label: 'Wan 2.2', color: 'bg-orange-500/15 text-orange-300' },
hunyuan: { label: 'Hunyuan', color: 'bg-red-500/15 text-red-300' },
ltx: { label: 'LTX', color: 'bg-cyan-500/15 text-cyan-300' },
mochi: { label: 'Mochi', color: 'bg-pink-500/15 text-pink-300' },
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index d0098cfe..7a2e3ada 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -19,6 +19,7 @@ export const MODEL_TYPE_DEFAULTS: Record<ModelType, {
flux2: { steps: 20, cfgScale: 1.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024 },
zimage: { steps: 12, cfgScale: 3.5, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024 },
wan: { steps: 25, cfgScale: 5.0, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 49, fps: 16 },
+ wan22: { steps: 30, cfgScale: 5.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 576, frames: 49, fps: 24 },
hunyuan: { steps: 30, cfgScale: 6.0, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 45, fps: 15 },
ltx: { steps: 20, cfgScale: 1.0, sampler: 'euler', scheduler: 'simple', width: 768, height: 512, frames: 97, fps: 24 },
unknown: { steps: 20, cfgScale: 7.0, sampler: 'euler', scheduler: 'normal', width: 1024, height: 1024 },