mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 04:52:13 -07:00
Removed the wait at first launch for most graphics cards. Increased speed of training by 10-20%, but you have to retrain all models from scratch. SAEHD: added option 'use float16' Experimental option. Reduces the model size by half. Increases the speed of training. Decreases the accuracy of the model. The model may collapse or not train. Model may not learn the mask in large resolutions. true_face_training option is replaced by "True face power". 0.0000 .. 1.0 Experimental option. Discriminates the result face to be more like the src face. Higher value - stronger discrimination. Comparison - https://i.imgur.com/czScS9q.png
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
import queue as Queue
|
|
import multiprocessing
|
|
|
|
class SubprocessGenerator(object):
|
|
def __init__(self, generator_func, user_param=None, prefetch=2, start_now=True):
|
|
super().__init__()
|
|
self.prefetch = prefetch
|
|
self.generator_func = generator_func
|
|
self.user_param = user_param
|
|
self.sc_queue = multiprocessing.Queue()
|
|
self.cs_queue = multiprocessing.Queue()
|
|
self.p = None
|
|
if start_now:
|
|
self._start()
|
|
|
|
def _start(self):
|
|
if self.p == None:
|
|
user_param = self.user_param
|
|
self.user_param = None
|
|
self.p = multiprocessing.Process(target=self.process_func, args=(user_param,) )
|
|
self.p.daemon = True
|
|
self.p.start()
|
|
|
|
def process_func(self, user_param):
|
|
self.generator_func = self.generator_func(user_param)
|
|
while True:
|
|
while self.prefetch > -1:
|
|
try:
|
|
gen_data = next (self.generator_func)
|
|
except StopIteration:
|
|
self.cs_queue.put (None)
|
|
return
|
|
self.cs_queue.put (gen_data)
|
|
self.prefetch -= 1
|
|
self.sc_queue.get()
|
|
self.prefetch += 1
|
|
|
|
def __iter__(self):
|
|
return self
|
|
|
|
def __getstate__(self):
|
|
self_dict = self.__dict__.copy()
|
|
del self_dict['p']
|
|
return self_dict
|
|
|
|
def __next__(self):
|
|
self._start()
|
|
gen_data = self.cs_queue.get()
|
|
if gen_data is None:
|
|
self.p.terminate()
|
|
self.p.join()
|
|
raise StopIteration()
|
|
self.sc_queue.put (1)
|
|
return gen_data
|