hrishikeshrt / google_drive_ocr Goto Github PK
View Code? Open in Web Editor NEWPerform OCR using Google's Drive API v3
License: Other
Perform OCR using Google's Drive API v3
License: Other
GoogleOCRApplication
class supports
Expose these methods to CLI for a greater control
Question:
Can you confirm what this application still working as intended?
I first set it up about a month ago and successfully used for a while. Today I attempted to OCR some images, but now then I try to use it in command line mode I am getting this
Here is the error block:
Traceback (most recent call last):
File "C:\Utils\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Utils\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Utils\Python\Python310\Scripts\google-ocr.exe_main.py", line 7, in
File "C:\Utils\Python\Python310\lib\site-packages\google_drive_ocr\cli.py", line 117, in main
app = GoogleOCRApplication(
File "", line 9, in init
File "C:\Utils\Python\Python310\lib\site-packages\google_drive_ocr\application.py", line 98, in post_init
creds = self.get_credentials()
File "C:\Utils\Python\Python310\lib\site-packages\google_drive_ocr\application.py", line 144, in get_credentials
creds.refresh(Request())
File "C:\Utils\Python\Python310\lib\site-packages\google\oauth2\credentials.py", line 339, in refresh
) = reauth.refresh_grant(
File "C:\Utils\Python\Python310\lib\site-packages\google\oauth2\reauth.py", line 367, in refresh_grant
_client._handle_error_response(response_data, retryable_error)
File "C:\Utils\Python\Python310\lib\site-packages\google\oauth2_client.py", line 74, in _handle_error_response
raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
I tried creating and using new secret.json but nothing changes.
Did I managed to mess something up on my side between then and now, or is this just google changing stuff over time?
The token had expired, so I deleted the project and re-created a new project. (Both the old and new projects are just for doing OCR)
I downloaded the new client_secret.json file and tried to perform OCR, but I get the following error.
Is it something to do with cache, etc.?
google.auth.exceptions.RefreshError: ('invalid_client: Unauthorized', {'error': 'invalid_client', 'error_description': 'Unauthorized'})
Runtime error
Install via
pkg install popper
pip install google_drive_ocr
cd <libDir>
ln -s liblcms2.so liblcms2.so.2
#google-ocr --config /storage/28E1-1BF4/GoogleOCR/gdo.cfg --pdf /storage/emulated/0/Download/In.pdf --pages 1-3 --verbose
Storing credentials to /data/data/com.termux/files/home/.credentials/token.json file_cache is only supported with oauth2client<4.0.0 Extracting 3 pages from '/storage/emulated/0/Download/In.pdf' .. Extracted 3 pages: 1 to 3. Traceback (most recent call last): File "/data/data/com.termux/files/usr/bin/google-ocr", line 8, in sys.exit(main()) File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/google_drive_ocr/cli.py", line 153, in main app.perform_ocr_batch( File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/google_drive_ocr/application.py", line 266, in perform_ocr_batch _workload = workload + (idx < extra) UnboundLocalError: local variable 'extra' referenced before assignment
Accès bloqué : [.....] n'a pas terminé la procédure de validation de Google
It seems the package does not support write the output to file itself. It is great if the command line has an option to write the ocr result to output file like .txt or docs or any text extension.
Thank you
It was working earlier but stopped a few days ago. Following is the command I ran and the error.
> google-ocr -i image.png --client-secret client_secret_11_oct_2023.json --debug
{'__module__': 'google_drive_ocr.cli', 'image': 'image.png', 'batch': None, 'image_dir': None, 'output': None, 'extension': '.png', 'suffix': '.google.txt', 'pdf': None, 'pages': None, 'client_secret': 'client_secret_11_oct_2023.json', 'upload_folder_id': None, 'workers': 1, 'no_keep': False, 'verbose': False, 'debug': True, '__dict__': <attribute '__dict__' of 'Config' objects>, '__weakref__': <attribute '__weakref__' of 'Config' objects>, '__doc__': None, 'config_file': None, 'write_out_config_file_to_this_path': None}
Making request: POST https://oauth2.googleapis.com/token
Starting new HTTPS connection (1): oauth2.googleapis.com:443
https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 400 None
Traceback (most recent call last):
File "/usr/local/bin/google-ocr", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/google_drive_ocr/cli.py", line 117, in main
app = GoogleOCRApplication(
^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 9, in __init__
File "/usr/local/lib/python3.11/site-packages/google_drive_ocr/application.py", line 98, in __post_init__
creds = self.get_credentials()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/google_drive_ocr/application.py", line 144, in get_credentials
creds.refresh(Request())
File "/usr/local/lib/python3.11/site-packages/google/oauth2/credentials.py", line 344, in refresh
) = reauth.refresh_grant(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/google/oauth2/reauth.py", line 365, in refresh_grant
_client._handle_error_response(response_data, retryable_error)
File "/usr/local/lib/python3.11/site-packages/google/oauth2/_client.py", line 72, in _handle_error_response
raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
Installed via Source
Runtime error...
Got x3 separate pages in my dir though ...
~ $ google-ocr --config /storage/28E1-1BF4/GoogleOCR/gdo.cfg --pdf /storage/emulated/0/Download/In.pdf
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/bin/google-ocr", line 33, in <module>
sys.exit(load_entry_point('google-drive-ocr==0.2.5', 'console_scripts', 'google-ocr')())
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/google_drive_ocr/cli.py", line 153, in main
app.perform_ocr_batch(
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/google_drive_ocr/application.py", line 266, in perform_ocr_batch
_workload = workload + (idx < extra)
UnboundLocalError: local variable 'extra' referenced before assignment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.