-
Notifications
You must be signed in to change notification settings - Fork 0
/
flaskweb.py
29 lines (21 loc) · 881 Bytes
/
flaskweb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, Response
# Required to run the YOLOv8 model
import cv2
from running_yolo_webcam.YOLO_Video import video_detection
app = Flask(__name__)
@app.route("/")
def lil():
return "hello this is testing "
def generate_frames(video=0):
yolo_output = video_detection(video, model1="runs/detect/train2/weights/best.pt", model2="github/[email protected]", weights2="github/[email protected]", csvfile_path="rafay.csv")
for detection_ in yolo_output:
ref,buffer=cv2.imencode('.jpg',detection_)
frame=buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame +b'\r\n')
@app.route('/video_feed')
def video_feed():
return Response(generate_frames(),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == "__main__":
app.run(debug=True)