예제 #1
0
        public static bool CheckAiAvailable(AI ai, ModelCollection.ModelInfo model)
        {
            if (IoUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), ai.pkgDir), true) < 1)
            {
                UiUtils.ShowMessageBox("The selected AI is not installed!", UiUtils.MessageType.Error);
                I.Cancel("Selected AI not available.", true);
                return(false);
            }

            if (model == null || model.dir.Trim() == "")
            {
                UiUtils.ShowMessageBox("No valid AI model has been selected!", UiUtils.MessageType.Error);
                I.Cancel("No valid model selected.", true);
                return(false);
            }

            if (I.current.ai.aiName.ToUpper().Contains("CUDA") && NvApi.gpuList.Count < 1)
            {
                UiUtils.ShowMessageBox("Warning: No Nvidia GPU was detected. CUDA might fall back to CPU!\n\nTry an NCNN implementation instead if you don't have an Nvidia GPU.", UiUtils.MessageType.Error);

                if (!Config.GetBool("allowCudaWithoutDetectedGpu", true))
                {
                    I.Cancel("No CUDA-capable graphics card available.", true);
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        public static ComboBox LoadAiModelsIntoGui(ComboBox combox, AI ai)
        {
            combox.Items.Clear();

            try
            {
                ModelCollection modelCollection = AiModels.GetModels(ai);

                if (modelCollection.models == null || modelCollection.models.Count < 1)
                {
                    return(combox);
                }

                for (int i = 0; i < modelCollection.models.Count; i++)
                {
                    ModelCollection.ModelInfo modelInfo = modelCollection.models[i];

                    if (string.IsNullOrWhiteSpace(modelInfo.name))
                    {
                        continue;
                    }

                    combox.Items.Add(modelInfo.GetUiString());

                    if (modelInfo.isDefault)
                    {
                        combox.SelectedIndex = i;
                    }
                }

                if (combox.SelectedIndex < 0)
                {
                    combox.SelectedIndex = 0;
                }

                SelectNcnnIfNoCudaAvail(combox);
            }
            catch (Exception e)
            {
                Logger.Log($"Failed to load available AI models for {ai.aiName}! {e.Message}");
                Logger.Log($"Stack Trace: {e.StackTrace}", true);
            }

            return(combox);
        }
예제 #3
0
        public static async Task DownloadForAi(AI ai)
        {
            ModelCollection modelCollection = AiModels.GetModels(ai);

            for (int i = 0; i < modelCollection.models.Count; i++)
            {
                if (canceled)
                {
                    return;
                }

                ModelCollection.ModelInfo modelInfo = modelCollection.models[i];
                form.SetStatus($"Downloading files for {modelInfo.ai.aiName.Replace("_", "-")}...");
                await ModelDownloader.DownloadModelFiles(ai, modelInfo.dir, false);

                taskCounter++;
                UpdateProgressBar();
            }
        }
예제 #4
0
        public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, float interpFactorArg, float itsScale, Interpolate.OutMode outModeArg, ModelCollection.ModelInfo modelArg)
        {
            inPath        = inPathArg;
            outPath       = outPathArg;
            ai            = aiArg;
            inFpsDetected = inFpsDetectedArg;
            inFps         = inFpsArg;
            interpFactor  = interpFactorArg;
            outFps        = inFpsArg * (double)interpFactorArg;
            outItsScale   = itsScale;
            outMode       = outModeArg;
            model         = modelArg;

            alpha      = false;
            stepByStep = false;

            framesExt = "";
            interpExt = "";

            try
            {
                tempFolder    = InterpolateUtils.GetTempFolderLoc(inPath, outPath);
                framesFolder  = Path.Combine(tempFolder, Paths.framesDir);
                interpFolder  = Path.Combine(tempFolder, Paths.interpDir);
                inputIsFrames = IoUtils.IsPathDirectory(inPath);
            }
            catch
            {
                Logger.Log("Tried to create InterpSettings struct without an inpath. Can't set tempFolder, framesFolder and interpFolder.", true);
                tempFolder    = "";
                framesFolder  = "";
                interpFolder  = "";
                inputIsFrames = false;
            }

            _inputResolution  = new Size(0, 0);
            _scaledResolution = new Size(0, 0);

            RefreshExtensions();
        }
예제 #5
0
        public InterpSettings(string serializedData)
        {
            inPath            = "";
            outPath           = "";
            ai                = Implementations.networks[0];
            inFpsDetected     = new Fraction();
            inFps             = new Fraction();
            interpFactor      = 0;
            outFps            = new Fraction();
            outMode           = Interpolate.OutMode.VidMp4;
            model             = null;
            alpha             = false;
            stepByStep        = false;
            _inputResolution  = new Size(0, 0);
            _scaledResolution = new Size(0, 0);
            framesExt         = "";
            interpExt         = "";

            Dictionary <string, string> entries = new Dictionary <string, string>();

            foreach (string line in serializedData.SplitIntoLines())
            {
                if (line.Length < 3)
                {
                    continue;
                }
                string[] keyValuePair = line.Split('|');
                entries.Add(keyValuePair[0], keyValuePair[1]);
            }

            foreach (KeyValuePair <string, string> entry in entries)
            {
                switch (entry.Key)
                {
                case "INPATH": inPath = entry.Value; break;

                case "OUTPATH": outPath = entry.Value; break;

                case "AI": ai = Implementations.GetAi(entry.Value); break;

                case "INFPSDETECTED": inFpsDetected = new Fraction(entry.Value); break;

                case "INFPS": inFps = new Fraction(entry.Value); break;

                case "OUTFPS": outFps = new Fraction(entry.Value); break;

                case "INTERPFACTOR": interpFactor = float.Parse(entry.Value); break;

                case "OUTMODE": outMode = (Interpolate.OutMode)Enum.Parse(typeof(Interpolate.OutMode), entry.Value); break;

                case "MODEL": model = AiModels.GetModelByName(ai, entry.Value); break;

                case "INPUTRES": _inputResolution = FormatUtils.ParseSize(entry.Value); break;

                case "OUTPUTRES": _scaledResolution = FormatUtils.ParseSize(entry.Value); break;

                case "ALPHA": alpha = bool.Parse(entry.Value); break;

                case "STEPBYSTEP": stepByStep = bool.Parse(entry.Value); break;

                case "FRAMESEXT": framesExt = entry.Value; break;

                case "INTERPEXT": interpExt = entry.Value; break;
                }
            }

            try
            {
                tempFolder    = InterpolateUtils.GetTempFolderLoc(inPath, outPath);
                framesFolder  = Path.Combine(tempFolder, Paths.framesDir);
                interpFolder  = Path.Combine(tempFolder, Paths.interpDir);
                inputIsFrames = IoUtils.IsPathDirectory(inPath);
            }
            catch
            {
                Logger.Log("Tried to create InterpSettings struct without an inpath. Can't set tempFolder, framesFolder and interpFolder.", true);
                tempFolder    = "";
                framesFolder  = "";
                interpFolder  = "";
                inputIsFrames = false;
            }

            RefreshExtensions();
        }