google-research

Форк
0
45 строк · 1.7 Кб
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
"""Example code to create tfrecord for training."""
17

18
import numpy as np
19
import tensorflow as tf
20

21
with tf.io.TFRecordWriter('example.tfrecord') as writer:
22
  for _ in range(5):  # Iterate over 5 examples
23
    frames = 100  # Number of frames in the example video
24
    fps = 25  # FPS in the example video
25

26
    is_signing = np.random.randint(
27
        low=0, high=1, size=(frames), dtype='byte').tobytes()
28
    data = tf.io.serialize_tensor(
29
        tf.random.normal(shape=(frames, 1, 137, 2), dtype=tf.float32)).numpy()
30
    confidence = tf.io.serialize_tensor(
31
        tf.random.normal(shape=(frames, 1, 137), dtype=tf.float32)).numpy()
32

33
    features = {
34
        'fps':
35
            tf.train.Feature(int64_list=tf.train.Int64List(value=[fps])),
36
        'pose_data':
37
            tf.train.Feature(bytes_list=tf.train.BytesList(value=[data])),
38
        'pose_confidence':
39
            tf.train.Feature(bytes_list=tf.train.BytesList(value=[confidence])),
40
        'is_signing':
41
            tf.train.Feature(bytes_list=tf.train.BytesList(value=[is_signing]))
42
    }
43

44
    example = tf.train.Example(features=tf.train.Features(feature=features))
45
    writer.write(example.SerializeToString())
46

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

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

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

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