예제 #1
0
파일: Program.cs 프로젝트: soapun/s02170128
        static void Main(string[] args)
        {
            ConsoleTraceListener listener = new ConsoleTraceListener();

            Trace.Listeners.Add(listener);

            string ProjPath = Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName;
            string DirPath  = ProjPath + @"\pics_to_recognize\";

            OnnxClassifier clf = new OnnxClassifier(ProjPath + @"\model\resnet50-v2-7.onnx");

            PredictionQueue cq = new PredictionQueue();

            cq.Enqueued += PredictionCaught;
            Task keyBoardTask = Task.Run(() =>
            {
                Trace.WriteLine("*** Press Esc to cancel");
                while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                {
                }
                clf.StopPrediction();
            });

            clf.PredictAll(cq, new DirectoryInfo(DirPath).GetFiles());

            Trace.Listeners.Remove(listener);
            Trace.Close();
        }
예제 #2
0
        public ActionResult <List <PredictionResult> > GetNew([FromBody] List <PredictionRequest> mpr) // Base64
        {
            var cq = new PredictionQueue();

            clf.PredictAll(cq, mpr.Select(i => new Tuple <string, byte[]>(i.FilePath, Convert.FromBase64String(i.Image))).ToList());
            var res = cq.Queue.ToList();

            res.ForEach(delegate(PredictionResult pr) { dB.AddToDataBase(pr); });
            return(new ActionResult <List <PredictionResult> >(cq.Queue.ToList()));
        }