Skip to content

Instantly share code, notes, and snippets.

@yankov
Created March 2, 2012 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yankov/1956708 to your computer and use it in GitHub Desktop.
Save yankov/1956708 to your computer and use it in GitHub Desktop.
require 'redis'
require 'face'
# fb user_id of the user that needs to be find on match.com
FB_UID = '11111@facebook.com'
# show all profiles whith the given confidence of recognition
ACCURACY = 30
redis = Redis.new
pictures = redis.hgetall("people")
# recognize user
client = Face.get_client(:api_key => FACECOM_APIKEY, :api_secret => FACECOM_APISECRET)
# note in fb_user you pass here YOUR fb user id, not an id of the user your are looking for
client.facebook_credentials = {:fb_user => YOUR_FB_USER_ID, :fb_oauth_token =>YOUR_FB_OAUTH_TOKEN}
#train pictures
response = client.faces_train(:uids => [FB_UID] )
pictures.keys.each_slice(20) do |pictures_chunk|
response = client.faces_recognize(:urls => pictures_chunk, :uids => [FB_UID])
response["photos"].each do |photo|
photo["tags"].each{|tag|
next if tag.nil? || tag['uids'].empty?
p "Profile found, #{pictures[photo['url']]}, confidence #{tag['uids'][0]['confidence']}" if tag['uids'][0]['confidence'].to_i > ACCURACY
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment