示例#1
0
        static void Main(string[] args)
        {
            var modelPath = "models/resnet50.model";
            var width     = 224;

            var tensor = JpegToTensor(GetDataPath("datasets/towers/et1.jpg"), width, width);

            var model = Sequential.Load(GetDataPath(modelPath));

            var prediction1 = model.Predict(tensor).Squeeze();

            tensor = JpegToTensor(GetDataPath("datasets/towers/et2.jpg"), width, width);

            var prediction2 = model.Predict(tensor).Squeeze();

            Console.WriteLine($" Distance to picture of the same object: {TensorUtils.EuclideanDistance(prediction1, prediction2).ToString("F2")}");

            tensor = JpegToTensor(GetDataPath("datasets/towers/et3.jpg"), width, width);

            prediction2 = model.Predict(tensor).Squeeze();
            Console.WriteLine($" Distance to picture of the same object: {TensorUtils.EuclideanDistance(prediction1, prediction2).ToString("F2")}");

            tensor = JpegToTensor(GetDataPath("datasets/towers/pt1.jpg"), width, width);

            prediction2 = model.Predict(tensor).Squeeze();
            Console.WriteLine($" Ddistance to picture of a different object: {TensorUtils.EuclideanDistance(prediction1, prediction2).ToString("F2")}");
        }