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(); } } }
/// <summary> /// Inserts a new node with the given object after the node at /// the specified depth. /// </summary> /// <typeparam name="TValue">The type of the value.</typeparam> /// <param name="obj">The contents of the node.</param> /// <param name="depth">The depth of the node's parent.</param> /// <returns>The created file node.</returns> public IFileNode Insert <TValue> (INamedObject <TValue> obj, int depth) where TValue : ISelfSerializable, new() { var result = FileNode.Create(obj); InsertInternal(Root[depth], result); return(result); }
public static void Start() { AppDomain.CurrentDomain.UnhandledException += LogException; URL url = new URL(ConfigurationManager.AppSettings["URL"]); fileNodeImpl = new FileNodeImpl(url); fileNodeImpl.Create(); isStop = false; while (!isStop) { Thread.Sleep(10000); } Log.WriteDebug("File server started."); }
public static FileNode LoadResource(ManifestResource resource, bool overwrite = false) { Logger.Log("Load Resource: " + resource); FileNode node = Root.GetFile(resource.FileName); if (!overwrite && node.IsExist) { Logger.Log("resource finded! " + node.AbosolutePath); } else { if (overwrite) { Logger.Log("resource is overwriting. copy to: " + node.AbosolutePath); if (node.IsExist) { node.Delete(); } } else { Logger.Log("resource not found. copy to : " + node.AbosolutePath); } var assembly = typeof(Core).GetTypeInfo().Assembly; using (Stream stream = assembly.GetManifestResourceStream(resource.Resource)) { if (stream == null) { throw new FileNotFoundException("Resource is not founded: " + resource.Resource); } if (!node.IsExist) { node.Create(); } Copy(stream, node); } } return(node); }
private void CreateInternal( bool recursive, CreationCollisionOption options, CancellationToken cancellationToken ) { cancellationToken.ThrowIfCancellationRequested(); lock (_inMemoryFileSystem.Storage) { if (recursive) { var inMemoryParent = (InMemoryStorageFolder)Parent; inMemoryParent.CreateInternal( recursive: true, CreationCollisionOption.UseExisting, cancellationToken ); } switch (options) { case CreationCollisionOption.Fail: FailImpl(); break; case CreationCollisionOption.ReplaceExisting: ReplaceExistingImpl(); break; case CreationCollisionOption.UseExisting: UseExistingImpl(); break; default: throw new NotSupportedException(ExceptionStrings.Enum.UnsupportedValue(options)); } } void FailImpl() { FileNode.Create(_storage, Path); } void ReplaceExistingImpl() { if (_storage.TryGetFileNode(Path) is FileNode existingNode) { existingNode.Delete(); } FileNode.Create(_storage, Path); } void UseExistingImpl() { if (!_storage.HasFileNode(Path)) { FileNode.Create(_storage, Path); } } }
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); }