0

I am following the cpp tutorial. I have replaced the model with my own and replaces the input and output tensors, here and here. The Model is binding but on evaluation step abruptly aborts.

As far as I know, there is nothing wrong with my code and model. I have tried to change the input image into various sizes and color modes(grayscale and rgb) but nothing works.

Changes made:

int main(int argc, char* argv[])
{
    init_apartment();

    // did they pass in the args 
    if (ParseArgs(argc, argv) == false)
    {
        printf("Usage: %s [imagefile] [cpu|directx]", argv[0]);
        return -1;
    }

    // Get model path
    auto modelPath = GetModelPath();

    // load the model
    printf("Loading modelfile '%ws' on the '%s' device\n", modelPath.c_str(), deviceName.c_str());
    DWORD ticks = GetTickCount();
    auto model = LearningModel::LoadFromFilePath(modelPath);
    ticks = GetTickCount() - ticks;
    printf("model file loaded in %d ticks\n", ticks);

    // load the image
    printf("Loading the image...\n");
    auto imageFrame = LoadImageFile(imagePath);
    // now create a session and binding
    LearningModelSession session(model, LearningModelDevice(deviceKind));//Exception thrown at this line
    LearningModelBinding binding(session);

    // bind the intput image
    printf("Binding...\n");
    binding.Bind(L"conv2d_1_input_01", ImageFeatureValue::CreateFromVideoFrame(imageFrame));
    // temp: bind the output (we don't support unbound outputs yet)
    printf("Now...\n");
    vector<int64_t> shape({ 1, 2 });
    binding.Bind(L"dense_1_Softmax_0", TensorFloat::Create(shape));

    // now run the model
    printf("Running the model...\n");
    ticks = GetTickCount();
    printf("why");
    auto results = session.Evaluate(binding, L"RunId");
    printf("why");
    ticks = GetTickCount() - ticks;
    printf("model run took %d ticks\n", ticks);

    // get the output
    auto resultTensor = results.Outputs().Lookup(L"dense_1_Softmax_0").as<TensorFloat>();
    auto resultVector = resultTensor.GetAsVectorView();
    PrintResults(resultVector);
}

Console output: https://i.stack.imgur.com/fyoau.jpg

Error:

https://i.stack.imgur.com/xytE7.jpg

[Console output in text form]

Loading modelfile 'D:\Projects\Windows-Machine-Learning-master\Samples\SqueezeNetObjectDetection\Desktop\cpp\Debug\wifi3.onnx' on the 'default' device

model file loaded in 531 ticks

Loading the image...

Binding...

Now...

Running the model...

why

Errormsg:

Debug Error!

Program: .../CPP.exe

abort() has been called

Model link: https://www.dropbox.com/s/fudgynpislpsyta/wifi3.onnx?dl=0

Output by Debugger:

Exception thrown at 0x75013442 in SqueezeNetObjectDetectionCPP.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x006FF5C8. occurred

Jodh Singh
  • 11
  • 1
  • If you want people to spend time to help you out, make sure they are not wasting their time by trying to decrypt program scopes. Make sure your indentation follows scoping. The current formatting is an exercise in obfuscation. – IInspectable Sep 02 '19 at 12:45
  • @IInspectable Code formatted properly now? – Jodh Singh Sep 02 '19 at 12:49
  • Nothing in the information provided suggests any sort of abrupt abortion. Please provide the full error description (or whatever you get) in **text**. Also make sure to take the [tour] and read [ask]. – IInspectable Sep 02 '19 at 14:18
  • Thanks for the suggestions @IInspectable. Is it better now? – Jodh Singh Sep 02 '19 at 15:53
  • Run it under a debugger. That'll give you lots of information. C++ won't be much fun, if you don't know how to use a debugger. – IInspectable Sep 02 '19 at 21:32

1 Answers1

0

The code looks good, the problem appears to be with your model. Running under the debugger and looking at the output window shows:

Exception thrown at 0x76950052 (KernelBase.dll) in SqueezeNetObjectDetectionCPP.exe: WinRT originate error - 0x80004005 : 'Non-zero status code returned while running FusedConv node. Name:'fused conv2d_1' Status Message: Input channels C is not equal to kernel channels * group. C: 32 kernel channels: 1 group: 1'.

The error message tells you what nodes in the model are not evaluating.