Add quartz inspection core ignore rules

This commit is contained in:
trung09122002
2026-05-13 17:31:00 +07:00
commit f2db04e640
9 changed files with 1041 additions and 0 deletions

31
scripts/build_engine.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CORE_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
ONNX_PATH="${1:-${CORE_DIR}/models/yolo26_tile_seg_v3.onnx}"
ENGINE_PATH="${2:-${CORE_DIR}/models/yolo26_tile_seg_v3_fp16.trt}"
TRTEXEC="${TRTEXEC:-}"
if [[ -z "${TRTEXEC}" ]]; then
if command -v trtexec >/dev/null 2>&1; then
TRTEXEC="$(command -v trtexec)"
elif [[ -n "${TENSORRT_DIR:-}" && -x "${TENSORRT_DIR}/bin/trtexec" ]]; then
TRTEXEC="${TENSORRT_DIR}/bin/trtexec"
elif [[ -x "/usr/src/tensorrt/bin/trtexec" ]]; then
TRTEXEC="/usr/src/tensorrt/bin/trtexec"
else
echo "trtexec was not found. Install TensorRT 10+ or set TRTEXEC=/path/to/trtexec." >&2
exit 1
fi
fi
mkdir -p "$(dirname "${ENGINE_PATH}")"
"${TRTEXEC}" \
--onnx="${ONNX_PATH}" \
--saveEngine="${ENGINE_PATH}" \
--fp16 \
--useCudaGraph \
--noDataTransfers
echo "TensorRT engine written to: ${ENGINE_PATH}"

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python3
"""Export the trained YOLO26 segmentation model to ONNX for TensorRT."""
import os
from pathlib import Path
from ultralytics import YOLO
CORE_DIR = Path(__file__).resolve().parents[1]
MODEL = Path(os.environ.get(
"YOLO26_MODEL",
CORE_DIR / "runs/segment/yolo26_tile_seg_v3/weights/best.pt",
))
OUT_DIR = CORE_DIR / "models"
EXISTING_ONNX = CORE_DIR / "runs/segment/yolo26_tile_seg_v3/weights/best.onnx"
def require_yolo26_support() -> None:
from ultralytics.nn.modules import head
if not hasattr(head, "Segment26"):
raise RuntimeError(
"This checkpoint uses the YOLO26 Segment26 head, but the active "
"ultralytics install does not provide it. Run this script with the "
"same YOLO26-capable Python environment used for training."
)
def main() -> None:
OUT_DIR.mkdir(parents=True, exist_ok=True)
target = OUT_DIR / "yolo26_tile_seg_v3.onnx"
if EXISTING_ONNX.exists():
if EXISTING_ONNX.resolve() != target.resolve():
target.write_bytes(EXISTING_ONNX.read_bytes())
print(f"ONNX copied to: {target}")
return
if not MODEL.exists():
raise FileNotFoundError(f"Model checkpoint not found: {MODEL}")
require_yolo26_support()
model = YOLO(str(MODEL))
exported = model.export(
format="onnx",
imgsz=864,
opset=17,
simplify=True,
dynamic=False,
half=False,
)
exported_path = Path(exported)
if exported_path.resolve() != target.resolve():
target.write_bytes(exported_path.read_bytes())
print(f"ONNX exported to: {target}")
if __name__ == "__main__":
main()