示例#1
0
  def __init__(self, input_type, input):
    self.input_type = input_type
    self.item_counter = 0

    if input_type == 'json':
      coco_annotation = COCO(input)
      annotation_directory = os.path.join(os.getcwd(), os.path.dirname(input))
      classes = ObjectDetectorJson.get_classes_from_coco_annotation(input)
      self.json_data = ObjectDetectorJson.convert_coco_to_toolbox_format(coco_annotation, classes,
                                                                         annotation_directory)
    if input_type == "video":
      self.cap = cv2.VideoCapture(input)

    if input_type == "cam":
      self.cap = cv2.VideoCapture(0)
示例#2
0
    batch_size = 32  # Number of images in the batch

    class execution:
        CUDA_VISIBLE_DEVICES = "0"  # Environment variable to control cuda device used for training
        per_process_gpu_memory_fraction = 0.5  # Fix extra memory allocation issue
        allow_growth = True  # Option which attempts to allocate only as much GPU memory based on runtime allocations

        intra_op_parallelism_threads = 2
        inter_op_parallelism_threads = 8
        transformer_parallel_calls = 4  # Number of parallel threads in data transformer/augmentation
        transformer_prefetch_size = 8  # Number of batches to prefetch


input_shape = (256, 256, 3
               )  # Input shape of the model (width, height, channels)
classes = ObjectDetectorJson.get_classes_from_coco_annotation(
    os.path.join(current_dir, train.annotation_path))
model_dir = os.path.join(
    os.path.dirname(os.path.abspath(__file__)), 'model'
)  # Path to the folder where all training and evaluation artifacts will be located
if not os.path.exists(model_dir):
    os.makedirs(model_dir)


def learning_rate_schedule(
):  # Function which controls learning rate during training
    import tensorflow as tf
    step = tf.train.get_or_create_global_step()
    lr = tf.case([(tf.less(step, 1000), lambda: tf.constant(0.0004)),
                  (tf.less(step, 10000), lambda: tf.constant(0.01)),
                  (tf.less(step, 40000), lambda: tf.constant(0.005)),
                  (tf.less(step, 55000), lambda: tf.constant(0.0005)),
    transformer_prefetch_size = 1


class infer:
  batch_size = 1
  out_subdir = "predictions"

  class execution:
    CUDA_VISIBLE_DEVICES = ""

    intra_op_parallelism_threads = 1
    inter_op_parallelism_threads = 1
    transformer_parallel_calls = 1
    transformer_prefetch_size = 1

classes = ObjectDetectorJson.get_classes_from_coco_annotation(train.annotation_path)
input_shape = [128, 128, 3]


def optimizer(learning_rate):
  import tensorflow as tf
  optimizer = tf.train.MomentumOptimizer(learning_rate=learning_rate, momentum=0.95)
  return optimizer


detector_params = {
  "data_format": "NHWC",
  "depth_multiplier": 0.35,
  "initial_weights_path": path.join(root_dir, "data/test/model_ckpt/model.ckpt"),
  "learning_rate": 0.001,
  "mobilenet_version": "v2",

class infer:
    batch_size = 1
    out_subdir = "predictions"

    class execution:
        CUDA_VISIBLE_DEVICES = ""

        intra_op_parallelism_threads = 1
        inter_op_parallelism_threads = 1
        transformer_parallel_calls = 1
        transformer_prefetch_size = 1


classes = ObjectDetectorJson.get_classes_from_coco_annotation(
    train.annotation_path)
input_shape = [128, 128, 3]


def optimizer(learning_rate):
    import tensorflow as tf
    optimizer = tf.train.MomentumOptimizer(learning_rate=learning_rate,
                                           momentum=0.95)
    return optimizer


detector_params = {
    "data_format": "NHWC",
    "depth_multiplier": 0.35,
    "initial_weights_path": path.join(root_dir,
                                      "data/test/model_ckpt/model.ckpt"),
  out_subdir = "predictions"  # Name of folder in model directory where output json files with detections will be saved
  batch_size = 32             # Number of images in the batch

  class execution:
    CUDA_VISIBLE_DEVICES = "0"             # Environment variable to control cuda device used for training
    per_process_gpu_memory_fraction = 0.5  # Fix extra memory allocation issue
    allow_growth = True                    # Option which attempts to allocate only as much GPU memory based on runtime allocations

    intra_op_parallelism_threads = 2
    inter_op_parallelism_threads = 8
    transformer_parallel_calls = 4  # Number of parallel threads in data transformer/augmentation
    transformer_prefetch_size = 8   # Number of batches to prefetch


input_shape = (256, 256, 3)  # Input shape of the model (width, height, channels)
classes = ObjectDetectorJson.get_classes_from_coco_annotation(os.path.join(current_dir, train.annotation_path))
model_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'model')  # Path to the folder where all training and evaluation artifacts will be located
if not os.path.exists(model_dir):
  os.makedirs(model_dir)


def learning_rate_schedule():  # Function which controls learning rate during training
  import tensorflow as tf
  step = tf.train.get_or_create_global_step()
  lr = tf.case([(tf.less(step,  1000), lambda: tf.constant(0.0004)),
                (tf.less(step, 10000), lambda: tf.constant(0.01)),
                (tf.less(step, 40000), lambda: tf.constant(0.005)),
                (tf.less(step, 55000), lambda: tf.constant(0.0005)),
                (tf.less(step, 65000), lambda: tf.constant(0.00005))])
  return lr
    batch_size = 32  # Number of images in the batch

    class execution:
        CUDA_VISIBLE_DEVICES = "0"  # Environment variable to control cuda device used for training
        per_process_gpu_memory_fraction = 0.5  # Fix extra memory allocation issue
        allow_growth = True  # Option which attempts to allocate only as much GPU memory based on runtime allocations

        intra_op_parallelism_threads = 2
        inter_op_parallelism_threads = 8
        transformer_parallel_calls = 4  # Number of parallel threads in data transformer/augmentation
        transformer_prefetch_size = 8  # Number of batches to prefetch


input_shape = (256, 256, 3
               )  # Input shape of the model (width, height, channels)
classes = ObjectDetectorJson.get_classes_from_coco_annotation(
    os.path.join(CURRENT_DIR, train.annotation_path))
MODEL_DIR = os.path.join(
    os.path.dirname(os.path.abspath(__file__)), 'model'
)  # Path to the folder where all training and evaluation artifacts will be located
if not os.path.exists(MODEL_DIR):
    os.makedirs(MODEL_DIR)


def learning_rate_schedule(
):  # Function which controls learning rate during training
    import tensorflow as tf
    step = tf.train.get_or_create_global_step()
    lr = tf.case([(tf.less(step, 1000), lambda: tf.constant(0.0004)),
                  (tf.less(step, 10000), lambda: tf.constant(0.01)),
                  (tf.less(step, 40000), lambda: tf.constant(0.005)),
                  (tf.less(step, 55000), lambda: tf.constant(0.0005)),