Giter Site home page Giter Site logo

parisneo / prompt_translator Goto Github PK

View Code? Open in Web Editor NEW
156.0 156.0 23.0 67 KB

A stable diffusion extension for translating prompts from 50 languages. The objective is to give users the possibility to use their own language to perform text prompting.

License: MIT License

Python 100.00%

prompt_translator's Issues

A bug has occurred

A bug has occurred, and the Chinese negative prompt word is not available. The software did not translate or load negative prompt words, only positive prompt words were translated.I hope you can solve it

Batch issue

When doing a batch of prompts, the extension translate each batch.

Example: I write my prompt and then i want to generate 50 images with this prompt, this should only translate once... but it translate 50 times (for the same prompt)

如何在WebAPI中启用这个插件?

实测在WebUI中能够正常翻译中文提示词,但是我希望在API的使用使用,该怎么写参数或者调用哪个接口才可以启用呢?

TypeError: 'method' object is not subscriptable

TypeError: 'method' object is not subscriptable
'''
Error calling: /home/xuji/stable-diffusion-webui/extensions/prompt_translator/scripts/main.py/ui
Traceback (most recent call last):
File "/home/xuji/stable-diffusion-webui/modules/scripts.py", line 270, in wrap_call
res = func(*args, **kwargs)
File "/home/xuji/stable-diffusion-webui/extensions/prompt_translator/scripts/main.py", line 403, in ui
self.set_negative_translate_active
TypeError: 'method' object is not subscriptable
'''

Unnecessary spaces in the translation break the prompt

When translating, the markup is damaged. For example, if part of prompt is taken in parentheses and followed by '+' signs for reinforcement, spaces appear before '+' signs after translation, it breaks prompt.
traslator-bug

You probably don't affect this directly, but as an option you might consider post-processing the text and removing spaces before control characters.

Error installing dictionary

When the dictionary starts to download, an error occurs

in
DESCRIPTOR = _descriptor.FileDescriptor(
File "D:\stable-diffusion-portable-main\venv\lib\site-packages\google\protobuf\descriptor.py", line 1072, in new
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool: duplicate file name sentencepiece_model.proto

ValueError: Couldn't instantiate the backend tokenizer

ValueError: Couldn't instantiate the backend tokenizer from one of:
(1) a tokenizers library serialization file,
(2) a slow tokenizer instance to convert or
(3) an equivalent slow tokenizer class to instantiate and convert.
You need to have sentencepiece installed to convert a slow tokenizer to a fast one.

what can i do

无法在sdwebuiapi中使用

感谢作者的付出,我在使用中遇到如下问题:
Error running process: /home/cui/stable-diffusion-webui/extensions/prompt_translator/scripts/main.py
Traceback (most recent call last):
File "/home/cui/stable-diffusion-webui/modules/scripts.py", line 417, in process
script.process(p, *script_args)
File "/home/cui/stable-diffusion-webui/extensions/prompt_translator/scripts/main.py", line 432, in process
print(f"Translating prompt to English from {language_options[language].label}")
TypeError: list indices must be integers or slices, not str

本地中使用是正常的,但在weiuiapi中报这个错误

Model is [mbart-large-50-many-to-one-mmt], not [mbart-large-50-one-to-many-mmt]

in README.md
usage section, should refer to Hugging Face model card.

many-to-one, not one-to-many.

I followed the instruction and downloaded the model,
same name and size,
but it won't do the translation 😢

Because of network condition, I didn't have a way to get the program to download the model automatically. So I did it manually, then I found the problem, It's not the model.

After I use the right model, the translation is OK,
as below:

Translating prompt to English from 中文
Initial prompt:一位**的公主,骑在独角兽上。
Translated prompt:A Chinese princess, riding on a unicorn.

I think the code might be right, but readme is wrong.

Error activating Enable translation

Hi:

I want to try this extension but after following the steps it gives me the following error:

"Building translator
Loading generator (this may take few minutes the first time as I need to download the model)
Loading tokenizer
(...)
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates"

Can you help me? Thank you

Nice idea, but...

...is completely useless for the Hungarian language. Here are three samples:

Initial prompt:egy lány a bozótban áll meztelenül, mögötte piros autó
Translated prompt:You know, Egyptian land, and a sketch, all of that melodrama, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know

Translated by DeepL: a girl standing naked in the bush with a red car behind her


Initial prompt:egy béka ül a tó partján, mögötte nádas
Translated prompt:Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian Egyptian

Translated by DeepL: a frog sitting on the shore of a pond with reeds behind him


Initial prompt:béka ül a tó partján, mögötte nádas
Translated prompt:You know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know, you know

Translated by DeepL: frog sitting on the shore of the lake, reeds behind him

So it translates completely differently, so that needs to be improved.

Doesn't work

Error running process: \Downloads\stable-diffusion-webui-master\stable-diffusion-webui-master\extensions\prompt_translator\scripts\main.py
Traceback (most recent call last):
File "
\Downloads\stable-diffusion-webui-master\stable-diffusion-webui-master\modules\scripts.py", line 417, in process
script.process(p, *script_args)
TypeError: Script.process() missing 1 required positional argument: 'language'

Wrong negative prompt

Initial negative prompt:color
Translated negative prompt:The Committee recommends that the State party:

API, auto-detect, NLLB-200

Hello everyone,
I love the translation feature. I have some questions:

  1. is it possible to call it over API?
  2. is it possible to autodetect the source language?
  3. is it possible to use NLLB-200 anyhow?

Thank you so much,
Johannes

Translation from English into English

It would be nice to have a minimal setting, for example, to be able to turn off the translation of a negative prompt, I have a negative prompt in English already fixed in the ui-config.json file. I think you need to remove the translation from English to English, it does not happen correctly. I write a prompt in my native language, but I add specific terms in English, as a result of the translation, the wrong prompt is obtained. How to remove an extension? Where is the Downloading pytorch_model.bin file located: 100%| 2.44G/2.44G ?

After downloading 2.4 GB of data and restarting the UI, the language selection did not appear.

Hi,

015 - Stable Diffusion - 127 0 0 1 - 2023-03-29_18-08-16

Building translator
Loading generator
Loading tokenizer
Traceback (most recent call last):
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
    result = await self.call_function(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "E:\Program Files\Stable_Diffusion\stable-diffusion-webui\extensions\prompt_translator\scripts\main.py", line 206, in set_active
    self.translator = MBartTranslator()
  File "E:\Program Files\Stable_Diffusion\stable-diffusion-webui\extensions\prompt_translator\scripts\main.py", line 99, in __init__
    self.tokenizer = MBart50TokenizerFast.from_pretrained(model_name, src_lang=src_lang, tgt_lang=tgt_lang)
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\tokenization_utils_base.py", line 1804, in from_pretrained
    return cls._from_pretrained(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\tokenization_utils_base.py", line 1959, in _from_pretrained
    tokenizer = cls(*init_inputs, **init_kwargs)
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\models\mbart50\tokenization_mbart50_fast.py", line 135, in __init__
    super().__init__(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\tokenization_utils_fast.py", line 114, in __init__
    fast_tokenizer = convert_slow_tokenizer(slow_tokenizer)
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\convert_slow_tokenizer.py", line 1162, in convert_slow_tokenizer
    return converter_class(transformer_tokenizer).converted()
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\convert_slow_tokenizer.py", line 438, in __init__
    from .utils import sentencepiece_model_pb2 as model_pb2
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\transformers\utils\sentencepiece_model_pb2.py", line 92, in <module>
    _descriptor.EnumValueDescriptor(
  File "e:\Program Files\Stable_Diffusion\stable-diffusion-webui\venv\lib\site-packages\google\protobuf\descriptor.py", line 796, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.