Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove the sliders from the controlnet modes and leave the values the same as in the webapp #150

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions package/Editor/PromptWindow/PromptWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,9 @@ private void PrepareAdvancedModalitySettings(out string modality, out string ope
{
string option1Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption1Index - 1];
if (!modalitySettings.ContainsKey(option1Name))
modalitySettings.Add(option1Name, $"{promptWindowUI.sliderValue1:0.00}");
}

if (promptWindowUI.selectedOption2Index > 0)
{
string option2Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption2Index - 1];
if (!modalitySettings.ContainsKey(option2Name))
modalitySettings.Add(option2Name, $"{promptWindowUI.sliderValue2:0.00}");
}

if (promptWindowUI.selectedOption3Index > 0)
{
string option3Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption3Index - 1];
if (!modalitySettings.ContainsKey(option3Name))
modalitySettings.Add(option3Name, $"{promptWindowUI.sliderValue3:0.00}");
{
modalitySettings.Add(option1Name, $"{promptWindowUI.sliderValue:0.00}");
}
}

modality = string.Join(",", modalitySettings.Select(kv => $"{kv.Key}:{float.Parse(kv.Value).ToString(CultureInfo.InvariantCulture)}"));
Expand Down
16 changes: 10 additions & 6 deletions package/Editor/PromptWindow/PromptWindowUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ public partial class PromptWindowUI

public string selectedPreset = "";
public int selectedOption1Index = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename Option1Name if there is no more 1-2-3-4, etc...
(and also other Something1Variable names)

public int selectedOption2Index = 0;
public int selectedOption3Index = 0;
public float sliderValue1 = 0.1f;
public float sliderValue2 = 0.1f;
public float sliderValue3 = 0.1f;

/// <summary>
/// Variable to display in interface on slider element.
/// </summary>
public int sliderDisplayedValue = 100;

/// <summary>
/// Value from the guidance slider in controlNet options, use to send to generation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that this value is not only for guidance but that's what the comment is saying

/// </summary>
public float sliderValue = 0.0f;

internal bool isImageToImage = false;
internal bool isControlNet = false;
Expand Down Expand Up @@ -303,7 +308,6 @@ private Rect DrawUploadedImage(Rect dropArea)
heightSliderValue = matchingHeight != -1 ? matchingHeight : currentHeight;

selectedOption1Index = NearestValueIndex(widthSliderValue, allowedWidthValues);
selectedOption2Index = NearestValueIndex(heightSliderValue, allowedHeightValues);
});

toolsMenu.DropDown(dropdownButtonRect);
Expand Down
47 changes: 10 additions & 37 deletions package/Editor/PromptWindow/Views/ControlNetView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,23 @@ private void RenderControlNetFoldout()
if (isAdvancedSettings)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Model 1", EditorStyles.label);
GUILayout.Label("Modality :", EditorStyles.label);

List<string> availableOptions1 = new List<string> { "None" };
availableOptions1.AddRange(dropdownOptions);
selectedOption1Index = EditorGUILayout.Popup(selectedOption1Index, availableOptions1.ToArray());

GUILayout.Label("Slider 1", EditorStyles.label);
sliderValue1 = Mathf.Round(EditorGUILayout.Slider(Mathf.Clamp(sliderValue1, 0.1f, 1.0f), 0.1f, 1.0f) * 100) / 100;
GUILayout.EndHorizontal();

if (selectedOption1Index > 0)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Model 2", EditorStyles.label);

List<string> availableOptions2 = new List<string> { "None" };
availableOptions2.AddRange(dropdownOptions);
availableOptions2.RemoveAt(selectedOption1Index);
selectedOption2Index = EditorGUILayout.Popup(selectedOption2Index, availableOptions2.ToArray());

GUILayout.Label("Slider 2", EditorStyles.label);
sliderValue2 = Mathf.Round(EditorGUILayout.Slider(Mathf.Clamp(sliderValue2, 0.1f, 1.0f), 0.1f, 1.0f) * 100) / 100;
GUILayout.EndHorizontal();
}

if (selectedOption2Index > 0)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Model 3", EditorStyles.label);

List<string> availableOptions3 = new List<string> { "None" };
availableOptions3.AddRange(dropdownOptions);
int option1Index = Array.IndexOf(dropdownOptions, availableOptions1[selectedOption1Index]);
int option2Index = Array.IndexOf(dropdownOptions, dropdownOptions[selectedOption2Index]);

availableOptions3.RemoveAt(option1Index + 1);
availableOptions3.RemoveAt(option2Index);

selectedOption3Index = EditorGUILayout.Popup(selectedOption3Index, availableOptions3.ToArray());

GUILayout.Label("Slider 3", EditorStyles.label);
sliderValue3 = Mathf.Round(EditorGUILayout.Slider(Mathf.Clamp(sliderValue3, 0.1f, 1.0f), 0.1f, 1.0f) * 100) / 100;
GUILayout.EndHorizontal();
{
GUILayout.Label("Guidance :", EditorStyles.label);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aligned of calling this Guidance and I would prefer Influence. @qvaleroo what do you think ?

sliderDisplayedValue = (int)EditorGUILayout.Slider(Mathf.Clamp(sliderDisplayedValue, 0, 100), 0, 100);
sliderValue = sliderDisplayedValue / 100.0f;
if (sliderValue == 0)
{
sliderValue = 0.01f;
}
}
GUILayout.EndHorizontal();
}
else
{
Expand Down
Loading