This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'STLR scheduler from https://arxiv.org/abs/1801.06146' | |
class STLR(_LRScheduler): | |
def __init__(self, optimizer, T_max, last_epoch=-1, ratio=32): | |
self.T_max = T_max | |
self.cut = np.floor(T_max*0.1) | |
self.ratio = ratio | |
super(STLR, self).__init__(optimizer, last_epoch) | |
def get_lr(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LandMarkRecognition(Dataset): | |
def __init__(self, root_dir, csv_file, transform=None): | |
self.landmarks_csv = pd.read_csv(csv_file) | |
self.root_dir = root_dir | |
self.transform = transform | |
self.image_names = [i for i in sorted(os.listdir(self.root_dir)) if i.endswith('.jpg')] | |
# print(len(self.image_names)) | |
def __len__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import argparse | |
import os | |
import time | |
import pdb | |
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" | |
os.environ["CUDA_VISIBLE_DEVICES"] = "3" | |
import random | |
import torch | |
import torch.nn as nn |