Antuke
commited on
Commit
·
a20f097
1
Parent(s):
14135e1
fix
Browse files
app.py
CHANGED
|
@@ -242,7 +242,6 @@ def process_image(image, selected_checkpoint_path):
|
|
| 242 |
img_pil_annotated = image.copy()
|
| 243 |
draw = ImageDraw.Draw(img_pil_annotated)
|
| 244 |
|
| 245 |
-
# --- Detect faces ---
|
| 246 |
faces = detector.detect(img_cv, pad_rect=True)
|
| 247 |
|
| 248 |
if faces is None or len(faces) == 0:
|
|
@@ -295,7 +294,7 @@ def process_image(image, selected_checkpoint_path):
|
|
| 295 |
# --- Draw Bounding Box ---
|
| 296 |
draw.rectangle([(x, y), (x + w, y + h)], outline="lime", width=2)
|
| 297 |
|
| 298 |
-
# --- Prepare Text Lines
|
| 299 |
lines_to_draw = []
|
| 300 |
|
| 301 |
# Age
|
|
@@ -603,7 +602,6 @@ def process_image(image, selected_checkpoint_path):
|
|
| 603 |
def create_interface(checkpoint_list, default_checkpoint, initial_status):
|
| 604 |
"""Create and configure the Gradio interface."""
|
| 605 |
|
| 606 |
-
# Custom CSS for better styling
|
| 607 |
custom_css = """
|
| 608 |
.gradio-container {
|
| 609 |
font-family: 'Arial', sans-serif;
|
|
@@ -890,13 +888,13 @@ def create_interface(checkpoint_list, default_checkpoint, initial_status):
|
|
| 890 |
|
| 891 |
return demo
|
| 892 |
|
| 893 |
-
#
|
| 894 |
|
| 895 |
print("="*60)
|
| 896 |
print("VLM SOFT BIOMETRICS - GRADIO INTERFACE")
|
| 897 |
print("="*60)
|
| 898 |
|
| 899 |
-
# ---
|
| 900 |
print(f"Downloading model weights from {MODEL_REPO_ID} to {CHECKPOINTS_DIR}...")
|
| 901 |
os.makedirs(CHECKPOINTS_DIR, exist_ok=True)
|
| 902 |
try:
|
|
@@ -912,7 +910,6 @@ except Exception as e:
|
|
| 912 |
traceback.print_exc()
|
| 913 |
|
| 914 |
|
| 915 |
-
# This will now find the files you just downloaded
|
| 916 |
checkpoint_list, default_checkpoint = scan_checkpoints(CHECKPOINTS_DIR)
|
| 917 |
|
| 918 |
if not checkpoint_list:
|
|
@@ -930,10 +927,10 @@ if default_checkpoint:
|
|
| 930 |
initial_status_msg = load_model_and_update_status(default_checkpoint)
|
| 931 |
print(initial_status_msg)
|
| 932 |
else:
|
| 933 |
-
print("
|
| 934 |
|
| 935 |
|
| 936 |
-
# --- Create interface
|
| 937 |
print("Creating Gradio interface...")
|
| 938 |
demo = create_interface(checkpoint_list, default_checkpoint, initial_status_msg)
|
| 939 |
print("✓ Interface created successfully!")
|
|
|
|
| 242 |
img_pil_annotated = image.copy()
|
| 243 |
draw = ImageDraw.Draw(img_pil_annotated)
|
| 244 |
|
|
|
|
| 245 |
faces = detector.detect(img_cv, pad_rect=True)
|
| 246 |
|
| 247 |
if faces is None or len(faces) == 0:
|
|
|
|
| 294 |
# --- Draw Bounding Box ---
|
| 295 |
draw.rectangle([(x, y), (x + w, y + h)], outline="lime", width=2)
|
| 296 |
|
| 297 |
+
# --- Prepare Text Lines ---
|
| 298 |
lines_to_draw = []
|
| 299 |
|
| 300 |
# Age
|
|
|
|
| 602 |
def create_interface(checkpoint_list, default_checkpoint, initial_status):
|
| 603 |
"""Create and configure the Gradio interface."""
|
| 604 |
|
|
|
|
| 605 |
custom_css = """
|
| 606 |
.gradio-container {
|
| 607 |
font-family: 'Arial', sans-serif;
|
|
|
|
| 888 |
|
| 889 |
return demo
|
| 890 |
|
| 891 |
+
# Application Startup
|
| 892 |
|
| 893 |
print("="*60)
|
| 894 |
print("VLM SOFT BIOMETRICS - GRADIO INTERFACE")
|
| 895 |
print("="*60)
|
| 896 |
|
| 897 |
+
# --- Model download from HF Repo ---
|
| 898 |
print(f"Downloading model weights from {MODEL_REPO_ID} to {CHECKPOINTS_DIR}...")
|
| 899 |
os.makedirs(CHECKPOINTS_DIR, exist_ok=True)
|
| 900 |
try:
|
|
|
|
| 910 |
traceback.print_exc()
|
| 911 |
|
| 912 |
|
|
|
|
| 913 |
checkpoint_list, default_checkpoint = scan_checkpoints(CHECKPOINTS_DIR)
|
| 914 |
|
| 915 |
if not checkpoint_list:
|
|
|
|
| 927 |
initial_status_msg = load_model_and_update_status(default_checkpoint)
|
| 928 |
print(initial_status_msg)
|
| 929 |
else:
|
| 930 |
+
print("Warning: No default model to load.")
|
| 931 |
|
| 932 |
|
| 933 |
+
# --- Create interface ---
|
| 934 |
print("Creating Gradio interface...")
|
| 935 |
demo = create_interface(checkpoint_list, default_checkpoint, initial_status_msg)
|
| 936 |
print("✓ Interface created successfully!")
|