<jupyter_start><jupyter_text>Loading Model<jupyter_code>from keras.models import load_model
import tensorflow as tf
import cv2
from matplotlib import pyplot as plt
import numpy as np
def normalize_input(x, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)):
        # x should be RGB with range [0, 255]
        return ((x / 255) - mean)  / std
model = load_model('models/parser_net.h5', custom_objects={'tf': tf})
#model = load_model('models/parser_net.h5')
#!ls -ltr images/test/test0.jpg
im = cv2.imread("images/test/test1.jpg")[..., ::-1]
print("Fists:")
print(im.shape)
face=im
orig_h, orig_w = face.shape[:2]
inp = cv2.resize(face, (512,512))
inp = normalize_input(inp)
inp = inp[None, ...]
print("second:")
print(inp.shape)
out = model.predict([inp])[0]
#type(out)
#print(out.shape)
parsing_map = out.argmax(axis=-1)
print(parsing_map.shape)
parsing_map = cv2.resize(
  parsing_map.astype(np.uint8), 
  (orig_w, orig_h), 
  interpolation=cv2.INTER_NEAREST)
#print(parsing_map[:,:,:10])
print(parsing_map.shape)
plt.imshow(parsing_map)
plt.figure(figsize=(15,4))
plt.subplot(1,2,1)
#plt.title("Left eye")
plt.imshow(im)

plt.subplot(1,2,2)
plt.imshow(parsing_map)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1778886118038238, 'fraction_numerical': 0.051537822111388194, 'mean_word_length': 5.579234972677596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '345623', 'license': 'MIT', 'n_tokens_mistral': 544, 'n_tokens_neox': 504, 'n_words': 92, 'path': 'Jupyter/FaceParserH5-Copy1.ipynb', 'repo_name': 'lveagithub/misc_python', 'size': '1203'}