tuan2308 commited on
Commit
a39ec9f
1 Parent(s): 72f5536

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -6,8 +6,8 @@ import roop.globals
6
  from roop.core import (
7
  start,
8
  decode_execution_providers,
9
- suggest_max_memory,
10
- suggest_execution_threads,
11
  )
12
  from roop.processors.frame.core import get_frame_processors_modules
13
  from roop.utilities import normalize_output_path
@@ -16,7 +16,7 @@ from PIL import Image
16
  import spaces
17
 
18
  @spaces.GPU
19
- def swap_face(source_file, target_file,doFaceEnhancer):
20
 
21
  source_path = "input.jpg"
22
  target_path = "target.jpg"
@@ -36,7 +36,7 @@ def swap_face(source_file, target_file,doFaceEnhancer):
36
  roop.globals.source_path, roop.globals.target_path, output_path
37
  )
38
  if doFaceEnhancer == True:
39
- roop.globals.frame_processors = ["face_swapper","face_enhancer"]
40
  else:
41
  roop.globals.frame_processors = ["face_swapper"]
42
  roop.globals.headless = True
@@ -46,9 +46,9 @@ def swap_face(source_file, target_file,doFaceEnhancer):
46
  roop.globals.many_faces = False
47
  roop.globals.video_encoder = "libx264"
48
  roop.globals.video_quality = 18
49
- roop.globals.max_memory = suggest_max_memory()
50
  roop.globals.execution_providers = decode_execution_providers(["cuda"])
51
- roop.globals.execution_threads = suggest_execution_threads()
52
 
53
  print(
54
  "start process",
@@ -66,8 +66,7 @@ def swap_face(source_file, target_file,doFaceEnhancer):
66
  start()
67
  return output_path
68
 
69
-
70
  app = gr.Interface(
71
- fn=swap_face, inputs=[gr.Image(), gr.Image(),gr.Checkbox(label="face_enhancer?", info="do face enhancer?")], outputs="image"
72
  )
73
- app.launch()
 
6
  from roop.core import (
7
  start,
8
  decode_execution_providers,
9
+ # suggest_max_memory, # Loại bỏ hàm này
10
+ # suggest_execution_threads, # Loại bỏ hàm này
11
  )
12
  from roop.processors.frame.core import get_frame_processors_modules
13
  from roop.utilities import normalize_output_path
 
16
  import spaces
17
 
18
  @spaces.GPU
19
+ def swap_face(source_file, target_file, doFaceEnhancer):
20
 
21
  source_path = "input.jpg"
22
  target_path = "target.jpg"
 
36
  roop.globals.source_path, roop.globals.target_path, output_path
37
  )
38
  if doFaceEnhancer == True:
39
+ roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
40
  else:
41
  roop.globals.frame_processors = ["face_swapper"]
42
  roop.globals.headless = True
 
46
  roop.globals.many_faces = False
47
  roop.globals.video_encoder = "libx264"
48
  roop.globals.video_quality = 18
49
+ roop.globals.max_memory = "4G" # Sử dụng giá trị mặc định
50
  roop.globals.execution_providers = decode_execution_providers(["cuda"])
51
+ roop.globals.execution_threads = 4 # Sử dụng giá trị mặc định
52
 
53
  print(
54
  "start process",
 
66
  start()
67
  return output_path
68
 
 
69
  app = gr.Interface(
70
+ fn=swap_face, inputs=[gr.Image(), gr.Image(), gr.Checkbox(label="face_enhancer?", info="do face enhancer?")], outputs="image"
71
  )
72
+ app.launch()