if (len(commonName) == 0): print("Warning: empty result for latin name {}".format(latinName)) commonName = latinName return commonName #%% Create the model(s) assert os.path.isfile(CLASSIFICATION_MODEL_PATH) if DETECTION_MODEL_PATH != None: assert os.path.isfile(DETECTION_MODEL_PATH) print("Loading model") model = speciesapi.DetectionClassificationAPI(CLASSIFICATION_MODEL_PATH, DETECTION_MODEL_PATH, IMAGE_SIZES, USE_GPU) print("Finished loading model") #%% Prepare the list of images and query names queries = None if isinstance(IMAGES_TO_CLASSIFY, str) and os.path.isdir(IMAGES_TO_CLASSIFY): images = glob.glob(os.path.join(IMAGES_TO_CLASSIFY, '**/*.*'), recursive=True) images = [fn for fn in images if os.path.isfile(fn)] queries = [os.path.basename(os.path.dirname(fn)) for fn in images] print('Loaded a folder of {} images'.format(len(images)))
if (len(common_name) == 0): print("Warning: empty result for latin name {}".format(latin_name)) common_name = latin_name return common_name #%% Create the model(s) assert os.path.isfile(classification_model_path) if detection_model_path != None: assert os.path.isfile(detection_model_path) print("Loading model") model = speciesapi.DetectionClassificationAPI(classification_model_path, detection_model_path, image_sizes, use_gpu) print("Finished loading model") #%% Prepare the list of images and query names queries = None if isinstance(images_to_classify,str) and os.path.isdir(images_to_classify): images = glob.glob(os.path.join(images_to_classify,'**/*.*'), recursive=True) images = [fn for fn in images if os.path.isfile(fn)] queries = [os.path.basename(os.path.dirname(fn)) for fn in images] print('Loaded a folder of {} images'.format(len(images))) elif isinstance(images_to_classify,str) and os.path.isfile(images_to_classify):