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

OS X support? #6

Open
saxoncameron opened this issue Apr 22, 2022 · 19 comments
Open

OS X support? #6

saxoncameron opened this issue Apr 22, 2022 · 19 comments
Labels
feature request New feature or request platform/osx Issue specific to macOS

Comments

@saxoncameron
Copy link

Hey there! This looks like a really useful app. I see that there's only an .exe release for Windows, so I've tried building it locally on my Mac (Monterey 12.2.1 on a MacBook Pro 16" 2019, python 3.9.12), but I get this error when attempting to run main.py in the code directory.

saxoncameron@sax code % python main.py
Traceback (most recent call last):
  File "/Users/saxoncameron/Sites/Poricom/code/main.py", line 24, in <module>
    from pyqtkeybind import keybinder
  File "/usr/local/lib/python3.9/site-packages/pyqtkeybind/__init__.py", line 11, in <module>
    from .x11 import X11KeyBinder
  File "/usr/local/lib/python3.9/site-packages/pyqtkeybind/x11/__init__.py", line 6, in <module>
    from PyQt5.QtX11Extras import QX11Info
ModuleNotFoundError: No module named 'PyQt5.QtX11Extras'

Note this is after running pip install -r requirements.txt as per README.md.

I don't care so much about building this locally, I just want to be able to use it. Any chance you could make a release for OS X? Thanks!

@blueaxis
Copy link
Owner

Unfortunately the package I'm using to implement external capture only support Windows and Linux systems. For now, you may use this branch to run the program in macOS. Note that this is only a band-aid fix and will disable the shortcut for external captures.
Still, you may use the external capture button under the FILE tab to perform OCR on images outside the application.

@saxoncameron
Copy link
Author

Thanks for the quick response!

I tried out the branch osx-support and was able to run the application, however it doesn't appear to function correctly which I must surmise is a platform problem. In the ensuing comments I will log my problems one by one with attached videos, as I hope that will help:

@saxoncameron
Copy link
Author

When attempting to open a .cbz file, it does not load, and if I had to guess, it's because the contents of the zip are in a series of folders rather than just a flat root of images.

If I unzip it and open one of those folders, it loads fine. See video example:

https://www.dropbox.com/s/980azkynwsjkx7t/cbz%20loading.mov?dl=0

@saxoncameron
Copy link
Author

Text selection OCR as per the README demo videos doesn't work for me at all unfortunately :( Neither with manga ocr or with tesseract vertical or horizontal. Video example:

https://www.dropbox.com/s/qs9jevz42dv1v59/ocr%20not%20working.mov?dl=0

@saxoncameron
Copy link
Author

Other suggestions:

  • It'd be VERY useful if OCR parsings were copied to the system clipboard so the results could be used with texthooker/clipboard applications, e.g. for parsing with Yomichan/Migaku
    • Without this, the program unfortunately wouldn't be useful for me even if the OCR was working
  • This prompt comes up on every load, and also when switching from tesseract back to -> manga ocr. It'd be nicer if it loaded just once, and thereafter was aware of it being cached.
    • image
  • It'd be great if you could minimise this sidebar
    • Pasted_Image_22_4_2022__4_18_pm
  • It'd be nice if you could use these controls with standard keyboard hotkeys, like ctrl/cmd +- for zoom, and left/right arrow keys for page navigation
    • image
  • It'd be ideal if the open dialog remembered the last directory that you opened from, rather than not doing so.
    • Pasted_Image_22_4_2022__4_21_pm
  • The options in dropdown menus in many of the setting dialogs are often cut-off
    • image
  • Although you can scroll through pages, with my trackpad I'm finding it way too sensitive. Even a small scroll navigates me ahead several pages. Increasing the scroll length required for multi-page navigation would be nice, as most users will only want to scroll one page at a time forward/backwards

@saxoncameron
Copy link
Author

saxoncameron commented Apr 22, 2022

Thank you for your efforts on this application so far - it's the first implementation of a GUI that I've seen for manga OCR, which is the best performing OCR I've used to date. With just a few changes and improvements this is something I can see myself using frequently for reading manga.

Hope this helps! Let me know if you'd like me to test any future changes or fixes. Thanks!

@blueaxis
Copy link
Owner

Text selection OCR as per the README demo videos doesn't work for me at all unfortunately :( Neither with manga ocr or with tesseract vertical or horizontal. Video example:

https://www.dropbox.com/s/qs9jevz42dv1v59/ocr%20not%20working.mov?dl=0

You have to hold the mouse button to show the detected text. Releasing the mouse button will hide the preview, which is what's happening here in your video.

It'd be VERY useful if OCR parsings were copied to the system clipboard

This is the default behavior, at least in Windows. Let me know if the text is being copied in the macOS clipboard once you've tried the above method.

When attempting to open a .cbz file, it does not load, and if I had to guess, it's because the contents of the zip are in a series of folders rather than just a flat root of images.

You are correct. My understanding of comic book archives is that they contain images only, which is why I implemented it to read only image files from directories/archives.

Although you can scroll through pages, with my trackpad I'm finding it way too sensitive.

Oops.. Just tested this on my laptop and I'm getting the same behavior. I completely forgot to test this. I will release a hotfix soon. For now, just use a mouse if you have one.

The options in dropdown menus in many of the setting dialogs are often cut-off

I'm not sure if this issue is unique to macOS. I will test this once I setup an macOS VM. Not promising anything though.

@blueaxis
Copy link
Owner

blueaxis commented Apr 22, 2022

Thank you for your suggestions! I will compile them in this comment with some notes.

  • Display directories containing images - This was the previous behavior as you can see in the v0.2.0 demo. I might bring it back given that some archives may contain only folders. (I decided to include this in v0.3.1)
  • Remove load model prompt - Might be difficult. I have no idea how HuggingFace names and stores model so it's difficult to track whether the model is already in cache.
  • Option to hide explorer/sidebar
  • Navigation using keyboard
  • Remember last path in file dialogs
  • Fix truncated dropdown menu - See comment above
  • Adjust scrolling using trackpad - Should be in v0.3.1

I will be busy for quite some time so expect these features in a much later date.

@blueaxis blueaxis added feature request New feature or request platform/osx Issue specific to macOS labels Apr 22, 2022
@saxoncameron
Copy link
Author

Thanks for your responses and summaries! It's working for me locally after you clarified mouse selection behaviour.

Looking forward to future features and improvements :)

@AhnafS
Copy link

AhnafS commented Jun 16, 2022

Hello, can you tell me how to run this on mac os?

@blueaxis
Copy link
Owner

@AhnafS follow the developer's guide under installation:

For developers, clone this repo and install requirements: pip install -r requirements.txt. Run the app in the command line using python main.py

Note that the global shortcut does not work for OSX

@AhnafS
Copy link

AhnafS commented Jun 16, 2022

after much trial and error, it seems like this does not completely work with the M1 MacBooks 🥲

@blueaxis
Copy link
Owner

@AhnafS There should be a branch for OSX. If this doesn't work, then it might be an M1 compatibility issue

@AhnafS
Copy link

AhnafS commented Jun 19, 2022

Yes thank you, I found a workaround for M1 users. If you have an M1 mac, then your ARM64 arch won't work on this project with python. Thus, you must create an x86 python env. To do this, I made a conda x86 env with Python 3.9.9. Then you can clone the project and download all the requirements. When downloading and running the project on the branch for OSX, you will still face some issues with a few libraries, but a simple google search can fix that :)

@Moebits
Copy link

Moebits commented Aug 27, 2022

Yes thank you, I found a workaround for M1 users. If you have an M1 mac, then your ARM64 arch won't work on this project with python. Thus, you must create an x86 python env. To do this, I made a conda x86 env with Python 3.9.9. Then you can clone the project and download all the requirements. When downloading and running the project on the branch for OSX, you will still face some issues with a few libraries, but a simple google search can fix that :)

How did you fix this error with tesserocr on Mac M1 (I am using x86 python)

Traceback (most recent call last):
  File "/Users/chris/Documents/Git Clone/Poricom/code/main.py", line 24, in <module>
    from MainWindow import MainWindow
  File "/Users/chris/Documents/Git Clone/Poricom/code/MainWindow.py", line 29, in <module>
    from utils.image_io import mangaFileToImageDir
  File "/Users/chris/Documents/Git Clone/Poricom/code/utils/image_io.py", line 26, in <module>
    from tesserocr import PyTessBaseAPI
ImportError: dlopen(/Users/chris/.pyenv/versions/3.9.9/lib/python3.9/site-packages/tesserocr.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace (__ZN9tesseract11TessBaseAPI10GetBoxTextEi)

@AhnafS
Copy link

AhnafS commented Aug 27, 2022

Yes thank you, I found a workaround for M1 users. If you have an M1 mac, then your ARM64 arch won't work on this project with python. Thus, you must create an x86 python env. To do this, I made a conda x86 env with Python 3.9.9. Then you can clone the project and download all the requirements. When downloading and running the project on the branch for OSX, you will still face some issues with a few libraries, but a simple google search can fix that :)

How did you fix this error with tesserocr on Mac M1 (I am using x86 python)

Traceback (most recent call last):
  File "/Users/chris/Documents/Git Clone/Poricom/code/main.py", line 24, in <module>
    from MainWindow import MainWindow
  File "/Users/chris/Documents/Git Clone/Poricom/code/MainWindow.py", line 29, in <module>
    from utils.image_io import mangaFileToImageDir
  File "/Users/chris/Documents/Git Clone/Poricom/code/utils/image_io.py", line 26, in <module>
    from tesserocr import PyTessBaseAPI
ImportError: dlopen(/Users/chris/.pyenv/versions/3.9.9/lib/python3.9/site-packages/tesserocr.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace (__ZN9tesseract11TessBaseAPI10GetBoxTextEi)

I remember having this same problem, I googled it and this issue thread helped me out a lot.
sirfz/tesserocr#9
You should try doing pip3 install cython tesseract-ocr libtesseract-dev libleptonica-dev

@Moebits
Copy link

Moebits commented Aug 27, 2022

You should try doing pip3 install cython tesseract-ocr libtesseract-dev libleptonica-dev

I installed these with brew (since these are linux packages, not python), but it still hasn't resolved my issue.

Since you got this to compile on M1 Macs would you mind packaging it into an app? You could probably use PyInstaller.

@AhnafS
Copy link

AhnafS commented Aug 27, 2022

You should try doing pip3 install cython tesseract-ocr libtesseract-dev libleptonica-dev

I installed these with brew (since these are linux packages, not python), but it still hasn't resolved my issue.

Since you got this to compile on M1 Macs would you mind packaging it into an app? You could probably use PyInstaller.

Im very new to python, so it will take a little while. But I just did a fresh download again, and got this same error. If you do conda install tesserocr it should work

@Moebits
Copy link

Moebits commented Aug 27, 2022

Im very new to python, so it will take a little while. But I just did a fresh download again, and got this same error. If you do conda install tesserocr it should work

I understand, I haven't got this working but I am going to use mokuro as an alternative instead, it OCR's every page and creates html files to read in a browser which works for me, and compiles fine with x86 python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request platform/osx Issue specific to macOS
Projects
None yet
Development

No branches or pull requests

4 participants