|
| 1 | +#!/usr/bin/env python2 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +""" |
| 4 | +@author: www.github.com/GustavZ |
| 5 | +""" |
| 6 | +import numpy as np |
| 7 | + |
| 8 | +class Config(object): |
| 9 | + """ |
| 10 | + Inference Configuration class |
| 11 | + Replaces 'config.sample.yml' of v1.0 |
| 12 | + """ |
| 13 | + ### Inference Config |
| 14 | + VIDEO_INPUT = 0 # Input Must be OpenCV readable |
| 15 | + VISUALIZE = True # Disable for performance increase |
| 16 | + |
| 17 | + |
| 18 | + ### Testing |
| 19 | + IMAGE_PATH = 'test_images' # path for test.py test_images |
| 20 | + LIMIT_IMAGES = None # if set to None, all images are used |
| 21 | + CPU_ONLY = False # CPU Placement for speed test |
| 22 | + WRITE_TIMELINE = True # write json timeline file (slows infrence) |
| 23 | + |
| 24 | + |
| 25 | + ### Object_Detection |
| 26 | + WIDTH = 600 # OpenCV only supports 4:3 formats others will be converted |
| 27 | + HEIGHT = 600 # 600x600 leads to 640x480 |
| 28 | + MAX_FRAMES = 5000 # only used if visualize==False |
| 29 | + FPS_INTERVAL = 5 # Interval [s] to print fps of the last interval in console |
| 30 | + DET_INTERVAL = 500 # intervall [frames] to print detections to console |
| 31 | + DET_TH = 0.5 # detection threshold for det_intervall |
| 32 | + ## speed hack |
| 33 | + SPLIT_MODEL = True # Splits Model into a GPU and CPU session (currently only works for ssd_mobilenets) |
| 34 | + SSD_SHAPE = 300 # used for the split model algorithm (currently only supports ssd networks trained on 300x300 and 600x600 input) |
| 35 | + ## Tracking |
| 36 | + USE_TRACKER = False # Use a Tracker (currently only works properly WITHOUT split_model) |
| 37 | + TRACKER_FRAMES = 20 # Number of tracked frames between detections |
| 38 | + NUM_TRACKERS = 5 # Max number of objects to track |
| 39 | + ## Model |
| 40 | + OD_MODEL_NAME = 'ssd_mobilenet_v11_coco' |
| 41 | + OD_MODEL_PATH = 'models/ssd_mobilenet_v11_coco/frozen_inference_graph.pb' |
| 42 | + LABEL_PATH = 'rod/data/mscoco_label_map.pbtxt' |
| 43 | + NUM_CLASSES = 90 |
| 44 | + |
| 45 | + |
| 46 | + ### DeepLab |
| 47 | + ALPHA = 0.3 # mask overlay factor |
| 48 | + BBOX = True # compute boundingbox in postprocessing |
| 49 | + MINAREA = 500 # min Pixel Area to apply bounding boxes (avoid noise) |
| 50 | + ## Model |
| 51 | + DL_MODEL_NAME = 'deeplabv3_mnv2_pascal_train_aug_2018_01_29' |
| 52 | + DL_MODEL_PATH = 'models/deeplabv3_mnv2_pascal_train_aug/frozen_inference_graph.pb' |
| 53 | + LABEL_NAMES = np.asarray([ |
| 54 | + 'background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', |
| 55 | + 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', |
| 56 | + 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tv']) |
| 57 | + |
| 58 | + |
| 59 | + def __init__(self): |
| 60 | + ## TimeLine File naming |
| 61 | + if self.CPU_ONLY: |
| 62 | + os.environ['CUDA_VISIBLE_DEVICES'] = '-1' |
| 63 | + self.DEVICE = '_CPU' |
| 64 | + else: |
| 65 | + self.DEVICE = '_GPU' |
| 66 | + if self.SPLIT_MODEL: |
| 67 | + self.SM = '_SM' |
| 68 | + else: |
| 69 | + self.SM = '' |
0 commit comments