TSjB commited on
Commit
40dbf38
·
verified ·
1 Parent(s): 7c7f54e
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -377,14 +377,14 @@ def translatePy(text, src_lang='rus_Cyrl', tgt_lang='krc_Cyrl',
377
  text, return_tensors='pt', padding=True, truncation=True,
378
  max_length=max_input_length
379
  )
380
- print(f'Inputs: {inputs}')
381
  result = model_translate.generate(
382
  **inputs.to(model_translate.device),
383
  forced_bos_token_id=tokenizer.convert_tokens_to_ids(tgt_lang),
384
  max_new_tokens=int(a + b * inputs.input_ids.shape[1]),
385
  num_beams=num_beams, **kwargs
386
  )
387
- print(f'Outputs: {result}')
388
  return tokenizer.batch_decode(result, skip_special_tokens=True)
389
 
390
 
@@ -413,13 +413,13 @@ def translateDisp(text, from_, to, dialect):
413
  # Разбиваем текст на предложения, сохраняя знаки препинания
414
  text = re.findall(r'.+?[.!?\n](?:\s|$)', text)
415
 
416
- print(f'Split text: {text}')
417
 
418
  str_ = translatePy(text, src_lang = from_, tgt_lang = to)
419
 
420
- print(f'Translated text: {str_}')
421
  str_ = ' '.join(str_).strip()
422
- print(f'Jointed text: {str_}')
423
 
424
  if to == 'krc_Cyrl':
425
  str_ = fromModel(str_, dialect = dialect)
 
377
  text, return_tensors='pt', padding=True, truncation=True,
378
  max_length=max_input_length
379
  )
380
+ #print(f'Inputs: {inputs}')
381
  result = model_translate.generate(
382
  **inputs.to(model_translate.device),
383
  forced_bos_token_id=tokenizer.convert_tokens_to_ids(tgt_lang),
384
  max_new_tokens=int(a + b * inputs.input_ids.shape[1]),
385
  num_beams=num_beams, **kwargs
386
  )
387
+ #print(f'Outputs: {result}')
388
  return tokenizer.batch_decode(result, skip_special_tokens=True)
389
 
390
 
 
413
  # Разбиваем текст на предложения, сохраняя знаки препинания
414
  text = re.findall(r'.+?[.!?\n](?:\s|$)', text)
415
 
416
+ #print(f'Split text: {text}')
417
 
418
  str_ = translatePy(text, src_lang = from_, tgt_lang = to)
419
 
420
+ #print(f'Translated text: {str_}')
421
  str_ = ' '.join(str_).strip()
422
+ #print(f'Jointed text: {str_}')
423
 
424
  if to == 'krc_Cyrl':
425
  str_ = fromModel(str_, dialect = dialect)