Skip to content

Unified Model Serialization, Export, and Deployment API #119

@dagbolade

Description

@dagbolade

Overview

PyDeepFlow currently lacks a unified and robust API for saving, loading, exporting, and deploying trained models (including both ANNs and CNNs). This feature is crucial for research reproducibility, production deployment, model sharing, and integration with external tools or services. The goal is to design and implement a comprehensive serialization and deployment system.

Key Requirements

1. Model Save/Load Utilities

  • Implement save_model and load_model methods for all primary model classes (e.g., Multi_Layer_ANN, Multi_Layer_CNN).
  • Ensure model architecture, weights, optimizer state, and training history are all stored.
  • Support multiple file formats: custom binary (pickle), HDF5, and (optionally) ONNX.
  • Integrate with checkpoint callbacks for seamless training resumption.

2. Export to Standardized Formats

  • Enable export of trained models to the ONNX format for interoperability with other frameworks and deployment platforms.
  • Provide utilities for conversion and clear user-facing documentation/examples.

3. Deployment Helpers

  • Simple, consistent prediction/inference API for both batch and single-instance usage.
  • (Optional) Provide a reference CLI or HTTP server for serving models (e.g., using FastAPI or Flask).

4. Documentation and Examples

  • Add Jupyter notebook and script examples for model saving, loading, exporting, and basic serving.
  • Update documentation to cover new features and recommended workflows.

5. Testing and Compatibility

  • Comprehensive tests ensuring models can be saved, loaded, and produce consistent results.
  • Document any migration/compatibility guidance for existing users.

Value Proposition

  • Makes PyDeepFlow production and research ready.
  • Enables reproducibility and easy sharing of trained models.
  • Facilitates integration with other ML tools and external deployment solutions.

Acceptance Criteria

  • Models can be saved and loaded with all state preserved.
  • Export to ONNX or similar format is possible for both ANN and CNN.
  • At least one example notebook and script are provided.
  • Documentation is updated to include new workflow.
  • Adequate coverage in automated tests.

Related areas: pydeepflow/model.py, pydeepflow/checkpoints.py, pydeepflow/optimizers.py, pydeepflow/early_stopping.py, and documentation.

This is a major enhancement and may require discussion and iteration.


If you find this issue to be a good fit, could you please assign it to me @dagbolade? Thank you!

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions