diff --git a/SelectPrompt/2025各月节日宣传节点时间表.md b/SelectPrompt/2025各月节日宣传节点时间表.md index ed99f83..91e88eb 100644 --- a/SelectPrompt/2025各月节日宣传节点时间表.md +++ b/SelectPrompt/2025各月节日宣传节点时间表.md @@ -84,7 +84,3 @@ **说明**: - 调休影响:春节(1月26日周日、2月8日周六上班)、劳动节(4月27日周日上班)、国庆节(9月28日周日、10月11日周六上班),表中已排除调休日。 - ---- - -以上信息整合自国务院官方通知及多平台公开日历,建议结合具体行业需求调整活动节奏。 \ No newline at end of file diff --git a/core/__pycache__/posterGen.cpython-312.pyc b/core/__pycache__/posterGen.cpython-312.pyc index 027d971..458ef97 100644 Binary files a/core/__pycache__/posterGen.cpython-312.pyc and b/core/__pycache__/posterGen.cpython-312.pyc differ diff --git a/core/posterGen.py b/core/posterGen.py index 7555bc9..9243446 100644 --- a/core/posterGen.py +++ b/core/posterGen.py @@ -812,11 +812,11 @@ class PosterGenerator: traceback.print_exc() return None - def process_directory(self, input_dir, text_data=None): - """处理目录中的所有图片并为每张图片生成海报""" - # ... (此函数可能不再需要,或者需要重构以适应新的流程) ... - pass + def set_img_frame_possibility(self, img_frame_possibility): + self.img_frame_posbility = img_frame_possibility + def set_text_bg_possibility(self, text_bg_possibility): + self.text_bg_posbility = text_bg_possibility def main(): # 设置是否使用文本框底图(True为使用,False为不使用) diff --git a/main.py b/main.py index 5a8a6b9..7428c80 100644 --- a/main.py +++ b/main.py @@ -152,17 +152,23 @@ def generate_content_and_posters_step(config, run_id, topics_list, output_handle res_dir_config = config.get("resource_dir", []) poster_size = tuple(config.get("poster_target_size", [900, 1200])) txt_possibility = config.get("text_possibility", 0.3) + img_frame_possibility = config.get("img_frame_possibility", 0.7) + text_bg_possibility = config.get("text_bg_possibility", 0) collage_subdir = config.get("output_collage_subdir", "collage_img") poster_subdir = config.get("output_poster_subdir", "poster") poster_filename = config.get("output_poster_filename", "poster.jpg") cam_img_subdir = config.get("camera_image_subdir", "相机") poster_content_system_prompt = config.get("poster_content_system_prompt", None) + # 检查关键路径是否存在 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}.") continue # 跳过此主题的海报生成 # --- 结束读取参数 --- + with open(poster_content_system_prompt, "r", encoding="utf-8") as f: + poster_content_system_prompt = f.read() + posters_attempted = generate_posters_for_topic( topic_item=topic_item, output_dir=config["output_dir"], # Base output dir is still needed @@ -177,6 +183,8 @@ def generate_content_and_posters_step(config, run_id, topics_list, output_handle resource_dir_config=res_dir_config, poster_target_size=poster_size, text_possibility=txt_possibility, + img_frame_possibility=img_frame_possibility, + text_bg_possibility=text_bg_possibility, output_collage_subdir=collage_subdir, output_poster_subdir=poster_subdir, output_poster_filename=poster_filename, diff --git a/poster_gen_config.json b/poster_gen_config.json index 1c6d1b2..b091931 100644 --- a/poster_gen_config.json +++ b/poster_gen_config.json @@ -55,5 +55,7 @@ 900, 1200 ], - "text_possibility": 0.3 + "text_possibility": 0.3, + "img_frame_possibility": 0, + "text_bg_possibility": 0 } \ No newline at end of file diff --git a/utils/__pycache__/tweet_generator.cpython-312.pyc b/utils/__pycache__/tweet_generator.cpython-312.pyc index 9b0d56e..79d3e87 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 5ea5af1..2a6eecc 100644 --- a/utils/tweet_generator.py +++ b/utils/tweet_generator.py @@ -445,6 +445,8 @@ def generate_posters_for_topic(topic_item: dict, poster_assets_base_dir: str, image_base_dir: str, modify_image_subdir: str, + img_frame_possibility: float, + text_bg_possibility: float, resource_dir_config: list, poster_target_size: tuple, text_possibility: float, @@ -517,6 +519,8 @@ def generate_posters_for_topic(topic_item: dict, logging.error("Error: 'poster_assets_base_dir' not provided. Cannot generate posters.") return False poster_gen_instance = core_posterGen.PosterGenerator(base_dir=poster_assets_base_dir) + poster_gen_instance.set_img_frame_possibility(img_frame_possibility) + poster_gen_instance.set_text_bg_possibility(text_bg_possibility) except Exception as e: logging.exception("Error initializing generators for poster creation:") return False