Skip to main content

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.

imgshape demo PyPI Downloads

⚡️ 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.transforms or even a DataLoader.

  • 🌐 Interactive GUI modes:

    • Streamlit app (app.py) → modern multi-tab UI
    • Gradio app (--web) → quick prototyping

🚀 Installation

pip install imgshape

Requires Python 3.8+ Core deps: Pillow, numpy, matplotlib, scikit-image, streamlit Optional extras:

  • imgshape[torch] → PyTorch / torchvision support
  • imgshape[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.transforms pipelines 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.
  • 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, and torchloader.
  • 🎨 UI Polishing:

    • Defensive wrappers for analyze_type, recommend_preprocessing, TorchLoader.
    • Footer links to Instagram, GitHub, HuggingFace, Kaggle, Medium.

📎 Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgshape-2.2.0.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imgshape-2.2.0-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

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

Hashes for imgshape-2.2.0.tar.gz
Algorithm Hash digest
SHA256 a77747e65be1694fb0e461a220bd4164fbd5f8042435e8fda0fe189ac7a20678
MD5 2b9d457793e72b9daae30fdc1503fb71
BLAKE2b-256 fa23317c6d30fa970350275a67e2d2f6503e1221fac5ae4c6fcfbf8de313ddfb

See more details on using hashes here.

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

Hashes for imgshape-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0a1f578f059d25bbdb8b5870159834ac67fe88e5472b5572a9a62de9a0f9ac2
MD5 51fdc3f722e20be174534f21d8f4d8dd
BLAKE2b-256 f8b89a194c000b8ad464d1acbc17224f7771d143c10355c7aa7203b5345ef67f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page