from libraries.logger import Logger from duplex.utils import get_tx2_and_config_file from duplex.duplex_engine import DuplexEngine import sys if __name__ == '__main__': is_tx2, cfg = get_tx2_and_config_file() log = Logger(lib_name='ODJD', config_file=cfg, TF_KERAS=True) args = [x.upper() for x in sys.argv] log.P("Args: {}".format(args)) _debug = 'DEBUG' in args show_debug = 'NOSHOW' not in args use_face = 'NOFACE' not in args use_emotion = 'NOEMO' not in args show_boxes = 'NOBOX' not in args eng = DuplexEngine(log=log, runs_on_device=is_tx2, debug=_debug, use_face=use_face, use_emotion=use_emotion, boxes=show_boxes, )
if log is not None: log.P(" GPU free mem: {:.1f} Gb".format(val / (1024**3))) return val if __name__ == '__main__': cfg = 'config/duplex_config.txt' log = Logger(lib_name='MGS', config_file=cfg, TF_KERAS=True) yolo = log.LoadGraphFromModels('01_1712_y_720_1280_c.pb') face = log.LoadGraphFromModels('20_190301_mob_ssd_faces.pb') config_proto = tf.compat.v1.ConfigProto() config_proto.gpu_options.allow_growth = True yolo_sess = tf.compat.v1.Session(graph=yolo, config=config_proto) log.P("Created yolo session") config_proto = tf.compat.v1.ConfigProto() config_proto.gpu_options.allow_growth = True face_sess = tf.compat.v1.Session(graph=face, config=config_proto) log.P("Created ssd session") tf_face_classes = face_sess.graph.get_tensor_by_name("detection_classes:0") tf_face_scores = face_sess.graph.get_tensor_by_name("detection_scores:0") tf_face_boxes = face_sess.graph.get_tensor_by_name("detection_boxes:0") tf_face_dets = face_sess.graph.get_tensor_by_name("num_detections:0") tf_face_input = face_sess.graph.get_tensor_by_name("image_tensor:0") tf_learning_phase = yolo_sess.graph.get_tensor_by_name( "keras_learning_phase:0") tf_classes = yolo_sess.graph.get_tensor_by_name("YOLO_OUTPUT_CLASSES" +
log.P("*"*50) log.P("LocalConfig v{} received config data:".format(__VER__)) dct_prev = log.load_data_json(fn_config) log.P(" Current: {}".format(dct_prev)) log.save_data_json(dct_config, fn_config ) dct_new = log.load_data_json(fn_config) log.P(" New: {}".format(dct_config)) jresponse = flask.jsonify({ "RECEIVED_CONFIG_UPDATE": dct_new}) jresponse.headers["Access-Control-Allow-Origin"] = "*" jresponse.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS, DELETE" jresponse.headers["Access-Control-Allow-Headers"] = "Content-Type" log.P("*"*50) return jresponse if __name__ == '__main__': config_file = 'config/duplex_config.txt' log = Logger(lib_name='ODJcfg', config_file=config_file, TF_KERAS=False) log.P("Starting OmniDJ local config server {}".format(__VER__)) dct_viewer = log.load_data_json(fn_config) log.P("Currend config:\n{}".format(dct_viewer)) app = flask.Flask('LocalConfigServer') app.add_url_rule(rule='/config', endpoint="LocalConfig", view_func=config_update, methods = ['GET', 'POST','OPTIONS'] ) app.run(host='127.0.0.1', port=5500)