darshankr commited on
Commit
6a6db87
1 Parent(s): 31984b2

Update app.py

Browse files

change model to indic languages

Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -17,10 +17,10 @@ app.add_middleware(
17
  )
18
 
19
  model = AutoModelForSeq2SeqLM.from_pretrained(
20
- "ai4bharat/indictrans2-en-indic-1B", trust_remote_code=True
21
  )
22
  tokenizer = AutoTokenizer.from_pretrained(
23
- "ai4bharat/indictrans2-en-indic-1B", trust_remote_code=True
24
  )
25
 
26
  ip = IndicProcessor(inference=True)
@@ -28,9 +28,8 @@ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
28
  model = model.to(DEVICE)
29
 
30
 
31
- def translate_text(sentences: List[str], target_lang: str):
32
  try:
33
- src_lang = "eng_Latn"
34
  batch = ip.preprocess_batch(sentences, src_lang=src_lang, tgt_lang=target_lang)
35
  inputs = tokenizer(
36
  batch,
@@ -68,6 +67,7 @@ def read_root():
68
 
69
  class TranslateRequest(BaseModel):
70
  sentences: List[str]
 
71
  target_lang: str
72
 
73
 
 
17
  )
18
 
19
  model = AutoModelForSeq2SeqLM.from_pretrained(
20
+ "ai4bharat/indictrans2-indic-indic-1B", trust_remote_code=True
21
  )
22
  tokenizer = AutoTokenizer.from_pretrained(
23
+ "ai4bharat/indictrans2-indic-indic-1B", trust_remote_code=True
24
  )
25
 
26
  ip = IndicProcessor(inference=True)
 
28
  model = model.to(DEVICE)
29
 
30
 
31
+ def translate_text(sentences: List[str], src_lang: str, target_lang: str):
32
  try:
 
33
  batch = ip.preprocess_batch(sentences, src_lang=src_lang, tgt_lang=target_lang)
34
  inputs = tokenizer(
35
  batch,
 
67
 
68
  class TranslateRequest(BaseModel):
69
  sentences: List[str]
70
+ src_lang
71
  target_lang: str
72
 
73