def post(self): args = parser.parse_args() location = "images/%s" % (args['image_name']) blob = bucket.get_blob(location) image_data = blob.download_as_string() output = li.label(image_data) return (item for item in output if item['name'] == 'mosquito').next()
def get(self, image_name): location = "images/%s" % (image_name) blob = bucket.get_blob(location) image_data = blob.download_as_string() output = li.label(image_data) return str( (item for item in output if item['name'] == 'mosquito').next())
def api_root(): app.logger.info(PROJECT_HOME) if request.method == 'POST' and request.files['image']: app.logger.info(app.config['UPLOAD_FOLDER']) img = request.files['image'] img_name = secure_filename(img.filename) create_new_folder(app.config['UPLOAD_FOLDER']) saved_path = os.path.join(app.config['UPLOAD_FOLDER'], img_name) app.logger.info("saving {}".format(saved_path)) img.save(saved_path) im = Image.open(saved_path) print("do") n = lb.label(saved_path) return render_template('safe.html', n=n) else: return "Where is the image?" if __name__ == '__main__': app.run(host='0.0.0.0', debug=False)
def get(self, image_name): location = "images/%s" % (image_name) blob = bucket.get_blob(location) image_data = blob.download_as_string() output = li.label(image_data) return output
from flask import Flask, render_template import label_image as lb app = Flask(__name__) n = lb.label(saved_path) @app.route("/") def template_test(): return render_template('safe.html', lb(saved_path)) if __name__ == '__main__': app.run(debug=True)
def calculate_fitness(self): scores = label_image.label(self.image) scores = dict(scores) print scores self.fitness = scores.get(self.fitness_label, 0) return self.fitness