This commit is contained in:
iperov 2019-02-22 23:25:01 +04:00
parent daebe10ca7
commit 281787ac3e

View file

@ -250,25 +250,25 @@ def umeyama(src, dst, estimate_scale):
return T
mean_face_x = np.array([
0.000213256, 0.0752622, 0.18113, 0.29077, 0.393397, 0.586856, 0.689483, 0.799124,
0.904991, 0.98004, 0.490127, 0.490127, 0.490127, 0.490127, 0.36688, 0.426036,
0.490127, 0.554217, 0.613373, 0.121737, 0.187122, 0.265825, 0.334606, 0.260918,
0.182743, 0.645647, 0.714428, 0.793132, 0.858516, 0.79751, 0.719335, 0.254149,
0.340985, 0.428858, 0.490127, 0.551395, 0.639268, 0.726104, 0.642159, 0.556721,
0.490127, 0.423532, 0.338094, 0.290379, 0.428096, 0.490127, 0.552157, 0.689874,
0.553364, 0.490127, 0.42689 ])
mean_face_y = np.array([
0.106454, 0.038915, 0.0187482, 0.0344891, 0.0773906, 0.0773906, 0.0344891,
0.0187482, 0.038915, 0.106454, 0.203352, 0.307009, 0.409805, 0.515625, 0.587326,
0.609345, 0.628106, 0.609345, 0.587326, 0.216423, 0.178758, 0.179852, 0.231733,
0.245099, 0.244077, 0.231733, 0.179852, 0.178758, 0.216423, 0.244077, 0.245099,
0.780233, 0.745405, 0.727388, 0.742578, 0.727388, 0.745405, 0.780233, 0.864805,
0.902192, 0.909281, 0.902192, 0.864805, 0.784792, 0.778746, 0.785343, 0.778746,
0.784792, 0.824182, 0.831803, 0.824182 ])
landmarks_2D = np.stack( [ mean_face_x, mean_face_y ], axis=1 )
#mean_face_x = np.array([
#0.000213256, 0.0752622, 0.18113, 0.29077, 0.393397, 0.586856, 0.689483, 0.799124,
#0.904991, 0.98004, 0.490127, 0.490127, 0.490127, 0.490127, 0.36688, 0.426036,
#0.490127, 0.554217, 0.613373, 0.121737, 0.187122, 0.265825, 0.334606, 0.260918,
#0.182743, 0.645647, 0.714428, 0.793132, 0.858516, 0.79751, 0.719335, 0.254149,
#0.340985, 0.428858, 0.490127, 0.551395, 0.639268, 0.726104, 0.642159, 0.556721,
#0.490127, 0.423532, 0.338094, 0.290379, 0.428096, 0.490127, 0.552157, 0.689874,
#0.553364, 0.490127, 0.42689 ])
#
#mean_face_y = np.array([
#0.106454, 0.038915, 0.0187482, 0.0344891, 0.0773906, 0.0773906, 0.0344891,
#0.0187482, 0.038915, 0.106454, 0.203352, 0.307009, 0.409805, 0.515625, 0.587326,
#0.609345, 0.628106, 0.609345, 0.587326, 0.216423, 0.178758, 0.179852, 0.231733,
#0.245099, 0.244077, 0.231733, 0.179852, 0.178758, 0.216423, 0.244077, 0.245099,
#0.780233, 0.745405, 0.727388, 0.742578, 0.727388, 0.745405, 0.780233, 0.864805,
#0.902192, 0.909281, 0.902192, 0.864805, 0.784792, 0.778746, 0.785343, 0.778746,
#0.784792, 0.824182, 0.831803, 0.824182 ])
#
#landmarks_2D = np.stack( [ mean_face_x, mean_face_y ], axis=1 )
def get_transform_mat (image_landmarks, output_size, scale=1.0):
if not isinstance(image_landmarks, np.ndarray):
@ -306,11 +306,7 @@ def get_transform_mat (image_landmarks, output_size, scale=1.0):
import mathlib
def main():
def f ( *args, asd=True, **kwargs ):
import code
code.interact(local=dict(globals(), **locals()))
f( 1, asd=True, bg=0)
from nnlib import nnlib
exec( nnlib.import_all( device_config=nnlib.device.Config() ), locals(), globals() )
@ -1357,6 +1353,64 @@ O[i0, i1, i2, i3: (1 + 1 - 1)/1, (64 + 1 - 1)/1, (64 + 2 - 1)/2, (1 + 1 - 1)/1]
if __name__ == "__main__":
#import os
#os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"
#os.environ["PLAIDML_DEVICE_IDS"] = "opencl_nvidia_geforce_gtx_1060_6gb.0"
#import keras
#import numpy as np
#import cv2
#import time
#K = keras.backend
#
#
#
#PNet_Input = keras.layers.Input ( (None, None,3) )
#x = PNet_Input
#x = keras.layers.Conv2D (10, kernel_size=(3,3), strides=(1,1), padding='valid', name="conv1")(x)
#x = keras.layers.PReLU (shared_axes=[1,2], name="PReLU1" )(x)
#x = keras.layers.MaxPooling2D( pool_size=(2,2), strides=(2,2), padding='same' ) (x)
#x = keras.layers.Conv2D (16, kernel_size=(3,3), strides=(1,1), padding='valid', name="conv2")(x)
#x = keras.layers.PReLU (shared_axes=[1,2], name="PReLU2" )(x)
#x = keras.layers.Conv2D (32, kernel_size=(3,3), strides=(1,1), padding='valid', name="conv3")(x)
#x = keras.layers.PReLU (shared_axes=[1,2], name="PReLU3" )(x)
#prob = keras.layers.Conv2D (2, kernel_size=(1,1), strides=(1,1), padding='valid', name="conv41")(x)
#x = keras.layers.Conv2D (4, kernel_size=(1,1), strides=(1,1), padding='valid', name="conv42")(x)
#
#pnet = K.function ([PNet_Input], [x,prob] )
#
#img = np.random.uniform ( size=(1920,1920,3) )
#minsize=80
#factor=0.95
#factor_count=0
#h=img.shape[0]
#w=img.shape[1]
#
#minl=np.amin([h, w])
#m=12.0/minsize
#minl=minl*m
## create scale pyramid
#scales=[]
#while minl>=12:
# scales += [m*np.power(factor, factor_count)]
# minl = minl*factor
# factor_count += 1
# # first stage
# for scale in scales:
# hs=int(np.ceil(h*scale))
# ws=int(np.ceil(w*scale))
# im_data = cv2.resize(img, (ws, hs), interpolation=cv2.INTER_LINEAR)
# im_data = (im_data-127.5)*0.0078125
# img_x = np.expand_dims(im_data, 0)
# img_x = np.transpose(img_x, (0,2,1,3))
# t = time.time()
# out = pnet([img_x])
# t = time.time() - t
# print (img_x.shape, t)
#
#import code
#code.interact(local=dict(globals(), **locals()))
#os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"
#os.environ["PLAIDML_DEVICE_IDS"] = "opencl_nvidia_geforce_gtx_1060_6gb.0"
#import keras