Skip to content

Commit 6ebfeb7

Browse files
committed
ADD: Neuron Coverage DNN
0 parents  commit 6ebfeb7

27 files changed

+906
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Introduction
2+
3+
The main purpose of this source code is to demonstrate the correlation between image transformations and neuron
4+
coverage. A model is trained on generated BeamNG dataset for the simple task of keeping vehicles on the road. A part of
5+
the dataset is then transformed (rotate, adjust brightness, etc...) and input to the trained model. Neuron coverage
6+
and output from the trained model on both original and transformed image data will be recorded and summarize to verify
7+
the correlation.
8+
9+
## Setup
10+
11+
Clone <strong>config.yml.sample</strong> file and rename it to <strong>config.yml</strong>. Modify the configurations corresponding to your local setup.
12+
13+
## Running
14+
`python run.py --task TASK_TO_PERFORM` <br>
15+
Replace TASK_TO_PERFORM with one of the following options: <strong>collecting, training, evaluating</strong>

requirements.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
beamngpy==1.18
2+
Keras==2.4.3
3+
tensorflow==2.4.0
4+
shapely==1.7.1
5+
pandas==1.2.1
6+
imageio==2.9.0
7+
scikit-learn==0.24.1
8+
opencv-python==4.5.1.48
9+
PyYAML~=5.3.1
10+
numpy~=1.19.5
11+
matplotlib~=3.3.3

run.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Author: Tran Phan
4+
5+
import argparse
6+
7+
from src.modules import logger
8+
9+
10+
def get_console_arguments():
11+
# parse console arguments
12+
parser = argparse.ArgumentParser(description='Neuron Coverage Demonstration')
13+
parser.add_argument('--task', dest='task', choices=['collecting', 'data_cleaning', 'training', 'evaluating'],
14+
default="",
15+
required=True, help='Enter one of the following: collecting, training, evaluating')
16+
parser.add_argument('--q', dest='number_of_images', type=int, default=1000,
17+
required=False, help='Number of images data to collect')
18+
parser.add_argument('--cm', dest='collect_mode', choices=['manual_mode', 'ai_mode'], default="manual_mode",
19+
required=False, help='Data collect mode: manual_mode or ai_mode')
20+
parser.add_argument('--model', dest='model', choices=['inception_v3', 'cnn'],
21+
default="inception_v3",
22+
help='Enter one of the following model name for training: inception_v2, cnn')
23+
parser.add_argument('--mf', dest='model_file', type=str, default="model_1.h5",
24+
help='Model file name for running evaluator')
25+
26+
return parser.parse_args()
27+
28+
29+
if __name__ == "__main__":
30+
args = get_console_arguments()
31+
32+
if args.task == "collecting":
33+
logger.info("Task: Collecting")
34+
from src.training import data_collector
35+
36+
data_collector.run_collector(int(args.number_of_images), args.collect_mode)
37+
38+
if args.task == "data_cleaning":
39+
logger.info("Task: Cleaning training data")
40+
from src.training import data_cleaner
41+
42+
data_cleaner.run_data_cleaner()
43+
44+
elif args.task == "training":
45+
logger.info("Task: Training - " + args.model)
46+
from src.training import model_training
47+
48+
model_training.run_trainer(args.model)
49+
50+
elif args.task == "evaluating":
51+
logger.info("Task: Evaluating")
52+
from src.evaluation import evaluate
53+
54+
evaluate.run_evaluator(args.model_file)

src/__init__.py

Whitespace-only changes.
260 Bytes
Binary file not shown.
343 Bytes
Binary file not shown.

src/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
logging:
2+
filename:
3+
level: DEBUG
4+
encoding: utf-8
5+
format: '%(asctime)s | %(levelname)s | %(name)s | %(message)s'
6+
7+
data_collecting:
8+
mode: "manual"
9+
number_of_images: 5
10+
image_width: 299
11+
image_height: 299
12+
scenario_level: "west_coast_usa"
13+
scenario_name: "example"
14+
vehicle_model: "etk800"
15+
pos: "-717,101,118"
16+
rot_quat: "0,0,0.3826834,0.9238795"
17+
data_path: "/training/data/images/" # relative to the root of the project
18+
csv_path: "/training/data/training_data.csv"
19+
model_path: "/training/models/"
20+
sleep: 1 #seconds
21+
22+
training:
23+
epochs: 30
24+
25+
evaluation:
26+
neuron_cover_threshold: 0.2
27+
evaluation_data_path: "/evaluation/data/images/"
28+
29+
beamNG:
30+
home: "Directory of BeamNG program"
31+
host: "localhost"
32+
port: 64256

src/config.yml.sample

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
logging:
2+
filename:
3+
level: DEBUG
4+
encoding: utf-8
5+
format: '%(asctime)s | %(levelname)s | %(name)s | %(message)s'
6+
7+
data_collecting:
8+
mode: "manual"
9+
number_of_images: 5
10+
image_width: 500
11+
image_height: 500
12+
scenario_level: "west_coast_usa"
13+
scenario_name: "example"
14+
vehicle_model: "etk800"
15+
pos: "-717,101,118"
16+
rot_quat: "0,0,0.3826834,0.9238795"
17+
data_path: "/training/data/images/" # relative to the root of the project
18+
csv_path: "/training/data/training_data.csv"
19+
model_path: "/training/models/"
20+
sleep: 1 #seconds
21+
22+
training:
23+
epochs: 5
24+
25+
evaluation:
26+
neuron_cover_threshold: 0.2
27+
evaluation_data_path: "/evaluation/data/images/"
28+
29+
beamNG:
30+
home: "Directory of BeamNG program"
31+
host: "localhost"
32+
port: 64256

src/definitions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Author: Tran Phan
4+
5+
import os
6+
7+
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
5.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)