Batch処理
This commit is contained in:
+95
-17
@@ -11,11 +11,12 @@ from bpy.types import Panel
|
||||
|
||||
from ..core.async_bake_generator import get_bake_generator
|
||||
from ..core.async_generator import get_generator
|
||||
from ..core.batch_processor import get_batch_processor
|
||||
from ..core.utils import (
|
||||
get_server_status,
|
||||
get_cache_info,
|
||||
format_size,
|
||||
get_detections_path_for_strip,
|
||||
check_detection_cache,
|
||||
)
|
||||
|
||||
|
||||
@@ -35,9 +36,15 @@ class SEQUENCER_PT_face_mask(Panel):
|
||||
seq_editor = context.scene.sequence_editor
|
||||
# Note: Blender 5.0 uses 'strips' instead of 'sequences'
|
||||
|
||||
batch = get_batch_processor()
|
||||
generator = get_generator()
|
||||
bake_generator = get_bake_generator()
|
||||
|
||||
# Batch progress (highest priority)
|
||||
if batch.is_running:
|
||||
self._draw_batch_progress(layout, wm, batch, generator, bake_generator)
|
||||
return
|
||||
|
||||
# Show progress if generating masks
|
||||
if generator.is_running:
|
||||
self._draw_progress(layout, wm, generator)
|
||||
@@ -65,6 +72,7 @@ class SEQUENCER_PT_face_mask(Panel):
|
||||
self._draw_parameters(layout, scene)
|
||||
self._draw_server_status(layout)
|
||||
self._draw_cache_info(layout, context, seq_editor)
|
||||
self._draw_batch_controls(layout, context, seq_editor)
|
||||
|
||||
def _draw_parameters(self, layout, scene):
|
||||
"""Draw detection parameters."""
|
||||
@@ -181,7 +189,75 @@ class SEQUENCER_PT_face_mask(Panel):
|
||||
text="Cancel",
|
||||
icon='CANCEL',
|
||||
)
|
||||
|
||||
|
||||
def _draw_batch_progress(self, layout, wm, batch, generator, bake_generator):
|
||||
"""Draw batch bake progress."""
|
||||
box = layout.box()
|
||||
if batch._mode == "mask_only":
|
||||
box.label(text="Batch Generating Cache...", icon='RENDER_ANIMATION')
|
||||
else:
|
||||
box.label(text="Batch Baking...", icon='RENDER_ANIMATION')
|
||||
|
||||
# Overall progress
|
||||
total = max(wm.batch_total, 1)
|
||||
# Show n-1/total while current strip is in progress, n/total when moving to next
|
||||
done_count = max(wm.batch_current - 1, 0)
|
||||
overall_factor = done_count / total
|
||||
box.progress(
|
||||
factor=overall_factor,
|
||||
text=f"{wm.batch_current} / {wm.batch_total}",
|
||||
)
|
||||
|
||||
if wm.batch_current_name:
|
||||
box.label(text=f"Strip: {wm.batch_current_name}")
|
||||
|
||||
# Inner progress (mask gen or bake)
|
||||
if generator.is_running:
|
||||
inner = wm.mask_progress / max(wm.mask_total, 1)
|
||||
box.progress(
|
||||
factor=inner,
|
||||
text=f"Detecting: {wm.mask_progress} / {wm.mask_total}",
|
||||
)
|
||||
elif bake_generator.is_running:
|
||||
inner = wm.bake_progress / max(wm.bake_total, 1)
|
||||
box.progress(
|
||||
factor=inner,
|
||||
text=f"Baking: {wm.bake_progress} / {wm.bake_total}",
|
||||
)
|
||||
|
||||
box.operator(
|
||||
"sequencer.cancel_batch_bake",
|
||||
text="Cancel Batch",
|
||||
icon='CANCEL',
|
||||
)
|
||||
|
||||
def _draw_batch_controls(self, layout, context, seq_editor):
|
||||
"""Draw batch bake button when multiple MOVIE strips are selected."""
|
||||
if not seq_editor:
|
||||
return
|
||||
selected_movies = [s for s in seq_editor.strips if s.select and s.type == "MOVIE"]
|
||||
if not selected_movies:
|
||||
return
|
||||
count = len(selected_movies)
|
||||
label = f"Batch ({count} strip{'s' if count > 1 else ''} selected)"
|
||||
box = layout.box()
|
||||
box.label(text=label, icon='RENDER_ANIMATION')
|
||||
box.operator(
|
||||
"sequencer.batch_bake_selected",
|
||||
text="Batch Bake Selected",
|
||||
icon='RENDER_ANIMATION',
|
||||
)
|
||||
box.operator(
|
||||
"sequencer.batch_regenerate_cache",
|
||||
text="Batch Regenerate Cache",
|
||||
icon='FILE_REFRESH',
|
||||
)
|
||||
box.operator(
|
||||
"sequencer.batch_restore_original",
|
||||
text="Batch Restore Original",
|
||||
icon='LOOP_BACK',
|
||||
)
|
||||
|
||||
def _draw_generation_controls(self, layout, context, strip):
|
||||
"""Draw mask generation controls."""
|
||||
box = layout.box()
|
||||
@@ -191,31 +267,33 @@ class SEQUENCER_PT_face_mask(Panel):
|
||||
row = box.row()
|
||||
row.label(text=f"Strip: {strip.name}")
|
||||
|
||||
detections_path = get_detections_path_for_strip(strip.name)
|
||||
has_mask = bpy.path.abspath(detections_path) and os.path.exists(
|
||||
bpy.path.abspath(detections_path)
|
||||
)
|
||||
|
||||
has_mask = check_detection_cache(strip.name)
|
||||
|
||||
if has_mask:
|
||||
row = box.row()
|
||||
row.label(text="✓ Detection cache exists", icon='CHECKMARK')
|
||||
|
||||
# Generate button
|
||||
box.operator(
|
||||
"sequencer.generate_face_mask",
|
||||
text="Generate Detection Cache" if not has_mask else "Regenerate Cache",
|
||||
icon='FACE_MAPS',
|
||||
)
|
||||
# Generate / Regenerate button
|
||||
if not has_mask:
|
||||
box.operator(
|
||||
"sequencer.generate_face_mask",
|
||||
text="Generate Detection Cache",
|
||||
icon='FACE_MAPS',
|
||||
)
|
||||
else:
|
||||
op = box.operator(
|
||||
"sequencer.generate_face_mask",
|
||||
text="Regenerate Cache",
|
||||
icon='FILE_REFRESH',
|
||||
)
|
||||
op.force = True
|
||||
|
||||
def _draw_blur_controls(self, layout, context, strip):
|
||||
"""Draw blur application controls."""
|
||||
box = layout.box()
|
||||
box.label(text="Blur Bake", icon='MATFLUID')
|
||||
|
||||
detections_path = get_detections_path_for_strip(strip.name)
|
||||
has_mask = bpy.path.abspath(detections_path) and os.path.exists(
|
||||
bpy.path.abspath(detections_path)
|
||||
)
|
||||
has_mask = check_detection_cache(strip.name)
|
||||
|
||||
if not has_mask:
|
||||
box.label(text="Generate detection cache first", icon='INFO')
|
||||
|
||||
Reference in New Issue
Block a user