Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -11,7 +11,8 @@ PY_MODULES = {
|
|
| 11 |
"dark_circles.py": "DarkCircleDetector",
|
| 12 |
"inflammation.py": "RednessDetector",
|
| 13 |
"texture.py": "TextureDetector",
|
| 14 |
-
"skin_tone.py": "SkinToneDetector"
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
def dynamic_import(module_path, class_name):
|
|
@@ -54,6 +55,14 @@ def analyze_skin(image: np.ndarray, analysis_type: str) -> np.ndarray:
|
|
| 54 |
detector = detector_classes["SkinToneDetector"](image)
|
| 55 |
result = detector.predict_json()
|
| 56 |
output = result.get("output_image")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
return output
|
| 58 |
|
| 59 |
# --- Gradio Interface code ---
|
|
@@ -62,7 +71,7 @@ app = gr.Interface(
|
|
| 62 |
inputs=[
|
| 63 |
gr.Image(type="numpy", label="Upload your face image"),
|
| 64 |
gr.Radio(
|
| 65 |
-
["dark circles", "redness", "texture", "skin tone"],
|
| 66 |
label="Select Skin Analysis Type"
|
| 67 |
),
|
| 68 |
],
|
|
|
|
| 11 |
"dark_circles.py": "DarkCircleDetector",
|
| 12 |
"inflammation.py": "RednessDetector",
|
| 13 |
"texture.py": "TextureDetector",
|
| 14 |
+
"skin_tone.py": "SkinToneDetector",
|
| 15 |
+
"oiliness.py": "OilinessDetector" # Added oiliness module
|
| 16 |
}
|
| 17 |
|
| 18 |
def dynamic_import(module_path, class_name):
|
|
|
|
| 55 |
detector = detector_classes["SkinToneDetector"](image)
|
| 56 |
result = detector.predict_json()
|
| 57 |
output = result.get("output_image")
|
| 58 |
+
elif analysis_type == "oiliness":
|
| 59 |
+
detector = detector_classes["OilinessDetector"](image)
|
| 60 |
+
result = detector.predict_json()
|
| 61 |
+
if result.get("detected"):
|
| 62 |
+
output = result.get("overlay_image")
|
| 63 |
+
print(f"Oiliness scores: {result.get('scores')}")
|
| 64 |
+
else:
|
| 65 |
+
print(f"Oiliness detection error: {result.get('error')}")
|
| 66 |
return output
|
| 67 |
|
| 68 |
# --- Gradio Interface code ---
|
|
|
|
| 71 |
inputs=[
|
| 72 |
gr.Image(type="numpy", label="Upload your face image"),
|
| 73 |
gr.Radio(
|
| 74 |
+
["dark circles", "redness", "texture", "skin tone", "oiliness"], # Added oiliness option
|
| 75 |
label="Select Skin Analysis Type"
|
| 76 |
),
|
| 77 |
],
|