Skip to content

Instantly share code, notes, and snippets.

@RobGeada
RobGeada / TrustyAIDeployment.yaml
Created November 7, 2023 12:43
TrustyAI Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
annotations:
deployment.kubernetes.io/revision: '2'
resourceVersion: '152956090'
name: trustyai-service
uid: 9c074c66-b21b-4727-b92e-b686bc17b838
creationTimestamp: '2023-11-07T12:11:09Z'
generation: 2
@RobGeada
RobGeada / model_yolo.yaml
Created October 20, 2023 15:00
YOLOv5 model for ODH + OVMS
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: yolo-model
annotations:
serving.kserve.io/deploymentMode: ModelMesh
spec:
predictor:
model:
modelFormat:
@RobGeada
RobGeada / trustyai_yolo_minio.yaml
Created October 20, 2023 14:57
TrustyAI Minio for YOLOv5 on ODH
apiVersion: v1
kind: Service
metadata:
name: minio
spec:
ports:
- name: minio-client-port
port: 9000
protocol: TCP
targetPort: 9000
{"learner":{"attributes":{"best_iteration":"99","best_ntree_limit":"100","scikit_learn":"{\"n_estimators\": 100, \"objective\": \"reg:squarederror\", \"max_depth\": null, \"max_leaves\": null, \"max_bin\": null, \"grow_policy\": null, \"learning_rate\": null, \"verbosity\": null, \"booster\": null, \"tree_method\": null, \"gamma\": null, \"min_child_weight\": null, \"max_delta_step\": null, \"subsample\": null, \"sampling_method\": null, \"colsample_bytree\": null, \"colsample_bylevel\": null, \"colsample_bynode\": null, \"reg_alpha\": null, \"reg_lambda\": null, \"scale_pos_weight\": null, \"base_score\": null, \"missing\": NaN, \"num_parallel_tree\": null, \"random_state\": 42, \"n_jobs\": null, \"monotone_constraints\": null, \"interaction_constraints\": null, \"importance_type\": null, \"gpu_id\": null, \"validate_parameters\": null, \"predictor\": null, \"enable_categorical\": false, \"feature_types\": null, \"max_cat_to_onehot\": null, \"max_cat_threshold\": null, \"eval_metric\": null, \"early_stopping
@RobGeada
RobGeada / coco-000000339995.json
Created September 4, 2023 15:09
Example Coco Kserve payload
This file has been truncated, but you can view the full file.
{"inputs": [{"name": "images", "shape": [1, 3, 640, 640], "datatype": "FP32", "data": [[[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 101, 101, 102, 101, 105, 107, 103, 102, 103, 103, 106, 110, 109, 113, 112, 110, 109, 109, 115, 117, 118, 124, 127, 125, 127, 112, 109, 117, 112, 113, 110, 112, 114, 113, 110, 112, 111, 110, 110, 108, 113, 112, 107, 98, 100, 101, 103, 103, 111, 116, 112, 112, 118, 120, 116, 113, 117, 116, 114, 114, 119, 115, 116, 112, 112, 116, 114, 112, 114, 110, 106, 109, 110, 111, 113, 113, 112, 113, 114, 116, 129, 120, 123, 122, 113, 114, 121, 119, 122, 122, 126, 117, 111, 97, 103, 112, 114, 112, 106, 104, 103, 112, 117, 122, 122, 124, 126, 132, 135, 139, 144, 151, 160, 161, 156, 156, 153, 140, 123, 110, 107, 99, 98, 99, 1
@RobGeada
RobGeada / coco_to_kserve.py
Last active September 4, 2023 15:51
Convert COCO images to KSserve payloads
import os
import json
import numpy as np
from PIL import Image
def expand2square(pil_img, background_color):
width, height = pil_img.size
if width == height:
return pil_img
elif width > height:
@RobGeada
RobGeada / trustyai_operator_kfdef.yaml
Created August 17, 2023 14:55
Default TrustyAI Operator KFDef
apiVersion: kfdef.apps.kubeflow.org/v1
kind: KfDef
metadata:
name: trustyai-service-operator
spec:
applications:
- kustomizeConfig:
repoRef:
name: manifests
path: config
@RobGeada
RobGeada / chess_visualization.py
Created August 4, 2023 11:49
Chess plotter in Matplotlib
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
plt.style.use('https://raw.githubusercontent.com/RobGeada/stylelibs/main/material_tex.mplstyle')
mpl.rcParams["text.usetex"] = "false"
import numpy as np
def draw_board():
colors = np.zeros([8,8])
colors[::2,::2] = 1
import drools_integrators.DroolsWrapper;
import drools_integrators.Explainers;
import org.apache.commons.math3.analysis.function.Exp;
import org.junit.Test;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.trustyai.explainability.model.Feature;
import org.kie.trustyai.explainability.model.FeatureFactory;
import org.kie.trustyai.explainability.model.Output;
import org.kie.trustyai.explainability.model.PredictionInput;
@RobGeada
RobGeada / shap_value_candlestick_plot.py
Last active November 29, 2021 15:29
Generate candlestick plot from PmmlShapExplainerTest output
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams.update({
"axes.facecolor": "DDDDDD",
"axes.edgecolor": "white",
"axes.grid": True,
"axes.axisbelow": True,
"legend.facecolor": "ffffff",