Metadata-Version: 2.4
Name: isarsoft-model-utility
Version: 0.1.0
Summary: Isarsoft Model Export Toolkit - Export models for Perception
Author-email: Isarsoft <support@isarsoft.com>
License: Apache License 2.0
Project-URL: Homepage, https://isarsoft.com
Project-URL: Repository, https://gitlab.com/isarsoft/isarsoft-model-utility
Project-URL: Issues, https://gitlab.com/isarsoft/isarsoft-model-utility/issues
Keywords: onnx,object-detection,export,machine-learning,perception
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=1.13.0
Requires-Dist: onnx<=1.17.0
Requires-Dist: onnxruntime<=1.21.0
Requires-Dist: onnxsim
Requires-Dist: opencv-contrib-python-headless
Requires-Dist: numpy==1.26.4
Requires-Dist: Pillow
Requires-Dist: onnxslim==0.1.58
Requires-Dist: rfdetr[onnxexport]==1.1.0rc0
Requires-Dist: colored
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: license-file

# Isarsoft Model Utility

A command-line utility for exporting object detection models to ONNX format for Isarsoft Perception, complete with metadata generation and optional packaging.

## Features

* Convert PyTorch `.pt` models from RFDETR to ONNX
* Embed metadata: class labels, model description, company attribution
* Options to anonymize or georeference specific classes
* Support for custom input image sizes
* Generate a thumbnail for frontend display (optional)
* Package outputs into a ZIP archive (optional)
* Verbose logging for debugging and audit trails

## Requirements

* Python 3.10 or later

## Installation

```bash

# Create a conda environment (recommended)
conda create -n isarsoft-export python=3.10 -y
conda activate isarsoft-export

# Install the package
pip install isarsoft-model-utility
```

## Usage

```bash
isarsoft-export --model <MODEL_PATH> \
                --output <OUTPUT_DIR> \
                --classes <CLASS_LIST> 
                --model-name <MODEL>
```

All flags and options are described below.

### Required Arguments

| Flag        | Shortcut | Description                                                   |
| ----------- | -------- | ------------------------------------------------------------- |
| `--model`   | `-m`     | Path to model file (`.pt`) or use `default` for pretrained   |
| `--output`  | `-o`     | Directory where exported files will be saved                  |
| `--classes` | `-c`     | Comma-separated list of class names (e.g., `person,car,bike`) |


### Optional Arguments

| Flag                     | Shortcut | Type    | Default                          | Description                                                 |
| ------------------------ | -------- | ------- | -------------------------------- | ----------------------------------------------------------- |
| `--model-name`           | `-n`     | String  | `rfdetr`                         | Model Name for the Frontend                                 |
| `--description`          | `-d`     | String  | `Object detection model` | Model description for metadata                              |
| `--company`              |          | String  | `Generated`                      | Company name for metadata                                   |
| `--anonymize-classes`    |          | String  | None                             | Comma-separated class indices to anonymize (e.g., `0,1`)    |
| `--georeference-classes` |          | String  | None                             | Comma-separated class indices to georeference (e.g., `2,3`) |
| `--imgsz`                |          | Integer | `560`                            | Input image size for export                                 |
| `--thumbnail`            |          | String  | None                             | Location of thumbnail for Frontend                          |
| `--no-zip`               |          | Flag    | Disabled                         | Skip creating zip package                                   |
| `--verbose`              | `-v`     | Flag    | Disabled                         | Enable verbose logging                                      |

### Examples

Basic export with class names:

```bash
isarsoft-export \
  --model model.pt \
  --output ./exported \
  --classes person,car,bike
  --model-name custom
```

Export with custom metadata and class options:

```bash
isarsoft-export \
  --model model.pt \
  --output ./exported \
  --classes person,vehicle,animal \
  --description "Multi-class detector" \
  --company "MyCompany" \
  --anonymize-classes 0 \
  --georeference-classes 1,2 \
  --model-name custom
```

Export with custom image size and thumbnail:

```bash
isarsoft-export \
  --model model.pt \
  --output ./exported \
  --classes person \
  --imgsz 728 \
  --thumbnail ./thumbnail.svg \
  --model-name custom
```

## Exit Codes

* `0` on successful export
* `1` on failure (errors are printed; use `--verbose` for traceback)

## Logging

Verbose mode (`--verbose`) outputs detailed logs to the console, including validation steps and stack traces on error.
