Update app.py
Browse files
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 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
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 |
-
|
38 |
-
|
39 |
-
# return model(text)
|
40 |
-
|
41 |
-
# model = gr.load("models/Purz/face-projection")
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
["
|
55 |
-
["
|
56 |
-
["
|
|
|
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,
|