MacBook pro commited on
Commit
d87a575
·
1 Parent(s): fbcde68

Load CodeFormer repo modules automatically

Browse files
Files changed (1) hide show
  1. swap_pipeline.py +9 -0
swap_pipeline.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import io
3
  import time
4
  import logging
 
5
  from typing import Optional, Dict, Any, List
6
 
7
  import numpy as np
@@ -269,6 +270,14 @@ class FaceSwapPipeline:
269
  if not os.path.isfile(CODEFORMER_PATH):
270
  logger.warning(f"CodeFormer weight missing; skipping: {CODEFORMER_PATH}")
271
  return
 
 
 
 
 
 
 
 
272
  try:
273
  import torch # type: ignore
274
  except Exception:
 
2
  import io
3
  import time
4
  import logging
5
+ import sys
6
  from typing import Optional, Dict, Any, List
7
 
8
  import numpy as np
 
270
  if not os.path.isfile(CODEFORMER_PATH):
271
  logger.warning(f"CodeFormer weight missing; skipping: {CODEFORMER_PATH}")
272
  return
273
+ repo_root = os.path.join('models', 'codeformer_repo')
274
+ try:
275
+ if self._ensure_repo_clone(repo_root):
276
+ for extra in (repo_root, os.path.join(repo_root, 'CodeFormer')):
277
+ if os.path.isdir(extra) and extra not in sys.path:
278
+ sys.path.insert(0, extra)
279
+ except Exception as clone_err: # noqa: BLE001
280
+ logger.debug(f"CodeFormer repo clone/setup failed (continuing with installed packages): {clone_err}")
281
  try:
282
  import torch # type: ignore
283
  except Exception: