# Breaking Changes to the API

As Red Analyze High Detail mode and Loss Inspector are added in VisionPro Deep Learning 1.1.0, there are some changes to API as well.

### C/C++ API

Major changes of C/C++ API include access to and interaction with Red Analyze High Detail mode and Loss Inspector.

Copy

Red Analyze High Detail

    1
    2
    3
    4
    5
    6
    7

    ...
    // Red HD mode
    std::stringstream param_ss;
    param_ss << "workspaces/" << workspace_name << "/streams/" << stream_name << "/tools/" << tool_name << "/tool_type";
    status = vidi_training_set_parameter(param_ss.str().c_str(), "red_sua");
    ...

Copy

Loss Graph

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    ...
    // Get lossgraph data
    status = vidi_training_get_loss_graph_data(workspace_name, stream_name, tool_name, true, 0, &lossgraph_buffer);
    CHECK_STATUS(status);

    rapidxml::xml_document<> doc;
    doc.parse<0>(lossgraph_buffer.data);

    rapidxml::xml_node<>* lossgraph_node = doc.first_node("loss_graph_data");
    assert(lossgraph_node);

    // check if it has "data" node
    if (lossgraph_node->first_node("data") == nullptr)
        break;

    rapidxml::xml_node<>* last_node = lossgraph_node->last_node("data");
    assert(last_node);

    rapidxml::xml_attribute<>* elapsedEpoch = last_node->first_attribute("current_epoch");
    rapidxml::xml_attribute<>* bestEpoch = last_node->first_attribute("min_epoch");
    rapidxml::xml_attribute<>* elapsedLoss = last_node->first_attribute("current_loss");
    rapidxml::xml_attribute<>* bestLoss = last_node->first_attribute("min_loss");
    ...

Please refer to Examples (C:\ProgramData\Cognex\VisionPro Dee Learning\1.1\Examples\c++\Example.Training.HDRed, Example.Training.HDGreen) for the details of usage.

Please refer to C/C++ API document (C:\Program Files\Cognex\VisionPro Deep Learning\Cognex\VisionPro Deep Learning\1.1\Develop\docs) for the details of APIs.

Header File | API | Description
--- | --- | ---
vidi_tranining.h | vidi_training_clear_backup_loss_graph_data function | Clear the backed up loss graph data for the High Detail Mode Tool
vidi_tranining.h | vidi_training_get_loss_graph_data function | Get the loss graph data for the High Detail Mode Tool
vidi_tranining.h | vidi_training_restore_loss_graph_data function | Restore the backed up loss graph data for the High Detail Mode Tool

### .NET API

Major changes of .NET API include access to and interaction with Red Analyze High Detail mode and Loss Inspector.

Copy

Red Analyze High Detail

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ...

    // creates a new workspace
        var workspace = control.Workspaces.Add("workspace");

        //creates a stream
        var stream = workspace.Streams.Add("default");

        //creates a red tool at the root of the toolchain
        var hdRedTool = stream.Tools.Add("red_HDM", ToolType.Red) as IRedTool;

    ...

Copy

Loss Graph

    1
    2
    3
    4
    5
    6
    7
    8
    ...

    // 1. Get loss graph data using GetLossGraphData method
        var lossGraph = hdRedTool.GetLossGraphData(true);
        if (lossGraph.Count() != 0)
            System.Console.WriteLine($"{lossGraph.Last().CurrentEpoch,15} {lossGraph.Last().MinEpoch,15} {lossGraph.Last().CurrentLoss,15} {lossGraph.Last().MinLoss,15} {" ",15}");

    ...

Please refer to Examples (C:\ProgramData\Cognex\VisionPro Dee Learning\1.1\Examples\c#\Example.Training.HDRed.Console, Example.Training.HDRed.Console) for the details of usage.

Please refer to .NET API document (C:\Program Files\Cognex\VisionPro Deep Learning\Cognex\VisionPro Deep Learning\1.1\Develop\docs) for the details of APIs.

Assembly | Namespace | Interface, Member, or API | Description
--- | --- | --- | ---
ViDi.NET.Interfaces | ViDi2.Runtime / ViDi2.Training | IRedHighDetailParameters | Runtime parameters for high-detail red tool
ViDi.NET.Interfaces | ViDi2.Training | ILibraryAccess.ClearBackupLossGraphData Method | Clear the backed up loss graph data for the High Detail Mode Tool
ViDi.NET.Interfaces | ViDi2.Training | ILibraryAccess.GetLossGraphData Method | Get loss graph data for High-detail red/green tool
ViDi.NET.Interfaces | ViDi2.Training | ILibraryAccess.RestoreLossGraphData Method | Restore backed up loss graph data for High Detail Mode tool