imgshape — robust image shape detection, dataset analysis, preprocessing & augmentation recommendations, visualization, compatibility reports, and PyTorch loader helpers
Project description
🖼️ imgshape — Smart Image Analysis & Preprocessing Toolkit (v2.2.0)
imgshape is a Python toolkit for image shape detection, dataset inspection, preprocessing & augmentation recommendations, visualization, report generation, and PyTorch DataLoader helpers — making it a smarter dataset assistant for ML/DL workflows.
⚡️ Why use imgshape?
-
📐 Detect image shapes (H × W × C) for single files or whole datasets.
-
🔍 Compute entropy, edge density, dominant color, and guess image type.
-
🧠 Get preprocessing recommendations (resize, normalization, suitable model family).
-
🔄 Augmentation recommender: suggest flips, crops, color jitter, etc., based on dataset stats.
-
📊 Visualizations: size histograms, dimension scatter plots, channel distribution.
-
✅ Model compatibility checks: verify dataset readiness for models like
mobilenet_v2,resnet18, etc. -
📝 Dataset reports: export Markdown/HTML/PDF with stats, plots, preprocessing, and augmentation plans.
-
🔗 Torch integration: generate ready-to-use
torchvision.transformsor even aDataLoader. -
🌐 Interactive GUI modes:
- Streamlit app (
app.py) → modern multi-tab UI - Gradio app (
--web) → quick prototyping
- Streamlit app (
🚀 Installation
pip install imgshape
Requires Python 3.8+ Core deps:
Pillow,numpy,matplotlib,scikit-image,streamlitOptional extras:
imgshape[torch]→ PyTorch / torchvision supportimgshape[pdf]→ PDF report generation (weasyprint)imgshape[viz]→ prettier plots (seaborn)
💻 CLI Usage
# Shape detection
imgshape --path ./sample.jpg --shape
# Single image analysis
imgshape --path ./sample.jpg --analyze
# Preprocessing + augmentations
imgshape --path ./sample.jpg --recommend --augment
# Dataset compatibility check
imgshape --dir ./images --check mobilenet_v2
# Dataset visualization
imgshape --viz ./images
# Dataset report (md + html)
imgshape --path ./images --report --augment --report-format md,html --out report
# Torch integration (transform/DataLoader)
imgshape --path ./images --torchloader --augment --out transform_snippet.py
# Launch Streamlit app
streamlit run app.py
# Launch Gradio GUI
imgshape --web
📦 Python API
from imgshape.shape import get_shape
from imgshape.analyze import analyze_type
from imgshape.recommender import recommend_preprocessing
from imgshape.augmentations import AugmentationRecommender
print(get_shape("sample.jpg"))
print(analyze_type("sample.jpg"))
print(recommend_preprocessing("sample.jpg"))
# Augmentation plan
ar = AugmentationRecommender(seed=42)
plan = ar.recommend_for_dataset({"entropy_mean": 6.2, "image_count": 100})
print(plan.recommended_order)
📝 New in v2.2.0
-
🌐 Streamlit App (
app.py) with 5 interactive tabs:- Shape → instant image shape detection
- Analyze → entropy, channels, and dataset visualization
- Recommend → preprocessing + heuristic augmentation plan
- Report → export dataset reports in Markdown/HTML
- TorchLoader → export
torchvision.transformspipelines or snippets
-
🔗 TorchLoader:
- Safe wrapper for Compose/snippet/no-op callable depending on availability.
- Backward compatibility with old
(plan, preprocessing)test calls.
-
🧠 AugmentationRecommender:
- Deterministic heuristic plans with
.as_dict()export. - Handles entropy, resolution, and imbalance.
- Deterministic heuristic plans with
-
✅ Compatibility Fixes:
check_compatibility()outputs structured results.- Deprecated alias
check_model_compatibility()preserved.
-
📝 Report Generators:
- Markdown + HTML outputs improved.
-
⚡️ Test Suite:
- Fixed pytest failures in
compatibility,report, andtorchloader.
- Fixed pytest failures in
-
🎨 UI Polishing:
- Defensive wrappers for
analyze_type,recommend_preprocessing, TorchLoader. - Footer links to Instagram, GitHub, HuggingFace, Kaggle, Medium.
- Defensive wrappers for
📎 Resources
- Source Code
- Issues
- License: MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imgshape-2.2.0.tar.gz.
File metadata
- Download URL: imgshape-2.2.0.tar.gz
- Upload date:
- Size: 39.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a77747e65be1694fb0e461a220bd4164fbd5f8042435e8fda0fe189ac7a20678
|
|
| MD5 |
2b9d457793e72b9daae30fdc1503fb71
|
|
| BLAKE2b-256 |
fa23317c6d30fa970350275a67e2d2f6503e1221fac5ae4c6fcfbf8de313ddfb
|
File details
Details for the file imgshape-2.2.0-py3-none-any.whl.
File metadata
- Download URL: imgshape-2.2.0-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0a1f578f059d25bbdb8b5870159834ac67fe88e5472b5572a9a62de9a0f9ac2
|
|
| MD5 |
51fdc3f722e20be174534f21d8f4d8dd
|
|
| BLAKE2b-256 |
f8b89a194c000b8ad464d1acbc17224f7771d143c10355c7aa7203b5345ef67f
|