def __init__(self, config): self.calib_file = config["dir"]["calib_file"] self.box2d_dir = config["dir"]["box2d_dir"] self.model = bbox_3D_net((224, 224, 3)) self.model.load_weights(config["model_dir"]) self.classes = config["class"] self.cls_to_ind = {cls: i for i, cls in enumerate(self.classes)} self.dims_avg_dir = dir["dims_avg"] self.dims_avg = np.loadtxt(self.dims_avg_dir, delimiter=',') self.cam_to_img = get_cam_data(self.calib_file) self.fx = self.cam_to_img[0][0] self.u0 = self.cam_to_img[0][2] self.v0 = self.cam_to_img[1][2]
import cv2 import numpy as np import os from util.post_processing import gen_3D_box, draw_3D_box, draw_2D_box from net.bbox_3D_net import bbox_3D_net from util.process_data import get_cam_data, get_dect2D_data os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0" # Construct the network model = bbox_3D_net((224, 224, 3)) model.load_weights('./model_saved/weights.h5') image_dir = '/home/kid/workspace/3D_detection/dataset/test/image/' calib_file = '/home/kid/workspace/3D_detection/dataset/test/calib.txt' box2d_dir = '/home/kid/workspace/3D_detection/dataset/test/label/' classes = [ 'Car', 'Van', 'Truck', 'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram' ] cls_to_ind = {cls: i for i, cls in enumerate(classes)} dims_avg = np.loadtxt(r'dataset/voc_dims.txt', delimiter=',') all_image = sorted(os.listdir(image_dir)) # np.random.shuffle(all_image) cam_to_img = get_cam_data(calib_file) fx = cam_to_img[0][0]
import numpy as np import os from keras.callbacks import TensorBoard, EarlyStopping, ModelCheckpoint from keras.optimizers import Adam from layer.loss_func import orientation_loss from util.process_data import load_and_process_annotation_data,train_data_gen from net.bbox_3D_net import bbox_3D_net os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"]="0" # Construct the network model = bbox_3D_net((224,224,3),bin_num=6,vgg_weights='imagenet') minimizer = Adam(lr=1e-5) early_stop = EarlyStopping(monitor='val_loss', min_delta=0.001, patience=10, mode='min', verbose=1) checkpoint = ModelCheckpoint('weights.hdf5', monitor='val_loss', verbose=1, save_best_only=True, mode='min', period=1) tensorboard = TensorBoard(log_dir='./logs/', histogram_freq=0, write_graph=True, write_images=False) model.compile(optimizer=minimizer,#minimizer, loss={'dimension': 'mean_squared_error', 'orientation': orientation_loss, 'confidence': 'categorical_crossentropy'}, loss_weights={'dimension': 2., 'orientation': 1., 'confidence': 4.}) image_dir = '/home/kid/workspace/3D_detection/dataset/image_2/' label_dir = '/home/kid/workspace/3D_detection/dataset/label_2/' classes = [line.strip() for line in open(r'dataset/voc_labels.txt').readlines()] cls_to_ind = {cls:i for i,cls in enumerate(classes)}