nothotdog.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:NotHotDog 作者: ryanml 项目源码 文件源码
def is_hot_dog():
    if request.method == 'POST':
        if not 'file' in request.files:
            return jsonify({'error': 'no file'}), 400
        # Image info
        img_file = request.files.get('file')
        img_name = img_file.filename
        mimetype = img_file.content_type
        # Return an error if not a valid mimetype
        if not mimetype in valid_mimetypes:
            return jsonify({'error': 'bad-type'})
        # Write image to static directory and do the hot dog check
        img_file.save(os.path.join(app.config['UPLOAD_FOLDER'], img_name))
        hot_dog_conf = rekognizer.get_confidence(img_name)
        # Delete image when done with analysis
        os.remove(os.path.join(app.config['UPLOAD_FOLDER'], img_name))
        is_hot_dog = 'false' if hot_dog_conf == 0 else 'true'
        return_packet = {
            'is_hot_dog': is_hot_dog,
            'confidence': hot_dog_conf
        }
        return jsonify(return_packet)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号