mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 13:02:15 -07:00
* superb improved fanseg * _ * _ * added FANseg extractor for src and dst faces to use it in training * - * _ * _ * update to 'partial' func * _ * trained FANSeg_256_full_face.h5, new experimental models: AVATAR, RecycleGAN * _ * _ * _ * fix for TCC mode cards(tesla), was conflict with plaidML initialization. * _ * update manuals * _
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import time
|
|
import multiprocessing
|
|
|
|
class SubprocessFunctionCaller(object):
|
|
class CliFunction(object):
|
|
def __init__(self, s2c, c2s, lock):
|
|
self.s2c = s2c
|
|
self.c2s = c2s
|
|
self.lock = lock
|
|
|
|
def __call__(self, *args, **kwargs):
|
|
self.lock.acquire()
|
|
self.c2s.put ( {'args':args, 'kwargs':kwargs} )
|
|
while True:
|
|
if not self.s2c.empty():
|
|
obj = self.s2c.get()
|
|
self.lock.release()
|
|
return obj
|
|
time.sleep(0.005)
|
|
|
|
class HostProcessor(object):
|
|
def __init__(self, s2c, c2s, func):
|
|
self.s2c = s2c
|
|
self.c2s = c2s
|
|
self.func = func
|
|
|
|
def process_messages(self):
|
|
while not self.c2s.empty():
|
|
obj = self.c2s.get()
|
|
result = self.func ( *obj['args'], **obj['kwargs'] )
|
|
self.s2c.put (result)
|
|
|
|
@staticmethod
|
|
def make_pair( func ):
|
|
s2c = multiprocessing.Queue()
|
|
c2s = multiprocessing.Queue()
|
|
lock = multiprocessing.Lock()
|
|
|
|
host_processor = SubprocessFunctionCaller.HostProcessor (s2c, c2s, func)
|
|
cli_func = SubprocessFunctionCaller.CliFunction (s2c, c2s, lock)
|
|
|
|
return host_processor, cli_func
|