#!/usr/bin/env python3

from flask import Flask, request, jsonify
from EmoPy.src.fermodel import FERModel
from pkg_resources import resource_filename
from base64 import b64decode
import cv2

app = Flask(__name__)

@app.route("/")
def hello():
  return "Emotion Server"

@app.route("/image", methods=['POST'])
def image():
  content = request.json
  target_emotions = ['anger', 'happiness']
  model = FERModel(target_emotions, verbose=True)
  data_uri = content['image']
  header, encoded = data_uri.split(",", 1)
  image_data = b64decode(encoded) 
  prediction = model.predict(image_data)
  
  sum = 0  
  for i in range(len(prediction[0])):
      sum = sum + prediction[0][i]
  return {"faceDetected":"true","emotion":{"anger": prediction[0][0] / sum, "happiness": prediction[0][1] / sum}}
  #return str(prediction)        
  

if __name__ == "__main__":
  app.run()

f6e1fee76ba51c95dab3b9a07a88d5f81de13121
<mask token>


@app.route('/')
def hello():
    return 'Emotion Server'


@app.route('/image', methods=['POST'])
def image():
    content = request.json
    target_emotions = ['anger', 'happiness']
    model = FERModel(target_emotions, verbose=True)
    data_uri = content['image']
    header, encoded = data_uri.split(',', 1)
    image_data = b64decode(encoded)
    prediction = model.predict(image_data)
    sum = 0
    for i in range(len(prediction[0])):
        sum = sum + prediction[0][i]
    return {'faceDetected': 'true', 'emotion': {'anger': prediction[0][0] /
        sum, 'happiness': prediction[0][1] / sum}}


<mask token>

<mask token>


@app.route('/')
def hello():
    return 'Emotion Server'


@app.route('/image', methods=['POST'])
def image():
    content = request.json
    target_emotions = ['anger', 'happiness']
    model = FERModel(target_emotions, verbose=True)
    data_uri = content['image']
    header, encoded = data_uri.split(',', 1)
    image_data = b64decode(encoded)
    prediction = model.predict(image_data)
    sum = 0
    for i in range(len(prediction[0])):
        sum = sum + prediction[0][i]
    return {'faceDetected': 'true', 'emotion': {'anger': prediction[0][0] /
        sum, 'happiness': prediction[0][1] / sum}}


if __name__ == '__main__':
    app.run()

<mask token>
app = Flask(__name__)


@app.route('/')
def hello():
    return 'Emotion Server'


@app.route('/image', methods=['POST'])
def image():
    content = request.json
    target_emotions = ['anger', 'happiness']
    model = FERModel(target_emotions, verbose=True)
    data_uri = content['image']
    header, encoded = data_uri.split(',', 1)
    image_data = b64decode(encoded)
    prediction = model.predict(image_data)
    sum = 0
    for i in range(len(prediction[0])):
        sum = sum + prediction[0][i]
    return {'faceDetected': 'true', 'emotion': {'anger': prediction[0][0] /
        sum, 'happiness': prediction[0][1] / sum}}


if __name__ == '__main__':
    app.run()

from flask import Flask, request, jsonify
from EmoPy.src.fermodel import FERModel
from pkg_resources import resource_filename
from base64 import b64decode
import cv2
app = Flask(__name__)


@app.route('/')
def hello():
    return 'Emotion Server'


@app.route('/image', methods=['POST'])
def image():
    content = request.json
    target_emotions = ['anger', 'happiness']
    model = FERModel(target_emotions, verbose=True)
    data_uri = content['image']
    header, encoded = data_uri.split(',', 1)
    image_data = b64decode(encoded)
    prediction = model.predict(image_data)
    sum = 0
    for i in range(len(prediction[0])):
        sum = sum + prediction[0][i]
    return {'faceDetected': 'true', 'emotion': {'anger': prediction[0][0] /
        sum, 'happiness': prediction[0][1] / sum}}


if __name__ == '__main__':
    app.run()

#!/usr/bin/env python3

from flask import Flask, request, jsonify
from EmoPy.src.fermodel import FERModel
from pkg_resources import resource_filename
from base64 import b64decode
import cv2

app = Flask(__name__)

@app.route("/")
def hello():
  return "Emotion Server"

@app.route("/image", methods=['POST'])
def image():
  content = request.json
  target_emotions = ['anger', 'happiness']
  model = FERModel(target_emotions, verbose=True)
  data_uri = content['image']
  header, encoded = data_uri.split(",", 1)
  image_data = b64decode(encoded) 
  prediction = model.predict(image_data)
  
  sum = 0  
  for i in range(len(prediction[0])):
      sum = sum + prediction[0][i]
  return {"faceDetected":"true","emotion":{"anger": prediction[0][0] / sum, "happiness": prediction[0][1] / sum}}
  #return str(prediction)        
  

if __name__ == "__main__":
  app.run()
