andzhang01 commited on
Commit
2d29941
1 Parent(s): 464c542

Upload 23 files

Browse files
Files changed (24) hide show
  1. .gitattributes +2 -0
  2. prompt_translator/.gitignore +132 -0
  3. prompt_translator/.vscode/settings.json +3 -0
  4. prompt_translator/LICENSE +21 -0
  5. prompt_translator/README.md +46 -0
  6. prompt_translator/scripts/__pycache__/main.cpython-310.pyc +0 -0
  7. prompt_translator/scripts/main.py +470 -0
  8. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/added_tokens.json +0 -0
  9. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/model.safetensors +3 -0
  10. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/model.safetensors.index.json +0 -0
  11. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/tokenizer.json +0 -0
  12. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/024ddcc796a33d2e4decd4c1bd5fe90ad295aaba9072edb3796a09ef9b755934 +3 -0
  13. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/45fccfb2bb92e64115346219ea10b8388bbcdd74 +12 -0
  14. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/ceb27363e751c4b33905f24aa046188be4f38882 +1 -0
  15. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865 +3 -0
  16. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/edabc105ab15c9ee8c030daa9f9780831b4c0fd2 +1 -0
  17. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/f72b537ec40e699db3bb26ab7b2cadecef4b0801 +57 -0
  18. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/refs/main +1 -0
  19. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/config.json +57 -0
  20. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/generation_config.json +12 -0
  21. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/pytorch_model.bin +3 -0
  22. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/sentencepiece.bpe.model +3 -0
  23. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/special_tokens_map.json +1 -0
  24. prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/tokenizer_config.json +1 -0
.gitattributes CHANGED
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/024ddcc796a33d2e4decd4c1bd5fe90ad295aaba9072edb3796a09ef9b755934 filter=lfs diff=lfs merge=lfs -text
56
+ prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865 filter=lfs diff=lfs merge=lfs -text
prompt_translator/.gitignore ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # remove models
132
+ models
prompt_translator/.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "ros.distro": "noetic"
3
+ }
prompt_translator/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Saifeddine ALOUI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
prompt_translator/README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Prompt Translator for Stable Diffusion
2
+ [![Follow me on Twitter](https://img.shields.io/twitter/follow/SpaceNerduino?style=social)](https://twitter.com/SpaceNerduino)
3
+ [![Follow Me on YouTube](https://img.shields.io/badge/Follow%20Me%20on-YouTube-red?style=flat&logo=youtube)](https://www.youtube.com/user/Parisneo)
4
+
5
+ Stable diffusion is a text to image generation model. The `prompt_translator` extension allows people to translate their prompt from any language to English before executing the generation, making it accessible to a wider audience.
6
+
7
+ ## Utility
8
+
9
+ Here is an example of how useful prompt_translator can be:
10
+
11
+ Let's say that you are a French speaker and want to use Stable Diffusion to generate an image of a beautiful mountain. However, the model requires the prompt to be in English. Without prompt_translator, you would need to either write your prompt in English (if you're comfortable with the language) or use an external translation tool to manually translate your prompt to English.
12
+
13
+ With prompt_translator, you can simply select "French" as your source language and write your prompt in French. The extension will automatically translate your prompt to English before sending it to the model. This way, you can use Stable Diffusion without having to worry about the language barrier.
14
+
15
+ Using prompt_translator makes Stable Diffusion more accessible to people who are not comfortable with English or have limited proficiency in the language. It opens up new possibilities for text-to-image generation by allowing users to use their native language to write prompts.
16
+
17
+ We hope that prompt_translator will make Stable Diffusion more accessible and easier to use for people around the world. Please feel free to contribute to the project or report any issues on our GitHub page.
18
+
19
+ ## Installation
20
+
21
+ To install `prompt_translator`, clone the repository or extract the zip file to the extensions folder of the sd_webui mother application.
22
+
23
+ ## Usage
24
+
25
+ After installing `prompt_translator`, a new entry will be added to the Gradio UI. To use the automatic translation tool, click the "Load Translation Model" button to load the translation model. The translation model used in this tool is the `mbart-large-50-many-to-one-mmt` model developed by Meta (formerly Facebook). You can find more information about the model on its [Hugging Face model card](https://huggingface.co/facebook/mbart-large-50-many-to-one-mmt).
26
+
27
+ Once the model is loaded, a dropdown UI will be displayed, where the user can select the source language of their prompt. The user can then write their prompt in the desired language and press the "Generate" button to generate the image. The prompt will automatically be translated to English, and the resulting image will look as described in the text.
28
+
29
+ Here are some screenshots of the extension in work:
30
+
31
+ ![image](https://user-images.githubusercontent.com/827993/228090321-2554472d-6fd0-4449-a6d4-190a62ddcce9.png)
32
+ ![image](https://user-images.githubusercontent.com/827993/228090380-9f2f8928-4698-403e-8ed5-94043ed25480.png)
33
+
34
+ Using the X/Y/Z script, we can test changing words in another language. Here is French:
35
+ ![image](https://user-images.githubusercontent.com/827993/229276434-6e024886-13d8-4aa5-b143-6622e544f192.png)
36
+
37
+ ## Supported Languages
38
+
39
+ The list of supported languages is: Arabic (ar_AR), Czech (cs_CZ), German (de_DE), English (en_XX), Spanish (es_XX), Estonian (et_EE), Finnish (fi_FI), French (fr_XX), Gujarati (gu_IN), Hindi (hi_IN), Italian (it_IT), Japanese (ja_XX), Kazakh (kk_KZ), Korean (ko_KR), Lithuanian (lt_LT), Latvian (lv_LV), Burmese (my_MM), Nepali (ne_NP), Dutch (nl_XX), Romanian (ro_RO), Russian (ru_RU), Sinhala (si_LK), Turkish (tr_TR), Vietnamese (vi_VN), Chinese (zh_CN), Afrikaans (af_ZA), Azerbaijani (az_AZ), Bengali (bn_IN), Persian (fa_IR), Hebrew (he_IL), Croatian (hr_HR), Indonesian (id_ID), Georgian (ka_GE), Khmer (km_KH), Macedonian (mk_MK), Malayalam (ml_IN), Mongolian (mn_MN), Marathi (mr_IN), Polish (pl_PL), Pashto (ps_AF), Portuguese (pt_XX), Swedish (sv_SE), Swahili (sw_KE), Tamil (ta_IN), Telugu (te_IN), Thai (th_TH), Tagalog (tl_XX), Ukrainian (uk_UA), Urdu (ur_PK), Xhosa (xh_ZA), Galician (gl_ES), Slovene (sl_SI).
40
+
41
+ ## License
42
+
43
+ This project is licensed under the MIT license.
44
+
45
+ ## Contributing
46
+ Contributions to prompt_translator are welcome! If you find a bug or have an idea for a new feature, please create an issue on the project's GitHub page. If you'd like to contribute code, please fork the repository, make your changes, and submit a pull request.
prompt_translator/scripts/__pycache__/main.cpython-310.pyc ADDED
Binary file (13.8 kB). View file
 
prompt_translator/scripts/main.py ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MBartTranslator :
2
+ # Author : ParisNeo
3
+ # Description : This script translates Stable diffusion prompt from one of the 50 languages supported by MBART
4
+ # It uses MBartTranslator class that provides a simple interface for translating text using the MBart language model.
5
+
6
+ import modules.scripts as scripts
7
+ import gradio as gr
8
+ from modules.shared import opts
9
+
10
+ from transformers import MBart50TokenizerFast, MBartForConditionalGeneration
11
+ import re
12
+ import os
13
+
14
+ # The directory to store the models
15
+ cache_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'models')
16
+
17
+ class MBartTranslator:
18
+ """MBartTranslator class provides a simple interface for translating text using the MBart language model.
19
+
20
+ The class can translate between 50 languages and is based on the "facebook/mbart-large-50-many-to-many-mmt"
21
+ pre-trained MBart model. However, it is possible to use a different MBart model by specifying its name.
22
+
23
+ Attributes:
24
+ model (MBartForConditionalGeneration): The MBart language model.
25
+ tokenizer (MBart50TokenizerFast): The MBart tokenizer.
26
+ """
27
+
28
+ def __init__(self, model_name="facebook/mbart-large-50-many-to-many-mmt", src_lang=None, tgt_lang=None):
29
+
30
+ self.supported_languages = [
31
+ "ar_AR",
32
+ "de_DE",
33
+ "en_XX",
34
+ "es_XX",
35
+ "fr_XX",
36
+ "hi_IN",
37
+ "it_IT",
38
+ "ja_XX",
39
+ "ko_XX",
40
+ "pt_XX",
41
+ "ru_RU",
42
+ "zh_XX",
43
+ "af_ZA",
44
+ "bn_BD",
45
+ "bs_XX",
46
+ "ca_XX",
47
+ "cs_CZ",
48
+ "da_XX",
49
+ "el_GR",
50
+ "et_EE",
51
+ "fa_IR",
52
+ "fi_FI",
53
+ "gu_IN",
54
+ "he_IL",
55
+ "hi_XX",
56
+ "hr_HR",
57
+ "hu_HU",
58
+ "id_ID",
59
+ "is_IS",
60
+ "ja_XX",
61
+ "jv_XX",
62
+ "ka_GE",
63
+ "kk_XX",
64
+ "km_KH",
65
+ "kn_IN",
66
+ "ko_KR",
67
+ "lo_LA",
68
+ "lt_LT",
69
+ "lv_LV",
70
+ "mk_MK",
71
+ "ml_IN",
72
+ "mr_IN",
73
+ "ms_MY",
74
+ "ne_NP",
75
+ "nl_XX",
76
+ "no_XX",
77
+ "pl_XX",
78
+ "ro_RO",
79
+ "si_LK",
80
+ "sk_SK",
81
+ "sl_SI",
82
+ "sq_AL",
83
+ "sr_XX",
84
+ "sv_XX",
85
+ "sw_TZ",
86
+ "ta_IN",
87
+ "te_IN",
88
+ "th_TH",
89
+ "tl_PH",
90
+ "tr_TR",
91
+ "uk_UA",
92
+ "ur_PK",
93
+ "vi_VN",
94
+ "war_PH",
95
+ "yue_XX",
96
+ "zh_CN",
97
+ "zh_TW",
98
+ ]
99
+ print("Building translator")
100
+ print("Loading generator (this may take few minutes the first time as I need to download the model)")
101
+ self.model = MBartForConditionalGeneration.from_pretrained(model_name, cache_dir=cache_dir)
102
+ print("Loading tokenizer")
103
+ self.tokenizer = MBart50TokenizerFast.from_pretrained(model_name, src_lang=src_lang, tgt_lang=tgt_lang, cache_dir=cache_dir)
104
+ print("Translator is ready")
105
+
106
+ def translate(self, text: str, input_language: str, output_language: str) -> str:
107
+ """Translate the given text from the input language to the output language.
108
+
109
+ Args:
110
+ text (str): The text to translate.
111
+ input_language (str): The input language code (e.g. "hi_IN" for Hindi).
112
+ output_language (str): The output language code (e.g. "en_US" for English).
113
+
114
+ Returns:
115
+ str: The translated text.
116
+ """
117
+ if input_language not in self.supported_languages:
118
+ raise ValueError(f"Input language not supported. Supported languages: {self.supported_languages}")
119
+ if output_language not in self.supported_languages:
120
+ raise ValueError(f"Output language not supported. Supported languages: {self.supported_languages}")
121
+
122
+ self.tokenizer.src_lang = input_language
123
+ encoded_input = self.tokenizer(text, return_tensors="pt")
124
+ generated_tokens = self.model.generate(
125
+ **encoded_input, forced_bos_token_id=self.tokenizer.lang_code_to_id[output_language]
126
+ )
127
+ translated_text = self.tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
128
+
129
+ return translated_text[0]
130
+
131
+
132
+
133
+ class LanguageOption:
134
+ """
135
+ A class representing a language option in a language selector.
136
+
137
+ Attributes:
138
+ label (str): The display label for the language option.
139
+ language_code (str): The ISO 639-1 language code for the language option.
140
+ """
141
+
142
+ def __init__(self, label, language_code):
143
+ """
144
+ Initializes a new LanguageOption instance.
145
+
146
+ Args:
147
+ label (str): The display label for the language option.
148
+ language_code (str): The ISO 639-1 language code for the language option.
149
+ """
150
+ self.label = label
151
+ self.language_code = language_code
152
+
153
+
154
+
155
+ # This is a list of LanguageOption objects that represent the various language options available.
156
+ # Each LanguageOption object contains a label that represents the display name of the language and
157
+ # a language code that represents the code for the language that will be used by the translation model.
158
+ # The language codes follow a format of "xx_YY" where "xx" represents the language code and "YY" represents the
159
+ # country or region code. If the language code is not specific to a country or region, then "XX" is used instead.
160
+ # For example, "en_XX" represents English language and "fr_FR" represents French language specific to France.
161
+ # These LanguageOption objects will be used to display the language options to the user and to retrieve the
162
+ # corresponding language code when the user selects a language.
163
+ language_options = [
164
+ LanguageOption("عربية", "ar_AR"),
165
+ LanguageOption("Deutsch", "de_DE"),
166
+ LanguageOption("Español", "es_XX"),
167
+ LanguageOption("Français", "fr_XX"),
168
+ LanguageOption("हिन्दी", "hi_IN"),
169
+ LanguageOption("Italiano", "it_IT"),
170
+ LanguageOption("日本語", "ja_XX"),
171
+ LanguageOption("한국어", "ko_XX"),
172
+ LanguageOption("Português", "pt_XX"),
173
+ LanguageOption("Русский", "ru_RU"),
174
+ LanguageOption("中文", "zh_CN"),
175
+ LanguageOption("Afrikaans", "af_ZA"),
176
+ LanguageOption("বাংলা", "bn_BD"),
177
+ LanguageOption("Bosanski", "bs_XX"),
178
+ LanguageOption("Català", "ca_XX"),
179
+ LanguageOption("Čeština", "cs_CZ"),
180
+ LanguageOption("Dansk", "da_XX"),
181
+ LanguageOption("Ελληνικά", "el_GR"),
182
+ LanguageOption("Eesti", "et_EE"),
183
+ LanguageOption("فارسی", "fa_IR"),
184
+ LanguageOption("Suomi", "fi_FI"),
185
+ LanguageOption("ગુજરાતી", "gu_IN"),
186
+ LanguageOption("עברית", "he_IL"),
187
+ LanguageOption("हिन्दी", "hi_XX"),
188
+ LanguageOption("Hrvatski", "hr_HR"),
189
+ LanguageOption("Magyar", "hu_HU"),
190
+ LanguageOption("Bahasa Indonesia", "id_ID"),
191
+ LanguageOption("Íslenska", "is_IS"),
192
+ LanguageOption("日本語", "ja_XX"),
193
+ LanguageOption("Javanese", "jv_XX"),
194
+ LanguageOption("ქართული", "ka_GE"),
195
+ LanguageOption("Қазақ", "kk_XX"),
196
+ LanguageOption("ខ្មែរ", "km_KH"),
197
+ LanguageOption("ಕನ್ನಡ", "kn_IN"),
198
+ LanguageOption("한국어", "ko_KR"),
199
+ LanguageOption("ລາວ", "lo_LA"),
200
+ LanguageOption("Lietuvių", "lt_LT"),
201
+ LanguageOption("Latviešu", "lv_LV"),
202
+ LanguageOption("Македонски", "mk_MK"),
203
+ LanguageOption("മലയാളം", "ml_IN"),
204
+ LanguageOption("मराठी", "mr_IN"),
205
+ LanguageOption("Bahasa Melayu", "ms_MY"),
206
+ LanguageOption("नेपाली", "ne_NP"),
207
+ LanguageOption("Nederlands", "nl_XX"),
208
+ LanguageOption("Norsk", "no_XX"),
209
+ LanguageOption("Polski", "pl_XX"),
210
+ LanguageOption("Română", "ro_RO"),
211
+ LanguageOption("සිංහල", "si_LK"),
212
+ LanguageOption("Slovenčina", "sk_SK"),
213
+ LanguageOption("Slovenščina", "sl_SI"),
214
+ LanguageOption("Shqip", "sq_AL"),
215
+ LanguageOption("Turkish", "tr_TR"),
216
+ LanguageOption("Tiếng Việt", "vi_VN")
217
+ ]
218
+
219
+ def remove_unnecessary_spaces(text):
220
+ """Removes unnecessary spaces between characters."""
221
+ pattern = r"\)\s*\+\+|\)\+\+\s*"
222
+ replacement = r")++"
223
+ return re.sub(pattern, replacement, text)
224
+
225
+ def correct_translation_format(original_text, translated_text):
226
+ original_parts = original_text.split('++')
227
+ translated_parts = translated_text.split('++')
228
+
229
+ corrected_parts = []
230
+ for i, original_part in enumerate(original_parts):
231
+ translated_part = translated_parts[i]
232
+
233
+ original_plus_count = original_part.count('+')
234
+ translated_plus_count = translated_part.count('+')
235
+ plus_difference = translated_plus_count - original_plus_count
236
+
237
+ if plus_difference > 0:
238
+ translated_part = translated_part.replace('+' * plus_difference, '', 1)
239
+ elif plus_difference < 0:
240
+ translated_part += '+' * abs(plus_difference)
241
+
242
+ corrected_parts.append(translated_part)
243
+
244
+ corrected_text = '++'.join(corrected_parts)
245
+ return corrected_text
246
+
247
+ def extract_plus_positions(text):
248
+ """
249
+ Given a string of text, extracts the positions of all sequences of one or more '+' characters.
250
+
251
+ Args:
252
+ - text (str): the input text
253
+
254
+ Returns:
255
+ - positions (list of lists): a list of [start, end, count] for each match, where start is the index of the
256
+ first '+' character, end is the index of the last '+' character + 1, and count is the number of '+' characters
257
+ in the match.
258
+ """
259
+ # Match any sequence of one or more '+' characters
260
+ pattern = re.compile(r'\++')
261
+
262
+ # Find all matches of the pattern in the text
263
+ matches = pattern.finditer(text)
264
+
265
+ # Loop through the matches and add their positions to the output list
266
+ positions = []
267
+ last_match_end = None
268
+ for match in matches:
269
+ if last_match_end is not None and match.start() != last_match_end:
270
+ # If there is a gap between the current match and the previous one, add a new position
271
+ j = last_match_end - 1
272
+ while text[j] == "+":
273
+ j -= 1
274
+ j += 1
275
+ positions.append([j, last_match_end, last_match_end - j])
276
+
277
+ last_match_end = match.end()
278
+
279
+ # If the final match extends to the end of the string, add its position to the output list
280
+ if last_match_end is not None and last_match_end == len(text):
281
+ j = last_match_end - 1
282
+ while text[j] == "+":
283
+ j -= 1
284
+ j += 1
285
+ positions.append([j, last_match_end, last_match_end - j])
286
+
287
+ return positions
288
+
289
+
290
+ def match_pluses(original_text, translated_text):
291
+ """
292
+ Given two strings of text, replaces sequences of '+' characters in the second string with the corresponding
293
+ sequences of '+' characters in the first string.
294
+
295
+ Args:
296
+ - original_text (str): the original text
297
+ - translated_text (str): the translated text with '+' characters
298
+
299
+ Returns:
300
+ - output (str): the translated text with '+' characters replaced by those in the original text
301
+ """
302
+ in_positions = extract_plus_positions(original_text)
303
+ out_positions = extract_plus_positions(translated_text)
304
+
305
+ out_vals = []
306
+ out_current_pos = 0
307
+
308
+ if len(in_positions) == len(out_positions):
309
+ # Iterate through the positions and replace the sequences of '+' characters in the translated text
310
+ # with those in the original text
311
+ for in_, out_ in zip(in_positions, out_positions):
312
+ out_vals.append(translated_text[out_current_pos:out_[0]])
313
+ out_vals.append(original_text[in_[0]:in_[1]])
314
+ out_current_pos = out_[1]
315
+
316
+ # Check that the number of '+' characters in the original and translated sequences is the same
317
+ if in_[2] != out_[2]:
318
+ print("detected different + count")
319
+
320
+ # Add any remaining text from the translated string to the output
321
+ out_vals.append(translated_text[out_current_pos:])
322
+
323
+ # Join the output values into a single string
324
+ output = "".join(out_vals)
325
+ return output
326
+
327
+ def post_process_prompt(original, translated):
328
+ """Applies post-processing to the translated prompt such as removing unnecessary spaces and extra plus signs."""
329
+ clean_prompt = remove_unnecessary_spaces(translated)
330
+ clean_prompt = match_pluses(original, clean_prompt)
331
+ #clean_prompt = remove_extra_plus(clean_prompt)
332
+ return clean_prompt
333
+
334
+ class Script(scripts.Script):
335
+ def __init__(self) -> None:
336
+ """Initializes the Script class and sets the default value for enable_translation attribute."""
337
+ super().__init__()
338
+ self.enable_translation=False
339
+ self.is_negative_translate_active=False
340
+
341
+ def title(self):
342
+ """Returns the title of the script."""
343
+ return "Translate prompt to english"
344
+
345
+ def show(self, is_img2img):
346
+ """Returns the visibility status of the script in the interface."""
347
+ return scripts.AlwaysVisible
348
+
349
+ def set_active(self, active):
350
+ """Sets the is_active attribute and initializes the translator object if not already created.
351
+ Also, sets the visibility of the language dropdown to True."""
352
+ self.is_active=active
353
+ if not hasattr(self, "translator"):
354
+ self.translator = MBartTranslator()
355
+ return "ready", self.options.update(visible=True)
356
+
357
+ def set_negative_translate_active(self, negative_translate_active):
358
+ """Sets the is_active attribute and initializes the translator object if not already created.
359
+ Also, sets the visibility of the language dropdown to True."""
360
+ self.is_negative_translate_active=negative_translate_active
361
+
362
+
363
+
364
+ def ui(self, is_img2img):
365
+ """Sets up the user interface of the script."""
366
+ self.is_active=False
367
+ self.current_axis_options = [x for x in language_options]
368
+
369
+ with gr.Row():
370
+ with gr.Column(scale=19):
371
+ with gr.Accordion("Prompt Translator",open=False):
372
+ with gr.Accordion("Help",open=False):
373
+ md = gr.Markdown("""
374
+ # Description
375
+ This script translates your prompt from another language to english before generating the image allowing you to write prompts in your native language.
376
+ # How to use
377
+ Select Enable translation and wait until you the label shows ready.
378
+ Once the label has Ready on it, select the prompt language, write the prompt in the prompt field then press generate. The script will translate the prompt and generate the text.
379
+ # Note
380
+ First time you enable the script, it may take a long time (around a minute), but once loaded, it will be faster.
381
+ """)
382
+ with gr.Column():
383
+ self.enable_translation = gr.Checkbox(label="Enable translation")
384
+ with gr.Column() as options:
385
+ self.options=options
386
+ self.translate_negative_prompt = gr.Checkbox(label="Translate negative prompt")
387
+ self.enable_translation.value=False
388
+ self.language = gr.Dropdown(
389
+ label="Source language",
390
+ choices=[x.label for x in self.current_axis_options],
391
+ value="Français",
392
+ type="index",
393
+ elem_id=self.elem_id("x_type")
394
+ )
395
+ self.output=gr.Label("After enabling translation, please Wait until I am ready")
396
+ self.enable_translation.change(
397
+ self.set_active,
398
+ [self.enable_translation],
399
+ [self.output, self.options],
400
+ show_progress=True
401
+ )
402
+ self.translate_negative_prompt.change(
403
+ self.set_negative_translate_active,
404
+ [self.translate_negative_prompt],
405
+ )
406
+
407
+ self.options.visible=False
408
+ return [self.language]
409
+
410
+ def get_prompts(self, p):
411
+ """Returns the original prompts and negative prompts associated with a Prompt object."""
412
+ original_prompts = p.all_prompts if len(p.all_prompts) > 0 else [p.prompt]
413
+ original_negative_prompts = (
414
+ p.all_negative_prompts
415
+ if len(p.all_negative_prompts) > 0
416
+ else [p.negative_prompt]
417
+ )
418
+
419
+ return original_prompts, original_negative_prompts
420
+
421
+ def process(self, p, language, **kwargs):
422
+ """Translates the prompts from a non-English language to English using the MBartTranslator object."""
423
+
424
+ if hasattr(self, "translator") and self.is_active:
425
+ original_prompts, original_negative_prompts = self.get_prompts(p)
426
+ translated_prompts=[]
427
+ previous_prompt = ""
428
+ previous_translated_prompt = ""
429
+
430
+ for original_prompt in original_prompts:
431
+ if previous_prompt != original_prompt:
432
+ print(f"Translating prompt to English from {language_options[language].label}")
433
+ print(f"Initial prompt:{original_prompt}")
434
+ ln_code = language_options[language].language_code
435
+ translated_prompt = self.translator.translate(original_prompt, ln_code, "en_XX")
436
+ translated_prompt = post_process_prompt(original_prompt, translated_prompt)
437
+ print(f"Translated prompt:{translated_prompt}")
438
+ translated_prompts.append(translated_prompt)
439
+
440
+ previous_prompt=original_prompt
441
+ previous_translated_prompt = translated_prompt
442
+ else:
443
+ translated_prompts.append(previous_translated_prompt)
444
+
445
+
446
+ if p.negative_prompt!='' and self.is_negative_translate_active:
447
+ previous_negative_prompt = ""
448
+ previous_translated_negative_prompt = ""
449
+ translated_negative_prompts=[]
450
+ for negative_prompt in original_negative_prompts:
451
+ if previous_negative_prompt!=negative_prompt:
452
+ print(f"Translating negative prompt to English from {language_options[language].label}")
453
+ print(f"Initial negative prompt:{negative_prompt}")
454
+ ln_code = language_options[language].language_code
455
+ translated_negative_prompt = self.translator.translate(negative_prompt, ln_code, "en_XX")
456
+ translated_negative_prompt = post_process_prompt(negative_prompt,translated_negative_prompt)
457
+ print(f"Translated negative prompt:{translated_negative_prompt}")
458
+ translated_negative_prompts.append(translated_negative_prompt)
459
+
460
+
461
+ previous_negative_prompt = negative_prompt
462
+ previous_translated_negative_prompt = translated_negative_prompt
463
+ else:
464
+ translated_negative_prompts.append(previous_translated_negative_prompt)
465
+
466
+ p.negative_prompt = translated_negative_prompts[0]
467
+ p.all_negative_prompts = translated_negative_prompts
468
+ p.prompt = translated_prompts[0]
469
+ p.prompt_for_display = translated_prompts[0]
470
+ p.all_prompts=translated_prompts
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/added_tokens.json ADDED
File without changes
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
3
+ size 0
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/model.safetensors.index.json ADDED
File without changes
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/.no_exist/44d4131e08a5a9b2183e2da22898829fc554ab4e/tokenizer.json ADDED
File without changes
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/024ddcc796a33d2e4decd4c1bd5fe90ad295aaba9072edb3796a09ef9b755934 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:024ddcc796a33d2e4decd4c1bd5fe90ad295aaba9072edb3796a09ef9b755934
3
+ size 2444714899
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/45fccfb2bb92e64115346219ea10b8388bbcdd74 ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "decoder_start_token_id": 2,
5
+ "early_stopping": true,
6
+ "eos_token_id": 2,
7
+ "forced_eos_token_id": 2,
8
+ "max_length": 200,
9
+ "num_beams": 5,
10
+ "pad_token_id": 1,
11
+ "transformers_version": "4.27.0.dev0"
12
+ }
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/ceb27363e751c4b33905f24aa046188be4f38882 ADDED
@@ -0,0 +1 @@
 
 
1
+ {"src_lang": null, "tgt_lang": null, "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "cls_token": "<s>", "pad_token": "<pad>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "bos_token": "<s>", "tokenizer_file": null, "language_codes": "ML50", "special_tokens_map_file": "/home/suraj/projects/mbart-50/mbart-50/special_tokens_map.json", "name_or_path": "/home/suraj/projects/mbart-50/hf_models/mbart-50-large-many-to-many/"}
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/edabc105ab15c9ee8c030daa9f9780831b4c0fd2 ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": "<mask>", "additional_special_tokens": ["ar_AR", "cs_CZ", "de_DE", "en_XX", "es_XX", "et_EE", "fi_FI", "fr_XX", "gu_IN", "hi_IN", "it_IT", "ja_XX", "kk_KZ", "ko_KR", "lt_LT", "lv_LV", "my_MM", "ne_NP", "nl_XX", "ro_RO", "ru_RU", "si_LK", "tr_TR", "vi_VN", "zh_CN", "af_ZA", "az_AZ", "bn_IN", "fa_IR", "he_IL", "hr_HR", "id_ID", "ka_GE", "km_KH", "mk_MK", "ml_IN", "mn_MN", "mr_IN", "pl_PL", "ps_AF", "pt_XX", "sv_SE", "sw_KE", "ta_IN", "te_IN", "th_TH", "tl_XX", "uk_UA", "ur_PK", "xh_ZA", "gl_ES", "sl_SI"]}
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/blobs/f72b537ec40e699db3bb26ab7b2cadecef4b0801 ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/home/suraj/projects/mbart-50/hf_models/mbart-50-large-many-to-many/",
3
+ "_num_labels": 3,
4
+ "activation_dropout": 0.0,
5
+ "activation_function": "relu",
6
+ "add_bias_logits": false,
7
+ "add_final_layer_norm": true,
8
+ "architectures": [
9
+ "MBartForConditionalGeneration"
10
+ ],
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 0,
13
+ "classif_dropout": 0.0,
14
+ "classifier_dropout": 0.0,
15
+ "d_model": 1024,
16
+ "decoder_attention_heads": 16,
17
+ "decoder_ffn_dim": 4096,
18
+ "decoder_layerdrop": 0.0,
19
+ "decoder_layers": 12,
20
+ "decoder_start_token_id": 2,
21
+ "dropout": 0.1,
22
+ "early_stopping": true,
23
+ "encoder_attention_heads": 16,
24
+ "encoder_ffn_dim": 4096,
25
+ "encoder_layerdrop": 0.0,
26
+ "encoder_layers": 12,
27
+ "eos_token_id": 2,
28
+ "forced_eos_token_id": 2,
29
+ "gradient_checkpointing": false,
30
+ "id2label": {
31
+ "0": "LABEL_0",
32
+ "1": "LABEL_1",
33
+ "2": "LABEL_2"
34
+ },
35
+ "init_std": 0.02,
36
+ "is_encoder_decoder": true,
37
+ "label2id": {
38
+ "LABEL_0": 0,
39
+ "LABEL_1": 1,
40
+ "LABEL_2": 2
41
+ },
42
+ "max_length": 200,
43
+ "max_position_embeddings": 1024,
44
+ "model_type": "mbart",
45
+ "normalize_before": true,
46
+ "normalize_embedding": true,
47
+ "num_beams": 5,
48
+ "num_hidden_layers": 12,
49
+ "output_past": true,
50
+ "pad_token_id": 1,
51
+ "scale_embedding": true,
52
+ "static_position_embeddings": false,
53
+ "tokenizer_class": "MBart50Tokenizer",
54
+ "transformers_version": "4.9.0.dev0",
55
+ "use_cache": true,
56
+ "vocab_size": 250054
57
+ }
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/refs/main ADDED
@@ -0,0 +1 @@
 
 
1
+ 44d4131e08a5a9b2183e2da22898829fc554ab4e
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/home/suraj/projects/mbart-50/hf_models/mbart-50-large-many-to-many/",
3
+ "_num_labels": 3,
4
+ "activation_dropout": 0.0,
5
+ "activation_function": "relu",
6
+ "add_bias_logits": false,
7
+ "add_final_layer_norm": true,
8
+ "architectures": [
9
+ "MBartForConditionalGeneration"
10
+ ],
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 0,
13
+ "classif_dropout": 0.0,
14
+ "classifier_dropout": 0.0,
15
+ "d_model": 1024,
16
+ "decoder_attention_heads": 16,
17
+ "decoder_ffn_dim": 4096,
18
+ "decoder_layerdrop": 0.0,
19
+ "decoder_layers": 12,
20
+ "decoder_start_token_id": 2,
21
+ "dropout": 0.1,
22
+ "early_stopping": true,
23
+ "encoder_attention_heads": 16,
24
+ "encoder_ffn_dim": 4096,
25
+ "encoder_layerdrop": 0.0,
26
+ "encoder_layers": 12,
27
+ "eos_token_id": 2,
28
+ "forced_eos_token_id": 2,
29
+ "gradient_checkpointing": false,
30
+ "id2label": {
31
+ "0": "LABEL_0",
32
+ "1": "LABEL_1",
33
+ "2": "LABEL_2"
34
+ },
35
+ "init_std": 0.02,
36
+ "is_encoder_decoder": true,
37
+ "label2id": {
38
+ "LABEL_0": 0,
39
+ "LABEL_1": 1,
40
+ "LABEL_2": 2
41
+ },
42
+ "max_length": 200,
43
+ "max_position_embeddings": 1024,
44
+ "model_type": "mbart",
45
+ "normalize_before": true,
46
+ "normalize_embedding": true,
47
+ "num_beams": 5,
48
+ "num_hidden_layers": 12,
49
+ "output_past": true,
50
+ "pad_token_id": 1,
51
+ "scale_embedding": true,
52
+ "static_position_embeddings": false,
53
+ "tokenizer_class": "MBart50Tokenizer",
54
+ "transformers_version": "4.9.0.dev0",
55
+ "use_cache": true,
56
+ "vocab_size": 250054
57
+ }
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "decoder_start_token_id": 2,
5
+ "early_stopping": true,
6
+ "eos_token_id": 2,
7
+ "forced_eos_token_id": 2,
8
+ "max_length": 200,
9
+ "num_beams": 5,
10
+ "pad_token_id": 1,
11
+ "transformers_version": "4.27.0.dev0"
12
+ }
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:024ddcc796a33d2e4decd4c1bd5fe90ad295aaba9072edb3796a09ef9b755934
3
+ size 2444714899
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": "<mask>", "additional_special_tokens": ["ar_AR", "cs_CZ", "de_DE", "en_XX", "es_XX", "et_EE", "fi_FI", "fr_XX", "gu_IN", "hi_IN", "it_IT", "ja_XX", "kk_KZ", "ko_KR", "lt_LT", "lv_LV", "my_MM", "ne_NP", "nl_XX", "ro_RO", "ru_RU", "si_LK", "tr_TR", "vi_VN", "zh_CN", "af_ZA", "az_AZ", "bn_IN", "fa_IR", "he_IL", "hr_HR", "id_ID", "ka_GE", "km_KH", "mk_MK", "ml_IN", "mn_MN", "mr_IN", "pl_PL", "ps_AF", "pt_XX", "sv_SE", "sw_KE", "ta_IN", "te_IN", "th_TH", "tl_XX", "uk_UA", "ur_PK", "xh_ZA", "gl_ES", "sl_SI"]}
prompt_translator/scripts/models/models--facebook--mbart-large-50-many-to-many-mmt/snapshots/44d4131e08a5a9b2183e2da22898829fc554ab4e/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"src_lang": null, "tgt_lang": null, "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "cls_token": "<s>", "pad_token": "<pad>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "bos_token": "<s>", "tokenizer_file": null, "language_codes": "ML50", "special_tokens_map_file": "/home/suraj/projects/mbart-50/mbart-50/special_tokens_map.json", "name_or_path": "/home/suraj/projects/mbart-50/hf_models/mbart-50-large-many-to-many/"}