Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added data/facebank/.gitignore
Empty file.
41 changes: 41 additions & 0 deletions mtcnn_pytorch/src/get_nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
from collections import OrderedDict
import numpy as np

def get_np_version_number():
ver_str = np.__version__
ver_list = ver_str.split('.')
ver_num = int(ver_list[0]) * 10000 + int(ver_list[1])*100 + int(ver_list[2])
return ver_num

class Flatten(nn.Module):

Expand Down Expand Up @@ -51,8 +56,19 @@ def __init__(self):

self.conv4_1 = nn.Conv2d(32, 2, 1, 1)
self.conv4_2 = nn.Conv2d(32, 4, 1, 1)
np_ver = get_np_version_number()
if np_ver >= 11602: # from np 1.16.2, allow_pickle default set to False
# save np.load
np_load_old = np.load
# modify the default parameters of np.load
np.load = lambda *a,**k: np_load_old(*a, allow_pickle=True, **k)

weights = np.load('mtcnn_pytorch/src/weights/pnet.npy')[()]

if np_ver >= 11602: # from np 1.16.2, allow_pickle default set to False
# restore np.load for future normal usage
np.load = np_load_old

for n, p in self.named_parameters():
p.data = torch.FloatTensor(weights[n])

Expand Down Expand Up @@ -96,8 +112,19 @@ def __init__(self):

self.conv5_1 = nn.Linear(128, 2)
self.conv5_2 = nn.Linear(128, 4)
np_ver = get_np_version_number()
if np_ver >= 11602: # from np 1.16.2, allow_pickle default set to False
# save np.load
np_load_old = np.load
# modify the default parameters of np.load
np.load = lambda *a,**k: np_load_old(*a, allow_pickle=True, **k)

weights = np.load('mtcnn_pytorch/src/weights/rnet.npy')[()]

if np_ver >= 11602: # from np 1.16.2, allow_pickle default set to False
# restore np.load for future normal usage
np.load = np_load_old

for n, p in self.named_parameters():
p.data = torch.FloatTensor(weights[n])

Expand Down Expand Up @@ -148,7 +175,21 @@ def __init__(self):
self.conv6_2 = nn.Linear(256, 4)
self.conv6_3 = nn.Linear(256, 10)

np_ver = get_np_version_number()
if np_ver >= 11602: # from np 1.16.2, allow_pickle default set to False
# save np.load
np_load_old = np.load
# modify the default parameters of np.load
np.load = lambda *a,**k: np_load_old(*a, allow_pickle=True, **k)

weights = np.load('mtcnn_pytorch/src/weights/onet.npy')[()]


if np_ver >= 11602: # from np 1.16.2, allow_pickle default set to False
# restore np.load for future normal usage
np.load = np_load_old


for n, p in self.named_parameters():
p.data = torch.FloatTensor(weights[n])

Expand Down