Ejemplo n.º 1
0
        public EyeGazeModelRecorder(string session, Size screenSize)
        {
            SessionName = session;
            ScreenSize  = screenSize;

            DirectoryNode node = Storage.Root.GetDirectory($"[{DateTime.Now.ToString()}] {session}");

            Storage.FixPathChars(node);
            if (!node.IsExist)
            {
                node.Create();
            }
            Parent = node;

            FileNode file = node.GetFile("model.txt");

            if (file.IsExist)
            {
                file.Delete();
            }
            file.Create();
            using (Stream s = file.Open())
            {
                using (StreamWriter write = new StreamWriter(s))
                {
                    write.WriteLine($"scr:{screenSize.Width},{screenSize.Height}");
                    write.Flush();
                }
            }
        }
Ejemplo n.º 2
0
        public void Load()
        {
            Logger.Log("Download model");
            FileNode      f   = Storage.Root.GetFile("inception5h.zip");
            DirectoryNode dir = Storage.Root.GetDirectory("Inception5h");

            if (!f.IsExist)
            {
                f.Create();
                string webPath = "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip";
                using (HttpClient hc = new HttpClient())
                {
                    byte[] buffer = hc.GetByteArrayAsync(webPath).Result;
                    f.WriteBytes(buffer);
                }
                if (!dir.IsExist)
                {
                    dir.Create();
                }
                else
                {
                    FileNode[] files = dir.GetFiles();
                    if (files != null)
                    {
                        foreach (FileNode existsfile in files)
                        {
                            existsfile.Delete();
                        }
                    }
                }
            }
            Logger.Log("Finish download model");

            FileNode graphfile = dir.GetFile("tensorflow_inception_graph.pb");
            FileNode indexfile = dir.GetFile("imagenet_comp_graph_label_strings.txt");

            if (!graphfile.IsExist || !indexfile.IsExist)
            {
                Storage.UnZip(f, dir);
            }

            Logger.Log("Load graph");
            if (graph == null)
            {
                graph = new Graph();
                graph.ImportPb(graphfile);
                Logger.Log("Graph load finished");
            }
            else
            {
                Logger.Log("Graph is loaded");
            }

            Logger.Log("Load Index File");
            if (resultTag == null)
            {
                resultTag = indexfile.ReadLines();
                Logger.Log($"{resultTag.Length} Counts indexes are loaded");
            }
            else
            {
                Logger.Log("Index file already loaded");
            }

            sess = new Session(graph);
        }