Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
86b224e
Logistic Regression-patch2
darksapien23151 Jun 10, 2025
8921c90
Merge branch 'main' into logreg-patch1
darksapien23151 Jun 13, 2025
297909d
Update extras/iris_pipeline_project/model_config.json
darksapien23151 Jun 26, 2025
620ae60
Update extras/iris_pipeline_project/pipeline/ovmsmodel.py
darksapien23151 Jun 26, 2025
e5af86b
Update model_config.json
darksapien23151 Jun 26, 2025
96c1953
Update Dockerfile
darksapien23151 Jun 26, 2025
e64e7a1
Update graph.pbtxt
darksapien23151 Jun 26, 2025
5e1439e
Update ovmsmodel.py
darksapien23151 Jun 26, 2025
930aaa8
Create .gitignore
darksapien23151 Jun 27, 2025
ca366ca
Delete extras/iris_pipeline_project/data directory
darksapien23151 Jun 27, 2025
8a3097d
Update .gitignore
darksapien23151 Jun 28, 2025
3cdf97c
Add files via upload
darksapien23151 Jun 28, 2025
f938740
Removed data folder
hvssmanne Jun 28, 2025
b28a63e
Create README.md
darksapien23151 Jul 1, 2025
e7a6f1f
Update client_train.py
darksapien23151 Jul 1, 2025
d70052e
Update ovmsmodel.py
darksapien23151 Jul 3, 2025
0bf9bee
Update ovmsmodel.py
darksapien23151 Jul 3, 2025
1053f5f
Update README.md
darksapien23151 Jul 3, 2025
860a889
Update Dockerfile
darksapien23151 Jul 3, 2025
f56008b
Update .gitignore
darksapien23151 Jul 6, 2025
dc5f52e
Update client_train.py
darksapien23151 Jul 7, 2025
66d5966
Update client_inference.py
darksapien23151 Jul 7, 2025
0b6cbc0
Update ovmsmodel.py
darksapien23151 Jul 7, 2025
daaf522
Update ovmsmodel.py
darksapien23151 Jul 8, 2025
3dd60cc
Modified files and removed model/
hvssmanne Jul 9, 2025
a783d99
Merge branch 'openvinotoolkit:main' into logreg-patch1
darksapien23151 Jul 9, 2025
59031cf
Merge remote-tracking branch 'origin/logreg-patch1' and resolve confl…
hvssmanne Jul 9, 2025
c49bf22
Update README.md
darksapien23151 Jul 9, 2025
a31c177
Update README.md
darksapien23151 Jul 9, 2025
59a66a0
Update README.md
darksapien23151 Jul 9, 2025
b1e6ad0
Update README.md
darksapien23151 Jul 9, 2025
36689ab
Create data_preprocess.py
darksapien23151 Jul 9, 2025
f2049be
Update .gitignore
darksapien23151 Jul 9, 2025
ffcb534
Update ovmsmodel.py
darksapien23151 Jul 9, 2025
7c00c27
Update ovmsmodel.py
darksapien23151 Jul 13, 2025
bc42ce7
Update Dockerfile
darksapien23151 Jul 13, 2025
f102453
Update ovmsmodel.py
darksapien23151 Jul 13, 2025
82d5f0c
Update client_train.py
darksapien23151 Jul 13, 2025
8821147
Add files via upload
darksapien23151 Jul 13, 2025
a614ae5
Update extras/iris_pipeline_project/Dockerfile
darksapien23151 Jul 15, 2025
49ee303
Update .gitignore
darksapien23151 Jul 15, 2025
1f1b8b4
Update ovmsmodel.py
darksapien23151 Jul 15, 2025
b61cbe1
Update data_preprocess.py
darksapien23151 Jul 15, 2025
4c68c8b
Update data_preprocess.py
darksapien23151 Jul 15, 2025
53a79b1
Merge branch 'main' into logreg-patch1
darksapien23151 Jul 15, 2025
60db5be
Update client_inference.py
darksapien23151 Jul 15, 2025
c16a94c
Update client_train.py
darksapien23151 Jul 15, 2025
c2174e9
Update README.md
darksapien23151 Jul 15, 2025
1a21d72
Update README.md
darksapien23151 Jul 15, 2025
17f77b7
Update README.md
darksapien23151 Jul 15, 2025
d0b01cf
Update Dockerfile
darksapien23151 Jul 16, 2025
43b985e
Update client_train.py
darksapien23151 Jul 23, 2025
f616db7
Update ovmsmodel.py
darksapien23151 Jul 23, 2025
701ef29
Create labelmap.json
darksapien23151 Jul 23, 2025
b76cbda
Update model_config.json
darksapien23151 Jul 23, 2025
6737047
Update client_inference.py
darksapien23151 Jul 26, 2025
7845c64
Update ovmsmodel.py
darksapien23151 Jul 26, 2025
e1dd8cb
Update Dockerfile
darksapien23151 Jul 28, 2025
2c28d8b
Update Dockerfile
darksapien23151 Aug 15, 2025
35aada3
Create model.py
darksapien23151 Aug 15, 2025
4b9784b
Update ovmsmodel.py
darksapien23151 Aug 15, 2025
0c1202f
Add hyperparameters
hvssmanne Aug 30, 2025
11e3673
Add KMeans support
hvssmanne Aug 30, 2025
02915c8
Update README.md
darksapien23151 Sep 1, 2025
bd2e780
Update README.md
darksapien23151 Sep 1, 2025
e566762
Update README.md
darksapien23151 Sep 1, 2025
79e0d3b
Update extras/iris_pipeline_project/pipeline/ovmsmodel.py
darksapien23151 Sep 1, 2025
95447f3
Update extras/iris_pipeline_project/pipeline/model.py
darksapien23151 Sep 1, 2025
b7db421
Update extras/iris_pipeline_project/client/client_inference.py
darksapien23151 Sep 1, 2025
040f0c5
Update extras/iris_pipeline_project/client/client_inference.py
darksapien23151 Sep 1, 2025
9f7d3a0
Update README.md
darksapien23151 Sep 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extras/iris_pipeline_project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/
model/
23 changes: 23 additions & 0 deletions extras/iris_pipeline_project/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM openvino/model_server:latest

USER root

ENV LD_LIBRARY_PATH=/ovms/lib
ENV PYTHONPATH=/ovms/lib/python

RUN apt-get update && apt-get install -y python3-pip
RUN pip install --no-cache-dir --break-system-packages \
pandas numpy scikit-learn joblib skl2onnx onnx onnxruntime \
scikit-learn-intelex==2025.7.0 \
tritonclient[all]
RUN python3 -m pip install --no-cache-dir --break-system-packages \
torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu && \
python3 -m pip install --no-cache-dir --break-system-packages \
intel-extension-for-pytorch oneccl_bind_pt \
--extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/

RUN rm /ovms/lib/libtbb.so* && cp /usr/local/lib/libtbb.so* /ovms/lib/

ENTRYPOINT ["/ovms/bin/ovms"]


182 changes: 182 additions & 0 deletions extras/iris_pipeline_project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# OVMS Iris Pipeline Example

This repository demonstrates how to use OpenVINO Model Server (OVMS) with a custom Mediapipe pipeline for the Iris dataset, including both model training and inference through a Python client.
At the moment, it supports Logistic regression and KMeans.

---

## Step 1: Clone the Repository

```bash
git clone https://github.com/openvinotoolkit/model_server.git
cd model_server/extras/iris_pipeline_project
```
---


## Step 2: Build and Run OVMS Docker Image

### 2.1. Build the Docker Image

```bash
docker build --no-cache -t prototype_iris .
```

### 2.2. Run the OVMS Container

```bash
docker run --rm -it -v $(pwd):/workspace -p 9000:9000 prototype_iris --config_path /workspace/model_config.json --port 9000 --log_level DEBUG
```
- **Note:** Adjust `$(pwd)` if you are running from a different working directory.

---

## Step 3: Project Structure

```
client/
├── client_inference.py
└── client_train.py
data_folder/
├── iris_train.csv
└── iris_test.csv
pipeline/
├── __pycache__/
├── graph.pbtxt
├── model.py
└── ovmsmodel.py
Dockerfile
model_config.json
kmeans_params.json
hyperparams.json

```

---

## Step 4: Run Training and Inference

### 4.1. Training

```bash
python client/client_train.py train iris_train.csv Species --params hyperparams.json --encode Species --model_class LogisticRegressionTorch

python client/client_train.py train iris_train.csv Species --params kmeans_params.json --encode Species --model_class KMeansSkLearn


```

### 4.2. Inference

```bash
python client/client_inference.py infer data_folder/iris_test.csv --target_column Species --model_class LogisticRegressionTorch

python client/client_inference.py infer iris_train_nolabel.csv --target_column Species --model_class KMeansSkLearn

```

---

For Enabling accelerator support:
Manually set the ```bool - (use_ipex/use_oneDAL)``` in model.py file under "pipeline" directory to either True/False depending on the necessity.

## Instructions for preparing the data
Run the command to download the Iris dataset, which is taken to be the hello-world dataset of classification datasets.

```bash
curl -o iris.csv https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data
```


Command-Line Usage

The training and inference client supports flexible options for both Logistic Regression and KMeans models.

Usage
python client/client_train.py <train|infer> <path_to_csv> <target_column (or NONE for KMeans)> \
[--params <path_to_params_json>] [--encode <col1,col2,...>] [--model_class <ModelClassName>]

Arguments

train|infer
Mode of operation.

train: Train a new model with the provided dataset.

infer: Run inference using a trained model.

<path_to_csv>
Path to the dataset in CSV format.

<target_column>

For classification (Logistic Regression): name of the target column.

For clustering (KMeans): use NONE.

--params <path_to_params_json> (optional)
Path to a JSON file containing model hyperparameters.
Example:

{
"max_iter": 300,
"solver": "lbfgs",
"random_state": 42,
"n_clusters": 3
}

If not provided, default parameters are used.

--encode <col1,col2,...> (optional)
Comma-separated list of categorical column names to encode.

Encoding can also be performed client-side before sending data to the server.

If omitted, no encoding is applied.

--model_class <ModelClassName> (optional)
Specify the model class explicitly (e.g., LogisticRegression, KMeans).

Defaults are inferred from the mode and target column.

---

## Troubleshooting

- **Logs:**
For debugging, check OVMS container logs:
```bash
docker logs prototype_iris
```
- **Code Changes:**
After editing `pipeline/ovmsmodel.py`, **restart the OVMS container** for changes to take effect.

- **If nothing prints from your Python node:**
- Use `flush=True` in your print statements.
- Print to `sys.stderr`.
- Try writing to a file inside the container for debug.

---

## Example Output
For Training:

```
Read CSV file successfully
Training mode detected. Preparing data for training...
Connected to OVMS at localhost:9000
Model trained successfully

```
For Inference:

```
Read CSV file successfully
Inference mode detected.
Inference predictions: [...]

```

---

NOTE: Cluster assignments and centroid details are available in the container logs. Since the terminal is non-GUI, .show() visualization is not supported.
Loading