예제 #1
0
        protected override async Task EvaluateAsync(MLModelResult result, VideoFrame inputFrame)
        {
            // Initialize the input
            PcbModelInput input = new PcbModelInput()
            {
                data = inputFrame
            };

            // Evaluate the input
            PcbModelOutput output = await EvaluateAsync(input, result.CorrelationId);

            // Get first label from output
            string label = output.classLabel?.FirstOrDefault();

            // Find probability for label
            if (string.IsNullOrEmpty(label) == false)
            {
                float probability = output.loss?.ContainsKey(label) == true ? output.loss[label] : 0f;

                result.OutputFeatures = new MLModelOutputFeature[]
                {
                    new MLModelOutputFeature()
                    {
                        Label = label, Probability = probability
                    }
                };
            }
        }
예제 #2
0
        public async Task <PcbModelOutput> EvaluateAsync(PcbModelInput input, string correlationId = "")
        {
            PcbModelOutput output = new PcbModelOutput();

            // Bind input and output model
            LearningModelBindingPreview binding = new LearningModelBindingPreview(this.LearningModel);

            binding.Bind("data", input.data);
            binding.Bind("classLabel", output.classLabel);
            binding.Bind("loss", output.loss);

            // Evaluate the bindings
            LearningModelEvaluationResultPreview evalResult = await this.LearningModel.EvaluateAsync(binding, correlationId);

            return(output);
        }