def download_imagenet(self): """ Download pre-trained weights for the specified backbone name. This name is in the format {backbone}_weights_tf_dim_ordering_tf_kernels_notop where backbone is the densenet + number of layers (e.g. densenet121). For more info check the explanation from the keras densenet script itself: https://github.com/keras-team/keras/blob/master/keras/applications/densenet.py """ origin = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/' file_name = '{}_weights_tf_dim_ordering_tf_kernels_notop.h5' # load weights if keras.backend.image_data_format() == 'channels_first': raise ValueError('Weights for "channels_first" format are not available.') weights_url = origin + file_name.format(self.backbone) return get_file(file_name.format(self.backbone), weights_url, cache_subdir='models')
def download_imagenet(backbone, weights_url=None): """ Download pre-trained weights for the specified backbone name. This name is in the format {backbone}_weights_tf_dim_ordering_tf_kernels_notop where backbone is the densenet + number of layers (e.g. densenet121). For more info check the explanation from the keras densenet script itself: https://github.com/keras-team/keras/blob/master/keras/applications/densenet.py # Arguments backbone : Backbone name. """ # load weights if keras.backend.image_data_format() == 'channels_first': raise ValueError( 'Weights for "channels_first" format are not available.') if weights_url is None: weights_url = WEIGHT_PATH.format(backbone) split_url = weights_url.split("/") print("the split url is " + split_url[len(split_url) - 1]) weights_path = get_file(split_url[len(split_url) - 1], weights_url, cache_subdir='models') return weights_path