private async Task EvaluateVideoFrameAsync(VideoFrame frame)
        {
            if (frame != null)
            {
                try
                {
                    PlanesInput inputData = new PlanesInput();
                    inputData.data = ImageFeatureValue.CreateFromVideoFrame(frame);
                    var results = await planeModel.EvaluateAsync(inputData);

                    var loss   = results.loss.ToList();
                    var labels = results.classLabel;

                    float value = loss.FirstOrDefault()["plane"];

                    var  lossStr = (value * 100.0f).ToString("#0.00") + "%";
                    bool isPlane = false;
                    if (value > 0.75)
                    {
                        isPlane = true;
                    }

                    string message = $"Predictions: {lossStr} - Is it a plane? {isPlane}";
                    Status.Text = message;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"error: {ex.Message}");
                    Status.Text = $"error: {ex.Message}";
                }
            }
        }
예제 #2
0
        public async Task <PlanesOutput> EvaluateAsync(PlanesInput input)
        {
            binding.Bind("data", input.data);
            var result = await session.EvaluateAsync(binding, "0");

            var output = new PlanesOutput();

            output.classLabel = result.Outputs["classLabel"] as TensorString;
            output.loss       = result.Outputs["loss"] as IList <IDictionary <string, float> >;
            return(output);
        }