本文整理汇总了Python中yolo3.utils.get_random_data方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_random_data方法的具体用法?Python utils.get_random_data怎么用?Python utils.get_random_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yolo3.utils
的用法示例。
在下文中一共展示了utils.get_random_data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: data_generator
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def data_generator(annotation_lines, batch_size, input_shape, anchors, num_classes, random=True, verbose=False):
'''data generator for fit_generator'''
n = len(annotation_lines)
i = 0
while True:
image_data = []
box_data = []
for b in range(batch_size):
if i==0 and random:
np.random.shuffle(annotation_lines)
image, box = get_random_data(annotation_lines[i], input_shape, random=random)
image_data.append(image)
box_data.append(box)
i = (i+1) % n
image_data = np.array(image_data)
if verbose:
print("Progress: ",i,"/",n)
box_data = np.array(box_data)
y_true = preprocess_true_boxes(box_data, input_shape, anchors, num_classes)
yield [image_data, *y_true], np.zeros(batch_size)
示例2: bottleneck_generator
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def bottleneck_generator(annotation_lines, batch_size, input_shape, anchors, num_classes, bottlenecks):
n = len(annotation_lines)
i = 0
while True:
box_data = []
b0=np.zeros((batch_size,bottlenecks[0].shape[1],bottlenecks[0].shape[2],bottlenecks[0].shape[3]))
b1=np.zeros((batch_size,bottlenecks[1].shape[1],bottlenecks[1].shape[2],bottlenecks[1].shape[3]))
b2=np.zeros((batch_size,bottlenecks[2].shape[1],bottlenecks[2].shape[2],bottlenecks[2].shape[3]))
for b in range(batch_size):
_, box = get_random_data(annotation_lines[i], input_shape, random=False, proc_img=False)
box_data.append(box)
b0[b]=bottlenecks[0][i]
b1[b]=bottlenecks[1][i]
b2[b]=bottlenecks[2][i]
i = (i+1) % n
box_data = np.array(box_data)
y_true = preprocess_true_boxes(box_data, input_shape, anchors, num_classes)
yield [b0, b1, b2, *y_true], np.zeros(batch_size)
示例3: data_generator
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def data_generator(annotation_lines, batch_size, input_shape, anchors, num_classes):
'''data generator for fit_generator'''
n = len(annotation_lines)
i = 0
while True:
image_data = []
box_data = []
for b in range(batch_size):
if i==0:
np.random.shuffle(annotation_lines)
image, box = get_random_data(annotation_lines[i], input_shape, random=True)
image_data.append(image)
box_data.append(box)
i = (i+1) % n
image_data = np.array(image_data) # input of original yolo: image
box_data = np.array(box_data) # output of original yolo: boxes
y_true = preprocess_true_boxes(box_data, input_shape, anchors, num_classes) # some kind of output description?!
yield [image_data, *y_true], np.zeros(batch_size)
示例4: data_generator
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def data_generator(annotation_lines, batch_size, input_shape, anchors, num_classes):
n = len(annotation_lines)
np.random.shuffle(annotation_lines)
i = 0
while True:
image_data = []
box_data = []
for b in range(batch_size):
i %= n
image, box = get_random_data(annotation_lines[i], input_shape, random=True)
image_data.append(image)
box_data.append(box)
i += 1
image_data = np.array(image_data)
box_data = np.array(box_data)
y_true = preprocess_true_boxes(box_data, input_shape, anchors, num_classes)
yield [image_data, *y_true], np.zeros(batch_size)
示例5: data_generator
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def data_generator(annotation_lines, batch_size, input_shape, anchors, num_classes):
'''data generator for fit_generator'''
n = len(annotation_lines)
i = 0
while True:
image_data = []
box_data = []
for b in range(batch_size):
if i==0:
np.random.shuffle(annotation_lines)
image, box = get_random_data(annotation_lines[i], input_shape, random=True)
image_data.append(image)
box_data.append(box)
i = (i+1) % n
image_data = np.array(image_data)
box_data = np.array(box_data)
y_true = preprocess_true_boxes(box_data, input_shape, anchors, num_classes)
yield [image_data, *y_true], np.zeros(batch_size)
开发者ID:Akhtar303,项目名称:Vehicle-Detection-and-Tracking-Usig-YOLO-and-Deep-Sort-with-Keras-and-Tensorflow,代码行数:20,代码来源:train.py
示例6: parse_tfrecord
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def parse_tfrecord(self, example_proto):
feature_description = {
'image/encoded': tf.io.FixedLenFeature([], tf.string),
'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/bbox/label': tf.io.VarLenFeature(tf.int64)
}
features = tf.io.parse_single_example(example_proto,
feature_description)
image = tf.image.decode_image(features['image/encoded'],
channels=3,
dtype=tf.float32)
image.set_shape([None, None, 3])
xmins = features['image/object/bbox/xmin'].values
xmaxs = features['image/object/bbox/xmax'].values
ymins = features['image/object/bbox/ymin'].values
ymaxs = features['image/object/bbox/ymax'].values
labels = features['image/object/bbox/label'].values
image, bbox = get_random_data(image,
xmins,
xmaxs,
ymins,
ymaxs,
labels,
self.input_shape,
train=self.mode == DATASET_MODE.TRAIN)
y1, y2, y3 = tf.py_function(
preprocess_true_boxes,
[bbox, self.input_shape, self.anchors, self.num_classes],
[tf.float32, tf.float32, tf.float32])
y1.set_shape([None, None, len(self.anchors) // 3, self.num_classes + 5])
y2.set_shape([None, None, len(self.anchors) // 3, self.num_classes + 5])
y3.set_shape([None, None, len(self.anchors) // 3, self.num_classes + 5])
return image, (y1, y2, y3)
示例7: parse_text
# 需要导入模块: from yolo3 import utils [as 别名]
# 或者: from yolo3.utils import get_random_data [as 别名]
def parse_text(self, line):
values = tf.strings.split([line], ' ').values
image = tf.image.decode_image(tf.io.read_file(values[0]),
channels=3,
dtype=tf.float32)
image.set_shape([None, None, 3])
reshaped_data = tf.reshape(values[1:], [-1, 5])
xmins = tf.strings.to_number(reshaped_data[:, 0], tf.float32)
xmaxs = tf.strings.to_number(reshaped_data[:, 2], tf.float32)
ymins = tf.strings.to_number(reshaped_data[:, 1], tf.float32)
ymaxs = tf.strings.to_number(reshaped_data[:, 3], tf.float32)
labels = tf.strings.to_number(reshaped_data[:, 4], tf.int64)
image, bbox = get_random_data(image,
xmins,
xmaxs,
ymins,
ymaxs,
labels,
self.input_shape,
train=self.mode == DATASET_MODE.TRAIN)
y1, y2, y3 = tf.py_function(
preprocess_true_boxes,
[bbox, self.input_shape, self.anchors, self.num_classes],
[tf.float32, tf.float32, tf.float32])
y1.set_shape([None, None, len(self.anchors) // 3, self.num_classes + 5])
y2.set_shape([None, None, len(self.anchors) // 3, self.num_classes + 5])
y3.set_shape([None, None, len(self.anchors) // 3, self.num_classes + 5])
return image, (y1, y2, y3)