Ashrafb commited on
Commit
252e5b6
β€’
1 Parent(s): ef5af0c

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -33
app.py DELETED
@@ -1,33 +0,0 @@
1
- import gradio as gr
2
- from transformers import M2M100ForConditionalGeneration
3
- from tokenization_small100 import SMALL100Tokenizer
4
-
5
- langs = """af,am,ar,ast,az,ba,be,bg,bn,br,bs,ca,ceb,cs,cy,da,de,el,en,es,et,fa,ff,fi,fr,fy,ga,gd,gl,gu,ha,he,hi,hr,ht,hu,hy,id,ig,ilo,is,it,ja,jv,ka,kk,km,kn,ko,lb,lg,ln,lo,lt,lv,mg,mk,ml,mn,mr,ms,my,ne,nl,no,ns,oc,or,pa,pl,ps,pt,ro,ru,sd,si,sk,sl,so,sq,sr,ss,su,sv,sw,ta,th,tl,tn,tr,uk,ur,uz,vi,wo,xh,yi,yo,zh,zu"""
6
- lang_list = langs.split(',')
7
-
8
- model = M2M100ForConditionalGeneration.from_pretrained("alirezamsh/small100")
9
- tokenizer = SMALL100Tokenizer.from_pretrained("alirezamsh/small100")
10
-
11
- def translate(lang, text):
12
- tokenizer.tgt_lang = lang
13
- encoded_text = tokenizer(text, return_tensors="pt")
14
- generated_tokens = model.generate(**encoded_text)
15
- return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]
16
-
17
- with gr.Blocks(analytics_enabled=False) as app:
18
-
19
- Source = gr.Textbox( label="Source" )
20
- Language = gr.Dropdown( lang_list, label="Language" )
21
- Translate = gr.Button( "Translate" )
22
- Result = gr.Textbox( label="Result" )
23
-
24
-
25
- Translate.click(
26
- translate,
27
- inputs=[ Language, Source ],
28
- outputs=[Result],
29
- api_name="translate",
30
- )
31
-
32
- app.launch( inline=True )
33
- block.queue( concurrency_count=2 )