image processing and stuff
Project description
image2layout_computer_vision
An image processing module for some computer vision tasks (public module for image2layout)
Package Page: pypi
Features:
- Text Detection and Recognition (OCR)
- Color extraction (background and main foreground)
Installations
Install with python
/conda
[Linux]
- (Optional) Conda
curl https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh -o ~/conda.sh
bash ~/conda.sh -b -f -p /opt/conda
rm ~/conda.sh
conda init --all --dry-run --verbose
conda create -n cv python=3.10 -y
conda activate cv
- Python libraries (python>=3.8)
# python -m pip install 'torch>=2.0' torchvision torchaudio
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
python -m pip install datasets transformers scikit-learn
python -m pip install --upgrade datasets transformers scikit-learn Pillow numpy pandas
python -m pip install paddleocr paddlepaddle
python -m pip install --upgrade image2layout-computer-vision
Install with docker
For running with CPU on Ubuntu
sudo docker build --tag cv -f Dockerfile_cpu .
sudo docker run -it -p 0.0.0.0:8000:8000 -p 0.0.0.0:8001:8001 -v $(pwd):/app cv bash
From inside container
cd deployment
conda activate cv
python api_serve.py -n CV -p 8000
Usage
- Run this python code to pre-download model weights
from image2layout_computer_vision import model_dispatch
model_dispatch._load()
- Recognize texts
import image2layout_computer_vision as icv
# [A] text + box, 2 lists of dicts with keys [text, box, score]
data_merged, data_raw = icv.detect_text_full('path/to/image.png')
# [B] no text, only box -> 2 lists of dicts with keys [text, box, score]
data_merged, data_raw = icv.detect_text_boxes('path/to/image.png')
# [C] text + box -> list of dicts with keys [text, box, score]
data_raw = icv.detect_text_element('path/to/image.png')
# [D] text + box (multiple images) -> list of list of dicts with keys [text, box, score]
data_raw_multi = icv.detect_text_elements(['path/to/image.png', 'path/to/image2.png'])
- Extract colors
import image2layout_computer_vision as icv
# 2 rgb-color tuples for background and foreground
color_bg, color_fg = icv.extract_colors('path/to/image.png')
Build
(for building and uploading this package)
python -m pip install --upgrade pip
python -m pip install --upgrade build twine "keyring<19.0"
rm -rf dist
python -m build
python -m twine upload dist/* --verbose
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for image2layout_computer_vision-0.1.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42f05b17098b8ac6fae81a7fac20939c637ebf087114cc6b16e035adde0aba0f |
|
MD5 | b8dfad093908d5c335cce2beca3afdc3 |
|
BLAKE2b-256 | 8e77dae51852929696ee29646c014fddab7b690bdceec08bb147d5bb594d0ad3 |
Close
Hashes for image2layout_computer_vision-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6d02b32f967fae0f423ddfb5e0e22662621d2da3df3e20d058f682fbf142268 |
|
MD5 | e7877bed849d084f7a9ca77149f011eb |
|
BLAKE2b-256 | 19cc67dc3cc85a5e5228ee952af2ca1c9a7b3eff215630f7d17e636713aea700 |