Views
No views yet
inference.py) for 3-line code implementation.1pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # For CUDA support
2pip install opencv-python onnxruntime-gpu huggingface_hub pillow tqdm numpywget https://huggingface.co/biometric-ai-lab/Face_Recognition/resolve/main/inference.py1# File: run_demo.py
2from inference import FaceAnalysis
3
4# 1. Initialize the AI (Downloads models automatically on first run)
5print("⏳ Initializing models...")
6app = FaceAnalysis()
7
8# 2. Define your images
9img1_path = "face1.jpg" # <--- Change this to your image path
10img2_path = "face2.jpg" # <--- Change this to your image path
11
12# 3. Run Comparison
13print(f"🔍 Comparing {img1_path} vs {img2_path}...")
14
15try:
16 # Get similarity score and boolean result
17 similarity, is_same = app.compare(img1_path, img2_path)
18
19 print("-" * 30)
20 print(f"🔹 Similarity Score: {similarity:.4f}")
21 print("-" * 30)
22
23 if is_same:
24 print("✅ RESULT: SAME PERSON")
25 else:
26 print("❌ RESULT: DIFFERENT PERSON")
27
28except Exception as e:
29 print(f"Error: {e}")
30 print("Tip: Make sure the image paths are correct!")1dataset/
2├── person_1/
3│ ├── img1.jpg
4│ └── ...
5└── person_2/
6 └── img1.jpg1python train.py \\
2 --data_dir ./dataset \\
3 --output_dir ./checkpoints \\
4 --epochs 50 \\
5 --batch_size 64 \\
6 --lr_backbone 8e-6 \\
7 --lr_head 8e-5