From a806d0aa0400f01e88b836a3d0d6815c487e1968 Mon Sep 17 00:00:00 2001 From: Kevin Allen Date: Sat, 28 Apr 2018 16:48:04 -0400 Subject: [PATCH] SCAN THE CODE: refactor classifier using base class main function --- .../{stc_datasets.yaml => stc/datasets.yaml} | 0 .../{stc_labels.json => stc/labels.json} | 0 .../{stc_colors.csv => stc/training.csv} | 0 .../scan_the_code_classifier.py | 20 ++++++------------- 4 files changed, 6 insertions(+), 14 deletions(-) rename perception/navigator_vision/config/{stc_datasets.yaml => stc/datasets.yaml} (100%) rename perception/navigator_vision/config/{stc_labels.json => stc/labels.json} (100%) rename perception/navigator_vision/config/{stc_colors.csv => stc/training.csv} (100%) diff --git a/perception/navigator_vision/config/stc_datasets.yaml b/perception/navigator_vision/config/stc/datasets.yaml similarity index 100% rename from perception/navigator_vision/config/stc_datasets.yaml rename to perception/navigator_vision/config/stc/datasets.yaml diff --git a/perception/navigator_vision/config/stc_labels.json b/perception/navigator_vision/config/stc/labels.json similarity index 100% rename from perception/navigator_vision/config/stc_labels.json rename to perception/navigator_vision/config/stc/labels.json diff --git a/perception/navigator_vision/config/stc_colors.csv b/perception/navigator_vision/config/stc/training.csv similarity index 100% rename from perception/navigator_vision/config/stc_colors.csv rename to perception/navigator_vision/config/stc/training.csv diff --git a/perception/navigator_vision/navigator_vision/scan_the_code_classifier.py b/perception/navigator_vision/navigator_vision/scan_the_code_classifier.py index dfe2683d..34f223ab 100755 --- a/perception/navigator_vision/navigator_vision/scan_the_code_classifier.py +++ b/perception/navigator_vision/navigator_vision/scan_the_code_classifier.py @@ -10,24 +10,16 @@ class ScanTheCodeClassifier(GaussianColorClassifier): def __init__(self): rospack = RosPack() path = rospack.get_path('navigator_vision') - self.features_file = os.path.join(path, 'config/stc_colors.csv') - super(ScanTheCodeClassifier, self).__init__(ScanTheCodeClassifier.CLASSES) - - def train_from_csv(self): - return super(ScanTheCodeClassifier, self).train_from_csv(self.features_file) - - def save_csv(self, features, classes): - return super(ScanTheCodeClassifier, self).save_csv(features, classes, filename=self.features_file) + training_file = os.path.join(path, 'config/stc/training.csv') + labelfile = os.path.join(path, 'config/stc/labels.json') + super(ScanTheCodeClassifier, self).__init__(ScanTheCodeClassifier.CLASSES, + training_file=training_file, labelfile=labelfile) if __name__ == '__main__': ''' - When run as an executable, saves the training features to a csv file - 2 arguemnts: labelbox.io labelfile, and image directory + Can be run as executable to extract features or check accuracy score ''' import sys - labelfile = sys.argv[1] - image_dir = sys.argv[2] s = ScanTheCodeClassifier() - features, classes = s.extract_labels(labelfile, image_dir) - s.save_csv(features, classes) + s.main(sys.argv[1:])