Esempio n. 1
0
v4.preprocess预测

@author: luoyi
Created on 2021年3月6日
'''
import tensorflow as tf
import numpy as np
#    print时不用科学计数法表示
np.set_printoptions(suppress=True) 

import models.layer.v4_tiny.preprocess as pp
import data.dataset_cells as ds_cells


batch_size=4
db = ds_cells.tensor_db(batch_size=batch_size)
i = 10
idx = 0
for x,y in db:
    if (idx < i): 
        idx += 1
        continue
    y_true = y[:, 0, :]
    break
    pass

num_scales, num_anchors, num_classes, H,W = 3, 3, 1, 6,15
threshold_liable_iou = 0.25

yolohard = tf.random.uniform(shape=(batch_size, H, W, num_anchors, num_classes + 5))
Esempio n. 2
0
import models.yolo_v4_tiny as yolo

from math import ceil

log = logf.get_logger('train_v4')

#    初始化数据集
#    训练集
count_train = conf.DATASET_CELLS.get_count_train()
batch_size = conf.DATASET_CELLS.get_batch_size()
epochs = conf.DATASET_CELLS.get_epochs()
db_train = ds_cells.tensor_db(
    img_dir=conf.DATASET_CELLS.get_in_train(),
    label_path=conf.DATASET_CELLS.get_label_train(),
    is_label_mutiple=conf.DATASET_CELLS.get_label_train_mutiple(),
    count=count_train,
    batch_size=batch_size,
    epochs=epochs,
    shuffle_buffer_rate=conf.DATASET_CELLS.get_shuffle_buffer_rate(),
    x_preprocess=lambda x: ((x - 255.) - 0.5) / 2,
    y_preprocess=None)
log.info('init dataset train... ')

#    验证集
db_val = ds_cells.tensor_db(
    img_dir=conf.DATASET_CELLS.get_in_val(),
    label_path=conf.DATASET_CELLS.get_label_val(),
    is_label_mutiple=conf.DATASET_CELLS.get_label_val_mutiple(),
    count=conf.DATASET_CELLS.get_count_val(),
    batch_size=conf.DATASET_CELLS.get_batch_size(),
    epochs=conf.DATASET_CELLS.get_epochs(),
    shuffle_buffer_rate=conf.DATASET_CELLS.get_shuffle_buffer_rate(),
Esempio n. 3
0
yolo_v4_tiny = YoloV4Tiny()
yolo_v4_tiny.load_model_weight(model_weights_path)
yolo_v4_tiny.trainable = False
yolo_v4_tiny.show_info()

count = conf.DATASET_CELLS.get_count_train()
#    数据可能有问题,只能用当初训练的batch_size个数据。多了准确率就不对
count = 4
#    加载测试数据
test_db = ds_cells.tensor_db(
    img_dir=conf.DATASET_CELLS.get_in_test(),
    label_path=conf.DATASET_CELLS.get_label_test(),
    is_label_mutiple=conf.DATASET_CELLS.get_label_test_mutiple(),
    count=count,
    batch_size=count,
    epochs=conf.DATASET_CELLS.get_epochs(),
    shuffle_buffer_rate=conf.DATASET_CELLS.get_shuffle_buffer_rate(),
    x_preprocess=lambda x: ((x - 255.) - 0.5) / 2,
    y_preprocess=None,
    num_scales=conf.DATASET_CELLS.get_scales_set().shape[0],
    num_anchors=conf.DATASET_CELLS.get_anchors_set().shape[1],
    max_objects=conf.V4.get_max_objects())

X_test = []
Y_test = []
for x, y in test_db:
    X_test.append(x)
    Y_test.append(y)
    pass
X_test = tf.concat(X_test, axis=0) if len(X_test) > 1 else X_test[0]
Y_test = tf.concat(Y_test, axis=0) if len(Y_test) > 1 else Y_test[0]