Bild Model Auswahl

This commit is contained in:
Simon Lübeß
2023-10-22 15:16:05 +02:00
parent 08bc1e4baa
commit 91b644501a
3 changed files with 80 additions and 29 deletions

View File

@ -12,7 +12,7 @@ public class ImageGenerator
private readonly IConfiguration _config;
private string ModelName => _config.GetValue<string>("StableDiffusionModel") ?? "No Model Defined";
//private string ModelName => _config.GetValue<string>("StableDiffusionModel") ?? "No Model Defined";
public ImageGenerator(IConfiguration config, BildInfoData bildInfoData)
{
@ -34,7 +34,7 @@ public class ImageGenerator
/// <param name="height">Die höhe des zu generierenden Bildes. <see langword="null"/> für Standardhöhe des Modells</param>
/// <param name="negativePromt">Begriffe, die explizit nicht generiert werden sollen.</param>
/// <returns>Die BildInfo des generierten Bildes; oder null, wenn ein Fehler auftrat.</returns>
public async Task<BildInfoModel?> GenerateImageAsync(string imagePrompt, WunschInfoModel wunschInfo, int? width = null, int? height = null, string negativePromt = "")
public async Task<BildInfoModel?> GenerateImageAsync(string imagePrompt, string modelName, WunschInfoModel wunschInfo, int? width = null, int? height = null, string negativePromt = "")
{
var postData = new
{
@ -60,7 +60,7 @@ public class ImageGenerator
try
{
var inferenceModelUrl = $"https://api-inference.huggingface.co/models/{ModelName}";
var inferenceModelUrl = $"https://api-inference.huggingface.co/models/{modelName}";
var response = await _client.PostAsync(inferenceModelUrl, content);
@ -75,7 +75,7 @@ public class ImageGenerator
// Die tatsächliche Url wird in SaveImageStreamAsync gesetzt.
Dateiname = "PlaceHolder",
Datum = imageDate,
ImageModel = ModelName,
ImageModel = modelName,
WunschId = wunschInfo.Id,
Prompt = imagePrompt
};