Ejemplo n.º 1
0
            public LayerWrapper CreateLayerFromSeed(string chainName, LayerInfo info, int layerIndex)
            {
                Layer  toAdd     = CopyLayer(Seed);
                string buildDate = GetLayerBuildDate(LayerDllLocation);

                try
                {
                    Dictionary <string, object> parameters = info.Parameters;
                    string          intentFilename         = chainName + "_" + info.Name + "_" + layerIndex;
                    IRuntimeStorage intent = RuntimeStorage.FromCouchDb(intentFilename);
                    parameters.Add("intent", intent);
                    parameters.Add("shared", sharedLayerData);
                    toAdd.Init(parameters);
                    IEnumerable <string> libnames = toAdd.AnnotationLibraries();


                    LayerWrapper wrapper = new LayerWrapper(toAdd, parameters, intent, buildDate);
                    return(wrapper);
                }
                catch (IOException e)
                {
                    Console.WriteLine("Could not load layer: " + info.Name);
                    Console.WriteLine("Error Message: " + e.Message);
                    Console.WriteLine("Stack Trace: " + e.StackTrace);
                    return(null);
                }
            }
Ejemplo n.º 2
0
 public void Init(Dictionary<string, object> parameters)
 {
     if (parameters.ContainsKey("library"))
     {
         _annotationLibrary = parameters["library"].ToString();
         _runtimeIntent = parameters["intent"] as IRuntimeStorage;
     }
 }
Ejemplo n.º 3
0
 public void Init(Dictionary <string, object> parameters)
 {
     if (parameters.ContainsKey("library"))
     {
         _annotationLibrary = parameters["library"].ToString();
         _runtimeIntent     = parameters["intent"] as IRuntimeStorage;
     }
 }
Ejemplo n.º 4
0
 public RuntimeController(IRuntimeStorage runtime,
                          IActionDispatcher dispatcher,
                          IGrainFactory factory,
                          ILogger <RuntimeController> logger)
 {
     this.runtime    = runtime;
     this.dispatcher = dispatcher;
     this.factory    = factory;
     this.logger     = logger;
 }
Ejemplo n.º 5
0
		public LayerWrapper (Layer layer, 
			Dictionary<string,object> parameters,
			IRuntimeStorage intent,
			string id)
		{
			this.Layer = layer;
			this.Id = id;
			this.Intent = intent;
			this.Parameters = parameters;
		}
Ejemplo n.º 6
0
 public LayerWrapper(Layer layer,
                     Dictionary <string, object> parameters,
                     IRuntimeStorage intent,
                     string id)
 {
     this.Layer      = layer;
     this.Id         = id;
     this.Intent     = intent;
     this.Parameters = parameters;
 }
Ejemplo n.º 7
0
        private static void SetConfigId(List <LayerWrapper> layers, int layerIndex)
        {
            LayerWrapper    layer    = layers[layerIndex];
            string          configid = LayerChain.ConfigurationId(layers, layerIndex);
            IRuntimeStorage intent   = layer.Intent;

            JObject jobj = new JObject();

            jobj["id"] = configid;
            intent.PutData("config", jobj);
        }
Ejemplo n.º 8
0
        public void UpdateLogic()
        {
            AnnotationUpdateUtility.UpdateInvalidatedLayers(_layers);
            Storage = RuntimeStorage.FromCouchDb("prefab_single_layer");
            var args = new ProcessAnnotationArgs(Storage, GetPtypes());

            if (File.Exists(_singleLayerName))
            {
                _interpreter = LoadSingleLayer(_singleLayerName);
                _interpreter.ProcessAnnotations(args);
            }
        }
Ejemplo n.º 9
0
        public List <Ptype> LoadPtypes(IRuntimeStorage intent)
        {
            this.intent = intent;
            ptypeData   = LoadPtypesFromIntent();

            List <Ptype.Mutable> ptypes = new List <Ptype.Mutable>();

            foreach (PtypeMetadata data in ptypeData.Values)
            {
                ptypes.Add(data.Ptype);
            }

            return(Ptype.CreatePrototypeLibrary(ptypes));
        }
Ejemplo n.º 10
0
        private void SavePtypesToIntent(IRuntimeStorage intent, IEnumerable <PtypeMetadata> ptypeData)
        {
            JArray array = new JArray();

            foreach (PtypeMetadata data in ptypeData)
            {
                JObject item = new JObject();

                item.Add("id", data.Ptype.Id);
                item.Add("model", data.Ptype.Model);

                JArray features = new JArray();
                JArray regions  = new JArray();

                AddFeaturesToJArray(features, data);
                AddRegionsToJArray(regions, data);

                item.Add("features", features);
                item.Add("regions", regions);

                JArray examples = new JArray();
                foreach (Example e in data.Examples)
                {
                    JObject ejson = new JObject();
                    ejson.Add("imageId", e.ImageId);
                    ejson.Add("positive", e.IsPositive);

                    JObject region = new JObject();
                    region.Add("top", e.Region.Top);
                    region.Add("left", e.Region.Left);
                    region.Add("width", e.Region.Width);
                    region.Add("height", e.Region.Height);

                    ejson.Add("region", region);

                    examples.Add(ejson);
                }

                item.Add("examples", examples);
                array.Add(item);
            }


            intent.PutData(INTENT_PTYPES, array);
        }
		private void SavePtypesToIntent(IRuntimeStorage intent, IEnumerable<PtypeMetadata> ptypeData){
			JArray array = new JArray();
			foreach(PtypeMetadata data in ptypeData){

				JObject item = new JObject();

				item.Add("id", data.Ptype.Id);
				item.Add("model", data.Ptype.Model);

				JArray features = new JArray();
				JArray regions = new JArray();

				AddFeaturesToJArray(features, data);
				AddRegionsToJArray(regions, data);

				item.Add("features", features);
				item.Add("regions", regions);
                
				JArray examples = new JArray();
				foreach(Example e in data.Examples){
					JObject ejson = new JObject();
					ejson.Add("imageId", e.ImageId);
					ejson.Add("positive", e.IsPositive);

					JObject region = new JObject();
					region.Add("top", e.Region.Top);
					region.Add("left", e.Region.Left);
					region.Add("width", e.Region.Width);
					region.Add("height", e.Region.Height);

					ejson.Add("region", region);

					examples.Add(ejson);
				}

				item.Add("examples", examples);
				array.Add(item);
			}
            
			
			intent.PutData(INTENT_PTYPES , array);
		}
Ejemplo n.º 12
0
		public void Init(Dictionary<string, object> parameters) {

			intent = (IRuntimeStorage)parameters["intent"];

			shared = (Dictionary<string,object>)parameters["shared"];
			libraries = new List<string>();
			if(parameters.ContainsKey("library"))
				libraries.Add(  (string)parameters["library"] );


			try{
				ptypeUtil = new PtypeSerializationUtility();
				List<Ptype> lib = ptypeUtil.LoadPtypes(intent);
                shared[SHARED_PTYPES_KEY] = lib;

				this.featureTree = FeatureTree.FeatureTree.BuildTree(GetFeatures(lib));
			}catch(Exception e){
				Console.Error.WriteLine(e.StackTrace);
			}
		}
Ejemplo n.º 13
0
        public void Init(Dictionary <string, object> parameters)
        {
            intent = (IRuntimeStorage)parameters["intent"];

            shared    = (Dictionary <string, object>)parameters["shared"];
            libraries = new List <string>();
            if (parameters.ContainsKey("library"))
            {
                libraries.Add((string)parameters["library"]);
            }


            try{
                ptypeUtil = new PtypeSerializationUtility();
                List <Ptype> lib = ptypeUtil.LoadPtypes(intent);
                shared[SHARED_PTYPES_KEY] = lib;

                this.featureTree = FeatureTree.FeatureTree.BuildTree(GetFeatures(lib));
            }catch (Exception e) {
                Console.Error.WriteLine(e.StackTrace);
            }
        }
Ejemplo n.º 14
0
 public ProcessAnnotationArgs(IRuntimeStorage intent, IEnumerable <Ptype> ptypes)
 {
     RuntimeStorage = intent;
     Prototypes     = ptypes;
 }
Ejemplo n.º 15
0
 public PrefabSingleInterpretArgs(MutableTree tree, IRuntimeStorage runtimeStorage)
 {
     Tree = tree;
     RuntimeStorage = new PythonRuntimeStorageWrapper(runtimeStorage);
 }
Ejemplo n.º 16
0
		public InterpretArgs (Tree tree, Tree.BatchTransform updater, IRuntimeStorage runtimeStorage)
		{
			this._updater = updater;
			Tree = tree;
            RuntimeStorage = runtimeStorage;
		}
Ejemplo n.º 17
0
 public DashboardController(IRuntimeStorage runtime, IConfigurationStorage configuration, IGrainFactory factory)
 {
     this.runtime       = runtime;
     this.configuration = configuration;
     this.factory       = factory;
 }
Ejemplo n.º 18
0
 public AnnotationArgs(List<AnnotatedNode> nodes, IRuntimeStorage runtimeStorage)
 {
     this.AnnotatedNodes = nodes;
     this.RuntimeStorage = runtimeStorage;
 }
Ejemplo n.º 19
0
 public DeleteCommand(RuntimeStorageBrowser window, GridItem item,IRuntimeStorage intent)
 {
     _item = item;
     _window = window;
     _intent = intent;
 }
Ejemplo n.º 20
0
 public AnnotationArgs(List <AnnotatedNode> nodes, IRuntimeStorage runtimeStorage)
 {
     this.AnnotatedNodes = nodes;
     this.RuntimeStorage = runtimeStorage;
 }
        public PythonRuntimeStorageWrapper(IRuntimeStorage storage)
        {

            RuntimeStorage = storage;
            
        }
Ejemplo n.º 22
0
 public PrefabSingleInterpretArgs(MutableTree tree, IRuntimeStorage runtimeStorage)
 {
     Tree           = tree;
     RuntimeStorage = new PythonRuntimeStorageWrapper(runtimeStorage);
 }
Ejemplo n.º 23
0
 public PythonRuntimeStorageWrapper(IRuntimeStorage storage)
 {
     RuntimeStorage = storage;
 }
		public List<Ptype> LoadPtypes(IRuntimeStorage intent)
        {
			this.intent = intent;
			ptypeData = LoadPtypesFromIntent();

			List<Ptype.Mutable> ptypes = new List<Ptype.Mutable>();
			foreach(PtypeMetadata data in ptypeData.Values)
				ptypes.Add(data.Ptype);

			return Ptype.CreatePrototypeLibrary(ptypes);
		}
Ejemplo n.º 25
0
 public ProcessAnnotationArgs(IRuntimeStorage intent, IEnumerable<Ptype> ptypes)
 {
     RuntimeStorage = intent;
     Prototypes = ptypes;
 }
Ejemplo n.º 26
0
        public void UpdateLogic()
        {
            AnnotationUpdateUtility.UpdateInvalidatedLayers(_layers);
            Storage = RuntimeStorage.FromCouchDb("prefab_single_layer");
            var args = new ProcessAnnotationArgs(Storage, GetPtypes());

            if (File.Exists(_singleLayerName))
            {
                _interpreter = LoadSingleLayer(_singleLayerName);
                _interpreter.ProcessAnnotations(args);
            }
        }
Ejemplo n.º 27
0
 public DeviceStatusHistoryGrain(IRuntimeStorage runtimeStorage, ILogger <DeviceStatusHistoryGrain> logger)
 {
     this.runtimeStorage = runtimeStorage;
     this.logger         = logger;
 }
Ejemplo n.º 28
0
 public InterpretArgs(Tree tree, Tree.BatchTransform updater, IRuntimeStorage runtimeStorage)
 {
     this._updater  = updater;
     Tree           = tree;
     RuntimeStorage = runtimeStorage;
 }