Пример #1
0
def main():
    try:
        global ACC

        if nargs < 2:
            print "\n\rUSAGE : ResultSummary <Result Summary Config File> \n\r Result Summary Config File : See Sample Config File - WTS-ResultSummary.conf"
            return

        f = ReadMapFile(sys.argv[1], "OUTPUT_FILE", "=")
        if not f.endswith(".xml"):
            f = "%s.xml" % f

        sm = ReadMapFile(sys.argv[1], "M_CHECK", '=')
        log_path = ReadMapFile(sys.argv[1], "LOG_PATH", '=')

        if not log_path.endswith("/"):
            log_path = "%s/" % log_path

        prog_name = ReadMapFile(sys.argv[1], "PROG_NAME", '=')
        UID = ReadMapFile(sys.argv[1], "UID", '=')
        test_criteria = ReadMapFile(sys.argv[1], "TEST_CRITERIA_FILE", '=')
        format_style = ReadMapFile(sys.argv[1], "FORMAT_STYLE", '=')

        init_logging("debug-log-result-summary.txt")
        logging.info(
            "LOG_PATH [%s] PROG_NAME [%s] UID [%s] OUTPUT_FILE [%s] TEST_CRITERIA_FILE [%s] FORMAT_STYLE [%s]"
            % (log_path, prog_name, UID, f, test_criteria, format_style))

        if prog_name == '60G':
            prog_name = "_" + prog_name
        rSummary = ResultSummary(f, test_criteria, prog_name, UID, log_path,
                                 sm, format_style)

        signVerification = ReadMapFile(sys.argv[1], "SIGN_VERIFICATION", '=')

        # Enable Signature verification - by default it is disabled
        if signVerification == "1":
            setattr(rSummary, "SignVerification", 1)
            acc_ip = ReadMapFile(sys.argv[1], "ACC_IP_ADDR", '=')
            acc_port = ReadMapFile(sys.argv[1], "ACC_IP_PORT", '=')
            ACC = ACCClient(acc_ip, acc_port)
            #unit test with hard coded file name

        rSummary.generateSummary()
        rSummary.writeXML()

    except StandardError:
        err = sys.exc_info()
        logging.error("End %s" % err[1])
def main():
    try:
        global ACC

        if nargs < 2:
            print "\n\rUSAGE : ResultSummary <Result Summary Config File> \n\r Result Summary Config File : See Sample Config File - WTS-ResultSummary.conf"
            return

        f = ReadMapFile(sys.argv[1], "OUTPUT_FILE", "=")
        if not f.endswith(".xml"):
            f = "%s.xml" % f

        sm = ReadMapFile(sys.argv[1], "M_CHECK", '=')
        log_path = ReadMapFile(sys.argv[1], "LOG_PATH", '=')

        if not log_path.endswith("/"):
            log_path = "%s/" % log_path

        prog_name = ReadMapFile(sys.argv[1], "PROG_NAME", '=')
        UID = ReadMapFile(sys.argv[1], "UID", '=')
        test_criteria = ReadMapFile(sys.argv[1], "TEST_CRITERIA_FILE", '=')
        format_style = ReadMapFile(sys.argv[1], "FORMAT_STYLE", '=')

        init_logging("debug-log-result-summary.txt")
        logging.info("LOG_PATH [%s] PROG_NAME [%s] UID [%s] OUTPUT_FILE [%s] TEST_CRITERIA_FILE [%s] FORMAT_STYLE [%s]"  % (log_path, prog_name, UID, f, test_criteria, format_style))

        rSummary = ResultSummary(f, test_criteria, prog_name, UID, log_path, sm, format_style)

        signVerification = ReadMapFile(sys.argv[1], "SIGN_VERIFICATION", '=')

        # Enable Signature verification - by default it is disabled
        if signVerification == "1":
            setattr(rSummary, "SignVerification", 1)
            acc_ip = ReadMapFile(sys.argv[1], "ACC_IP_ADDR", '=')
            acc_port = ReadMapFile(sys.argv[1], "ACC_IP_PORT", '=')
            ACC = ACCClient(acc_ip, acc_port)
            #unit test with hard coded file name

        rSummary.generateSummary()
        rSummary.writeXML()

    except StandardError:
        err = sys.exc_info()
        logging.error("End %s" % err[1])
Пример #3
0
    optimizer = optim.Adam(model.parameters(), lr=args.lr)

    if amp is not None:
        model, optimizer = amp.initialize(model, optimizer, opt_level=args.amp)

    model = nn.DataParallel(model)
    model = model.to(device)

    scheduler = None
    if args.sched == 'cycle':
        scheduler = CycleScheduler(optimizer,
                                   args.lr,
                                   n_iter=len(loader) * args.epoch,
                                   momentum=None)

    logging = init_logging('log')
    log = logging.log
    writer = SummaryWriter('log/board')
    for i in range(args.epoch):
        log('--' * 50)
        train(args, i, loader, model, optimizer, scheduler, device, log,
              writer)
        log('--' * 50)
        test(args, i, loader, model, device, log, writer)
        torch.save(
            {
                'model': model.module.state_dict(),
                'args': args
            },
            f'checkpoint/pixelsnail_{args.hier}_{str(i + 1).zfill(3)}.pt',
        )
Пример #4
0
def runTestCase(testListFile, testID, grp=0):
    global U
    print "\n*** Running Test - %s *** \n" % testID

    initFile = ReadMapFile(testListFile, testID, "!")
    testFile = ReadMapFile(testListFile, testID, "!", 2)

    if initFile == -1 or testFile == -1:
        print "Invalid test case - %s" % testID
        exit(1)

    setattr(U, "initFile", initFile)

    #init Logging
    init_logging(U.testID, 1, grp)

    tmsPacket.ProgramName = U.progName

    logging.info("\n Test Info %s" % U)

    uccPath = U.cmdPath
    if uccPath.endswith('\\') == 0:
        uccPath = uccPath + '\\'

    setUCCPath(uccPath)
    initFile = uccPath + initFile
    testFile = uccPath + testFile
    # Run Init Env
    if not re.search("WMM-", testID):
        if U.qual:
            InitTestEnv(U.testID, U.cmdPath, U.progName, U.initFile, U.TBFile,
                        U.qual, U.TB_QUAL_AP, U.TB_QUAL_STA)
        else:
            InitTestEnv(U.testID, U.cmdPath, U.progName, U.initFile, U.TBFile)

    #Run UCC Core

    if os.path.exists(initFile) == 0:
        logging.error("Invalid file name - %s" % initFile)
        wfa_print_result("1")

    if os.path.exists(testFile) == 0:
        logging.error("Invalid file name - %s" % testFile)
        wfa_print_result("1")

    logging.info("\n %7s Testcase Init File = %s \n" % ("", initFile))
    logging.info("\n %7s Testcase Command File = %s \n" % ("", testFile))

    if U.qual:
        fileW = open("%s\DUTParam.txt" % (U.cmdPath), 'w')
        print "- DUT NAME [%s]" % U.DUT_NAME.lower()
        dut_ca = ReadMapFile(initFile,
                             "wfa_control_agent_%s" % U.DUT_NAME.lower(), "!")

        # Following assumes that $Channel is the first parmater in InitEnv.txt
        channel = ReadMapFile("%s\InitEnv.txt" % U.cmdPath, "define", "!", 2)
        band = "24G"
        if int(channel) > 35:
            band = "5G"

        fileW.write("wfa_control_agent_dut!%s!\n" % dut_ca)
        fileW.write("define!$DUT_Name!%s!\n" % (U.DUT_NAME))

        fileW.write("define!$DutMacAddress!$%sMACAddress_%s!\n" %
                    (U.DUT_NAME, band))

        fileW.write("define!$APUT_uname!%sUserName!\n" % (U.DUT_NAME))
        fileW.write("define!$APUT_pword!%sAPPassword!\n" % (U.DUT_NAME))
        fileW.write("define!$APUT_hostname!%sHostName!\n" % (U.DUT_NAME))
        fileW.close()

    logging.info("START: TEST CASE [%s] " % testID)
    try:
        expt_msg = ""
        fileInit = open(initFile)
        print "\n-------------------\n"
        scanner(fileInit, firstword)
        print "\n-------------------\n"
        process_cmdfile(testFile)

    except Exception:
        expt_msg = "%s" % sys.exc_info()[1]
    finally:
        if expt_msg != "":
            wfa_print_result(0, expt_msg)
        else:
            wfa_print_result(1)

        logging.info("END: TEST CASE [%s] " % testID)
        fileInit.close()
        reset()
    cap = skvideo.io.vreader(Video_source)

    # skip 500 frames to train bg subtractor
    train_bg_subtractor(bg_subtractor, cap, num=500)
    _frame_number = -1
    frame_number = -1
    for frame in cap:
        if not frame.any():
            log.error("frame capture failed, stopping...")
            break

        # real frame number
        _frame_number += 1
        #skipping every 2nd frame to speed up processing
        if _frame_number % 2 != 0:
            continue
        frame_number += 1

        pipeline.set_context({'frame': frame, 'frame_number': frame_number})
        pipeline.run()


# we check if the out image directory exists or not and call main function
if __name__ == "__main__":
    log = myutils.init_logging()

    if not os.path.exists(Image_dir):
        log.debug("Creating image directory '%s'....", Image_dir)
        os.makedirs(Image_dir)
    main()
Пример #6
0
def runTestCase(testListFile, testID, grp=0):
    global U, starttime
    print "\n*** Running Test - %s *** \n" % testID

    initFile = ReadMapFile(testListFile, testID, "!")
    testFile = ReadMapFile(testListFile, testID, "!", 2)

    if initFile == -1 or testFile == -1:
        print "Invalid test case - %s" % testID
        exit(1)

    setattr(U, "initFile", initFile)

    #init Logging
    init_logging(U.testID, 1, grp)

    tmsPacket.ProgramName = U.progName
    tmsPacket.TestResult = "FAIL"
    tmsPrint()

    logging.info("\n Test Info %s" % U)

    uccPath = U.cmdPath
    if uccPath.endswith('\\') == 0:
        uccPath = uccPath + '\\'

    setUCCPath(uccPath)
    initFile = uccPath + initFile
    testFile = uccPath + testFile
    # Run Init Env
    if not re.search("WMM-", testID):
        if U.qual:
            InitTestEnv(U.testID, U.cmdPath, U.progName, U.initFile, U.TBFile, U.qual, U.TB_QUAL_AP, U.TB_QUAL_STA)
        else:
            InitTestEnv(U.testID, U.cmdPath, U.progName, U.initFile, U.TBFile)


    #Run UCC Core

    if os.path.exists(initFile) == 0:
        logging.error("Invalid file name - %s" % initFile)
        wfa_print_result("1")

    if os.path.exists(testFile) == 0:
        logging.error("Invalid file name - %s" % testFile)
        wfa_print_result("1")

    logging.info("\n %7s Testcase Init File = %s \n" % ("", initFile))
    logging.info("\n %7s Testcase Command File = %s \n" % ("", testFile))

    if U.qual:
        fileW = open("%s\DUTParam.txt" % (U.cmdPath), 'w')
        print "- DUT NAME [%s]" % U.DUT_NAME.lower()
        dut_ca = ReadMapFile(initFile, "wfa_control_agent_%s" % U.DUT_NAME.lower(), "!")

        # Following assumes that $Channel is the first parmater in InitEnv.txt
        channel = ReadMapFile("%s\InitEnv.txt" % U.cmdPath, "define", "!", 2)
        band = "24G"
        if int(channel) > 35:
            band = "5G"

        fileW.write("wfa_control_agent_dut!%s!\n" % dut_ca)
        fileW.write("define!$DUT_Name!%s!\n" % (U.DUT_NAME))

        fileW.write("define!$DutMacAddress!$%sMACAddress_%s!\n" % (U.DUT_NAME, band))

        fileW.write("define!$APUT_uname!%sUserName!\n" % (U.DUT_NAME))
        fileW.write("define!$APUT_pword!%sAPPassword!\n" % (U.DUT_NAME))
        fileW.write("define!$APUT_hostname!%sHostName!\n" % (U.DUT_NAME))
        fileW.close()

    logging.info("START: TEST CASE [%s] " % testID)
    try:
        expt_msg = ""
        fileInit = open(initFile)
        print "\n-------------------\n"
        scanner(fileInit, firstword)
        print "\n-------------------\n"
        process_cmdfile(testFile)

    except Exception:
        expt_msg = "%s" % sys.exc_info()[1]
    finally:  
        if expt_msg != "":
            if re.search("r_info", expt_msg):
                wfa_print_result(1)
            else:
                wfa_print_result(0, expt_msg)
        else:
            wfa_print_result(1)

        if tmsPacket.TestResult != "PASS" and re.search("60G", U.testID):
            logging.info("#####Resetting the devices to their 60GHz defaults.....#####")
            resetFile = get_reset_default_file()
            if resetFile is None:
                logging.info("Reset file not found, skip resetting.....")
            else:
                resetFile= uccPath + resetFile
                process_cmdfile(resetFile)
        logging.info("END: TEST CASE [%s] " % testID)
        elapsed = (time.time() - starttime)
        logging.info("END: TEST CASE [%s]        Execution Time [%s] seconds" % (testID, round(elapsed,2)))
        fileInit.close()
        reset()
Пример #7
0
    device = 'cuda'

    transform = transforms.Compose([
        transforms.Resize(args.size),
        transforms.CenterCrop(args.size),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
    ])

    dataset = datasets.ImageFolder(args.path, transform=transform)
    loader = DataLoader(dataset, batch_size=128, shuffle=True, num_workers=4)

    model = nn.DataParallel(VQVAE()).to(device)

    optimizer = optim.Adam(model.parameters(), lr=args.lr)
    scheduler = None
    if args.sched == 'cycle':
        scheduler = CycleScheduler(
            optimizer,
            args.lr,
            n_iter=len(loader) * args.epoch,
            momentum=None  # len(loader)=batch size
        )

    log = init_logging(logging)  # log函数
    for i in range(args.epoch):
        train(i, loader, model, optimizer, scheduler, device, log)
        torch.save(model.module.state_dict(),
                   f'checkpoint/vqvae_{str(i + 1).zfill(3)}.pt')