예제 #1
0
        async Task FetchBatchResults(int num)
        {
            var batch   = new MLArrayBatchProvider(inputs.Take(num).ToArray());
            var options = new MLPredictionOptions()
            {
                UsesCpuOnly = false
            };

            Stopwatch stopWatch = Stopwatch.StartNew();
            await Task.Run(() =>
            {
                model.GetPredictions(batch, options, out NSError error);
            });

            stopWatch.Stop();
            batchMilliseconds = stopWatch.ElapsedMilliseconds;
        }
        /// <summary>
        /// Make a prediction using the standard interface
        /// </summary>
        /// <param name="input">an instance of hate_coremlInput to predict from</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public hate_coremlOutput GetPrediction(hate_coremlInput input, MLPredictionOptions options, out NSError error)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var prediction = model.GetPrediction(input, options, out error);

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

            var output1Value = prediction.GetFeatureValue("output1").MultiArrayValue;

            return(new hate_coremlOutput(output1Value));
        }
예제 #3
0
        /// <summary>
        /// Make a prediction using the standard interface
        /// </summary>
        /// <param name="input">an instance of MarsHabitatPricerInput to predict from</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public MarsHabitatPricerOutput GetPrediction(MarsHabitatPricerInput input, MLPredictionOptions options, out NSError error)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var prediction = model.GetPrediction(input, options, out error);

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

            var priceValue = prediction.GetFeatureValue("price").DoubleValue;

            return(new MarsHabitatPricerOutput(priceValue));
        }
예제 #4
0
        /// <summary>
        /// Make a prediction using the standard interface
        /// </summary>
        /// <param name="input">an instance of CookHappyJuneInput to predict from</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public CookHappyJuneOutput GetPrediction(CookHappyJuneInput input, MLPredictionOptions options, out NSError error)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var prediction = model.GetPrediction(input, options, out error);

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

            var lossValue       = prediction.GetFeatureValue("loss").DictionaryValue;
            var classLabelValue = prediction.GetFeatureValue("classLabel").StringValue;

            return(new CookHappyJuneOutput(lossValue, classLabelValue));
        }
예제 #5
0
        /// <summary>
        /// Make a prediction using the standard interface
        /// </summary>
        /// <param name="input">an instance of FreeSoundsModel25Input to predict from</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public FreeSoundsModel25Output GetPrediction(FreeSoundsModel25Input input, MLPredictionOptions options, out NSError error)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var prediction = model.GetPrediction(input, options, out error);

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

            var classLabelProbsValue = prediction.GetFeatureValue("classLabelProbs").DictionaryValue;
            var classLabelValue      = prediction.GetFeatureValue("classLabel").StringValue;

            return(new FreeSoundsModel25Output(classLabelProbsValue, classLabelValue));
        }
예제 #6
0
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="audioSamples">Input audio samples to be classified as 15600 1-dimensional array of floats</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public FreeSoundsPlusModel25Output GetPrediction(MLMultiArray audioSamples, MLPredictionOptions options, out NSError error)
        {
            var input = new FreeSoundsPlusModel25Input(audioSamples);

            return(GetPrediction(input, options, out error));
        }
예제 #7
0
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="data"> as color (kCVPixelFormatType_32BGRA) image buffer, 224 pizels wide by 224 pixels high</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public CookHappyJuneOutput GetPrediction(CVPixelBuffer data, MLPredictionOptions options, out NSError error)
        {
            var input = new CookHappyJuneInput(data);

            return(GetPrediction(input, options, out error));
        }
예제 #8
0
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="data"> as color (kCVPixelFormatType_32BGRA) image buffer, 224 pizels wide by 224 pixels high</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public RamenOutput GetPrediction(CVPixelBuffer data, MLPredictionOptions options, out NSError error)
        {
            var input = new RamenInput(data);

            return(GetPrediction(input, options, out error));
        }
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="input1"> as 1 1-dimensional array of doubles</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public hate_coremlOutput GetPrediction(MLMultiArray input1, MLPredictionOptions options, out NSError error)
        {
            var input = new hate_coremlInput(input1);

            return(GetPrediction(input, options, out error));
        }
예제 #10
0
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="data"> as color (kCVPixelFormatType_32BGRA) image buffer, 224 pizels wide by 224 pixels high</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public jankenmodelOutput GetPrediction(CVPixelBuffer data, MLPredictionOptions options, out NSError error)
        {
            var input = new jankenmodelInput(data);

            return(GetPrediction(input, options, out error));
        }
예제 #11
0
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="data"> as color (kCVPixelFormatType_32BGRA) image buffer, 224 pizels wide by 224 pixels high</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public coil100Model_CoreMLOutput GetPrediction(CVPixelBuffer data, MLPredictionOptions options, out NSError error)
        {
            var input = new coil100Model_CoreMLInput(data);

            return(GetPrediction(input, options, out error));
        }
예제 #12
0
        /// <summary>
        /// Make a prediction using the convenience interface
        /// </summary>
        /// <param name="solarPanels">Number of solar panels as double</param>
        /// <param name="greenhouses">Number of greenhouses as double</param>
        /// <param name="size">Size in acres as double</param>
        /// <param name="options">prediction options</param>
        /// <param name="error">If an error occurs, upon return contains an NSError object that describes the problem.</param>
        public MarsHabitatPricerOutput GetPrediction(double solarPanels, double greenhouses, double size, MLPredictionOptions options, out NSError error)
        {
            var input = new MarsHabitatPricerInput(solarPanels, greenhouses, size);

            return(GetPrediction(input, options, out error));
        }