Ii commited on
Commit
9216db1
·
verified ·
1 Parent(s): dcca02f

Update refacer.py

Browse files
Files changed (1) hide show
  1. refacer.py +15 -2
refacer.py CHANGED
@@ -31,7 +31,6 @@ class Refacer:
31
  self.first_face = False
32
  self.force_cpu = force_cpu
33
  self.colab_performance = colab_performance
34
- self.__check_encoders() # Correct method name
35
  self.__check_providers()
36
  self.total_mem = psutil.virtual_memory().total
37
  self.__init_apps()
@@ -65,7 +64,7 @@ class Refacer:
65
  self.mode = RefacerMode.CUDA
66
  self.use_num_cpus = 2
67
  self.sess_options.intra_op_num_threads = 1
68
- if 'TensorrtExecutionProvider' in self.providers:
69
  self.providers.remove('TensorrtExecutionProvider')
70
  print(f"CUDA mode with providers {self.providers}")
71
 
@@ -196,3 +195,17 @@ class Refacer:
196
  os.remove('temp.mp4')
197
 
198
  return video_buffer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  self.first_face = False
32
  self.force_cpu = force_cpu
33
  self.colab_performance = colab_performance
 
34
  self.__check_providers()
35
  self.total_mem = psutil.virtual_memory().total
36
  self.__init_apps()
 
64
  self.mode = RefacerMode.CUDA
65
  self.use_num_cpus = 2
66
  self.sess_options.intra_op_num_threads = 1
67
+ if 'TensorrtExecutionProvider' in the providers:
68
  self.providers.remove('TensorrtExecutionProvider')
69
  print(f"CUDA mode with providers {self.providers}")
70
 
 
195
  os.remove('temp.mp4')
196
 
197
  return video_buffer
198
+
199
+ # Gradio Code
200
+ def run(*vars):
201
+ video_path = vars[0]
202
+ origins = vars[1:(num_faces + 1)]
203
+ destinations = vars[(num_faces + 1):(num_faces * 2) + 1]
204
+ thresholds = vars[(num_faces * 2) + 1:]
205
+
206
+ faces = []
207
+ for k in range(0, num_faces):
208
+ if origins[k] is not None and destinations[k] is not None:
209
+ faces.append({
210
+ 'origin': origins[k],
211
+ 'destination[_{{{CITATION{{{_1{](https://github.com/qixinbo/OneButtonDeepLearning/tree/6e209f40102a7acaeb5d5798da013758c0ff9cd3/FaceSwap%2Fmenus%2FFaceSwap%2Finsightface_func%2Finsightface%2Fapp%2Fface_analysis.py)[_{{{CITATION{{{_2{](https://github.com/pgtinsley/arcface_aman/tree/7beda0d69dc40acc0138525ca84f50ecda126d8c/python-package%2Finsightface%2Fapp%2Fface_analysis.py)