Skip to content

Commit

Permalink
Fixed a bug that interrupted the autotagger if the model did not cont…
Browse files Browse the repository at this point in the history
…ain additional settings. #169
  • Loading branch information
starik222 committed Nov 30, 2024
1 parent fbbf5a9 commit ba184ba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions BooruDatasetTagManager/Form_AutoTaggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using Manina.Windows.Forms;
using Microsoft.VisualBasic.Devices;

namespace BooruDatasetTagManager
{
public partial class Form_AutoTaggerSettings : Form
{
private Dictionary<string, Control> interrogatorSettingsControls = new Dictionary<string, Control>();
private List<string> selectedInterrogators = new List<string>();
private string ctrlPattern = "(.*?)_ctrl_(.*)";
public Form_AutoTaggerSettings()
{
Expand Down Expand Up @@ -214,6 +216,7 @@ private async Task<bool> CreateInterrogatorTabAsync(string name)
MessageBox.Show(intParams.ErrMes, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
selectedInterrogators.Add(name);
Tab tab = new Tab();
tab.Name = name;
tab.Text = name;
Expand Down Expand Up @@ -293,6 +296,7 @@ private void RemoveTab(string name)
{
TaggerSettingTabs.Tabs.Remove(tab);
}
selectedInterrogators.Remove(name);
var ctrlsToRemove = interrogatorSettingsControls.Where(a => a.Key.StartsWith(name + "_ctrl")).Select(a => a.Key);
foreach(var item in ctrlsToRemove)
interrogatorSettingsControls.Remove(item);
Expand Down Expand Up @@ -332,6 +336,15 @@ private void SetSavedSettingsToControls()
private void SaveSettingsFromControls()
{
Program.Settings.AutoTagger.InterragatorParams.Clear();

foreach (var network in selectedInterrogators)
{
if (!Program.Settings.AutoTagger.InterragatorParams.ContainsKey(network))
{
Program.Settings.AutoTagger.InterragatorParams.Add(network, new List<AdditionalParameters>());
}
}

foreach (var item in interrogatorSettingsControls)
{
Regex r = new Regex(ctrlPattern, RegexOptions.Compiled);
Expand Down

0 comments on commit ba184ba

Please sign in to comment.