Update
This commit is contained in:
parent
43a5d4568a
commit
6394fd3e09
|
@ -1,6 +1,6 @@
|
||||||
classes=21
|
classes=21
|
||||||
train=./data/widok_01_21/widok_01_21_train_labels.txt
|
train=/data/widok_01_21/widok_01_21_train_labels.txt
|
||||||
valid=./data/widok_01_21/widok_01_21_test_labels.txt
|
valid=/data/widok_01_21/widok_01_21_test_labels.txt
|
||||||
names=./data/widok_01_21/widok_01_21.names
|
names=/data/widok_01_21/widok_01_21.names
|
||||||
backup=backup/
|
backup=backup/
|
||||||
eval=coco
|
eval=coco
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -43,7 +43,7 @@ train:
|
||||||
experiments:
|
experiments:
|
||||||
dir: ./experiments
|
dir: ./experiments
|
||||||
detect:
|
detect:
|
||||||
source: /home/tomekb/yolov3/data/widok_01_19/widok_01_19_test_labels.txt
|
source: ./data/widok_01_19/widok_01_19_test_labels.txt
|
||||||
test-img-size: 1024
|
test-img-size: 1024
|
||||||
conf-thres: 0.3
|
conf-thres: 0.3
|
||||||
iou-thres: 0.6
|
iou-thres: 0.6
|
||||||
|
@ -51,7 +51,7 @@ detect:
|
||||||
agnostic-nms:
|
agnostic-nms:
|
||||||
augment:
|
augment:
|
||||||
confussion-matrix:
|
confussion-matrix:
|
||||||
labels-dir: /home/tomekb/yolov3/data/widok_01_19/widok_01_19_labels
|
labels-dir: ./data/widok_01_19/widok_01_19_labels
|
||||||
bayes:
|
bayes:
|
||||||
todo: todo
|
todo: todo
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Configuration:
|
||||||
for key, value in config_file['bayes'].items():
|
for key, value in config_file['bayes'].items():
|
||||||
self.__dict__[key] = value
|
self.__dict__[key] = value
|
||||||
|
|
||||||
def __init__(self, config_path='./config_bayes.yml') -> None:
|
def __init__(self, config_path) -> None:
|
||||||
self.config_path = config_path
|
self.config_path = config_path
|
||||||
file = yaml.load(open(config_path, 'r'), Loader=yaml.Loader)
|
file = yaml.load(open(config_path, 'r'), Loader=yaml.Loader)
|
||||||
self.train = self.Train(file)
|
self.train = self.Train(file)
|
||||||
|
|
|
@ -18,12 +18,12 @@ train:
|
||||||
img-size-start:
|
img-size-start:
|
||||||
type: discrete
|
type: discrete
|
||||||
min: 512
|
min: 512
|
||||||
max: 1088
|
max: 576
|
||||||
step: 64
|
step: 64
|
||||||
img-size-end:
|
img-size-end:
|
||||||
type: discrete
|
type: discrete
|
||||||
min: 512
|
min: 512
|
||||||
max: 1088
|
max: 576
|
||||||
step: 64
|
step: 64
|
||||||
rect:
|
rect:
|
||||||
type: discrete
|
type: discrete
|
||||||
|
@ -122,7 +122,7 @@ detect:
|
||||||
test-img-size:
|
test-img-size:
|
||||||
type: discrete
|
type: discrete
|
||||||
min: 512
|
min: 512
|
||||||
max: 1088
|
max: 576
|
||||||
step: 64
|
step: 64
|
||||||
conf-thres:
|
conf-thres:
|
||||||
type: continuous
|
type: continuous
|
||||||
|
|
|
@ -6,19 +6,22 @@ import shutil
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import GPyOpt
|
import GPyOpt
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from config_bayes import Configuration
|
from config_bayes import Configuration
|
||||||
|
|
||||||
from utils import call_subprocess, get_values_from_conff_matrix
|
from utils import call_subprocess, get_values_from_conff_matrix
|
||||||
|
|
||||||
config = Configuration()
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
PROJECT_ROOT = os.path.join(dir_path, '..')
|
||||||
|
|
||||||
|
bayes_config_yaml = os.path.join(dir_path, 'config_bayes.yml')
|
||||||
|
config = Configuration(bayes_config_yaml)
|
||||||
|
|
||||||
date_string = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
|
date_string = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
|
||||||
bayes_params_file = open(os.path.join(config.experiments.dir, f"{date_string}_bayes_params.txt"), 'a+')
|
bayes_params_file = open(os.path.join(PROJECT_ROOT, config.experiments.dir, f"{date_string}_bayes_params.txt"), 'a+')
|
||||||
|
|
||||||
|
|
||||||
def call_training_script(gaussian_hyps):
|
def call_training_script(gaussian_hyps):
|
||||||
cmd = 'python-u /home/tomekb/yolov3/train.py'
|
cmd = 'python -u train.py'
|
||||||
cmd += ' --epochs ' + gaussian_hyps['epochs'].__str__()
|
cmd += ' --epochs ' + gaussian_hyps['epochs'].__str__()
|
||||||
cmd += ' --batch-size ' + gaussian_hyps['batch-size'].__str__()
|
cmd += ' --batch-size ' + gaussian_hyps['batch-size'].__str__()
|
||||||
cmd += ' --cfg ' + config.train.cfg.__str__()
|
cmd += ' --cfg ' + config.train.cfg.__str__()
|
||||||
|
@ -40,11 +43,7 @@ def call_training_script(gaussian_hyps):
|
||||||
print("_______ CALLING TRAINING SCRIPT _______")
|
print("_______ CALLING TRAINING SCRIPT _______")
|
||||||
print(cmd)
|
print(cmd)
|
||||||
|
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
os.chdir(os.path.join(dir_path, '..')) # change to project root directory
|
|
||||||
|
|
||||||
call_subprocess(cmd)
|
call_subprocess(cmd)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ def move_training_results_to_experiments_dir():
|
||||||
os.mkdir(training_results_dir_path)
|
os.mkdir(training_results_dir_path)
|
||||||
|
|
||||||
weights_path = os.path.join(training_results_dir_path, 'best.pt')
|
weights_path = os.path.join(training_results_dir_path, 'best.pt')
|
||||||
shutil.move('/home/tomekb/yolov3/weights/best.pt', weights_path) # move best weights
|
shutil.move('./weights/best.pt', weights_path) # move best weights
|
||||||
|
|
||||||
names_path = open(config.train.data).readlines()[3].split('=')[-1].rstrip() # read names path from file
|
names_path = open(config.train.data).readlines()[3].split('=')[-1].rstrip() # read names path from file
|
||||||
names_file_name = ntpath.basename(names_path)
|
names_file_name = ntpath.basename(names_path)
|
||||||
|
@ -66,7 +65,7 @@ def move_training_results_to_experiments_dir():
|
||||||
shutil.copy(names_path,
|
shutil.copy(names_path,
|
||||||
experiment_names_path) # copy names file from *.data file to created experiment dir with training results
|
experiment_names_path) # copy names file from *.data file to created experiment dir with training results
|
||||||
|
|
||||||
tensorboard_dir = '/home/tomekb/yolov3/runs'
|
tensorboard_dir = './runs'
|
||||||
tensorboard_events_files = glob.glob(os.path.join(tensorboard_dir, '*'))
|
tensorboard_events_files = glob.glob(os.path.join(tensorboard_dir, '*'))
|
||||||
last_modified_events_file = max(tensorboard_events_files, key=os.path.getmtime)
|
last_modified_events_file = max(tensorboard_events_files, key=os.path.getmtime)
|
||||||
shutil.move(last_modified_events_file,
|
shutil.move(last_modified_events_file,
|
||||||
|
@ -74,17 +73,12 @@ def move_training_results_to_experiments_dir():
|
||||||
|
|
||||||
shutil.copy2(config.config_path, training_results_dir_path) # copying configuration yaml
|
shutil.copy2(config.config_path, training_results_dir_path) # copying configuration yaml
|
||||||
|
|
||||||
# for test purposes only
|
|
||||||
# TODO CHANGE ME AFTER TESTS
|
|
||||||
shutil.copy2('/home/tomekb/yolov3/experiments/yolov3-spp-100-epochs-freeze-layers/best.pt',
|
|
||||||
training_results_dir_path)
|
|
||||||
|
|
||||||
return weights_path, experiment_names_path, training_results_dir_path
|
return weights_path, experiment_names_path, training_results_dir_path
|
||||||
|
|
||||||
|
|
||||||
def call_detection_script(gaussian_hyps, weights_path, names_path, dir):
|
def call_detection_script(gaussian_hyps, weights_path, names_path, dir):
|
||||||
detect_output_dir = os.path.join(dir, 'output')
|
detect_output_dir = os.path.join(dir, 'output')
|
||||||
cmd = f"""/home/tomekb/miniconda3/envs/conda3.7/bin/python -u /home/tomekb/yolov3/detect.py
|
cmd = f"""python -u ./detect.py
|
||||||
--cfg {config.train.cfg}
|
--cfg {config.train.cfg}
|
||||||
--source {config.detect.source}
|
--source {config.detect.source}
|
||||||
--output {detect_output_dir}
|
--output {detect_output_dir}
|
||||||
|
@ -107,7 +101,7 @@ def call_detection_script(gaussian_hyps, weights_path, names_path, dir):
|
||||||
def call_generate_confussion_matrix(detect_output_dir, names_path, train_results_dir):
|
def call_generate_confussion_matrix(detect_output_dir, names_path, train_results_dir):
|
||||||
labels_dir = getattr(config.confussion_matrix, 'labels-dir')
|
labels_dir = getattr(config.confussion_matrix, 'labels-dir')
|
||||||
conff_matrix_path = os.path.join(train_results_dir, 'confussion-matrix.tsv')
|
conff_matrix_path = os.path.join(train_results_dir, 'confussion-matrix.tsv')
|
||||||
cmd = f"node /home/tomekb/yolov3/our_scripts/generate-confusion-matrix.js {detect_output_dir} {labels_dir} {names_path} > {conff_matrix_path}"
|
cmd = f"node ./our_scripts/generate-confusion-matrix.js {detect_output_dir} {labels_dir} {names_path} > {conff_matrix_path}"
|
||||||
print("_______ CALLING CONFUSSION MATRIX SCRIPT _______")
|
print("_______ CALLING CONFUSSION MATRIX SCRIPT _______")
|
||||||
print(cmd)
|
print(cmd)
|
||||||
call_subprocess(cmd)
|
call_subprocess(cmd)
|
||||||
|
@ -171,10 +165,7 @@ def yolov3(x):
|
||||||
bayes_params_file.writelines([line, '\n'])
|
bayes_params_file.writelines([line, '\n'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# uruchamiać z
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
bounds = config.get_bayes_bounds()
|
bounds = config.get_bayes_bounds()
|
||||||
|
|
||||||
# for b in bounds:
|
# for b in bounds:
|
||||||
|
@ -184,6 +175,8 @@ if __name__ == '__main__':
|
||||||
X = None
|
X = None
|
||||||
Y = None
|
Y = None
|
||||||
|
|
||||||
|
os.chdir(PROJECT_ROOT) # change to project root directory
|
||||||
|
|
||||||
bayes_optimizer = GPyOpt.methods.BayesianOptimization(f=yolov3, domain=bounds, X=X, Y=Y, verbosity=True,
|
bayes_optimizer = GPyOpt.methods.BayesianOptimization(f=yolov3, domain=bounds, X=X, Y=Y, verbosity=True,
|
||||||
initial_design_numdata=2)
|
initial_design_numdata=2)
|
||||||
bayes_optimizer.run_optimization(config.bayes.iterations, verbosity=True)
|
bayes_optimizer.run_optimization(config.bayes.iterations, verbosity=True)
|
||||||
|
|
Loading…
Reference in New Issue