google drive to github release

This commit is contained in:
Sefik Ilkin Serengil 2021-07-03 00:27:35 +03:00
parent c21b1f7287
commit a904d9007c
9 changed files with 120 additions and 104 deletions

View File

@ -10,7 +10,9 @@ import os
from pathlib import Path
import gdown
def loadModel():
#url = "https://drive.google.com/uc?id=1LVB3CdVejpmGHM28BpqqkbZP5hDEcdZY"
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/arcface_weights.h5'):
base_model = ResNet34()
inputs = base_model.inputs[0]
arcface_model = base_model.outputs[0]
@ -26,7 +28,6 @@ def loadModel():
home = str(Path.home())
url = "https://drive.google.com/uc?id=1LVB3CdVejpmGHM28BpqqkbZP5hDEcdZY"
file_name = "arcface_weights.h5"
output = home+'/.deepface/weights/'+file_name
@ -37,11 +38,7 @@ def loadModel():
#---------------------------------------
try:
model.load_weights(output)
except:
print("pre-trained weights could not be loaded.")
print("You might try to download it from the url ", url," and copy to ",output," manually")
return model

View File

@ -9,7 +9,9 @@ from tensorflow.keras.layers import Conv2D, Activation, Input, Add, MaxPooling2D
#-------------------------------------
def loadModel(url = 'https://drive.google.com/uc?id=1uRLtBCTQQAvHJ_KVrdbRJiCKxU8m5q2J'):
#url = 'https://drive.google.com/uc?id=1uRLtBCTQQAvHJ_KVrdbRJiCKxU8m5q2J'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/deepid_keras_weights.h5'):
myInput = Input(shape=(55, 47, 3))

View File

@ -530,7 +530,9 @@ def InceptionResNetV2():
return model
def loadModel(url = 'https://drive.google.com/uc?id=1971Xk5RwedbudGgTIrGAL4F7Aifu7id1'):
#url = 'https://drive.google.com/uc?id=1971Xk5RwedbudGgTIrGAL4F7Aifu7id1'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/facenet_weights.h5'):
model = InceptionResNetV2()
#-----------------------------------

View File

@ -13,7 +13,9 @@ from tensorflow.keras import backend as K
#---------------------------------------
def loadModel(url = 'https://drive.google.com/uc?id=1LSe1YCV1x-BfNnfb7DFZTNpv_Q9jITxn'):
#url = 'https://drive.google.com/uc?id=1LSe1YCV1x-BfNnfb7DFZTNpv_Q9jITxn'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/openface_weights.h5'):
myInput = Input(shape=(96, 96, 3))
x = ZeroPadding2D(padding=(3, 3), input_shape=(96, 96, 3))(myInput)

View File

@ -63,7 +63,9 @@ def baseModel():
return model
def loadModel(url = 'https://drive.google.com/uc?id=1CPSeum3HpopfomUEK1gybeuIVoeJT_Eo'):
#url = 'https://drive.google.com/uc?id=1CPSeum3HpopfomUEK1gybeuIVoeJT_Eo'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/vgg_face_weights.h5'):
model = baseModel()
@ -78,12 +80,7 @@ def loadModel(url = 'https://drive.google.com/uc?id=1CPSeum3HpopfomUEK1gybeuIVoe
#-----------------------------------
try:
model.load_weights(output)
except Exception as err:
print(str(err))
print("Pre-trained weight could not be loaded.")
print("You might try to download the pre-trained weights from the url ", url, " and copy it to the ", output)
#-----------------------------------

View File

@ -16,7 +16,9 @@ elif tf_version == 2:
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.layers import Convolution2D, Flatten, Activation
def loadModel(url = 'https://drive.google.com/uc?id=1YCox_4kJ-BYeXq27uUbasu--yz28zUMV'):
#url = 'https://drive.google.com/uc?id=1YCox_4kJ-BYeXq27uUbasu--yz28zUMV'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/age_model_weights.h5'):
model = VGGFace.baseModel()

View File

@ -15,7 +15,9 @@ elif tf_version == 2:
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, AveragePooling2D, Flatten, Dense, Dropout
def loadModel(url = 'https://drive.google.com/uc?id=13iUHHP3SlNg53qSuQZDdHDSDNdBP9nwy'):
#url = 'https://drive.google.com/uc?id=13iUHHP3SlNg53qSuQZDdHDSDNdBP9nwy'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/facial_expression_model_weights.h5'):
num_classes = 7
@ -52,15 +54,18 @@ def loadModel(url = 'https://drive.google.com/uc?id=13iUHHP3SlNg53qSuQZDdHDSDNdB
if os.path.isfile(home+'/.deepface/weights/facial_expression_model_weights.h5') != True:
print("facial_expression_model_weights.h5 will be downloaded...")
#TO-DO: upload weights to google drive
output = home+'/.deepface/weights/facial_expression_model_weights.h5'
gdown.download(url, output, quiet=False)
#zip
"""
#google drive source downloads zip
output = home+'/.deepface/weights/facial_expression_model_weights.zip'
gdown.download(url, output, quiet=False)
#unzip facial_expression_model_weights.zip
with zipfile.ZipFile(output, 'r') as zip_ref:
zip_ref.extractall(home+'/.deepface/weights/')
"""
model.load_weights(home+'/.deepface/weights/facial_expression_model_weights.h5')

View File

@ -14,7 +14,9 @@ elif tf_version == 2:
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.layers import Convolution2D, Flatten, Activation
def loadModel(url = 'https://drive.google.com/uc?id=1wUXRVlbsni2FN9-jkS_f4UTUrm1bRLyk'):
#url = 'https://drive.google.com/uc?id=1wUXRVlbsni2FN9-jkS_f4UTUrm1bRLyk'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/gender_model_weights.h5'):
model = VGGFace.baseModel()

View File

@ -16,7 +16,9 @@ elif tf_version == 2:
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.layers import Convolution2D, Flatten, Activation
def loadModel(url = 'https://drive.google.com/uc?id=1nz-WDhghGQBC4biwShQ9kYjvQMpO6smj'):
#url = 'https://drive.google.com/uc?id=1nz-WDhghGQBC4biwShQ9kYjvQMpO6smj'
def loadModel(url = 'https://github.com/serengil/deepface_models/releases/download/v1.0/race_model_single_batch.h5'):
model = VGGFace.baseModel()
@ -41,13 +43,18 @@ def loadModel(url = 'https://drive.google.com/uc?id=1nz-WDhghGQBC4biwShQ9kYjvQMp
if os.path.isfile(home+'/.deepface/weights/race_model_single_batch.h5') != True:
print("race_model_single_batch.h5 will be downloaded...")
#zip
output = home+'/.deepface/weights/race_model_single_batch.h5'
gdown.download(url, output, quiet=False)
"""
#google drive source downloads zip
output = home+'/.deepface/weights/race_model_single_batch.zip'
gdown.download(url, output, quiet=False)
#unzip race_model_single_batch.zip
with zipfile.ZipFile(output, 'r') as zip_ref:
zip_ref.extractall(home+'/.deepface/weights/')
"""
race_model.load_weights(home+'/.deepface/weights/race_model_single_batch.h5')