예제 #1
0
        public async Task <Inceptionv3_convertedOutput> Evaluate(StorageFile file)
        {
            Inceptionv3_convertedInput tensorInput = new Inceptionv3_convertedInput();

            byte[] image = await ResizedImage(file, INPUT_WIDTH, INPUT_HEIGHT);


            List <float> input = new List <float>();
            List <float> R     = new List <float>();
            List <float> G     = new List <float>();
            List <float> B     = new List <float>();

            for (int j = 0; j < INPUT_HEIGHT; j++)
            {
                for (int i = 0; i < INPUT_WIDTH; i++)
                {
                    R.Add(GetPixel(image, i, j, INPUT_WIDTH, INPUT_HEIGHT).R / 255f);
                    G.Add(GetPixel(image, i, j, INPUT_WIDTH, INPUT_HEIGHT).G / 255f);
                    B.Add(GetPixel(image, i, j, INPUT_WIDTH, INPUT_HEIGHT).B / 255f);
                }
            }
            input.AddRange(R);
            input.AddRange(G);
            input.AddRange(B);
            tensorInput.input_1_0 = TensorFloat.CreateFromArray(new long[] { 1, 256, 256, 3 }, input.ToArray());
            return(await Model.EvaluateAsync(tensorInput));
        }
        public async Task <Inceptionv3_convertedOutput> EvaluateAsync(Inceptionv3_convertedInput input)
        {
            binding.Bind("input_1_0", input.input_1_0);
            var result = await session.EvaluateAsync(binding, "0");

            var output = new Inceptionv3_convertedOutput();

            output.dense_2_Softmax_01 = result.Outputs["dense_2_Softmax_01"] as TensorFloat;
            return(output);
        }