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
- 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
- Tesseract
sudo apt install tesseract-ocr libtesseract-dev -y
- Python libraries (python>=3.8)
# python -m pip install 'torch>=2.0' torchvision torchaudio
conda install pytorch torchvision torchaudio cpuonly -c pytorch --name cv -y
python -m pip install Pillow pandas numpy scikit-learn pyyaml==5.1 chardet pytesseract
python -m pip install --upgrade datasets transformers
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
python -m pip install --upgrade image2layout-computer-vision
Install with docker
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_layout
model_dispatch_layout._load()
- Detect texts
import image2layout_computer_vision as icv
# ImageBoxes object
imageboxes = icv.detect_text('path/to/image.png')
# draw annotations
img_anno = imageboxes.draw_anno()
# boxes_merged = merged boxes (sentences), boxes_raw = all boxes (words)
boxes_merged, boxes_raw = icv.detect_text_boxes('path/to/image.png')
# merge boxes
boxes_merged = icv.ImageBoxes.group_boxes(
boxes_raw,
line_dist_max=1.0,
line_dist_min=-0.1,
line_iou_min=0.4,
row_hdist_max=0.4,
row_vdist_max=1.8,
row_height_ratio_min=0.8,
)
- Extract colors
import image2layout_computer_vision as icv
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.0.14.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ea499204bde742afd9557ca660a86a5ff364295af101a79c2c1435745c7afb1 |
|
MD5 | ed6e188dbdf70f4e007c51c42c31ee6e |
|
BLAKE2b-256 | 0c9e19b619a9387df7e0390c26dbf68cedd6dee13c394bab1634f6a3d1b16923 |
Close
Hashes for image2layout_computer_vision-0.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d20c0e3823752f9300097e1a0548d155405a661a16689740ea85a6f5722e57ca |
|
MD5 | bfa052b38788daff70e3a5e0ce3f9a7a |
|
BLAKE2b-256 | e95a0d7572bb65c8eafc2e3c3802407573503ef6a327e173e90b59bdbad94e7e |