def classify_image(image_base64_data, file_path=None): imgs = get_cropped_image_if_2_eyes(file_path, image_base64_data) result = [] for img in imgs: scalled_raw_img = cv2.resize(img, (32, 32)) img_har = w2d(img, 'db1', 5) scalled_img_har = cv2.resize(img_har, (32, 32)) combined_img = np.vstack( (scalled_raw_img.reshape(32 * 32 * 3, 1), scalled_img_har.reshape(32 * 32, 1))) len_image_array = 32 * 32 * 3 + 32 * 32 final = combined_img.reshape(1, len_image_array).astype(float) result.append({ 'class': class_number_to_name(__model.predict(final)[0]), 'class_probability': np.around(__model.predict_proba(final) * 100, 2).tolist()[0], 'class_dictionary': __class_name_to_number }) return result
def classify_image(image_base64_data, file_path=None): imgs = cropped_face_2_eyes(file_path, image_base64_data) result = [] for img in imgs: scalled_raw_img = cv2.resize(img, (32, 32)) img_har = w2d(img, 'db1', 5) scalled_img_har = cv2.resize(img_har, (32, 32)) combined_img = np.vstack( (scalled_raw_img.reshape(32 * 32 * 3, 1), scalled_img_har.reshape(32 * 32, 1))) len_img_array = 32 * 32 * 3 + 32 * 32 final = combined_img.reshape(1, len_img_array).astype(float) probablity = np.round(__model.predict_proba(final) * 100, 2).tolist()[0] c_name = [value for key, value in __class_number_to_name.items()] probablity_name = [] for name, probab in zip(c_name, probablity): probablity_name.append(str(name) + ':' + (str(probab))) result.append({ 'class': class_number_to_name(__model.predict(final)[0]), 'class_probablity': np.around(__model.predict_proba(final) * 100, 2).tolist()[0], 'class_dictionary': __class_name_to_number, }) return result
def v_stack(bs4): imgs = get_crop(bs4) result = [] for img in imgs: scalled_raw_img = cv2.resize(img, (32, 32)) img_har = w2d(img, 'db1', 5) scalled_img_har = cv2.resize(img_har, (32, 32)) combined_img = np.vstack( (scalled_raw_img.reshape(32 * 32 * 3, 1), scalled_img_har.reshape(32 * 32, 1))) len_image_array = 32 * 32 * 3 + 32 * 32 final = combined_img.reshape(1, len_image_array).astype(float) result.append(__model.predict(final)[0]) return result