Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ValueError: "TranslatorConfig" object has no field "_translator_gen" #791

Open
pkr5277 opened this issue Dec 16, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@pkr5277
Copy link

pkr5277 commented Dec 16, 2024

Issue

D:\python program\manga-image-translator>python -m manga_translator local --us
e-gpu -v --config-file "D:/python program/manga-image-translator/config-info.toml" -i "F:/漫画&杂志/漫画/commies/狂野的苏西3"
[local] Namespace(verbose=True, attempts=0, ignore_errors=False, model_dir=Non
e, use_gpu=True, use_gpu_limited=False, font_path='', pre_dict=None, post_dict
=None, kernel_size=3, mode='local', input=['F:/漫画&杂志/漫画/commies/狂野的苏
3'], dest='', format=None, overwrite=False, skip_no_text=False, use_mtpe=Fal l
se, save_text=False, save_text_file='', prep_manual=False, save_quality=100, config_file='D:/python program/manga-image-translator/config-info.toml')
[local] Running in local mode
[local] Loading models
ERROR: [local] ValueError: "TranslatorConfig" object has no field "translator_gen"
Traceback (most recent call last):
File "D:\python program\manga-image-translator\manga_translator_main
.py", line 94, in
asyncio.run(dispatch(args))
File "C:\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "D:\python program\manga-image-translator\manga_translator_main_.py", line 56, in dispatch
await translator.translate_path(path, dest, args_dict)
File "D:\python program\manga-image-translator\manga_translator\mode\local.py", line 115, in translate_path
raise e
File "D:\python program\manga-image-translator\manga_translator\mode\local.py", line 111, in translate_path
if await self.translate_file(file_path, output_dest, params, config):
File "D:\python program\manga-image-translator\manga_translator\mode\local.py", line 140, in translate_file
return await self._translate_file(path, dest, config, ctx)
File "D:\python program\manga-image-translator\manga_translator\mode\local.py", line 183, in _translate_file
ctx = await self.translate(img, config)
File "D:\python program\manga-image-translator\manga_translator\manga_translator.py", line 171, in translate
await prepare_translation(config.translator.translator_gen)
File "D:\python program\manga-image-translator\manga_translator\config.py", line 237, in translator_gen
self._translator_gen = TranslatorChain(f'{str(self.translator)}:{self.target_lang}')
File "pydantic\main.py", line 357, in pydantic.main.BaseModel.setattr
ValueError: "TranslatorConfig" object has no field "_translator_gen"

D:/python program/manga-image-translator/config-info.toml

title = "Config"
type = "object"

["$defs".Alignment]
enum = [ "auto", "left", "center", "right" ]
title = "Alignment"
type = "string"

["$defs".Colorizer]
enum = [ "none", "mc2" ]
title = "Colorizer"
type = "string"

["$defs".ColorizerConfig]
title = "ColorizerConfig"
type = "object"

["$defs".ColorizerConfig.properties.colorization_size]
default = 576
title = "Colorization Size"
type = "integer"

["$defs".ColorizerConfig.properties.denoise_sigma]
default = 30
title = "Denoise Sigma"
type = "integer"

["$defs".ColorizerConfig.properties.colorizer]
"$ref" = "#/$defs/Colorizer"
default = "none"

["$defs".Detector]
enum = [ "default", "dbconvnext", "ctd", "craft", "none" ]
title = "Detector"
type = "string"

["$defs".DetectorConfig]
title = "DetectorConfig"
type = "object"

["$defs".DetectorConfig.properties.detector]
"$ref" = "#/$defs/Detector"
default = "default"

["$defs".DetectorConfig.properties.detection_size]
default = 1_536
title = "Detection Size"
type = "integer"

["$defs".DetectorConfig.properties.text_threshold]
default = 0.5
title = "Text Threshold"
type = "number"

["$defs".DetectorConfig.properties.det_rotate]
default = false
title = "Det Rotate"
type = "boolean"

["$defs".DetectorConfig.properties.det_auto_rotate]
default = false
title = "Det Auto Rotate"
type = "boolean"

["$defs".DetectorConfig.properties.det_invert]
default = false
title = "Det Invert"
type = "boolean"

["$defs".DetectorConfig.properties.det_gamma_correct]
default = false
title = "Det Gamma Correct"
type = "boolean"

["$defs".DetectorConfig.properties.box_threshold]
default = 0.7
title = "Box Threshold"
type = "number"

["$defs".DetectorConfig.properties.unclip_ratio]
default = 2.3
title = "Unclip Ratio"
type = "number"

["$defs".Direction]
enum = [ "auto", "horizontal", "vertical" ]
title = "Direction"
type = "string"

["$defs".InpaintPrecision]
enum = [ "fp32", "fp16", "bf16" ]
title = "InpaintPrecision"
type = "string"

["$defs".Inpainter]
enum = [
"default",
"lama_large",
"lama_mpe",
"sd",
"none",
"original"
]
title = "Inpainter"
type = "string"

["$defs".InpainterConfig]
title = "InpainterConfig"
type = "object"

["$defs".InpainterConfig.properties.inpainter]
"$ref" = "#/$defs/Inpainter"
default = "none"

["$defs".InpainterConfig.properties.inpainting_size]
default = 2_048
title = "Inpainting Size"
type = "integer"

["$defs".InpainterConfig.properties.inpainting_precision]
"$ref" = "#/$defs/InpaintPrecision"
default = "fp32"

["$defs".Ocr]
enum = [ "32px", "48px", "48px_ctc", "mocr" ]
title = "Ocr"
type = "string"

["$defs".OcrConfig]
title = "OcrConfig"
type = "object"

["$defs".OcrConfig.properties.use_mocr_merge]
default = false
title = "Use Mocr Merge"
type = "boolean"

["$defs".OcrConfig.properties.ocr]
"$ref" = "#/$defs/Ocr"
default = "48px"

["$defs".OcrConfig.properties.min_text_length]
default = 0
title = "Min Text Length"
type = "integer"

["$defs".OcrConfig.properties.ignore_bubble]
default = 0
title = "Ignore Bubble"
type = "integer"

["$defs".RenderConfig]
title = "RenderConfig"
type = "object"

["$defs".RenderConfig.properties.renderer]
"$ref" = "#/$defs/Renderer"
default = "default"

["$defs".RenderConfig.properties.alignment]
"$ref" = "#/$defs/Alignment"
default = "auto"

["$defs".RenderConfig.properties.disable_font_border]
default = false
title = "Disable Font Border"
type = "boolean"

["$defs".RenderConfig.properties.font_size_offset]
default = 0
title = "Font Size Offset"
type = "integer"

["$defs".RenderConfig.properties.font_size_minimum]
default = -1
title = "Font Size Minimum"
type = "integer"

["$defs".RenderConfig.properties.direction]
"$ref" = "#/$defs/Direction"
default = "auto"

["$defs".RenderConfig.properties.uppercase]
default = false
title = "Uppercase"
type = "boolean"

["$defs".RenderConfig.properties.lowercase]
default = false
title = "Lowercase"
type = "boolean"

["$defs".RenderConfig.properties.gimp_font]
default = "Sans-serif"
title = "Gimp Font"
type = "string"

["$defs".RenderConfig.properties.no_hyphenation]
default = false
title = "No Hyphenation"
type = "boolean"

["$defs".RenderConfig.properties.font_color]
title = "Font Color"

[["$defs".RenderConfig.properties.font_color.anyOf]]
type = "string"

[["$defs".RenderConfig.properties.font_color.anyOf]]
type = "null"

["$defs".RenderConfig.properties.line_spacing]
title = "Line Spacing"

[["$defs".RenderConfig.properties.line_spacing.anyOf]]
type = "integer"

[["$defs".RenderConfig.properties.line_spacing.anyOf]]
type = "null"

["$defs".RenderConfig.properties.font_size]
title = "Font Size"

[["$defs".RenderConfig.properties.font_size.anyOf]]
type = "integer"

[["$defs".RenderConfig.properties.font_size.anyOf]]
type = "null"

["$defs".Renderer]
enum = [ "default", "manga2eng", "none" ]
title = "Renderer"
type = "string"

["$defs".Translator]
enum = [
"youdao",
"baidu",
"deepl",
"papago",
"caiyun",
"gpt3",
"gpt3.5",
"gpt4",
"none",
"original",
"sakura",
"deepseek",
"groq",
"offline",
"nllb",
"nllb_big",
"sugoi",
"jparacrawl",
"jparacrawl_big",
"m2m100",
"m2m100_big",
"mbart50",
"qwen2",
"qwen2_big"
]
title = "Translator"
type = "string"

["$defs".TranslatorConfig]
title = "TranslatorConfig"
type = "object"

["$defs".TranslatorConfig.properties.translator]
"$ref" = "#/$defs/Translator"
default = "sugoi"

["$defs".TranslatorConfig.properties.target_lang]
default = "CHS"
title = "Target Lang"
type = "string"

["$defs".TranslatorConfig.properties.no_text_lang_skip]
default = false
title = "No Text Lang Skip"
type = "boolean"

["$defs".TranslatorConfig.properties.skip_lang]
title = "Skip Lang"

[["$defs".TranslatorConfig.properties.skip_lang.anyOf]]
type = "string"

[["$defs".TranslatorConfig.properties.skip_lang.anyOf]]
type = "null"

["$defs".TranslatorConfig.properties.gpt_config]
title = "Gpt Config"

[["$defs".TranslatorConfig.properties.gpt_config.anyOf]]
type = "string"

[["$defs".TranslatorConfig.properties.gpt_config.anyOf]]
type = "null"

["$defs".TranslatorConfig.properties.translator_chain]
title = "Translator Chain"

[["$defs".TranslatorConfig.properties.translator_chain.anyOf]]
type = "string"

[["$defs".TranslatorConfig.properties.translator_chain.anyOf]]
type = "null"

["$defs".TranslatorConfig.properties.selective_translation]
title = "Selective Translation"

[["$defs".TranslatorConfig.properties.selective_translation.anyOf]]
type = "string"

[["$defs".TranslatorConfig.properties.selective_translation.anyOf]]
type = "null"

["$defs".UpscaleConfig]
title = "UpscaleConfig"
type = "object"

["$defs".UpscaleConfig.properties.upscaler]
"$ref" = "#/$defs/Upscaler"
default = "esrgan"

["$defs".UpscaleConfig.properties.revert_upscaling]
default = false
title = "Revert Upscaling"
type = "boolean"

["$defs".UpscaleConfig.properties.upscale_ratio]
title = "Upscale Ratio"

[["$defs".UpscaleConfig.properties.upscale_ratio.anyOf]]
type = "integer"

[["$defs".UpscaleConfig.properties.upscale_ratio.anyOf]]
type = "null"

["$defs".Upscaler]
enum = [ "waifu2x", "esrgan", "4xultrasharp" ]
title = "Upscaler"
type = "string"

[properties.filter_text]
title = "Filter Text"

[[properties.filter_text.anyOf]]
type = "string"

[[properties.filter_text.anyOf]]
type = "null"

[properties.render]
"$ref" = "#/$defs/RenderConfig"

[properties.render.default]
renderer = "default"
alignment = "auto"
disable_font_border = false
font_size_offset = 0
font_size_minimum = -1
direction = "auto"
uppercase = false
lowercase = false
gimp_font = "Sans-serif"
no_hyphenation = false

[properties.upscale]
"$ref" = "#/$defs/UpscaleConfig"

[properties.upscale.default]
upscaler = "esrgan"
revert_upscaling = false

[properties.translator]
"$ref" = "#/$defs/TranslatorConfig"

[properties.translator.default]
translator = "sugoi"
target_lang = "ENG"
no_text_lang_skip = false

[properties.detector]
"$ref" = "#/$defs/DetectorConfig"

[properties.detector.default]
detector = "default"
detection_size = 1_536
text_threshold = 0.5
det_rotate = false
det_auto_rotate = false
det_invert = false
det_gamma_correct = false
box_threshold = 0.7
unclip_ratio = 2.3

[properties.colorizer]
"$ref" = "#/$defs/ColorizerConfig"

[properties.colorizer.default]
colorization_size = 576
denoise_sigma = 30
colorizer = "none"

[properties.inpainter]
"$ref" = "#/$defs/InpainterConfig"

[properties.inpainter.default]
inpainter = "none"
inpainting_size = 2_048
inpainting_precision = "fp32"

[properties.ocr]
"$ref" = "#/$defs/OcrConfig"

[properties.ocr.default]
use_mocr_merge = false
ocr = "48px"
min_text_length = 0
ignore_bubble = 0

[properties.kernel_size]
default = 3
title = "Kernel Size"
type = "integer"

[properties.mask_dilation_offset]
default = 0
title = "Mask Dilation Offset"
type = "integer"

Command Line Arguments

No response

Console logs

No response

@pkr5277 pkr5277 added the bug Something isn't working label Dec 16, 2024
@pkr5277
Copy link
Author

pkr5277 commented Dec 16, 2024

i use config-example.toml
mask_dilation_offset = 0

[render]
renderer = "default"
alignment = "auto"
disable_font_border = false
font_size_offset = 0
font_size_minimum = -1
direction = "auto"
uppercase = false
lowercase = false
gimp_font = "Sans-serif"
no_hyphenation = false

[upscale]
upscaler = "esrgan"
revert_upscaling = false

[translator]
translator = "sugoi"
target_lang = "ENG"
no_text_lang_skip = false

[detector]
detector = "default"
detection_size = 1536
text_threshold = 0.5
det_rotate = false
det_auto_rotate = false
det_invert = false
det_gamma_correct = false
box_threshold = 0.7
unclip_ratio = 2.3

[colorizer]
colorization_size = 576
denoise_sigma = 30
colorizer = "none"

[inpainter]
inpainter = "none"
inpainting_size = 2048
inpainting_precision = "fp32"

[ocr]
use_mocr_merge = false
ocr = "48px"
min_text_length = 0
ignore_bubble = 0

It still gives the same error

5eqkhrmn xc2

@popcion
Copy link
Contributor

popcion commented Dec 16, 2024

你用config.json试试呢

EDIT: 我现在也发现了这个错误,这个错误是仅在特定图片上才会出现的,也和模型有关,有些模型比如gemini会出现这个错误(我使用newapi将gemini转成openai格式出现了这个错误,暂时没在其他模型遇到这个错误),改模型可以解决。
看错了,我遇到的错误是Error in _request_translation: object of type 'NoneType' has no len()Error in _request_translation: 'NoneType' object is not iterable ERROR: [GPT4Translator] Error during translation attempt: 'NoneType' object is not iterable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants