def st_api(img_style, img_content, callback=None):
 global workers
 all_args = [{'length': 360, 'ratio': 2000.0, 'n_iter': 32, 'callback': callback}, {'length': 512, 'ratio': 20000.0, 'n_iter': 16, 'callback': callback}]
 st_lock = None
 st_worker = None
 while (st_lock is None):
  for (lock, worker) in workers.iteritems():
   if lock.acquire(False):
    st_lock = lock
    st_worker = worker
    break
   else:
    time.sleep(0.1)
 img_out = 'content'
 for args in all_args:
  args['init'] = img_out
  st_worker.transfer_style(img_style, img_content, **args)
  img_out = st_worker.get_generated()
 st_lock.release()
 return img_out

def st_api ( img_style , img_content , callback = None ) : global workers all_args = [ { 'length' : 360 , 'ratio' : 2000.0 , 'n_iter' : 32 , 'callback' : callback } , { 'length' : 512 , 'ratio' : 20000.0 , 'n_iter' : 16 , 'callback' : callback } ] st_lock = None st_worker = None while ( st_lock is None ) : for ( lock , worker ) in workers . iteritems ( ) : if lock . acquire ( False ) : st_lock = lock st_worker = worker break else : time . sleep ( 0.1 ) img_out = 'content' for args in all_args : args [ 'init' ] = img_out st_worker . transfer_style ( img_style , img_content , ** args ) img_out = st_worker . get_generated ( ) st_lock . release ( ) return img_out
style transfer api .