FangSen9000 commited on
Commit ·
a6f9451
1
Parent(s): 6178c29
Carry out pre-processing for translation
Browse files- __pycache__/gloss2pose.cpython-311.pyc +0 -0
- __pycache__/viser_backend.cpython-311.pyc +0 -0
- index.js +40 -15
__pycache__/gloss2pose.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/gloss2pose.cpython-311.pyc and b/__pycache__/gloss2pose.cpython-311.pyc differ
|
|
|
__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
|
|
|
index.js
CHANGED
|
@@ -10,6 +10,24 @@ const toFloat = (value, fallback) => {
|
|
| 10 |
return Number.isNaN(parsed) ? fallback : parsed;
|
| 11 |
};
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
function ensureStyles() {
|
| 14 |
if (document.getElementById(STYLE_ID)) {
|
| 15 |
return;
|
|
@@ -300,16 +318,21 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 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
|
| 304 |
-
<div>1. Can you
|
| 305 |
-
<div>2.
|
| 306 |
-
<div>3. How is “
|
| 307 |
-
<div>4.
|
| 308 |
-
<div style="margin-top:6px;">Text samples (
|
| 309 |
-
<div>1.
|
| 310 |
-
<div>2. I
|
| 311 |
-
<div>3.
|
| 312 |
-
<div>4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
</div>
|
| 314 |
</div>
|
| 315 |
<div class="form-group" style="margin-top:4px;">
|
|
@@ -585,21 +608,22 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 585 |
}
|
| 586 |
|
| 587 |
async handleTranslate(isAuto = false) {
|
| 588 |
-
const
|
| 589 |
const maxTokens = toInt(this.maxNewTokensInput.value, 64);
|
| 590 |
-
if (!
|
| 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...');
|
| 599 |
this.setTranslateLoading(true);
|
| 600 |
}
|
| 601 |
try {
|
| 602 |
-
const gloss = await this.translatePromptToGloss(
|
| 603 |
this.glossInput.value = gloss;
|
| 604 |
if (!isAuto) {
|
| 605 |
this.updateStatus('Gloss translation completed');
|
|
@@ -613,15 +637,16 @@ export default class StableSignerPlugin extends ControlWavePlugin {
|
|
| 613 |
}
|
| 614 |
}
|
| 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',
|
| 622 |
data: {
|
| 623 |
text: promptText,
|
| 624 |
-
prompt:
|
| 625 |
maxNewTokens
|
| 626 |
}
|
| 627 |
});
|
|
|
|
| 10 |
return Number.isNaN(parsed) ? fallback : parsed;
|
| 11 |
};
|
| 12 |
|
| 13 |
+
const normalizePromptText = (raw) => {
|
| 14 |
+
if (!raw) return "";
|
| 15 |
+
const text = raw.trim();
|
| 16 |
+
const doubleQuoted = text.match(/"([^"]{2,})"/);
|
| 17 |
+
if (doubleQuoted) {
|
| 18 |
+
return doubleQuoted[1].trim();
|
| 19 |
+
}
|
| 20 |
+
const singleQuoted = text.match(/'([^']{2,})'/);
|
| 21 |
+
if (singleQuoted) {
|
| 22 |
+
return singleQuoted[1].trim();
|
| 23 |
+
}
|
| 24 |
+
const forClause = text.match(/\bfor\s+([^?!.]+)[?!.]?$/i);
|
| 25 |
+
if (forClause && forClause[1].trim().length > 0) {
|
| 26 |
+
return forClause[1].trim();
|
| 27 |
+
}
|
| 28 |
+
return text;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
function ensureStyles() {
|
| 32 |
if (document.getElementById(STYLE_ID)) {
|
| 33 |
return;
|
|
|
|
| 318 |
<textarea id="stable-prompt-text" placeholder="Describe the action or context; the system will translate it to gloss."></textarea>
|
| 319 |
<div class="stable-hint">Input text auto-translates and fills the uppercase gloss field below (still editable).</div>
|
| 320 |
<div class="form-group" style="margin-top:8px;font-size:13px;color:#475569;">
|
| 321 |
+
<div>Prompt samples (picked from the latest prompt2gloss eval logs with strongest gloss matches):</div>
|
| 322 |
+
<div>1. Can you provide instruction on the sign language for “You’re going to hit it just a little more behind.”?</div>
|
| 323 |
+
<div>2. Can you show me how “Then what I like to do is go on with my fiber pliable paste.” appears in sign language?</div>
|
| 324 |
+
<div>3. How is “A baby snake might shed every week to an adult snake that might shed once a year so it really varies as to how often they’re going to shed their skin because it depends on how much they are growing.” signed?</div>
|
| 325 |
+
<div>4. How would you express “You check the pressure of the tires and to change tire pressures every time you come in, depending on track conditions, the track continues to change every single time you go out there.” in sign language?</div>
|
| 326 |
+
<div style="margin-top:6px;">Text samples (same sentences without the meta question):</div>
|
| 327 |
+
<div>1. You’re going to hit it just a little more behind.</div>
|
| 328 |
+
<div>2. Then what I like to do is go on with my fiber pliable paste.</div>
|
| 329 |
+
<div>3. A baby snake might shed every week to an adult snake that might shed once a year so it really varies as to how often they’re going to shed their skin because it depends on how much they are growing.</div>
|
| 330 |
+
<div>4. “You check the pressure of the tires and to change tire pressures every time you come in, depending on track conditions, the track continues to change every single time you go out there.”</div>
|
| 331 |
+
<div style="margin-top:6px;">Ground-truth gloss samples (for reference):</div>
|
| 332 |
+
<div>1. <strong>TO HIT A MORE BEHIND</strong></div>
|
| 333 |
+
<div>2. <strong>THEN WHAT I LIKE TO GO ON WITH MY</strong></div>
|
| 334 |
+
<div>3. <strong>A BABY SNAKE EVERY WEEK TO ADULT THAT ONCE YEAR REALLY HOW OFTEN THEIR SKIN BECAUSE ON MUCH THEY</strong></div>
|
| 335 |
+
<div>4. <strong>YOU CHECK PRESSURE AND TO CHANGE EVERY TIME COME IN ON SINGLE GO OUT THERE</strong></div>
|
| 336 |
</div>
|
| 337 |
</div>
|
| 338 |
<div class="form-group" style="margin-top:4px;">
|
|
|
|
| 608 |
}
|
| 609 |
|
| 610 |
async handleTranslate(isAuto = false) {
|
| 611 |
+
const promptTextRaw = (this.promptTextInput.value || '').trim();
|
| 612 |
const maxTokens = toInt(this.maxNewTokensInput.value, 64);
|
| 613 |
+
if (!promptTextRaw) {
|
| 614 |
if (!isAuto) {
|
| 615 |
this.updateStatus('Prompt/Text is empty');
|
| 616 |
this.logsPre.textContent = 'Please enter a Prompt or Text to translate';
|
| 617 |
}
|
| 618 |
throw new Error('Prompt/Text is empty');
|
| 619 |
}
|
| 620 |
+
const normalizedPrompt = normalizePromptText(promptTextRaw);
|
| 621 |
if (!isAuto) {
|
| 622 |
this.updateStatus('Translating...');
|
| 623 |
this.setTranslateLoading(true);
|
| 624 |
}
|
| 625 |
try {
|
| 626 |
+
const gloss = await this.translatePromptToGloss(normalizedPrompt, maxTokens, promptTextRaw);
|
| 627 |
this.glossInput.value = gloss;
|
| 628 |
if (!isAuto) {
|
| 629 |
this.updateStatus('Gloss translation completed');
|
|
|
|
| 637 |
}
|
| 638 |
}
|
| 639 |
|
| 640 |
+
async translatePromptToGloss(promptText, maxNewTokens, originalPrompt = null) {
|
| 641 |
if (!promptText) {
|
| 642 |
throw new Error('Prompt/Text is empty');
|
| 643 |
}
|
| 644 |
+
const payloadPrompt = originalPrompt || promptText;
|
| 645 |
const response = await window.controlWaveWebSocket.sendRequest(this.id, {
|
| 646 |
action: 'prompt_to_gloss',
|
| 647 |
data: {
|
| 648 |
text: promptText,
|
| 649 |
+
prompt: payloadPrompt,
|
| 650 |
maxNewTokens
|
| 651 |
}
|
| 652 |
});
|