Enhance AIImages mod by adding scheduler support and updating UI for improved model and sampler selection. Localized strings in English and Russian have been updated for clarity. Update AIImages.dll to reflect changes in functionality.
This commit is contained in:
@@ -50,6 +50,7 @@ namespace AIImages.Services
|
||||
width = request.Width,
|
||||
height = request.Height,
|
||||
sampler_name = request.Sampler,
|
||||
scheduler = request.Scheduler,
|
||||
seed = request.Seed,
|
||||
save_images = false,
|
||||
send_images = true,
|
||||
@@ -186,6 +187,38 @@ namespace AIImages.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetAvailableSchedulers(string apiEndpoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
string endpoint = $"{apiEndpoint}/sdapi/v1/schedulers";
|
||||
HttpResponseMessage response = await httpClient.GetAsync(endpoint);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return GetDefaultSchedulers();
|
||||
|
||||
string jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
var schedulers = JsonConvert.DeserializeObject<List<SdScheduler>>(jsonResponse);
|
||||
|
||||
var schedulerNames = new List<string>();
|
||||
if (schedulers != null)
|
||||
{
|
||||
foreach (var scheduler in schedulers)
|
||||
{
|
||||
schedulerNames.Add(scheduler.name);
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[AI Images] Found {schedulerNames.Count} schedulers");
|
||||
return schedulerNames;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning($"[AI Images] Failed to load schedulers: {ex.Message}");
|
||||
return GetDefaultSchedulers();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetDefaultSamplers()
|
||||
{
|
||||
return new List<string>
|
||||
@@ -212,6 +245,19 @@ namespace AIImages.Services
|
||||
};
|
||||
}
|
||||
|
||||
private List<string> GetDefaultSchedulers()
|
||||
{
|
||||
return new List<string>
|
||||
{
|
||||
"Automatic",
|
||||
"Uniform",
|
||||
"Karras",
|
||||
"Exponential",
|
||||
"Polyexponential",
|
||||
"SGM Uniform",
|
||||
};
|
||||
}
|
||||
|
||||
// Вспомогательные классы для десериализации JSON ответов
|
||||
#pragma warning disable S3459, S1144 // Properties set by JSON deserializer
|
||||
private sealed class Txt2ImgResponse
|
||||
@@ -229,6 +275,11 @@ namespace AIImages.Services
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
private sealed class SdScheduler
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
#pragma warning restore S3459, S1144
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user