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)
CPU
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
python -m pip install paddleocr paddlepaddle
python -m pip install datasets transformers scikit-learn Pillow numpy pandas chardet
python -m pip install --upgrade image2layout-computer-vision
GPU
# python -m pip install 'torch>=2.0' torchvision torchaudio
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y
python -m pip install paddleocr paddlepaddle-gpu
python -m pip install datasets transformers scikit-learn Pillow numpy pandas chardet
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 OCR
OCR._load()
- Recognize texts
from image2layout_computer_vision.ocr as OCR
# input file_path or Image.Image object
# [A] no text, box only, 2 lists of dicts with keys [text (empty), box, score (empty)]-
- Extract colors
import image2layout_computer_vision as icv
# [A] list [ tuples [ 2 rgb-color tuples ] ] for background and foreground
# sample output: [((2, 2, 2), (4, 4, 4)), ((6, 6, 6), (8, 8, 8))]
colors_all = icv.extract_colors(['path/to/image.png', 'path/to/image2.png'])
# [B] 2 rgb-color tuples for background and foreground
# sample output: ((9, 9, 9), (6, 6, 6))
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.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4a35eebdafc48cb4a46f0015c252ebdabf64f6a0cce0f55895ae8cf76193ee1 |
|
MD5 | ff41f99386e3b1dac6d43eac69fb01b0 |
|
BLAKE2b-256 | 6abe3d08fbdc21483607d883c3caedcbdf86740892c62b22c92d575e3c4a71bf |
Close
Hashes for image2layout_computer_vision-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5383f9caf9834fa35435a12aaa59a99602928df41bc09c405de96c1fc80345ac |
|
MD5 | c6cba454f122e45fa14d7211be2fd523 |
|
BLAKE2b-256 | dd154cbb2ef75182f130298e57ad4687b1066515d1a30502ee3584b262a8d6af |