f850d36092 | ||
---|---|---|
.. | ||
Labels.txt | ||
README.md | ||
SqueezeNetObjectDetectionCPP.vcxproj | ||
SqueezeNetObjectDetectionCPP.vcxproj.filters | ||
main.cpp | ||
packages.config | ||
pch.cpp | ||
pch.h |
README.md
SqueezeNet Object Detection sample
This is a desktop application that uses SqueezeNet, a pre-trained machine learning model, to detect the predominant object in an image selected by the user from a file.
Note: SqueezeNet was trained to work with image sizes of 224x224, so you must provide an image of size 224X224.
Prerequisites
-
Visual Studio Extension for C++/WinRT
Do the following to add the C++/WinRT extension in Visual Studio.
- Go to Tools > Extensions and Updates.
- Select Online in the left pane and search for "WinRT" using the search box.
- Select the C++/WinRT extension, click Download, and close Visual Studio. The extension should install automatically.
- When the extension has finished installing, re-open Visual Studio.
Build the sample
- If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
- Start Microsoft Visual Studio 2017 and select File > Open > Project/Solution.
- Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample (SqueezeNetObjectDetection\Desktop\cpp). Double-click the Visual Studio solution file (.sln).
- Confirm that the project is pointed to the correct SDK that you installed (e.g. 17763). You can do this by right-clicking the project in the Solution Explorer, selecting Properties, and modifying the Windows SDK Version.
- Confirm that you are set for the right configuration and platform (for example: Debug, x64).
- Build the solution (Ctrl+Shift+B).
Run the sample
- Open a Command Prompt (in the Windows 10 search bar, type cmd and press Enter).
- Change the current folder to the folder containing the built EXE (
cd <path-to-exe>
). - Run the executable as shown below. Make sure to replace the install location with what matches yours:
SqueezeNetObjectDetection.exe C:\Repos\Windows-Machine-Learning\SharedContent\media\kitten_224.png
- You should get output similar to the following:
Loading modelfile 'C:\Repos\Windows-Machine-Learning\SharedContent\models\SqueezeNet.onnx' on the 'default' device
model file loaded in 421 ticks
Loading the image...
Binding...
Running the model...
model run took 31 ticks
tabby, tabby cat with confidence of 0.931461
Egyptian cat with confidence of 0.065307
tiger cat with confidence of 0.002927
License
MIT. See LICENSE file.