Exemplo n.º 1
0
def main():
    """
    Inputs: 
    None
    Outputs:
    Runs Testing code
    """
    # TODO: Make LogDir
    # TODO: Display time to end and cleanup other print statements with color
    # TODO: Make logging file a parameter

    # Parse Command Line arguments
    Parser = argparse.ArgumentParser()
    Parser.add_argument('--ModelPath', dest='ModelPath', default='/media/nitin/Research/EVDodge/CheckpointsEVDBHomographyDodgeNetLR5e-4Epoch200/199model.ckpt',\
                                                         help='Path to load latest model from, Default:ModelPath')
    Parser.add_argument('--ReadPath', dest='ReadPath', default='/media/nitin/Research/EVDodge/DatasetChethanEvents/DeblurredHomography',\
                                                                             help='Path to load images from, Default:ReadPath')
    Parser.add_argument('--WritePath', dest='WritePath', default='/media/nitin/Research/EVDodge/DatasetChethanEvents/DeblurredHomographyDodgeNet',\
                                                                             help='Path to write images to, Default:WritePath')
    Parser.add_argument(
        '--GPUDevice',
        type=int,
        default=0,
        help='What GPU do you want to use? -1 for CPU, Default:0')

    Args = Parser.parse_args()
    ModelPath = Args.ModelPath
    ReadPath = Args.ReadPath
    WritePath = Args.WritePath
    GPUDevice = Args.GPUDevice

    # Set GPUDevice
    tu.SetGPU(GPUDevice)

    # Setup all needed parameters including file reading
    TrainNames, ImageSize, PatchSize, NumTrainSamples, NumImgsStack = SetupAll(
        ReadPath)

    # Define PlaceHolder variables for Input and Predicted output
    PatchPH = tf.placeholder(tf.float32,
                             shape=(1, PatchSize[0], PatchSize[1],
                                    2 * PatchSize[2]),
                             name='Input')

    TestOperation(PatchPH, PatchSize, ModelPath, ReadPath, WritePath,
                  TrainNames, NumTrainSamples)
Exemplo n.º 2
0
def main():
    """
    Inputs: 
    None
    Outputs:
    Runs the Training and testing code based on the Flag
    """
    # TODO: Make LogDir
    # TODO: Make logging file a parameter
    # TODO: Time to complete print

    # Parse Command Line arguments
    Parser = argparse.ArgumentParser()
    Parser.add_argument('--BasePath', default='/home/nitin/EVDodge/DatasetsForPaper/DownfacingEventsProcessed', help='Base path of images, Default:/home/nitin/EVDodge/DatasetsForPaper/DownfacingEventsProcessed')
    Parser.add_argument('--NumEpochs', type=int, default=200, help='Number of Epochs to Train for, Default:200')
    Parser.add_argument('--DivTrain', type=int, default=1, help='Factor to reduce Train data by per epoch, Default:1')
    Parser.add_argument('--MiniBatchSize', type=int, default=256, help='Size of the MiniBatch to use, Default:256')
    Parser.add_argument('--LoadCheckPoint', type=int, default=0, help='Load Model from latest Checkpoint from CheckPointsPath?, Default:0')
    Parser.add_argument('--LossFuncName', default='PhotoL1', help='Choice of Loss functions, choose from PhotoL1, PhotoChab, PhotoRobust when using TrainingType as US. Default:PhotoL1')
    Parser.add_argument('--NetworkType', default='Small', help='Choice of Network type, choose from Small, Large, Default:Small')
    Parser.add_argument('--CheckPointPath', default='../CheckpointsHomography/', help='Path to save checkpoints, Default:../CheckpointsHomography/')
    Parser.add_argument('--LogsPath', default='/media/nitin/Research/EVDodge/Logs/', help='Path to save Logs, Default:/media/nitin/Research/EVDodge/Logs/')
    Parser.add_argument('--GPUDevice', type=int, default=0, help='What GPU do you want to use? -1 for CPU, Default:0')
    Parser.add_argument('--LR', type=float, default=1e-4, help='Learning Rate, Default: 1e-4')
    Parser.add_argument('--TrainingType', default='US', help='Training Type, S: Supervised, US: Unsupervised, Default: US')
    
    Args = Parser.parse_args()
    NumEpochs = Args.NumEpochs
    BasePath = Args.BasePath
    DivTrain = float(Args.DivTrain)
    MiniBatchSize = Args.MiniBatchSize
    LoadCheckPoint = Args.LoadCheckPoint
    LossFuncName = Args.LossFuncName
    NetworkType = Args.NetworkType
    CheckPointPath = Args.CheckPointPath
    LogsPath = Args.LogsPath
    GPUDevice = Args.GPUDevice
    LearningRate = Args.LR
    TrainingType = Args.TrainingType
    
    # Set GPUDevice
    tu.SetGPU(GPUDevice)

    # Setup all needed parameters including file reading
    TrainNames, ValNames, TestNames, OptimizerParams,\
    SaveCheckPoint, ImageSize, Rho, NumTrainSamples, NumValSamples, NumTestSamples,\
    NumTestRunsPerEpoch = SetupAll(BasePath, LearningRate)

    # If CheckPointPath doesn't exist make the path
    if(not (os.path.isdir(CheckPointPath))):
       os.makedirs(CheckPointPath)

    # Find Latest Checkpoint File
    if LoadCheckPoint==1:
        LatestFile = FindLatestModel(CheckPointPath)
    else:
        LatestFile = None
    
    # Pretty print stats
    PrettyPrint(NumEpochs, DivTrain, MiniBatchSize, NumTrainSamples, NumTestSamples, LatestFile)
        
    # Define PlaceHolder variables for Input and Predicted output
    ImgPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, ImageSize[0], ImageSize[1], 6), name='Input')

    # PH for losses
    I1PH = tf.placeholder(tf.float32, shape=(MiniBatchSize, 260, 346, 3), name='I1')
    I2PH = tf.placeholder(tf.float32, shape=(MiniBatchSize, 260, 346, 3), name='I2')
    MaskPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, 260, 346, 3), name='Mask')
    AllPtsPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, 4, 2), name='AllPts')
    LabelPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, 8, 1), name='Label')  

    TrainOperation(ImgPH, I1PH, I2PH, MaskPH, AllPtsPH, LabelPH, TrainNames, TestNames, NumTrainSamples, ImageSize, Rho,
                   NumEpochs, MiniBatchSize, OptimizerParams, SaveCheckPoint, CheckPointPath, NumTestRunsPerEpoch,
                   DivTrain, LatestFile, LossFuncName, NetworkType, BasePath, LogsPath, TrainingType)
Exemplo n.º 3
0
def main():
    """
    Inputs: 
    None
    Outputs:
    Runs the Training and testing code based on the Flag
    """
    # TODO: Make LogDir
    # TODO: Make logging file a parameter
    # TODO: Time to complete print

    # Parse Command Line arguments
    Parser = argparse.ArgumentParser()
    Parser.add_argument('--BasePath', default='/media/nitin/Research/EVDodge/downfacing_processed', help='Base path of images, Default:/media/nitin/Research/EVDodge/downfacing_processed')
    Parser.add_argument('--NumEpochs', type=int, default=200, help='Number of Epochs to Train for, Default:200')
    Parser.add_argument('--DivTrain', type=int, default=1, help='Factor to reduce Train data by per epoch, Default:1')
    Parser.add_argument('--MiniBatchSize', type=int, default=256, help='Size of the MiniBatch to use, Default:256')
    Parser.add_argument('--LoadCheckPoint', type=int, default=0, help='Load Model from latest Checkpoint from CheckPointsPath?, Default:0')
    Parser.add_argument('--CheckPointPath', default='../CheckpointsHomography/', help='Path to save checkpoints, Default:../CheckpointsHomography/')
    Parser.add_argument('--LogsPath', default='/media/nitin/Research/EVDodge/Logs/', help='Path to save Logs, Default:/media/nitin/Research/EVDodge/Logs/')
    Parser.add_argument('--LossFuncName', default='M', help='Choice of Loss functions, choose from M for Mean, V for Variance, Default:M')
    Parser.add_argument('--GPUDevice', type=int, default=0, help='What GPU do you want to use? -1 for CPU, Default:0')
    Parser.add_argument('--LR', type=float, default=1e-4, help='Learning Rate, Default: 1e-4')
    Parser.add_argument('--SymType', default='L1', help='Similarity mapping, choose from L1 and Chab, Default:L1')
    
    Args = Parser.parse_args()
    NumEpochs = Args.NumEpochs
    BasePath = Args.BasePath
    DivTrain = float(Args.DivTrain)
    MiniBatchSize = Args.MiniBatchSize
    LoadCheckPoint = Args.LoadCheckPoint
    CheckPointPath = Args.CheckPointPath
    LogsPath = Args.LogsPath
    LossFuncName = Args.LossFuncName
    GPUDevice = Args.GPUDevice
    LearningRate = Args.LR
    SymType = Args.SymType
    
    # Set GPUDevice
    tu.SetGPU(GPUDevice)


    # Setup all needed parameters including file reading
    TrainNames, ValNames, TestNames, OptimizerParams,\
    SaveCheckPoint, ImageSize, PatchSize, NumTrainSamples, NumValSamples, NumTestSamples,\
    NumTestRunsPerEpoch = SetupAll(BasePath, LearningRate)

    # Find Latest Checkpoint File
    if LoadCheckPoint==1:
        LatestFile = FindLatestModel(CheckPointPath)
    else:
        LatestFile = None
    
    # Pretty print stats
    PrettyPrint(NumEpochs, DivTrain, MiniBatchSize, NumTrainSamples, NumTestSamples, LatestFile)
        
    # Define PlaceHolder variables for Input and Predicted output
    PatchPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, PatchSize[0], PatchSize[1], PatchSize[2]), name='Input')

    # PH for losses
    IPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, ImageSize[0], ImageSize[1], ImageSize[2]), name='IPH')
    MaskPH = tf.placeholder(tf.float32, shape=(MiniBatchSize, ImageSize[0], ImageSize[1], ImageSize[2]), name='Mask')

    TrainOperation(PatchPH, IPH, MaskPH, TrainNames, TestNames, NumTrainSamples, ImageSize, PatchSize,
                   NumEpochs, MiniBatchSize, OptimizerParams, SaveCheckPoint, CheckPointPath, NumTestRunsPerEpoch,
                   DivTrain, LatestFile, LossFuncName, BasePath, LogsPath, SymType)
Exemplo n.º 4
0
def main():
    """
    Inputs: 
    None
    Outputs:
    Runs Testing code
    """
    # TODO: Make LogDir
    # TODO: Display time to end and cleanup other print statements with color
    # TODO: Make logging file a parameter

    # Parse Command Line arguments
    Parser = argparse.ArgumentParser()
    Parser.add_argument('--ModelPath', dest='ModelPath', default='/media/nitin/Research/EVDodge/CheckpointsDeblurHomographyLR1e-4Epochs400/399model.ckpt',\
                                                         help='Path to load latest model from, Default:ModelPath')
    Parser.add_argument('--ReadPath', dest='ReadPath', default='/media/nitin/Research/EVDodge/DatasetChethanEvents/Deblurred',\
                                                                             help='Path to load images from, Default:ReadPath')
    Parser.add_argument('--WritePath', dest='WritePath', default='/media/nitin/Research/EVDodge/DatasetChethanEvents/DeblurredHomography',\
                                                                             help='Path to load images from, Default:WritePath')
    Parser.add_argument(
        '--GPUDevice',
        type=int,
        default=0,
        help='What GPU do you want to use? -1 for CPU, Default:0')
    Parser.add_argument(
        '--CropType',
        dest='CropType',
        default='C',
        help=
        'What kind of crop do you want to perform? R: Random, C: Center, Default: C'
    )

    Args = Parser.parse_args()
    ModelPath = Args.ModelPath
    ReadPath = Args.ReadPath
    WritePath = Args.WritePath
    GPUDevice = Args.GPUDevice
    CropType = Args.CropType

    # Set GPUNum
    tu.SetGPU(GPUDevice)

    # Setup all needed parameters including file reading
    TrainNames, ImageSize, PatchSize, NumTrainSamples = SetupAll(ReadPath)

    # Define PlaceHolder variables for Input and Predicted output
    PatchPH = tf.placeholder(tf.float32,
                             shape=(1, PatchSize[0], PatchSize[1],
                                    PatchSize[2] * 2),
                             name='Input')
    I1PH = tf.placeholder(tf.float32,
                          shape=(1, PatchSize[0], PatchSize[1], PatchSize[2]),
                          name='I1')
    I2PH = tf.placeholder(tf.float32,
                          shape=(1, PatchSize[0], PatchSize[1], PatchSize[2]),
                          name='I2')

    if (not os.path.exists(WritePath)):
        cprint("WARNING: %s doesnt exist, Creating it." % WritePath, 'yellow')
        os.mkdir(WritePath)

    TestOperation(PatchPH, I1PH, I2PH, PatchSize, ModelPath, ReadPath,
                  WritePath, TrainNames, NumTrainSamples, CropType)
Exemplo n.º 5
0
def main():
    """
    Inputs: 
    None
    Outputs:
    Runs the Training and testing code based on the Flag
    """
    # TODO: Make LogDir
    # TODO: Make logging file a parameter
    # TODO: Time to complete print

    # Parse Command Line arguments
    Parser = argparse.ArgumentParser()
    Parser.add_argument(
        '--BasePath',
        default=
        '/media/nitin/Research/EVDodge/DatasetChethanEvents/DeblurredHomography',
        help=
        'Base path of images, Default:/media/nitin/Research/EVDodge/processed')
    Parser.add_argument('--NumEpochs',
                        type=int,
                        default=200,
                        help='Number of Epochs to Train for, Default:200')
    Parser.add_argument(
        '--DivTrain',
        type=int,
        default=1,
        help='Factor to reduce Train data by per epoch, Default:1')
    Parser.add_argument('--MiniBatchSize',
                        type=int,
                        default=256,
                        help='Size of the MiniBatch to use, Default:256')
    Parser.add_argument(
        '--LoadCheckPoint',
        type=int,
        default=0,
        help=
        'Load Model from latest Checkpoint from CheckPointsPath?, Default:0')
    Parser.add_argument(
        '--GPUDevice',
        type=int,
        default=0,
        help='What GPU do you want to use? -1 for CPU, Default:0')
    Parser.add_argument(
        '--CheckPointPath',
        default='../CheckpointsSeg/',
        help='Path to save checkpoints, Default:../CheckpointsSeg/')
    Parser.add_argument(
        '--LogsPath',
        default='/media/nitin/Research/EVDodge/LogsSeg/',
        help='Path to save Logs, Default:/media/nitin/Research/EVDodge/LogsSeg/'
    )
    Parser.add_argument('--LR',
                        type=float,
                        default=1e-3,
                        help='Learning Rate, Default: 1e-3')
    Parser.add_argument(
        '--MaxFrameDiff',
        type=int,
        default=1,
        help='Maximum Frame difference to feed into network, Default: 1')

    Args = Parser.parse_args()
    NumEpochs = Args.NumEpochs
    BasePath = Args.BasePath
    DivTrain = float(Args.DivTrain)
    MiniBatchSize = Args.MiniBatchSize
    LoadCheckPoint = Args.LoadCheckPoint
    GPUDevice = Args.GPUDevice
    CheckPointPath = Args.CheckPointPath
    LogsPath = Args.LogsPath
    LearningRate = Args.LR
    MaxFrameDiff = Args.MaxFrameDiff

    # Set GPUDevice
    tu.SetGPU(GPUDevice)

    # If CheckPointPath doesn't exist make the path
    if (not (os.path.isdir(CheckPointPath))):
        os.makedirs(CheckPointPath)

    # If LogsPath doesn't exist make the path
    if (not (os.path.isdir(LogsPath))):
        os.makedirs(LogsPath)

    # Setup all needed parameters including file reading
    TrainNames, TrainLabels, OptimizerParams, SaveCheckPoint, Factor, ImageSize, NumTrainSamples = SetupAll(
        BasePath, LearningRate)

    # Find Latest Checkpoint File
    if LoadCheckPoint == 1:
        LatestFile = FindLatestModel(CheckPointPath)
    else:
        LatestFile = None

    # Pretty print stats
    PrettyPrint(NumEpochs, DivTrain, MiniBatchSize, NumTrainSamples,
                LatestFile)

    # Define PlaceHolder variables for Input and Predicted output
    ImgPH = tf.placeholder(tf.float32,
                           shape=(MiniBatchSize, ImageSize[0], ImageSize[1],
                                  6),
                           name='Input')
    I1PH = tf.placeholder(tf.float32,
                          shape=(MiniBatchSize, ImageSize[0], ImageSize[1], 3),
                          name='I1')
    I2PH = tf.placeholder(tf.float32,
                          shape=(MiniBatchSize, ImageSize[0], ImageSize[1], 3),
                          name='I2')
    LabelPH = tf.placeholder(tf.float32,
                             shape=(MiniBatchSize, ImageSize[0], ImageSize[1],
                                    2),
                             name='Label')  # 2 classes

    TrainOperation(ImgPH, I1PH, I2PH, LabelPH, TrainNames, TrainLabels,
                   NumTrainSamples, Factor, ImageSize, NumEpochs,
                   MiniBatchSize, OptimizerParams, SaveCheckPoint,
                   CheckPointPath, DivTrain, LatestFile, MaxFrameDiff,
                   LogsPath, BasePath)