{"library":"model-archiver","title":"Model Archiver","description":"Model Archiver is a Python library and command-line tool used for creating archives of trained neural network models. These archives, typically with a .mar extension, are specifically structured to be consumed by the MXNet-Model-Server for efficient inference. The PyPI package (version 1.0.3) serves as a standalone tool, although its core functionality has largely evolved into 'torch-model-archiver' for the 'TorchServe' (formerly 'Multi-Model-Server') ecosystem.","language":"python","status":"maintenance","last_verified":"Thu Apr 16","install":{"commands":["pip install model-archiver"],"cli":{"name":"model-archiver","version":"usage: model-archiver [-h] --model-name MODEL_NAME --model-path MODEL_PATH"}},"imports":["from model_archiver.mar import ModelArchiver"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"model-archiver --model-name my_mxnet_model \\\n               --version 1.0 \\\n               --model-path ./path_to_model_artifacts/ \\\n               --handler my_handler.py \\\n               --extra-files requirements.txt,config.json \\\n               --export-path ./model_store/\n\n# Example `my_handler.py` (simplified structure):\n# class MXNetHandler:\n#     def __init__(self):\n#         self.model = None\n#     def initialize(self, context):\n#         properties = context.system_properties\n#         model_dir = properties.get(\"model_dir\")\n#         # Load model, e.g., using MXNet's gluon.nn\n#         # self.model = gluon.nn.load_param(os.path.join(model_dir, 'model_params.params'))\n#     def preprocess(self, data):\n#         # Preprocess input data\n#         return data\n#     def inference(self, data):\n#         # Perform inference using self.model\n#         return self.model(data)\n#     def postprocess(self, data):\n#         # Postprocess inference results\n#         return data","lang":"bash","description":"Create a model archive (.mar file) for an MXNet model. This command packages your model artifacts, a custom handler script (`my_handler.py`), and any extra files (like `requirements.txt` or configuration files) into a single archive. The generated .mar file is then placed in the specified `export-path`. Ensure your handler script correctly implements the `initialize`, `preprocess`, `inference`, and `postprocess` methods for your specific model.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}