-
-
Notifications
You must be signed in to change notification settings - Fork 593
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]: Last Update #757
Comments
Do we really need the config file? Aren't we normalizing everything too much? |
It was a mess before. the args are the same, but moved to a file. this is --help & the config structure
{
"$defs": {
"Alignment": {
"enum": [
"auto",
"left",
"center",
"right"
],
"title": "Alignment",
"type": "string"
},
"Colorizer": {
"enum": [
"none",
"mc2"
],
"title": "Colorizer",
"type": "string"
},
"ColorizerConfig": {
"properties": {
"colorization_size": {
"default": 576,
"title": "Colorization Size",
"type": "integer"
},
"denoise_sigma": {
"default": 30,
"title": "Denoise Sigma",
"type": "integer"
},
"colorizer": {
"$ref": "#/$defs/Colorizer",
"default": "none"
}
},
"title": "ColorizerConfig",
"type": "object"
},
"Detector": {
"enum": [
"default",
"dbconvnext",
"ctd",
"craft",
"none"
],
"title": "Detector",
"type": "string"
},
"DetectorConfig": {
"properties": {
"detector": {
"$ref": "#/$defs/Detector",
"default": "default"
},
"detection_size": {
"default": 1536,
"title": "Detection Size",
"type": "integer"
},
"text_threshold": {
"default": 0.5,
"title": "Text Threshold",
"type": "number"
},
"det_rotate": {
"default": false,
"title": "Det Rotate",
"type": "boolean"
},
"det_auto_rotate": {
"default": false,
"title": "Det Auto Rotate",
"type": "boolean"
},
"det_invert": {
"default": false,
"title": "Det Invert",
"type": "boolean"
},
"det_gamma_correct": {
"default": false,
"title": "Det Gamma Correct",
"type": "boolean"
},
"box_threshold": {
"default": 0.7,
"title": "Box Threshold",
"type": "number"
},
"unclip_ratio": {
"default": 2.3,
"title": "Unclip Ratio",
"type": "number"
}
},
"title": "DetectorConfig",
"type": "object"
},
"Direction": {
"enum": [
"auto",
"horizontal",
"vertical"
],
"title": "Direction",
"type": "string"
},
"InpaintPrecision": {
"enum": [
"fp32",
"fp16",
"bf16"
],
"title": "InpaintPrecision",
"type": "string"
},
"Inpainter": {
"enum": [
"default",
"lama_large",
"lama_mpe",
"sd",
"none",
"original"
],
"title": "Inpainter",
"type": "string"
},
"InpainterConfig": {
"properties": {
"inpainter": {
"$ref": "#/$defs/Inpainter",
"default": "none"
},
"inpainting_size": {
"default": 2048,
"title": "Inpainting Size",
"type": "integer"
},
"inpainting_precision": {
"$ref": "#/$defs/InpaintPrecision",
"default": "fp32"
}
},
"title": "InpainterConfig",
"type": "object"
},
"Ocr": {
"enum": [
"32px",
"48px",
"48px_ctc",
"mocr"
],
"title": "Ocr",
"type": "string"
},
"OcrConfig": {
"properties": {
"use_mocr_merge": {
"default": false,
"title": "Use Mocr Merge",
"type": "boolean"
},
"ocr": {
"$ref": "#/$defs/Ocr",
"default": "48px"
},
"min_text_length": {
"default": 0,
"title": "Min Text Length",
"type": "integer"
},
"ignore_bubble": {
"default": 0,
"title": "Ignore Bubble",
"type": "integer"
}
},
"title": "OcrConfig",
"type": "object"
},
"RenderConfig": {
"properties": {
"renderer": {
"$ref": "#/$defs/Renderer",
"default": "default"
},
"alignment": {
"$ref": "#/$defs/Alignment",
"default": "auto"
},
"disable_font_border": {
"default": false,
"title": "Disable Font Border",
"type": "boolean"
},
"font_size_offset": {
"default": 0,
"title": "Font Size Offset",
"type": "integer"
},
"font_size_minimum": {
"default": -1,
"title": "Font Size Minimum",
"type": "integer"
},
"direction": {
"$ref": "#/$defs/Direction",
"default": "auto"
},
"uppercase": {
"default": false,
"title": "Uppercase",
"type": "boolean"
},
"lowercase": {
"default": false,
"title": "Lowercase",
"type": "boolean"
},
"gimp_font": {
"default": "Sans-serif",
"title": "Gimp Font",
"type": "string"
},
"no_hyphenation": {
"default": false,
"title": "No Hyphenation",
"type": "boolean"
},
"font_color": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Font Color"
},
"line_spacing": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Line Spacing"
},
"font_size": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Font Size"
}
},
"title": "RenderConfig",
"type": "object"
},
"Renderer": {
"enum": [
"default",
"manga2eng",
"none"
],
"title": "Renderer",
"type": "string"
},
"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"
},
"TranslatorConfig": {
"properties": {
"translator": {
"$ref": "#/$defs/Translator",
"default": "sugoi"
},
"target_lang": {
"default": "ENG",
"title": "Target Lang",
"type": "string"
},
"no_text_lang_skip": {
"default": false,
"title": "No Text Lang Skip",
"type": "boolean"
},
"skip_lang": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Skip Lang"
},
"gpt_config": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Gpt Config"
},
"translator_chain": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Translator Chain"
},
"selective_translation": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Selective Translation"
}
},
"title": "TranslatorConfig",
"type": "object"
},
"UpscaleConfig": {
"properties": {
"upscaler": {
"$ref": "#/$defs/Upscaler",
"default": "esrgan"
},
"revert_upscaling": {
"default": false,
"title": "Revert Upscaling",
"type": "boolean"
},
"upscale_ratio": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Upscale Ratio"
}
},
"title": "UpscaleConfig",
"type": "object"
},
"Upscaler": {
"enum": [
"waifu2x",
"esrgan",
"4xultrasharp"
],
"title": "Upscaler",
"type": "string"
}
},
"properties": {
"filter_text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filter Text"
},
"render": {
"$ref": "#/$defs/RenderConfig",
"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,
"font_color": null,
"line_spacing": null,
"font_size": null
}
},
"upscale": {
"$ref": "#/$defs/UpscaleConfig",
"default": {
"upscaler": "esrgan",
"revert_upscaling": false,
"upscale_ratio": null
}
},
"translator": {
"$ref": "#/$defs/TranslatorConfig",
"default": {
"translator": "sugoi",
"target_lang": "ENG",
"no_text_lang_skip": false,
"skip_lang": null,
"gpt_config": null,
"translator_chain": null,
"selective_translation": null
}
},
"detector": {
"$ref": "#/$defs/DetectorConfig",
"default": {
"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": {
"$ref": "#/$defs/ColorizerConfig",
"default": {
"colorization_size": 576,
"denoise_sigma": 30,
"colorizer": "none"
}
},
"inpainter": {
"$ref": "#/$defs/InpainterConfig",
"default": {
"inpainter": "none",
"inpainting_size": 2048,
"inpainting_precision": "fp32"
}
},
"ocr": {
"$ref": "#/$defs/OcrConfig",
"default": {
"use_mocr_merge": false,
"ocr": "48px",
"min_text_length": 0,
"ignore_bubble": 0
}
},
"kernel_size": {
"default": 3,
"title": "Kernel Size",
"type": "integer"
},
"mask_dilation_offset": {
"default": 0,
"title": "Mask Dilation Offset",
"type": "integer"
}
},
"title": "Config",
"type": "object"
} |
Id say this is what a config file was made for, since you repeatedly use the same configuration & the arguments can be grouped/sorted into groups. There are many arguments. This may be new roght now, but will make it easier for everyone to work with |
Here's the schema converted to a html site |
you can always change default args. i don't know this seems more complex. I prefer to use the old version but I will try to use it this way, thanks for the diagram. |
I changed it because the args can be different between jpn translation, Chinese, big text & small text. and if you want to modify the default config you have a cleaner config file. you don't need to pass in the config path. there are default values, that can be changed, in the config.py, but then you can just change it in a config file which makes more sense. there were a lot of args that were meant to be used with a specific mode which was refactored into the modes. there are less args. if you want a specific configuration you can pass in the config path. Before it was unclear what arg belonged to what that's why it was moved into a structured file & it can't be more complex, because the args are still the same. I copied the args sorted them and dumped them into a class, which is loaded from a file(json, [toml(open request)]). Also the config can also be an api request input, which makes it easier to use with a running service. I think just starting the translator without doing anything takes up 2-5s. Which can be worked around using the api. There isn't a good ui for that yet, but theoretically it would make more sense to start a service and use the webui, as every setting is in the request and not in the args |
I am using the API version and can you help me with the addresses? |
windows linux both |
i'm now using "http://192.168.68.102:5004/inpaint_translate" it does work on 192.168.68.102 and port 5004 server is live but error is i try /translate/bytes same error i'm on linux |
I correct myself there was an issue with the cmd execution. python server/main.py --port 5003 will work with the fix in the pull request #759 |
server was refactored. checkout /docs |
openapi dump {"openapi":"3.1.0","info":{"title":"FastAPI","version":"0.1.0"},"paths":{"/register":{"post":{"tags":["internal-api"],"summary":"Register Instance","operationId":"register_instance_register_post","parameters":[{"name":"X-Nonce","in":"header","required":true,"schema":{"type":"string","title":"X-Nonce"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorInstance"}}}},"responses":{"200":{"description":"no response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/json":{"post":{"tags":["api","json"],"summary":"Json","operationId":"json_translate_json_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslateRequest"}}},"required":true},"responses":{"200":{"description":"json strucure inspired by the ichigo translator extension","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/bytes":{"post":{"tags":["api","json"],"summary":"Bytes","operationId":"bytes_translate_bytes_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslateRequest"}}},"required":true},"responses":{"200":{"description":"custom byte structure for decoding look at examples in 'examples/response.*'"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/image":{"post":{"tags":["api","json"],"summary":"Image","operationId":"image_translate_image_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslateRequest"}}},"required":true},"responses":{"200":{"description":"the result image"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/json/stream":{"post":{"tags":["api","json"],"summary":"Stream Json","operationId":"stream_json_translate_json_stream_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslateRequest"}}},"required":true},"responses":{"200":{"description":"A stream over elements with strucure(1byte status, 4 byte size, n byte data) status code are 0,1,2,3,4 0 is result data, 1 is progress report, 2 is error, 3 is waiting queue position, 4 is waiting for translator instance"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/bytes/stream":{"post":{"tags":["api","json"],"summary":"Stream Bytes","operationId":"stream_bytes_translate_bytes_stream_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslateRequest"}}},"required":true},"responses":{"200":{"description":"A stream over elements with strucure(1byte status, 4 byte size, n byte data) status code are 0,1,2,3,4 0 is result data, 1 is progress report, 2 is error, 3 is waiting queue position, 4 is waiting for translator instance"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/image/stream":{"post":{"tags":["api","json"],"summary":"Stream Image","operationId":"stream_image_translate_image_stream_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslateRequest"}}},"required":true},"responses":{"200":{"description":"A stream over elements with strucure(1byte status, 4 byte size, n byte data) status code are 0,1,2,3,4 0 is result data, 1 is progress report, 2 is error, 3 is waiting queue position, 4 is waiting for translator instance"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/with-form/json":{"post":{"tags":["api","form"],"summary":"Json Form","operationId":"json_form_translate_with_form_json_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_json_form_translate_with_form_json_post"}}},"required":true},"responses":{"200":{"description":"json strucure inspired by the ichigo translator extension","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TranslationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/with-form/bytes":{"post":{"tags":["api","form"],"summary":"Bytes Form","operationId":"bytes_form_translate_with_form_bytes_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_bytes_form_translate_with_form_bytes_post"}}},"required":true},"responses":{"200":{"description":"custom byte structure for decoding look at examples in 'examples/response.*'"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/with-form/image":{"post":{"tags":["api","form"],"summary":"Image Form","operationId":"image_form_translate_with_form_image_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_image_form_translate_with_form_image_post"}}},"required":true},"responses":{"200":{"description":"the result image"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/with-form/json/stream":{"post":{"tags":["api","form"],"summary":"Stream Json Form","operationId":"stream_json_form_translate_with_form_json_stream_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_stream_json_form_translate_with_form_json_stream_post"}}},"required":true},"responses":{"200":{"description":"A stream over elements with strucure(1byte status, 4 byte size, n byte data) status code are 0,1,2,3,4 0 is result data, 1 is progress report, 2 is error, 3 is waiting queue position, 4 is waiting for translator instance"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/with-form/bytes/stream":{"post":{"tags":["api","form"],"summary":"Stream Bytes Form","operationId":"stream_bytes_form_translate_with_form_bytes_stream_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_stream_bytes_form_translate_with_form_bytes_stream_post"}}},"required":true},"responses":{"200":{"description":"A stream over elements with strucure(1byte status, 4 byte size, n byte data) status code are 0,1,2,3,4 0 is result data, 1 is progress report, 2 is error, 3 is waiting queue position, 4 is waiting for translator instance"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/translate/with-form/image/stream":{"post":{"tags":["api","form"],"summary":"Stream Image Form","operationId":"stream_image_form_translate_with_form_image_stream_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_stream_image_form_translate_with_form_image_stream_post"}}},"required":true},"responses":{"200":{"description":"A stream over elements with strucure(1byte status, 4 byte size, n byte data) status code are 0,1,2,3,4 0 is result data, 1 is progress report, 2 is error, 3 is waiting queue position, 4 is waiting for translator instance"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/queue-size":{"post":{"tags":["api","json"],"summary":"Queue Size","operationId":"queue_size_queue_size_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"integer","title":"Response Queue Size Queue Size Post"}}}}}}},"/":{"get":{"tags":["ui"],"summary":"Index","operationId":"index__get","responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/manual":{"get":{"tags":["ui"],"summary":"Manual","operationId":"manual_manual_get","responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"Alignment":{"type":"string","enum":["auto","left","center","right"],"title":"Alignment"},"Body_bytes_form_translate_with_form_bytes_post":{"properties":{"image":{"type":"string","format":"binary","title":"Image"},"config":{"type":"string","title":"Config","default":"{}"}},"type":"object","required":["image"],"title":"Body_bytes_form_translate_with_form_bytes_post"},"Body_image_form_translate_with_form_image_post":{"properties":{"image":{"type":"string","format":"binary","title":"Image"},"config":{"type":"string","title":"Config","default":"{}"}},"type":"object","required":["image"],"title":"Body_image_form_translate_with_form_image_post"},"Body_json_form_translate_with_form_json_post":{"properties":{"image":{"type":"string","format":"binary","title":"Image"},"config":{"type":"string","title":"Config","default":"{}"}},"type":"object","required":["image"],"title":"Body_json_form_translate_with_form_json_post"},"Body_stream_bytes_form_translate_with_form_bytes_stream_post":{"properties":{"image":{"type":"string","format":"binary","title":"Image"},"config":{"type":"string","title":"Config","default":"{}"}},"type":"object","required":["image"],"title":"Body_stream_bytes_form_translate_with_form_bytes_stream_post"},"Body_stream_image_form_translate_with_form_image_stream_post":{"properties":{"image":{"type":"string","format":"binary","title":"Image"},"config":{"type":"string","title":"Config","default":"{}"}},"type":"object","required":["image"],"title":"Body_stream_image_form_translate_with_form_image_stream_post"},"Body_stream_json_form_translate_with_form_json_stream_post":{"properties":{"image":{"type":"string","format":"binary","title":"Image"},"config":{"type":"string","title":"Config","default":"{}"}},"type":"object","required":["image"],"title":"Body_stream_json_form_translate_with_form_json_stream_post"},"Colorizer":{"type":"string","enum":["none","mc2"],"title":"Colorizer"},"ColorizerConfig":{"properties":{"colorization_size":{"type":"integer","title":"Colorization Size","default":576},"denoise_sigma":{"type":"integer","title":"Denoise Sigma","default":30},"colorizer":{"$ref":"#/components/schemas/Colorizer","default":"none"}},"type":"object","title":"ColorizerConfig"},"Config":{"properties":{"filter_text":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Filter Text"},"render":{"$ref":"#/components/schemas/RenderConfig","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}},"upscale":{"$ref":"#/components/schemas/UpscaleConfig","default":{"upscaler":"esrgan","revert_upscaling":false}},"translator":{"$ref":"#/components/schemas/TranslatorConfig","default":{"translator":"sugoi","target_lang":"ENG","no_text_lang_skip":false}},"detector":{"$ref":"#/components/schemas/DetectorConfig","default":{"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":{"$ref":"#/components/schemas/ColorizerConfig","default":{"colorization_size":576,"denoise_sigma":30,"colorizer":"none"}},"inpainter":{"$ref":"#/components/schemas/InpainterConfig","default":{"inpainter":"none","inpainting_size":2048,"inpainting_precision":"fp32"}},"ocr":{"$ref":"#/components/schemas/OcrConfig","default":{"use_mocr_merge":false,"ocr":"48px","min_text_length":0,"ignore_bubble":0}},"kernel_size":{"type":"integer","title":"Kernel Size","default":3},"mask_dilation_offset":{"type":"integer","title":"Mask Dilation Offset","default":0}},"type":"object","title":"Config"},"Detector":{"type":"string","enum":["default","dbconvnext","ctd","craft","none"],"title":"Detector"},"DetectorConfig":{"properties":{"detector":{"$ref":"#/components/schemas/Detector","default":"default"},"detection_size":{"type":"integer","title":"Detection Size","default":1536},"text_threshold":{"type":"number","title":"Text Threshold","default":0.5},"det_rotate":{"type":"boolean","title":"Det Rotate","default":false},"det_auto_rotate":{"type":"boolean","title":"Det Auto Rotate","default":false},"det_invert":{"type":"boolean","title":"Det Invert","default":false},"det_gamma_correct":{"type":"boolean","title":"Det Gamma Correct","default":false},"box_threshold":{"type":"number","title":"Box Threshold","default":0.7},"unclip_ratio":{"type":"number","title":"Unclip Ratio","default":2.3}},"type":"object","title":"DetectorConfig"},"Direction":{"type":"string","enum":["auto","horizontal","vertical"],"title":"Direction"},"ExecutorInstance":{"properties":{"ip":{"type":"string","title":"Ip"},"port":{"type":"integer","title":"Port"},"busy":{"type":"boolean","title":"Busy","default":false}},"type":"object","required":["ip","port"],"title":"ExecutorInstance"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InpaintPrecision":{"type":"string","enum":["fp32","fp16","bf16"],"title":"InpaintPrecision"},"Inpainter":{"type":"string","enum":["default","lama_large","lama_mpe","sd","none","original"],"title":"Inpainter"},"InpainterConfig":{"properties":{"inpainter":{"$ref":"#/components/schemas/Inpainter","default":"none"},"inpainting_size":{"type":"integer","title":"Inpainting Size","default":2048},"inpainting_precision":{"$ref":"#/components/schemas/InpaintPrecision","default":"fp32"}},"type":"object","title":"InpainterConfig"},"Ocr":{"type":"string","enum":["32px","48px","48px_ctc","mocr"],"title":"Ocr"},"OcrConfig":{"properties":{"use_mocr_merge":{"type":"boolean","title":"Use Mocr Merge","default":false},"ocr":{"$ref":"#/components/schemas/Ocr","default":"48px"},"min_text_length":{"type":"integer","title":"Min Text Length","default":0},"ignore_bubble":{"type":"integer","title":"Ignore Bubble","default":0}},"type":"object","title":"OcrConfig"},"RenderConfig":{"properties":{"renderer":{"$ref":"#/components/schemas/Renderer","default":"default"},"alignment":{"$ref":"#/components/schemas/Alignment","default":"auto"},"disable_font_border":{"type":"boolean","title":"Disable Font Border","default":false},"font_size_offset":{"type":"integer","title":"Font Size Offset","default":0},"font_size_minimum":{"type":"integer","title":"Font Size Minimum","default":-1},"direction":{"$ref":"#/components/schemas/Direction","default":"auto"},"uppercase":{"type":"boolean","title":"Uppercase","default":false},"lowercase":{"type":"boolean","title":"Lowercase","default":false},"gimp_font":{"type":"string","title":"Gimp Font","default":"Sans-serif"},"no_hyphenation":{"type":"boolean","title":"No Hyphenation","default":false},"font_color":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Font Color"},"line_spacing":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Line Spacing"},"font_size":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Font Size"}},"type":"object","title":"RenderConfig"},"Renderer":{"type":"string","enum":["default","manga2eng","none"],"title":"Renderer"},"TextColor":{"properties":{"fg":{"prefixItems":[{"type":"integer"},{"type":"integer"},{"type":"integer"}],"type":"array","maxItems":3,"minItems":3,"title":"Fg"},"bg":{"prefixItems":[{"type":"integer"},{"type":"integer"},{"type":"integer"}],"type":"array","maxItems":3,"minItems":3,"title":"Bg"}},"type":"object","required":["fg","bg"],"title":"TextColor"},"TranslateRequest":{"properties":{"image":{"anyOf":[{"type":"string","format":"binary"},{"type":"string"}],"title":"Image"},"config":{"$ref":"#/components/schemas/Config","default":{"render":{"alignment":"auto","direction":"auto","disable_font_border":false,"font_size_minimum":-1,"font_size_offset":0,"gimp_font":"Sans-serif","lowercase":false,"no_hyphenation":false,"renderer":"default","uppercase":false},"upscale":{"revert_upscaling":false,"upscaler":"esrgan"},"translator":{"no_text_lang_skip":false,"target_lang":"ENG","translator":"sugoi"},"detector":{"box_threshold":0.7,"det_auto_rotate":false,"det_gamma_correct":false,"det_invert":false,"det_rotate":false,"detection_size":1536,"detector":"default","text_threshold":0.5,"unclip_ratio":2.3},"colorizer":{"colorization_size":576,"colorizer":"none","denoise_sigma":30},"inpainter":{"inpainter":"none","inpainting_precision":"fp32","inpainting_size":2048},"ocr":{"ignore_bubble":0,"min_text_length":0,"ocr":"48px","use_mocr_merge":false},"kernel_size":3,"mask_dilation_offset":0}}},"type":"object","required":["image"],"title":"TranslateRequest","description":"This request can be a multipart or a json request"},"Translation":{"properties":{"minX":{"type":"integer","title":"Minx"},"minY":{"type":"integer","title":"Miny"},"maxX":{"type":"integer","title":"Maxx"},"maxY":{"type":"integer","title":"Maxy"},"is_bulleted_list":{"type":"boolean","title":"Is Bulleted List"},"angle":{"anyOf":[{"type":"number"},{"type":"integer"}],"title":"Angle"},"prob":{"type":"number","title":"Prob"},"text_color":{"$ref":"#/components/schemas/TextColor"},"text":{"additionalProperties":{"type":"string"},"type":"object","title":"Text"},"background":{"type":"string","format":"base64","title":"Background","description":"Background image encoded as a base64 string","examples":["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA..."]}},"type":"object","required":["minX","minY","maxX","maxY","is_bulleted_list","angle","prob","text_color","text","background"],"title":"Translation"},"TranslationResponse":{"properties":{"translations":{"items":{"$ref":"#/components/schemas/Translation"},"type":"array","title":"Translations"}},"type":"object","required":["translations"],"title":"TranslationResponse"},"Translator":{"type":"string","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"},"TranslatorConfig":{"properties":{"translator":{"$ref":"#/components/schemas/Translator","default":"sugoi"},"target_lang":{"type":"string","title":"Target Lang","default":"ENG"},"no_text_lang_skip":{"type":"boolean","title":"No Text Lang Skip","default":false},"skip_lang":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Skip Lang"},"gpt_config":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Gpt Config"},"translator_chain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Translator Chain"},"selective_translation":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Selective Translation"}},"type":"object","title":"TranslatorConfig"},"UpscaleConfig":{"properties":{"upscaler":{"$ref":"#/components/schemas/Upscaler","default":"esrgan"},"revert_upscaling":{"type":"boolean","title":"Revert Upscaling","default":false},"upscale_ratio":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Upscale Ratio"}},"type":"object","title":"UpscaleConfig"},"Upscaler":{"type":"string","enum":["waifu2x","esrgan","4xultrasharp"],"title":"Upscaler"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}} |
if you want to use the stream version(with progress) the encoding is quite easy. the data is encoded with statuscode(1byte) chunk size(4 bytes) data (chunk size bytes). there can be multiple chunks in a stream chunk. an example can be found in the manual.html. the bytes route can be loaded from c++/rust etc. examples can be found in the examples folder |
Okay, I will send and process it as you wish. But what I mean is, are the addresses absolutely correct? Even if I send it in the wrong type, it always gives me a 404 error. It was working in yesterday's version. I changed the format_translate part a little bit to send the masked image.Even if I type /translate/image or /inpaint_translate Is it normal that it always gives 404? |
the html files / and /manual got a bit messed up. it worked in pycharm, but it failed with python server/main.py. I fixed this issue in the open pull request & will be merged soon. the inpaint_translate will always fail bc the route does not exist anymore. the new route would be /translate/image or /translate/json. the valid formats are json & multipart form. if using multipart form the config is a json string(json.dumps or json.stringify/no object just a unprocessed json file/string). Important is that it is no get request, but post request which is probably the issue you are running into. const formData = new FormData();
formData.append('image', file);
const text = configField.innerText;
if (text.length > 2) {
formData.append('config', text)
}
async function process(response, statusField, errorField, image) {
if (response.ok) {
const reader = response.body.getReader();
const decoder = new TextDecoder('utf-8');
let buffer = new Uint8Array();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const newBuffer = new Uint8Array(buffer.length + value.length);
newBuffer.set(buffer);
newBuffer.set(value, buffer.length);
buffer = newBuffer;
while (buffer.length >= 5) {
const dataSize = new DataView(buffer.buffer).getUint32(1, false);
const totalSize = 5 + dataSize;
if (buffer.length < totalSize) {
break;
}
const statusCode = buffer[0];
const data = buffer.slice(5, totalSize);
if(statusCode === 0) {
if(image) {
gdata = new Blob([data], { type: 'application/octet-stream' });
statusField.innerHTML = '<button onclick="download_bytes()">download data</button>';
}else {
gdata = decoder.decode(data);
statusField.innerHTML = '<button onclick="downloadFile()">download data</button>';
}
}else if(statusCode === 1) {
const parsed_data = decoder.decode(data);
statusField.innerHTML = `translation step ${parsed_data}`;
}else if(statusCode === 2) {
statusField.innerHTML = decoder.decode(data);
errorField.innerHTML = "";
}else if(statusCode === 3) {
const parsed_data = decoder.decode(data);
statusField.innerHTML = `in queue: ${parsed_data}`;
}else if(statusCode === 4) {
statusField.innerHTML = `started translation`;
}
buffer = buffer.slice(totalSize);
}
}
} else {
errorField.innerHTML = response.statusText;
}
}
const response = await fetch( generateImage.checked ? '/translate/with-form/image/stream' : '/translate/with-form/json/stream', {
method: 'POST',
body: formData
});
await process(response, statusField, errorField, generateImage.checked) |
this would be the example for the stream. if you are not using stream the response will be the json text/image bytes |
and ws doesn't work |
if we use shared which means api okey i understand now if we want to use api we need to post request to /execute/translate or /simple_execute/translate addresses because we can only use translate method for MangaTranslator others starts with _. but this is not working either error is please help i don't understand this |
The parts you mentioned are addresses that are not implemented for shared. |
the shared mode is an internal mode that takes in a pickle dump. its meant to allow external programs to access functions. server is one of the things that access the translator. what shared does is take in a function name and bytes that are the attributes. the attributes get split into a tuple by pickle and the response of the function gets dumped by pickle into bytes. the ./server is using this shared module to translate. server has a queue implementated so only a single translation is ran at the same time. the server auto starts a shared instance & everything is handled by the server. the ws module isn't documented anywhere, the local module is what's normally used & the shared module isn't meant to be called manually unless you run a multi instance server. to start the server windows linux both right now there is actually an issue with looking up the html files, so they will show an error when going to routes / and /manual. the patch is in #759 also the linux/windows specific code is not needed once the patch is merged. the server has the /docs route what the patch does is simply resolving the issue with the path of the translator: sys.path.append(os.path.abspath(os.path.join(os.path.dirname(file), '..'))) and fixing the .html file path:
|
the error you got was a corrupted data error. my guess is that you sent a string instead of a pickle.dump to the internal service |
hmmm Okay, so in order to run shared as before like api, I need to simply implement image and other arguments? or i run with server ? |
my goal was to seperate the server & the translator, bc multi instance. should run on a sperate thread etc. the
As you can see I started the server & the server started the translator in shared mode. the server runs on the port you input. and the translator runs on port given +1. the translator can run on a different pc or there could be multiple servers that are accessed by the server program. the server programs job is to manage translators. the first translator is started locally automatically. the shared module can be considered an internal module. ExecutorInstance is dispatching a job to the translator. the shared mode is a low level api for developers that want to hook into the translator without writing custom code. the server is a high level api which is meant to be used by the user. it processes the imgs& isn't returning the raw context from the translator, but a more readable format. also it serves a ui, which is more of a prototype & not really usefull. if someone would convert the http://127.0.0.1:5003/manual to support batches it would be quite usable actually. stilll ugly, tho. |
here's a graphic how the server with multiple instances would work: https://excalidraw.com/#json=rvUhRg_Qk9vehKAtMxDMS,bX_5cDZgRJMnlLpHM6xvwA |
BallonsTranslator for example just copied the code that is used to translate. with the shared module it could be used like native code, since both use python, but just sent/receive from the translator: fetch_data("http://"+self.ip+":"+str(self.port)+"/simple_execute/_run_inpainting",ctx, config). of course this creates a bit of overhead, but it would not require to fork the project & if there are updates in the main project the updates would be automatically applied to the project that uses it |
thanks I managed to get it working. But I have a long job :D I used this app using with this method, i detect text ballons with yolo and sent these fields to the application. it's work slow so i simply run 2-3 app on port 5003 5004 5005 and since I sent it to the application running on more than one port, the speed did not decrease. but now :D it will be more complicated. |
I think a single translator instance takes up all the available resources. the instances were meant if you have mutiple pcs.
it could be that --use-gpu will improve performance if you have a (cuda) gpu |
I use cuda and it works very well. I can use multiple app since it has 16gb vram 4060ti. |
That’s probably due to this project being a collection of models that are chained after each other for a final product. You could try out to modify how many instances are spawned and check if you translate multiple images at once if the time decreases. There is code in place that kills als translators when the server is closed. That's why start_translator is returned.
|
Tbh it doesn't really makes sense that the return isn't at the end, but the caching isn't implemented anyway |
I didn't look into it very closely, but it's starting to get really annoying. I will look at it completely sometime and find a solution, but as I said, it increases over time, according to the pictures. If I can't find the problem, I will restart it from time to time, thank you very much. |
Issue
Can you please revert the last update? Every arg has changed and there is no explanation.
Command Line Arguments
No response
Console logs
No response
The text was updated successfully, but these errors were encountered: