Refactor AIImages mod to replace ArtStyle enum with ArtStyleDef name for improved flexibility in prompt generation. Update UI components to reflect changes in art style selection and enhance scrolling functionality in the right column. Update AIImages.dll to incorporate the latest modifications.
This commit is contained in:
@@ -34,25 +34,6 @@ namespace AIImages.Services
|
||||
{ "Pretty", "attractive features, pleasant appearance, charming" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<ArtStyle, string> ArtStylePrompts = new Dictionary<
|
||||
ArtStyle,
|
||||
string
|
||||
>
|
||||
{
|
||||
{ ArtStyle.None, "" },
|
||||
{ ArtStyle.Realistic, "photorealistic, hyperrealistic, realistic photo, photography" },
|
||||
{ ArtStyle.SemiRealistic, "semi-realistic, detailed illustration, realistic art" },
|
||||
{ ArtStyle.Anime, "anime style, manga style, anime character" },
|
||||
{
|
||||
ArtStyle.ConceptArt,
|
||||
"concept art, digital art, artstation, professional concept design"
|
||||
},
|
||||
{ ArtStyle.DigitalPainting, "digital painting, painterly, brush strokes, artistic" },
|
||||
{ ArtStyle.OilPainting, "oil painting, traditional painting, canvas, fine art" },
|
||||
{ ArtStyle.Sketch, "pencil sketch, hand drawn, sketch art, line art" },
|
||||
{ ArtStyle.CellShaded, "cell shaded, flat colors, toon shading, stylized" },
|
||||
};
|
||||
|
||||
public string GeneratePositivePrompt(
|
||||
PawnAppearanceData appearanceData,
|
||||
StableDiffusionSettings settings
|
||||
@@ -66,17 +47,15 @@ namespace AIImages.Services
|
||||
// 1. Базовый пользовательский промпт (если указан) - идет первым
|
||||
if (!string.IsNullOrEmpty(settings.PositivePrompt))
|
||||
{
|
||||
prompt.Append(settings.PositivePrompt);
|
||||
prompt.Append(settings.PositivePrompt.TrimEnd(',', ' '));
|
||||
prompt.Append(", ");
|
||||
}
|
||||
|
||||
// 2. Художественный стиль
|
||||
if (
|
||||
ArtStylePrompts.TryGetValue(settings.ArtStyle, out string stylePrompt)
|
||||
&& !string.IsNullOrEmpty(stylePrompt)
|
||||
)
|
||||
var styleDef = DefDatabase<ArtStyleDef>.GetNamedSilentFail(settings.ArtStyleDefName);
|
||||
if (styleDef != null && !string.IsNullOrEmpty(styleDef.positivePrompt))
|
||||
{
|
||||
prompt.Append(stylePrompt);
|
||||
prompt.Append(styleDef.positivePrompt);
|
||||
prompt.Append(", ");
|
||||
}
|
||||
|
||||
@@ -127,7 +106,7 @@ namespace AIImages.Services
|
||||
}
|
||||
|
||||
// 10. Качественные теги
|
||||
prompt.Append(GetQualityTags(settings.ArtStyle));
|
||||
prompt.Append(GetQualityTags(settings.ArtStyleDefName));
|
||||
|
||||
return prompt.ToString().Trim().TrimEnd(',');
|
||||
}
|
||||
@@ -139,34 +118,38 @@ namespace AIImages.Services
|
||||
// 1. Пользовательский негативный промпт (если указан) - идет первым
|
||||
if (!string.IsNullOrEmpty(settings.NegativePrompt))
|
||||
{
|
||||
negativePrompt.Append(settings.NegativePrompt);
|
||||
negativePrompt.Append(", ");
|
||||
negativePrompt.Append(settings.NegativePrompt.TrimEnd(',', ' '));
|
||||
}
|
||||
|
||||
// Получаем стиль из Def
|
||||
var styleDef = DefDatabase<ArtStyleDef>.GetNamedSilentFail(settings.ArtStyleDefName);
|
||||
if (styleDef == null || !styleDef.addBaseNegativePrompts)
|
||||
{
|
||||
// Для стилей без базовых негативов - используем только пользовательский промпт
|
||||
return negativePrompt.ToString().Trim();
|
||||
}
|
||||
|
||||
// 2. Базовые негативные промпты
|
||||
if (negativePrompt.Length > 0)
|
||||
{
|
||||
negativePrompt.Append(", ");
|
||||
}
|
||||
|
||||
negativePrompt.Append(
|
||||
"ugly, deformed, low quality, blurry, bad anatomy, worst quality, "
|
||||
);
|
||||
negativePrompt.Append(
|
||||
"mutated, disfigured, bad proportions, extra limbs, missing limbs, "
|
||||
"mutated, disfigured, bad proportions, extra limbs, missing limbs"
|
||||
);
|
||||
|
||||
// 3. Специфичные для стиля негативы
|
||||
switch (settings.ArtStyle)
|
||||
// 3. Специфичные для стиля негативы из Def
|
||||
if (!string.IsNullOrEmpty(styleDef.negativePrompt))
|
||||
{
|
||||
case ArtStyle.Realistic:
|
||||
case ArtStyle.SemiRealistic:
|
||||
negativePrompt.Append("cartoon, anime, painting, drawing, illustration, ");
|
||||
break;
|
||||
case ArtStyle.Anime:
|
||||
negativePrompt.Append("realistic, photo, photography, 3d, ");
|
||||
break;
|
||||
case ArtStyle.None:
|
||||
// Без дополнительных негативных промптов для стиля None
|
||||
break;
|
||||
negativePrompt.Append(", ");
|
||||
negativePrompt.Append(styleDef.negativePrompt);
|
||||
}
|
||||
|
||||
return negativePrompt.ToString().Trim().TrimEnd(',');
|
||||
return negativePrompt.ToString().Trim();
|
||||
}
|
||||
|
||||
public string GetFullPromptDescription(
|
||||
@@ -317,24 +300,33 @@ namespace AIImages.Services
|
||||
return apparelDesc.ToString();
|
||||
}
|
||||
|
||||
private string GetQualityTags(ArtStyle style)
|
||||
private string GetQualityTags(string styleDefName)
|
||||
{
|
||||
var baseTags = "highly detailed, professional, masterpiece, best quality";
|
||||
|
||||
switch (style)
|
||||
var styleDef = DefDatabase<ArtStyleDef>.GetNamedSilentFail(styleDefName);
|
||||
if (styleDef == null)
|
||||
{
|
||||
case ArtStyle.None:
|
||||
return baseTags;
|
||||
case ArtStyle.Realistic:
|
||||
case ArtStyle.SemiRealistic:
|
||||
return $"{baseTags}, professional photography, 8k uhd, dslr, high quality, sharp focus";
|
||||
case ArtStyle.Anime:
|
||||
return $"{baseTags}, anime masterpiece, high resolution, vibrant colors";
|
||||
case ArtStyle.ConceptArt:
|
||||
return $"{baseTags}, trending on artstation, professional digital art";
|
||||
default:
|
||||
return baseTags;
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder tags = new StringBuilder();
|
||||
|
||||
// Базовые теги качества
|
||||
if (styleDef.addBaseQualityTags)
|
||||
{
|
||||
tags.Append("highly detailed, professional, masterpiece, best quality");
|
||||
}
|
||||
|
||||
// Специфичные для стиля теги качества
|
||||
if (!string.IsNullOrEmpty(styleDef.qualityTags))
|
||||
{
|
||||
if (tags.Length > 0)
|
||||
{
|
||||
tags.Append(", ");
|
||||
}
|
||||
tags.Append(styleDef.qualityTags);
|
||||
}
|
||||
|
||||
return tags.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user