# ============================================================================
# Gst-nvinferserver (gRPC) Configuration for RF-DETR — WITH custom-lib
# DeepStream 9.1 — parses raw dets/labels in-process, attaches obj_meta directly
#
# custom_lib path is image-owned: /opt/contextra/lib/libcontextra_nvinferserver_rfdetr.so
# ============================================================================

infer_config {
  unique_id: 1
  gpu_ids: [0]
  max_batch_size: 1
  backend {
    triton {
      model_name: "RFDETRMedium"
      version: -1
      grpc {
        url: "localhost:8001"
        enable_cuda_buffer_sharing: false
      }
    }
    inputs: [{
      name: "input"
    }]
    outputs: [
      {name: "dets"},
      {name: "labels"}
    ]
    output_mem_type: MEMORY_TYPE_CPU
  }

  preprocess {
    network_format: MEDIA_FORMAT_NONE
    tensor_order: TENSOR_ORDER_LINEAR
    tensor_name: "input"
    maintain_aspect_ratio: 0
    frame_scaling_hw: FRAME_SCALING_HW_DEFAULT
    frame_scaling_filter: 1
    normalize {
      scale_factor: 0.00392156862
      channel_offsets: [0, 0, 0]
    }
  }

  postprocess {
    labelfile_path: ""
    other { }
  }

  # Custom lib that parses RF-DETR raw outputs and attaches NvDsObjectMeta
  custom_lib {
    path: "/opt/contextra/lib/libcontextra_nvinferserver_rfdetr.so"
  }

  extra {
    copy_input_to_host_buffers: false
    output_buffer_pool_size: 2
    custom_process_funcion: "CreateContextraRfDetrProcessor"
  }
}

input_control {
  process_mode: PROCESS_MODE_FULL_FRAME
  operate_on_gie_id: -1
  interval: 0
}

output_control {
  output_tensor_meta: true
}
