metadata:
  name: emdetector
  namespace: cvat
  annotations:
    name: EM14 v1
    type: detector
    framework: pytorch
    spec: |
      [
        { "id": 0, "name": "EM14", "type": "rectangle" },
        { "id": 1, "name": "EM18", "type": "rectangle" },
        { "id": 2, "name": "EM17", "type": "rectangle" },
        { "id": 3, "name": "EM170", "type": "rectangle" },
        { "id": 4, "name": "EM19", "type": "rectangle" },
        { "id": 5, "name": "EM190", "type": "rectangle" },
        { "id": 6, "name": "EM20", "type": "rectangle" },
        { "id": 7, "name": "EM200", "type": "rectangle" },
        { "id": 8, "name": "EM201", "type": "rectangle" },
        { "id": 9, "name": "EM202", "type": "rectangle" },
        { "id": 10, "name": "EM203", "type": "rectangle" }
      ]      

spec:
  description: 工位检测
  runtime: "python:3.9"
  handler: main:handler
  eventTimeout: 30s

  build:
    image: cvat.pth.yolo8.emdetector:latest-gpu
    baseImage: python:3.9
    directives:
      preCopy:
        - kind: ENV
          value: DEBIAN_FRONTEND=noninteractive
        - kind: RUN
          value: apt-get update && apt-get install -y libgl1 libglib2.0-0 && apt-get clean
        - kind: RUN
          value: pip install ultralytics torch torchvision opencv-python-headless && pip cache purge

  triggers:
    myHttpTrigger:
      numWorkers: 1
      kind: 'http'
      workerAvailabilityTimeoutMilliseconds: 10000
      attributes:
        # Set value from the calculation of tracking of 100 objects at the same time on a 4k image
        maxRequestBodySize: 268435456 # 256MB

  volumes:
    - volume:
        name: model-volume
        hostPath:
          path: /DATA/wjl/cvat/models/best.pt  # 可选：如果使用HostPath挂载模型
      volumeMount:
        name: model-volume
        mountPath: /opt/nuclio/best.pt

  resources:
    limits:
      nvidia.com/gpu: 1

  platform:
    attributes:
      restartPolicy:
        name: always
        maximumRetryCount: 3
      mountMode: volume
