SandaAbhishekSagar commited on
Commit
b5f1962
·
1 Parent(s): d24353d

revamped code of translate.py

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. translate.py +3 -3
app.py CHANGED
@@ -52,7 +52,7 @@ interface = gr.Interface(
52
  gr.Image(label="Generated Image"),
53
  ],
54
  title="LinguaVision - Multilingual Chatbot with Image Generation",
55
- description="Enter text in any language to translate it into English and generate an image based on the text.\n NOTE: This tool takes approximately 20 minutes to execute.",
56
  )
57
 
58
  if __name__ == "__main__":
 
52
  gr.Image(label="Generated Image"),
53
  ],
54
  title="LinguaVision - Multilingual Chatbot with Image Generation",
55
+ description="Enter text in any language to translate it into English and generate an image based on the text.",
56
  )
57
 
58
  if __name__ == "__main__":
translate.py CHANGED
@@ -40,9 +40,9 @@ def translate_text(text, src_lang="auto", tgt_lang="en"):
40
  # Tokenize the input text
41
  inputs = tokenizer(text, return_tensors="pt", padding=True)
42
 
43
- # Set the source language and target language for the model
44
- # If source language is auto, the model will automatically detect it
45
- tokenizer.src_lang = src_lang if src_lang != "auto" else None
46
  tokenizer.tgt_lang = tgt_lang
47
 
48
  # Generate the translation
 
40
  # Tokenize the input text
41
  inputs = tokenizer(text, return_tensors="pt", padding=True)
42
 
43
+ # Set the source and target languages
44
+ if src_lang != "auto":
45
+ tokenizer.src_lang = src_lang
46
  tokenizer.tgt_lang = tgt_lang
47
 
48
  # Generate the translation