예제 #1
0
파일: worker.py 프로젝트: relh/dream-book
import remotequeue

open("/home/ubuntu/deepdream.py", "w").write(
    urllib2.urlopen("https://raw.githubusercontent.com/relh/dreambook/master/API/worker/deepdream.py").read()
)

# dreambaby is a generator which yields StringIO buffers containing
# partial deep dreams, until the last one, the full deep dream
# it takes in a PIL Image and template
from deepdream import dreambaby

# grab the queue
AUTH_KEY = "changeinprod"
QUEUE_IP = "127.0.0.1"

MANAGED_QUEUE = remotequeue.get(QUEUE_IP, AUTH_KEY)

S3 = boto3.resource("s3")
BUCKET_NAME = "deepdreambook"

NUM_THREADS = 3
# constrained by RAM and GPU


def url_to_image(url):
    """ takes in a url, returns a PIL.Image """
    buf = StringIO(urllib2.urlopen(url).read())
    return PIL.Image.open(buf)


def push_buffer(buf, key):
예제 #2
0
from bottle import route, hook, response, run, request
import datetime
import remotequeue
import sys

Q = remotequeue.get('127.0.0.1', 'secret')

@hook('after_request')
def enable_cors():
    response.headers['Access-Control-Allow-Origin'] = '*'

@route('/')
def index():
    print '[' + str(datetime.datetime.now()) + '] ' + str(request.environ.get('REMOTE_ADDR'))
    sys.stdout.flush()
    return Q.get()

run(host = '0.0.0.0', port = 8080, server = 'tornado')
예제 #3
0
from bottle import route, hook, response, run
import remotequeue

Q = remotequeue.get("127.0.0.1", "secret")


@hook("after_request")
def enable_cors():
    response.headers["Access-Control-Allow-Origin"] = "*"


@route("/")
def index():
    return Q.get()


run(host="0.0.0.0", port=8080, server="tornado")
예제 #4
0
from bottle import route, hook, response, run
import remotequeue

Q = remotequeue.get('127.0.0.1', 'secret')


@hook('after_request')
def enable_cors():
    response.headers['Access-Control-Allow-Origin'] = '*'


@route('/')
def index():
    return Q.get()


run(host='0.0.0.0', port=8080, server='tornado')