public void InitilizeDeepLearningNetwork(int gpu = 0) { if (m_NetConf == null) { m_NetConf = new NetConfigaration(); } InitializeNetInGpu(m_NetConf.ConfigFile, m_NetConf.Weightfile); DetectionHardware = DetectionHardwares.GPU; var lines = File.ReadAllLines(m_NetConf.NamesFile); for (var i = 0; i < lines.Length; i++) { m_ObjectType.Add(i, lines[i]); } }
public void InitilizeDeepLearningNetwork(int gpu = 0) { if (m_NetConf == null) { m_NetConf = new NetConfigaration(); } HardwareReport = new HardwareReports(); DetectionHardware = DetectionHardwares.CPU; if (HardwareReport.IsCudaExists && HardwareReport.IsCudnnExists) { DetectionHardware = DetectionHardwares.GPU; } switch (DetectionHardware) { case DetectionHardwares.CPU: InitializeNetInCpu(m_NetConf.ConfigFile, m_NetConf.Weightfile, 0); break; case DetectionHardwares.GPU: var deviceCount = GetDeviceCount(); if (gpu > (deviceCount - 1)) { throw new IndexOutOfRangeException("Graphic device index is out of range"); } var deviceName = new StringBuilder(); GetDeviceName(gpu, deviceName); HardwareReport.GraphicDeviceName = deviceName.ToString(); InitializeNetInGpu(m_NetConf.ConfigFile, m_NetConf.Weightfile, gpu); break; default: break; } var lines = File.ReadAllLines(m_NetConf.NamesFile); for (var i = 0; i < lines.Length; i++) { m_ObjectType.Add(i, lines[i]); } }