FangSen9000 commited on
Commit
a6f9451
·
1 Parent(s): 6178c29

Carry out pre-processing for translation

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__/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 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>
305
- <div>2. I am intrigued to learn the sign language for &lsquo;I call it painting the wall.&rsquo;.</div>
306
- <div>3. How is &ldquo;So we&rsquo;re going to go up and down; let&rsquo;s switch hands, down and up; down and up.&rdquo; denoted in sign language?</div>
307
- <div>4. Can you elucidate how &lsquo;And just let those fingers relax.&rsquo; looks in sign language?</div>
308
- <div style="margin-top:6px;">Text samples (from prompt2gloss training data):</div>
309
- <div>1. We&apos;re going to work on a arm drill that will help you have graceful hand movements in front of you.</div>
310
- <div>2. I call it painting the wall.</div>
311
- <div>3. &ldquo;So we&apos;re going to go up and down; let&apos;s switch hands, down and up; down and up.&rdquo;</div>
312
- <div>4. And just let those fingers relax.</div>
 
 
 
 
 
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 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...');
599
  this.setTranslateLoading(true);
600
  }
601
  try {
602
- const gloss = await this.translatePromptToGloss(promptText, maxTokens);
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: promptText,
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 &ldquo;You&rsquo;re going to hit it just a little more behind.&rdquo;?</div>
323
+ <div>2. Can you show me how &ldquo;Then what I like to do is go on with my fiber pliable paste.&rdquo; appears in sign language?</div>
324
+ <div>3. How is &ldquo;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&rsquo;re going to shed their skin because it depends on how much they are growing.&rdquo; signed?</div>
325
+ <div>4. How would you express &ldquo;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.&rdquo; in sign language?</div>
326
+ <div style="margin-top:6px;">Text samples (same sentences without the meta question):</div>
327
+ <div>1. You&rsquo;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&rsquo;re going to shed their skin because it depends on how much they are growing.</div>
330
+ <div>4. &ldquo;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.&rdquo;</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
  });