vanhai123 commited on
Commit
7588485
·
verified ·
1 Parent(s): 16aefd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -11,7 +11,9 @@ blip_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image
11
  translator_tokenizer = NllbTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
12
  translator_model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")
13
  lang_code = "vie_Latn"
14
- lang_token_id = translator_tokenizer.lang_code_to_id[lang_code]
 
 
15
 
16
  def caption_translate(image):
17
  # Step 1: Get English caption
 
11
  translator_tokenizer = NllbTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
12
  translator_model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")
13
  lang_code = "vie_Latn"
14
+
15
+ # Manually map lang_code to token ID (based on tokenizer's config)
16
+ lang_token_id = translator_tokenizer.convert_tokens_to_ids(lang_code)
17
 
18
  def caption_translate(image):
19
  # Step 1: Get English caption