def __init__(self, config, COCO): self.config = config self.COCO = COCO self.image_dir = config['image_dir'] self.id_to_label = set_id_to_label(config['label_set']) self.input_shape = tuple(config['input_shape']) self.default_boxes = anchor.generate_default_boxes(config["anchor_param"]) self.annotation_path = os.path.join(config['annotation_dir'], 'GDUT_HWD.json')
classes = np.array(out_labels) scores = out_scores.numpy() return boxes, classes, scores if __name__ == '__main__': with open('./config.yml') as f: cfg = yaml.load(f) try: config = cfg[args.arch.upper()] except AttributeError: raise ValueError('Unknown architecture: {}'.format(args.arch)) default_boxes = generate_default_boxes(config) batch_generator, info = create_batch_generator(args.data_dir, args.data_year, default_boxes, config['image_size'], BATCH_SIZE, args.num_examples, mode='test') try: ssd = create_ssd(NUM_CLASSES, args.arch, args.pretrained_type, args.checkpoint_dir, args.checkpoint_path) except Exception as e: print(e) print('The program is exiting...')
from ssd.ssd import init_ssd import tensorflow as tf from tensorflow.keras.optimizers.schedules import PiecewiseConstantDecay from voc_data import create_batch_generator from anchor import generate_default_boxes from losses import create_losses from settings import * ARCH = 'pre_ssd300-mobilenetv1' CHECKPOINT_DIR = 'checkpoint/pre_mobilenetv1_lite' CHECKPOINT_PATH = 'checkpoint/pre_mobilenetv1_lite/ssd_epoch_200.h5' os.makedirs(CHECKPOINT_DIR, exist_ok=True) default_boxes = generate_default_boxes(INFO[ARCH]) with tf.device('/device:GPU:0'): batch_generator, val_generator, info = create_batch_generator( DATA_DIR, DATA_YEAR, default_boxes, SIZE, BATCH_SIZE, NUM_BATCHES, mode='train', augmentation=['flip']) # the patching algorithm is currently causing bottleneck sometimes dummy = tf.random.normal((1, 300, 300, 3)) ssd = create_pre_ssd_mobilenetv1_lite(weights=None) pretrained_type = 'specified' checkpoint_path = CHECKPOINT_PATH