prajdabre commited on
Commit
05e17e2
1 Parent(s): 3a21e36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -4
app.py CHANGED
@@ -19,7 +19,7 @@ def generate(input, slang, tlang):
19
  tlang = CREOLE[tlang]
20
  inp = tokenizer(input.strip() + " </s> <2" + slang + ">",
21
  add_special_tokens=False, return_tensors="pt", padding=True).input_ids
22
- if (slang != "eng" and tlang == "eng") or (slang == "eng" and tlang != "eng"):
23
  model_output = model.generate(inp, use_cache=True, num_beams=1, max_length=int(2*len(inp[0])), min_length=1, early_stopping=True, pad_token_id=pad_id,
24
  bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2"+tlang+">"))
25
  decoded_output = tokenizer.decode(
@@ -35,9 +35,6 @@ def generate(input, slang, tlang):
35
  bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2"+tlang+">"))
36
  decoded_output = tokenizer.decode(
37
  model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
38
- else:
39
- decoded_output = input
40
-
41
 
42
  return decoded_output
43
 
 
19
  tlang = CREOLE[tlang]
20
  inp = tokenizer(input.strip() + " </s> <2" + slang + ">",
21
  add_special_tokens=False, return_tensors="pt", padding=True).input_ids
22
+ if (slang != "eng" and tlang == "eng") or (slang == "eng" and tlang != "eng") or (slang == tlang):
23
  model_output = model.generate(inp, use_cache=True, num_beams=1, max_length=int(2*len(inp[0])), min_length=1, early_stopping=True, pad_token_id=pad_id,
24
  bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2"+tlang+">"))
25
  decoded_output = tokenizer.decode(
 
35
  bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2"+tlang+">"))
36
  decoded_output = tokenizer.decode(
37
  model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
 
 
 
38
 
39
  return decoded_output
40