diff --git a/core/__pycache__/poster_gen.cpython-312.pyc b/core/__pycache__/poster_gen.cpython-312.pyc index 02febf6..3cbbba7 100644 Binary files a/core/__pycache__/poster_gen.cpython-312.pyc and b/core/__pycache__/poster_gen.cpython-312.pyc differ diff --git a/core/poster_gen.py b/core/poster_gen.py index 01bd012..84410ea 100644 --- a/core/poster_gen.py +++ b/core/poster_gen.py @@ -334,8 +334,7 @@ class PosterGenerator: # 检查文字数据 if text_data is None: - print("警告: 未提供文本数据,使用默认文本") - text_data = {'title': '旅游景点', 'subtitle': '', 'additional_texts': []} + return text_layer print(f"处理文本数据: {text_data}") diff --git a/genPrompts/Refer/标题参考格式.txt b/genPrompts/Refer/标题参考格式.txt index 530e772..0e4ea38 100644 --- a/genPrompts/Refer/标题参考格式.txt +++ b/genPrompts/Refer/标题参考格式.txt @@ -5,14 +5,11 @@ 帐篷房+温泉+泳池!599解锁遛娃天堂 广东本地人爱去的温泉酒店被我挖到了! 谁懂啊!!在惠州发现了温泉酒店卷王! -和男朋友去了5次惠州...温泉锁死这家♨️ 99元住海景房🤯淡季海岛捡漏秘籍‼ 没有人敢说惠州希尔顿酒店的事吗? 五一反向旅行!齐云小镇住+玩含门票…💰399俩 乌镇免门票!住景区+早茶客+游船…才555💰俩 -99元住海景王座房‼错过等下辈子 -周末遛娃|安利冬日淡季两天一夜湖州亲子游, -人生建议:带娃去敦煌,一定要6-8月去❗️, +99住海景王座房‼错过等下辈子 高铁亲子游🚄带娃在北海的三天两夜,附攻略, 安吉!城堡酒店+helloKitty乐园2日票!💰688 佛山遛娃!盈香心动乐园!💰399=住+2天畅玩! diff --git a/main.py b/main.py index f30f2d1..9a5590e 100644 --- a/main.py +++ b/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_content_system_prompt = config.get("poster_content_system_prompt", 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: 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 # 传递具体参数 variants=poster_variants, + title_possibility=title_possibility, poster_assets_base_dir=poster_assets_dir, image_base_dir=img_base_dir, resource_dir_config=res_dir_config, diff --git a/poster_gen_config.json b/poster_gen_config.json index 2d23cd3..777a595 100644 --- a/poster_gen_config.json +++ b/poster_gen_config.json @@ -1,7 +1,7 @@ { "date": "4月30日, 4月28日, 5月1日", - "num": 3, - "variants": 2, + "num": 8, + "variants": 5, "topic_temperature": 0.2, "topic_top_p": 0.3, "topic_presence_penalty": 1.5, @@ -70,6 +70,7 @@ 900, 1200 ], + "title_possibility": 0.3, "text_possibility": 0.3, "img_frame_possibility": 0, "text_bg_possibility": 0, diff --git a/utils/__pycache__/tweet_generator.cpython-312.pyc b/utils/__pycache__/tweet_generator.cpython-312.pyc index 3d274b0..7bc31c9 100644 Binary files a/utils/__pycache__/tweet_generator.cpython-312.pyc and b/utils/__pycache__/tweet_generator.cpython-312.pyc differ diff --git a/utils/tweet_generator.py b/utils/tweet_generator.py index 44a6302..9b39eec 100644 --- a/utils/tweet_generator.py +++ b/utils/tweet_generator.py @@ -448,9 +448,10 @@ def generate_posters_for_topic(topic_item: dict, image_base_dir: str, img_frame_possibility: float, text_bg_possibility: float, + title_possibility: float, + text_possibility: float, resource_dir_config: list, poster_target_size: tuple, - text_possibility: float, output_collage_subdir: str, output_poster_subdir: str, output_poster_filename: str, @@ -649,21 +650,20 @@ def generate_posters_for_topic(topic_item: dict, # --- 结束保存 Collage --- # --- Create Poster --- - text_data = { + if random.random() < title_possibility: + text_data = { "title": poster_config.get('main_title', 'Default Title'), "subtitle": "", "additional_texts": [] - } - texts = poster_config.get('texts', []) - if texts: - # 确保文本不为空 - if texts[0]: - text_data["additional_texts"].append({"text": texts[0], "position": "middle", "size_factor": 0.8}) - - # 添加第二个文本(如果有并且满足随机条件) - if len(texts) > 1 and texts[1] and random.random() < text_possibility: - text_data["additional_texts"].append({"text": texts[1], "position": "middle", "size_factor": 0.8}) - + } + texts = poster_config.get('texts', []) + if texts: + # 确保文本不为空 + for text in texts: + if random.random() < text_possibility: + text_data["additional_texts"].append({"text": text, "position": "middle", "size_factor": 0.8}) + else: + text_data = None # 打印要发送的文本数据 logging.info(f"文本数据: {text_data}")