Exemple #1
0
def run():
    gw = Gateway()
    # inputs
    mux = Mux(board.GPIO14, board.GPIO12, board.GPIO15, board.GPIO13)
    gw.add_component(TemporalMonoNumericKeypad("keypad", MuxInSource(0, mux)))  # Y0
    gw.add_component(Switch("beam", MuxInSource(1, mux)))  # Y1
    gw.add_component(Switch("doordown", MuxInSource(2, mux)))  # Y2
    gw.add_component(Switch("doorup", MuxInSource(3, mux)))  # Y3
    gw.add_component(Switch("reardoor", MuxInSource(4, mux)))  # Y4
    gw.add_component(Switch("patiodoor", MuxInSource(5, mux)))  # Y5
    gw.add_component(Switch("frontdoor", MuxInSource(6, mux)))  # Y6
    gw.add_component(Switch("Y7", MuxInSource(7, mux)))  # Y7
    # outputs
    gw.add_component(Light("light", board.GPIO4))
    gw.add_component(PulseRelay("lift", board.GPIO5))

    gw.run()
def parse_args():
    parser = argparse.ArgumentParser()
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument("-s2D", "--segmentation_model_2D", default=False, help="If the model's output is a 2D segmentation mask",
        action='store_true')
    group.add_argument("-s3D", "--segmentation_model_3D", default=False, help="If the model's output is a 3D segmentation mask",
        action='store_true')
    group.add_argument("-b", "--bounding_box_model", default=False, help="If the model's output are bounding boxes",
        action='store_true')
    group.add_argument("-cl", "--classification_model", default=False, help="If the model's output are labels",
        action='store_true')  
    args = parser.parse_args()

    return args

if __name__ == '__main__':
    args = parse_args()
    app = Gateway(__name__)
    app.register_error_handler(Exception, handle_exception)
    if args.bounding_box_model:
        app.add_inference_route('/', request_handler_bbox)
    elif args.segmentation_model_3D:
        app.add_inference_route('/', request_handler_3D_segmentation)
    elif args.classification_model:
        app.add_inference_route('/', request_handler_classification)
    else:
        app.add_inference_route('/', request_handler_2D_segmentation)

    app.add_healthcheck_route(healthcheck_handler)
    app.run(host='0.0.0.0', port=8000, debug=True, use_reloader=True)