Deepstream test add yolov7 model can not load the model

I use yolov7.pt convert to the onnx , in orin device use trtexec to onnx file to weight, add to deepsteam test3 , run , show can not load the model , why

**• Hardware Platform Jetson
**• DeepStream Version 6.1
**• JetPack Version (valid for Jetson only) 5.01

Could you attach your log to us?


use this mothed How to run YOLOv7 on Deepstream - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums

Some config parameters in your config file are inconsistent with the actual parameters of your model. Could you use the onnx model that we provided?
https://github.com/NVIDIA-AI-IOT/yolo_deepstream

when i use one source is ok , can run
but i add multiple sources, tips

but i add yolov4 engina use multiple sources is good

From the log attached, there may be some problems in your config file. Please confirm the model config file is under the corresponding path.

use this config file

[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
model-color-format=0
model-engine-file=yolov7-tiny.onnx_b1_gpu0_fp16.engine
#model-engine-file=yolov7_tinytest.engine
#model-onnx-file=yolov7-tiny.onnx
labelfile-path=labels.txt
force-implicit-batch-dim=1
batch-size=2
process-mode=1
model-color-format=0
network-mode=2
num-detected-classes=80
interval=0
gie-unique-id=1
parse-bbox-func-name=NvDsInferParseCustomEfficientNMS
custom-lib-path=libnvds_infercustomparser.so

[class-attrs-all]
nms-iou-threshold=0.45
pre-cluster-threshold=0.25
topk=300

[tracker]
enable=0
tracker-width=640
tracker-height=384
ll-lib-file=/opt/nvidia/deepstream/deepstream-6.1/lib/libnvds_nvmultiobjecttracker.so
gpu-id=0
enable-batch-process=1
enable-past-frame=1
display-tracking-id=1
ll-config-file=/opt/nvidia/deepstream/deepstream-6.1/samples/configs/deepstream-app/config_tracker_IOU.yml

1.The filed is onnx-file not model-onnx-file. Please refer to our Guide:
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvinfer.html#id2
2.model-engine-file=yolov7-tiny.onnx_b1_gpu0_fp16.engine. Does this engine file exists and is it generated in your enviroment? If it generated in your enviroment, it should not report such error.

yolov7-tiny.onnx_b1_gpu0_fp16.engine file is exit , i use one source is ok , can run


when I add two sources ,have the error

It’s weird. This error is that the model cannot be found. It has nothing to do with the number of sources. How do you change 1 source to 2 sources? Could you attach your source code?

please look, Basically, it’s a modified deepstream-test3

int main (int argc, char *argv[])
{
    GMainLoop *loop = NULL;
    GstElement *pipeline = NULL, *streammux = NULL, *sink = NULL, *pgie = NULL,
            *queue1, *queue2, *queue3, *queue4, *queue5, *queue6, *nvvidconv = NULL,
            *nvosd = NULL, *tiler = NULL, *nvtracker = NULL;
    GstElement *transform = NULL;

    GstPad *osd_sink_pad = NULL;

    GstBus *bus = NULL;
    guint bus_watch_id;
    GstPad *tiler_src_pad = NULL;
    guint i, num_sources;
    guint tiler_rows, tiler_columns;
    guint pgie_batch_size;


    /* Check input arguments */
    DLOGFL()<<"argc"<<argc;
    if (argc < 2) {
        g_printerr ("Usage: %s <uri1> [uri2] ... [uriN] \n", argv[0]);
        return -1;
    }
    num_sources = argc - 1;

    /* Standard GStreamer initialization */
    gst_init (&argc, &argv);
    loop = g_main_loop_new (NULL, FALSE);

    /* Create gstreamer elements */
    /* Create Pipeline element that will form a connection of other elements */
    pipeline = gst_pipeline_new ("dstest3-pipeline");

    /* Create nvstreammux instance to form batches from one or more sources. */
    streammux = gst_element_factory_make ("nvstreammux", "stream-muxer");

    if (!pipeline || !streammux) {
        g_printerr ("One element could not be created. Exiting.\n");
        return -1;
    }
    g_object_set (G_OBJECT (streammux), "live-source", 1, NULL);

    gst_bin_add (GST_BIN (pipeline), streammux);

    for (i = 0; i < num_sources; i++) {
        GstPad *sinkpad, *srcpad;
        gchar pad_name[16] = { };
        GstElement *source_bin = create_source_bin (i, argv[i + 1]);
        if (!source_bin) {
            g_printerr ("Failed to create source bin. Exiting.\n");
            return -1;
        }
        gst_bin_add (GST_BIN (pipeline), source_bin);

        g_snprintf (pad_name, 15, "sink_%u", i);
        sinkpad = gst_element_get_request_pad (streammux, pad_name);
        if (!sinkpad) {
            g_printerr ("Streammux request sink pad failed. Exiting.\n");
            return -1;
        }

        srcpad = gst_element_get_static_pad (source_bin, "src");
        if (!srcpad) {
            g_printerr ("Failed to get src pad of source bin. Exiting.\n");
            return -1;
        }

        if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) {
            g_printerr ("Failed to link source bin to stream muxer. Exiting.\n");
            return -1;
        }

        gst_object_unref (srcpad);
        gst_object_unref (sinkpad);
    }

    /* Use nvinfer to infer on batched frame. */
    pgie = gst_element_factory_make ("nvinfer", "primary-nvinference-engine");

    /* We need to have a tracker to track the identified objects */
    nvtracker = gst_element_factory_make("nvtracker", "tracker");

    /* Add queue elements between every two elements */
    queue1 = gst_element_factory_make ("queue", "queue1");
    queue2 = gst_element_factory_make ("queue", "queue2");
    queue3 = gst_element_factory_make ("queue", "queue3");
    queue4 = gst_element_factory_make ("queue", "queue4");
    queue5 = gst_element_factory_make ("queue", "queue5");
    queue6 = gst_element_factory_make ("queue", "queue6");


    // Use nvtiler to composite the batched frames into a 2D tiled array based on the source of the frames. 
    tiler = gst_element_factory_make ("nvmultistreamtiler", "nvtiler");

    /* Use convertor to convert from NV12 to RGBA as required by nvosd */
    nvvidconv = gst_element_factory_make ("nvvideoconvert", "nvvideo-converter");

    /* Create OSD to draw on the converted RGBA buffer */
    nvosd = gst_element_factory_make ("nvdsosd", "nv-onscreendisplay");

    /* Finally render the osd output */

    transform = gst_element_factory_make ("nvegltransform", "nvegl-transform");

    sink = gst_element_factory_make ("nveglglessink", "nvvideo-renderer");

    if (!pgie || !nvtracker || !tiler || !nvvidconv || !nvosd || !sink) {
        g_printerr ("One element could not be created. Exiting.\n");
        return -1;
    }

    //if(!transform && prop.integrated) {
    //    g_printerr ("One tegra element could not be created. Exiting.\n");
    //    return -1;
    //}

    g_object_set (G_OBJECT (streammux), "batch-size", num_sources, NULL);
    DLOGFL()<<"streammux batch-size"<<num_sources;

    g_object_set (G_OBJECT (streammux), "width", MUXER_OUTPUT_WIDTH, "height",
                  MUXER_OUTPUT_HEIGHT,
                  "batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC, NULL);

    //give seek 
    g_object_set (G_OBJECT (sink), "sync", 0, NULL);
    /* Configure the nvinfer element using the nvinfer config file. */
    g_object_set (G_OBJECT (pgie),
                  "config-file-path", "dstest3_pgie_config.txt", NULL);

    /* Override the batch-size set in the config file with the number of sources. */
    g_object_get (G_OBJECT (pgie), "batch-size", &pgie_batch_size, NULL);
    DLOGFL()<<"pgie_batch_size"<<pgie_batch_size;
    if (pgie_batch_size != num_sources) {
        g_printerr
                ("WARNING: Overriding infer-config batch-size (%d) with number of sources (%d)\n",
                 pgie_batch_size, num_sources);
        g_object_set (G_OBJECT (pgie), "batch-size", num_sources, NULL);
    }

    tiler_rows = (guint) sqrt (num_sources);
    tiler_columns = (guint) ceil (1.0 * num_sources / tiler_rows);
    /* we set the tiler properties here */
    g_object_set (G_OBJECT (tiler), "rows", tiler_rows, "columns", tiler_columns,
                  "width", TILED_OUTPUT_WIDTH, "height", TILED_OUTPUT_HEIGHT, NULL);

    
    g_object_set (G_OBJECT (nvosd), "process-mode", OSD_PROCESS_MODE,
                  "display-text", OSD_DISPLAY_TEXT, NULL);

    g_object_set (G_OBJECT (sink), "qos", 0, NULL);

    /* Set necessary properties of the tracker element. */
    if (!set_tracker_properties(nvtracker))
    {
        g_printerr("Failed to set tracker properties. Exiting.\n");
        return -1;
    }

    /* we add a message handler */
    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
    gst_object_unref (bus);

    /* Set up the pipeline */
    /* we add all elements into the pipeline */

    //gst_bin_add_many (GST_BIN (pipeline), queue1, pgie, queue2, nvtracker, tiler,
    //                  nvvidconv, nvosd, transform, sink, NULL);
    gst_bin_add_many (GST_BIN (pipeline), queue1, pgie, queue2/*, nvtracker*/, tiler,
                      nvvidconv, nvosd, transform, sink, NULL);
    /* we link the elements together
    * nvstreammux -> nvinfer -> nvtiler -> nvvidconv -> nvosd -> video-renderer */
    /*if (!gst_element_link_many (streammux, queue1, pgie, queue2, nvtracker, tiler,
                                nvvidconv, nvosd, transform, sink, NULL)) {
        g_printerr ("Elements could not be linked. Exiting.\n");
        return -1;
    }*/
    if (!gst_element_link_many (streammux, queue1, pgie, queue2/*, nvtracker*/, tiler,
                                nvvidconv, nvosd, transform, sink, NULL)) {
        g_printerr ("Elements could not be linked. Exiting.\n");
        return -1;
    }


    /* Lets add probe to get informed of the meta data generated, we add probe to
   * the sink pad of the osd element, since by that time, the buffer would have
   * had got all the metadata. */
    /*tiler_src_pad = gst_element_get_static_pad (pgie, "src");
    if (!tiler_src_pad)
        g_print ("Unable to get src pad\n");
    else
        gst_pad_add_probe (tiler_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
                           tiler_src_pad_buffer_probe, NULL, NULL);
    gst_object_unref (tiler_src_pad);*/

    osd_sink_pad = gst_element_get_static_pad(nvosd, "sink");
    if (!osd_sink_pad)
        g_print("Unable to get sink pad\n");
    else
        gst_pad_add_probe(osd_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
                          osd_sink_pad_buffer_probe, NULL, NULL);
    gst_object_unref(osd_sink_pad);

    /* Set the pipeline to "playing" state */
    g_print ("Now playing:");
    for (i = 0; i < num_sources; i++) {
        g_print (" %s,", argv[i + 1]);
    }
    g_print ("\n");
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

    /* Wait till pipeline encounters an error or EOS */
    g_print ("Running...\n");
    g_main_loop_run (loop);

    /* Out of the main loop, clean up nicely */
    g_print ("Returned, stopping playback\n");
    gst_element_set_state (pipeline, GST_STATE_NULL);
    g_print ("Deleting pipeline\n");
    gst_object_unref (GST_OBJECT (pipeline));
    g_source_remove (bus_watch_id);
    g_main_loop_unref (loop);
    close(socket_fd);
    return 0;
}

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

Could you attach your config file too? Also, if you use yolov7, I suggest you refer to the link below:
https://github.com/NVIDIA-AI-IOT/yolo_deepstream

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.