修复种草图生成:以三合一主图为参考 img2img 生成,按颜色分配(每色优先、超出随机补足);新增 BR/CA/DE/ES/IT/PL/SA 七国配置与提示词;删除验证用测试脚本

This commit is contained in:
2026-08-24 14:02:19 +08:00
parent f493bde8a9
commit 3c341d2e78
51 changed files with 2571 additions and 514 deletions
+15 -6
View File
@@ -8,7 +8,8 @@
4. 用完全用:池中种子数 ≤ 需要数时全部使用(不再随机限量/截断);
5. 每个国家独立配置:configs/countries/<country>.yaml 的 style.seeds / related.seed_keywords。
limit 由 seed_node 从 context 注入max_style_seeds / max_related_seeds0 或缺失=不限)。
limit 由 seed_node 从 context 注入max_seeds(单一总量,不再按类型分,从统一池随机抽后均分
style/related);兼容旧参数 max_style_seeds / max_related_seeds0 或缺失=不限)。
LLM 后端生成失败时自动回退到静态+节日主题,保证不中断。
"""
import random
@@ -87,14 +88,22 @@ class DynamicStrategy(SeedStrategy):
add(dyn_related, 1.0, "dynamic")
items = list(pool.values())
limit_total = int(context.get("max_seeds") or 0)
limit_style = int(context.get("max_style_seeds") or 0)
limit_related = int(context.get("max_related_seeds") or 0)
# 2) 每次随机取(加权,不重复);池不足 → 全部用
style_pick = _weighted_sample(items, limit_style)
style_keys = {id(it) for it in style_pick}
remaining = [it for it in items if id(it) not in style_keys]
related_pick = _weighted_sample(remaining, limit_related)
if limit_total > 0:
# 不再按类型分:从统一池随机抽 max_seeds 个,均分到 style/related(各约一半)
pick = _weighted_sample(items, limit_total)
half = (len(pick) + 1) // 2
style_pick = pick[:half]
related_pick = pick[half:]
else:
# 兼容旧参数(max_style_seeds / max_related_seeds 分别限量)
style_pick = _weighted_sample(items, limit_style)
style_keys = {id(it) for it in style_pick}
remaining = [it for it in items if id(it) not in style_keys]
related_pick = _weighted_sample(remaining, limit_related)
return {
"style_seeds": [it["word"] for it in style_pick],