FangSen9000 commited on
Commit ·
3abeb82
1
Parent(s): 5255536
Optimize timeout period
Browse files- __pycache__/gloss2pose.cpython-311.pyc +0 -0
- __pycache__/prompt2gloss.cpython-311.pyc +0 -0
- __pycache__/viser_backend.cpython-311.pyc +0 -0
- easy_dwpose/__pycache__/__init__.cpython-311.pyc +0 -0
- easy_dwpose/draw/__pycache__/__init__.cpython-311.pyc +0 -0
- easy_dwpose/draw/__pycache__/controlnext.cpython-311.pyc +0 -0
- easy_dwpose/draw/__pycache__/openpose.cpython-311.pyc +0 -0
- index.js +99 -13
- utils/__pycache__/npz_interpolation.cpython-311.pyc +0 -0
- viser_backend.py +17 -3
__pycache__/gloss2pose.cpython-311.pyc
ADDED
|
Binary file (72.4 kB). View file
|
|
|
__pycache__/prompt2gloss.cpython-311.pyc
ADDED
|
Binary file (4.47 kB). View file
|
|
|
__pycache__/viser_backend.cpython-311.pyc
ADDED
|
Binary file (23 kB). View file
|
|
|
easy_dwpose/__pycache__/__init__.cpython-311.pyc
CHANGED
|
Binary files a/easy_dwpose/__pycache__/__init__.cpython-311.pyc and b/easy_dwpose/__pycache__/__init__.cpython-311.pyc differ
|
|
|
easy_dwpose/draw/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (278 Bytes). View file
|
|
|
easy_dwpose/draw/__pycache__/controlnext.cpython-311.pyc
ADDED
|
Binary file (14.4 kB). View file
|
|
|
easy_dwpose/draw/__pycache__/openpose.cpython-311.pyc
ADDED
|
Binary file (10.3 kB). View file
|
|
|
index.js
CHANGED
|
@@ -213,6 +213,11 @@ function ensureStyles() {
|
|
| 213 |
gap: 10px;
|
| 214 |
align-items: center;
|
| 215 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
@media (max-width: 1200px) {
|
| 217 |
.stable-signer-root {
|
| 218 |
flex-direction: column;
|
|
@@ -274,19 +279,29 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 274 |
</div>
|
| 275 |
<div class="stable-signer-right">
|
| 276 |
<div class="stable-control-header">
|
| 277 |
-
<button id="stable-
|
| 278 |
<span class="stable-status-chip" id="stable-status">Idle</span>
|
| 279 |
</div>
|
| 280 |
-
<div class="
|
| 281 |
-
<
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
<
|
| 285 |
-
|
| 286 |
-
<
|
| 287 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
</div>
|
| 289 |
</div>
|
|
|
|
|
|
|
|
|
|
| 290 |
<div class="form-group">
|
| 291 |
<label>Gloss 序列(自动生成,可手动编辑)</label>
|
| 292 |
<textarea id="stable-gloss" placeholder="示例:YOU WANT DRINK WATER"></textarea>
|
|
@@ -386,10 +401,10 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 386 |
this.videoSelect = container.querySelector('#stable-video-select');
|
| 387 |
this.videoRefreshBtn = container.querySelector('#stable-video-refresh');
|
| 388 |
this.videoMeta = container.querySelector('#stable-video-meta');
|
|
|
|
| 389 |
this.generateBtn = container.querySelector('#stable-generate');
|
| 390 |
this.statusChip = container.querySelector('#stable-status');
|
| 391 |
-
this.
|
| 392 |
-
this.textInput = container.querySelector('#stable-text');
|
| 393 |
this.glossInput = container.querySelector('#stable-gloss');
|
| 394 |
this.existingInput = container.querySelector('#stable-existing-video');
|
| 395 |
this.fpsInput = container.querySelector('#stable-fps');
|
|
@@ -413,6 +428,7 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 413 |
}
|
| 414 |
|
| 415 |
attachEvents() {
|
|
|
|
| 416 |
this.generateBtn.addEventListener('click', () => this.handleGenerate());
|
| 417 |
this.videoRefreshBtn.addEventListener('click', () => this.refreshRecentVideos());
|
| 418 |
this.videoSelect.addEventListener('change', () => this.handleRecentSelection());
|
|
@@ -433,9 +449,10 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 433 |
|
| 434 |
collectPayload() {
|
| 435 |
const glossValue = (this.glossInput.value || '').toUpperCase().replace(/\s+/g, ' ').trim();
|
|
|
|
| 436 |
return {
|
| 437 |
-
prompt:
|
| 438 |
-
text:
|
| 439 |
gloss: glossValue,
|
| 440 |
existingVideo: this.existingInput.value,
|
| 441 |
fps: toInt(this.fpsInput.value, 30),
|
|
@@ -461,6 +478,22 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 461 |
return;
|
| 462 |
}
|
| 463 |
const payload = this.collectPayload();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
this.setLoading(true);
|
| 465 |
this.updateStatus('Running...');
|
| 466 |
try {
|
|
@@ -505,6 +538,53 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 505 |
}
|
| 506 |
}
|
| 507 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
async updateVideo(url, path) {
|
| 509 |
if (!url || !this.videoEl) return;
|
| 510 |
const absoluteUrl = url.startsWith('http') ? url : `${window.location.origin}${url}`;
|
|
@@ -614,6 +694,12 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 614 |
this.generateBtn.textContent = isLoading ? '生成中...' : '生成 Pose Video';
|
| 615 |
}
|
| 616 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 617 |
updateStatus(text) {
|
| 618 |
this.statusChip.textContent = text;
|
| 619 |
}
|
|
|
|
| 213 |
gap: 10px;
|
| 214 |
align-items: center;
|
| 215 |
}
|
| 216 |
+
.stable-hint {
|
| 217 |
+
margin-top: 6px;
|
| 218 |
+
font-size: 12px;
|
| 219 |
+
color: #475569;
|
| 220 |
+
}
|
| 221 |
@media (max-width: 1200px) {
|
| 222 |
.stable-signer-root {
|
| 223 |
flex-direction: column;
|
|
|
|
| 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 ‘We’re going to work on a arm drill that will help you have graceful hand movements in front of you.’ in sign language?</div>
|
| 292 |
+
<div>2. I am intrigued to learn the sign language for ‘I call it painting the wall.’.</div>
|
| 293 |
+
<div>3. How is “So we’re going to go up and down; let’s switch hands, down and up; down and up.” denoted in sign language?</div>
|
| 294 |
+
<div>4. Can you elucidate how ‘And just let those fingers relax.’ looks in sign language?</div>
|
| 295 |
+
<div style="margin-top:6px;">Text samples (from prompt2gloss training data):</div>
|
| 296 |
+
<div>1. We're going to work on a arm drill that will help you have graceful hand movements in front of you.</div>
|
| 297 |
+
<div>2. I call it painting the wall.</div>
|
| 298 |
+
<div>3. “So we're going to go up and down; let's switch hands, down and up; down and up.”</div>
|
| 299 |
+
<div>4. And just let those fingers relax.</div>
|
| 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>
|
|
|
|
| 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');
|
| 407 |
+
this.promptTextInput = container.querySelector('#stable-prompt-text');
|
|
|
|
| 408 |
this.glossInput = container.querySelector('#stable-gloss');
|
| 409 |
this.existingInput = container.querySelector('#stable-existing-video');
|
| 410 |
this.fpsInput = container.querySelector('#stable-fps');
|
|
|
|
| 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());
|
| 434 |
this.videoSelect.addEventListener('change', () => this.handleRecentSelection());
|
|
|
|
| 449 |
|
| 450 |
collectPayload() {
|
| 451 |
const glossValue = (this.glossInput.value || '').toUpperCase().replace(/\s+/g, ' ').trim();
|
| 452 |
+
const promptText = (this.promptTextInput.value || '').trim();
|
| 453 |
return {
|
| 454 |
+
prompt: promptText,
|
| 455 |
+
text: promptText,
|
| 456 |
gloss: glossValue,
|
| 457 |
existingVideo: this.existingInput.value,
|
| 458 |
fps: toInt(this.fpsInput.value, 30),
|
|
|
|
| 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) {
|
| 487 |
+
try {
|
| 488 |
+
await this.handleTranslate(true);
|
| 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 |
+
}
|
| 497 |
this.setLoading(true);
|
| 498 |
this.updateStatus('Running...');
|
| 499 |
try {
|
|
|
|
| 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...');
|
| 553 |
+
this.setTranslateLoading(true);
|
| 554 |
+
}
|
| 555 |
+
try {
|
| 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 {
|
| 564 |
+
if (!isAuto) {
|
| 565 |
+
this.setTranslateLoading(false);
|
| 566 |
+
}
|
| 567 |
+
}
|
| 568 |
+
}
|
| 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',
|
| 576 |
+
data: {
|
| 577 |
+
text: promptText,
|
| 578 |
+
prompt: promptText,
|
| 579 |
+
maxNewTokens
|
| 580 |
+
}
|
| 581 |
+
});
|
| 582 |
+
if (!response || response.status !== 'success' || !response.gloss) {
|
| 583 |
+
throw new Error(response?.message || 'Gloss 翻译失败');
|
| 584 |
+
}
|
| 585 |
+
return response.gloss;
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
async updateVideo(url, path) {
|
| 589 |
if (!url || !this.videoEl) return;
|
| 590 |
const absoluteUrl = url.startsWith('http') ? url : `${window.location.origin}${url}`;
|
|
|
|
| 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) {
|
| 704 |
this.statusChip.textContent = text;
|
| 705 |
}
|
utils/__pycache__/npz_interpolation.cpython-311.pyc
ADDED
|
Binary file (13.4 kB). View file
|
|
|
viser_backend.py
CHANGED
|
@@ -234,6 +234,8 @@ class StableSignerBackend(PluginBackendBase):
|
|
| 234 |
return {"status": "success", "videos": self._list_recent_videos()}
|
| 235 |
if action == "probe_video":
|
| 236 |
return self.handle_probe_video(data)
|
|
|
|
|
|
|
| 237 |
return super().handle_message(message)
|
| 238 |
|
| 239 |
def handle_probe_video(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
|
@@ -251,13 +253,25 @@ class StableSignerBackend(PluginBackendBase):
|
|
| 251 |
}
|
| 252 |
return {"status": "error", "message": "Video not found or outside plugin directory."}
|
| 253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
def handle_generate_pose(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 255 |
if not self._generation_lock.acquire(blocking=False):
|
| 256 |
return {"status": "error", "message": "A generation job is already running. Please wait."}
|
| 257 |
|
| 258 |
try:
|
| 259 |
-
|
| 260 |
-
|
|
|
|
| 261 |
gloss_input = (data.get("gloss") or "").strip()
|
| 262 |
max_new_tokens = _safe_int(data.get("maxNewTokens"), 64)
|
| 263 |
|
|
@@ -278,7 +292,7 @@ class StableSignerBackend(PluginBackendBase):
|
|
| 278 |
|
| 279 |
if not gloss_input:
|
| 280 |
if not text_input:
|
| 281 |
-
return {"status": "error", "message": "Please enter
|
| 282 |
gloss_input = self._generate_gloss(text_input, prompt_input, max_new_tokens)
|
| 283 |
|
| 284 |
gloss_tokens = [token for token in gloss_input.upper().split() if token]
|
|
|
|
| 234 |
return {"status": "success", "videos": self._list_recent_videos()}
|
| 235 |
if action == "probe_video":
|
| 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]:
|
|
|
|
| 253 |
}
|
| 254 |
return {"status": "error", "message": "Video not found or outside plugin directory."}
|
| 255 |
|
| 256 |
+
def handle_prompt_to_gloss(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 257 |
+
prompt_text = (data.get("text") or data.get("prompt") or "").strip()
|
| 258 |
+
if not prompt_text:
|
| 259 |
+
return {"status": "error", "message": "Prompt/Text is empty."}
|
| 260 |
+
max_new_tokens = _safe_int(data.get("maxNewTokens"), 64)
|
| 261 |
+
try:
|
| 262 |
+
gloss = self._generate_gloss(prompt_text, prompt_text, max_new_tokens)
|
| 263 |
+
return {"status": "success", "gloss": gloss}
|
| 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."}
|
| 270 |
|
| 271 |
try:
|
| 272 |
+
prompt_input_raw = (data.get("prompt") or "").strip()
|
| 273 |
+
text_input = (data.get("text") or prompt_input_raw).strip()
|
| 274 |
+
prompt_input = prompt_input_raw or text_input
|
| 275 |
gloss_input = (data.get("gloss") or "").strip()
|
| 276 |
max_new_tokens = _safe_int(data.get("maxNewTokens"), 64)
|
| 277 |
|
|
|
|
| 292 |
|
| 293 |
if not gloss_input:
|
| 294 |
if not text_input:
|
| 295 |
+
return {"status": "error", "message": "Please enter Prompt/Text or a gloss sequence."}
|
| 296 |
gloss_input = self._generate_gloss(text_input, prompt_input, max_new_tokens)
|
| 297 |
|
| 298 |
gloss_tokens = [token for token in gloss_input.upper().split() if token]
|