google-research

Форк
0
/
generate_data.py 
48 строк · 1.4 Кб
1
# coding=utf-8
2
# Copyright 2024 The Google Research Authors.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
"""Process csv data to tfrecords."""
17

18
import os
19

20
from absl import app
21
from absl import flags
22
import tensorflow.compat.v1 as tf
23

24
from protein_lm import data
25

26
FLAGS = flags.FLAGS
27

28
flags.DEFINE_string(
29
    'input_dir', default='', help=('Directory to load CSVs from.'))
30
flags.DEFINE_string(
31
    'output_dir', default='', help=('Directory to output tfrecords to.'))
32

33

34
def main(argv):
35
  if not FLAGS.input_dir:
36
    raise ValueError('Must provide input directory.')
37
  if not FLAGS.output_dir:
38
    raise ValueError('Must provide output directory.')
39

40
  files = tf.gfile.Glob(os.path.join(FLAGS.input_dir, '*.csv'))
41
  tf.gfile.MakeDirs(FLAGS.output_dir)
42
  for i, file in enumerate(files):
43
    file = os.path.join(FLAGS.input_dir, file)
44
    print(file)
45
    data.csv_to_tfrecord(file, FLAGS.output_dir, idx=i, total=len(files))
46

47
if __name__ == '__main__':
48
  app.run(main)
49

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.