def query_blob(id): blob = Image("static\\img\\%d.jpg" % id).crop( int(request.form["x"]), int(request.form["y"]), int(request.form["width"]), int(request.form["height"]) ) if blob and "SK_MODEL" in app.config: if blob.height > blob.width: blob = blob.resize(h=app.config["PATCH_SIZE"]) else: blob = blob.resize(w=app.config["PATCH_SIZE"]) blob = blob.embiggen((app.config["PATCH_SIZE"], app.config["PATCH_SIZE"])) np_img = blob.getGrayNumpy().transpose().reshape(-1) pred = labels.inverse_transform(sk_model.predict(np_img))[0] return jsonify(prediction=pred) else: return jsonify(prediction="")
def query_blob(id): blob = Image("static\\img\\%d.jpg" % id).crop(int(request.form['x']), int(request.form['y']), int(request.form['width']), int(request.form['height'])) if blob and 'SK_MODEL' in app.config: if blob.height > blob.width: blob = blob.resize(h=app.config['PATCH_SIZE']) else: blob = blob.resize(w=app.config['PATCH_SIZE']) blob = blob.embiggen( (app.config['PATCH_SIZE'], app.config['PATCH_SIZE'])) np_img = blob.getGrayNumpy().transpose().reshape(-1) pred = labels.inverse_transform(sk_model.predict(np_img))[0] return jsonify(prediction=pred) else: return jsonify(prediction='')
from SimpleCV import Image, Color import time img = Image('ladies.jpg') #print img.size() # Embiggen the image, put it on a green background, in the upper right emb = img.embiggen((560, 400), Color.GREEN, (0, 0)) emb.show() time.sleep(10)