Exemple #1
0
        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);
                    }
                }
            }
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
                    }
                }
            }
        }
Exemple #4
0
        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);
                    }
                }
            }
        }