Update app.py
Browse files
app.py
CHANGED
|
@@ -12,22 +12,16 @@ face_mesh = mp_face_mesh.FaceMesh(static_image_mode=True, max_num_faces=1, refin
|
|
| 12 |
|
| 13 |
def extract_features(image, landmarks):
|
| 14 |
mean_intensity = np.mean(image)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
cx1, cy1 = int(left_cheek.x * w), int(left_cheek.y * h)
|
| 26 |
-
cx2, cy2 = int(right_cheek.x * w), int(right_cheek.y * h)
|
| 27 |
-
skin_tone1 = np.mean(image[cy1-5:cy1+5, cx1-5:cx1+5]) if 5 <= cy1 < h-5 and 5 <= cx1 < w-5 else 0
|
| 28 |
-
skin_tone2 = np.mean(image[cy2-5:cy2+5, cx2-5:cx2+5]) if 5 <= cy2 < h-5 and 5 <= cx2 < w-5 else 0
|
| 29 |
-
avg_skin_tone = (skin_tone1 + skin_tone2) / 2
|
| 30 |
-
return [mean_intensity, bbox_width, bbox_height, eye_dist, nose_len, jaw_width, avg_skin_tone]
|
| 31 |
|
| 32 |
def train_model(output_range):
|
| 33 |
X = [[random.uniform(0.2, 0.5), random.uniform(0.05, 0.2), random.uniform(0.05, 0.2),
|
|
|
|
| 12 |
|
| 13 |
def extract_features(image, landmarks):
|
| 14 |
mean_intensity = np.mean(image)
|
| 15 |
+
red_channel = image[:, :, 2]
|
| 16 |
+
green_channel = image[:, :, 1]
|
| 17 |
+
blue_channel = image[:, :, 0]
|
| 18 |
+
total_pixels = image.shape[0] * image.shape[1]
|
| 19 |
+
|
| 20 |
+
red_percent = 100 * np.sum(red_channel > green_channel) / total_pixels
|
| 21 |
+
green_percent = 100 * np.sum(green_channel > red_channel) / total_pixels
|
| 22 |
+
blue_percent = 100 * np.sum(blue_channel > red_channel) / total_pixels
|
| 23 |
+
|
| 24 |
+
return [red_percent, green_percent, blue_percent]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def train_model(output_range):
|
| 27 |
X = [[random.uniform(0.2, 0.5), random.uniform(0.05, 0.2), random.uniform(0.05, 0.2),
|