diff --git a/immich_model_exporter/__init__.py b/immich_model_exporter/__init__.py index 64f3ae7..244d99f 100644 --- a/immich_model_exporter/__init__.py +++ b/immich_model_exporter/__init__.py @@ -2,6 +2,7 @@ import resource from pathlib import Path +import numpy as np import typer from tenacity import retry, stop_after_attempt, wait_fixed from typing_extensions import Annotated @@ -53,6 +54,8 @@ def export( output_dir = output_dir / model_name match model_source: case ModelSource.MCLIP | ModelSource.OPENCLIP: + rand = np.random.rand(1,77) + np.save("randtextualinput.npy",rand) output_dir.mkdir(parents=True, exist_ok=True) onnx_export(hf_model_name, model_source, output_dir, cache=cache) case ModelSource.INSIGHTFACE: diff --git a/immich_model_exporter/exporters/constants.py b/immich_model_exporter/exporters/constants.py index 45e08a5..4f47c9f 100644 --- a/immich_model_exporter/exporters/constants.py +++ b/immich_model_exporter/exporters/constants.py @@ -35,6 +35,7 @@ class SourceMetadata(NamedTuple): } RKNN_SOCS = ["rk3566", "rk3568", "rk3576", "rk3588"] +RKNN_BLOCKED_OPS = ["CumSum"] # glob to delete old UUID blobs when reuploading models diff --git a/immich_model_exporter/exporters/rknn.py b/immich_model_exporter/exporters/rknn.py index c45c4a6..47dca78 100644 --- a/immich_model_exporter/exporters/rknn.py +++ b/immich_model_exporter/exporters/rknn.py @@ -1,6 +1,6 @@ from pathlib import Path -from .constants import RKNN_SOCS +from .constants import RKNN_BLOCKED_OPS, RKNN_SOCS def _export_platform( @@ -36,6 +36,15 @@ def _export_platform( ret = rknn.build(do_quantization=False) + if "textual" in input_path.as_posix(): + ret = rknn.accuracy_analysis(inputs=["randtextualinput.npy"]) + if ret != 0: + RuntimeError("Accuracy analysis failed!") + analysis_result= open("./snapshot/error_analysis.txt","r") + for ops in RKNN_BLOCKED_OPS: + if ops in analysis_result.read(): + raise RuntimeError("ONNX Model contains Unsupported OPs!") + if ret != 0: raise RuntimeError("Build failed!")