An unofficial python wrapper for the Facebook face recognition endpoint
An unofficial python wrapper for the Facebook face recognition endpoint
pip install fbrecog
from fbrecog import recognize
Go to your Facebook profile.
Open chrome dev tools by Right Click > Inspect
Upload any picture. As it gets uploaded monitor the Network tab for 'dpr?' endpoint.
Click on it. Scroll down to Request Header. Copy the entire cookie string.
Scroll further down to Form Data. Copy the value of fb_dtsg parameter.
from pprint import pprint
from fbrecog import FBRecog
path = '1.jpg' # Insert your image file path here
path2 = '2.jpg' # Insert your image file path here
access_token = '#######' # Insert your access token obtained from Graph API explorer here
cookie = '###' # Insert your cookie string here
fb_dtsg = '###' # Insert the fb_dtsg parameter obtained from Form Data here.
# Instantiate the recog class
recog = FBRecog(access_token, cookies, fb_dtsg)
# Recog class can be used multiple times with different paths
print(recog.recognize(path))
print(recog.recognize(path2))
# Call recognize_raw to get more info about the faces detected, including their positions
pprint(recog.recognize_raw(path), indent=2)