feat: 中間データのmsgpack移行
This commit is contained in:
@@ -29,7 +29,7 @@ class AsyncBakeGenerator:
|
||||
def start(
|
||||
self,
|
||||
video_path: str,
|
||||
mask_path: str,
|
||||
detections_path: str,
|
||||
output_path: str,
|
||||
blur_size: int,
|
||||
fmt: str,
|
||||
@@ -53,7 +53,7 @@ class AsyncBakeGenerator:
|
||||
|
||||
self.worker_thread = threading.Thread(
|
||||
target=self._worker,
|
||||
args=(video_path, mask_path, output_path, blur_size, fmt),
|
||||
args=(video_path, detections_path, output_path, blur_size, fmt),
|
||||
daemon=True,
|
||||
)
|
||||
self.worker_thread.start()
|
||||
@@ -72,7 +72,7 @@ class AsyncBakeGenerator:
|
||||
def _worker(
|
||||
self,
|
||||
video_path: str,
|
||||
mask_path: str,
|
||||
detections_path: str,
|
||||
output_path: str,
|
||||
blur_size: int,
|
||||
fmt: str,
|
||||
@@ -85,7 +85,7 @@ class AsyncBakeGenerator:
|
||||
client = get_client()
|
||||
task_id = client.bake_blur(
|
||||
video_path=video_path,
|
||||
mask_path=mask_path,
|
||||
detections_path=detections_path,
|
||||
output_path=output_path,
|
||||
blur_size=blur_size,
|
||||
fmt=fmt,
|
||||
|
||||
+24
-4
@@ -9,8 +9,7 @@ Blender's UI remains responsive via bpy.app.timers.
|
||||
import os
|
||||
import threading
|
||||
import queue
|
||||
from functools import partial
|
||||
from typing import Optional, Callable, Tuple
|
||||
from typing import Optional, Callable
|
||||
from pathlib import Path
|
||||
|
||||
# Will be imported when running inside Blender
|
||||
@@ -150,9 +149,20 @@ class AsyncMaskGenerator:
|
||||
while self.is_running:
|
||||
status = client.get_task_status(task_id)
|
||||
state = status.get("status")
|
||||
|
||||
total = status.get("total", 0)
|
||||
if total > 0:
|
||||
self.total_frames = total
|
||||
|
||||
if state == "completed":
|
||||
self.result_queue.put(("done", output_dir))
|
||||
final_progress = status.get("progress", self.total_frames)
|
||||
if final_progress >= 0:
|
||||
self.progress_queue.put(("progress", final_progress))
|
||||
result_path = status.get(
|
||||
"result_path",
|
||||
os.path.join(output_dir, "detections.msgpack"),
|
||||
)
|
||||
self.result_queue.put(("done", result_path))
|
||||
return
|
||||
|
||||
elif state == "failed":
|
||||
@@ -167,7 +177,7 @@ class AsyncMaskGenerator:
|
||||
|
||||
# Report progress
|
||||
progress = status.get("progress", 0)
|
||||
if progress > 0:
|
||||
if progress >= 0:
|
||||
self.progress_queue.put(("progress", progress))
|
||||
|
||||
time.sleep(0.5)
|
||||
@@ -206,6 +216,16 @@ class AsyncMaskGenerator:
|
||||
try:
|
||||
msg_type, data = self.result_queue.get_nowait()
|
||||
self.is_running = False
|
||||
|
||||
# Ensure UI receives a final progress update before completion.
|
||||
if (
|
||||
msg_type == "done"
|
||||
and self.total_frames > 0
|
||||
and self.current_frame < self.total_frames
|
||||
and self._on_progress
|
||||
):
|
||||
self.current_frame = self.total_frames
|
||||
self._on_progress(self.current_frame, self.total_frames)
|
||||
|
||||
if self._on_complete:
|
||||
self._on_complete(msg_type, data)
|
||||
|
||||
@@ -252,7 +252,7 @@ class InferenceClient:
|
||||
def bake_blur(
|
||||
self,
|
||||
video_path: str,
|
||||
mask_path: str,
|
||||
detections_path: str,
|
||||
output_path: str,
|
||||
blur_size: int,
|
||||
fmt: str,
|
||||
@@ -268,7 +268,7 @@ class InferenceClient:
|
||||
|
||||
data = {
|
||||
"video_path": video_path,
|
||||
"mask_path": mask_path,
|
||||
"detections_path": detections_path,
|
||||
"output_path": output_path,
|
||||
"blur_size": blur_size,
|
||||
"format": fmt,
|
||||
|
||||
@@ -78,6 +78,11 @@ def get_cache_dir_for_strip(strip_name: str) -> str:
|
||||
return os.path.join(get_cache_root(), strip_name)
|
||||
|
||||
|
||||
def get_detections_path_for_strip(strip_name: str) -> str:
|
||||
"""Get msgpack detection cache path for a specific strip."""
|
||||
return os.path.join(get_cache_dir_for_strip(strip_name), "detections.msgpack")
|
||||
|
||||
|
||||
def get_cache_info(strip_name: Optional[str] = None) -> Tuple[str, int, int]:
|
||||
"""
|
||||
Get cache directory information.
|
||||
|
||||
Reference in New Issue
Block a user