Ejemplo n.º 1
0
Archivo: app.py Proyecto: atwj/tf_bites
 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()
Ejemplo n.º 2
0
Archivo: app.py Proyecto: atwj/tf_bites
 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())
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
Archivo: app.py Proyecto: atwj/tf_bites
 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
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
 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