Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -554,24 +554,24 @@ def process_image(image_rgb, procedure, intensity):
|
|
| 554 |
|
| 555 |
sym_arrow = "+" if sym_delta > 0 else ""
|
| 556 |
info_lines = [
|
| 557 |
-
|
| 558 |
f" Type: {procedure.replace('_', ' ').title()}",
|
| 559 |
f" Intensity: {intensity:.0f}%",
|
| 560 |
f" Description: {PROCEDURE_INFO.get(procedure, '')}",
|
| 561 |
-
|
| 562 |
-
|
| 563 |
f" Landmarks: {len(face.landmarks)} points",
|
| 564 |
f" Confidence: {face.confidence:.2f}",
|
| 565 |
f" Avg shift: {displacement:.1f} px",
|
| 566 |
-
|
| 567 |
-
|
| 568 |
f" Before: {pre_overall:.1f} / 100",
|
| 569 |
f" After: {post_overall:.1f} / 100",
|
| 570 |
f" Change: {sym_arrow}{sym_delta:.1f}",
|
| 571 |
-
|
| 572 |
-
|
| 573 |
f" Time: {elapsed:.2f}s",
|
| 574 |
-
|
| 575 |
]
|
| 576 |
info = "\n".join(info_lines)
|
| 577 |
return wireframe_rgb, mask_vis, composited_rgb, image_rgb_512, info
|
|
@@ -678,6 +678,8 @@ with gr.Blocks(
|
|
| 678 |
<p style="font-size:0.85em; color:#aab;">
|
| 679 |
Powered by MediaPipe 478-point face mesh, thin-plate spline warping, and
|
| 680 |
procedure-specific anatomical displacement models. Runs entirely on CPU.
|
|
|
|
|
|
|
| 681 |
</p>
|
| 682 |
<div class="link-bar">
|
| 683 |
<a href="{GITHUB_URL}">GitHub</a>
|
|
@@ -701,8 +703,7 @@ with gr.Blocks(
|
|
| 701 |
)
|
| 702 |
# Show a brief description for each procedure
|
| 703 |
_proc_desc_md = " | ".join(
|
| 704 |
-
f"**{k.replace('_', ' ').title()}**: {v}"
|
| 705 |
-
for k, v in PROCEDURE_INFO.items()
|
| 706 |
)
|
| 707 |
gr.Markdown(
|
| 708 |
f"<div style='font-size:0.82em;color:#666;line-height:1.5;'>"
|
|
@@ -741,12 +742,18 @@ with gr.Blocks(
|
|
| 741 |
|
| 742 |
with gr.Accordion("Photo Tips for Best Results", open=False):
|
| 743 |
gr.Markdown(
|
| 744 |
-
"- **Front-facing**: Use a straight-on frontal photo,
|
| 745 |
-
"
|
| 746 |
-
"- **
|
| 747 |
-
"
|
| 748 |
-
"- **
|
| 749 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 750 |
)
|
| 751 |
|
| 752 |
outputs = [out_wireframe, out_mask, out_result, out_original, info_box]
|
|
|
|
| 554 |
|
| 555 |
sym_arrow = "+" if sym_delta > 0 else ""
|
| 556 |
info_lines = [
|
| 557 |
+
"--- Procedure ---",
|
| 558 |
f" Type: {procedure.replace('_', ' ').title()}",
|
| 559 |
f" Intensity: {intensity:.0f}%",
|
| 560 |
f" Description: {PROCEDURE_INFO.get(procedure, '')}",
|
| 561 |
+
"",
|
| 562 |
+
"--- Detection ---",
|
| 563 |
f" Landmarks: {len(face.landmarks)} points",
|
| 564 |
f" Confidence: {face.confidence:.2f}",
|
| 565 |
f" Avg shift: {displacement:.1f} px",
|
| 566 |
+
"",
|
| 567 |
+
"--- Symmetry ---",
|
| 568 |
f" Before: {pre_overall:.1f} / 100",
|
| 569 |
f" After: {post_overall:.1f} / 100",
|
| 570 |
f" Change: {sym_arrow}{sym_delta:.1f}",
|
| 571 |
+
"",
|
| 572 |
+
"--- Performance ---",
|
| 573 |
f" Time: {elapsed:.2f}s",
|
| 574 |
+
" Mode: TPS (CPU)",
|
| 575 |
]
|
| 576 |
info = "\n".join(info_lines)
|
| 577 |
return wireframe_rgb, mask_vis, composited_rgb, image_rgb_512, info
|
|
|
|
| 678 |
<p style="font-size:0.85em; color:#aab;">
|
| 679 |
Powered by MediaPipe 478-point face mesh, thin-plate spline warping, and
|
| 680 |
procedure-specific anatomical displacement models. Runs entirely on CPU.
|
| 681 |
+
This 2D demo is the foundation -- 3D face reconstruction from phone video
|
| 682 |
+
is on the roadmap.
|
| 683 |
</p>
|
| 684 |
<div class="link-bar">
|
| 685 |
<a href="{GITHUB_URL}">GitHub</a>
|
|
|
|
| 703 |
)
|
| 704 |
# Show a brief description for each procedure
|
| 705 |
_proc_desc_md = " | ".join(
|
| 706 |
+
f"**{k.replace('_', ' ').title()}**: {v}" for k, v in PROCEDURE_INFO.items()
|
|
|
|
| 707 |
)
|
| 708 |
gr.Markdown(
|
| 709 |
f"<div style='font-size:0.82em;color:#666;line-height:1.5;'>"
|
|
|
|
| 742 |
|
| 743 |
with gr.Accordion("Photo Tips for Best Results", open=False):
|
| 744 |
gr.Markdown(
|
| 745 |
+
"- **Front-facing**: Use a straight-on frontal photo, "
|
| 746 |
+
"not a side profile\n"
|
| 747 |
+
"- **Good lighting**: Even, natural lighting works best. "
|
| 748 |
+
"Avoid harsh shadows\n"
|
| 749 |
+
"- **Neutral expression**: Keep a relaxed, neutral face "
|
| 750 |
+
"for accurate landmark detection\n"
|
| 751 |
+
"- **No obstructions**: Remove glasses, hats, or anything "
|
| 752 |
+
"covering the face\n"
|
| 753 |
+
"- **Resolution**: At least 256x256 pixels. The image will "
|
| 754 |
+
"be resized to 512x512 internally\n"
|
| 755 |
+
"- **Single face**: Make sure only one face is clearly "
|
| 756 |
+
"visible in the frame"
|
| 757 |
)
|
| 758 |
|
| 759 |
outputs = [out_wireframe, out_mask, out_result, out_original, info_box]
|