Example #1
0
File: script.py Project: icchy/7vi
def response(flow):
    url = flow.request.url
    orig_path = get_path(url, origdir)
    orig_dir_path = os.path.dirname(orig_path)
    if not os.path.exists(orig_dir_path):
        os.makedirs(orig_dir_path)
    with open(orig_path, 'wb') as fp:
        fp.write(flow.response.content)

    mod_path = get_path(url, moddir)
    if os.path.exists(mod_path):
        # rewrite response
        with open(mod_path, 'rb') as fp:
            flow.response.content = fp.read()
Example #2
0
def poor_log(msg, *args):
    from time import strftime
    from lib import get_path
    timestamp = strftime("%Y-%m-%d %H:%M:%S")
    log_file = get_path('log')
    with open(log_file, 'a+b', 0) as f:
        format = "[%s]" % timestamp + msg + "\n"
        f.write(format % args)
Example #3
0
def edit(url):
    origpath = get_path(url, origdir)
    modpath = get_path(url, moddir)
    editor = os.getenv('EDITOR', 'vim')

    cp_ts = None
    if not os.path.exists(modpath) and os.path.exists(origpath):
        modpath_dir = os.path.dirname(modpath)
        if not os.path.exists(modpath_dir):
            os.makedirs(modpath_dir)
        shutil.copyfile(origpath, modpath)
        cp_ts = get_ts(modpath)

    ret = subprocess.call([editor, modpath])

    # delete if no changes on copied file
    if cp_ts and cp_ts == get_ts(modpath):
        logger.info('no changes on {}'.format(modpath))
        os.remove(modpath)
Example #4
0
    def __init__(self, proj_path, cfg, network = None):
        self._cfg = cfg
        self._root_path = proj_path
        self.net = network
        # self.output_dir = output_dir

        pretrained_model_path = os.path.join(self._root_path,
                                             cfg.COMMON.DATA_PATH, cfg.TRAIN.PRETRAIN)
        pretrained_model = os.listdir(pretrained_model_path)

        assert len(pretrained_model) == 1, 'pretrain model should be one'
        self._pretrain = os.path.join(pretrained_model_path, pretrained_model[0])

        self._ckpt_path = get_path(os.path.join(self._root_path, cfg.COMMON.DATA_PATH, cfg.TRAIN.CKPT))
        self._restore = cfg.TRAIN.RESTORE
        self._max_iter = cfg.TRAIN.MAX_ITER
Example #5
0
if __name__ == '__main__':
    # print(os.getcwd())
    cfg = load_config()
    print('Using config:')
    # pprint.pprint(cfg)

    """
    @params
     use_cache 是否从重新进行data_process过程,一般dataset/for_train文件发生变化需要进行
    """
    roidb = get_training_roidb(cfg)  # 返回roidb roidb就是我们需要的对象实例

    # output_dir = get_path('dataset/output')
    # log_dir = get_path('dataset/log')

    checkpoints_dir = get_path(cfg.COMMON.CKPT)

    # print('Output will be saved to {:s}'.format(output_dir))
    # print('Logs will be saved to {:s}'.format(log_dir))

    # """
    # @params 
    # network ctpn_network 实例
    # roidb roi 列表
    # output_dir tensorflow输出的 绝对路径 要拼接本地机器所在的运行目录
    # log_dir 日志输出 绝对路径
    # max_iter 训练轮数
    # pretrain_model 预训练VGG16模型 绝对路径
    # restore bool值 是否从checkpoints断点开始恢复上次中断的训练
    # """
    vgg16_net_param = '../dataset/pretrain/VGG_imagenet.npy'
Example #6
0
    total_rows += sheet.max_row
    keys = {}
    for j, row in enumerate(sheet.rows):
        if j > 0:
            break
        for k, cell in enumerate(row):  # Проверяем, чтобы был СНИЛС и Код
            if cell.value in IN_SNILS:
                keys[IN_SNILS[0]] = k
        if len(keys) < 1:
            print('В файле "' + sys.argv[i + 1] +
                  '" отсутствует колонка со СНИЛС')
            time.sleep(3)
            sys.exit()
    sheets_keys.append(keys)

path = get_path(sys.argv[1])

print('\n' + datetime.now().strftime("%H:%M:%S") +
      ' Начинаем преобразование и нарезку xlsx файлов \n')

k = 1  # Счетчик строк в csv
file_number = 1
cl_csvs = []
for i, sheet in enumerate(
        sheets):  # Загружаем все xlsx файлы по мере сохранения в БД
    for j, row in enumerate(sheet.rows):  # Теперь строки
        if j == 0:
            continue
        cl_csv = {}
        if lenl(row[keys[IN_SNILS[0]]].value
                ) < 12:  # and l(row[keys[IN_SNILS[0]]].value) > 100:
Example #7
0
from ctpn.train_net import train_net
from lib.load_config import load_config
from data_process.roidb import get_training_roidb
from lib import get_path

if __name__ == '__main__':
    cfg = load_config()
    print('Using config:')
    pprint.pprint(cfg)
    """
    @params
     use_cache 是否从重新进行data_process过程,一般dataset/for_train文件发生变化需要进行
    """
    roidb = get_training_roidb(cfg)  # 返回roidb roidb就是我们需要的对象实例

    output_dir = get_path('dataset/output')
    log_dir = get_path('dataset/log')

    checkpoints_dir = get_path(cfg.COMMON.CKPT)

    print('Output will be saved to {:s}'.format(output_dir))
    print('Logs will be saved to {:s}'.format(log_dir))

    # """
    # @params
    # network ctpn_network 实例
    # roidb roi 列表
    # output_dir tensorflow输出的 绝对路径 要拼接本地机器所在的运行目录
    # log_dir 日志输出 绝对路径
    # max_iter 训练轮数
    # pretrain_model 预训练VGG16模型 绝对路径