Skip to content

Commit

Permalink
last update
Browse files Browse the repository at this point in the history
  • Loading branch information
philipperemy committed Nov 5, 2016
1 parent ec710d5 commit b44dc3f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 166 deletions.
17 changes: 15 additions & 2 deletions main.py
Expand Up @@ -19,7 +19,13 @@
model_api_host = str(credentials['API_HOST'])
model_id = str(credentials['MODEL_ID'])

model.MODEL_THRESHOLD = 25.0

def stats(likes, nopes):
prop_likes = (float(likes) / (likes + nopes)) * 100.0
prop_nopes = 100.0 - prop_likes
print('likes = {} ({}%), nopes = {} ({}%)'.format(likes, prop_likes,
nopes, prop_nopes))


if __name__ == '__main__':

Expand All @@ -30,6 +36,9 @@
print('MODEL_API_HOST = {}'.format(model_api_host))
print('MODEL_ID = {}'.format(model_id))

like_count = 0
nope_count = 0

while True:
token = ti.auth_token(fb_auth_token, fb_id)

Expand Down Expand Up @@ -77,13 +86,17 @@
model_api_host=model_api_host,
model_id=model_id)
if action == 'like':
like_count += 1
print(' -> Like')
stats(like_count, nope_count)
match = ti.like(user.user_id)
if match:
print(' -> Match!')
else:
nope_count += 1
print(' -> nope')
stats(like_count, nope_count)
ti.nope(user.user_id)

except Exception, e:
except Exception as e:
print(e)
13 changes: 6 additions & 7 deletions request_model.py
Expand Up @@ -7,19 +7,18 @@
import time
import uuid

import numpy as np
from requests import post
from scipy.misc import imread
from scipy.misc import imsave

MODEL_THRESHOLD = None


def like_or_nope(_filename_paths, model_api_host, model_id):
count = 0.0
scores = []
for _url in _filename_paths:
count += call_model(imread(_url), api_host=model_api_host, model_id=model_id)
print('cumulative score = {}, threshold to be accepted = {}'.format(count, MODEL_THRESHOLD))
if count > MODEL_THRESHOLD:
scores.append(call_model(imread(_url), api_host=model_api_host, model_id=model_id))
print(scores)
if np.any(np.array(scores) > 40.0):
return 'like'
return 'nope'

Expand Down Expand Up @@ -57,5 +56,5 @@ def call_model(image, api_host='', model_id=''):
try:
img = imread(target_dir + filename)
call_model(img, credentials['API_HOST'], credentials['MODEL_ID'])
except Exception, e:
except Exception as e:
print(str(e))
157 changes: 0 additions & 157 deletions tinder_api.py

This file was deleted.

0 comments on commit b44dc3f

Please sign in to comment.