1.掌握深度学习图像处理(基于keras、tensorflow、opencv)
2.掌握web前后端设计(基 于flask框架)
3.开发基于web端的深度学习图像,把web端应用与人工智能相结合
视频教程:
https://edu.csdn.net/course/detail/28400/391614?pre_view=1
人脸识别实例:
import face_recognition
from flask import Flask, jsonify, request, redirect
# You can change this to any folder on your system
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
app = Flask(__name__)
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/', methods=['GET', 'POST'])
def upload_image():
# Check if a valid image file was uploaded
if request.method == 'POST':
if 'file' not in request.files:
return redirect(request.url)
file = request.files['file']
if file.filename == '':
return redirect(request.url)
if file and allowed_file(file.filename):
# The image file seems valid! Detect faces and return the result.
return detect_faces_in_image(file)
print("get")
return'''
Flask网页上传图片演示
'''
def detect_faces_in_image(file_stream):
# Pre-calculated face encoding of Obama generated with face_recognition.face_encodings(img)
biden_image = face_recognition.load_image_file("./images/yangmi.jpg")
known_face_encoding = face_recognition.face_encodings(biden_image)[0]
# Load the uploaded image file
img = face_recognition.load_image_file(file_stream)
# Get face encodings for any faces in the uploaded image
unknown_face_encodings = face_recognition.face_encodings(img)
face_found = False
is_obama = False
if len(unknown_face_encodings) > 0:
face_found = True
# See if the first face in the uploaded image matches the known face of Obama
match_results = face_recognition.compare_faces([known_face_encoding], unknown_face_encodings[0])
if match_results[0]:
is_obama = True
# Return the result as json
result = {"face_found_in_image": face_found,
"is_picture_of_yangmi": is_obama
}
return jsonify(result)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5001, debug=True)