|
24 | 24 | import re |
25 | 25 | import shutil |
26 | 26 | import tempfile |
| 27 | +import uuid |
27 | 28 | import weakref |
28 | 29 | from concurrent.futures import ThreadPoolExecutor |
| 30 | +from datetime import datetime |
29 | 31 | from typing import Any, Dict, List, Optional, Tuple |
30 | 32 |
|
31 | 33 | import torch |
@@ -70,9 +72,19 @@ def _safe(name: str, default: str = "x") -> str: |
70 | 72 | return s[:128] |
71 | 73 |
|
72 | 74 |
|
73 | | -def _default_output_dir() -> str: |
74 | | - hf_home = os.path.expanduser(os.getenv("HF_HOME", "~/.cache/huggingface")) |
75 | | - return os.path.join(hf_home, "lmms_eval", "generated_videos", "fastvideo") |
| 75 | +def _generate_run_id() -> str: |
| 76 | + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") |
| 77 | + short_uuid = str(uuid.uuid4())[:8] |
| 78 | + return f"{timestamp}_{short_uuid}" |
| 79 | + |
| 80 | + |
| 81 | +def _model_slug(model_path: str) -> str: |
| 82 | + base = os.path.basename(str(model_path).rstrip("/")) |
| 83 | + return _SAFE_RE.sub("_", base).strip("_") or "model" |
| 84 | + |
| 85 | + |
| 86 | +def _default_output_dir(model_path: str) -> str: |
| 87 | + return os.path.join("./logs/fastvideo", _model_slug(model_path), _generate_run_id()) |
76 | 88 |
|
77 | 89 |
|
78 | 90 | _DTYPES = { |
@@ -212,8 +224,9 @@ def __init__( |
212 | 224 | self.seed = seed |
213 | 225 | self.negative_prompt = negative_prompt |
214 | 226 |
|
215 | | - self.output_dir = os.path.abspath(os.path.expanduser(output_dir or _default_output_dir())) |
| 227 | + self.output_dir = os.path.abspath(os.path.expanduser(output_dir or _default_output_dir(self.model_path))) |
216 | 228 | os.makedirs(self.output_dir, exist_ok=True) |
| 229 | + eval_logger.info(f"FastVideo output directory: {self.output_dir}") |
217 | 230 | self._tmp_img_dir = tempfile.mkdtemp(prefix="fastvideo_inputs_") |
218 | 231 |
|
219 | 232 | self.batch_size_per_gpu = int(batch_size) |
|
0 commit comments