static void Main(string[] args) { var usage = @" Usage: Launch a local instance of IRC.SampleRecogServerCSharp.\n\ Command line arguments: \n\ -gateway SERVERURI ServerUri\n\ -rootdir Root_Directory this directory holds logo image and caption script files\n\ -saveimage DIRECTORY Directory where recognized image is saved. Default: current dir \n\ -log LogFile Path to log file \n\ "; List <string> args_list = args.ToList(); args_list.Add("-con"); args = args_list.ToArray(); var parse = new ArgumentParser(args); var usePort = VHubSetting.RegisterServicePort; var saveimagedir = parse.ParseString("-saveimage", Directory.GetCurrentDirectory()); var gatewayServers = parse.ParseStrings("-gateway", new string[] { "vm-hubr.trafficmanager.net" }); var rootdir = parse.ParseString("-rootdir", Directory.GetCurrentDirectory()); var serviceName = "ImageCaptionGenerator"; var bAllParsed = parse.AllParsed(usage); // prepare parameters for registering this recognition instance to vHub gateway var startParam = new VHubBackendStartParam(); /// Add traffic manager gateway, see http://azure.microsoft.com/en-us/services/traffic-manager/, /// Gateway that is added as traffic manager will be repeatedly resovled via DNS resolve foreach (var gatewayServer in gatewayServers) { if (!(StringTools.IsNullOrEmpty(gatewayServer))) { startParam.AddOneTrafficManager(gatewayServer, usePort); } } ; // start a local instance. Console.WriteLine("Local instance started and registered to {0}", gatewayServers[0]); Console.WriteLine("Current working directory: {0}", Directory.GetCurrentDirectory()); Console.WriteLine("Press ENTER to exit"); RemoteInstance.StartLocal(serviceName, startParam, () => new CaptionGenerationInstance(saveimagedir, rootdir)); while (RemoteInstance.IsRunningLocal(serviceName)) { if (Console.KeyAvailable) { var cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.Enter) { Console.WriteLine("ENTER pressed, exiting..."); RemoteInstance.StopLocal(serviceName); } else { System.Threading.Thread.Sleep(10); } } } }
public void Start() { var curDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var usePort = VHubSetting.RegisterServicePort; var savedatadir = Path.Combine(curDir, "savedata"); if (!Directory.Exists(savedatadir)) { Directory.CreateDirectory(savedatadir); } var gatewayServers = new string[] { "vm-hubr.trafficmanager.net" }; var rootdir = Path.Combine(curDir, "Data"); // prepare parameters for registering this recognition instance to vHub gateway var startParam = new VHubBackendStartParam(); /// Add traffic manager gateway, see http://azure.microsoft.com/en-us/services/traffic-manager/, /// Gateway that is added as traffic manager will be repeatedly resovled via DNS resolve foreach (var gatewayServer in gatewayServers) { if (!(StringTools.IsNullOrEmpty(gatewayServer))) { startParam.AddOneTrafficManager(gatewayServer, usePort); } } ; Logger.Log(LogLevel.Info, "Local instance started and registered to " + gatewayServers[0]); Logger.Log(LogLevel.Info, "Current working directory: " + Directory.GetCurrentDirectory()); RemoteInstance.StartLocal(serviceName, startParam, () => new MLLRInstance(savedatadir, rootdir)); }
static void Main(string[] args) { var usage = @" Usage: Launch a local instance of Caffe Host service.\n\ Command line arguments: \n\ -gateway SERVERURI ServerUri\n\ -evalconfig ConfigFile path to config file specifying measurment data and settings\n\ -log LogFile Path to log file\n\ "; List <string> args_list = args.ToList(); args_list.Add("-con"); args = args_list.ToArray(); var parse = new ArgumentParser(args); var usePort = VHubSetting.RegisterServicePort; var gatewayServers = parse.ParseStrings("-gateway", new string[] { "vm-hub.trafficmanager.net" }); var serviceName = "EvaluationServerService"; var configFile = parse.ParseString("-evalconfig", ""); var evalSetting = new EvaluationSetting(configFile); var bAllParsed = parse.AllParsed(usage); // prepare parameters for registering this recognition instance to vHub gateway var startParam = new VHubBackendStartParam(); /// Add traffic manager gateway, see http://azure.microsoft.com/en-us/services/traffic-manager/, /// Gateway that is added as traffic manager will be repeatedly resovled via DNS resolve foreach (var gatewayServer in gatewayServers) { if (!(StringTools.IsNullOrEmpty(gatewayServer))) { startParam.AddOneTrafficManager(gatewayServer, usePort); } } ; // start a local instance. Console.WriteLine("Local instance started and registered to {0}", gatewayServers[0]); Console.WriteLine("Current working directory: {0}", Directory.GetCurrentDirectory()); Console.WriteLine("Press ENTER to exit"); RemoteInstance.StartLocal(serviceName, startParam, () => new EvaluationServerInstance(gatewayServers[0], configFile, evalSetting)); while (RemoteInstance.IsRunningLocal(serviceName)) { if (Console.KeyAvailable) { var cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.Enter) { Console.WriteLine("ENTER pressed, exiting..."); RemoteInstance.StopLocal(serviceName); } else { System.Threading.Thread.Sleep(10); } } } }
static void Main(string[] args) { var usage = @" Usage: Launch an intance of SampleRecogServerFSharp. The application is intended to run on any machine. It will home in to an image recognition hub gateway for service\n\ Command line arguments: \n\ -start Launch a Prajna Recognition service in cluster\n\ -stop Stop existing Prajna Recognition service in cluster\n\ -exe Execute in exe mode \n\ -cluster CLUSTER_NAME Name of the cluster for service launch \n\ -port PORT Port used for service \n\ -node NODE_Name Launch the recognizer on the node of the cluster only (note that the cluster parameter still need to be provided \n\ -rootdir Root_Directory this directories holds DLLs, data model files that need to be remoted for execution\n\ -gateway SERVERURI ServerUri\n\ -only SERVERURI Only register with this server, disregard default. \n\ -saveimage DIRECTORY Directory where recognized image is saved \n\ "; var parse = new ArgumentParser(args); var prajnaClusterFile = parse.ParseString("-cluster", ""); var usePort = parse.ParseInt("-port", VHubSetting.RegisterServicePort); var nodeName = parse.ParseString("-node", ""); var curfname = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; var curdir = Directory.GetParent(curfname).FullName; var upperdir = Directory.GetParent(curdir).FullName; var upper2dir = Directory.GetParent(upperdir).FullName; var defaultRootdir = upper2dir; var rootdir = parse.ParseString("-rootdir", defaultRootdir); var dlldir = parse.ParseString("-dlldir", defaultRootdir); var bStart = parse.ParseBoolean("-start", false); var bStop = parse.ParseBoolean("-stop", false); var bExe = parse.ParseBoolean("-exe", true); var saveImageDirectory = parse.ParseString("-saveimage", @"."); var gatewayServers = parse.ParseStrings("-gateway", new string[] {}); var onlyServers = parse.ParseStrings("-only", new string[] {}); var serviceName = "SampleRecognitionServiceCS"; /// <remark> /// The code below is from PrajnaRecogServer for register multiple classifier (one for each domain) /// You should modify the code to retrieve your own classifiers /// </remark> var bAllParsed = parse.AllParsed(usage); if (bAllParsed) { Cluster.StartCluster(prajnaClusterFile); if (!(StringTools.IsNullOrEmpty(nodeName))) { var cluster = Cluster.GetCurrent().GetSingleNodeCluster(nodeName); if (Object.ReferenceEquals(cluster, null)) { throw new Exception("Can't find node in cluster"); } else { Cluster.SetCurrent(cluster); } } } if (bExe) { JobDependencies.DefaultTypeOfJobMask = JobTaskKind.ApplicationMask; } var curJob = JobDependencies.setCurrentJob("SampleRecogServerCSharp"); if (bStart) { // add other file dependencies // allow mapping local to different location in remote in case user specifies different model files var exeName = System.Reflection.Assembly.GetExecutingAssembly().Location; var exePath = Path.GetDirectoryName(exeName); /// If you need to change the current directory at remote, uncomment and set the following variable the following // curJob.EnvVars.Add(DeploymentSettings.EnvStringSetJobDirectory, "." ) /// All data files are placed under rootdir locally, and will be placed at root (relative directory at remote ). var dirAtRemote = curJob.AddDataDirectoryWithPrefix(null, rootdir, "root", "*", SearchOption.AllDirectories); /// Add all var dlls = curJob.AddDataDirectory(dlldir, "*", SearchOption.AllDirectories); var managedDlls = curJob.AddDataDirectoryWithPrefix(null, exePath, "dependencies", "*", SearchOption.AllDirectories); var startParam = new SampleRecogInstanceCSharpParam { SaveImageDirectory = saveImageDirectory }; /// Add traffic manager gateway, see http://azure.microsoft.com/en-us/services/traffic-manager/, /// Gateway that is added as traffic manager will be repeatedly resovled via DNS resolve foreach (var gatewayServer in gatewayServers) { if (!(StringTools.IsNullOrEmpty(gatewayServer))) { startParam.AddOneTrafficManager(gatewayServer, usePort); } } ; /// Add simple gateway, no repeated DNS service. foreach (var onlyServer in onlyServers) { if (!(StringTools.IsNullOrEmpty(onlyServer))) { startParam.AddOneServer(onlyServer, usePort); } } var curCluster = Cluster.GetCurrent(); if (Object.ReferenceEquals(curCluster, null)) { // If no cluster parameter, start a local instance. RemoteInstance.StartLocal(serviceName, startParam, SampleRecogInstanceCSharpParam.ConstructSampleRecogInstanceCSharp); while (RemoteInstance.IsRunningLocal(serviceName)) { if (Console.KeyAvailable) { var cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.Enter) { RemoteInstance.StopLocal(serviceName); } else { System.Threading.Thread.Sleep(10); } } } } else { // If there is cluster parameter, start remote recognition cluster. RemoteInstance.Start(serviceName, startParam, SampleRecogInstanceCSharpParam.ConstructSampleRecogInstanceCSharp); } } else if (bStop) { RemoteInstance.Stop(serviceName); } }
static void Main(string[] args) { var usage = @" Usage: Launch a local instance of Caffe Host service.\n\ Command line arguments: \n\ -gateway SERVERURI ServerUri\n\ -recogname RecogName Recognizer Name\n\ -model ModelFile Path to model config file, including proto, model, mean, labelmap, entity_info files\n\ -topk TopK Top K result to return (default: 5)\n\ -thresh Confidence Confidence threshold (default: 0.9)\n\ -gpu gpu_id Gpu id (default: 0 for gpu 0), -1 for CPU only\n\ -log LogFile Path to log file\n\ "; List <string> args_list = args.ToList(); args_list.Add("-con"); args = args_list.ToArray(); var parse = new ArgumentParser(args); var usePort = VHubSetting.RegisterServicePort; var gatewayServers = parse.ParseStrings("-gateway", new string[] { "vm-hubr.trafficmanager.net" }); var serviceName = "CaffeHostService"; var cmd = new CmdArgs(); cmd.recoginzerName = parse.ParseString("-recogName", "CaffeHost"); cmd.modelCfgFile = parse.ParseString("-model", ""); cmd.topK = parse.ParseInt("-topk", 5); cmd.confThreshold = (float)parse.ParseFloat("-thresh", 0.9); cmd.gpu = parse.ParseInt("-gpu", 0); var rootdir = Path.GetDirectoryName(cmd.modelCfgFile); var bAllParsed = parse.AllParsed(usage); CaffePredictor predictor = new CaffePredictor(); // prepare parameters for registering this recognition instance to vHub gateway var startParam = new VHubBackendStartParam(); /// Add traffic manager gateway, see http://azure.microsoft.com/en-us/services/traffic-manager/, /// Gateway that is added as traffic manager will be repeatedly resovled via DNS resolve foreach (var gatewayServer in gatewayServers) { if (!(StringTools.IsNullOrEmpty(gatewayServer))) { startParam.AddOneTrafficManager(gatewayServer, usePort); } } ; // start a local instance. Console.WriteLine("Local instance started and registered to {0}", gatewayServers[0]); Console.WriteLine("Current working directory: {0}", Directory.GetCurrentDirectory()); Console.WriteLine("Press ENTER to exit"); RemoteInstance.StartLocal(serviceName, startParam, () => new CaffeHostInstance(cmd)); while (RemoteInstance.IsRunningLocal(serviceName)) { if (Console.KeyAvailable) { var cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.Enter) { Console.WriteLine("ENTER pressed, exiting..."); RemoteInstance.StopLocal(serviceName); } else { System.Threading.Thread.Sleep(10); } } } }