import pickle import cv2 import numpy as np import tensorflow as tf import random import torch import traceback import json import time #os.chdir('/mnt/oss/luci-hangzhou/junxuan/notebooks/cvml-kit') from utils import draw_bbox_on_img, TqdmLogger from options.test_options import TestOptions from models.models import create_model from data.data_loader import CreateDataLoader from datatools.tfrecord import feature logger = TqdmLogger('data_aug') import torchvision.transforms as transforms import torch from data.base_dataset import BaseDataset from data.image_folder import make_dataset from PIL import Image from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(value=[value])) def _bytes_feature(value): return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
# Example: # python inspect_tfrecord.py /data/train.tfrecord-00000-of-00010 10 import os import sys import pickle import cv2 import numpy as np import tensorflow as tf import json from utils import draw_bbox_on_img, TqdmLogger #from grab import algo_grabcut import random from maskrcnn_benchmark.config import cfg from predictor import COCODemo logger = TqdmLogger('inspector') def all_path(dirname): result = []#所有的文件 for maindir, subdir, file_name_list in os.walk(dirname): for filename in file_name_list: _,type=filename.split('.') if type=='tfrecord': apath = os.path.join(maindir, filename)#合并成一个完整路径 result.append(apath)
# Example: # python inspect_tfrecord.py /data/train.tfrecord-00000-of-00010 10 import os import sys import pickle import cv2 import numpy as np import tensorflow as tf os.chdir('/mnt/oss/luci-hangzhou/junxuan/notebooks/cvml-kit') from utils import draw_bbox_on_img, TqdmLogger #from grab import algo_grabcut import random from maskrcnn_benchmark.config import cfg from predictor import COCODemo logger = TqdmLogger('inspector') from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() def extract_fn(tfrecord): image_feature_description = { 'image/height': tf.io.FixedLenFeature([], tf.int64), 'image/width': tf.io.FixedLenFeature([], tf.int64), #'image/channels': tf.io.FixedLenFeature([], tf.int64), 'image/object/bbox/xmin': tf.io.VarLenFeature(tf.float32), 'image/object/bbox/xmax': tf.io.VarLenFeature(tf.float32), 'image/object/bbox/ymin': tf.io.VarLenFeature(tf.float32), 'image/object/bbox/ymax': tf.io.VarLenFeature(tf.float32), 'image/object/class/label': tf.io.VarLenFeature(tf.int64), 'image/object/class/text': tf.io.VarLenFeature(tf.string),