Last active
April 24, 2016 18:15
-
-
Save daiiz/6c4c6cd3564d77ad0213a5eb103df8de to your computer and use it in GitHub Desktop.
A local server for tfPhotoPalette
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from flask import Flask, request, jsonify | |
import urllib | |
app = Flask(__name__) | |
def getPhoto (received_json): | |
return { | |
"base64jpg": received_json['jpg'], | |
"jpg" : urllib.urlopen(received_json['jpg']).read(), | |
"type": received_json['photo_type'] | |
} | |
# tfPhotoPaletteからデータを受信 | |
@app.route('/api/classify', methods=['POST']) | |
def classify (): | |
# 受信した画像情報 | |
photo = getPhoto(request.json) | |
# | |
# ここに処理を記述 | |
# | |
scores = {"photo_type": photo["type"]} | |
# tfPhotoPaletteに結果を返却 | |
return jsonify(theme="", scores=scores, description="Palette Server") | |
if __name__ == '__main__': | |
app.run(port=52892) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tfPhotoPalette とは
tfPhotoPalette の使用例
tfPhotoPalette を入手