Upload 13 files
Browse files
roop/processors/Enhance_CodeFormer.py
CHANGED
@@ -7,10 +7,6 @@ import roop.globals
|
|
7 |
from roop.typing import Face, Frame, FaceSet
|
8 |
from roop.utilities import resolve_relative_path
|
9 |
|
10 |
-
|
11 |
-
# THREAD_LOCK = threading.Lock()
|
12 |
-
|
13 |
-
|
14 |
class Enhance_CodeFormer():
|
15 |
model_codeformer = None
|
16 |
|
|
|
7 |
from roop.typing import Face, Frame, FaceSet
|
8 |
from roop.utilities import resolve_relative_path
|
9 |
|
|
|
|
|
|
|
|
|
10 |
class Enhance_CodeFormer():
|
11 |
model_codeformer = None
|
12 |
|
roop/processors/Enhance_GFPGAN.py
CHANGED
@@ -7,10 +7,6 @@ import roop.globals
|
|
7 |
from roop.typing import Face, Frame, FaceSet
|
8 |
from roop.utilities import resolve_relative_path
|
9 |
|
10 |
-
|
11 |
-
# THREAD_LOCK = threading.Lock()
|
12 |
-
|
13 |
-
|
14 |
class Enhance_GFPGAN():
|
15 |
plugin_options:dict = None
|
16 |
|
|
|
7 |
from roop.typing import Face, Frame, FaceSet
|
8 |
from roop.utilities import resolve_relative_path
|
9 |
|
|
|
|
|
|
|
|
|
10 |
class Enhance_GFPGAN():
|
11 |
plugin_options:dict = None
|
12 |
|
roop/processors/FaceSwapInsightFace.py
CHANGED
@@ -32,30 +32,22 @@ class FaceSwapInsightFace():
|
|
32 |
self.input_std = 255.0
|
33 |
#cuda_options = {"arena_extend_strategy": "kSameAsRequested", 'cudnn_conv_algo_search': 'DEFAULT'}
|
34 |
sess_options = onnxruntime.SessionOptions()
|
35 |
-
sess_options.enable_cpu_mem_arena = False
|
36 |
self.model_swap_insightface = onnxruntime.InferenceSession(model_path, sess_options, providers=roop.globals.execution_providers)
|
37 |
|
38 |
|
39 |
-
|
40 |
def Run(self, source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
41 |
-
blob = cv2.dnn.blobFromImage(temp_frame, 1.0 / self.input_std, (128, 128),
|
42 |
-
(self.input_mean, self.input_mean, self.input_mean), swapRB=True)
|
43 |
latent = source_face.normed_embedding.reshape((1,-1))
|
44 |
latent = np.dot(latent, self.emap)
|
45 |
latent /= np.linalg.norm(latent)
|
46 |
io_binding = self.model_swap_insightface.io_binding()
|
47 |
-
io_binding.bind_cpu_input("target",
|
48 |
io_binding.bind_cpu_input("source", latent)
|
49 |
io_binding.bind_output("output", self.devicename)
|
50 |
self.model_swap_insightface.run_with_iobinding(io_binding)
|
51 |
ort_outs = io_binding.copy_outputs_to_cpu()[0]
|
52 |
-
|
53 |
-
return np.clip(255 * img_fake, 0, 255).astype(np.uint8)[:,:,::-1]
|
54 |
-
|
55 |
-
|
56 |
-
img_fake, M = self.model_swap_insightface.get(temp_frame, target_face, source_face, paste_back=False)
|
57 |
-
# target_face.matrix = M
|
58 |
-
# return img_fake
|
59 |
|
60 |
|
61 |
def Release(self):
|
|
|
32 |
self.input_std = 255.0
|
33 |
#cuda_options = {"arena_extend_strategy": "kSameAsRequested", 'cudnn_conv_algo_search': 'DEFAULT'}
|
34 |
sess_options = onnxruntime.SessionOptions()
|
35 |
+
sess_options.enable_cpu_mem_arena = False
|
36 |
self.model_swap_insightface = onnxruntime.InferenceSession(model_path, sess_options, providers=roop.globals.execution_providers)
|
37 |
|
38 |
|
39 |
+
|
40 |
def Run(self, source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
|
|
|
|
41 |
latent = source_face.normed_embedding.reshape((1,-1))
|
42 |
latent = np.dot(latent, self.emap)
|
43 |
latent /= np.linalg.norm(latent)
|
44 |
io_binding = self.model_swap_insightface.io_binding()
|
45 |
+
io_binding.bind_cpu_input("target", temp_frame)
|
46 |
io_binding.bind_cpu_input("source", latent)
|
47 |
io_binding.bind_output("output", self.devicename)
|
48 |
self.model_swap_insightface.run_with_iobinding(io_binding)
|
49 |
ort_outs = io_binding.copy_outputs_to_cpu()[0]
|
50 |
+
return ort_outs[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
|
53 |
def Release(self):
|
roop/processors/Frame_Upscale.py
CHANGED
@@ -2,11 +2,11 @@ import cv2
|
|
2 |
import numpy as np
|
3 |
import onnxruntime
|
4 |
import roop.globals
|
5 |
-
import threading
|
6 |
|
7 |
-
from roop.utilities import resolve_relative_path
|
8 |
from roop.typing import Frame
|
9 |
|
|
|
10 |
class Frame_Upscale():
|
11 |
plugin_options:dict = None
|
12 |
model_upscale = None
|
@@ -16,8 +16,6 @@ class Frame_Upscale():
|
|
16 |
processorname = 'upscale'
|
17 |
type = 'frame_enhancer'
|
18 |
|
19 |
-
THREAD_LOCK_UPSCALE = threading.Lock()
|
20 |
-
|
21 |
|
22 |
def Initialize(self, plugin_options:dict):
|
23 |
if self.plugin_options is not None:
|
@@ -40,7 +38,7 @@ class Frame_Upscale():
|
|
40 |
elif self.prev_type == "lsdirx4":
|
41 |
model_path = resolve_relative_path('../models/Frame/lsdir_x4.onnx')
|
42 |
self.scale = 4
|
43 |
-
|
44 |
self.model_upscale = onnxruntime.InferenceSession(model_path, None, providers=roop.globals.execution_providers)
|
45 |
self.model_inputs = self.model_upscale.get_inputs()
|
46 |
model_outputs = self.model_upscale.get_outputs()
|
@@ -109,7 +107,7 @@ class Frame_Upscale():
|
|
109 |
|
110 |
for index, tile_frame in enumerate(upscale_tile_frames):
|
111 |
tile_frame = self.prepare_tile_frame(tile_frame)
|
112 |
-
with
|
113 |
self.io_binding.bind_cpu_input(self.model_inputs[0].name, tile_frame)
|
114 |
self.model_upscale.run_with_iobinding(self.io_binding)
|
115 |
ort_outs = self.io_binding.copy_outputs_to_cpu()
|
|
|
2 |
import numpy as np
|
3 |
import onnxruntime
|
4 |
import roop.globals
|
|
|
5 |
|
6 |
+
from roop.utilities import resolve_relative_path, conditional_thread_semaphore
|
7 |
from roop.typing import Frame
|
8 |
|
9 |
+
|
10 |
class Frame_Upscale():
|
11 |
plugin_options:dict = None
|
12 |
model_upscale = None
|
|
|
16 |
processorname = 'upscale'
|
17 |
type = 'frame_enhancer'
|
18 |
|
|
|
|
|
19 |
|
20 |
def Initialize(self, plugin_options:dict):
|
21 |
if self.plugin_options is not None:
|
|
|
38 |
elif self.prev_type == "lsdirx4":
|
39 |
model_path = resolve_relative_path('../models/Frame/lsdir_x4.onnx')
|
40 |
self.scale = 4
|
41 |
+
onnxruntime.set_default_logger_severity(3)
|
42 |
self.model_upscale = onnxruntime.InferenceSession(model_path, None, providers=roop.globals.execution_providers)
|
43 |
self.model_inputs = self.model_upscale.get_inputs()
|
44 |
model_outputs = self.model_upscale.get_outputs()
|
|
|
107 |
|
108 |
for index, tile_frame in enumerate(upscale_tile_frames):
|
109 |
tile_frame = self.prepare_tile_frame(tile_frame)
|
110 |
+
with conditional_thread_semaphore():
|
111 |
self.io_binding.bind_cpu_input(self.model_inputs[0].name, tile_frame)
|
112 |
self.model_upscale.run_with_iobinding(self.io_binding)
|
113 |
ort_outs = self.io_binding.copy_outputs_to_cpu()
|
roop/processors/Mask_XSeg.py
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
import numpy as np
|
2 |
import cv2
|
3 |
import onnxruntime
|
4 |
-
import threading
|
5 |
import roop.globals
|
6 |
|
7 |
from roop.typing import Frame
|
8 |
-
from roop.utilities import resolve_relative_path
|
9 |
|
10 |
-
THREAD_LOCK_CLIP = threading.Lock()
|
11 |
|
12 |
|
13 |
class Mask_XSeg():
|
|
|
1 |
import numpy as np
|
2 |
import cv2
|
3 |
import onnxruntime
|
|
|
4 |
import roop.globals
|
5 |
|
6 |
from roop.typing import Frame
|
7 |
+
from roop.utilities import resolve_relative_path, conditional_thread_semaphore
|
8 |
|
|
|
9 |
|
10 |
|
11 |
class Mask_XSeg():
|