Long startup time on Linux (#356)

This commit is contained in:
Luke Barr 2019-08-19 13:56:54 -05:00 committed by iperov
parent e7562054d0
commit a33ef50da5

View file

@ -12,7 +12,7 @@ import cv2
import models import models
from interact import interact as io from interact import interact as io
def trainerThread (s2c, c2s, args, device_args): def trainerThread (s2c, c2s, e, args, device_args):
while True: while True:
try: try:
start_time = time.time() start_time = time.time()
@ -66,6 +66,7 @@ def trainerThread (s2c, c2s, args, device_args):
else: else:
previews = [( 'debug, press update for new', model.debug_one_iter())] previews = [( 'debug, press update for new', model.debug_one_iter())]
c2s.put ( {'op':'show', 'previews': previews} ) c2s.put ( {'op':'show', 'previews': previews} )
e.set() #Set the GUI Thread as Ready
if model.is_first_run(): if model.is_first_run():
@ -189,9 +190,12 @@ def main(args, device_args):
s2c = queue.Queue() s2c = queue.Queue()
c2s = queue.Queue() c2s = queue.Queue()
thread = threading.Thread(target=trainerThread, args=(s2c, c2s, args, device_args) ) e = threading.Event()
thread = threading.Thread(target=trainerThread, args=(s2c, c2s, e, args, device_args) )
thread.start() thread.start()
e.wait() #Wait for inital load to occur.
if no_preview: if no_preview:
while True: while True:
if not c2s.empty(): if not c2s.empty():
@ -291,7 +295,7 @@ def main(args, device_args):
key_events = io.get_key_events(wnd_name) key_events = io.get_key_events(wnd_name)
key, chr_key, ctrl_pressed, alt_pressed, shift_pressed = key_events[-1] if len(key_events) > 0 else (0,0,False,False,False) key, chr_key, ctrl_pressed, alt_pressed, shift_pressed = key_events[-1] if len(key_events) > 0 else (0,0,False,False,False)
if key == ord('\n') or key == ord('\r'): if key == ord('\n') or key == ord('\r'):
s2c.put ( {'op': 'close'} ) s2c.put ( {'op': 'close'} )
elif key == ord('s'): elif key == ord('s'):
@ -321,4 +325,4 @@ def main(args, device_args):
except KeyboardInterrupt: except KeyboardInterrupt:
s2c.put ( {'op': 'close'} ) s2c.put ( {'op': 'close'} )
io.destroy_all_windows() io.destroy_all_windows()