Size Qwen 2.1 Generate from the bench aspect table.
Wire EmptyLatentImage to the official ~1 MP grid so 16:9 lands at 1536×864, keep PE wh_ratio advisory, and leave Edit on the encode latent from image_1. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-14
@@ -1,18 +1,22 @@
|
||||
import {restoreLoras,loraUse} from './lora-memory.mjs'
|
||||
import { restoreInput, sectionsFrom } from './contracts.mjs'
|
||||
import { normalizeStyles } from './styles.mjs'
|
||||
export const aspectOptions = [{id:'auto',label:'Automatic',hint:'Match start or hero still'},{id:'16:9',label:'16:9',hint:'1344 × 768 · padded'},{id:'9:16',label:'9:16',hint:'768 × 1344 · padded'},{id:'1:1',label:'1:1',hint:'960 × 960 · padded'}]
|
||||
export function resolveQwen21Size(aspect, source) {
|
||||
const presets = {'16:9':[1024,576],'9:16':[576,1024],'1:1':[1024,1024]}
|
||||
if (presets[aspect]) return {width:presets[aspect][0],height:presets[aspect][1]}
|
||||
if (source?.width && source?.height) {
|
||||
const ratio = source.width / source.height
|
||||
const width = Math.max(32, Math.round(Math.sqrt(1024 * 1024 * ratio) / 32) * 32)
|
||||
const height = Math.max(32, Math.round(Math.sqrt(1024 * 1024 / ratio) / 32) * 32)
|
||||
return {width, height}
|
||||
}
|
||||
return {width:1024,height:1024}
|
||||
}
|
||||
import { QWEN21_ASPECT_IDS as ASPECT_IDS, resolveQwen21Size } from './qwen21-size.mjs'
|
||||
export { resolveQwen21Size, QWEN21_SIZE_TABLE } from './qwen21-size.mjs'
|
||||
|
||||
export const aspectOptions = [
|
||||
{id:'auto',label:'Automatic',hint:'Match start or hero still'},
|
||||
{id:'16:9',label:'16:9',hint:'Widescreen'},
|
||||
{id:'9:16',label:'9:16',hint:'Tall'},
|
||||
{id:'1:1',label:'1:1',hint:'Square'},
|
||||
{id:'4:3',label:'4:3',hint:'Standard'},
|
||||
{id:'3:4',label:'3:4',hint:'Portrait standard'},
|
||||
{id:'3:2',label:'3:2',hint:'Photo'},
|
||||
{id:'2:3',label:'2:3',hint:'Portrait photo'},
|
||||
{id:'21:9',label:'21:9',hint:'Ultrawide'},
|
||||
{id:'9:21',label:'9:21',hint:'Ultra-tall'}
|
||||
]
|
||||
|
||||
export function resolveSize(aspect, source, fallback = {width:1344,height:768}, engine = '') {
|
||||
if (engine === 'qwen21') return resolveQwen21Size(aspect, source)
|
||||
const presets = {'16:9':[1344,768],'9:16':[768,1344],'1:1':[960,960]}
|
||||
@@ -21,12 +25,15 @@ export function resolveSize(aspect, source, fallback = {width:1344,height:768},
|
||||
const factor = Math.min(1344/Math.max(source.width,source.height),768/Math.min(source.width,source.height))
|
||||
return {width:Math.max(256,Math.round(source.width*factor/32)*32),height:Math.max(256,Math.round(source.height*factor/32)*32)}
|
||||
}
|
||||
|
||||
export { ASPECT_IDS }
|
||||
|
||||
export function bindClip(form, clip, xaigen = false, memory) {
|
||||
if (!clip?.id) return form
|
||||
const saved = clip.studio2 || clip.job || {}
|
||||
const settings = saved.settings || clip.settings || {}
|
||||
const next = {...form, startClipId:clip.id, mode:'extend', settings:{...form.settings}}
|
||||
next.settings.aspect=['auto','16:9','9:16','1:1'].includes(settings.aspect)?settings.aspect:(form.settings?.aspect || 'auto')
|
||||
next.settings.aspect=ASPECT_IDS.has(settings.aspect)?settings.aspect:(form.settings?.aspect || 'auto')
|
||||
for (const key of ['duration','width','height','fps','loraStack','turbo','steps','cfg']) {
|
||||
if (settings[key] == null) continue
|
||||
try { next.settings[key] = typeof structuredClone === 'function' ? structuredClone(settings[key]) : JSON.parse(JSON.stringify(settings[key])) }
|
||||
@@ -96,7 +103,7 @@ export function hydrateStudio2Job(form, saved, { stillIds = new Set(), clipIds =
|
||||
if (['video','extend'].includes(mode)) engine = xaigen && engine === 'ltx' ? 'ltx' : 'minimax'
|
||||
else if (engine === 'minimax' || engine === 'ltx') engine = 'flux'
|
||||
const settings = structuredClone(src.settings || {})
|
||||
const aspect = ['auto','16:9','9:16','1:1'].includes(settings.aspect) ? settings.aspect : 'auto'
|
||||
const aspect = ASPECT_IDS.has(settings.aspect) ? settings.aspect : 'auto'
|
||||
const loraStack = Array.isArray(settings.loraStack) ? settings.loraStack.map(item => ({
|
||||
name: item.name,
|
||||
strengthModel: Number(item.strengthModel ?? item.strength ?? 1),
|
||||
|
||||
Reference in New Issue
Block a user