예제 #1
0
        static void LogOutput(string line, string logFilename, bool err = false)
        {
            if (string.IsNullOrWhiteSpace(line) || line.Length < 6)
            {
                return;
            }

            Stopwatch sw = new Stopwatch();

            sw.Restart();

            if (line.Contains("iVBOR"))
            {
                try
                {
                    string[] split = line.Split(':');
                    //MemoryStream stream = new MemoryStream(Convert.FromBase64String(split[1]));
                    //Image img = Image.FromStream(stream);
                    Logger.Log($"Received image {split[0]} in {sw.ElapsedMilliseconds} ms", true);
                }
                catch (Exception e)
                {
                    Logger.Log($"Failed to decode b64 string - {e}:");
                    Logger.Log(line);
                }
                return;
            }

            Logger.LogToFile(line, false, logFilename);

            if (line.Contains("ff:nocuda-cpu"))
            {
                Logger.Log("WARNING: CUDA-capable GPU device is not available, running on CPU instead!");
            }

            if (!hasShownError && err && line.ToLower().Contains("out of memory"))
            {
                hasShownError = true;
                InterpolateUtils.ShowMessage($"Your GPU ran out of VRAM! Please try a video with a lower resolution or use the Max Video Size option in the settings.\n\n{line}", "Error");
            }

            if (!hasShownError && err && line.ToLower().Contains("modulenotfounderror"))
            {
                hasShownError = true;
                InterpolateUtils.ShowMessage($"A python module is missing.\nCheck {logFilename} for details.\n\n{line}", "Error");
                if (!Python.HasEmbeddedPyFolder())
                {
                    Process.Start("https://github.com/n00mkrad/flowframes/blob/main/PythonDependencies.md");
                }
            }

            if (!hasShownError && line.ToLower().Contains("no longer supports this gpu"))
            {
                hasShownError = true;
                InterpolateUtils.ShowMessage($"Your GPU seems to be outdated and is not supported!\n\n{line}", "Error");
            }

            if (!hasShownError && err && (line.Contains("RuntimeError") || line.Contains("ImportError") || line.Contains("OSError")))
            {
                hasShownError = true;
                InterpolateUtils.ShowMessage($"A python error occured during interpolation!\nCheck {logFilename} for details.\n\n{line}", "Error");
            }

            if (!hasShownError && err && line.Contains("vk") && line.Contains(" failed"))
            {
                hasShownError = true;
                string dain = (Interpolate.current.ai.aiName == Networks.dainNcnn.aiName) ? "\n\nTry reducing the tile size in the AI settings." : "";
                InterpolateUtils.ShowMessage($"A Vulkan error occured during interpolation!\n\n{line}{dain}", "Error");
            }

            if (!hasShownError && err && line.Contains("vkAllocateMemory failed"))
            {
                hasShownError = true;
                bool   usingDain = (Interpolate.current.ai.aiName == Networks.dainNcnn.aiName);
                string msg       = usingDain ? "\n\nTry reducing the tile size in the AI settings." : "Try a lower resolution (Settings -> Max Video Size).";
                InterpolateUtils.ShowMessage($"Vulkan ran out of memory!\n\n{line}{msg}", "Error");
            }

            if (!hasShownError && err && line.Contains("invalid gpu device"))
            {
                hasShownError = true;
                InterpolateUtils.ShowMessage($"A Vulkan error occured during interpolation!\n\n{line}\n\nAre your GPU IDs set correctly?", "Error");
            }

            if (hasShownError)
            {
                Interpolate.Cancel();
            }

            InterpolateUtils.UpdateLastFrameFromInterpOutput(line);
        }