Skip to content

Commit aaa64a2

Browse files
committed
make it pythonic
1 parent 6575dd7 commit aaa64a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1121
-476
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ Results in up to x10 performance increase depending on the running system <br />
2121

2222

2323
## Inference:
24-
- create a copy of `config.sample.yml` called `config.yml`
25-
- optional: Change Parameters in `config.yml` to load other models or to modify configurations.<br />
26-
For example: If you are not interested in visualization: set `visualize` to `False`, <br />
27-
or if you want to switch off the speed hack set `split_model` to `False`, <br />
28-
- to be able to use KCF_Tracking run `build_kcf.sh` to build it and set `use_tracker` to `true` to use it <br />
29-
(currently only works for pure object detection models without `split_model`)
24+
- Change Inference Configurations inside `rod/config.py` according to your needs
25+
For example: If you are not interested in visualization: set `VISUALIZE` to `False`, <br />
26+
or if you want to switch off the speed hack set `SPLIT_MODEL` to `False`, <br />
27+
- to be able to use KCF_Tracking inside `scripts/` run `bash build_kcf.sh` to build it and set `USE_TRACKER` to `True` to use it <br />
28+
(currently only works for pure object detection models without `SPLIT_MODEL`)
3029
- for realtime inference using video stream run: `run_objectdetection.py` or `run_deeplab.py`
3130
- for benchmark tests on sample images run: `test_objectdetection.py`or `test_deeplab.py` <br />
32-
(put them as `.jpg` into `test_images/`)
31+
(put them as `.jpg` into `test_images/`. timeline results will appear in `test_results/`)
3332
- Enjoy!
3433

3534

build_kcf.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

config.sample.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.
File renamed without changes.

rod/config.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 = ''

stuff/object_detection/core/box_list_ops.py renamed to rod/core/box_list_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"""
2626
import tensorflow as tf
2727

28-
from stuff.object_detection.core import box_list
29-
from stuff.object_detection.utils import shape_utils
28+
from rod.core import box_list
29+
from rod.utils import shape_utils
3030

3131

3232
class SortOrder(object):
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)