示例#1
0
    def __init__(self, engine):
        super().__init__(engine,
                         extraction_keys=DETECTION_EXTRACTION_KEYS +
                         (Extractions.REID_FEATURES, ))
        self.add_masks = self.config.bool("add_masks", True)
        self.export_embeddings = self.config.bool("export_embeddings", False)

        tracker_reid_comp = self.config.string("tracker_reid_comp",
                                               "sigmoid_dot")
        tracker = self.config.string("tracker", "greedy")
        detection_confidence_threshold_car = self.config.float(
            "detection_confidence_threshold_car", 0.55)
        detection_confidence_threshold_pedestrian = self.config.float(
            "detection_confidence_threshold_pedestrian", 0.95)
        reid_weight_car = self.config.float("reid_weight_car", 1.0)
        reid_weight_pedestrian = self.config.float("reid_weight_pedestrian",
                                                   1.0)
        mask_iou_weight_car = self.config.float("mask_iou_weight_car", 0.0)
        mask_iou_weight_pedestrian = self.config.float(
            "mask_iou_weight_pedestrian", 0.0)
        bbox_center_weight_car = self.config.float("bbox_center_weight_car",
                                                   0.0)
        bbox_center_weight_pedestrian = self.config.float(
            "bbox_center_weight_pedestrian", 0.0)
        bbox_iou_weight_car = self.config.float("bbox_iou_weight_car", 0.0)
        bbox_iou_weight_pedestrian = self.config.float(
            "bbox_iou_weight_pedestrian", 0.0)
        association_threshold_car = self.config.float(
            "association_threshold_car", 0.3)
        association_threshold_pedestrian = self.config.float(
            "association_threshold_pedestrian", 0.3)
        keep_alive_car = self.config.int("keep_alive_car", 0)
        keep_alive_pedestrian = self.config.int("keep_alive_pedestrian", 0)
        reid_euclidean_offset_car = self.config.float(
            "reid_euclidean_offset_car", 5.0)
        reid_euclidean_scale_car = self.config.float(
            "reid_euclidean_scale_car", 1.0)
        reid_euclidean_offset_pedestrian = self.config.float(
            "reid_euclidean_offset_pedestrian", 5.0)
        reid_euclidean_scale_pedestrian = self.config.float(
            "reid_euclidean_scale_pedestrian", 1.0)
        box_offset = self.config.float("box_offset", 50.0)
        box_scale = self.config.float("box_scale", 0.02)
        new_reid = self.config.bool("new_reid", False)
        new_reid_threshold_car = self.config.float("new_reid_threshold_car",
                                                   2.0)
        new_reid_threshold_pedestrian = self.config.float(
            "new_reid_threshold_pedestrian", 2.0)
        self.tracker_options = {
            "tracker": tracker,
            "reid_comp": tracker_reid_comp,
            "detection_confidence_threshold_car":
            detection_confidence_threshold_car,
            "detection_confidence_threshold_pedestrian":
            detection_confidence_threshold_pedestrian,
            "reid_weight_car": reid_weight_car,
            "reid_weight_pedestrian": reid_weight_pedestrian,
            "mask_iou_weight_car": mask_iou_weight_car,
            "mask_iou_weight_pedestrian": mask_iou_weight_pedestrian,
            "bbox_center_weight_car": bbox_center_weight_car,
            "bbox_center_weight_pedestrian": bbox_center_weight_pedestrian,
            "bbox_iou_weight_car": bbox_iou_weight_car,
            "bbox_iou_weight_pedestrian": bbox_iou_weight_pedestrian,
            "association_threshold_car": association_threshold_car,
            "association_threshold_pedestrian":
            association_threshold_pedestrian,
            "keep_alive_car": keep_alive_car,
            "keep_alive_pedestrian": keep_alive_pedestrian,
            "reid_euclidean_offset_car": reid_euclidean_offset_car,
            "reid_euclidean_scale_car": reid_euclidean_scale_car,
            "reid_euclidean_offset_pedestrian":
            reid_euclidean_offset_pedestrian,
            "reid_euclidean_scale_pedestrian": reid_euclidean_scale_pedestrian,
            "new_reid_threshold_car": new_reid_threshold_car,
            "new_reid_threshold_pedestrian": new_reid_threshold_pedestrian,
            "box_offset": box_offset,
            "box_scale": box_scale,
            "new_reid": new_reid
        }

        self.mask_disjoint_strategy = self.config.string(
            "mask_disjoint_strategy", "y_pos")  # Or "score"

        self.export_detections = self.config.bool("export_detections", False)
        self.import_detections = self.config.bool("import_detections", False)
        self.visualize_tracks = self.config.bool("visualize_tracks", False)
        self.do_tracking = self.config.bool("do_tracking", True)
        self.embeddings = {}
        self.optical_flow_path = self.config.string(
            "optical_flow_path",
            "/work/" + username() + "/data/KITTI_flow_pwc/")
        self.run_tracking_eval = self.config.bool("run_tracking_eval", False)
示例#2
0
from datasets.Loader import register_dataset
from datasets.Mapillary.MapillaryLike_instance import MapillaryLikeInstanceDataset
from datasets.util.Util import username

DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/mapillary/"
NAME = "mapillary_instance"


@register_dataset("mapillary_instance_full", resolution="full")
@register_dataset("mapillary_instance_half", resolution="half")
@register_dataset("mapillary_instance_quarter", resolution="quarter")
class MapillaryInstanceDataset(MapillaryLikeInstanceDataset):
    def __init__(self, config, subset, resolution):
        assert resolution in ("quarter", "half", "full"), resolution
        if resolution == "full":
            default_path = DEFAULT_PATH
        else:
            default_path = DEFAULT_PATH.replace(
                "/mapillary/", "/mapillary_{}/".format(resolution))

        # there are 37 classes with instances in total

        # we excluded the following:
        #  8: construction--flat--crosswalk-plain -> doesn't really look like a useful object category
        # 34: object--bike-rack -> holes*
        # 45: object--support--pole -> very large and thin -> bounding box does not capture it well
        # 46: object--support--traffic-sign-frame -> holes*
        # 47: object--support--utility-pole -> holes*

        # further candidate for exclusion:
        #  0: animal--bird  -> usually very small
示例#3
0
import tensorflow as tf
import numpy as np

from datasets import DataKeys
from datasets.Mapillary.MapillaryLike_instance import MapillaryLikeInstanceDataset
from datasets.util.TrackingGT import load_tracking_gt_KITTI
from datasets.KITTI.segtrack.KITTI_segtrack import DEFAULT_PATH
from datasets.Loader import register_dataset
from datasets.util.Util import username

NAME = "KITTI_segtrack_bbox_regression"
KITTI_TRACKING_GT_DEFAULT_PATH = "/home/" + username(
) + "/vision/mask_annotations/KITTI_tracking_annotations/"


@register_dataset(NAME)
class KittiSegtrackBboxRegressionDataset(MapillaryLikeInstanceDataset):
    def __init__(self, config, subset):
        super().__init__(config, subset, NAME, DEFAULT_PATH,
                         "datasets/KITTI/segtrack/", 1000, [1, 2])
        self._gt = load_tracking_gt_KITTI(KITTI_TRACKING_GT_DEFAULT_PATH,
                                          filter_to_cars_and_pedestrians=True)

    def postproc_annotation(self, ann_filename, ann):
        ann = super().postproc_annotation(ann_filename, ann)
        if not isinstance(ann, dict):
            ann = {DataKeys.SEGMENTATION_LABELS: ann}

        def _lookup_bbox(fn):
            fn = fn.decode("utf-8")
            sp = fn.split(":")
示例#4
0
import glob
import tensorflow as tf

from datasets.DetectionDataset import MapillaryLikeDetectionFileListDataset
from datasets.KITTI.segtrack.KITTI_MOTS_info import SEQ_IDS_TRAIN, SEQ_IDS_VAL
from datasets.Loader import register_dataset
from datasets.util.Util import username
from datasets import DataKeys
from shutil import copytree
from random import randint
from core.Log import log
import os

NAME = "KITTI_segtrack"
NAME_DETECTION = "KITTI_segtrack_detection"
DEFAULT_PATH = "/globalwork/" + username() + "/data/KITTI_MOTS/train/"
ID_DIVISOR = 1000
CLASS_IDS_WITH_INSTANCES = [1, 2]
CROWD_ID = 10
NUM_CLASSES = 3  # background, car, pedestrian
N_MAX_DETECTIONS = 100


# used for detection on individual images
@register_dataset(NAME_DETECTION)
class KittiSegtrackDetectionDataset(MapillaryLikeDetectionFileListDataset):
    def __init__(self, config, subset, name=NAME, default_path=DEFAULT_PATH):
        self.seq_ids_train = SEQ_IDS_TRAIN
        self.seq_ids_val = SEQ_IDS_VAL
        self.imgs_are_pngs = config.bool("imgs_are_pngs", True)
        t = config.string_list("seq_ids_train", [])
示例#5
0
import numpy as np

from datasets.MOT.MOT_common import MOTDetectionDataset, MOTDataset
from datasets.Loader import register_dataset
from datasets.util.Util import username

# MOT17 is the same sequences as MOT16 with better ground truth annotations
NAME = "MOT17"
NAME_DETECTION = "MOT17_detection"
DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/MOT17/"
NUM_CLASSES = 3  # background, car, pedestrian
N_MAX_DETECTIONS = 100

# TODO This is from savitar1, any papers we can take this split from?
SEQ_IDS_TRAIN = ["MOT17-%02d-DPM" % idx for idx in [2, 5, 10, 13]]
SEQ_IDS_VAL = ["MOT17-%02d-DPM" % idx for idx in [4, 9, 11]]


# used for detection on invididual images
@register_dataset(NAME_DETECTION)
class MOT17DetectionDataset(MOTDetectionDataset):
  def __init__(self, config, subset):
    super().__init__(config, subset, NAME, DEFAULT_PATH, SEQ_IDS_TRAIN, SEQ_IDS_VAL, NUM_CLASSES)

  def get_data_arrays_for_file(self, img_filename, img_h, img_w):
    return mot17_get_data_arrays_for_file(self.gt_data, self.cat_to_class, self.visibility_threshold,
                                          img_filename, img_h, img_w)


# used for training on chunks of video
@register_dataset(NAME)
示例#6
0
import glob

from datasets.Dataset import FileListDataset
from datasets.Loader import register_dataset
from datasets.util.Util import username

NAME = "kitti_mturkers_instance"
DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/KITTI/"


@register_dataset(NAME)
class KITTIMturkersInstanceDataset(FileListDataset):
    def __init__(self, config, subset, name=NAME):
        super(KITTIMturkersInstanceDataset,
              self).__init__(config, name, subset, DEFAULT_PATH, 2)

    def read_inputfile_lists(self):
        files = glob.glob(self.data_dir +
                          "object/segmentations_jay_per_instance_new/*.png")
        imgs = [
            self.data_dir + "object/image_2/" +
            file.split("/")[-1].split(":")[0] + ".png" for file in files
        ]

        return imgs, files
示例#7
0
文件: Grabcut.py 项目: sabarim/itis
import glob
import tensorflow as tf

from datasets.Dataset import FileListDataset
from datasets.Loader import register_dataset
from datasets.util.Util import username

NAME = "grabcut"
DEFAULT_PATH="/fastwork/" + username() + "/mywork/data/Grabcut/"

@register_dataset(NAME)
class GrabcutDataset(FileListDataset):
  def __init__(self, config, subset, name=NAME):
    super().__init__(config, dataset_name=name, subset=subset, default_path=DEFAULT_PATH, num_classes=2)

  def postproc_annotation(self, ann_filename, ann):
    ann_postproc = tf.where(tf.equal(ann, 255), tf.ones_like(ann), ann)
    ann_postproc = tf.where(tf.equal(ann_postproc, 128), tf.ones_like(ann) * 255, ann_postproc)
    return ann_postproc

  def read_inputfile_lists(self):
    img_dir = self.data_dir + "images/"
    gt_dir = self.data_dir + "images-gt/"
    imgs = []
    gts = []

    for filename in glob.glob(img_dir + "*"):
      fn_base = filename.split("/")[-1].rsplit(".")[0]
      imgs += [filename]
      gts += [gt_dir + fn_base + ".png"]
示例#8
0
文件: DAVIS.py 项目: sabarim/itis
import glob

import tensorflow as tf

from datasets.Loader import register_dataset
from datasets.Dataset import FileListDataset
from datasets.util.Util import username

NUM_CLASSES = 2
VOID_LABEL = 255  # for translation augmentation
DAVIS_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/DAVIS/"
DAVIS2017_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/DAVIS2017/"
DAVIS_FLOW_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS_data/"
DAVIS_LUCID_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS_data/lucid/"
DAVIS2017_LUCID_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS2017_data/lucid/"
DAVIS_IMAGE_SIZE = (480, 854)
DAVIS2017_IMAGE_SIZE = (480, None)


def read_image_and_annotation_list(fn, data_dir):
    imgs = []
    ans = []
    with open(fn) as f:
        for l in f:
            sp = l.split()
            an = data_dir + sp[1]
            im = data_dir + sp[0]
            imgs.append(im)
示例#9
0
import glob
import os
import numpy as np

from datasets.MOT.MOT_common import MOTDetectionDataset, MOTDataset
from datasets.Loader import register_dataset
from datasets.util.Util import username

# MOT17 is the same sequences as MOT16 with better ground truth annotations
NAME = "PathTrack"
NAME_DETECTION = "PathTrack_detection"
DEFAULT_PATH = "/fastwork/" + username(
) + "/data/pathtrack_release_v1.0/pathtrack_release"
# PathTrack actually only contains pedestrian annotations; keep the three classes here so that it fits with MOT17
NUM_CLASSES = 3  # background, car, pedestrian
N_MAX_DETECTIONS = 100

# TODO Which split?
PATHTRACK_SEQUENCES = sorted(
    glob.glob(os.path.join(DEFAULT_PATH, "train", "*")))
PATHTRACK_SEQUENCES = [seq.split("/")[-1] for seq in PATHTRACK_SEQUENCES]
PATHTRACK_SPLITPOINT = int(np.ceil(len(PATHTRACK_SEQUENCES) * 0.7))
SEQ_IDS_TRAIN = PATHTRACK_SEQUENCES[:PATHTRACK_SPLITPOINT]
SEQ_IDS_VAL = PATHTRACK_SEQUENCES[PATHTRACK_SPLITPOINT:]


# used for detection on invididual images
@register_dataset(NAME_DETECTION)
class PathTrackDetectionDataset(MOTDetectionDataset):
    def __init__(self, config, subset):
        super().__init__(config, subset, NAME, DEFAULT_PATH, SEQ_IDS_TRAIN,
示例#10
0
from datasets.Loader import register_dataset
from datasets.Mapillary.MapillaryLike_instance import MapillaryLikeInstanceDataset
from datasets.util.Util import username

DEFAULT_PATH = "/home/" + username() + "/data/KITTI_instance/"
NAME = "KITTI_instance"


@register_dataset(NAME)
class KittiInstanceDataset(MapillaryLikeInstanceDataset):
    def __init__(self, config, subset):
        super().__init__(config,
                         subset,
                         NAME,
                         DEFAULT_PATH,
                         "datasets/KITTI/official",
                         256,
                         cat_ids_to_use=list(range(24, 34)))
示例#11
0
import numpy as np

from datasets.MOT.MOT_common import MOTDetectionDataset, MOTDataset
from datasets.Loader import register_dataset
from datasets.util.Util import username

NAME = "2DMOT2015"
NAME_DETECTION = "2DMOT2015_detection"
DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/2DMOT2015/"
# MOT2015 actually only contains pedestrian annotations; keep the three classes here so that it fits with MOT17
NUM_CLASSES = 3  # background, car, pedestrian
N_MAX_DETECTIONS = 100

# This is from savitar1, I think this split appears in some Paper
#SEQ_IDS_TRAIN = ["TUD-Stadtmitte", "ETH-Bahnhof", "ADL-Rundle-6", "KITTI-13", "PETS09-S2L1"]
#SEQ_IDS_VAL = ["TUD-Campus", "ETH-Sunnyday", "ETH-Pedcross2", "ADL-Rundle-8", "Venice-2", "KITTI-17"]
# This is all from 2DMOT2015 train which is not in either KITTI or MOT17
SEQ_IDS_TRAIN = ["TUD-Stadtmitte", "ETH-Bahnhof", "PETS09-S2L1"]
SEQ_IDS_VAL = ["TUD-Campus", "ETH-Sunnyday", "Venice-2"]


# used for detection on invididual images
@register_dataset(NAME_DETECTION)
class MOT15DetectionDataset(MOTDetectionDataset):
    def __init__(self, config, subset):
        super().__init__(config, subset, NAME, DEFAULT_PATH, SEQ_IDS_TRAIN,
                         SEQ_IDS_VAL, NUM_CLASSES)

    def get_data_arrays_for_file(self, img_filename, img_h, img_w):
        return mot15_get_data_arrays_for_file(self.gt_data, img_filename,
                                              img_h, img_w)