dataset/hisdb.py
def prepare_hisdb(data_dir=DEFAULT_DATA_DIR,
                  out_dir=None,
                  force=False):
  """ Downloads and extracts dibco dataset and its annotation data. """
  if not os.path.exists(data_dir):
    os.makedirs(data_dir)
  if out_dir is None:
    out_dir = data_dir
  if not os.path.exists(out_dir):
    os.makedirs(out_dir)

  train_record = 'train.record'
  test_record = 'test.record'
  num_train = 'num_train'
  num_test = 'num_test'

  if not (os.path.exists(os.path.join(data_dir, train_record)) and
          os.path.exists(os.path.join(data_dir, test_record)) and
          os.path.exists(os.path.join(data_dir, num_train)) and
          os.path.exists(os.path.join(data_dir, num_test))) or force:
    maybe_download(get_hisdb_meta_data(data_dir)['url'], data_dir, force=force)

    extracted_dir = os.path.join(data_dir, DATA_EXTRACTED_DIR)

    with open(os.path.join(extracted_dir, 'train.txt')) as i_f:
      with open(os.path.join(data_dir, num_train), mode='w') as o_f:
        o_f.write(str(len(i_f.readlines())))
    train_writer = tf.python_io.TFRecordWriter(
      os.path.join(out_dir, train_record))
    for data in get_label_map_dict(
        extracted_dir, os.path.join(extracted_dir, 'train.txt')):
      example = dict_to_example(data, gt_fn=parse_xml)
      train_writer.write(example.SerializeToString())
    train_writer.close()

    with open(os.path.join(extracted_dir, 'test.txt')) as i_f:
      with open(os.path.join(data_dir, num_test), mode='w') as o_f:
        o_f.write(str(len(i_f.readlines())))
    val_writer = tf.python_io.TFRecordWriter(os.path.join(out_dir, test_record))
    for data in get_label_map_dict(
        extracted_dir, os.path.join(extracted_dir, 'test.txt')):
      example = dict_to_example(data, gt_fn=parse_xml)
      val_writer.write(example.SerializeToString())
    val_writer.close()
    print()

  return get_hisdb_meta_data(data_dir)
 Downloads and extracts dibco dataset and its annotation data. 
Downloads and extracts dibco dataset and its annotation data.
Downloads and extracts dibco dataset and its annotation data .
def prepare_hisdb(data_dir=DEFAULT_DATA_DIR,
                  out_dir=None,
                  force=False):
  if not os.path.exists(data_dir):
    os.makedirs(data_dir)
  if out_dir is None:
    out_dir = data_dir
  if not os.path.exists(out_dir):
    os.makedirs(out_dir)
  train_record = 'train.record'
  test_record = 'test.record'
  num_train = 'num_train'
  num_test = 'num_test'
  if not (os.path.exists(os.path.join(data_dir, train_record)) and
          os.path.exists(os.path.join(data_dir, test_record)) and
          os.path.exists(os.path.join(data_dir, num_train)) and
          os.path.exists(os.path.join(data_dir, num_test))) or force:
    maybe_download(get_hisdb_meta_data(data_dir)['url'], data_dir, force=force)
    extracted_dir = os.path.join(data_dir, DATA_EXTRACTED_DIR)
    with open(os.path.join(extracted_dir, 'train.txt')) as i_f:
      with open(os.path.join(data_dir, num_train), mode='w') as o_f:
        o_f.write(str(len(i_f.readlines())))
    train_writer = tf.python_io.TFRecordWriter(
      os.path.join(out_dir, train_record))
    for data in get_label_map_dict(
        extracted_dir, os.path.join(extracted_dir, 'train.txt')):
      example = dict_to_example(data, gt_fn=parse_xml)
      train_writer.write(example.SerializeToString())
    train_writer.close()
    with open(os.path.join(extracted_dir, 'test.txt')) as i_f:
      with open(os.path.join(data_dir, num_test), mode='w') as o_f:
        o_f.write(str(len(i_f.readlines())))
    val_writer = tf.python_io.TFRecordWriter(os.path.join(out_dir, test_record))
    for data in get_label_map_dict(
        extracted_dir, os.path.join(extracted_dir, 'test.txt')):
      example = dict_to_example(data, gt_fn=parse_xml)
      val_writer.write(example.SerializeToString())
    val_writer.close()
    print()
  return get_hisdb_meta_data(data_dir)
def prepare_hisdb ( data_dir = DEFAULT_DATA_DIR , out_dir = None , force = False ) : if not os . path . exists ( data_dir ) : os . makedirs ( data_dir ) if out_dir is None : out_dir = data_dir if not os . path . exists ( out_dir ) : os . makedirs ( out_dir ) train_record = 'train.record' test_record = 'test.record' num_train = 'num_train' num_test = 'num_test' if not ( os . path . exists ( os . path . join ( data_dir , train_record ) ) and os . path . exists ( os . path . join ( data_dir , test_record ) ) and os . path . exists ( os . path . join ( data_dir , num_train ) ) and os . path . exists ( os . path . join ( data_dir , num_test ) ) ) or force : maybe_download ( get_hisdb_meta_data ( data_dir ) [ 'url' ] , data_dir , force = force ) extracted_dir = os . path . join ( data_dir , DATA_EXTRACTED_DIR ) with open ( os . path . join ( extracted_dir , 'train.txt' ) ) as i_f : with open ( os . path . join ( data_dir , num_train ) , mode = 'w' ) as o_f : o_f . write ( str ( len ( i_f . readlines ( ) ) ) ) train_writer = tf . python_io . TFRecordWriter ( os . path . join ( out_dir , train_record ) ) for data in get_label_map_dict ( extracted_dir , os . path . join ( extracted_dir , 'train.txt' ) ) : example = dict_to_example ( data , gt_fn = parse_xml ) train_writer . write ( example . SerializeToString ( ) ) train_writer . close ( ) with open ( os . path . join ( extracted_dir , 'test.txt' ) ) as i_f : with open ( os . path . join ( data_dir , num_test ) , mode = 'w' ) as o_f : o_f . write ( str ( len ( i_f . readlines ( ) ) ) ) val_writer = tf . python_io . TFRecordWriter ( os . path . join ( out_dir , test_record ) ) for data in get_label_map_dict ( extracted_dir , os . path . join ( extracted_dir , 'test.txt' ) ) : example = dict_to_example ( data , gt_fn = parse_xml ) val_writer . write ( example . SerializeToString ( ) ) val_writer . close ( ) print ( ) return get_hisdb_meta_data ( data_dir )
Downloads and extracts dibco dataset and its annotation data.
Downloads and extracts dibco dataset and its annotation data .
""" Downloads and extracts dibco dataset and its annotation data. """
data_dir
out_dir
force