Main

archived_examplesagentsllmsvector-databaselancedbgptopenaiAImultimodal-aimachine-learningembeddingsfine-tuningexamplesdeep-learningfacial_recognitiongpt-4-visionllama-indexragmultimodallangchainlancedb-recipes

Facial Recognition

  1. Detect Face(s) using facenet
  2. Crop the Face(s)
  3. Get Embedding for 1st Face Crop (Code will have to be changed for multiple faces)
  4. Repeat the process for all the images and save image Embeddings in DB as a LanceDB Table
  5. Take a Query Image and apply steps 1 to 3
  6. Query the Image in Table and get the Top-K matches

Install Libraries

Note: Restart and run the below again if there are some dependency conflicts

[10]

Importing all libraries

[11]

Get the Face Dataset

[16]
--2023-11-17 23:09:04--  http://vis-www.cs.umass.edu/lfw/lfw-a.tgz
Resolving vis-www.cs.umass.edu (vis-www.cs.umass.edu)... 128.119.244.95
Connecting to vis-www.cs.umass.edu (vis-www.cs.umass.edu)|128.119.244.95|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14486641 (14M) [application/x-gzip]
Saving to: ‘lfw-a.tgz’

lfw-a.tgz           100%[===================>]  13.82M  1.23MB/s    in 35s     

2023-11-17 23:09:41 (400 KB/s) - ‘lfw-a.tgz’ saved [14486641/14486641]

[ ]

Load the data using pandas and describe the data

[17]

Helper functions for Steps 1-3

[18]
  0%|          | 0.00/107M [00:00<?, ?B/s]

Create a New LanceDB Table and insert Embedding

(It'll open if it already exists)

[19]
  0%|          | 0/20 [00:00<?, ?it/s]

Search on a new query Image

[20]
Output

Top 3 Results for Query: ./lfw/Atal_Bihari_Vajpayee/Atal_Bihari_Vajpayee_0014.jpg