Detectron/detectron/utils/train.py
def create_model():
    """Build the model and look for saved model checkpoints in case we can
    resume from one.
    """
    logger = logging.getLogger(__name__)
    start_iter = 0
    checkpoints = {}
    output_dir = get_output_dir(cfg.TRAIN.DATASETS, training=True)
    weights_file = cfg.TRAIN.WEIGHTS#'/home/icubic/daily_work/code/Detectron/train/coco_2014_train/generalized_rcnn_S1S2/model_final2.pkl'##cfg.TRAIN.WEIGHTS
    if cfg.TRAIN.AUTO_RESUME:
        # Check for the final model (indicates training already finished)
        final_path = os.path.join(output_dir, 'model_final.pkl')
        if os.path.exists(final_path):
            logger.info('model_final.pkl exists; no need to train!')
            return None, None, None, {'final': final_path}, output_dir

        if cfg.TRAIN.COPY_WEIGHTS:
            copyfile(
                weights_file,
                os.path.join(output_dir, os.path.basename(weights_file)))
            logger.info('Copy {} to {}'.format(weights_file, output_dir))

        # Find the most recent checkpoint (highest iteration number)
        files = os.listdir(output_dir)
        for f in files:
            iter_string = re.findall(r'(?<=model_iter)\d+(?=\.pkl)', f)
            if len(iter_string) > 0:
                checkpoint_iter = int(iter_string[0])
                if checkpoint_iter > start_iter:
                    # Start one iteration immediately after the checkpoint iter
                    start_iter = checkpoint_iter + 1
                    resume_weights_file = f

        if start_iter > 0:
            # Override the initialization weights with the found checkpoint
            weights_file = os.path.join(output_dir, resume_weights_file)
            logger.info(
                '========> Resuming from checkpoint {} at start iter {}'.
                format(weights_file, start_iter)
            )

    logger.info('Building model: {}'.format(cfg.MODEL.TYPE))
    model = model_builder.create(cfg.MODEL.TYPE, train=True)   #for create model
    if cfg.MEMONGER:
        optimize_memory(model)
    # Performs random weight initialization as defined by the model
    workspace.RunNetOnce(model.param_init_net)
    return model, weights_file, start_iter, checkpoints, output_dir
Build the model and look for saved model checkpoints in case we can
    resume from one.
    
Build the model and look for saved model checkpoints in case we can
resume from one.
Build the model and look for saved model checkpoints in case we can resume from one .
def create_model():
    logger = logging.getLogger(__name__)
    start_iter = 0
    checkpoints = {}
    output_dir = get_output_dir(cfg.TRAIN.DATASETS, training=True)
    weights_file = cfg.TRAIN.WEIGHTS
    if cfg.TRAIN.AUTO_RESUME:
        final_path = os.path.join(output_dir, 'model_final.pkl')
        if os.path.exists(final_path):
            logger.info('model_final.pkl exists; no need to train!')
            return None, None, None, {'final': final_path}, output_dir
        if cfg.TRAIN.COPY_WEIGHTS:
            copyfile(
                weights_file,
                os.path.join(output_dir, os.path.basename(weights_file)))
            logger.info('Copy {} to {}'.format(weights_file, output_dir))
        files = os.listdir(output_dir)
        for f in files:
            iter_string = re.findall(r'(?<=model_iter)\d+(?=\.pkl)', f)
            if len(iter_string) > 0:
                checkpoint_iter = int(iter_string[0])
                if checkpoint_iter > start_iter:
                    start_iter = checkpoint_iter + 1
                    resume_weights_file = f
        if start_iter > 0:
            weights_file = os.path.join(output_dir, resume_weights_file)
            logger.info(
                '========> Resuming from checkpoint {} at start iter {}'.
                format(weights_file, start_iter)
            )
    logger.info('Building model: {}'.format(cfg.MODEL.TYPE))
    model = model_builder.create(cfg.MODEL.TYPE, train=True)   
    if cfg.MEMONGER:
        optimize_memory(model)
    workspace.RunNetOnce(model.param_init_net)
    return model, weights_file, start_iter, checkpoints, output_dir
def create_model ( ) : logger = logging . getLogger ( __name__ ) start_iter = 0 checkpoints = { } output_dir = get_output_dir ( cfg . TRAIN . DATASETS , training = True ) weights_file = cfg . TRAIN . WEIGHTS if cfg . TRAIN . AUTO_RESUME : final_path = os . path . join ( output_dir , 'model_final.pkl' ) if os . path . exists ( final_path ) : logger . info ( 'model_final.pkl exists; no need to train!' ) return None , None , None , { 'final' : final_path } , output_dir if cfg . TRAIN . COPY_WEIGHTS : copyfile ( weights_file , os . path . join ( output_dir , os . path . basename ( weights_file ) ) ) logger . info ( 'Copy {} to {}' . format ( weights_file , output_dir ) ) files = os . listdir ( output_dir ) for f in files : iter_string = re . findall ( r'(?<=model_iter)\d+(?=\.pkl)' , f ) if len ( iter_string ) > 0 : checkpoint_iter = int ( iter_string [ 0 ] ) if checkpoint_iter > start_iter : start_iter = checkpoint_iter + 1 resume_weights_file = f if start_iter > 0 : weights_file = os . path . join ( output_dir , resume_weights_file ) logger . info ( '========> Resuming from checkpoint {} at start iter {}' . format ( weights_file , start_iter ) ) logger . info ( 'Building model: {}' . format ( cfg . MODEL . TYPE ) ) model = model_builder . create ( cfg . MODEL . TYPE , train = True ) if cfg . MEMONGER : optimize_memory ( model ) workspace . RunNetOnce ( model . param_init_net ) return model , weights_file , start_iter , checkpoints , output_dir
Build the model and look for saved model checkpoints in case we can
resume from one.
Build the model and look for saved model checkpoints in case we can resume from one .
"""Build the model and look for saved model checkpoints in case we can
    resume from one.
    """ #'/home/icubic/daily_work/code/Detectron/train/coco_2014_train/generalized_rcnn_S1S2/model_final2.pkl'##cfg.TRAIN.WEIGHTS # Check for the final model (indicates training already finished) # Find the most recent checkpoint (highest iteration number) # Start one iteration immediately after the checkpoint iter # Override the initialization weights with the found checkpoint #for create model # Performs random weight initialization as defined by the model