diff --git a/.github/workflows/dockerImageBuild.yml b/.github/workflows/dockerImageBuild.yml index 3089eb0..6c4755e 100644 --- a/.github/workflows/dockerImageBuild.yml +++ b/.github/workflows/dockerImageBuild.yml @@ -3,6 +3,7 @@ name: build_docker on: release: types: [created] # 表示在创建新的 Release 时触发 + workflow_dispatch: jobs: build_docker: diff --git a/app/utils/vision_analyzer.py b/app/utils/vision_analyzer.py index 8024729..06342d7 100644 --- a/app/utils/vision_analyzer.py +++ b/app/utils/vision_analyzer.py @@ -55,7 +55,7 @@ class VisionAnalyzer: async def analyze_images(self, images: Union[List[str], List[PIL.Image.Image]], prompt: str, - batch_size: int = 5) -> List[Dict]: + batch_size: int) -> List[Dict]: """批量分析多张图片""" try: # 加载图片 @@ -82,6 +82,8 @@ class VisionAnalyzer: results = [] total_batches = (len(images) + batch_size - 1) // batch_size + logger.debug(f"共 {total_batches} 个批次,每批次 {batch_size} 张图片") + with tqdm(total=total_batches, desc="分析进度") as pbar: for i in range(0, len(images), batch_size): batch = images[i:i + batch_size] diff --git a/webui/components/script_settings.py b/webui/components/script_settings.py index e10bd93..8dfa10b 100644 --- a/webui/components/script_settings.py +++ b/webui/components/script_settings.py @@ -417,11 +417,12 @@ def generate_script(tr, params): asyncio.set_event_loop(loop) # 执行异步分析 + vision_batch_size = st.session_state.get('vision_batch_size') or config.frames.get("vision_batch_size") results = loop.run_until_complete( analyzer.analyze_images( images=keyframe_files, prompt=config.app.get('vision_analysis_prompt'), - batch_size=config.frames.get("vision_batch_size", st.session_state.get('vision_batch_size', 5)) + batch_size=vision_batch_size ) ) loop.close() @@ -437,8 +438,8 @@ def generate_script(tr, params): if 'error' in result: logger.warning(f"批次 {result['batch_index']} 处理出现警告: {result['error']}") continue - - batch_files = get_batch_files(keyframe_files, result, config.frames.get("vision_batch_size", 5)) + # 获取当前批次的文件列表 + batch_files = get_batch_files(keyframe_files, result, vision_batch_size) logger.debug(f"批次 {result['batch_index']} 处理完成,共 {len(batch_files)} 张图片") logger.debug(batch_files) @@ -477,7 +478,7 @@ def generate_script(tr, params): if 'error' in result: continue - batch_files = get_batch_files(keyframe_files, result, config.frames.get("vision_batch_size", 5)) + batch_files = get_batch_files(keyframe_files, result, vision_batch_size) _, _, timestamp_range = get_batch_timestamps(batch_files, prev_batch_files) frame_content = {