Skip to content

Commit

Permalink
Fix keras version, handle multiple requests, and multiple requests wi…
Browse files Browse the repository at this point in the history
…th bit a of confidence'
  • Loading branch information
tesYolan committed Jun 4, 2018
1 parent e4ec540 commit ea07b9d
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,8 +2,9 @@ shape_predictor_68_face_landmarks.dat
*.pyc
logs/logs/*
logs/models/*
tmp/*
*.h5
*.json
!logs/logs/.gitkeep
!logs/models/.gitkeep
!logs/.gitkeep
!logs/.gitkeep
5 changes: 3 additions & 2 deletions environment.yml
@@ -1,14 +1,15 @@
name: emotion-recogntion-snet-agent
dependencies:
- Keras==2.1.5
- Keras==2.1.6
- numpy==1.14.3
- protobuf==3.5.2
- ptyprocess==0.5.2
- Pygments==2.2.0
- pyparsing==2.2.0
- python==3.6.5
- python-dateutil==2.7.3
- pytz==2018.4
- PyWavelets==0.5.2
- pytz==2018.4
- PyYAML==3.12
- scikit-image==0.13.1
- scipy==1.1.0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -13,7 +13,7 @@ html5lib==0.9999999
ipython==6.4.0
ipython-genutils==0.2.0
jedi==0.12.0
Keras==2.1.5
Keras==2.1.6
kiwisolver==1.0.1
Mako==1.0.7
Markdown==2.6.11
Expand Down
File renamed without changes.
18 changes: 15 additions & 3 deletions singnet_wrap/script.py → script.py
@@ -1,4 +1,6 @@
import base64
import random
import os
import numpy as np
from aiohttp import web
from jsonrpcserver.aio import methods
Expand All @@ -10,9 +12,10 @@
'''
class Args:
def __init__(self):
self.json = 'logs/models/model-ff.json'
self.weights = 'logs/models/model-ff.h5'
self.json = 'models/models/model-ff.json'
self.weights = 'models/models/model-ff.h5'
self.model_input = 'image'
# TODO currenty we save, so this should be set this False for now
self.snet = False
self.gui = False
self.path = ''
Expand All @@ -37,7 +40,11 @@ async def classify(**kwargs):
raise InvalidParams("image type is required")
binary_image = base64.b64decode(image)
# this requires that we save the file.
with open('tmp.'+str(image_type), 'wb') as f:
current_files = os.listdir('tmp')
tmp_file_name = 'tmp/tmp_' + str(random.randint(0,100000000000)) +'_.' + str(image_type)
while tmp_file_name in current_files:
tmp_file_name = 'tmp/tmp_' + str(random.randint(0,100000000000)) +'_.' + str(image_type)
with open(tmp_file_name,'wb') as f:
f.write(binary_image)
model.args.path = 'tmp.'+str(image_type)
bounding_boxes, emotions = model.predict()
Expand All @@ -53,4 +60,9 @@ async def handle(request):

if __name__ == '__main__':
app.router.add_post('/', handle)
# create a tmp folder if it doesn't exist to hold files
try:
os.mkdir('tmp')
except OSError:
print('tmp folder already exists, not created')
web.run_app(app, host="127.0.0.1", port=8000)
File renamed without changes.
File renamed without changes

0 comments on commit ea07b9d

Please sign in to comment.