summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--live-mogrify.py33
-rw-r--r--options/dataset_options.py1
2 files changed, 24 insertions, 10 deletions
diff --git a/live-mogrify.py b/live-mogrify.py
index a56baa0..1999124 100644
--- a/live-mogrify.py
+++ b/live-mogrify.py
@@ -124,16 +124,20 @@ def process_image(opt, data_opt, im):
img = np.add(array_a, array_b).astype('uint8')
return img
+def list_checkpoints():
+ pass
+def list_videos():
+ pass
+
class Listener():
def __init__(self):
opt, data_opt, data_opt_parser = load_opt()
self.opt = opt
self.data_opt = data_opt
self.data_opt_parser = data_opt_parser.parser
+ self.model = create_model(opt)
self.working = False
def _set_fn(self, key, value):
- if key == 'pause' and self.data_opt.processing is False:
- process_live_input(self.opt, self.data_opt, self.rpc_client)
if hasattr(self.data_opt, key):
try:
if str(value) == 'True':
@@ -153,21 +157,32 @@ class Listener():
return vars(self.data_opt)
def _cmd_fn(self, cmd, payload):
print("got command {}".format(cmd))
- return 'yes'
+ if cmd == 'list_checkpoints':
+ return list_checkpoints()
+ if cmd == 'list_videos':
+ return list_videos()
+ if cmd == 'play' and self.data_opt.processing is False:
+ self.data_opt.pause = False
+ process_live_input(self.opt, self.data_opt, self.rpc_client, self.model)
+ if cmd == 'pause' and self.data_opt.processing is True:
+ self.data_opt.pause = True
+ return 'paused'
+ if cmd == 'exit':
+ print("Exiting now...!")
+ sys.exit(0)
+ return 'exited'
+ return 'ok'
def _ready_fn(self, rpc_client):
- # self.connect()
- process_live_input(self.opt, self.data_opt, rpc_client)
+ process_live_input(self.opt, self.data_opt, rpc_client, self.model)
def connect(self):
self.rpc_client = CortexRPC(self._get_fn, self._set_fn, self._ready_fn, self._cmd_fn)
-def process_live_input(opt, data_opt, rpc_client):
+def process_live_input(opt, data_opt, rpc_client, model):
if data_opt.processing:
print("Already processing...")
data_opt.processing = True
data_loader = CreateRecursiveDataLoader(opt)
dataset = data_loader.load_data()
-
- model = create_model(opt)
print("generating...")
A_offset, A_im, A_dir = load_first_frame(opt, data_opt)
@@ -254,8 +269,6 @@ def process_live_input(opt, data_opt, rpc_client):
cv2.imwrite(tmp_path, next_img)
os.rename(tmp_path, next_path)
- if data_opt.exit:
- sys.exit(0)
if data_opt.pause:
data_opt.pause = False
break
diff --git a/options/dataset_options.py b/options/dataset_options.py
index 92ea2bc..3ba6452 100644
--- a/options/dataset_options.py
+++ b/options/dataset_options.py
@@ -108,6 +108,7 @@ class DatasetOptions(BaseOptions):
action='store_true',
help='internally stores whether or not we should be processing..'
)
+
self.parser.add_argument(
'--pause',
action='store_true',