Пример #1
0
 private void MenuItem_Click_8(object sender, RoutedEventArgs e)
 {
     Frame       = new FrameOrder();
     DataContext = Frame;
     lsvDoorOpening.ItemsSource = frame.FrameCollection;
     lsvRails.ItemsSource       = frame.Rails;
 }
        private void lsvFrameOrders_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListViewItem item = sender as ListViewItem;

            if (item.Content as FrameOrder != null)
            {
                SelectedFrame = item.Content as FrameOrder;
                Close();
            }
        }
Пример #3
0
        public static async Task RunAi(string outpath, AI ai, bool stepByStep = false)
        {
            if (canceled)
            {
                return;
            }

            await Task.Run(async() => { await Dedupe.CreateDupesFile(current.framesFolder, currentInputFrameCount, current.framesExt); });

            await Task.Run(async() => { await FrameRename.Rename(); });

            await Task.Run(async() => { await FrameOrder.CreateFrameOrderFile(current.framesFolder, Config.GetBool(Config.Key.enableLoop), current.interpFactor); });

            Program.mainForm.SetStatus("Downloading models...");
            await ModelDownloader.DownloadModelFiles(ai, current.model.dir);

            if (canceled)
            {
                return;
            }

            currentlyUsingAutoEnc = Utils.CanUseAutoEnc(stepByStep, current);

            IoUtils.CreateDir(outpath);

            List <Task> tasks = new List <Task>();

            if (ai.aiName == Implementations.rifeCuda.aiName)
            {
                tasks.Add(AiProcess.RunRifeCuda(current.framesFolder, current.interpFactor, current.model.dir));
            }

            if (ai.aiName == Implementations.rifeNcnn.aiName)
            {
                tasks.Add(AiProcess.RunRifeNcnn(current.framesFolder, outpath, current.interpFactor, current.model.dir));
            }

            if (ai.aiName == Implementations.flavrCuda.aiName)
            {
                tasks.Add(AiProcess.RunFlavrCuda(current.framesFolder, current.interpFactor, current.model.dir));
            }

            if (ai.aiName == Implementations.dainNcnn.aiName)
            {
                tasks.Add(AiProcess.RunDainNcnn(current.framesFolder, outpath, current.interpFactor, current.model.dir, Config.GetInt(Config.Key.dainNcnnTilesize, 512)));
            }

            if (ai.aiName == Implementations.xvfiCuda.aiName)
            {
                tasks.Add(AiProcess.RunXvfiCuda(current.framesFolder, current.interpFactor, current.model.dir));
            }

            if (currentlyUsingAutoEnc)
            {
                Logger.Log($"{Logger.GetLastLine()} (Using Auto-Encode)", true);
                tasks.Add(AutoEncode.MainLoop(outpath));
            }

            Program.mainForm.SetStatus("Running AI...");
            await Task.WhenAll(tasks);
        }
Пример #4
0
        public static async Task PostProcessFrames(bool stepByStep)
        {
            if (canceled)
            {
                return;
            }

            int extractedFrames = IOUtils.GetAmountOfFiles(current.framesFolder, false, "*.png");

            if (!Directory.Exists(current.framesFolder) || currentInputFrameCount <= 0 || extractedFrames < 2)
            {
                if (extractedFrames == 1)
                {
                    Cancel("Only a single frame was extracted from your input file!\n\nPossibly your input is an image, not a video?");
                }
                else
                {
                    Cancel("Frame extraction failed!\n\nYour input file might be incompatible.");
                }
            }

            if (Config.GetInt("dedupMode") == 1)
            {
                await Dedupe.Run(current.framesFolder);
            }
            else
            {
                Dedupe.ClearCache();
            }

            if (!Config.GetBool("enableLoop"))
            {
                await Utils.CopyLastFrame(currentInputFrameCount);
            }

            if (Config.GetInt("dedupMode") > 0)
            {
                await Dedupe.CreateDupesFile(current.framesFolder, currentInputFrameCount);
            }

            if (canceled)
            {
                return;
            }

            await FrameOrder.CreateFrameOrderFile(current.framesFolder, Config.GetBool("enableLoop"), current.interpFactor);

            if (canceled)
            {
                return;
            }

            try
            {
                Dictionary <string, string> renamedFilesDict = await IOUtils.RenameCounterDirReversibleAsync(current.framesFolder, "png", 1, Padding.inputFramesRenamed);

                if (stepByStep)
                {
                    AiProcess.filenameMap = renamedFilesDict.ToDictionary(x => Path.GetFileName(x.Key), x => Path.GetFileName(x.Value));    // Save rel paths
                }
            }
            catch (Exception e)
            {
                Logger.Log($"Error renaming frame files: {e.Message}");
                Cancel("Error renaming frame files. Check the log for details.");
            }

            if (current.alpha)
            {
                Program.mainForm.SetStatus("Extracting transparency...");
                Logger.Log("Extracting transparency... (1/2)");
                await FfmpegAlpha.ExtractAlphaDir(current.framesFolder, current.framesFolder + Paths.alphaSuffix);

                Logger.Log("Extracting transparency... (2/2)", false, true);
                await FfmpegAlpha.RemoveAlpha(current.framesFolder, current.framesFolder);
            }
        }
Пример #5
0
 public MainWindow()
 {
     InitializeComponent();
     Frame = new FrameOrder();
     LoadCombos();
 }
Пример #6
0
 private void Button_Click_3(object sender, RoutedEventArgs e)
 {
     Frame       = new FrameOrder();
     DataContext = null;
     LoadCombos();
 }