{"id":20263006,"url":"https://github.com/k-rt-dev/manga-ocr-pyinstaller","last_synced_at":"2025-06-17T11:09:47.262Z","repository":{"id":152804326,"uuid":"612732744","full_name":"K-RT-Dev/manga-ocr-pyinstaller","owner":"K-RT-Dev","description":"Minimal example of how to generate an .exe executable using PyInstaller that can run Manga-Ocr","archived":false,"fork":false,"pushed_at":"2023-03-11T20:17:10.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T19:57:55.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/K-RT-Dev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-11T20:13:33.000Z","updated_at":"2023-03-11T20:58:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c77528a-d933-4e0f-a4a8-dffbf5a7142f","html_url":"https://github.com/K-RT-Dev/manga-ocr-pyinstaller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/K-RT-Dev/manga-ocr-pyinstaller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Fmanga-ocr-pyinstaller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Fmanga-ocr-pyinstaller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Fmanga-ocr-pyinstaller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Fmanga-ocr-pyinstaller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/K-RT-Dev","download_url":"https://codeload.github.com/K-RT-Dev/manga-ocr-pyinstaller/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Fmanga-ocr-pyinstaller/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260346881,"owners_count":22995151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T11:32:54.150Z","updated_at":"2025-06-17T11:09:42.245Z","avatar_url":"https://github.com/K-RT-Dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Introduction\n\nMinimal example of how to generate an *.exe* executable using [PyInstaller](https://pyinstaller.org/) that can run [Manga-Ocr](https://github.com/kha-white/manga-ocr). Due to Manga-Ocr's use of [PyTorch](https://pytorch.org/), it is not trivial to generate a correctly functioning and lightweight *.exe*.\n\nThe instructions provide a way to generate an executable that launches Manga-Ocr using the CPU for image processing, as well as instructions for generating an executable that launches Manga-Ocr to use the GPU ([Cuda](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/contents.html)).\n\nWe were able to successfully generate the executable by using [Poetry](https://python-poetry.org/) to create a Python Environment, as well as a custom modification of PyInstaller's *.spec* file to optimize the compilation .\n\n### Instructions\n\n0. Make sure to have **Python 3.9** installed (other versions may cause conflicts).\n1. Install [Poetry](https://python-poetry.org/) if you don't have it.\n2. Validate that it is correctly installed using: `poetry -v`\n3. Create and activate the environment with: `poetry shell`\n4. Install dependencies with: `poetry install`\n\n**---Instructions to compile Manga-Ocr to use CPU for image processing---**\nThis compilation will result in a folder with an approximate weight of 650mb. If we compress the folder using WinRar, we can achieve a weight of 125mb.\n\n5. Run the program with Python to validate its functionality: `python main.py`\n6. Create the build using: `pyinstaller MangaOcrPyInstaller.spec`\n7. The build can be found in directory */dist*. To run the program, click on \"MangaOcrPyInstaller.exe\"\n\n**---Instructions to compile Manga-Ocr to use GPU (Cuda) for image processing---**\nSince Manga-Ocr uses PyTorch, GPU acceleration will only work if the computer has an Nvidia [graphics card that supports Cuda](https://developer.nvidia.com/cuda-gpus). The graphics card drivers must be up to date. The build of Manga-Ocr with GPU usage is exponentially heavier. This compilation will result in a folder with an approximate weight of 4gb. If we compress the folder using WinRar, we can achieve a weight of 1.3gb.\n\n5. Use `poe force-cuda11` to install extra dependencies for GPU usage. This will install *PyTorch 1.12*, *Torchvision 0.13*, and *Cuda 11.6* in our environment. This download is approximately 2.3gb\n6. Run the program with Python to validate its functionality: `python main.py`. We should see a message indicating that the GPU (Cuda) is being used\n7. Create the build using: `pyinstaller MangaOcrPyInstaller.spec`\n8. The build can be found in directory */dist*. To run the program, click on \"MangaOcrPyInstaller.exe\"\n\n### Considerations\n* Manga-Ocr checks if we have the [models stored in our cache](https://github.com/kha-white/manga-ocr/issues/17). If they are not present, Manga-Ocr will download the models (approximately 400mb) before starting. Subsequent executions will be faster as the models will be cached\n* If we use `poe force-cuda11` and want to uninstall those dependencies to switch back to using only the CPU, we should run `poe force-remove-cuda11` and then `poetry install`\n\n### Others\n- The *.spec* file was generated using [this solution](https://stackoverflow.com/questions/71863714/packagenotfound-error-while-executing-exe-file-made-by-pyinstaller) as a base. Then it was merged with [this](https://github.com/blueaxis/Cloe/blob/main/build/main.spec) implementation. Finally, it was manually validated which packages could be ignored.\n- Achieving to install Cuda with Poetry was possible thanks to [this approach](https://stackoverflow.com/questions/59158044/poetry-and-pytorch).\n\n### Todo\n- See if it's possible to reduce the weight of the GPU mode compilation by ignoring certain *.dll* and/or *.lib* files related to Cuda\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-rt-dev%2Fmanga-ocr-pyinstaller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-rt-dev%2Fmanga-ocr-pyinstaller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-rt-dev%2Fmanga-ocr-pyinstaller/lists"}