更改了海报文案的机制
This commit is contained in:
parent
031062c8d0
commit
27a4168a64
Binary file not shown.
@ -334,8 +334,7 @@ class PosterGenerator:
|
|||||||
|
|
||||||
# 检查文字数据
|
# 检查文字数据
|
||||||
if text_data is None:
|
if text_data is None:
|
||||||
print("警告: 未提供文本数据,使用默认文本")
|
return text_layer
|
||||||
text_data = {'title': '旅游景点', 'subtitle': '', 'additional_texts': []}
|
|
||||||
|
|
||||||
print(f"处理文本数据: {text_data}")
|
print(f"处理文本数据: {text_data}")
|
||||||
|
|
||||||
|
|||||||
@ -5,14 +5,11 @@
|
|||||||
帐篷房+温泉+泳池!599解锁遛娃天堂
|
帐篷房+温泉+泳池!599解锁遛娃天堂
|
||||||
广东本地人爱去的温泉酒店被我挖到了!
|
广东本地人爱去的温泉酒店被我挖到了!
|
||||||
谁懂啊!!在惠州发现了温泉酒店卷王!
|
谁懂啊!!在惠州发现了温泉酒店卷王!
|
||||||
和男朋友去了5次惠州...温泉锁死这家♨️
|
|
||||||
99元住海景房🤯淡季海岛捡漏秘籍‼
|
99元住海景房🤯淡季海岛捡漏秘籍‼
|
||||||
没有人敢说惠州希尔顿酒店的事吗?
|
没有人敢说惠州希尔顿酒店的事吗?
|
||||||
五一反向旅行!齐云小镇住+玩含门票…💰399俩
|
五一反向旅行!齐云小镇住+玩含门票…💰399俩
|
||||||
乌镇免门票!住景区+早茶客+游船…才555💰俩
|
乌镇免门票!住景区+早茶客+游船…才555💰俩
|
||||||
99元住海景王座房‼错过等下辈子
|
99住海景王座房‼错过等下辈子
|
||||||
周末遛娃|安利冬日淡季两天一夜湖州亲子游,
|
|
||||||
人生建议:带娃去敦煌,一定要6-8月去❗️,
|
|
||||||
高铁亲子游🚄带娃在北海的三天两夜,附攻略,
|
高铁亲子游🚄带娃在北海的三天两夜,附攻略,
|
||||||
安吉!城堡酒店+helloKitty乐园2日票!💰688
|
安吉!城堡酒店+helloKitty乐园2日票!💰688
|
||||||
佛山遛娃!盈香心动乐园!💰399=住+2天畅玩!
|
佛山遛娃!盈香心动乐园!💰399=住+2天畅玩!
|
||||||
|
|||||||
2
main.py
2
main.py
@ -165,6 +165,7 @@ def generate_content_and_posters_step(config, run_id, topics_list, output_handle
|
|||||||
poster_filename = config.get("output_poster_filename", "poster.jpg")
|
poster_filename = config.get("output_poster_filename", "poster.jpg")
|
||||||
poster_content_system_prompt = config.get("poster_content_system_prompt", None)
|
poster_content_system_prompt = config.get("poster_content_system_prompt", None)
|
||||||
collage_style = config.get("collage_style", None)
|
collage_style = config.get("collage_style", None)
|
||||||
|
title_possibility = config.get("title_possibility", 0.3)
|
||||||
# 检查关键路径是否存在
|
# 检查关键路径是否存在
|
||||||
if not poster_assets_dir or not img_base_dir:
|
if not poster_assets_dir or not img_base_dir:
|
||||||
logging.error(f"Missing critical paths for poster generation (poster_assets_base_dir or image_base_dir) in config. Skipping posters for topic {topic_index}.")
|
logging.error(f"Missing critical paths for poster generation (poster_assets_base_dir or image_base_dir) in config. Skipping posters for topic {topic_index}.")
|
||||||
@ -182,6 +183,7 @@ def generate_content_and_posters_step(config, run_id, topics_list, output_handle
|
|||||||
output_handler=output_handler, # <--- 传递 Output Handler
|
output_handler=output_handler, # <--- 传递 Output Handler
|
||||||
# 传递具体参数
|
# 传递具体参数
|
||||||
variants=poster_variants,
|
variants=poster_variants,
|
||||||
|
title_possibility=title_possibility,
|
||||||
poster_assets_base_dir=poster_assets_dir,
|
poster_assets_base_dir=poster_assets_dir,
|
||||||
image_base_dir=img_base_dir,
|
image_base_dir=img_base_dir,
|
||||||
resource_dir_config=res_dir_config,
|
resource_dir_config=res_dir_config,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"date": "4月30日, 4月28日, 5月1日",
|
"date": "4月30日, 4月28日, 5月1日",
|
||||||
"num": 3,
|
"num": 8,
|
||||||
"variants": 2,
|
"variants": 5,
|
||||||
"topic_temperature": 0.2,
|
"topic_temperature": 0.2,
|
||||||
"topic_top_p": 0.3,
|
"topic_top_p": 0.3,
|
||||||
"topic_presence_penalty": 1.5,
|
"topic_presence_penalty": 1.5,
|
||||||
@ -70,6 +70,7 @@
|
|||||||
900,
|
900,
|
||||||
1200
|
1200
|
||||||
],
|
],
|
||||||
|
"title_possibility": 0.3,
|
||||||
"text_possibility": 0.3,
|
"text_possibility": 0.3,
|
||||||
"img_frame_possibility": 0,
|
"img_frame_possibility": 0,
|
||||||
"text_bg_possibility": 0,
|
"text_bg_possibility": 0,
|
||||||
|
|||||||
Binary file not shown.
@ -448,9 +448,10 @@ def generate_posters_for_topic(topic_item: dict,
|
|||||||
image_base_dir: str,
|
image_base_dir: str,
|
||||||
img_frame_possibility: float,
|
img_frame_possibility: float,
|
||||||
text_bg_possibility: float,
|
text_bg_possibility: float,
|
||||||
|
title_possibility: float,
|
||||||
|
text_possibility: float,
|
||||||
resource_dir_config: list,
|
resource_dir_config: list,
|
||||||
poster_target_size: tuple,
|
poster_target_size: tuple,
|
||||||
text_possibility: float,
|
|
||||||
output_collage_subdir: str,
|
output_collage_subdir: str,
|
||||||
output_poster_subdir: str,
|
output_poster_subdir: str,
|
||||||
output_poster_filename: str,
|
output_poster_filename: str,
|
||||||
@ -649,21 +650,20 @@ def generate_posters_for_topic(topic_item: dict,
|
|||||||
# --- 结束保存 Collage ---
|
# --- 结束保存 Collage ---
|
||||||
|
|
||||||
# --- Create Poster ---
|
# --- Create Poster ---
|
||||||
text_data = {
|
if random.random() < title_possibility:
|
||||||
|
text_data = {
|
||||||
"title": poster_config.get('main_title', 'Default Title'),
|
"title": poster_config.get('main_title', 'Default Title'),
|
||||||
"subtitle": "",
|
"subtitle": "",
|
||||||
"additional_texts": []
|
"additional_texts": []
|
||||||
}
|
}
|
||||||
texts = poster_config.get('texts', [])
|
texts = poster_config.get('texts', [])
|
||||||
if texts:
|
if texts:
|
||||||
# 确保文本不为空
|
# 确保文本不为空
|
||||||
if texts[0]:
|
for text in texts:
|
||||||
text_data["additional_texts"].append({"text": texts[0], "position": "middle", "size_factor": 0.8})
|
if random.random() < text_possibility:
|
||||||
|
text_data["additional_texts"].append({"text": text, "position": "middle", "size_factor": 0.8})
|
||||||
# 添加第二个文本(如果有并且满足随机条件)
|
else:
|
||||||
if len(texts) > 1 and texts[1] and random.random() < text_possibility:
|
text_data = None
|
||||||
text_data["additional_texts"].append({"text": texts[1], "position": "middle", "size_factor": 0.8})
|
|
||||||
|
|
||||||
# 打印要发送的文本数据
|
# 打印要发送的文本数据
|
||||||
logging.info(f"文本数据: {text_data}")
|
logging.info(f"文本数据: {text_data}")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user