Beispiel #1
0
        public int Run_For_File(string file, string model_path, int[] dimentions)
        {
            byte[] byte_im = b_data;

            using (BBaseContext db = new BBaseContext())
            {
                var answer = db.Blobs.Where(p => p.File_Name == file).FirstOrDefault();
                if (answer != null)
                {
                    var im = answer.Image;
                    if (im.SequenceEqual(byte_im))
                    {
                        return(answer.Answer);
                    }
                }
            }

            var session   = new InferenceSession(model_path);
            var inputMeta = session.InputMetadata;

            var inputs = new List <NamedOnnxValue>();

            foreach (var name in inputMeta.Keys)
            {
                Add_File(inputs, dimentions, name);
            }

            var results = session.Run(inputs);

            foreach (var result in results)
            {
                var arr         = result.AsEnumerable <float>().ToArray();
                var expected_cl = Most_Possible_Result(arr);

                using (BBaseContext db = new BBaseContext())
                {
                    db.Blobs.Add(new ImgBloB {
                        Answer = expected_cl, File_Name = file, Image = byte_im
                    });
                    db.SaveChanges();
                }

                return(expected_cl);
            }

            return(-1);
        }
        public void Delete()
        {
            var blobs = db.Blobs;

            foreach (var blob in blobs)
            {
                db.Blobs.Remove(blob);
            }

            var answers = db.Answers;

            foreach (var answer in answers)
            {
                db.Answers.Remove(answer);
            }
            db.SaveChanges();
        }