Beispiel #1
0
        private void ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try {
                using (var dict = _db.GetDocument(CoreApp.DocId)) {
                    var arr = dict.GetArray(CoreApp.ArrKey);
                    for (int i = 0; i < arr.Count; i++)
                    {
                        DictionaryObject d = arr.GetDictionary(i);
                        _items[i].Name           = d.GetString("key");
                        _items[i].Quantity       = d.GetInt("value");
                        _items[i].ImageByteArray = d.GetBlob("image")?.Content;
                    }
                }
            } catch (Exception ex) {
                Debug.WriteLine(ex);
            } finally {
                IsBusy = false;
            }
        }
        public DictionaryObject Predict(DictionaryObject input)
        {
            var blob = input.GetBlob("photo");

            if (blob == null)
            {
                return(null);
            }

            var imageData = blob.Content;
            // `TensorFlowModel` is a fake implementation
            // this would be the implementation of the ml model you have chosen
            var modelOutput = TensorFlowModel.PredictImage(imageData);

            return(new MutableDictionaryObject(modelOutput)); // <1>
        }
        protected override DictionaryObject DoPrediction(DictionaryObject input)
        {
            var blob = input.GetBlob("text");

            if (blob == null)
            {
                return(null);
            }

            ContentType = blob.ContentType;

            var text = Encoding.UTF8.GetString(blob.Content);
            var wc   = text.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length;
            var sc   = text.Split('.', StringSplitOptions.RemoveEmptyEntries).Length;

            var output = new MutableDictionaryObject();

            output.SetInt("wc", wc);
            output.SetInt("sc", sc);
            return(output);
        }