Spaces:
Runtime error
Runtime error
Jour
commited on
Commit
•
8dc7ac2
0
Parent(s):
Duplicate from Jour/Translate-bloomz
Browse files- .gitattributes +27 -0
- README.md +14 -0
- app.py +52 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
19 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Translate With Bloom
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.0.26
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: Jour/Translate-bloomz
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
+
import os
|
5 |
+
|
6 |
+
|
7 |
+
LANGUAGES = ['Akan', 'Arabic', ' Assamese', 'Bambara', 'Bengali', 'Catalan', 'English', 'Spanish', ' Basque', 'French', ' Gujarati', 'Hindi',
|
8 |
+
'Indonesian', 'Igbo', 'Kikuyu', 'Kannada', 'Ganda', 'Lingala', 'Malayalam', 'Marathi', 'Nepali', 'Chichewa', 'Oriya', 'Panjabi', 'Portuguese',
|
9 |
+
'Kirundi', 'Kinyarwanda', 'Shona', 'Sotho', 'Swahili', 'Tamil', 'Telugu', 'Tswana', 'Tsonga', 'Twi', 'Urdu', 'Viêt Namese', 'Wolof', 'Xhosa',
|
10 |
+
'Yoruba', 'Chinese', 'Zulu']
|
11 |
+
|
12 |
+
API_URL = "https://api-inference.huggingface.co/models/bigscience/bloomz"
|
13 |
+
|
14 |
+
|
15 |
+
def translate(output, text):
|
16 |
+
"""Translate text from input language to output language"""
|
17 |
+
|
18 |
+
instruction = f"""Translatate to {output}: {text}\nTranslation: """
|
19 |
+
|
20 |
+
json_ = {
|
21 |
+
"inputs": instruction,
|
22 |
+
"parameters": {
|
23 |
+
"return_full_text": True,
|
24 |
+
"do_sample": False,
|
25 |
+
"max_new_tokens": 250,
|
26 |
+
},
|
27 |
+
"options": {
|
28 |
+
"use_cache": True,
|
29 |
+
"wait_for_model": True,
|
30 |
+
},
|
31 |
+
}
|
32 |
+
response = requests.request("POST", API_URL, json=json_)
|
33 |
+
output = response.json()
|
34 |
+
|
35 |
+
return output
|
36 |
+
|
37 |
+
demo = gr.Blocks()
|
38 |
+
|
39 |
+
with demo:
|
40 |
+
gr.Markdown("<h1><center>Translation with Bloom</center></h1>")
|
41 |
+
gr.Markdown("<center>Translation in many language with mt0-xxl</center>")
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
+
output_lang = gr.Dropdown(LANGUAGES, value='French', label='Select output language')
|
45 |
+
|
46 |
+
input_text = gr.Textbox(label="Input", lines=6)
|
47 |
+
output_text = gr.Textbox(lines=6, label="Output")
|
48 |
+
|
49 |
+
buton = gr.Button("translate")
|
50 |
+
buton.click(translate, inputs=[output_lang, input_text], outputs=output_text)
|
51 |
+
|
52 |
+
demo.launch(enable_queue=True, debug=True)
|