Logankunfall commited on
Commit
04aef2a
·
verified ·
1 Parent(s): 63b777d

Upload 811 files

Browse files
Files changed (2) hide show
  1. public/index.html +3 -3
  2. server.js +7 -3
public/index.html CHANGED
@@ -221,15 +221,15 @@
221
  <div class="row">
222
  <div class="col">
223
  <label>帧率 (16-60)</label>
224
- <input id="w21_fps" type="number" min="16" max="60" step="1" value="24">
225
  </div>
226
  <div class="col">
227
  <label>步数 (T2V:10-30, I2V:20-50)</label>
228
  <input id="w21_steps" type="number" min="10" max="50" step="1" value="25">
229
  </div>
230
  <div class="col">
231
- <label>帧数 (T2V:81-241, I2V:固定81)</label>
232
- <input id="w21_frames" type="number" min="81" max="241" step="1" value="81">
233
  </div>
234
  </div>
235
  <div class="row">
 
221
  <div class="row">
222
  <div class="col">
223
  <label>帧率 (16-60)</label>
224
+ <input id="w21_fps" type="number" min="16" max="60" step="1" value="16">
225
  </div>
226
  <div class="col">
227
  <label>步数 (T2V:10-30, I2V:20-50)</label>
228
  <input id="w21_steps" type="number" min="10" max="50" step="1" value="25">
229
  </div>
230
  <div class="col">
231
+ <label>帧数 (T2V:81-241必须4n+1, I2V:固定81)</label>
232
+ <input id="w21_frames" type="number" min="81" max="241" step="4" value="81">
233
  </div>
234
  </div>
235
  <div class="row">
server.js CHANGED
@@ -343,9 +343,13 @@ app.post('/api/wan21/text2video', async (req, res) => {
343
  function clampNum(v, min, max) { if (v===undefined||v===null||v==='') return undefined; const n=Number(v); if(!Number.isFinite(n)) return undefined; return Math.max(min, Math.min(max, n)); }
344
  function toBool(v){ if(typeof v==='boolean') return v; if(v==='true'||v==='1'||v===1) return true; if(v==='false'||v==='0'||v===0) return false; return undefined; }
345
 
346
- const fps = clampInt(clean.fps, 16, 60) ?? 24;
347
  const steps = clampInt(clean.steps, 10, 30) ?? 25;
348
- const frames = clean.frames === null ? null : (clampInt(clean.frames, 81, 241) ?? 81);
 
 
 
 
349
  const seed = clean.seed === null ? null : clampInt(clean.seed, -2147483648, 2147483647);
350
  const sample_shift = clean.sample_shift === null ? null : clampNum(clean.sample_shift, 1, 7);
351
  const single_frame = toBool(clean.single_frame);
@@ -365,7 +369,7 @@ app.post('/api/wan21/text2video', async (req, res) => {
365
  if (guidance_scale !== undefined) finalArgs.guidance_scale = guidance_scale;
366
  if (negative_prompt !== undefined) finalArgs.negative_prompt = negative_prompt;
367
 
368
- console.log('[WAN2.1 text2video] final args ->', { keys:Object.keys(finalArgs), promptLen:prompt.length, resolution: finalArgs.resolution || '(default)' });
369
 
370
  try {
371
  const url = 'https://chutes-wan2-1-14b.chutes.ai/text2video';
 
343
  function clampNum(v, min, max) { if (v===undefined||v===null||v==='') return undefined; const n=Number(v); if(!Number.isFinite(n)) return undefined; return Math.max(min, Math.min(max, n)); }
344
  function toBool(v){ if(typeof v==='boolean') return v; if(v==='true'||v==='1'||v===1) return true; if(v==='false'||v==='0'||v===0) return false; return undefined; }
345
 
346
+ const fps = clampInt(clean.fps, 16, 60) ?? 16;
347
  const steps = clampInt(clean.steps, 10, 30) ?? 25;
348
+ let frames = clean.frames === null ? null : (clampInt(clean.frames, 81, 241) ?? 81);
349
+ // 确保frames符合4n+1格式(single_frame时为1)
350
+ if (frames !== null && frames !== 1) {
351
+ frames = frames - (frames % 4) + 1;
352
+ }
353
  const seed = clean.seed === null ? null : clampInt(clean.seed, -2147483648, 2147483647);
354
  const sample_shift = clean.sample_shift === null ? null : clampNum(clean.sample_shift, 1, 7);
355
  const single_frame = toBool(clean.single_frame);
 
369
  if (guidance_scale !== undefined) finalArgs.guidance_scale = guidance_scale;
370
  if (negative_prompt !== undefined) finalArgs.negative_prompt = negative_prompt;
371
 
372
+ console.log('[WAN2.1 text2video] final args ->', { keys:Object.keys(finalArgs), promptLen:prompt.length, frames, resolution: finalArgs.resolution || '(default)' });
373
 
374
  try {
375
  const url = 'https://chutes-wan2-1-14b.chutes.ai/text2video';