xulihang / ImageTrans-docs

Documentation of ImageTrans, a computer-aided image translation tool. ImageTrans的文档项目。ImageTrans是一款计算机辅助图片/漫画翻译软件。
https://imagetrans.readthedocs.io/
93 stars 9 forks source link

Custom Workflow Batch? #117

Closed hentaitaku closed 3 weeks ago

hentaitaku commented 2 years ago

Hi i like to know if there is a why to automate a workflow for batch processing.

Like to make this workflow automatic for all images.

Text area detection heuristic Text area confidence Remove low confidence areas Remove non-text areas (OCR) use WinRT Japanese for it Detect balloons (Offline) Text area confidence Remove low confidence areas

Yomikaku (Japanese) OCR Sugoi (Tanslation to English)

Last from your batch image creation and saving as jpeg

xulihang commented 2 years ago

Currently, the custom workflow only supports the following settings:

image

The heuristic detection in batch mode will get text area confidence and remove low confidence areas automatically.

It cannot do the following:

  1. Use balloon detection and heuristic detection together.
  2. Use OCR to remove non-text areas.
  3. Get text area confidences in a single step.

The other steps should be possible using the current custom workflow.

hentaitaku commented 2 years ago

Dont need to be the workflow you mean, can be cli over cmd or a new batch that makes this steps. Just the why it is now is it to much work when it can be made more easy.

I know how to code php js and so on dont know if there is a api or a why to use cli, Like to make it auto so i just need to add images and all steps will be done with one click or min the text area finding stuff.

xulihang commented 2 years ago

You can run it through cli using its silent translator: https://imagetrans.readthedocs.io/en/latest/tools.html#id3

hentaitaku commented 2 years ago

Do you have a better doc for the cli what commends it can use or a example how i can use this over cli.

Text area detection heuristic Text area confidence Remove low confidence areas Remove non-text areas (OCR) use WinRT Japanese for it Detect balloons (Offline) Text area confidence Remove low confidence areas

xulihang commented 2 years ago

You can check out the server version: https://github.com/xulihang/ImageTrans_Server/blob/main/Translate.bas

hentaitaku commented 2 years ago

Hope you can make me a small example so i know how to code it.

Lets say for this how can i run this over cli?

Text area detection heuristic Remove low confidence areas Detect balloons

Hope there is a why lets say add steps in a config file and cli will run it.

xulihang commented 2 years ago

Let's take heuristic detection for example:

command:

java -jar .\ImageTrans.jar .\ja2en.json false true out .\fileList.txt

This will output three files in the out/(md5 hash of the image) dir:

auto.json # json data
image.jpg # original image
image-out.jpg # translated image

ja2en.json:

{
    "auto_clean": true,
    "otsu_enabled": true,
    "horizontal_merge_for_OCR": true,
    "remove_space": true,
    "detection_method": "heuristic",
    "reorder": false,
    "threshold": 200,
    "use_puretext": false,
    "source": "ja",
    "mt_interval": 1000,
    "precision_mode": true,
    "ocr_interval": 200,
    "stripfurigana": false,
    "auto_capital": false,
    "autoThreshold": true,
    "vertical_merge_for_OCR": true,
    "mtengine": "baidu",
    "minimumHeight": 3,
    "addBorder": false,
    "minimumHSpan": 15,
    "target": "en",
    "ocrlang": "jpn_vert",
    "maximumHeight": 100,
    "chinese_punctuation": false,
    "ocrengine": "tesseract (line mode)",
    "minimumVSpan": 15,
    "right2left": true
}

fileList.txt:

E:\B4J\ImageTrans\Objects\003.jpg

If you need to use balloon detection, then change detection_method to balloon.

You can try the GUI interface of silent translator first to have a basic idea of what it does.

hentaitaku commented 2 years ago

Hi i try to run the cli over this command:

"C:\Program Files\Java\jre1.8.0_311\bin\java.exe" -jar "D:\mangareader\batch\ImageTrans\ImageTrans.jar" "D:\mangareader\batch\ja2en.json" false true "D:\mangareader\batch\out" "D:\mangareader\batch\filelist.txt"

But get java errors:

main.start (java line: 37) java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Map). at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111) at anywheresoftware.b4a.BA.raiseEvent(BA.java:78) at org.xulihang.imagetrans.main.start(main.java:37) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:185) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Map). at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:496) at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:450) at anywheresoftware.b4a.BA.handleUncaughtException(BA.java:164) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108) ... 11 more Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Map). at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:487) ... 14 more Caused by: java.lang.RuntimeException: Object should first be initialized (Map). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32) at anywheresoftware.b4a.objects.collections.Map.GetDefault(Map.java:73) at org.xulihang.imagetrans.localizator._localize(localizator.java:265) at org.xulihang.imagetrans.localizator._localizelayout(localizator.java:356) at org.xulihang.imagetrans.localizator._localizeform(localizator.java:272) at org.xulihang.imagetrans.errorreporter._initialize(errorreporter.java:76) at org.xulihang.imagetrans.main._application_error(main.java:1088) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) ... 15 more

hentaitaku commented 2 years ago

Found the error need to run java from the ImageTrans.jar dir.

Is in silent translator a config option for Remove non-text areas (OCR and for Text area confidence > Remove low confidence areas or is auto_clean this option.

Think GUI Batch > Remove non-text areas (OCR) is broken will not remove text areas with any selected ocr, when i use it over edit is it working. When i run GUI Batch > Remove non-text areas (OCR) 2X is it working!

What a nice feature will be when you add all your batch options in the custom workflow.

xulihang commented 3 weeks ago

Run Custom Workflow via CLI: https://github.com/xulihang/ImageTrans-docs/issues/785