Пример #1
0
def save_checkpoint(state, is_best, filename='*_checkpoint.pth.tar'):
    work_dir = os.path.basename(os.path.dirname(os.path.realpath(__file__)))
    save_dir = os.path.join('./checkpoints/', work_dir)
    cine(save_dir)

    filename = filename.replace('*', time_string)
    filename = os.path.join(save_dir, filename)
    torch.save(state, filename)
    if is_best:
        shutil.copyfile(filename, os.path.join(save_dir, time_string+'_model_best.pth.tar'))
Пример #2
0
def save_checkpoint(state, filename='*_checkpoint.pth.tar'):
    work_dir = os.path.basename(os.path.dirname(os.path.realpath(__file__)))
    save_dir = os.path.join('/mv_users/peiguo/checkpoints/', work_dir)
    cine(save_dir)
    symlink = './checkpoints'
    if not os.path.exists(symlink):
        os.symlink(save_dir, symlink)

    filename = filename.replace('*', time_string)
    filename = os.path.join(save_dir, filename)
    torch.save(state, filename)
Пример #3
0
                    help='evaluate model on validation set')
parser.add_argument('--pretrained', dest='pretrained', action='store_true',
                    help='use pre-trained model')
parser.add_argument('--lr_decay', default='50', type=int,
                    help='lr decay frequency')
parser.add_argument('--crop_size', default='256', type=int,
                    help='size of cropped image')
parser.add_argument('--visualize', dest='visualize', action='store_true',
                    help='visualize middle output')
parser.add_argument('--nparts', default='15', type=int,
                    help='number of keypoints')

best_prec1 = 0
time_string = datetime.now().strftime('%Y_%m_%d_%H_%M_%S')

cine('logs')
Tee('logs/cmd_log_{}'.format(time_string), 'w')

unisize = 256
outsize = 64

def main():
    global args, best_prec1
    args = parser.parse_args()
    print(args)

    global fig, ax1, ax2, ax3, ax4
    if args.visualize:
        plt.ion()
        plt.show()
        fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2)