Skip to main content

HMB Helpers Package

Python PyPI License PyTorch TensorFlow Tests Code Coverage Examples Documentation Docs Status Read the Docs Code Style Modules Contributions Maintenance Release DOI

A comprehensive collection of helper modules for image processing, segmentation, deep learning workflows, text/PDF utilities, and scientific computing in PyTorch, TensorFlow, and beyond.

Documentation: https://hmb-helpers-package.readthedocs.io/en/latest/


Table of Contents


Motivation

HMB Helpers Package aims to accelerate research and development in computer vision, deep learning, and text analytics by providing ready-to-use, well-tested utility modules that simplify common tasks, reduce boilerplate code, and promote reproducibility in scientific projects.

Installation

Install only core dependencies (e.g., numpy, pillow, pandas, scikit-learn):

pip install hmb-helpers

Package on PyPI: https://pypi.org/project/hmb-helpers/

Install with Optional Features

Add only the features you need:

# Computer vision & PyTorch.
pip install "hmb-helpers[cv,pytorch]"

# NLP & text processing.
pip install "hmb-helpers[nlp]"

# PDF handling.
pip install "hmb-helpers[pdf]"

# Full installation (most optional dependencies)
# Note: The `all` extra installs most optional dependencies but intentionally
# excludes large, platform- and device-specific frameworks (PyTorch, TensorFlow,
# Keras and related runtime packages). Install those frameworks separately
# using the dedicated extras below or via the framework's official installer.
pip install "hmb-helpers[all]"

# Install vision models and pretrained weights.
pip install "hmb-helpers[timm,transformers,ultralytics]"

# Computer vision & PyTorch.
pip install "hmb-helpers[cv,pytorch]"

# NLP & text processing.
pip install "hmb-helpers[nlp]"

Development Install

For modifying the package source:

git clone https://github.com/HossamBalaha/HMB-Helpers-Package.git
cd HMB-Helpers-Package
pip install -e ".[dev]"

GPU Support (PyTorch CUDA)

The pytorch extra installs CPU wheels by default. For CUDA:

pip install "hmb-helpers[pytorch]"
pip uninstall torch torchvision torchaudio -y
pip install torch==2.7.1+cu128 torchvision==0.22.1+cu128 torchaudio==2.7.1+cu128 \
  --extra-index-url https://download.pytorch.org/whl/cu128

Or use the official PyTorch installer for your platform.

Dependencies

Core Dependencies (Always Installed)

  • numpy>=1.26.4,<2: Numerical computing
  • pillow>=12.2.0: Image I/O and basic processing
  • pyyaml>=6.0.3: YAML parsing for configuration and dataset helper utilities
  • pandas>=2.3.3: Tabular data handling used across multiple helpers
  • matplotlib>=3.9: Basic plotting utilities used by helpers and examples
  • tqdm>=4.67.3: Progress bars used in many processing functions
  • scikit-learn>=1.7.2: Common ML utilities (encoders, imputers, scalers) used by preprocessors

Optional Feature Groups

Install only what you need via extras:

Feature Command Key Packages
Scientific Stack [scientific] scipy, scikit-image (Note: pandas and scikit-learn are core dependencies)
Computer Vision [cv] opencv-python, imagehash, pyvips, simpleitk, PyWavelets
PyTorch [pytorch] torch, torchvision, torchaudio, lion_pytorch, prodigyopt, schedulefree
TensorFlow [tensorflow] tensorflow, keras, tf-keras, tensorboard
NLP [nlp] nltk, spacy, gensim, textblob, qalsadi
PDF [pdf] PyMuPDF, PyPDF2, tabula-py, jpype1
Audio [audio] librosa, spafe, praat-parselmouth
Medical Imaging [medical] pydicom, nibabel, openslide-python, openslide-bin
Classical ML [ml] xgboost, catboost, lightgbm, optuna, imbalanced-learn
Visualization [plotting] seaborn, plotly, kaleido, ptitprince, squarify
Utilities [utils] albumentations, shap, trimesh, sympy, shapely, py7zr

See requirements.txt for exact version pins used in development. Note that pip install "hmb-helpers[all]" purposefully omits PyTorch/TensorFlow/Keras so that users can install the appropriate platform-specific (CPU/CUDA) wheels via the framework vendor instructions or by selecting the framework extras explicitly (for example pip install "hmb-helpers[pytorch]").

Features & Modules

Core Modules

  1. AgentsHelper: AI agent orchestration and interaction utilities.
  2. ArabicTextHelper: Specialized tools for Arabic text processing and analysis.
  3. AttentionMapsHelper: Tools for generating and visualizing attention maps in deep learning models.
  4. AudioHelper: Audio processing, feature extraction, and manipulation utilities.
  5. CompressionsHelper: Data compression and decompression utilities.
  6. DataAugmentationHelper: Image and data augmentation pipelines.
  7. DatasetsHelper: Utilities to detect, prepare, and validate image classification datasets (train/val/test layouts).
  8. EmbeddingsToTextHelper: Convert between embeddings and text representations for NLP tasks.
  9. ExplainabilityHelper: Model explainability and interpretability (e.g., SHAP analysis).
  10. HandCraftedFeatures: Feature extraction utilities for images and tabular data.
  11. ImagesComparisonMetrics: Image comparison metrics (SSIM, PSNR, MSE, etc.).
  12. ImageSegmentationMetrics: Segmentation evaluation metrics (IoU, Dice, pixel accuracy).
  13. ImagesHelper: Comprehensive image loading, saving, resizing, cropping, and manipulation.
  14. ImagesNormalization: Image normalization, standardization, and color space conversion.
  15. ImagesToEmbeddings: Extract embeddings from images using timm and transformers models.
  16. Initializations: Model and layer initialization helpers for deep learning frameworks.
  17. MachineLearningHelper: ML workflow helpers (data splitting, cross-validation, model selection).
  18. MetaheuristicsHelper: Metaheuristic optimization algorithms (e.g., MRFO).
  19. PDFHelper: PDF reading, extraction, manipulation, and annotation.
  20. PerformanceMetrics: Comprehensive performance metrics for classification and regression.
  21. PlotsHelper: Plotting and visualization helpers (wrappers around matplotlib/seaborn utilities).
  22. PyTorchClassificationLosses: Custom classification loss functions for PyTorch.
  23. PyTorchClassificationModelsZoo: Classification models and architectures for PyTorch.
  24. PyTorchHelper: PyTorch utilities for models, tensors, device management, and checkpointing.
  25. PyTorchModelMemoryProfiler: Utilities to profile PyTorch model memory usage.
  26. PyTorchSegmentationLosses: Custom segmentation losses (Dice, BCE, DiceBCE, Focal, Tversky, IoU).
  27. PyTorchTabularModelsZoo: Collection of tabular model utilities and reference architectures.
  28. PyTorchTrainingPipeline: Training pipeline helpers for PyTorch experiments (data loaders, trainers, schedulers).
  29. PyTorchUNetModelsZoo: UNet architecture implementations and utilities for PyTorch.
  30. StatisticalAnalysisHelper: Statistical analysis and data exploration tools.
  31. StringsHelper: String manipulation and text processing utilities.
  32. TextGenerationMetrics: Metrics for text generation models (ROUGE, BLEU, METEOR).
  33. TextHelper: Text normalization, cleaning, tokenization, and NLP utilities.
  34. TFAttentionBlocks: TensorFlow/Keras attention mechanism implementations.
  35. TFHelper: TensorFlow/Keras utilities and helpers (Grad-CAM, etc.).
  36. TFSegmentationLosses: TensorFlow/Keras segmentation loss implementations.
  37. TFUNetHelper: TensorFlow/Keras UNet-related helpers and utilities.
  38. Utils: Miscellaneous utilities for file I/O, configuration, and data handling.
  39. VectorsHelper: Vector operations and geometric computations.
  40. VideosHelper: Video processing and frame extraction utilities.
  41. VotingHelper: Ensemble voting methods for machine learning.
  42. WSIHelper: Whole Slide Image (WSI) processing for digital pathology.
  43. YOLOHelper: YOLO model training and inference utilities.

Documentation

Full documentation is available in the build/html/ directory after building with Sphinx.

On POSIX systems with make available (Linux, macOS):

cd source
make html

Examples

All example scripts, detailed usage, CLI tables and troubleshooting tips live in the examples README:

  • HMB/Examples/README.md — beginner-friendly guide with per-script descriptions, example run commands, and compact CLI tables (recommended starting point).

Quick pointers:

  • Examples and helper scripts are located under HMB/Examples.
  • Platform wrappers (Windows): HMB/Examples/BAT Files/ — run with call from the repository root.
  • Platform wrappers (POSIX): HMB/Examples/SH Files/ — run with bash.

If you want a short list of commonly used examples, open HMB/Examples/README.md — it contains a curated list and copyable run commands for each script.

Or run the equivalent POSIX wrapper (bash):

bash "HMB/Examples/SH Files/Timm_Statistics_Analysis_Ablations.sh"

To run an example Python file directly, quote the path if it contains spaces. Examples:

python "HMB\Examples\Timm_Statistics_Analysis_Ablations.py"
python3 "HMB/Examples/Timm_Statistics_Analysis_Ablations.py"

Testing

The package ships a two-tier test suite. The main suite under tests/ covers every framework-independent module and finishes in seconds on a CPU-only environment without PyTorch or TensorFlow installed. The heavy suite under HeavyTests/ holds the tests that load PyTorch, TensorFlow, Ultralytics, or timm; it is kept local and git-ignored because loading those frameworks dominates the runtime of a full run.

Run the bundled test runner:

# Run all tests.
python tests/run_tests.py

# Run a specific test file.
python tests/run_tests.py Test_ImagesHelper.py

Run tests with pytest (recommended if you have pytest installed):

pytest -q
# or run a specific test file
pytest -q tests/Test_ImagesHelper.py

Run the heavy suite (requires the full requirements.txt stack with PyTorch, TensorFlow, and Ultralytics installed):

pytest -q HeavyTests/

Test coverage includes:

  • Unit tests for all core modules
  • Edge case validation
  • Integration tests for complex workflows
  • Performance and regression tests

Current test status: 476 tests passing in the main suite (CPU-only environment without PyTorch or TensorFlow, measured at roughly 13 seconds), plus the framework-dependent tests under HeavyTests/ when the deep-learning stack is installed.

Contributing

Contributions are welcome! See CONTRIBUTING.md in the repository root for full contributor guidelines (development setup, testing, linting, PR checklist):

Quick summary:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines (short)

  • Write comprehensive docstrings for public functions and classes
  • Add unit tests for new functionality
  • Follow PEP 8 style guidelines and run black/flake8/mypy
  • Update documentation when adding or changing features
  • Ensure all tests pass before submitting a PR

Changelog

All notable changes are recorded in CHANGELOG.md in the repository root. See:

Citation & License

This project is licensed under the MIT License. See the LICENSE file for details.

Full license text is available in the repository: https://github.com/HossamBalaha/HMB-Helpers-Package/blob/main/LICENSE

If you use this package in your research, please cite the relevant modules as described in their headers.

Attribution Requirement

If you use this package in your work, please:

  1. Include a copy of the LICENSE file with any distribution
  2. Credit the author in documentation or publications:
    @software{balaha_hmb_helpers_2026_050,
      author    = {Balaha, Hossam Magdy},
      title     = {HMB-Helpers-Package: HMB-Helpers-Package v0.5.0},
      year      = {2026},
      publisher = {GitHub},
      month     = nov,
      version   = {v0.5.0},
      url       = {https://github.com/HossamBalaha/HMB-Helpers-Package}
    }
    
    @software{hossam_magdy_balaha_2026_22961799,
       author       = {Hossam Magdy Balaha},
       title        = {HossamBalaha/HMB-Helpers-Package: HMB-Helpers-Package v0.5.0},
       month        = nov,
       year         = 2026,
       publisher    = {Zenodo},
       version      = {v.0.5.0},
       doi          = {10.5281/zenodo.22961799},
       url          = {https://doi.org/10.5281/zenodo.22961799},
     }
    

Support & Contact

For questions, bug reports, or contributions, please contact the author:


Happy coding!

Metadata

Release files for hmb-helpers 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hmb-helpers 0.5.0
File Size Uploaded Provenance Actions
hmb_helpers-0.5.0.tar.gz 874.5 kB Without provenance Details for hmb_helpers-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hmb-helpers 0.5.0
File Interpreter ABI Platform Actions
hmb_helpers-0.5.0-py3-none-any.whl Python 3 none any Details for hmb_helpers-0.5.0-py3-none-any.whl

Total release size: 1.7 MB

Release files / hmb_helpers-0.5.0.tar.gz

Download URL hmb_helpers-0.5.0.tar.gz
Size 874.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2d3e65a4af9002a373a6196428fd88acfa350d81f3fe99df435f2a9510e06885
BLAKE2b-256 checksum
How to use checksums
d6617fae2bafdbad8359e0a49ca9fc15e64a2d09d29cefb1600a6069bdeda8ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / hmb_helpers-0.5.0-py3-none-any.whl

Download URL hmb_helpers-0.5.0-py3-none-any.whl
Size 846.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cabd2d20021903f01044a7f04c580e16b4461abf583624e8cebb6073cccded3
BLAKE2b-256 checksum
How to use checksums
29bb9def9f22757ed00505a86f6fe4a8724bca03b398078a5814d86e74c4c3e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for hmb-helpers 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page