示例#1
0
 def test_results_file_needs_to_be_a_csv_file(self, mock_isfile):
     params = [
         'Predictions.py', '/path/to/resnet50.h5', '/path/to/dir/images/',
         '/path/to/dir/save_images', 'results.txt'
     ]
     mock_isfile.return_value = True
     self.assertTrue('Name of the file needs to end with .csv!' in
                     validation_util.get_errors(params))
示例#2
0
 def test_needs_to_be_h5_file(self, mock_isfile):
     mock_isfile.return_value = True
     params = [
         'Predictions.py', '/path/to/file/resnet50.txt',
         '/path/to/dir/images/', '/path/to/dir/save_images', 'results.csv'
     ]
     self.assertTrue(
         'File should be a .h5 file!' in validation_util.get_errors(params))
示例#3
0
 def test_result_file_cant_exists_before_running_predictions(
         self, mock_isfile):
     mock_isfile.return_value = True
     params = [
         'Predictions.py', '/path/to/resnet50.h5', '/path/to/dir/images/',
         '/path/to/dir/save_images', 'results.csv'
     ]
     self.assertTrue(params[4] + " file of this name already exists!" in
                     validation_util.get_errors(params))
示例#4
0
 def test_path_to_trained_model_needs_to_be_correct(self, mock_isfile):
     mock_isfile.return_value = False
     params = [
         'Predictions.py', '/wrong/path/to/resnet50.h5',
         '/path/to/dir/images/', '/path/to/dir/save_images', 'results.csv'
     ]
     self.assertTrue(
         params[1] +
         ' not a correct path!' in validation_util.get_errors(params))
示例#5
0
 def test_path_to_image_directory_needs_to_be_correct(self, mock_isdir):
     mock_isdir.return_value = False
     params = [
         'Predictions.py', '/path/to/resnet50.h5',
         '/path/to/wrong/dir/images/', '/path/to/dir/save_images',
         'results.csv'
     ]
     self.assertTrue(
         params[2] +
         ' not a correct directory!' in validation_util.get_errors(params))
示例#6
0
def main(arg):
    # set the modified tf session as backend in keras
    keras.backend.tensorflow_backend.set_session(get_session())

    # make image save path if it doesn't exist
    if arg[3] is not None and not os.path.exists(arg[3]):
        os.makedirs(arg[3])

    errors = get_errors(arg)
    # check that there are no errors in the given arguments
    if not errors:
        [a, trained_model_path, read_image_directory_path, save_image_directory_path, predictions_csv] = arg
        save_prediction_to_csv(trained_model_path, read_image_directory_path, save_image_directory_path, predictions_csv)
    else:
        print('Given arguments are wrong:')
    for error in errors: print(error)
示例#7
0
 def test_cant_have_too_few_arguments(self):
     params = ['param1', 'param2', 'param3']
     self.assertTrue(
         "Too few arguments!" in validation_util.get_errors(params))
示例#8
0
 def test_cant_have_too_many_arguments(self):
     params = ['param1', 'param2', 'param3', 'param4', 'param5', 'param6']
     self.assertTrue(
         "Too many arguments!" in validation_util.get_errors(params))