a command line interface for preparing image models
Project description
Image Tools CLI 🖼️
Command line interface for pre-processing images for model training.
Features
-
Download all images from a url
-
Convert images to PNG
-
Resize and crop images
-
Chunk large images into smaller squares
Example: You may want to train on this image but need to split it into smaller squares for training.
Put it through the chunker and you get this:
chunk 1 | chunk 2 | chunk 3 | ||
---|---|---|---|---|
- Remove images with more than one person
Example: If your input images have more than one person, the image will be deleted:
Example: This image will not be deleted:
Installation
create a virtual environment and imgtools-cli through pip:
python3 -m venv venv
source venv/bin/activate
pip install imgtools-cli
Usage
Help
python -m imgtools_cli -h
Download all images from a website
-D {url}, {output directory}
python -m imgtools_cli -D https://www.gutenberg.org/cache/epub/67098/pg67098-images.html /Users/ootie/images
Convert images to PNG files
-I {input directory}
python -m imgtools_cli -I /Users/ootie/image_files
Resize / Crop images
-r {input directory}, {width}, {height}, {crop_focal_point}, {dnn_model_path}
Using crop focal point:
python -m imgtools_cli -r /Users/ootie/images 512 512 True None
Passing in a haar xml to focal crop faces:
python -m imgtools_cli -r /Users/ootie/images 512 512 True /Users/ootie/models/haarcascade_frontalface_default.xml
Chunk large images into squares
Easily take large images and split them into smaller squares for training.
-C {dimensions}, {input_directory}, {output_directory}
python -m imgtools_cli -C 512 /Users/ootie/input /Users/ootie/output
Hassan People Remover
Uses face detection to remove images with more than one person. Helpful for cleaning source images to be used for Stable Diffusion training.
Sample images to test with: https://github.com/hassan-sd/people-remover/tree/main/images
-R {input_directory}, {path_to_cascade_xml}
python -m imgtools_cli -R /Users/ootie/image-tools/images/ /Users/ootie/image-tools/examples/haarcascade_frontalface_default.xml
Ported from: https://github.com/hassan-sd/people-remover
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
Hashes for imgtools_cli-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd8f9954f62aae44267eb90b528209a11aee18c353b019b6bf7451518a3e8881 |
|
MD5 | fb5989d20b5372ee00b5a23033fcc446 |
|
BLAKE2b-256 | b58796d5197028654068bfbb479b87b89a570bc149a7c2badfa1adfba6b78246 |