Test commited on
Commit
f69b2fe
1 Parent(s): 90156bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -1,7 +1,16 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
  import gradio as gr
2
+ from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
3
+ model = MBartForConditionalGeneration.from_pretrained("SnypzZz/Llama2-13b-Language-translate")
4
+ tokenizer = MBart50TokenizerFast.from_pretrained("SnypzZz/Llama2-13b-Language-translate", src_lang="en_XX")
5
 
6
+ def d(input):
7
+ model_inputs = tokenizer(input, return_tensors="pt")
8
+ generated_tokens = model.generate(
9
+ **model_inputs,
10
+ forced_bos_token_id=tokenizer.lang_code_to_id["de_DE"]
11
+ )
12
+ output_DE = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
13
+ return output_DE
14
 
15
+ iface = gr.Interface(fn=d, inputs="text", outputs="text")
16
  iface.launch()