Skip to content

Commit

Permalink
fix: 125 control net options should have the same naming as on the we…
Browse files Browse the repository at this point in the history
…bapp (#152)

* fix: Update modalities option and manage model type options values

* fix: modality options is now according with the webapp

According to tag some modalities option are now available.
And has a corresponding translation to call correct modality inside api.
  • Loading branch information
TheLLspectre authored Mar 18, 2024
1 parent b71efd1 commit 63d1744
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 10 deletions.
8 changes: 5 additions & 3 deletions package/Editor/Models/ModelsUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ private void UpdatePage()
{
continue;
}
pageModels.Add(models[i]);

pageModels.Add(models[i]);
}
numberPages = (models.Count / maxModelsPerPage) +1;
numberPages = (models.Count / maxModelsPerPage) + 1;

if (currentPage < numberPages)
{
Expand Down Expand Up @@ -196,6 +196,8 @@ private void DrawTextureBox(float boxWidth, float boxHeight, float rowPadding, L
if (globalIndex >= 0 && globalIndex < models.Count)
{
DataCache.instance.SelectedModelId = models[globalIndex].id;
DataCache.instance.SelectedModelType = models[globalIndex].type;

EditorPrefs.SetString("SelectedModelName", name);
}

Expand Down
2 changes: 1 addition & 1 deletion package/Editor/PromptWindow/PromptWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void PrepareAdvancedModalitySettings(out string modality, out string ope

if (promptWindowUI.selectedOptionIndex > 0)
{
string optionName = promptWindowUI.dropdownOptions[promptWindowUI.selectedOptionIndex - 1];
string optionName = promptWindowUI.correspondingOptionsValue[promptWindowUI.selectedOptionIndex - 1];
if (!modalitySettings.ContainsKey(optionName))
{
modalitySettings.Add(optionName, $"{promptWindowUI.sliderValue:0.00}");
Expand Down
41 changes: 38 additions & 3 deletions package/Editor/PromptWindow/PromptWindowUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,53 @@ public partial class PromptWindowUI

internal static Texture2D imageUpload;

/// <summary>
/// First dropdown options according to SDXL models
/// </summary>
public readonly string[] dropdownOptions =
{
"",
"Character",
"Landscape",
"Structure",
"Pose",
"Depth",
"Segmentation",
"Illusion"
};

/// <summary>
/// Seconds dropdown options according to SD 1.5 models
/// </summary>
public readonly string[] dropdownOptionsSD15 =
{
"City",
"Interior",
"Edges",
"Scribble",
"Normal Map",
"Line Art"
};

/// <summary>
/// Translation to api calling modalities options, treat previous values in the exact same order.
/// </summary>
public readonly string[] correspondingOptionsValue =
{
"",
"character",
"landscape",
"canny",
"pose",
"depth",
"lines",
"seg",
"illusion",
"city",
"interior",
"lines",
"scribble",
"lineart",
"normal-map",
"shuffle"
"lineart"
};

internal readonly string[] schedulerOptions = new string[] // Scheduler options extracted from your HTML
Expand Down
35 changes: 32 additions & 3 deletions package/Editor/PromptWindow/Views/ControlNetView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,38 @@ private void RenderControlNetFoldout()
GUILayout.BeginHorizontal();
GUILayout.Label("Modality :", EditorStyles.label);

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


if (!string.IsNullOrEmpty(DataCache.instance.SelectedModelType))
{
switch (DataCache.instance.SelectedModelType)
{
case "sd-xl-composition":
availableOptions.AddRange(dropdownOptions);
break;

case "sd-xl-lora":
availableOptions.AddRange(dropdownOptions);
break;

case "sd-xl":
availableOptions.AddRange(dropdownOptions);
break;

case "sd-1_5":
availableOptions.AddRange(dropdownOptions);
availableOptions.AddRange(dropdownOptionsSD15);
break;

default:
break;

}
}

//availableOptions.AddRange(dropdownOptions);
selectedOptionIndex = EditorGUILayout.Popup(selectedOptionIndex, availableOptions.ToArray());

if (selectedOptionIndex > 0)
{
Expand Down
10 changes: 10 additions & 0 deletions package/Editor/_Services/DataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace Scenario.Editor
/// </summary>
public class DataCache : ScriptableSingleton<DataCache>
{

public Models.ModelData SelectedModelData { get { return selectedModelData; } set { selectedModelData = value; } }
private Models.ModelData selectedModelData = null;

#region ImageDataList

[SerializeField] private List<ImageDataStorage.ImageData> imageDataList = new();
Expand Down Expand Up @@ -151,6 +155,12 @@ public string SelectedModelId
set => EditorPrefs.SetString("SelectedModelId", value);
}

public string SelectedModelType
{
get => EditorPrefs.GetString("SelectedModelType", "");
set => EditorPrefs.SetString("SelectedModelType", value);
}

public int GetReservedSpaceCount()
{
return imageDataList.Count(x => x.Id == "-1");
Expand Down

0 comments on commit 63d1744

Please sign in to comment.