Metadata-Version: 2.4
Name: iinfer
Version: 0.13.3
Summary: iinfer: An application that executes AI model files in onnx or mmlab format.
Author-email: hamacom2004jp <hamacom2004jp@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/hamacom2004jp/iinfer
Project-URL: Documentation, https://hamacom2004jp.github.io/iinfer/index.html
Project-URL: Repository, https://github.com/hamacom2004jp/iinfer
Keywords: mmdetection,mmsegmentation,onnxruntime,inference,image,ai,model,cmdbox,audit,cli,excel,fastapi,mcp,redis,restapi,web
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Japanese
Classifier: Programming Language :: Python
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cmdbox<0.7.9,>=0.7.8
Requires-Dist: motpy
Requires-Dist: opencv-python
Requires-Dist: urllib3
Provides-Extra: agent-mcp
Requires-Dist: pydantic<3.0.0,>=2.0.0; extra == "agent-mcp"
Requires-Dist: fastmcp>=2.14.4; extra == "agent-mcp"
Requires-Dist: mcp<2.0.0,>=1.23.0; extra == "agent-mcp"
Provides-Extra: agent-adk
Requires-Dist: google-adk>=1.23.0; extra == "agent-adk"
Requires-Dist: a2a-sdk<0.4.0,>=0.3.4; extra == "agent-adk"
Requires-Dist: litellm<1.80.17,>=1.75.5; extra == "agent-adk"
Provides-Extra: agent-mem
Requires-Dist: sentence-transformers; extra == "agent-mem"
Requires-Dist: sqlite_vec; extra == "agent-mem"
Requires-Dist: transformers>=4.48.0; extra == "agent-mem"
Requires-Dist: torch; extra == "agent-mem"
Provides-Extra: rag
Requires-Dist: chunklet-py[document]; extra == "rag"
Requires-Dist: langchain_community; extra == "rag"
Requires-Dist: markdown; extra == "rag"
Requires-Dist: pdfplumber; extra == "rag"
Provides-Extra: omni
Requires-Dist: accelerate>=1.12.0; extra == "omni"
Requires-Dist: qwen-omni-utils>=0.0.9; extra == "omni"
Requires-Dist: torchvision>=0.25.0; extra == "omni"
Provides-Extra: saml
Requires-Dist: python3-saml; extra == "saml"
Requires-Dist: xmlsec==1.3.13; extra == "saml"
Provides-Extra: all
Requires-Dist: cmdbox[agent_adk,agent_mcp,agent_mem,omni,rag,saml]; extra == "all"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: collectlicense; extra == "dev"
Requires-Dist: sphinx; extra == "dev"
Requires-Dist: sphinx-rtd-theme; extra == "dev"
Requires-Dist: sphinx_fontawesome; extra == "dev"
Requires-Dist: sphinx-intl; extra == "dev"
Requires-Dist: sphinx-sitemap; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Dynamic: license-file

# iinfer (Image Inference Application)

- onnx又はmmlabフォーマットのAIモデルファイルを実行するアプリケーションです。
- ドキュメントは[こちら](https://hamacom2004jp.github.io/iinfer/)。
- このアプリケーションは[cmdbox](https://github.com/hamacom2004jp/cmdbox/)をベースにしています。
- iinferを使用することで、AIモデルを簡単に実行することが出来ます。
- 動作確認したモデルは[動作確認済みモデル](https://hamacom2004jp.github.io/iinfer/docs/models.html)に記載しています。
- 主なAIタスクは、画像分類、物体検知、領域検知、顔検知、顔認識です。
- 複数の `iinfer` コマンドの入出力をつなげる、パイプライン処理を行うことが出来ます。
- GUIモードを使用することで、 `iinfer` コマンド操作を簡単に行うことが出来ます。


## iinferの動作イメージ

![iinferの動作イメージ](https://github.com/hamacom2004jp/iinfer/raw/main/docs_src/static/orverview.drawio.png)

1. **iinfer client** は **imageファイル** や **camera** から画像を取得し、 **推論結果 predict.json** を出力します。
2. **iinfer server** は推論を行うサーバーです。 **iinfer client** からの要求に応えて、推論結果を **iinfer client** に返します。
3. **iinfer server** は予め **ai model** をロードしておくことで、推論を高速化します。
4. **iinfer client** と **iinfer server** は **Redis** 経由で通信します。
5. **iinfer server** と **Redis** は **dockerコンテナ** を使用して起動させることが出来ます。

## インストール方法

- 次のコマンドで iinfer をインストールしてください。
- また、Docker 版の Redis サーバーもインストールしてください。
- 詳細なインストール方法は [こちら](https://hamacom2004jp.github.io/iinfer/docs/install.html) を参照してください。

```bash
docker run -p 6379:6379 --name redis -e REDIS_PASSWORD=password -it ubuntu/redis:latest
pip install iinfer
iinfer -v
```

- WebモードでSAMLを使用する場合、依存関係のあるモジュールをインストールしてください。
```bash
pip install iinfer[saml]
apt-get install -y pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl build-essential libopencv-dev
```

- Webモードで`--agent use`を使用する場合、依存関係のあるモジュールをインストールしてください。
```bash
pip install "pydantic>=2.0.0,<3.0.0"
pip install "fastmcp>=2.14.0" "mcp>=1.10.0,<2.0.0"
pip install "google-adk>=1.21.0" "litellm"
```

## iinferの使用方法

iinferを使用するには、次のコマンドを実行します:

1. guiモードで利用する場合:

![guiモードのイメージ](https://github.com/hamacom2004jp/iinfer/raw/main/docs_src/static/ss/00242_cmd_predict.jpg)

```bash
iinfer -m gui -c start
```

2. コマンドモードで利用する場合

    1. AIモデルのデプロイ:

    ```bash
    # 画像AIモデルのデプロイ
    # 推論タイプはモデルのAIタスクやアルゴリズムに合わせて指定する。指定可能なキーワードは"iinfer -m client -c predict_type_list"コマンド参照。
    iinfer -m client -c deploy -n <任意のモデル名> -f \
                               --model_file <モデルファイル> \
                               --model_conf_file <モデル設定ファイル> \
                               --predict_type <推論タイプ> \
                               --label_file <ラベルファイル>

    # デプロイされている画像AIモデルの一覧
    iinfer -m client -c deploy_list -f
    ```

    2. AIモデルのセッションを開始:

    ```bash

    # 画像AIモデルを起動させて推論可能な状態に(セッションを確保)する
    # use_trackを指定するとObjectDetectionタスクの結果に対して、MOT（Multi Object Tracking）を実行しトラッキングIDを出力する。
    iinfer -m client -c start -n <モデル名> -f \
                              --use_track
    ```

   3. 推論を実行:

    ```bash
    # 推論を実行する
    # output_previewを指定するとimshowで推論結果画像を表示する（GUI必要）
    iinfer -m client -c predict -n <モデル名> -f \
                                -i <推論させる画像ファイル> \
                                -o <推論結果の画像ファイル> \
                                --output_preview

    # カメラキャプチャー画像を元に推論を実行し、クラススコアが0.8以上の物体のみを検出する
    # --stdin --image_type capture で標準入力のキャプチャー画像を推論する
    iinfer -m client -c capture | \
    iinfer -m client -c predict -n <モデル名> \
                                --stdin \
                                --image_type capture \
                                --nodraw | \
    iinfer -m postprocess -c det_filter -f -P \
                                --stdin \
                                --score_th 0.8
    ```

    4. AIモデルのセッションを開放:

    ```bash
    # 画像AIモデルを停止させてセッションを開放
    iinfer -m client -c stop -n <モデル名> -f
    ```

## Lisence

This project is licensed under the MIT License, see the LICENSE file for details
