Views
No views yet
.h5)(128, 128, 3)128x128 pixels[0, 1]0: Mask1: No Maskargmax(output)1import cv2
2import numpy as np
3from keras.models import load_model
4
5# Load model
6model = load_model("mask_detection_model.h5")
7
8# Load image
9image = cv2.imread("face.jpg")
10image_resized = cv2.resize(image, (128, 128))
11image_scaled = image_resized.astype("float32") / 255.0
12image_input = np.expand_dims(image_scaled, axis=0)
13
14# Predict
15prediction = model.predict(image_input)
16pred_label = np.argmax(prediction, axis=1)[0]
17
18if pred_label == 0:
19 print("Mask 😷✅")
20else:
21 print("No Mask ❌")