Code Monkey home page Code Monkey logo

sickzil-machine's Introduction

SickZil-Machine

English | 한국어

Notice

SZMC 0.1.1 - Fixed link
Tutorials and Tips

Currently, I am still working on the SickZil-Machine. It is just laying the groundwork invisible to users. I'm building the system I need for more effective training data collection, more efficient deep learning model training, faster experimentation and analysis, model serving and deployment automation, etc.
I will go to the distance. I appreciate if you could wait a little longer. Thank you.

szmc-0.1.0 (source: manga109, © Kanno Hiroshi, © Okuda Momoko, © Kato Masaki)

SickZil-Machine automates texts removal during manga/comics translation(Scanlation) process.

SeisinkiVulnus_028

LoveHina_vol14_003

AkkeraKanjinchou_031 All of the above images were edited automatically without human intervention.
(source: manga109, © Shimazaki Yuzuru, © Akamatsu Ken, © Kobayashi Yuki)

How it works??

Model

szmc-structure-eng

SickZil-Machine finds out the texts in manga/comics and erases it naturally to match the background.
Both processes are completely automatic, without any additional human intervention.
Of course, if you want, you can also specify text area you want to erase.

By the way, SickZil is korean word 식질, slang of 식자(작업). 식자 means editing manga/comics according to the translation(from translator).

We applied U-net for SegNet and Deepfill v2 for ComplNet.

Data set

SickZil-Machine consists of two deep learning models, SegNet and ComplNet.

To learn SegNet, we need original manga images and
text component masks that cover all text area corresponding to the original images.

To learn ComplNet, we need manga images with text removed (ie output).
(I'm researching how an images with a small amount of text affects performance.
 manga images with no text at all are the ideal data.)

Version 0.1.1 was trained using 285 image-mask pairs and 31,497 manga images.
(11,464 of 31,497 manga images are images with text.)

If you'd like to contribute a dataset to SickZil-Machine, please send your data to email .
The dataset will only be used for research purposes.

Release

We released 0.1.1 pre-release version!
You can download SZMC here.
Tutorials and Tips here.

SickZil-Machine is not a perfect program. We need your help.
If you find a bug or have a suggestion, please open a Github issue or send us an email.

Run the code(for developers)

You need NVIDIA driver 410.x, CUDA 10.0, CUDNN (>= 7.4.1). (tensorflow 1.13.0 requirements)

  1. git clone https://github.com/KUR-creative/SickZil-Machine.git; cd SickZil-Machine
  2. Download one of release zip files from here.
  3. Unzip the release file and copy SickZil-Machine-0.1.1-pre0-win64-cpu-eng/resource/cnet and SickZil-Machine-0.1.1-pre0-win64-cpu-eng/resource/snet directories to SickZil-Machine/resource.
  4. pip install -r requirements.txt
  5. cd src; python main.py

Future works

  • Increase text segmentation performance
  • Open manga text segmentation mask dataset
  • Automate typesetting(calligraphy style learning)



sickzil-machine's People

Contributors

0x00000ff avatar fanglangxinghai avatar kur-creative avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sickzil-machine's Issues

Refactoring szmc.qml

  • Rename id, objectNames along to consistent convention
    • Use camel case
    • Specify type in tail (Image -> XxxImg)
  • Decompose szmc-0.1.0.qml into multiple modules

--
state

  • window.state

dialog

  • MessageDialog - id: msgDialog
  • FileDialog - id: projectOpenDialog
  • Action - id: openProject

toolButton

....
more

references:
https://doc.qt.io/qt-5/qtqml-javascript-expressions.html
https://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html#

and think about functional reactive programming with qml...

`state` and `gui` modules can't reflect manga project folder changes from outside

If user press {gen_mask, rmtxt, restore_prev_image, ...} after the manga project folder is changed from outside (delete folder, files, etc..), exception occurs:

FileNotFoundError: [Errno 2] No such file or directory: '...'
  • rmtxt on not existing image (damaged images or masks)
  • gen_mask on not existing image (damaged images)
  • restore_prev_image but no prev_image (damaged prev_images)

Find all of this kind of crashes, and warn to user that manga project is damaged.
Or automatically fix.. do something..

0.1.0 Release Test

Write Test Cases First!
https://jaku.tistory.com/17

  • Linux
  • Windows
    --
  • no extension images OK

Automate if you can..

----------- coverage: platform linux, python 3.7.3-final-0 -----------
Name Stmts Miss Cover Missing

/home/kur/dev/SickZil-Machine/src/ImListModel.py 31 3 90% 35-36, 47
/home/kur/dev/SickZil-Machine/src/init.py 0 0 100%
/home/kur/dev/SickZil-Machine/src/config.py 27 1 96% 52
/home/kur/dev/SickZil-Machine/src/core.py 91 19 79% 55-58, 62-69, 141-143, 147-154
/home/kur/dev/SickZil-Machine/src/gui.py 98 34 65% 19-20, 79-91, 96-99, 103-106, 110-112, 142-154, 158-170
/home/kur/dev/SickZil-Machine/src/imgio.py 25 0 100%
/home/kur/dev/SickZil-Machine/src/main.py 9 9 0% 8-19
/home/kur/dev/SickZil-Machine/src/state.py 53 13 75% 41-51, 84-85, 89, 92
/home/kur/dev/SickZil-Machine/src/utils/init.py 0 0 100%
/home/kur/dev/SickZil-Machine/src/utils/fp.py 58 27 53% 16, 19, 26, 30-31, 34-37, 49, 66-89
/home/kur/dev/SickZil-Machine/src/utils/futils.py 46 20 57% 19-24, 33-35, 58-68
/home/kur/dev/SickZil-Machine/src/utils/imutils.py 112 35 69% 18, 33-34, 43-44, 62-64, 69-71, 81-85, 155, 158, 177-186, 199-210, 216-217

TOTAL 550 161 71%

Mask File Deletion

  • Press backspace or delete keys to remove current mask
  • select images in image list and deletion all selected images

Monitoring

Write log file in release build.
How user to report to dev? Think about it..

  • Create a log file each time you run SZMC
  • Log file name is time(or something sortable)
  • Print all informations
    --
  • Maintain server Use cloud service(new relic, firebase, sentry, etc..)
  • Notify users to collect data
  • Send log to server
    --
  • Test error cases: does client send error log correctly? when
    • Crash
    • Invalid machine
      etc..

https://stackoverflow.com/questions/44853059/tensorflow-logging-messages-do-not-appear

Create homepage(github.io) for project

Create web page for v0.1.1

  • Web site for SZMC: Release / Development / Research

For Release and Information

  • Blog(Move posts from old private blog)
  • Download SZMC

For Contribution

  • Contribute Dataset
  • Donate

For Research

  • Download Dataset
  • Challenges
    • SegNet Challenge
    • ComplNet Challenge
    • SZMC Challenge

Others

  • link to Github repositories
  • Contact

Implement "manga project" creation from flat image directory

User can create from "flat image directory"(just has some image files) to "manga project" directory for SickZil-Machine
"manga project" directory has {images, masks, origin_imgs, origin_segmaps}.
UI

  • This function is activated when user selects "flat image directory" in projectOpenDialog.
  • Inform the user what will happen before creation using warning dialog.
  • User can edit name of "manga project directory" using interactive dialog.
  • Decide default name of manga project directory.

internals

  • Test inter-device copying images to manga project directory
  • If project directory already exists, then copy not existing images(no overwirte)

Image or Segmap Reversion

  • Save original images to other directory
    If user change image right affter revert, warn user to overwrite prev image?
  • Save previous mask to prev_masks
    --
  • Revert to original image
  • Revert to prev mask / or first mask? and mask: union with current mask?
  • If no mask file, then just reset mask(to empty)

Just save/revert only images in version 0.1.0

Reversion is very limited undo/redo functionality.
In later versions, implement a proper undo / redo system.

Inference part of image

Set rectangle area with mouse, and then seg->compl.
it would be very efficient. And very useful when user edit a mask after full automated masks generation.

  • User can select part of mask to inference

Implement drawing tools

Brush

  • cursor
  • size control
  • tool button
  • shortcut key
    slider for size control later.

Rectangle

  • cursor
  • drawing effect (like gimp)
  • tool button
  • actual drawing
  • shortcut key

Line

Line(use shift, like gimp)
draw line with shift key (like gimp)
drawing effect (like gimp)

later.

Panning

  • cursor
  • tool button
  • Panning image with mouse wheel(Is it possible?)

Use right mouse to erase? Think about it..

Public Release

  • 디시인사이드 만화 갤러리
  • Add Request(부탁): please inform szmc to use icon.
  • Add escape clause(면책 조항)
  • Rework release page and release section in README
    --
  • Correct English docs
  • Reddit
    --
    etc..

Few general code quality improvement suggestions

  1. requirements.txt
    Add a requirements.txt for dependencies such as Tensorflow with an exact required version

  2. black linting/formatting
    Add a Black formatting configuration to ensure code quality https://github.com/psf/black

  3. License
    Add a LICENSE file

  4. Don't put actual initiation code under under if __name__ == '__main__':, instead you should:

def main():
    consts.load_config('../resource/config.json')
    app = QApplication(sys.argv)

    engine = QQmlApplicationEngine()
    main_window = gui.MainWindow(engine)
    
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

Automatic inference limit setting

Problem

If image is too big, SZMC crashes.

  • Catch OOM,
  • and then update seg_limit or compl_limit in config.json
Generate Masks:  45%|████████████████████████████▌                                   | 127/285 [10:15<12:25,  4.72s/it]Traceback (most recent call last):
  File "site-packages\tensorflow\python\client\session.py", line 1356, in _do_call
  File "site-packages\tensorflow\python\client\session.py", line 1341, in _run_fn
  File "site-packages\tensorflow\python\client\session.py", line 1429, in _call_tf_sessionrun
tensorflow.python.framework.errors_impl.ResourceExhaustedError: 2 root error(s) found.
  (0) Resource exhausted: OOM when allocating tensor with shape[1,32,2912,1280] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
         [[{{node snet/concatenate_4/concat}}]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

         [[snet/conv2d_19/truediv/_5]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

  (1) Resource exhausted: OOM when allocating tensor with shape[1,32,2912,1280] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
         [[{{node snet/concatenate_4/concat}}]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src\gui.py", line 178, in gen_mask_all
  File "site-packages\tqdm\_tqdm.py", line 1017, in __iter__
  File "src\gui.py", line 20, in imgpath2mask
  File "src\utils\fp.py", line 5, in <lambda>
  File "site-packages\funcy\funcs.py", line 106, in <lambda>
  File "site-packages\funcy\funcs.py", line 106, in <lambda>
  File "src\core.py", line 104, in segmap
  File "src\utils\fp.py", line 5, in <lambda>
  File "site-packages\funcy\funcs.py", line 106, in <lambda>
  File "site-packages\funcy\funcs.py", line 106, in <lambda>
  File "site-packages\funcy\funcs.py", line 106, in <lambda>
  [Previous line repeated 1 more time]
  File "src\core.py", line 103, in <lambda>
  File "src\core.py", line 59, in segment
  File "src\core.py", line 37, in segment_or_oom
  File "src\core.py", line 97, in snet
  File "site-packages\tensorflow\python\client\session.py", line 950, in run
  File "site-packages\tensorflow\python\client\session.py", line 1173, in _run
  File "site-packages\tensorflow\python\client\session.py", line 1350, in _do_run
  File "site-packages\tensorflow\python\client\session.py", line 1370, in _do_call
tensorflow.python.framework.errors_impl.ResourceExhaustedError: 2 root error(s) found.
  (0) Resource exhausted: OOM when allocating tensor with shape[1,32,2912,1280] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
         [[node snet/concatenate_4/concat (defined at src\core.py:25) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

         [[snet/conv2d_19/truediv/_5]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

  (1) Resource exhausted: OOM when allocating tensor with shape[1,32,2912,1280] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
         [[node snet/concatenate_4/concat (defined at src\core.py:25) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

0 successful operations.
0 derived errors ignored.

Original stack trace for 'snet/concatenate_4/concat':
  File "src\main.py", line 11, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "c:\users\kur\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "src\gui.py", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "c:\users\kur\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "src\core.py", line 27, in <module>
  File "src\core.py", line 25, in load_model
  File "site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
  File "site-packages\tensorflow\python\framework\importer.py", line 443, in import_graph_def
  File "site-packages\tensorflow\python\framework\importer.py", line 236, in _ProcessNewOps
  File "site-packages\tensorflow\python\framework\ops.py", line 3751, in _add_new_tf_operations
  File "site-packages\tensorflow\python\framework\ops.py", line 3751, in <listcomp>
  File "site-packages\tensorflow\python\framework\ops.py", line 3641, in _create_op_from_tf_operation
  File "site-packages\tensorflow\python\framework\ops.py", line 2005, in __init__

If the machine crashed while generating the masks / removing texts by GPU OOM error, log in cmd would be like above.

Solution

image
before

image
after

Please edit seg_limit in resource/config.json to smaller value if crash occurs in generating masks.
Please edit compl_limit in resource/config.json to smaller value if crash occurs in removing texts.

In most system, "seg_limit" = 3000000 will fix the bug.
If not, decrease seg_limit more.

Other Solution

Wait next release... It will be fixed, and automatically set the limits.

Add cli mode and option arguments

Good for hackers like you and me!

  • Convert many "flat img dir" -> "mproj"
  • Open many mproj
  • full-auto rmTxt on many mproj

... and more..

Can't find snet/cnet files in release zip

README.md says
Unzip the release file and copy SickZil-Machine-0.1.1-pre0-win64-cpu-eng/resource/cnet and SickZil-Machine-0.1.1-pre0-win64-cpu-eng/resource/snet directories to SickZil-Machine/resource.
But I can't find those files in the release zip. At least not in SickZil-Machine-0.1.1-pre0-win64-cpu-eng.zip or SickZil-Machine-0.1.1-pre0-win64-gpu-eng.zip.

Image loading bug

I've found a bug that the application loads only one page of image when I load a project after loading a project that contains of image.

another case, entire directory cannot be loaded, It seems several glitches exists on file checking routine for filtering images or non-images.

User-friendly (gui) features

  • Button tool tips: explain function, shortcut, etc..
  • Edit typo
  • set Pen / Eraser mode cursor colors or something?
  • Status bar later
  • multilingual support preparation
    • check: pyinstaller can set default cmd arg? or..?
  • Y key to change to previous tool

--

  • Read config.json file and use it (both in qml, py)
  • Full Screen
  • Enter key for single rmtxt
  • Display current working project(display with title)
  • gen_mask, rmtxt progress bar later

--

  • Fix bug: press up/down key in startup page, it deletes qml file in some system. (#16 )
  • next/prev button useless

Implement mask-all, rmtxt-all

  • Warn to User: It takes very long time! (expected time: ...) Ok / No
  • Change icon order: XX-all first, vertical bar, simgle image tools...
  • mask_all
  • rmtxt_all
    --
    if there is mask already then rmtxt?

Need MacOS version

Me is an Apple machine, macbook pro user needs it!
hope can see it in the near future!

진행중 다음 사진으로 넘기면 나오는... 버그 같은

Honeycam 2019-08-18 19-34-17

이미지 첨부해봅니다
마스크를 그리는 작업이던 지우는 작업이던
진행도중(좌클릭 상태로) 파일을 넘기면 바로 그려지는 작업으로 전환
다른 방향에서 진행중인 경우 다음장 첫화면 보이는곳까지 직선 쫙

그냥... 이런게 있길래요...
근데 여기다가 자꾸 불만사항 적어도 되는지요; 죄송스럽네요

Create server..

For saving logs, image files, etc.. from client

Add sending logs/imgs features to client too!(open another issues)

Client sends

  • images, masks, prev_images
  • User Statistics
    • How many people uses SZMC?
    • System Information
    • Running time for h x w image
    • Use Pattern
  • Bug, Crash report

Optimize segnet/complnet processing

Find optimal size of image input of snet/cnet.
It can be varied by OS, GPU/CPU, RAM size, etc...
Plot relation of size and processing time.
If there is no general relation, try to implement "Dynamic" snet/cnet processing time optimization

  • Save optimized h/w of snet/cnet processing (save config file)
  • Save processing time
  • Calculate expected time using saved processing time, h, w

The first image takes longer, the second faster.

  • Is it possible even if the first image is small? Can this improve performance?
  • Monitor gpu usage in windows / linux

Ready for feedbacks of Users

Issue Templates

  • Bug Report (Kor)
  • Bug Report (Eng)
  • Feature Request (Kor)
  • Feature Request (Eng)

contact

  • Open public email for SZMC

역질머신(YukZil-Machine) 기능

Feature Request (Kor)

만화갤러리에서 글을 보고 제안하기 위해 글을 남겨봅니다.
몇 가지 찾아본 결과 무료 일본어 ocr로 nhocr이 있고,
파파고에서도 파이썬을 위한 무료 API를 제공하는 것으로 보입니다. 다만 하루 1만자의 글자수 제한이 있고 유료 이용시 100만자당 월 2만원이 든다고 합니다.링크
유료 API를 제안드리긴 힘들 것 같고 ocr로 글씨의 좌표를 찾아 일본어를 추출하고 삽입할 번역내용을 입력하는 부분은 가능하다고 생각됩니다. 추출한 내용을 띄우는 일본어 텍스트 박스와 번역내용을 입력할 텍스트 박스를 띄우면 되지 않을까 싶습니다.
다만 글씨크기 조절에 대해서는 아이디어가 없네요. 이 부분은 죄송합니다.
바쁘시겠지만 다음 버전에서 고려해주시면 감사하겠습니다.

User Manuals and Introductions

  • Tutorial in startup image Useless
  • Korean version -> (#23)
  • Create homepage(githun.io) for project -> (#24)
  • Complete README.md(gif, how it works, 어케했 노-> 누)

--

  • Button and Key manual in startup page - Especially, keyboard buttons.
  • Introduction Video on Youtube <- Just Do t!
  • limits(pool color..) and requirements.txt

--

  • Kor
  • Eng

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.