Description
I wanted to post process the detections out of custom library
hence i had perprocessed it in this way.
This is my config_infer file
[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
onnx-file=models/yolov8n-seg-psda.onnx
model-engine-file=engine/yolov8n-seg-psda.onnx_b1_gpu0_fp16.engine
gie-unique-id=1
network-type=100
network-mode=2
output-tensor-meta=1
infer-dims=3;640;640
and my function write back the bbox values is below
def add_obj_meta_to_frame(frame_object_data, batch_meta, frame_meta, label_names):
""" Inserts an object into the metadata """
# this is a good place to insert objects into the metadata.
# Here's an example of inserting a single object.
frame_object, masks = frame_object_data
obj_meta = pyds.nvds_acquire_obj_meta_from_pool(batch_meta)
# Set bbox properties. These are in input resolution.alloc mask array deepstream 6.2 in python
rect_params = obj_meta.rect_params
rect_params.left = frame_object.left
rect_params.top = frame_object.top
rect_params.width = frame_object.width
rect_params.height = frame_object.height
mask_param = pyds.NvOSD_MaskParams.cast(obj_meta)
mask_param.width, mask_param.height = masks.shape
allocated_mask_array = mask_param.alloc_mask_array()
del allocated_mask_array
final_mask = np.copyto(allocated_mask_array, masks.flatten())
mask_params.height = frame_object.mask_height
mask_params.size = frame_object.mask_size
mask_params.data = frame_object.mask
# Semi-transparent yellow backgroud
rect_params.has_bg_color = 1
rect_params.bg_color.set(1, 1, 0, 0.4)
# Red border of width 3
rect_params.border_width = 3
rect_params.border_color.set(1, 0, 0, 1)
# Set object info including class, detection confidence, etc.
obj_meta.confidence = frame_object.detectionConfidence
obj_meta.class_id = frame_object.classId
# There is no tracking ID upon detection. The tracker will
# assign an ID.
obj_meta.object_id = UNTRACKED_OBJECT_ID
lbl_id = frame_object.classId
infoLog(f"LabelID: {lbl_id}")
if lbl_id >= len(label_names):
lbl_id = 0
# Set the object classification label.
obj_meta.obj_label = label_names[lbl_id]
# Set display text for the object.
txt_params = obj_meta.text_params
if txt_params.display_text:
pyds.free_buffer(txt_params.display_text)
txt_params.x_offset = int(abs(rect_params.left))
txt_params.y_offset = max(0, int(abs(rect_params.top)) - 10)
txt_params.display_text = (
label_names[lbl_id] + " " + "{:04.3f}".format(frame_object.detectionConfidence)
)
infoLog(f"{rect_params.left}, {rect_params.top}, {rect_params.width}, {rect_params.height}, {obj_meta.object_id}, {obj_meta.obj_label}")
# Font , font-color and font-size
txt_params.font_params.font_name = "Serif"
txt_params.font_params.font_size = 10
# set(red, green, blue, alpha); set to White
txt_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0)
# Text background color
txt_params.set_bg_clr = 1
# set(red, green, blue, alpha); set to Black
txt_params.text_bg_clr.set(0.0, 0.0, 0.0, 1.0)
# Inser the object into current frame meta
# This object has no parent
pyds.nvds_add_obj_meta_to_frame(frame_meta, obj_meta, None)
On doing
allocated_mask_array = mask_param.alloc_mask_array()
del allocated_mask_array
final_mask = np.copyto(allocated_mask_array, masks.flatten())
I am getting segmentation fault core dumped, could you please guide me through.
Environment
TensorRT Version:
GPU Type:
Nvidia Driver Version:
CUDA Version: 12.2
CUDNN Version: 8.6
Operating System + Version: Ubuntu 20.04
Python Version (if applicable): 3.8
PyTorch Version (if applicable): Yolov8
Baremetal or Container (if container which image + tag): nvcr.io/nvidia/deepstream:6.2-devel
Relevant Files
Model:
https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n-seg.pt
Steps To Reproduce
I have used this function altered from the reference deepstream_python_apps/apps/deepstream-ssd-parser/ssd_parser.py at 175d711184f407a42cba7d8ffebf875a126a74f7 · NVIDIA-AI-IOT/deepstream_python_apps · GitHub