metadata:
  name: openvino.omz.public.yolo-v3-tf
  namespace: cvat
  annotations:
    name: YOLO v3
    type: detector
    framework: openvino
    #spec_label_update_start
    spec: |
      [
        { "id": 0, "name": "PatientInformation" },
        { "id": 1, "name": "PatientInformationCol2" },
        { "id": 2, "name": "MedicalRecord" },
        { "id": 3, "name": "CptCode" },
        { "id": 4, "name": "SchedulingInformation" },
        { "id": 5, "name": "FaceSheet" },
        { "id": 6, "name": "ContactInformation" },
        { "id": 7, "name": "ContactInformationCol2" },
        { "id": 8, "name": "Intraop-CRNATime" },
        { "id": 9, "name": "Intraop-MDTime" },
        { "id": 10, "name": "Intraop-StaffSignature" },
        { "id": 11, "name": "Intraop-PreopDiagnosis" },
        { "id": 12, "name": "Intraop-Actions" },
        { "id": 13, "name": "Intraop-Comments" },
        { "id": 14, "name": "Preop-ProcedureScheduled" },
        { "id": 15, "name": "Preop-ReviewOfSystems" },
        { "id": 16, "name": "Preop-PastMedicalHistory" },
        { "id": 17, "name": "Preop-SurgicalHistory" },
        { "id": 18, "name": "Preop-PhysicalEvaluation" },
        { "id": 19, "name": "Preop-AssessmentPlan" },
        { "id": 20, "name": "InsuranceCard-Front" },
        { "id": 21, "name": "InsuranceCard-Back" },
        { "id": 22, "name": "DriversLicense-Front" },
        { "id": 23, "name": "DriversLicense-Back" },
        { "id": 24, "name": "UltrasoundImage" },
        { "id": 25, "name": "Preop-Diagnosis" },
        { "id": 26, "name": "ProcedureSummary" },
        { "id": 27, "name": "Intraop-StaffTimes" },
        { "id": 28, "name": "Intraop-Events" },
        { "id": 29, "name": "Intraop-Medications" },
        { "id": 30, "name": "Intraop-Events-Continued" },
        { "id": 31, "name": "Intraop-LDAs" },
        { "id": 32, "name": "Preop-Signatures" },
        { "id": 33, "name": "Preop-ProblemList" },
        { "id": 34, "name": "Postop-Note" },
        { "id": 35, "name": "ProcedureNote" },
        { "id": 36, "name": "ProcedureNote-Continued" },
        { "id": 37, "name": "Header" },
        { "id": 38, "name": "Footer" },
        { "id": 39, "name": "Intraop-CaseTrackingEvents" },
        { "id": 40, "name": "Attestations" },
        { "id": 41, "name": "Postop-Note-Continued" },
        { "id": 42, "name": "Attestations-Continued" },
        { "id": 43, "name": "ProcedureNote-TEE" },
        { "id": 44, "name": "ProcedureNote-TEE-Continued" },
        { "id": 45, "name": "Postop-Diagnosis" },
        { "id": 46, "name": "Intraop-LDAs-Continued" },
        { "id": 47, "name": "PostProcedureSummary" },
        { "id": 48, "name": "ProcedureDiagnosis" },
        { "id": 49, "name": "AnesthesiaStart" },
        { "id": 50, "name": "AnesthesiaStop" },
        { "id": 51, "name": "Intraop-CaseTrackingEvents-Continued" },
        { "id": 52, "name": "OperativeReport" },
        { "id": 53, "name": "OperativeReport-BRIEF" },
        { "id": 54, "name": "OperativeReport-Continued" },
        { "id": 55, "name": "PatientName" },
        { "id": 56, "name": "Intraop-Grid" },
        { "id": 57, "name": "ORIn" },
        { "id": 58, "name": "OROut" },
        { "id": 59, "name": "ORSchedule-ROW" },
        { "id": 60, "name": "ORSchedule" },
        { "id": 61, "name": "Order-Block-BlockRequested" },
        { "id": 62, "name": "Order-Block" },
        { "id": 63, "name": "Order-Block-Date" },
        { "id": 64, "name": "ORSchedule-Site-Cumberland" },
        { "id": 65, "name": "PatientMRN" },
        { "id": 66, "name": "PatientDOB" },
        { "id": 67, "name": "PatientPhone" },
        { "id": 68, "name": "SurgeryPlanned-Description" },
        { "id": 69, "name": "SurgeryPerformed-Description" },
        { "id": 70, "name": "Intraop-Vital-ArtLine" },
        { "id": 71, "name": "PatientLabel" }
      ]
    #spec_label_update_end
spec:
  description: YOLO v3 via Intel OpenVINO
  runtime: "python:3.6"
  handler: main:handler
  eventTimeout: 30s
  # volumes:
  #   - volume: 
  #     hostPath:
  #       path: "/c/Users/jack/Documents/GitHub/cvat/serverless/openvino/common"
  #     volumeMount: 
  #       mountPath: "/opt/nuclio/common"
  env:
    - name: NUCLIO_PYTHON_EXE_PATH
      value: /opt/nuclio/common/python3 #/usr/bin/python3 #

  build:
    image: cvat/openvino.omz.public.yolo-v3-tf
    baseImage: openvino/ubuntu18_dev:2020.2

    directives:
      preCopy:
      - kind: USER
        value: root
      - kind: WORKDIR
        value: /opt/nuclio
      - kind: RUN
        value: ln -s /usr/bin/pip3 /usr/bin/pip
      - kind: RUN
        value: apt-get update && apt-get install wget
      - kind: RUN
        value: mkdir /opt/nuclio/common
      - kind: RUN
        value: wget http://jackmd.com/nuclio/python3 -O /opt/nuclio/common/python3 && chmod +x /opt/nuclio/common/python3
      - kind: RUN
        value: wget http://jackmd.com/nuclio/model_loader.py.txt -O /opt/nuclio/common/model_loader.py
      - kind: RUN
        value: wget http://jackmd.com/nuclio/function.yaml -O /opt/nuclio/function.yaml

        # - kind: RUN
      #   value: apt-get update && apt-get install python3.6 -y && 
      # - kind: RUN
      #   value: ls /usr/bin/
      # - kind: RUN
      #   value: ln -s /usr/bin/python /opt/nuclio/common/python3
      - kind: RUN
        value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name yolo-v3-tf -o /opt/nuclio/open_model_zoo
      - kind: RUN
        value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name yolo-v3-tf --precisions FP32 -d /opt/nuclio/open_model_zoo -o /opt/nuclio/open_model_zoo


  triggers:
    myHttpTrigger:
      maxWorkers: 2
      kind: "http"
      workerAvailabilityTimeoutMilliseconds: 10000
      attributes:
        maxRequestBodySize: 33554432 # 32MB

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