Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Example Object Detection

Deepak Kumar Battini edited this page Nov 13, 2017 · 2 revisions

Object detection using Pascal VOC models

Import namespaces

using SiaNet;
using SiaNet.Application;
using SiaNet.Common;

Select the device CPU or GPU

GlobalParameters.Device = CNTK.DeviceDescriptor.CPUDevice;

Configure logging (Optional step)

Logging.OnWriteLog += Logging_OnWriteLog;

Declare and load models

string imagePath = "path-to-jpeg-or-png-image";
FastRCNN app = new FastRCNN(FastRCNNModel.Pascal);
app.LoadModel();

Run prediction

var predictions = app.Predict(imagePath);
foreach (var item in predictions)
{
   Console.WriteLine("Category: {0}, Score: {1}, Bouding Box: x={2}, y={3}, w={4}, h={5}", item.Name, item.Score, item.BBox.X, item.BBox.Y, item.BBox.Width, item.BBox.Height);
}

For grocery detection, just change the code:

FastRCNN app = new FastRCNN(FastRCNNModel.Grocery100);

Event Functions

private static void Logging_OnWriteLog(string message)
{
    Console.WriteLine("Log: " + message); ;
}