FangSen9000 commited on
Commit
ac40945
·
1 Parent(s): 3abeb82

Add the issue of fixing the confidence level

Browse files
__pycache__/gloss2pose.cpython-311.pyc CHANGED
Binary files a/__pycache__/gloss2pose.cpython-311.pyc and b/__pycache__/gloss2pose.cpython-311.pyc differ
 
__pycache__/gloss2pose.cpython-312.pyc ADDED
Binary file (63.8 kB). View file
 
__pycache__/viser_backend.cpython-311.pyc CHANGED
Binary files a/__pycache__/viser_backend.cpython-311.pyc and b/__pycache__/viser_backend.cpython-311.pyc differ
 
generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708.mp4 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:11c9bec1c44c66b4e8a914f4cf3f08bdfbc0f0ed7a476c6aa73cc8129c6df552
3
- size 1669008
 
 
 
 
generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708_combined.mp4 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9601bc572dc3c58fe6bdb055b1254c580fb7f33642e3313d81b06598a349d980
3
- size 2054929
 
 
 
 
gloss2pose.py CHANGED
@@ -330,7 +330,9 @@ class SignLanguageQA:
330
  frame_keys = [k for k in npz_data.keys() if k.startswith('frame_') and k.endswith('_bodies')]
331
  return len(frame_keys)
332
 
333
- def create_pose_frame(self, frame_data, width=480, height=480, scale_x=1.0, scale_y=1.0, hide_torso_lines=False, y_offset=0, draw_style='controlnext'):
 
 
334
  """Create single frame pose image with progressive scaling and optional y offset
335
 
336
  Args:
@@ -346,7 +348,7 @@ class SignLanguageQA:
346
  frame_data = self.apply_y_offset(frame_data, y_offset)
347
 
348
  if draw_style == 'openpose':
349
- filtered_frame = self.filter_pose_for_openpose(frame_data, conf_threshold=0.6, update_subset=True)
350
  # Use OpenPose style (simpler, no processing needed)
351
  vis_img = draw_pose_openpose(
352
  pose=filtered_frame,
@@ -354,11 +356,11 @@ class SignLanguageQA:
354
  width=width,
355
  include_face=True,
356
  include_hands=True,
357
- conf_threshold=0.6
358
  )
359
  return vis_img
360
  else:
361
- filtered_frame = self.filter_pose_for_openpose(frame_data, conf_threshold=0.6, update_subset=False)
362
  # Use ControlNeXt style (default, with advanced features)
363
  processed_pred = process_pose_data(filtered_frame, height, width)
364
 
@@ -958,8 +960,8 @@ class SignLanguageQA:
958
 
959
  def generate_video_from_glosses(self, gloss_list, output_path, fps=30, width=480, height=480,
960
  smoothing_frames=5, smoothing_method='none', npz_interpolation_frames=0,
961
- scale_x=1.0, scale_y=1.0, hide_torso_lines=False, ref_image_path=None, draw_style='controlnext',
962
- normalize_pose=True):
963
  """Generate video from gloss list with optional progressive scaling and head alignment
964
 
965
  Args:
@@ -1068,7 +1070,11 @@ class SignLanguageQA:
1068
  y_offset = ref_head_top - current_head_top
1069
  print(f"📐 Calculated Y offset: {y_offset:.2f}")
1070
 
1071
- pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines, y_offset, draw_style)
 
 
 
 
1072
  if pose_frame is not None:
1073
  gloss_frames.append(pose_frame)
1074
 
@@ -1133,7 +1139,11 @@ class SignLanguageQA:
1133
 
1134
  # Create visual frame
1135
  if frame_data:
1136
- pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines, y_offset, draw_style)
 
 
 
 
1137
  if pose_frame is not None:
1138
  interpolated_pose_frames.append(pose_frame)
1139
 
@@ -1496,8 +1506,8 @@ def main():
1496
  help='Smoothing frames (default: 5)')
1497
  parser.add_argument('--npz-interpolation', type=int, default=0,
1498
  help='Number of NPZ interpolation frames between glosses (default: 0)')
1499
- parser.add_argument('--scale-x', type=float, default=1.5,
1500
- help='Progressive X-axis scaling factor (default: 1.5)')
1501
  parser.add_argument('--scale-y', type=float, default=1.5,
1502
  help='Progressive Y-axis scaling factor (default: 1.5)')
1503
  parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',
@@ -1506,6 +1516,8 @@ def main():
1506
  help='Reference image path for head alignment')
1507
  parser.add_argument('--draw-style', type=str, choices=['controlnext', 'openpose'], default='controlnext',
1508
  help='Drawing style for pose visualization. controlnext: advanced features with confidence-based coloring. openpose: simpler classic style. (default: controlnext)')
 
 
1509
  parser.add_argument('--normalize-pose', type=str, choices=['true', 'false'], default='true',
1510
  help='Normalize pose data to standard coordinate system. This ensures different videos are in the same coordinate space, reducing inconsistency from different video sources. (default: true)')
1511
  parser.add_argument('--max-candidates', type=int, default=10,
@@ -1554,7 +1566,8 @@ def main():
1554
  gloss_list, output_file, args.fps, args.width, args.height,
1555
  args.smoothing_frames, args.smoothing, args.npz_interpolation,
1556
  args.scale_x, args.scale_y, args.hide_torso_lines == 'true',
1557
- args.ref_image_path, args.draw_style, args.normalize_pose == 'true'
 
1558
  )
1559
 
1560
  if not success:
 
330
  frame_keys = [k for k in npz_data.keys() if k.startswith('frame_') and k.endswith('_bodies')]
331
  return len(frame_keys)
332
 
333
+ def create_pose_frame(self, frame_data, width=480, height=480, scale_x=1.0, scale_y=1.0,
334
+ hide_torso_lines=False, y_offset=0, draw_style='controlnext',
335
+ conf_threshold=0.6):
336
  """Create single frame pose image with progressive scaling and optional y offset
337
 
338
  Args:
 
348
  frame_data = self.apply_y_offset(frame_data, y_offset)
349
 
350
  if draw_style == 'openpose':
351
+ filtered_frame = self.filter_pose_for_openpose(frame_data, conf_threshold=conf_threshold, update_subset=True)
352
  # Use OpenPose style (simpler, no processing needed)
353
  vis_img = draw_pose_openpose(
354
  pose=filtered_frame,
 
356
  width=width,
357
  include_face=True,
358
  include_hands=True,
359
+ conf_threshold=conf_threshold
360
  )
361
  return vis_img
362
  else:
363
+ filtered_frame = self.filter_pose_for_openpose(frame_data, conf_threshold=conf_threshold, update_subset=False)
364
  # Use ControlNeXt style (default, with advanced features)
365
  processed_pred = process_pose_data(filtered_frame, height, width)
366
 
 
960
 
961
  def generate_video_from_glosses(self, gloss_list, output_path, fps=30, width=480, height=480,
962
  smoothing_frames=5, smoothing_method='none', npz_interpolation_frames=0,
963
+ scale_x=1.0, scale_y=1.0, hide_torso_lines=False, ref_image_path=None,
964
+ draw_style='controlnext', normalize_pose=True, draw_conf_threshold=0.6):
965
  """Generate video from gloss list with optional progressive scaling and head alignment
966
 
967
  Args:
 
1070
  y_offset = ref_head_top - current_head_top
1071
  print(f"📐 Calculated Y offset: {y_offset:.2f}")
1072
 
1073
+ pose_frame = self.create_pose_frame(
1074
+ frame_data, width, height, scale_x, scale_y,
1075
+ hide_torso_lines, y_offset, draw_style,
1076
+ conf_threshold=draw_conf_threshold
1077
+ )
1078
  if pose_frame is not None:
1079
  gloss_frames.append(pose_frame)
1080
 
 
1139
 
1140
  # Create visual frame
1141
  if frame_data:
1142
+ pose_frame = self.create_pose_frame(
1143
+ frame_data, width, height, scale_x, scale_y,
1144
+ hide_torso_lines, y_offset, draw_style,
1145
+ conf_threshold=draw_conf_threshold
1146
+ )
1147
  if pose_frame is not None:
1148
  interpolated_pose_frames.append(pose_frame)
1149
 
 
1506
  help='Smoothing frames (default: 5)')
1507
  parser.add_argument('--npz-interpolation', type=int, default=0,
1508
  help='Number of NPZ interpolation frames between glosses (default: 0)')
1509
+ parser.add_argument('--scale-x', type=float, default=1.4,
1510
+ help='Progressive X-axis scaling factor (default: 1.4)')
1511
  parser.add_argument('--scale-y', type=float, default=1.5,
1512
  help='Progressive Y-axis scaling factor (default: 1.5)')
1513
  parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',
 
1516
  help='Reference image path for head alignment')
1517
  parser.add_argument('--draw-style', type=str, choices=['controlnext', 'openpose'], default='controlnext',
1518
  help='Drawing style for pose visualization. controlnext: advanced features with confidence-based coloring. openpose: simpler classic style. (default: controlnext)')
1519
+ parser.add_argument('--draw-threshold', type=float, default=0.6,
1520
+ help='Confidence threshold for drawing joints (default: 0.6)')
1521
  parser.add_argument('--normalize-pose', type=str, choices=['true', 'false'], default='true',
1522
  help='Normalize pose data to standard coordinate system. This ensures different videos are in the same coordinate space, reducing inconsistency from different video sources. (default: true)')
1523
  parser.add_argument('--max-candidates', type=int, default=10,
 
1566
  gloss_list, output_file, args.fps, args.width, args.height,
1567
  args.smoothing_frames, args.smoothing, args.npz_interpolation,
1568
  args.scale_x, args.scale_y, args.hide_torso_lines == 'true',
1569
+ args.ref_image_path, args.draw_style, args.normalize_pose == 'true',
1570
+ args.draw_threshold
1571
  )
1572
 
1573
  if not success:
index.js CHANGED
@@ -96,8 +96,13 @@ function ensureStyles() {
96
  gap: 12px;
97
  margin-bottom: 15px;
98
  }
99
- .stable-control-header button {
100
- flex: none;
 
 
 
 
 
101
  }
102
  .stable-status-chip {
103
  font-size: 13px;
@@ -155,10 +160,15 @@ function ensureStyles() {
155
  }
156
  .stable-advanced-grid {
157
  margin-top: 12px;
158
- display: grid;
159
- grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
160
  gap: 12px;
161
  }
 
 
 
 
 
162
  .stable-switch {
163
  display: flex;
164
  align-items: center;
@@ -264,28 +274,31 @@ export default class StableSignerPlugin extends ControlWavePlugin {
264
  <div class="stable-video-frame">
265
  <video id="stable-video" controls playsinline loop muted></video>
266
  <div id="stable-video-placeholder" class="stable-video-placeholder">
267
- 生成的 pose 视频将显示在这里
268
  </div>
269
  </div>
270
  <div class="stable-video-controls">
271
  <select id="stable-video-select">
272
- <option value="">选择最近生成的视频</option>
273
  </select>
274
- <button id="stable-video-refresh" class="btn secondary">刷新</button>
275
  </div>
276
  <div class="stable-meta" id="stable-video-meta">
277
- 等待生成视频...
278
  </div>
279
  </div>
280
  <div class="stable-signer-right">
281
  <div class="stable-control-header">
282
- <button id="stable-translate" class="btn secondary">翻译 Prompt → Gloss</button>
 
 
 
283
  <span class="stable-status-chip" id="stable-status">Idle</span>
284
  </div>
285
  <div class="form-group">
286
  <label>Prompt / Text</label>
287
- <textarea id="stable-prompt-text" placeholder="描述你想要的动作或上下文,系统会自动翻译为 Gloss"></textarea>
288
- <div class="stable-hint">输入内容会自动翻译并填入下方的大写 Gloss,可继续手动编辑</div>
289
  <div class="form-group" style="margin-top:8px;font-size:13px;color:#475569;">
290
  <div>Prompt samples (from prompt2gloss training data):</div>
291
  <div>1. Can you instruct me to say &lsquo;We&rsquo;re going to work on a arm drill that will help you have graceful hand movements in front of you.&rsquo; in sign language?</div>
@@ -300,37 +313,37 @@ export default class StableSignerPlugin extends ControlWavePlugin {
300
  </div>
301
  </div>
302
  <div class="form-group" style="margin-top:4px;">
303
- <button id="stable-generate" class="btn primary" style="width:100%;">生成 Pose Video</button>
304
  </div>
305
  <div class="form-group">
306
- <label>Gloss 序列(自动生成,可手动编辑)</label>
307
- <textarea id="stable-gloss" placeholder="示例:YOU WANT DRINK WATER"></textarea>
308
  <div class="form-group" style="margin-top:8px;font-size:13px;color:#475569;">
309
- <div>示例:</div>
310
  <div>1. HELLO WORLD</div>
311
- <div>2. YOU WANT DRINK WATER</div>
312
  <div>3. TODAY WEATHER NICE</div>
313
  <div>4. I GO SCHOOL LATER</div>
314
  </div>
315
  </div>
316
  <div class="form-group">
317
- <label>复用已有视频(路径或文件名,可选)</label>
318
- <input id="stable-existing-video" type="text" placeholder="如:generated_pose_video/EXAMPLE.mp4">
319
  </div>
320
  <details class="stable-advanced">
321
- <summary>高级设置</summary>
322
  <div class="stable-advanced-grid">
323
  <div class="form-group">
324
  <label>FPS</label>
325
  <input id="stable-fps" type="number" min="5" max="60" value="30">
326
  </div>
327
  <div class="form-group">
328
- <label>宽度</label>
329
- <input id="stable-width" type="number" min="256" max="1024" value="480">
330
  </div>
331
  <div class="form-group">
332
- <label>高度</label>
333
- <input id="stable-height" type="number" min="256" max="1024" value="480">
334
  </div>
335
  <div class="form-group">
336
  <label>Smoothing</label>
@@ -343,15 +356,15 @@ export default class StableSignerPlugin extends ControlWavePlugin {
343
  </div>
344
  <div class="form-group">
345
  <label>Smoothing Frames</label>
346
- <input id="stable-smoothing-frames" type="number" min="0" max="60" value="5">
347
  </div>
348
  <div class="form-group">
349
  <label>NPZ Interp Frames</label>
350
- <input id="stable-npz" type="number" min="0" max="60" value="0">
351
  </div>
352
  <div class="form-group">
353
  <label>Scale X</label>
354
- <input id="stable-scale-x" type="number" step="0.1" value="1.5">
355
  </div>
356
  <div class="form-group">
357
  <label>Scale Y</label>
@@ -360,10 +373,14 @@ export default class StableSignerPlugin extends ControlWavePlugin {
360
  <div class="form-group">
361
  <label>Draw Style</label>
362
  <select id="stable-draw-style">
363
- <option value="controlnext">ControlNeXt</option>
364
  <option value="openpose">OpenPose</option>
 
365
  </select>
366
  </div>
 
 
 
 
367
  <div class="form-group">
368
  <label>Max Candidates</label>
369
  <input id="stable-max-candidates" type="number" min="0" value="10">
@@ -373,22 +390,22 @@ export default class StableSignerPlugin extends ControlWavePlugin {
373
  <input id="stable-max-new" type="number" min="8" max="256" value="64">
374
  </div>
375
  <div class="form-group">
376
- <label>参考图像路径 (可选)</label>
377
  <input id="stable-ref-image" type="text" placeholder="ref_img_dict/example.png">
378
  </div>
379
  <label class="stable-switch">
380
  <input type="checkbox" id="stable-normalize" checked>
381
- 归一化姿态
382
  </label>
383
  <label class="stable-switch">
384
  <input type="checkbox" id="stable-hide-torso">
385
- 隐藏躯干线
386
  </label>
387
  </div>
388
  </details>
389
  <div class="stable-logs">
390
- <label>日志输出</label>
391
- <pre id="stable-logs">(等待任务...)</pre>
392
  </div>
393
  </div>
394
  </div>
@@ -401,6 +418,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
401
  this.videoSelect = container.querySelector('#stable-video-select');
402
  this.videoRefreshBtn = container.querySelector('#stable-video-refresh');
403
  this.videoMeta = container.querySelector('#stable-video-meta');
 
404
  this.translateBtn = container.querySelector('#stable-translate');
405
  this.generateBtn = container.querySelector('#stable-generate');
406
  this.statusChip = container.querySelector('#stable-status');
@@ -416,6 +434,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
416
  this.scaleXInput = container.querySelector('#stable-scale-x');
417
  this.scaleYInput = container.querySelector('#stable-scale-y');
418
  this.drawStyleSelect = container.querySelector('#stable-draw-style');
 
419
  this.maxCandidatesInput = container.querySelector('#stable-max-candidates');
420
  this.maxNewTokensInput = container.querySelector('#stable-max-new');
421
  this.refImageInput = container.querySelector('#stable-ref-image');
@@ -428,6 +447,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
428
  }
429
 
430
  attachEvents() {
 
431
  this.translateBtn.addEventListener('click', () => this.handleTranslate());
432
  this.generateBtn.addEventListener('click', () => this.handleGenerate());
433
  this.videoRefreshBtn.addEventListener('click', () => this.refreshRecentVideos());
@@ -456,14 +476,15 @@ export default class StableSignerPlugin extends ControlWavePlugin {
456
  gloss: glossValue,
457
  existingVideo: this.existingInput.value,
458
  fps: toInt(this.fpsInput.value, 30),
459
- width: toInt(this.widthInput.value, 480),
460
- height: toInt(this.heightInput.value, 480),
461
  smoothing: this.smoothingSelect.value,
462
- smoothingFrames: toInt(this.smoothingFramesInput.value, 5),
463
- npzInterpolation: toInt(this.npzInput.value, 0),
464
- scaleX: toFloat(this.scaleXInput.value, 1.5),
465
  scaleY: toFloat(this.scaleYInput.value, 1.5),
466
  drawStyle: this.drawStyleSelect.value,
 
467
  maxCandidates: toInt(this.maxCandidatesInput.value, 10),
468
  maxNewTokens: toInt(this.maxNewTokensInput.value, 64),
469
  refImagePath: this.refImageInput.value,
@@ -474,13 +495,13 @@ export default class StableSignerPlugin extends ControlWavePlugin {
474
 
475
  async handleGenerate() {
476
  if (!window.controlWaveWebSocket || !window.controlWaveWebSocket.sendRequest) {
477
- this.updateStatus('WebSocket 未就绪');
478
  return;
479
  }
480
  const payload = this.collectPayload();
481
  if (!payload.gloss && !payload.text) {
482
- this.updateStatus('请输入 Prompt/Text 或 Gloss');
483
- this.logsPre.textContent = 'Prompt/Text 或 Gloss 不能为空';
484
  return;
485
  }
486
  if (!payload.gloss && payload.text) {
@@ -489,8 +510,8 @@ export default class StableSignerPlugin extends ControlWavePlugin {
489
  payload.gloss = (this.glossInput.value || '').trim();
490
  } catch (error) {
491
  console.error('[StableSigner] auto translation failed', error);
492
- this.updateStatus('Gloss 翻译失败');
493
- this.logsPre.textContent = (error && error.message) ? error.message : 'Prompt → Gloss 翻译失败';
494
  return;
495
  }
496
  }
@@ -538,15 +559,40 @@ export default class StableSignerPlugin extends ControlWavePlugin {
538
  }
539
  }
540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  async handleTranslate(isAuto = false) {
542
  const promptText = (this.promptTextInput.value || '').trim();
543
  const maxTokens = toInt(this.maxNewTokensInput.value, 64);
544
  if (!promptText) {
545
  if (!isAuto) {
546
- this.updateStatus('Prompt/Text 为空');
547
- this.logsPre.textContent = '请输入需要翻译的 Prompt 或 Text';
548
  }
549
- throw new Error('Prompt/Text 输入为空');
550
  }
551
  if (!isAuto) {
552
  this.updateStatus('Translating...');
@@ -556,8 +602,8 @@ export default class StableSignerPlugin extends ControlWavePlugin {
556
  const gloss = await this.translatePromptToGloss(promptText, maxTokens);
557
  this.glossInput.value = gloss;
558
  if (!isAuto) {
559
- this.updateStatus('Gloss 翻译完成');
560
- this.logsPre.textContent = `翻译结果: ${gloss}`;
561
  }
562
  return gloss;
563
  } finally {
@@ -569,7 +615,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
569
 
570
  async translatePromptToGloss(promptText, maxNewTokens) {
571
  if (!promptText) {
572
- throw new Error('Prompt/Text 输入为空');
573
  }
574
  const response = await window.controlWaveWebSocket.sendRequest(this.id, {
575
  action: 'prompt_to_gloss',
@@ -580,7 +626,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
580
  }
581
  });
582
  if (!response || response.status !== 'success' || !response.gloss) {
583
- throw new Error(response?.message || 'Gloss 翻译失败');
584
  }
585
  return response.gloss;
586
  }
@@ -600,7 +646,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
600
  };
601
 
602
  this.videoPlaceholder.style.display = 'flex';
603
- this.videoPlaceholder.textContent = '正在加载视频…';
604
  this.videoEl.style.display = 'none';
605
  resetVideoEl();
606
 
@@ -628,14 +674,14 @@ export default class StableSignerPlugin extends ControlWavePlugin {
628
  if (playPromise && typeof playPromise.catch === 'function') {
629
  playPromise.catch(() => {});
630
  }
631
- this.videoMeta.textContent = `视频: ${path || absoluteUrl}`;
632
  };
633
 
634
  this.videoEl.onerror = () => {
635
  this.videoEl.onloadeddata = null;
636
  this.videoEl.onerror = null;
637
  this.videoPlaceholder.style.display = 'flex';
638
- this.videoPlaceholder.textContent = '视频加载失败';
639
  const mediaError = this.videoEl.error;
640
  console.error('[StableSigner] video load error', mediaError ? {
641
  code: mediaError.code,
@@ -648,14 +694,14 @@ export default class StableSignerPlugin extends ControlWavePlugin {
648
  } catch (error) {
649
  resetVideoEl();
650
  this.videoPlaceholder.style.display = 'flex';
651
- this.videoPlaceholder.textContent = '视频加载失败';
652
  console.error('[StableSigner] video fetch failed', error);
653
  }
654
  }
655
 
656
  async refreshRecentVideos() {
657
  if (!window.controlWaveWebSocket || !window.controlWaveWebSocket.sendRequest) {
658
- this.updateStatus('等待 WebSocket...');
659
  return;
660
  }
661
  try {
@@ -664,12 +710,12 @@ export default class StableSignerPlugin extends ControlWavePlugin {
664
  });
665
  this.populateRecentVideos(response.videos || []);
666
  } catch (error) {
667
- this.videoMeta.textContent = `无法刷新视频列表: ${error.message}`;
668
  }
669
  }
670
 
671
  populateRecentVideos(videos) {
672
- this.videoSelect.innerHTML = '<option value="">选择最近生成的视频</option>';
673
  videos.forEach(video => {
674
  const option = document.createElement('option');
675
  option.value = video.url;
@@ -691,13 +737,19 @@ export default class StableSignerPlugin extends ControlWavePlugin {
691
 
692
  setLoading(isLoading) {
693
  this.generateBtn.disabled = isLoading;
694
- this.generateBtn.textContent = isLoading ? '生成中...' : '生成 Pose Video';
 
 
 
 
 
 
695
  }
696
 
697
  setTranslateLoading(isLoading) {
698
  if (!this.translateBtn) return;
699
  this.translateBtn.disabled = isLoading;
700
- this.translateBtn.textContent = isLoading ? '翻译中...' : '翻译 Prompt → Gloss';
701
  }
702
 
703
  updateStatus(text) {
 
96
  gap: 12px;
97
  margin-bottom: 15px;
98
  }
99
+ .stable-control-actions {
100
+ display: flex;
101
+ gap: 10px;
102
+ flex: 1;
103
+ }
104
+ .stable-control-actions button {
105
+ flex: 1;
106
  }
107
  .stable-status-chip {
108
  font-size: 13px;
 
160
  }
161
  .stable-advanced-grid {
162
  margin-top: 12px;
163
+ display: flex;
164
+ flex-wrap: wrap;
165
  gap: 12px;
166
  }
167
+ .stable-advanced-grid .form-group,
168
+ .stable-advanced-grid .stable-switch {
169
+ flex: 1 1 calc(50% - 12px);
170
+ min-width: 180px;
171
+ }
172
  .stable-switch {
173
  display: flex;
174
  align-items: center;
 
274
  <div class="stable-video-frame">
275
  <video id="stable-video" controls playsinline loop muted></video>
276
  <div id="stable-video-placeholder" class="stable-video-placeholder">
277
+ Generated pose video will appear here
278
  </div>
279
  </div>
280
  <div class="stable-video-controls">
281
  <select id="stable-video-select">
282
+ <option value="">Select recently generated video</option>
283
  </select>
284
+ <button id="stable-video-refresh" class="btn secondary">Refresh</button>
285
  </div>
286
  <div class="stable-meta" id="stable-video-meta">
287
+ Waiting for generated video...
288
  </div>
289
  </div>
290
  <div class="stable-signer-right">
291
  <div class="stable-control-header">
292
+ <div class="stable-control-actions">
293
+ <button id="stable-prewarm" class="btn secondary">Prewarm</button>
294
+ <button id="stable-translate" class="btn secondary">Translate Prompt → Gloss</button>
295
+ </div>
296
  <span class="stable-status-chip" id="stable-status">Idle</span>
297
  </div>
298
  <div class="form-group">
299
  <label>Prompt / Text</label>
300
+ <textarea id="stable-prompt-text" placeholder="Describe the action or context; the system will translate it to gloss."></textarea>
301
+ <div class="stable-hint">Input text auto-translates and fills the uppercase gloss field below (still editable).</div>
302
  <div class="form-group" style="margin-top:8px;font-size:13px;color:#475569;">
303
  <div>Prompt samples (from prompt2gloss training data):</div>
304
  <div>1. Can you instruct me to say &lsquo;We&rsquo;re going to work on a arm drill that will help you have graceful hand movements in front of you.&rsquo; in sign language?</div>
 
313
  </div>
314
  </div>
315
  <div class="form-group" style="margin-top:4px;">
316
+ <button id="stable-generate" class="btn primary" style="width:100%;">Generate Pose Video</button>
317
  </div>
318
  <div class="form-group">
319
+ <label>Gloss sequence (auto generated, editable)</label>
320
+ <textarea id="stable-gloss" placeholder="Example: I NEED HELP PLEASE"></textarea>
321
  <div class="form-group" style="margin-top:8px;font-size:13px;color:#475569;">
322
+ <div>Examples:</div>
323
  <div>1. HELLO WORLD</div>
324
+ <div>2. I NEED HELP PLEASE</div>
325
  <div>3. TODAY WEATHER NICE</div>
326
  <div>4. I GO SCHOOL LATER</div>
327
  </div>
328
  </div>
329
  <div class="form-group">
330
+ <label>Reuse existing video (path or filename, optional)</label>
331
+ <input id="stable-existing-video" type="text" placeholder="e.g., generated_pose_video/EXAMPLE.mp4">
332
  </div>
333
  <details class="stable-advanced">
334
+ <summary>Advanced Settings</summary>
335
  <div class="stable-advanced-grid">
336
  <div class="form-group">
337
  <label>FPS</label>
338
  <input id="stable-fps" type="number" min="5" max="60" value="30">
339
  </div>
340
  <div class="form-group">
341
+ <label>Width</label>
342
+ <input id="stable-width" type="number" min="256" max="1024" value="512">
343
  </div>
344
  <div class="form-group">
345
+ <label>Height</label>
346
+ <input id="stable-height" type="number" min="256" max="1024" value="512">
347
  </div>
348
  <div class="form-group">
349
  <label>Smoothing</label>
 
356
  </div>
357
  <div class="form-group">
358
  <label>Smoothing Frames</label>
359
+ <input id="stable-smoothing-frames" type="number" min="0" max="60" value="0">
360
  </div>
361
  <div class="form-group">
362
  <label>NPZ Interp Frames</label>
363
+ <input id="stable-npz" type="number" min="0" max="60" value="20">
364
  </div>
365
  <div class="form-group">
366
  <label>Scale X</label>
367
+ <input id="stable-scale-x" type="number" step="0.1" value="1.4">
368
  </div>
369
  <div class="form-group">
370
  <label>Scale Y</label>
 
373
  <div class="form-group">
374
  <label>Draw Style</label>
375
  <select id="stable-draw-style">
 
376
  <option value="openpose">OpenPose</option>
377
+ <option value="controlnext">ControlNeXt</option>
378
  </select>
379
  </div>
380
+ <div class="form-group">
381
+ <label>Draw Confidence Threshold</label>
382
+ <input id="stable-draw-threshold" type="number" min="0" max="1" step="0.05" value="0.6">
383
+ </div>
384
  <div class="form-group">
385
  <label>Max Candidates</label>
386
  <input id="stable-max-candidates" type="number" min="0" value="10">
 
390
  <input id="stable-max-new" type="number" min="8" max="256" value="64">
391
  </div>
392
  <div class="form-group">
393
+ <label>Reference image path (optional)</label>
394
  <input id="stable-ref-image" type="text" placeholder="ref_img_dict/example.png">
395
  </div>
396
  <label class="stable-switch">
397
  <input type="checkbox" id="stable-normalize" checked>
398
+ Normalize pose
399
  </label>
400
  <label class="stable-switch">
401
  <input type="checkbox" id="stable-hide-torso">
402
+ Hide torso lines
403
  </label>
404
  </div>
405
  </details>
406
  <div class="stable-logs">
407
+ <label>Log output</label>
408
+ <pre id="stable-logs">(waiting for task...)</pre>
409
  </div>
410
  </div>
411
  </div>
 
418
  this.videoSelect = container.querySelector('#stable-video-select');
419
  this.videoRefreshBtn = container.querySelector('#stable-video-refresh');
420
  this.videoMeta = container.querySelector('#stable-video-meta');
421
+ this.prewarmBtn = container.querySelector('#stable-prewarm');
422
  this.translateBtn = container.querySelector('#stable-translate');
423
  this.generateBtn = container.querySelector('#stable-generate');
424
  this.statusChip = container.querySelector('#stable-status');
 
434
  this.scaleXInput = container.querySelector('#stable-scale-x');
435
  this.scaleYInput = container.querySelector('#stable-scale-y');
436
  this.drawStyleSelect = container.querySelector('#stable-draw-style');
437
+ this.drawThresholdInput = container.querySelector('#stable-draw-threshold');
438
  this.maxCandidatesInput = container.querySelector('#stable-max-candidates');
439
  this.maxNewTokensInput = container.querySelector('#stable-max-new');
440
  this.refImageInput = container.querySelector('#stable-ref-image');
 
447
  }
448
 
449
  attachEvents() {
450
+ this.prewarmBtn.addEventListener('click', () => this.handlePrewarm());
451
  this.translateBtn.addEventListener('click', () => this.handleTranslate());
452
  this.generateBtn.addEventListener('click', () => this.handleGenerate());
453
  this.videoRefreshBtn.addEventListener('click', () => this.refreshRecentVideos());
 
476
  gloss: glossValue,
477
  existingVideo: this.existingInput.value,
478
  fps: toInt(this.fpsInput.value, 30),
479
+ width: toInt(this.widthInput.value, 512),
480
+ height: toInt(this.heightInput.value, 512),
481
  smoothing: this.smoothingSelect.value,
482
+ smoothingFrames: toInt(this.smoothingFramesInput.value, 0),
483
+ npzInterpolation: toInt(this.npzInput.value, 20),
484
+ scaleX: toFloat(this.scaleXInput.value, 1.4),
485
  scaleY: toFloat(this.scaleYInput.value, 1.5),
486
  drawStyle: this.drawStyleSelect.value,
487
+ drawConfidenceThreshold: toFloat(this.drawThresholdInput.value, 0.6),
488
  maxCandidates: toInt(this.maxCandidatesInput.value, 10),
489
  maxNewTokens: toInt(this.maxNewTokensInput.value, 64),
490
  refImagePath: this.refImageInput.value,
 
495
 
496
  async handleGenerate() {
497
  if (!window.controlWaveWebSocket || !window.controlWaveWebSocket.sendRequest) {
498
+ this.updateStatus('WebSocket not ready');
499
  return;
500
  }
501
  const payload = this.collectPayload();
502
  if (!payload.gloss && !payload.text) {
503
+ this.updateStatus('Enter Prompt/Text or Gloss');
504
+ this.logsPre.textContent = 'Prompt/Text or Gloss cannot be empty';
505
  return;
506
  }
507
  if (!payload.gloss && payload.text) {
 
510
  payload.gloss = (this.glossInput.value || '').trim();
511
  } catch (error) {
512
  console.error('[StableSigner] auto translation failed', error);
513
+ this.updateStatus('Gloss translation failed');
514
+ this.logsPre.textContent = (error && error.message) ? error.message : 'Prompt → Gloss translation failed';
515
  return;
516
  }
517
  }
 
559
  }
560
  }
561
 
562
+ async handlePrewarm() {
563
+ if (!window.controlWaveWebSocket || !window.controlWaveWebSocket.sendRequest) {
564
+ this.updateStatus('WebSocket not ready');
565
+ return;
566
+ }
567
+ this.updateStatus('Prewarming...');
568
+ this.setPrewarmLoading(true);
569
+ try {
570
+ const response = await window.controlWaveWebSocket.sendRequest(this.id, {
571
+ action: 'prewarm',
572
+ data: {}
573
+ });
574
+ const message = response.message || 'Prewarm completed';
575
+ const logs = response.logs || response.details || message;
576
+ this.logsPre.textContent = logs;
577
+ this.updateStatus('Prewarm completed');
578
+ } catch (error) {
579
+ console.error('[StableSigner] prewarm failed', error);
580
+ this.logsPre.textContent = (error && error.message) ? error.message : 'Prewarm failed';
581
+ this.updateStatus('Prewarm failed');
582
+ } finally {
583
+ this.setPrewarmLoading(false);
584
+ }
585
+ }
586
+
587
  async handleTranslate(isAuto = false) {
588
  const promptText = (this.promptTextInput.value || '').trim();
589
  const maxTokens = toInt(this.maxNewTokensInput.value, 64);
590
  if (!promptText) {
591
  if (!isAuto) {
592
+ this.updateStatus('Prompt/Text is empty');
593
+ this.logsPre.textContent = 'Please enter a Prompt or Text to translate';
594
  }
595
+ throw new Error('Prompt/Text is empty');
596
  }
597
  if (!isAuto) {
598
  this.updateStatus('Translating...');
 
602
  const gloss = await this.translatePromptToGloss(promptText, maxTokens);
603
  this.glossInput.value = gloss;
604
  if (!isAuto) {
605
+ this.updateStatus('Gloss translation completed');
606
+ this.logsPre.textContent = `Translation result: ${gloss}`;
607
  }
608
  return gloss;
609
  } finally {
 
615
 
616
  async translatePromptToGloss(promptText, maxNewTokens) {
617
  if (!promptText) {
618
+ throw new Error('Prompt/Text is empty');
619
  }
620
  const response = await window.controlWaveWebSocket.sendRequest(this.id, {
621
  action: 'prompt_to_gloss',
 
626
  }
627
  });
628
  if (!response || response.status !== 'success' || !response.gloss) {
629
+ throw new Error(response?.message || 'Gloss translation failed');
630
  }
631
  return response.gloss;
632
  }
 
646
  };
647
 
648
  this.videoPlaceholder.style.display = 'flex';
649
+ this.videoPlaceholder.textContent = 'Loading video…';
650
  this.videoEl.style.display = 'none';
651
  resetVideoEl();
652
 
 
674
  if (playPromise && typeof playPromise.catch === 'function') {
675
  playPromise.catch(() => {});
676
  }
677
+ this.videoMeta.textContent = `Video: ${path || absoluteUrl}`;
678
  };
679
 
680
  this.videoEl.onerror = () => {
681
  this.videoEl.onloadeddata = null;
682
  this.videoEl.onerror = null;
683
  this.videoPlaceholder.style.display = 'flex';
684
+ this.videoPlaceholder.textContent = 'Video load failed';
685
  const mediaError = this.videoEl.error;
686
  console.error('[StableSigner] video load error', mediaError ? {
687
  code: mediaError.code,
 
694
  } catch (error) {
695
  resetVideoEl();
696
  this.videoPlaceholder.style.display = 'flex';
697
+ this.videoPlaceholder.textContent = 'Video load failed';
698
  console.error('[StableSigner] video fetch failed', error);
699
  }
700
  }
701
 
702
  async refreshRecentVideos() {
703
  if (!window.controlWaveWebSocket || !window.controlWaveWebSocket.sendRequest) {
704
+ this.updateStatus('Waiting for WebSocket...');
705
  return;
706
  }
707
  try {
 
710
  });
711
  this.populateRecentVideos(response.videos || []);
712
  } catch (error) {
713
+ this.videoMeta.textContent = `Failed to refresh video list: ${error.message}`;
714
  }
715
  }
716
 
717
  populateRecentVideos(videos) {
718
+ this.videoSelect.innerHTML = '<option value="">Select recently generated video</option>';
719
  videos.forEach(video => {
720
  const option = document.createElement('option');
721
  option.value = video.url;
 
737
 
738
  setLoading(isLoading) {
739
  this.generateBtn.disabled = isLoading;
740
+ this.generateBtn.textContent = isLoading ? 'Generating...' : 'Generate Pose Video';
741
+ }
742
+
743
+ setPrewarmLoading(isLoading) {
744
+ if (!this.prewarmBtn) return;
745
+ this.prewarmBtn.disabled = isLoading;
746
+ this.prewarmBtn.textContent = isLoading ? 'Prewarming...' : 'Prewarm';
747
  }
748
 
749
  setTranslateLoading(isLoading) {
750
  if (!this.translateBtn) return;
751
  this.translateBtn.disabled = isLoading;
752
+ this.translateBtn.textContent = isLoading ? 'Translating...' : 'Translate Prompt → Gloss';
753
  }
754
 
755
  updateStatus(text) {
viser_backend.py CHANGED
@@ -236,6 +236,8 @@ class StableSignerBackend(PluginBackendBase):
236
  return self.handle_probe_video(data)
237
  if action == "prompt_to_gloss":
238
  return self.handle_prompt_to_gloss(data)
 
 
239
  return super().handle_message(message)
240
 
241
  def handle_probe_video(self, data: Dict[str, Any]) -> Dict[str, Any]:
@@ -264,6 +266,50 @@ class StableSignerBackend(PluginBackendBase):
264
  except Exception as exc: # pylint: disable=broad-except
265
  return {"status": "error", "message": str(exc)}
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  def handle_generate_pose(self, data: Dict[str, Any]) -> Dict[str, Any]:
268
  if not self._generation_lock.acquire(blocking=False):
269
  return {"status": "error", "message": "A generation job is already running. Please wait."}
@@ -300,16 +346,17 @@ class StableSignerBackend(PluginBackendBase):
300
  return {"status": "error", "message": "Gloss string is empty after normalization."}
301
 
302
  fps = _safe_int(data.get("fps"), 30)
303
- width = _safe_int(data.get("width"), 480)
304
- height = _safe_int(data.get("height"), 480)
305
  smoothing_method = data.get("smoothing", "none") or "none"
306
- smoothing_frames = _safe_int(data.get("smoothingFrames"), 5)
307
- npz_interp = _safe_int(data.get("npzInterpolation"), 0)
308
- scale_x = _safe_float(data.get("scaleX"), 1.5)
309
  scale_y = _safe_float(data.get("scaleY"), 1.5)
310
  hide_torso = _to_bool(data.get("hideTorsoLines"), False)
311
  normalize_pose = _to_bool(data.get("normalizePose"), True)
312
- draw_style = (data.get("drawStyle") or "controlnext").lower()
 
313
  max_candidates = _safe_int(data.get("maxCandidates"), 10)
314
  ref_image = (data.get("refImagePath") or "").strip() or None
315
 
@@ -334,6 +381,7 @@ class StableSignerBackend(PluginBackendBase):
334
  ref_image_path=ref_image,
335
  draw_style=draw_style,
336
  normalize_pose=normalize_pose,
 
337
  )
338
 
339
  logs = self._format_logs(log_buffer)
@@ -367,6 +415,7 @@ class StableSignerBackend(PluginBackendBase):
367
  "smoothing": smoothing_method,
368
  "npzInterpolation": npz_interp,
369
  "drawStyle": draw_style,
 
370
  },
371
  }
372
  except Exception as exc: # pylint: disable=broad-except
 
236
  return self.handle_probe_video(data)
237
  if action == "prompt_to_gloss":
238
  return self.handle_prompt_to_gloss(data)
239
+ if action == "prewarm":
240
+ return self.handle_prewarm(data)
241
  return super().handle_message(message)
242
 
243
  def handle_probe_video(self, data: Dict[str, Any]) -> Dict[str, Any]:
 
266
  except Exception as exc: # pylint: disable=broad-except
267
  return {"status": "error", "message": str(exc)}
268
 
269
+ def handle_prewarm(self, data: Dict[str, Any]) -> Dict[str, Any]:
270
+ candidate_counts = data.get("candidateCounts")
271
+ if isinstance(candidate_counts, list):
272
+ try:
273
+ counts = [max(1, int(value)) for value in candidate_counts if int(value) > 0]
274
+ except (TypeError, ValueError):
275
+ counts = []
276
+ else:
277
+ counts = []
278
+ if not counts:
279
+ counts = [5, 10, 20]
280
+
281
+ log_buffer = io.StringIO()
282
+ with contextlib.redirect_stdout(log_buffer), contextlib.redirect_stderr(log_buffer):
283
+ try:
284
+ self._load_prompt_model()
285
+ print("[Prewarm] Prompt2Gloss model ready.")
286
+ except Exception as exc: # pylint: disable=broad-except
287
+ print("[Prewarm] Failed to load Prompt2Gloss model:", exc)
288
+ return {"status": "error", "message": f"Prompt2Gloss load failed: {exc}", "logs": log_buffer.getvalue()}
289
+
290
+ warmed_counts = []
291
+ for count in counts:
292
+ try:
293
+ self._get_qa_system(count)
294
+ warmed_counts.append(count)
295
+ print(f"[Prewarm] QA system ready for max_candidates={count}.")
296
+ except Exception as exc: # pylint: disable=broad-except
297
+ print(f"[Prewarm] Failed to warm QA system (max_candidates={count}):", exc)
298
+
299
+ logs = log_buffer.getvalue()
300
+ if not warmed_counts:
301
+ return {
302
+ "status": "error",
303
+ "message": "Prewarm failed: unable to initialize QA systems.",
304
+ "logs": logs or "(no logs)",
305
+ }
306
+ return {
307
+ "status": "success",
308
+ "message": f"Prewarm done: Prompt2Gloss and {len(warmed_counts)} QA configs loaded.",
309
+ "counts": warmed_counts,
310
+ "logs": logs or "(no logs)",
311
+ }
312
+
313
  def handle_generate_pose(self, data: Dict[str, Any]) -> Dict[str, Any]:
314
  if not self._generation_lock.acquire(blocking=False):
315
  return {"status": "error", "message": "A generation job is already running. Please wait."}
 
346
  return {"status": "error", "message": "Gloss string is empty after normalization."}
347
 
348
  fps = _safe_int(data.get("fps"), 30)
349
+ width = _safe_int(data.get("width"), 512)
350
+ height = _safe_int(data.get("height"), 512)
351
  smoothing_method = data.get("smoothing", "none") or "none"
352
+ smoothing_frames = _safe_int(data.get("smoothingFrames"), 0)
353
+ npz_interp = _safe_int(data.get("npzInterpolation"), 20)
354
+ scale_x = _safe_float(data.get("scaleX"), 1.4)
355
  scale_y = _safe_float(data.get("scaleY"), 1.5)
356
  hide_torso = _to_bool(data.get("hideTorsoLines"), False)
357
  normalize_pose = _to_bool(data.get("normalizePose"), True)
358
+ draw_style = (data.get("drawStyle") or "openpose").lower()
359
+ draw_threshold = _safe_float(data.get("drawConfidenceThreshold"), 0.6)
360
  max_candidates = _safe_int(data.get("maxCandidates"), 10)
361
  ref_image = (data.get("refImagePath") or "").strip() or None
362
 
 
381
  ref_image_path=ref_image,
382
  draw_style=draw_style,
383
  normalize_pose=normalize_pose,
384
+ draw_conf_threshold=draw_threshold,
385
  )
386
 
387
  logs = self._format_logs(log_buffer)
 
415
  "smoothing": smoothing_method,
416
  "npzInterpolation": npz_interp,
417
  "drawStyle": draw_style,
418
+ "drawConfidenceThreshold": draw_threshold,
419
  },
420
  }
421
  except Exception as exc: # pylint: disable=broad-except