johnhelf commited on
Commit
adf0bff
1 Parent(s): d6f84f3
.gitignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ output/
2
+ roop/__pycache__
3
+ roop/processors/frame/__pycache__
4
+ roop/frame/__pycache__
5
+ flagged/
6
+ *.jpg
7
+ *.pyc
8
+ *.pth
9
+ *.onnx
10
+ .idea
11
+ .vscode
12
+ models/
app.py CHANGED
@@ -46,7 +46,7 @@ def swap_face(source_file, target_file,doFaceEnhancer):
46
  roop.globals.video_encoder = "libx264"
47
  roop.globals.video_quality = 18
48
  roop.globals.max_memory = suggest_max_memory()
49
- roop.globals.execution_providers = decode_execution_providers(["cpu"])
50
  roop.globals.execution_threads = suggest_execution_threads()
51
 
52
  print(
 
46
  roop.globals.video_encoder = "libx264"
47
  roop.globals.video_quality = 18
48
  roop.globals.max_memory = suggest_max_memory()
49
+ roop.globals.execution_providers = decode_execution_providers(["cuda"])
50
  roop.globals.execution_threads = suggest_execution_threads()
51
 
52
  print(
roop/__pycache__/__init__.cpython-310.pyc DELETED
Binary file (141 Bytes)
 
roop/__pycache__/capturer.cpython-310.pyc DELETED
Binary file (815 Bytes)
 
roop/__pycache__/core.cpython-310.pyc DELETED
Binary file (8.34 kB)
 
roop/__pycache__/face_analyser.cpython-310.pyc DELETED
Binary file (1.26 kB)
 
roop/__pycache__/globals.cpython-310.pyc DELETED
Binary file (537 Bytes)
 
roop/__pycache__/metadata.cpython-310.pyc DELETED
Binary file (176 Bytes)
 
roop/__pycache__/predicter.cpython-310.pyc DELETED
Binary file (1.22 kB)
 
roop/__pycache__/typing.cpython-310.pyc DELETED
Binary file (279 Bytes)
 
roop/__pycache__/ui.cpython-310.pyc DELETED
Binary file (8.4 kB)
 
roop/__pycache__/utilities.cpython-310.pyc DELETED
Binary file (5.59 kB)
 
roop/processors/__pycache__/__init__.cpython-310.pyc DELETED
Binary file (152 Bytes)
 
roop/processors/frame/__pycache__/__init__.cpython-310.pyc DELETED
Binary file (158 Bytes)
 
roop/processors/frame/__pycache__/core.cpython-310.pyc DELETED
Binary file (3.31 kB)
 
roop/processors/frame/__pycache__/face_swapper.cpython-310.pyc DELETED
Binary file (3.12 kB)
 
roop/processors/frame/face_enhancer.py CHANGED
@@ -9,6 +9,7 @@ from roop.core import update_status
9
  from roop.face_analyser import get_one_face
10
  from roop.typing import Frame, Face
11
  from roop.utilities import conditional_download, resolve_relative_path, is_image, is_video
 
12
 
13
  FACE_ENHANCER = None
14
  THREAD_SEMAPHORE = threading.Semaphore()
@@ -16,6 +17,11 @@ THREAD_LOCK = threading.Lock()
16
  NAME = 'ROOP.FACE-ENHANCER'
17
  frame_name = 'face_enhancer'
18
 
 
 
 
 
 
19
 
20
  def get_face_enhancer() -> Any:
21
  global FACE_ENHANCER
@@ -24,7 +30,7 @@ def get_face_enhancer() -> Any:
24
  if FACE_ENHANCER is None:
25
  model_path = resolve_relative_path('../models/GFPGANv1.4.pth')
26
  # todo: set models path https://github.com/TencentARC/GFPGAN/issues/399
27
- FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
28
  return FACE_ENHANCER
29
 
30
 
 
9
  from roop.face_analyser import get_one_face
10
  from roop.typing import Frame, Face
11
  from roop.utilities import conditional_download, resolve_relative_path, is_image, is_video
12
+ import torch
13
 
14
  FACE_ENHANCER = None
15
  THREAD_SEMAPHORE = threading.Semaphore()
 
17
  NAME = 'ROOP.FACE-ENHANCER'
18
  frame_name = 'face_enhancer'
19
 
20
+ if torch.cuda.is_available():
21
+ device='cuda'
22
+ else:
23
+ device='cpu'
24
+
25
 
26
  def get_face_enhancer() -> Any:
27
  global FACE_ENHANCER
 
30
  if FACE_ENHANCER is None:
31
  model_path = resolve_relative_path('../models/GFPGANv1.4.pth')
32
  # todo: set models path https://github.com/TencentARC/GFPGAN/issues/399
33
+ FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1,device=device) # type: ignore[attr-defined]
34
  return FACE_ENHANCER
35
 
36