public ModelCollection.ModelInfo GetModel(AI currentAi) { try { return(AiModels.GetModels(currentAi).models[aiModel.SelectedIndex]); } catch { return(null); } }
public static int GetTaskCount(List <AI> ais) { int count = 0; foreach (AI ai in ais) { ModelCollection modelCollection = AiModels.GetModels(ai); count += modelCollection.models.Count; } return(count); }
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); }
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(); } }
public static List <string> GetAllModelFolders() { List <string> modelPaths = new List <string>(); foreach (AI ai in Implementations.networks) { string aiPkgFolder = Path.Combine(Paths.GetPkgPath(), ai.pkgDir); ModelCollection aiModels = AiModels.GetModels(ai); foreach (ModelCollection.ModelInfo model in aiModels.models) { string mdlFolder = Path.Combine(aiPkgFolder, model.dir); if (Directory.Exists(mdlFolder)) { modelPaths.Add(mdlFolder); } } } return(modelPaths); }
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(); }