def replay(import_path):

    print "Replaying simulation from:"
    print import_path
    print ""

    # Search and return step* folder inside import_path (e.g. step100, step200, step300 etc), ordered by number
    steps_paths = glob.glob(os.path.join(import_path, "step*"))

    if len(steps_paths) == 0:
        print "There is no step* folder to replay from."
        exit()
    else:
        steps_paths = sorted(steps_paths,
                             key=lambda name: int(
                                 name.replace(import_path, "").replace(
                                     "step", "").replace("/", "")))
        step_number = 0
        for step_path in steps_paths:
            step_number += 1
            if step_number % 30 == 0:  # Load every X saved state
                load_state(os.path.join(step_path))
                p.load_parameters_post()
                p.STEPS = p.start_step
                p.realtimePlot = True
                main_loop.main_loop(p.current_matrix)
def replay(import_path):

    print "Replaying simulation from:"
    print import_path
    print ""

    # Search and return step* folder inside import_path (e.g. step100, step200, step300 etc), ordered by number
    steps_paths = glob.glob(os.path.join(import_path, "step*"))

    if len(steps_paths) == 0:
        print "There is no step* folder to replay from."
        exit()
    else:
        steps_paths = sorted(steps_paths, key=lambda name: int(name.replace(import_path, "").replace("step", "").replace("/", "")))
        step_number = 0
        for step_path in steps_paths:
            step_number += 1
            if step_number % 30 == 0: # Load every X saved state
                load_state(os.path.join(step_path))
                p.load_parameters_post()
                p.STEPS = p.start_step
                p.realtimePlot = True
                main_loop.main_loop(p.current_matrix)
Beispiel #3
0
                        args.endframe = 100

                        args.atthorizontal_splits = splits_setting[0]
                        args.horizontal_splits = splits_setting[1]
                        #args.overlap_px = 50

                        # Final Evaluation Machines
                        args.LimitEvalMach = finalEval_server_setting
                        # Attention Machines
                        args.SetAttMach = AttEval_server_setting

                        tmp_name = input_name + "_" + str(
                            args.atthorizontal_splits) + "to" + str(
                                args.horizontal_splits)
                        servers_name = str(args.SetAttMach) + "att_" + str(
                            args.LimitEvalMach).zfill(2) + "eval"

                        args.name = "MyCustom4K_" + tmp_name + "_" + servers_name + "_" + dual

                        #args.debug_just_handshake = "True"

                        print("RUN", args.name)

                        main_loop(args)

                        end = timer()
                        time = (end - start)
                        print("This run took " + str(time) + "s (" +
                              str(time / 60.0) + "min)")
Beispiel #4
0
import main_loop


#initiate variables
serial_port='/dev/ttyACM0'  #'/dev/ttyACM1'
imgdir="/home/pi/Desktop/Captures/"
imgprefix="CapF"

#initiate main loop
loop=main_loop.main_loop(serial_port)


def RunTests():

    #Arm Movement Testing
    #loop.test_arm()
    #loop.test_arm_XYZ(5,5,-9)
    loop.test_arm_home()
    #loop.test_arm_home_plane()
    #loop.test_arm_clearcamera()

def RunPickandPlace():
        #Run Pick and Place
        
        fullscreen=False
        detectXYZ=True
        calculateXYZ=True
        move_arm=True
        loop.capturefromPiCamera(imgdir,imgprefix,fullscreen,detectXYZ,calculateXYZ,move_arm)

def ImageDetection():
Beispiel #5
0
    parser = ArgumentParser(add_help=False)
    # ------------ add hotpotqa argument ----------
    parser.add_argument('--sp_threshold', type=int, default=0.9)
    parser.add_argument('--only_predict', action='store_true')
    # ---------------------------------------------
    parser = main_parser(parser)
    parser.set_defaults(
        train_source=os.path.join(root_dir, 'data',
                                  'hotpotqa_train_roberta-base.pkl'),
        test_source=os.path.join(root_dir, 'data',
                                 'hotpotqa_test_roberta-base.pkl'),
        introspect=True)
    config = parser.parse_args()
    config.reasoner_cls_name = 'QAReasoner'
    if not config.only_predict:  # train
        main_loop(config)

    tokenizer = AutoTokenizer.from_pretrained(config.model_name)
    sp, ans = {}, {}
    for qbuf, dbuf, buf, relevance_score, ids, output in prediction(config):
        _id = qbuf[0]._id
        start, end = logits2span(*output)
        ans_ids = ids[start:end]
        ans[_id] = tokenizer.convert_tokens_to_string(
            tokenizer.convert_ids_to_tokens(ans_ids)).replace(
                '</s>', '').replace('<pad>', '').strip()
        # supporting facts
        sp[_id] = extract_supporing_facts(config, buf, relevance_score, start,
                                          end)
    with open(os.path.join(config.tmp_dir, 'pred.json'), 'w') as fout:
        pred = {'answer': ans, 'sp': sp}
Beispiel #6
0
SETTINGS = '~/.config/vim-todo/config.txt'
PID = '~/.config/vim-todo/.pid'

if __name__ != "__main__":
    import os_utils.die

    os_utils.die("This should be run as a standalone app")

args = parse_args()

if args.restart:
    os_utils.stop_daemon(PID)
    todo_file = get_todo_file(args, SETTINGS)
    os_utils.start_daemon(PID)
    main_loop(todo_file, args.dry_run)
elif args.stop:
    os_utils.stop_daemon(PID)
elif args.no_daemon:
    todo_file = get_todo_file(args, SETTINGS)
    main_loop(todo_file, args.dry_run)
elif args.verify:
    todo_file = get_todo_file(args, SETTINGS)
    error = False

    lineno = 0
    for td in parser.process_todo_file(todo_file):
        lineno += 1
        if td.error is not None:
            error = True
            sys.stderr.write("%s:%d in line %s ERROR %s" %
Beispiel #7
0
def main():
	main_loop(test(pygame.display.set_mode((800, 600)))).run()
Beispiel #8
0
# Function to list saved states

if p.simulation_mode == 'list':

    saved_states.list_saved_states(p.saved_state_path)

elif p.simulation_mode == 'new':

    # Load default parameters
    p.load_default_parameters()
    matrix_initialization.matrix_initialization()
    # Calculate some derivatives parameters
    p.load_parameters_post()
    # Run the simulation per se
    main_loop.main_loop(p.current_matrix)

elif p.simulation_mode == 'load': # Or load parameters from saved state

    saved_states.load_state(p.saved_state_path)
    # Calculate some derivatives parameters
    p.load_parameters_post()
    main_loop.main_loop(p.current_matrix)

elif p.simulation_mode == 'replay':

    # Replay simulation
    saved_states.replay(p.saved_state_path)

elif p.simulation_mode == 'density':
Beispiel #9
0
from main_loop import main_loop
import logging

LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p"

logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, datefmt=DATE_FORMAT)
main_loop()