mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-23 20:11:10 +00:00
Merge pull request #401 from Yaswanth820/master
Added extract_text_from_image script
This commit is contained in:
commit
8689592a95
16
scripts/Extract_TEXT_FROM_IMAGE/README.md
Normal file
16
scripts/Extract_TEXT_FROM_IMAGE/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Extract text from image
|
||||
|
||||
This script extracts text from an image using the EasyOCR library.
|
||||
It can support multiple languages.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Create a virtual environment
|
||||
2. Install the requirements - `pip install -r requirements.txt`
|
||||
3. Run the script - `python main.py`
|
||||
|
||||
## Output
|
||||
|
||||
Output will be printed to console.
|
||||
|
||||
Happy coding!!
|
15
scripts/Extract_TEXT_FROM_IMAGE/main.py
Normal file
15
scripts/Extract_TEXT_FROM_IMAGE/main.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import easyocr
|
||||
|
||||
gpu = False # if you want to use GPU, set gpu=True
|
||||
languages = ['en'] # refer https://www.jaided.ai/easyocr/ for supporting languages
|
||||
|
||||
reader = easyocr.Reader(languages, gpu=gpu)
|
||||
|
||||
IMG_PATH = 'test1.png'
|
||||
result = reader.readtext(IMG_PATH)
|
||||
|
||||
text = ''
|
||||
for tup in result:
|
||||
text += tup[1]
|
||||
|
||||
print(text)
|
1
scripts/Extract_TEXT_FROM_IMAGE/requirements.txt
Normal file
1
scripts/Extract_TEXT_FROM_IMAGE/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
easyocr==1.6.2
|
BIN
scripts/Extract_TEXT_FROM_IMAGE/test1.png
Normal file
BIN
scripts/Extract_TEXT_FROM_IMAGE/test1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
Loading…
Reference in New Issue
Block a user