Skip to content

bybatkhuu/model.python-template

Repository files navigation

Model Template (AI/ML) module

This is a template repo for AI/ML model module.

Features

  • AI/ML model
  • Python module/package
  • Jupyter notebook
  • Template
  • CI/CD

Installation

1. Prerequisites

For development environment:

2. Download or clone the repository

2.1. Prepare projects directory (if not exists):

# Create projects directory:
mkdir -pv ~/workspaces/projects

# Enter into projects directory:
cd ~/workspaces/projects

# Set repository owner:
export _REPO_OWNER=[REPO_OWNER]
# For example:
export _REPO_OWNER=username

2.2. Follow one of the below options [A] or [B]:

A. Download source code from releases page:

# Set to downloaded version:
export _VERSION=[VERSION]
# For example:
export _VERSION=1.0.0

mv -v ~/Downloads/model.python_template-${_VERSION}.zip . && \
    unzip model.python_template-${_VERSION}.zip && \
    rm -v model.python_template-${_VERSION}.zip && \
    mv -v model.python_template-${_VERSION} model_template && \
    cd model_template

B. Or clone the repository (for development: git + ssh key):

git clone git@github.com:${_REPO_OWNER}/model.python_template.git model_template && cd model_template

3. Install python dependencies

3.1. Install base/common dependencies

< ./requirements.txt grep -v '^#' | xargs -t -L 1 pip install --timeout 60 --no-cache-dir

3.2. Install hardware specific dependencies

Follow the one of below instructions based on your environment (A is recommended for most cases):

A. For Intel/AMD x86_64 CPU:

< ./requirements.amd64.txt grep -v '^#' | xargs -t -L 1 pip install --timeout 60 --no-cache-dir

B. For arm64/aarch64 CPU:

< ./requirements.arm64.txt grep -v '^#' | xargs -t -L 1 pip install --timeout 60 --no-cache-dir

C. For NVIDIA GPU and x86_64 CPU:

< ./requirements.gpu.txt grep -v '^#' | xargs -t -L 1 pip install --timeout 60 --no-cache-dir

4. Install the module

Follow the one of below instructions based on your situation (A and B recommended for most cases):

A. Copy the module into the project directory [Recommended]:

# Copy the module source code to the project:
cp -r model_template [PROJECT_DIR]
# For example:
cp -r model_template /some/path/project/

B. Add module path to PYTHONPATH:

# Add current path to PYTHONPATH:
export PYTHONPATH="${PWD}:${PYTHONPATH}"

# Or add the module path to PYTHONPATH:
export PYTHONPATH="[MODULE_PATH]:${PYTHONPATH}"
# For example:
export PYTHONPATH="/some/path/model_template:${PYTHONPATH}"

C. Install wheel package (Not recommended):

Note: Not completed yet, because the GPU, CPU and ARM compatible wheel packages are not separated yet.

# Not implemented yet.

# Build wheel package:
pip install --upgrade pip setuptools wheel
python setup.py bdist_wheel

# Install wheel package:
pip install ./dist/model_template-[VERSION]-py3-none-any.whl
# For example:
pip install ./dist/model_template-0.0.1-py3-none-any.whl

Usage/Examples

Simple example

from model_template import ModelTemplate

Advanced example

# Not implemented yet

👍 ✨


Configuration

Environment variables

You can use the following environment variables to configure:

.env.example

Arguments

You can use the following arguments to configure:

Running Tests

To run tests, run the following command:

# Install test dependencies:
pip install --upgrade pytest

# Run tests:
pytest

Documentation

...

Roadmap

...


References

Releases

No releases published

Packages

No packages published