You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # @Author : linjie
  4. from flask import Flask, render_template, Response, request, session, redirect, url_for, send_from_directory, flash
  5. from werkzeug.utils import secure_filename
  6. from detect import *
  7. import os
  8. import torch
  9. from importlib import import_module
  10. # import camera driver
  11. if os.environ.get('CAMERA'):
  12. Camera = import_module('camera_' + os.environ['CAMERA']).Camera
  13. else:
  14. from yolov5_flask import Camera
  15. # from flack_cors import *
  16. app = Flask(__name__)
  17. # UPLOAD_FOLDER = "C:\Users\Arpit Sharma\Desktop\Friendship goals\content\yolov5\static\uploads"
  18. DETECTION_FOLDER = r'./static/detections'
  19. # app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
  20. #app.config['DETECTION_FOLDER'] = DETECTION_FOLDER
  21. @app.route('/index')
  22. def index():
  23. """Video streaming home page."""
  24. return render_template('index.html')
  25. def gen(camera):
  26. """Video streaming generator function."""
  27. while True:
  28. frame = camera.get_frame()
  29. yield (b'--frame\r\n'
  30. b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
  31. @app.route('/video_feed')
  32. def video_feed():
  33. """Video streaming route. Put this in the src attribute of an img tag."""
  34. return Response(gen(Camera()),
  35. mimetype='multipart/x-mixed-replace; boundary=frame')
  36. ###
  37. if __name__ == "__main__":
  38. app.run(debug = True)

随着人工智能和大数据的发展,任一方面对自动化工具有着一定的需求,在当下疫情防控期间,使用mindspore来实现yolo模型来进行目标检测及语义分割,对视频或图片都可以进行口罩佩戴检测和行人社交距离检测,来对公共场所的疫情防控来实行自动化管理。