add smile detection
This commit is contained in:
29
Class/detection/utils/preprocessor.py
Normal file
29
Class/detection/utils/preprocessor.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
from imageio import imread
|
||||
|
||||
def preprocess_input(x, v2=True):
|
||||
x = x.astype('float32')
|
||||
x = x / 255.0
|
||||
if v2:
|
||||
x = x - 0.5
|
||||
x = x * 2.0
|
||||
return x
|
||||
|
||||
|
||||
def _imread(image_name):
|
||||
return imread(image_name)
|
||||
|
||||
|
||||
def _imresize(image_array, size):
|
||||
return np.array(Image.fromarray(image_array).resize(size))
|
||||
# return imresize(image_array, size)
|
||||
|
||||
|
||||
def to_categorical(integer_classes, num_classes=2):
|
||||
integer_classes = np.asarray(integer_classes, dtype='int')
|
||||
num_samples = integer_classes.shape[0]
|
||||
categorical = np.zeros((num_samples, num_classes))
|
||||
categorical[np.arange(num_samples), integer_classes] = 1
|
||||
return categorical
|
||||
Reference in New Issue
Block a user