Spaces:
Running
Running
Justin Grammens
commited on
Commit
•
6955362
1
Parent(s):
f74f0b2
updated
Browse files
app.py
CHANGED
@@ -78,6 +78,19 @@ def classify_eye_shape(image):
|
|
78 |
formatted_output = {item['label']: item['score'] for item in output}
|
79 |
|
80 |
return formatted_output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
|
83 |
def classify_image_with_multiple_models(image):
|
@@ -87,8 +100,9 @@ def classify_image_with_multiple_models(image):
|
|
87 |
acne_results = classify_acne_type(image)
|
88 |
hair_color_results = classify_hair_color(image)
|
89 |
eye_shape = classify_eye_shape(image)
|
|
|
90 |
|
91 |
-
return face_shape_result, age_result, skin_type_result, acne_results, hair_color_results, eye_shape
|
92 |
|
93 |
|
94 |
# Create the Gradio interface
|
@@ -101,7 +115,8 @@ demo = gr.Interface(
|
|
101 |
gr.Label(num_top_classes=3, label="Skin Type"),
|
102 |
gr.Label(num_top_classes=5, label="Acne Type"),
|
103 |
gr.Label(num_top_classes=5, label="Hair Color"),
|
104 |
-
gr.Label(num_top_classes=4, label="Eye Shape")
|
|
|
105 |
],
|
106 |
title="Multiple Model Classification",
|
107 |
description="Upload an image to classify the face using mutiple classification models"
|
|
|
78 |
formatted_output = {item['label']: item['score'] for item in output}
|
79 |
|
80 |
return formatted_output
|
81 |
+
|
82 |
+
def classify_eye_color(image):
|
83 |
+
|
84 |
+
pipe = pipeline("image-classification", model="justingrammens/eye-color")
|
85 |
+
|
86 |
+
# Run the pipeline on the uploaded image
|
87 |
+
output = pipe(image)
|
88 |
+
|
89 |
+
print("Pipeline output for eye color:", output)
|
90 |
+
# Format the output to be compatible with gr.outputs.Label
|
91 |
+
formatted_output = {item['label']: item['score'] for item in output}
|
92 |
+
|
93 |
+
return formatted_output
|
94 |
|
95 |
|
96 |
def classify_image_with_multiple_models(image):
|
|
|
100 |
acne_results = classify_acne_type(image)
|
101 |
hair_color_results = classify_hair_color(image)
|
102 |
eye_shape = classify_eye_shape(image)
|
103 |
+
eye_color = classify_eye_color(image)
|
104 |
|
105 |
+
return face_shape_result, age_result, skin_type_result, acne_results, hair_color_results, eye_shape, eye_color
|
106 |
|
107 |
|
108 |
# Create the Gradio interface
|
|
|
115 |
gr.Label(num_top_classes=3, label="Skin Type"),
|
116 |
gr.Label(num_top_classes=5, label="Acne Type"),
|
117 |
gr.Label(num_top_classes=5, label="Hair Color"),
|
118 |
+
gr.Label(num_top_classes=4, label="Eye Shape"),
|
119 |
+
gr.Label(num_top_classes=5, label="Eye Color"),
|
120 |
],
|
121 |
title="Multiple Model Classification",
|
122 |
description="Upload an image to classify the face using mutiple classification models"
|