Skip to content
Snippets Groups Projects
Commit e544ff05 authored by nikolasph's avatar nikolasph
Browse files

Refactoring

parent 7732aa85
No related branches found
No related tags found
No related merge requests found
Showing
with 756 additions and 42 deletions
...@@ -25,18 +25,18 @@ __date__ = 2016-03-25 ...@@ -25,18 +25,18 @@ __date__ = 2016-03-25
### Argument Parser ### Argument Parser
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='This methods permits to execute a multiclass classification with one single view. At this point the used classifier is a RandomForest. The GridSearch permits to vary the number of trees and CrossValidation with k-folds.', description='This methods permits to execute a multiclass classification with one single view. At this point the used classifier is a RandomForest. The GridSearch permits to vary the number of trees and CrossValidation with k-folds. The result will be a plot of the score per class and a CSV with the best classifier found by the GridSearch.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
groupStandard = parser.add_argument_group('necessary arguments:') groupStandard = parser.add_argument_group('necessary arguments')
groupStandard.add_argument('--name', metavar='STRING', action='store', help='Name of Database (default: %(default)s)', default='Caltech') groupStandard.add_argument('--name', metavar='STRING', action='store', help='Name of Database (default: %(default)s)', default='Caltech')
groupStandard.add_argument('--feat', metavar='STRING', action='store', help='Name of Feature for Classification (default: %(default)s)', default='RGB') groupStandard.add_argument('--feat', metavar='STRING', action='store', help='Name of Feature for Classification (default: %(default)s)', default='RGB')
groupStandard.add_argument('--pathF', metavar='STRING', action='store', help='Path to the features (default: %(default)s)', default='Results-FeatExtr\\') groupStandard.add_argument('--pathF', metavar='STRING', action='store', help='Path to the features (default: %(default)s)', default='Results-FeatExtr/')
groupStandard.add_argument('--fileCL', metavar='STRING', action='store', help='Name of classLabels CSV-file (default: %(default)s)', default='classLabels.csv') groupStandard.add_argument('--fileCL', metavar='STRING', action='store', help='Name of classLabels CSV-file (default: %(default)s)', default='classLabels.csv')
groupStandard.add_argument('--fileFeat', metavar='STRING', action='store', help='Name of feature CSV-file (default: %(default)s)', default='feature.csv') groupStandard.add_argument('--fileFeat', metavar='STRING', action='store', help='Name of feature CSV-file (default: %(default)s)', default='feature.csv')
groupStandard.add_argument('-log', action='store_true', help='Use option to activate Logging to Console') groupStandard.add_argument('-log', action='store_true', help='Use option to activate Logging to Console')
groupClass = parser.add_argument_group('Classification arguments:') groupClass = parser.add_argument_group('Classification arguments')
groupClass.add_argument('--CL_split', metavar='FLOAT', action='store', help='Determine the the train size', type=float, default=0.8) groupClass.add_argument('--CL_split', metavar='FLOAT', action='store', help='Determine the the train size', type=float, default=0.8)
groupClass.add_argument('--CL_RF_trees', metavar='STRING', action='store', help='GridSearch: Determine the trees', default='50 100 150 200') groupClass.add_argument('--CL_RF_trees', metavar='STRING', action='store', help='GridSearch: Determine the trees', default='50 100 150 200')
groupClass.add_argument('--CL_RF_CV', metavar='INT', action='store', help='Number of k-folds for CV', type=int, default=8) groupClass.add_argument('--CL_RF_CV', metavar='INT', action='store', help='Number of k-folds for CV', type=int, default=8)
...@@ -50,7 +50,7 @@ t_start = time.time() ...@@ -50,7 +50,7 @@ t_start = time.time()
# Configure Logger # Configure Logger
dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-ClassMonoView/" dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-ClassMonoView/"
logfilename= datetime.datetime.now().strftime("%Y_%m_%d") + "-LOG-CMV-" + args.name + "-" + args.feat logfilename= datetime.datetime.now().strftime("%Y_%m_%d") + "-CMV-" + args.name + "-" + args.feat + "-LOG"
logfile = dir + logfilename logfile = dir + logfilename
if os.path.isfile(logfile + ".log"): if os.path.isfile(logfile + ".log"):
for i in range(1,20): for i in range(1,20):
......
...@@ -27,35 +27,35 @@ parser = argparse.ArgumentParser( ...@@ -27,35 +27,35 @@ parser = argparse.ArgumentParser(
description='This methods permits to export one or more features at the same time for a database of images (path, name). To extract one feature activate it by using the specific argument (e.g. -RGB). For each feature you can define the parameters by using the optional arguments (e.g. --RGB_Hist 32). The results will be exported to a CSV-File.', description='This methods permits to export one or more features at the same time for a database of images (path, name). To extract one feature activate it by using the specific argument (e.g. -RGB). For each feature you can define the parameters by using the optional arguments (e.g. --RGB_Hist 32). The results will be exported to a CSV-File.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
groupStandard = parser.add_argument_group('necessary arguments:') groupStandard = parser.add_argument_group('necessary arguments')
groupStandard.add_argument('--name', metavar='STRING', action='store', help='Select a name of DB, e.g. Caltech (default: %(default)s)', default='DB') groupStandard.add_argument('--name', metavar='STRING', action='store', help='Select a name of DB, e.g. Caltech (default: %(default)s)', default='DB')
groupStandard.add_argument('--path', metavar='STRING', action='store', help='Path to the database (default: %(default)s)', default='D:\\CaltechMini') groupStandard.add_argument('--path', metavar='STRING', action='store', help='Path to the database (default: %(default)s)', default='D:\\CaltechMini')
groupStandard.add_argument('-log', action='store_true', help='Use option to activate Logging to Console') groupStandard.add_argument('-log', action='store_true', help='Use option to activate Logging to Console')
groupRGB = parser.add_argument_group('RGB arguments:') groupRGB = parser.add_argument_group('RGB arguments')
groupRGB.add_argument('-RGB', action='store_true', help='Use option to activate RGB') groupRGB.add_argument('-RGB', action='store_true', help='Use option to activate RGB')
groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=16) groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=16)
groupRGB.add_argument('--RGB_CI', metavar='INT', action='store', help='Max Color Intensity [0 to VALUE]', type=int, default=256) groupRGB.add_argument('--RGB_CI', metavar='INT', action='store', help='Max Color Intensity [0 to VALUE]', type=int, default=256)
groupRGB.add_argument('-RGB_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupRGB.add_argument('-RGB_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupHSV = parser.add_argument_group('HSV arguments:') groupHSV = parser.add_argument_group('HSV arguments')
groupHSV.add_argument('-HSV', action='store_true', help='Use option to activate HSV') groupHSV.add_argument('-HSV', action='store_true', help='Use option to activate HSV')
groupHSV.add_argument('--HSV_H_Bins', metavar='INT', action='store', help='Number of bins for Hue', type=int, default=16) groupHSV.add_argument('--HSV_H_Bins', metavar='INT', action='store', help='Number of bins for Hue', type=int, default=16)
groupHSV.add_argument('--HSV_S_Bins', metavar='INT', action='store', help='Number of bins for Saturation', type=int, default=4) groupHSV.add_argument('--HSV_S_Bins', metavar='INT', action='store', help='Number of bins for Saturation', type=int, default=4)
groupHSV.add_argument('--HSV_V_Bins', metavar='INT', action='store', help='Number of bins for Value', type=int, default=4) groupHSV.add_argument('--HSV_V_Bins', metavar='INT', action='store', help='Number of bins for Value', type=int, default=4)
groupHSV.add_argument('-HSV_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupHSV.add_argument('-HSV_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupSIFT = parser.add_argument_group('SIFT arguments:') groupSIFT = parser.add_argument_group('SIFT arguments')
groupSIFT.add_argument('-SIFT', action='store_true', help='Use option to activate SIFT') groupSIFT.add_argument('-SIFT', action='store_true', help='Use option to activate SIFT')
groupSIFT.add_argument('--SIFT_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50) groupSIFT.add_argument('--SIFT_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50)
groupSIFT.add_argument('-SIFT_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupSIFT.add_argument('-SIFT_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupSURF = parser.add_argument_group('SURF arguments:') groupSURF = parser.add_argument_group('SURF arguments')
groupSURF.add_argument('-SURF', action='store_true', help='Use option to activate SURF') groupSURF.add_argument('-SURF', action='store_true', help='Use option to activate SURF')
groupSURF.add_argument('--SURF_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50) groupSURF.add_argument('--SURF_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50)
groupSURF.add_argument('-SURF_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupSURF.add_argument('-SURF_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupHOG = parser.add_argument_group('HOG arguments:') groupHOG = parser.add_argument_group('HOG arguments')
groupHOG.add_argument('-HOG', action='store_true', help='Use option to activate HOG') groupHOG.add_argument('-HOG', action='store_true', help='Use option to activate HOG')
groupHOG.add_argument('--HOG_CellD', metavar='INT', action='store', help='CellDimension for local histograms', type=int, default=5) groupHOG.add_argument('--HOG_CellD', metavar='INT', action='store', help='CellDimension for local histograms', type=int, default=5)
groupHOG.add_argument('--HOG_Orient', metavar='INT', action='store', help='Number of bins of local histograms', type=int, default=8) groupHOG.add_argument('--HOG_Orient', metavar='INT', action='store', help='Number of bins of local histograms', type=int, default=8)
...@@ -93,7 +93,7 @@ if(args.HOG): ...@@ -93,7 +93,7 @@ if(args.HOG):
# Configure Logger # Configure Logger
dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatExtr/" dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatExtr/"
logfilename= datetime.datetime.now().strftime("%Y_%m_%d") + "-LOG-FE-" + args.name + "-" + features.replace(" ", "_").rstrip("_") logfilename= datetime.datetime.now().strftime("%Y_%m_%d") + "-FE-" + args.name + "-" + features.replace(" ", "_").rstrip("_") + "-LOG"
logfile = dir + logfilename logfile = dir + logfilename
if os.path.isfile(logfile + ".log"): if os.path.isfile(logfile + ".log"):
for i in range(1,20): for i in range(1,20):
......
...@@ -27,45 +27,46 @@ parser = argparse.ArgumentParser( ...@@ -27,45 +27,46 @@ parser = argparse.ArgumentParser(
description='This methods permits to perform an optimisation of the parameter of one feature. Therefore you have so specify which feature to use (e.g. --feature RGB) and which of his parameters (the parameters depend on the feature chosen, e.g. for RGB: --parameter Bins). The method will calculate the results in your given range and export the results to a CSV-File.', description='This methods permits to perform an optimisation of the parameter of one feature. Therefore you have so specify which feature to use (e.g. --feature RGB) and which of his parameters (the parameters depend on the feature chosen, e.g. for RGB: --parameter Bins). The method will calculate the results in your given range and export the results to a CSV-File.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
groupStandard = parser.add_argument_group('necessary arguments:') groupStandard = parser.add_argument_group('necessary arguments')
groupStandard.add_argument('--name', metavar='STRING', action='store', help='Select a name of DB, e.g. Caltech (default: %(default)s)', default='DB') groupStandard.add_argument('--name', metavar='STRING', action='store', help='Select a name of DB, e.g. Caltech (default: %(default)s)', default='DB')
groupStandard.add_argument('--path', metavar='STRING', action='store', help='Path to the database (default: %(default)s)', default='D:\\CaltechMini') groupStandard.add_argument('--path', metavar='STRING', action='store', help='Path to the database (default: %(default)s)', default='D:\\CaltechMini')
groupStandard.add_argument('-log', action='store_true', help='Use option to activate Logging to Console') groupStandard.add_argument('-log', action='store_true', help='Use option to activate Logging to Console')
groupStandard.add_argument('-show', action='store_true', help='Use option to show results instead of saving it')
groupOpt = parser.add_argument_group('Optimisation arguments:') groupOpt = parser.add_argument_group('Optimisation arguments')
groupOpt.add_argument('--feature', choices=['RGB', 'HSV', 'SURF', 'SIFT', 'HOG'], help='Set feature from list (RGB, HSV, ..)', default='RGB') groupOpt.add_argument('--feature', choices=['RGB', 'HSV', 'SURF', 'SIFT', 'HOG'], help='Set feature from list (RGB, HSV, ..)', default='RGB')
groupOpt.add_argument('--param', choices=['RGB_Bins', 'RGB_MaxCI', 'HSV_H_Bins', 'HSV_S_Bins', 'HSV_V_Bins', 'SIFT_Cluster', 'SURF_Cluster', 'HOG_Cluster'], help='Parameter to optimise (remember depends on feature)', default='RGB_Bins') groupOpt.add_argument('--param', choices=['RGB_Bins', 'RGB_MaxCI', 'HSV_H_Bins', 'HSV_S_Bins', 'HSV_V_Bins', 'SIFT_Cluster', 'SURF_Cluster', 'HOG_Cluster'], help='Parameter to optimise (remember depends on feature)', default='RGB_Bins')
groupOpt.add_argument('--valueStart', metavar='INT', action='store', help='Start-Value for optimisation range', type=int) groupOpt.add_argument('--valueStart', metavar='INT', action='store', help='Start-Value for optimisation range', type=int)
groupOpt.add_argument('--valueEnd', metavar='INT', action='store', help='End-Value for optimisation range', type=int) groupOpt.add_argument('--valueEnd', metavar='INT', action='store', help='End-Value for optimisation range', type=int)
groupOpt.add_argument('--nCalcs', metavar='INT', action='store', help='Number of calculations between Start and End-Value', type=int) groupOpt.add_argument('--nCalcs', metavar='INT', action='store', help='Number of calculations between Start and End-Value', type=int)
groupRGB = parser.add_argument_group('RGB arguments:') groupRGB = parser.add_argument_group('RGB arguments')
groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=16) groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=16)
groupRGB.add_argument('--RGB_CI', metavar='INT', action='store', help='Max Color Intensity [0 to VALUE]', type=int, default=256) groupRGB.add_argument('--RGB_CI', metavar='INT', action='store', help='Max Color Intensity [0 to VALUE]', type=int, default=256)
groupRGB.add_argument('-RGB_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupRGB.add_argument('-RGB_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupHSV = parser.add_argument_group('HSV arguments:') groupHSV = parser.add_argument_group('HSV arguments')
groupHSV.add_argument('--HSV_H_Bins', metavar='INT', action='store', help='Number of bins for Hue', type=int, default=16) groupHSV.add_argument('--HSV_H_Bins', metavar='INT', action='store', help='Number of bins for Hue', type=int, default=16)
groupHSV.add_argument('--HSV_S_Bins', metavar='INT', action='store', help='Number of bins for Saturation', type=int, default=4) groupHSV.add_argument('--HSV_S_Bins', metavar='INT', action='store', help='Number of bins for Saturation', type=int, default=4)
groupHSV.add_argument('--HSV_V_Bins', metavar='INT', action='store', help='Number of bins for Value', type=int, default=4) groupHSV.add_argument('--HSV_V_Bins', metavar='INT', action='store', help='Number of bins for Value', type=int, default=4)
groupHSV.add_argument('-HSV_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupHSV.add_argument('-HSV_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupSIFT = parser.add_argument_group('SIFT arguments:') groupSIFT = parser.add_argument_group('SIFT arguments')
groupSIFT.add_argument('--SIFT_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50) groupSIFT.add_argument('--SIFT_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50)
groupSIFT.add_argument('-SIFT_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupSIFT.add_argument('-SIFT_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupSURF = parser.add_argument_group('SURF arguments:') groupSURF = parser.add_argument_group('SURF arguments')
groupSURF.add_argument('--SURF_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50) groupSURF.add_argument('--SURF_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=50)
groupSURF.add_argument('-SURF_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution') groupSURF.add_argument('-SURF_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
groupHOG = parser.add_argument_group('HOG arguments:') groupHOG = parser.add_argument_group('HOG arguments')
groupHOG.add_argument('--HOG_CellD', metavar='INT', action='store', help='CellDimension for local histograms', type=int, default=5) groupHOG.add_argument('--HOG_CellD', metavar='INT', action='store', help='CellDimension for local histograms', type=int, default=5)
groupHOG.add_argument('--HOG_Orient', metavar='INT', action='store', help='Number of bins of local histograms', type=int, default=8) groupHOG.add_argument('--HOG_Orient', metavar='INT', action='store', help='Number of bins of local histograms', type=int, default=8)
groupHOG.add_argument('--HOG_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=12) groupHOG.add_argument('--HOG_Cluster', metavar='INT', action='store', help='Number of k-means cluster', type=int, default=12)
groupHOG.add_argument('--HOG_Iter', metavar='INT', action='store', help='Max. number of iterations for clustering', type=int, default=100) groupHOG.add_argument('--HOG_Iter', metavar='INT', action='store', help='Max. number of iterations for clustering', type=int, default=100)
groupHOG.add_argument('--HOG_cores', metavar='INT', action='store', help='Number of cores for HOG', type=int, default=1) groupHOG.add_argument('--HOG_cores', metavar='INT', action='store', help='Number of cores for HOG', type=int, default=1)
groupClass = parser.add_argument_group('Classification arguments:') groupClass = parser.add_argument_group('Classification arguments')
groupClass.add_argument('--CL_split', metavar='FLOAT', action='store', help='Determine the train size', type=float, default=0.8) groupClass.add_argument('--CL_split', metavar='FLOAT', action='store', help='Determine the train size', type=float, default=0.8)
groupClass.add_argument('--CL_RF_trees', metavar='STRING', action='store', help='GridSearch: Determine the trees', default='50 100 150 200') groupClass.add_argument('--CL_RF_trees', metavar='STRING', action='store', help='GridSearch: Determine the trees', default='50 100 150 200')
groupClass.add_argument('--CL_RF_CV', metavar='INT', action='store', help='Number of k-folds for CV', type=int, default=8) groupClass.add_argument('--CL_RF_CV', metavar='INT', action='store', help='Number of k-folds for CV', type=int, default=8)
...@@ -92,7 +93,7 @@ para_Cl = [args.CL_split, map(int, args.CL_RF_trees.split()), args.CL_RF_CV, arg ...@@ -92,7 +93,7 @@ para_Cl = [args.CL_split, map(int, args.CL_RF_trees.split()), args.CL_RF_CV, arg
# Configure Logger # Configure Logger
dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatParaOpt/" dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatParaOpt/"
logfilename= datetime.datetime.now().strftime("%Y_%m_%d") + "-LOG-FPO-" + args.name + "-" + args.feat + "-" + args.param logfilename= datetime.datetime.now().strftime("%Y_%m_%d") + "-FPO-" + args.name + "-" + args.feature + "-" + args.param + "-LOG"
logfile = dir + logfilename logfile = dir + logfilename
if os.path.isfile(logfile + ".log"): if os.path.isfile(logfile + ".log"):
for i in range(1,20): for i in range(1,20):
...@@ -134,7 +135,7 @@ logging.debug("### Done:\t Feautre Optimisation ") ...@@ -134,7 +135,7 @@ logging.debug("### Done:\t Feautre Optimisation ")
################################ Render results ################################ Render results
logging.debug("### Start:\t Exporting to CSV ") logging.debug("### Start:\t Exporting to CSV ")
dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatParaOpt/" dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatParaOpt/"
filename = datetime.datetime.now().strftime("%Y_%m_%d") + "-FeatParaOpt-" + args.feature filename = datetime.datetime.now().strftime("%Y_%m_%d") + "-FPO-" + args.name + "-" + args.feature + "-" + args.param
ExportResults.exportPandasToCSV(df_feat_res, dir, filename) ExportResults.exportPandasToCSV(df_feat_res, dir, filename)
logging.debug("### Done:\t Exporting to CSV ") logging.debug("### Done:\t Exporting to CSV ")
...@@ -168,13 +169,18 @@ cl_desc = df_feat_res.c_cl_desc.values ...@@ -168,13 +169,18 @@ cl_desc = df_feat_res.c_cl_desc.values
# Description of Feature # Description of Feature
feat_desc = df_feat_res.a_feat_desc.values feat_desc = df_feat_res.a_feat_desc.values
# Store or Show plot
if(args.show):
store = False
else:
store = True store = True
fileName = datetime.datetime.now().strftime("%Y_%m_%d") + "-" + "-FPO-" + args.name + "-" + args.feature + "-" + args.param fileName = datetime.datetime.now().strftime("%Y_%m_%d") + "-FPO-" + args.name + "-" + args.feature + "-" + args.param
# Show Results for Calculation # Show Results for Calculation
ExportResults.showScoreTime(dir, fileName + "-TotalTime.png", store, score, tot_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation \n DB: ' + args.name + 'Feat: ' + args.feature, 'Precision', 'Total Time (Feature Extraction+Classification)\n [s]') ExportResults.showScoreTime(dir, fileName + "-TotalTime", store, score, tot_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation - DB:' + args.name + ' Feat:' + args.feature, 'Precision', 'Total Time (Feature Extraction+Classification)\n [s]')
ExportResults.showScoreTime(dir, fileName + "-FeatExtTime.png", store, score, feat_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation \n DB: ' + args.name + 'Feat: ' + args.feature, 'Precision', 'Feature Extraction Time\n [s]') ExportResults.showScoreTime(dir, fileName + "-FeatExtTime", store, score, feat_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation - DB:' + args.name + ' Feat:' + args.feature, 'Precision', 'Feature Extraction Time\n [s]')
ExportResults.showScoreTime(dir, fileName + "-ClassTime.png", store, score, cl_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation \n DB: ' + args.name + 'Feat: ' + args.feature, 'Precision', 'Classification Time\n [s]') ExportResults.showScoreTime(dir, fileName + "-ClassTime", store, score, cl_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation - DB:' + args.name + ' Feat:' + args.feature, 'Precision', 'Classification Time\n [s]')
logging.debug("### Done:\t Plot Result") logging.debug("### Done:\t Plot Result")
......
...@@ -12,6 +12,7 @@ import numpy as np # for Numpy Arrays ...@@ -12,6 +12,7 @@ import numpy as np # for Numpy Arrays
import matplotlib.pyplot as plt # for Plots import matplotlib.pyplot as plt # for Plots
from scipy.interpolate import interp1d # to Interpolate Data from scipy.interpolate import interp1d # to Interpolate Data
from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, HPacker # to generate the Annotations in plot from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, HPacker # to generate the Annotations in plot
from pylab import rcParams # to change size of plot
# Import own modules # Import own modules
...@@ -57,9 +58,13 @@ def showScoreTime(dir, filename, store, resScore, resTime, rangeX, parameter, fe ...@@ -57,9 +58,13 @@ def showScoreTime(dir, filename, store, resScore, resTime, rangeX, parameter, fe
f_score_interp = interp1d(rangeX, resScore, kind='quadratic') f_score_interp = interp1d(rangeX, resScore, kind='quadratic')
f_time_interp = interp1d(rangeX, resTime, kind='quadratic') f_time_interp = interp1d(rangeX, resTime, kind='quadratic')
# Change size of plot
rcParams['figure.figsize'] =20, 10
# Figure1 with subplot # Figure1 with subplot
fig, ax1 = plt.subplots() fig, ax1 = plt.subplots()
#plt.plot(x, y, type of line) #plt.plot(x, y, type of line)
# Generating X-Axis # Generating X-Axis
xnew = np.linspace(0, max(rangeX), num=100, endpoint=True) xnew = np.linspace(0, max(rangeX), num=100, endpoint=True)
...@@ -86,7 +91,7 @@ def showScoreTime(dir, filename, store, resScore, resTime, rangeX, parameter, fe ...@@ -86,7 +91,7 @@ def showScoreTime(dir, filename, store, resScore, resTime, rangeX, parameter, fe
ax1.annotate(letter, xy=(act_x, act_score), xytext=(act_x, act_score)) ax1.annotate(letter, xy=(act_x, act_score), xytext=(act_x, act_score))
ax2.annotate(letter, xy=(act_x, act_time), xytext=(act_x, act_time)) ax2.annotate(letter, xy=(act_x, act_time), xytext=(act_x, act_time))
# Creates a legend with description of feature and classificator of each datapoint # Creates a legend with description of feature and classificator of each datapoint
legend = legend + letter + ": " + act_feat_desc + " Classf: " + act_cl_desc + "\n" legend = legend + letter + ") Feature: " + act_feat_desc + "; Classifier: " + act_cl_desc + "\n"
# Remove last \n # Remove last \n
legend = legend[:-1] legend = legend[:-1]
...@@ -99,9 +104,9 @@ def showScoreTime(dir, filename, store, resScore, resTime, rangeX, parameter, fe ...@@ -99,9 +104,9 @@ def showScoreTime(dir, filename, store, resScore, resTime, rangeX, parameter, fe
anchored_box = AnchoredOffsetbox(loc=3, anchored_box = AnchoredOffsetbox(loc=3,
child=box, pad=0.2, child=box, pad=0.2,
frameon=True, frameon=True,
bbox_to_anchor=(0., 1.02), bbox_to_anchor=(0, 1.04), #to change the place of the legend (text above of figure)
bbox_transform=ax1.transAxes, bbox_transform=ax1.transAxes,
borderpad=1.5, borderpad=1.0,
) )
ax1.add_artist(anchored_box) ax1.add_artist(anchored_box)
fig.subplots_adjust(top=0.7) fig.subplots_adjust(top=0.7)
......
...@@ -193,9 +193,9 @@ def calcSURFSIFTDescriptors(dfImages, boolSIFT): ...@@ -193,9 +193,9 @@ def calcSURFSIFTDescriptors(dfImages, boolSIFT):
npImages = dfImages.values npImages = dfImages.values
if(boolSIFT==True): if(boolSIFT==True):
feat = "SIFT:\t " feat = "### SIFT:\t "
else: else:
feat = "SURF:\t " feat = "### SURF:\t "
# List where all the descriptors are stored # List where all the descriptors are stored
des_list = [] des_list = []
...@@ -316,9 +316,9 @@ def calcSURFSIFTHisto(nameDB, dfImages, cluster, boolNormMinMax, descriptors,des ...@@ -316,9 +316,9 @@ def calcSURFSIFTHisto(nameDB, dfImages, cluster, boolNormMinMax, descriptors,des
param = "Cluster_" + str(cluster) + "-" + "Norm_" + norm param = "Cluster_" + str(cluster) + "-" + "Norm_" + norm
if(boolSIFT==True): if(boolSIFT==True):
feat="SIFT" feat="### SIFT"
else: else:
feat="SURF" feat="### SURF"
description = nameDB + "-" + feat + "-" + param description = nameDB + "-" + feat + "-" + param
#### Bag of Words Approach #### Bag of Words Approach
......
2016-03-22 16:40:43,005 DEBUG:### Main Programm for Classification MonoView
2016-03-22 16:40:43,005 DEBUG:### Info: Database:CTMini Feature:RGB train_size:0.8, GridSearch of Trees:50 100 150 200, CrossValidation k-folds:8, cores:1
2016-03-22 16:40:43,006 DEBUG:### Start: Read CSV Files
2016-03-22 16:40:43,016 DEBUG:### Info: Shape of Feature:(97L, 48L), Length of classLabels vector:(97L,)
2016-03-22 16:40:43,016 DEBUG:### Done: Read CSV Files
2016-03-22 16:40:43,016 DEBUG:### Start: Determine Train/Test split
2016-03-22 16:40:43,016 DEBUG:### Info: Shape X_train:(77L, 48L), Length of y_train:77
2016-03-22 16:40:43,017 DEBUG:### Info: Shape X_test:(20L, 48L), Length of y_test:20
2016-03-22 16:40:43,017 DEBUG:### Done: Determine Train/Test split
2016-03-22 16:40:43,017 DEBUG:### Start: Classification
2016-03-22 16:40:45,684 DEBUG:### Info: Time for Classification: 2.67600011826[s]
2016-03-22 16:40:45,684 DEBUG:### End: Classification
2016-03-22 16:40:45,684 DEBUG:### Start: Exporting to CSV
2016-03-22 16:40:45,690 DEBUG:### Done: Exporting to CSV
2016-03-22 16:40:45,690 DEBUG:### Start: Plot Result
2016-03-22 16:40:45,839 DEBUG:### Done: Plot Result
;a_class_time;b_cl_desc;c_cl_res;d_cl_score
0;2.67600011826;Classif_RF-CV_8-Trees_50;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";0.948051948052
Code/Niko/Results-ClassMonoView/2016_03_22-CMV-CTMini-RGB.png

22.2 KiB

0;accordion
1;anchor
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2016-03-22 15:16:37,407 DEBUG:### Main Programm for Feature Extraction ###
2016-03-22 15:16:37,408 DEBUG:Infos: NameDB=CTMini, Path=D:\CaltechMini, Features=RGB HSV SIFT SURF HOG
2016-03-22 15:16:37,408 DEBUG:Start: Exportation of images from DB
2016-03-22 15:16:37,667 DEBUG:Done: Exportation of images from DB in:0.259000062943[s]
2016-03-22 15:16:37,668 DEBUG:Start: Features Extraction
2016-03-22 15:16:37,668 DEBUG:RGB: Start
2016-03-22 15:16:37,668 DEBUG:RGB: NumberOfBins=16, MaxColorIntensity=256, Norm=Distr
2016-03-22 15:16:37,844 DEBUG:RGB: Done in: 0.175000190735[s]
2016-03-22 15:16:37,844 DEBUG:HSV: Start
2016-03-22 15:16:37,844 DEBUG:HSV: HSVBins=[16,4,4], Norm=Distr
2016-03-22 15:16:38,188 DEBUG:HSV: Done in: 0.344999790192[s]
2016-03-22 15:16:38,190 DEBUG:SIFT: Start
2016-03-22 15:16:38,190 DEBUG:SIFT: Cluster=50, Norm=Distr
2016-03-22 15:16:38,190 DEBUG:SIFT: Keypoints Calculation
2016-03-22 15:16:40,349 DEBUG:SIFT: 25% of images processed (Keypoints)
2016-03-22 15:16:42,005 DEBUG:SIFT: 50% of images processed (Keypoints)
2016-03-22 15:16:43,447 DEBUG:SIFT: 75% of images processed (Keypoints)
2016-03-22 15:16:44,878 DEBUG:SIFT: Calculation of Dictonary with 50 Clusters
2016-03-22 15:16:48,861 DEBUG:SIFT: Assign words from Dictonary to each Image
2016-03-22 15:16:48,951 DEBUG:SIFT: 25% of images processed (Assignments)
2016-03-22 15:16:49,023 DEBUG:SIFT: 50% of images processed (Assignments)
2016-03-22 15:16:49,079 DEBUG:SIFT: 75% of images processed (Assignments)
2016-03-22 15:16:49,135 DEBUG:SIFT: Done in: 10.9459998608[s]
2016-03-22 15:16:49,135 DEBUG:SURF: Start
2016-03-22 15:16:49,137 DEBUG:SURF: Cluster=50, Norm=Distr
2016-03-22 15:16:49,138 DEBUG:SURF: Keypoints Calculation
2016-03-22 15:16:51,694 DEBUG:SURF: 25% of images processed (Keypoints)
2016-03-22 15:16:53,861 DEBUG:SURF: 50% of images processed (Keypoints)
2016-03-22 15:16:56,025 DEBUG:SURF: 75% of images processed (Keypoints)
2016-03-22 15:16:58,243 DEBUG:SURF: Calculation of Dictonary with 50 Clusters
2016-03-22 15:17:00,667 DEBUG:SURF: Assign words from Dictonary to each Image
2016-03-22 15:17:00,757 DEBUG:SURF: 25% of images processed (Assignments)
2016-03-22 15:17:00,829 DEBUG:SURF: 50% of images processed (Assignments)
2016-03-22 15:17:00,897 DEBUG:SURF: 75% of images processed (Assignments)
2016-03-22 15:17:00,986 DEBUG:SURF: Done in: 11.8489999771[s]
2016-03-22 15:17:00,986 DEBUG:HOG: Start
2016-03-22 15:17:00,986 DEBUG:HOG: CellDim=5, NbOrientations=8, Cluster=12, MaxIter=100, NbCores=1
2016-03-22 15:19:21,826 DEBUG:HOG: Done in: 140.839999914[s]
2016-03-22 15:19:21,828 DEBUG:Done: Features Extraction
2016-03-22 15:19:21,828 DEBUG:Start: Save Features to CSV Databases
2016-03-22 15:19:21,924 DEBUG:Done: Save Features to CSV Databases
Code/Niko/Results-FeatParaOpt/2016_03_22-FPO-CTMini-RGB-RGB_Bins-ClassTime.png

211 KiB

Code/Niko/Results-FeatParaOpt/2016_03_22-FPO-CTMini-RGB-RGB_Bins-FeatExtTime.png

213 KiB

2016-03-22 16:32:30,171 DEBUG:### Main Programm for Feature Parameter Optimisation
2016-03-22 16:32:30,171 DEBUG:### Optimisation - Feature:RGB Parameter:RGB_Bins from:2 to:30 in #calc:10
2016-03-22 16:32:30,173 DEBUG:### Start: Exportation of images from DB
2016-03-22 16:32:30,434 DEBUG:### Done: Exportation of Images from DB
2016-03-22 16:32:30,434 DEBUG:### Start: Feautre Optimisation
2016-03-22 16:32:30,434 DEBUG:### Start: FeatureExtraction Nr:1 from:10 with RGB_Bins=2 ###
2016-03-22 16:32:30,605 DEBUG:### Done: FeatureExtraction Nr:1 from:10 ###
2016-03-22 16:32:30,607 DEBUG:### Start: Classification Nr:1 from:10
2016-03-22 16:32:33,263 DEBUG:### Done: Classification Nr:1 from:10
2016-03-22 16:32:33,269 DEBUG:### Start: FeatureExtraction Nr:2 from:10 with RGB_Bins=5 ###
2016-03-22 16:32:33,440 DEBUG:### Done: FeatureExtraction Nr:2 from:10 ###
2016-03-22 16:32:33,441 DEBUG:### Start: Classification Nr:2 from:10
2016-03-22 16:32:36,063 DEBUG:### Done: Classification Nr:2 from:10
2016-03-22 16:32:36,068 DEBUG:### Start: FeatureExtraction Nr:3 from:10 with RGB_Bins=8 ###
2016-03-22 16:32:36,236 DEBUG:### Done: FeatureExtraction Nr:3 from:10 ###
2016-03-22 16:32:36,237 DEBUG:### Start: Classification Nr:3 from:10
2016-03-22 16:32:38,921 DEBUG:### Done: Classification Nr:3 from:10
2016-03-22 16:32:38,926 DEBUG:### Start: FeatureExtraction Nr:4 from:10 with RGB_Bins=11 ###
2016-03-22 16:32:39,098 DEBUG:### Done: FeatureExtraction Nr:4 from:10 ###
2016-03-22 16:32:39,099 DEBUG:### Start: Classification Nr:4 from:10
2016-03-22 16:32:41,841 DEBUG:### Done: Classification Nr:4 from:10
2016-03-22 16:32:41,845 DEBUG:### Start: FeatureExtraction Nr:5 from:10 with RGB_Bins=14 ###
2016-03-22 16:32:42,023 DEBUG:### Done: FeatureExtraction Nr:5 from:10 ###
2016-03-22 16:32:42,023 DEBUG:### Start: Classification Nr:5 from:10
2016-03-22 16:32:44,762 DEBUG:### Done: Classification Nr:5 from:10
2016-03-22 16:32:44,769 DEBUG:### Start: FeatureExtraction Nr:6 from:10 with RGB_Bins=18 ###
2016-03-22 16:32:44,950 DEBUG:### Done: FeatureExtraction Nr:6 from:10 ###
2016-03-22 16:32:44,950 DEBUG:### Start: Classification Nr:6 from:10
2016-03-22 16:32:47,818 DEBUG:### Done: Classification Nr:6 from:10
2016-03-22 16:32:47,822 DEBUG:### Start: FeatureExtraction Nr:7 from:10 with RGB_Bins=21 ###
2016-03-22 16:32:48,043 DEBUG:### Done: FeatureExtraction Nr:7 from:10 ###
2016-03-22 16:32:48,045 DEBUG:### Start: Classification Nr:7 from:10
2016-03-22 16:32:51,453 DEBUG:### Done: Classification Nr:7 from:10
2016-03-22 16:32:51,459 DEBUG:### Start: FeatureExtraction Nr:8 from:10 with RGB_Bins=24 ###
2016-03-22 16:32:51,677 DEBUG:### Done: FeatureExtraction Nr:8 from:10 ###
2016-03-22 16:32:51,677 DEBUG:### Start: Classification Nr:8 from:10
2016-03-22 16:32:54,657 DEBUG:### Done: Classification Nr:8 from:10
2016-03-22 16:32:54,661 DEBUG:### Start: FeatureExtraction Nr:9 from:10 with RGB_Bins=27 ###
2016-03-22 16:32:54,859 DEBUG:### Done: FeatureExtraction Nr:9 from:10 ###
2016-03-22 16:32:54,861 DEBUG:### Start: Classification Nr:9 from:10
2016-03-22 16:32:57,914 DEBUG:### Done: Classification Nr:9 from:10
2016-03-22 16:32:57,920 DEBUG:### Start: FeatureExtraction Nr:10 from:10 with RGB_Bins=30 ###
2016-03-22 16:32:58,135 DEBUG:### Done: FeatureExtraction Nr:10 from:10 ###
2016-03-22 16:32:58,138 DEBUG:### Start: Classification Nr:10 from:10
2016-03-22 16:33:01,158 DEBUG:### Done: Classification Nr:10 from:10
2016-03-22 16:33:01,164 DEBUG:### Done: Feautre Optimisation
2016-03-22 16:33:01,164 DEBUG:### Start: Exporting to CSV
2016-03-22 16:33:01,173 DEBUG:### Done: Exporting to CSV
2016-03-22 16:33:01,173 DEBUG:### Start: Plot Result
2016-03-22 16:33:03,180 DEBUG:### Done: Plot Result
Code/Niko/Results-FeatParaOpt/2016_03_22-FPO-CTMini-RGB-RGB_Bins-TotalTime.png

214 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment