KarmaCST commited on
Commit
3603393
1 Parent(s): 7be1027

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -32
app.py CHANGED
@@ -12,49 +12,50 @@ translation_model = AutoModelForSeq2SeqLM.from_pretrained("KarmaCST/nllb-200-dis
12
  tokenizer = AutoTokenizer.from_pretrained("KarmaCST/nllb-200-distilled-600M-dz-to-en")
13
 
14
 
15
- model = gr.load("models/Purz/face-projection")
16
-
17
-
18
  src_lang="dzo_Tibt"
19
  tgt_lang="eng_Latn"
20
 
21
- def translate_dzongkha_to_english(text):
22
- translation_pipeline = pipeline("translation",
23
- model=translation_model,
24
- tokenizer=tokenizer,
25
- src_lang=src_lang,
26
- tgt_lang=tgt_lang)
27
 
28
- translated_text = translation_pipeline(text)[0]['translation_text']
29
 
30
- def generate_image(translated_text, seed):
31
- if seed is not None:
32
- random.seed(seed)
33
-
34
- if text in [example[0] for example in examples]:
35
- print(f"Using example: {text}")
36
 
37
- return model(text)
38
-
39
- # return model(text)
40
-
41
- # model = gr.load("models/Purz/face-projection")
42
 
43
- # def generate_image(text, seed):
44
- # if seed is not None:
45
- # random.seed(seed)
 
 
 
 
 
46
 
47
- # if text in [example[0] for example in examples]:
48
- # print(f"Using example: {text}")
49
 
50
- # return model(text)
 
51
 
52
- examples = [
53
- ["Humanoid Cat Warrior, Full View", None],
54
- ["Warhammer Sisterhood", None],
55
- ["Future Robots war", None],
56
- ["Fantasy dragon", None]
 
57
  ]
 
 
 
 
 
 
58
 
59
  interface = gr.Interface(
60
  fn=translate_dzongkha_to_english,
 
12
  tokenizer = AutoTokenizer.from_pretrained("KarmaCST/nllb-200-distilled-600M-dz-to-en")
13
 
14
 
 
 
 
15
  src_lang="dzo_Tibt"
16
  tgt_lang="eng_Latn"
17
 
18
+ # def translate_dzongkha_to_english(text):
19
+ # translation_pipeline = pipeline("translation",
20
+ # model=translation_model,
21
+ # tokenizer=tokenizer,
22
+ # src_lang=src_lang,
23
+ # tgt_lang=tgt_lang)
24
 
25
+ # translated_text = translation_pipeline(text)[0]['translation_text']
26
 
27
+ # return translated_text
 
 
 
 
 
28
 
29
+ model = gr.load("models/Purz/face-projection")
 
 
 
 
30
 
31
+ def generate_image(text, seed):
32
+ translation_pipeline = pipeline("translation",
33
+ model=translation_model,
34
+ tokenizer=tokenizer,
35
+ src_lang=src_lang,
36
+ tgt_lang=tgt_lang)
37
+
38
+ text = translation_pipeline(text)[0]['translation_text']
39
 
40
+ if seed is not None:
41
+ random.seed(seed)
42
 
43
+ if text in [example[0] for example in examples]:
44
+ print(f"Using example: {text}")
45
 
46
+ return model(text)
47
+ examples=[
48
+ ["བྱི་ཅུང་ཚུ་གངས་རི་གི་ཐོག་ཁར་འཕུར།", None],
49
+ ["པཱ་རོ་ཁྲོམ་གྱི་ཐོག་ཁར་གནམ་གྲུ་འཕུར།",None],
50
+ ["པཱ་རོ་ཁྲོམ་གྱི་ཐོག་ཁར་ ཤིང་ཚུ་གི་བར་ན་ གནམ་གྲུ་འཕུར་བའི་འཐོང་གནང་།",None],
51
+ ["སློབ་ཕྲུག་ཚུ་ ཆརཔ་ནང་རྐང་རྩེད་རྩེ་དེས།"]
52
  ]
53
+ # examples = [
54
+ # ["Humanoid Cat Warrior, Full View", None],
55
+ # ["Warhammer Sisterhood", None],
56
+ # ["Future Robots war", None],
57
+ # ["Fantasy dragon", None]
58
+ # ]
59
 
60
  interface = gr.Interface(
61
  fn=translate_dzongkha_to_english,