Esempio n. 1
0
File: pr.py Progetto: jtpils/ais3d
def test_kitti():
    # load net
    num_classes = len(KITTI_CLASSES) + 1 # +1 background
    net = build_ssd('test', 300, num_classes) # initialize SSD
    net.load_state_dict(torch.load(args.trained_model))
    net.eval()
    print('Finished loading model!')
    # load data
    testset = KITTIDetection(KITTI_ROOT,['val'], None, KITTIAnnotationTransform())
    if args.cuda:
        net = net.cuda()
        print('test')
        cudnn.benchmark = True
    # evaluation
    test_net(args.save_folder, net, args.cuda, testset, BaseTransform(net.size, (104, 117, 123)),thresh=args.visual_threshold)
Esempio n. 2
0
File: demo.py Progetto: jtpils/ais3d
if torch.cuda.is_available():
    torch.set_default_tensor_type('torch.cuda.FloatTensor')
import time
from ssd import build_ssd

net = build_ssd('test', 300, 4)  # initialize SSD
#net.load_weights('../weights/ssd300_mAP_77.43_v2.pth')
#net.load_weights('../weights/VOC.pth')
net.load_weights('../weights/ssd300_Resz_KITTI_80000.pth')
#FOR TESTING WITH ONLY ONE IMAGE, WITHOUT THE DATASET FOLDER, COMMENT THE LIGHT ABOVE AND UNCOMMENT LINE BELOW. ALSO COMMENT THE LINE BELOW image = testset.pull_image(img_id)
#image = cv2.imread('/home/emeka/Downloads/pp.jpeg', cv2.IMREAD_COLOR)  # uncomment if dataset not downloaded
from matplotlib import pyplot as plt
from data import VOCDetection, VOC_ROOT, VOCAnnotationTransform, KITTIDetection, KITTI_ROOT, KITTIAnnotationTransform
# here we specify year (07 or 12) and dataset ('test', 'val', 'train')
#testset = VOCDetection(VOC_ROOT, [('2007', 'val')], None, VOCAnnotationTransform()) #CHANGED
testset = KITTIDetection(KITTI_ROOT, ['val'], None, KITTIAnnotationTransform())

for img_id in range(0, 150):
    image = testset.pull_image(img_id)
    rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    # View the sampled input image before transform
    #plt.figure(figsize=(10,10))
    #plt.imshow(rgb_image)
    #plt.show()

    x = cv2.resize(image, (300, 300)).astype(np.float32)
    #plt.imshow(x)
    # plt.show()
    x -= (104.0, 117.0, 123.0)
    x = x.astype(np.float32)
    x = x[:, :, ::-1].copy()
Esempio n. 3
0
        # extract 2d bounding box in 0-based coordinates
        self.xmin = float(data[0]) # left
        self.xmax = float(data[1]) # right
        self.ymin = float(data[2]) # top
        self.ymax = float(data[3]) # bottom
        self.zmin = float(data[4]) # top
        self.zmax = float(data[5]) # bottom
        self.box3d = np.array([self.xmin,self.xmax,self.ymin,self.ymax,self.zmin,self.zmax])

if __name__ == "__main__":

    datatype = 'val' #'train'
    KITTI_CLASSES = ( 'Index0', 'Background','Cyclist', 'Car', 'Pedestrian')
    class_to_ind = dict(zip(KITTI_CLASSES, range(len(KITTI_CLASSES))))
    # Load the Dataset
    testset = KITTIDetection(KITTI_ROOT,[datatype], None, KITTIAnnotationTransform)

    # Necessary Directories
    root_dir="/home/dllab/kitti_object/data_object_image_2"
    pcd_dir="/home/dllab/kitti_object/data_object_velodyne/pcl"
    segmented_pcd_dir="/home/emeka/Schreibtisch/AIS/ais3d/PCD_Files1"
    data_set = "training"
    images_dir = os.path.join(root_dir,data_set, "image_{0}".format(2))
    detection_dir = '/home/emeka/Schreibtisch/AIS/ais3d/Detections'
    calib_dir = '/home/dllab/kitti_object/data_object_velodyne/data_object_calib/training/calib'
    box_dir = '/home/emeka/Schreibtisch/AIS/ais3d/bbox_labels_new'
    label_dir = os.path.join(root_dir,data_set, "label_{0}".format(2))
    # Assign 1 to visualize the images and PCD
    show_images=0

    # Iterate for every image
Esempio n. 4
0
if torch.cuda.is_available():
    torch.set_default_tensor_type('torch.cuda.FloatTensor')
import time
from ssd import build_ssd

net = build_ssd('test', 300, 4)    # initialize SSD
#net.load_weights('../weights/ssd300_mAP_77.43_v2.pth')
#net.load_weights('../weights/VOC.pth')
net.load_weights('../weights/ssd300_Resz_KITTI_80000.pth')
#FOR TESTING WITH ONLY ONE IMAGE, WITHOUT THE DATASET FOLDER, COMMENT THE LIGHT ABOVE AND UNCOMMENT LINE BELOW. ALSO COMMENT THE LINE BELOW image = testset.pull_image(img_id)
#image = cv2.imread('/home/emeka/Downloads/pp.jpeg', cv2.IMREAD_COLOR)  # uncomment if dataset not downloaded
from matplotlib import pyplot as plt
from data import VOCDetection, VOC_ROOT, VOCAnnotationTransform, KITTIDetection, KITTI_ROOT, KITTIAnnotationTransform
# here we specify year (07 or 12) and dataset ('test', 'val', 'train')
#testset = VOCDetection(VOC_ROOT, [('2007', 'val')], None, VOCAnnotationTransform()) #CHANGED
testset = KITTIDetection(KITTI_ROOT,['train'], None, KITTIAnnotationTransform())
save_folder = '/home/emeka/Schreibtisch/AIS/ais3d/Detections/'
for img_id in range(0,len(testset)):
    image = testset.pull_image(img_id)
    rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    # View the sampled input image before transform
    #plt.figure(figsize=(10,10))
    #plt.imshow(rgb_image)
    #plt.show()

    x = cv2.resize(image, (300, 300)).astype(np.float32)
    #plt.imshow(x)
   # plt.show()
    x -= (104.0, 117.0, 123.0)
    x = x.astype(np.float32)
    x = x[:, :, ::-1].copy()
Esempio n. 5
0
        self.xmax = float(data[1])  # right
        self.ymin = float(data[2])  # top
        self.ymax = float(data[3])  # bottom
        self.zmin = float(data[4])  # top
        self.zmax = float(data[5])  # bottom
        self.box3d = np.array(
            [self.xmin, self.xmax, self.ymin, self.ymax, self.zmin, self.zmax])


if __name__ == "__main__":

    datatype = 'val'  #'train' #val
    KITTI_CLASSES = ('Index0', 'Background', 'Cyclist', 'Car', 'Pedestrian')
    class_to_ind = dict(zip(KITTI_CLASSES, range(len(KITTI_CLASSES))))
    # Load the Dataset
    testset = KITTIDetection(KITTI_ROOT, [datatype], None,
                             KITTIAnnotationTransform)

    # Necessary Directories
    root_dir = "/home/dllab/kitti_object/data_object_image_2"
    pcd_dir = "/home/dllab/kitti_object/data_object_velodyne/pcl"
    segmented_pcd_dir = "/home/emeka/Schreibtisch/AIS/ais3d/PCD_Files1"
    data_set = "training"
    images_dir = os.path.join(root_dir, data_set, "image_{0}".format(2))
    detection_dir = '/home/emeka/Schreibtisch/AIS/ais3d/Detections'
    calib_dir = '/home/dllab/kitti_object/data_object_velodyne/data_object_calib/training/calib'
    box_dir = '/home/emeka/Schreibtisch/AIS/ais3d/bbox_labels_new'
    points_dir = "/home/emeka/Schreibtisch/AIS/ais3d/PCD_Files2/DetectionLocations"
    label_dir = os.path.join(root_dir, data_set, "label_{0}".format(2))
    # Assign 1 to visualize the images and PCD
    show_images = 1