Hi, i need help passing my cv2 yolov8s video feed to a django application i got for my project
Im new to neural network development i got pretrained YOLO8s model and trained it on my custom dataset, made a python class, using cv2 to display the results now i need help passing my cv2 yolov8s video feed to a django application i got for my project, how do i do that?
'''
from ultralytics import YOLO
from pathlib import Path
import cv2, onnx, onnxoptimizer,numpy,onnxruntime
import torch.onnx
import torchvision.models as models
from database.db import *
from pprint import pprint as pt
class Main_field:
def __init__(self, model, size, source, conf_):
self.model = self.load_model(model)
self.size = size
self.source = source
self.conf_ = conf_
def __call__(self):
self.process_video()
def load_model(self, model):
model.fuse()
return model
def process_video(self):
cap = cv2.VideoCapture(self.source)
while True:
ret, frame = cap.read()
if not ret: break
results = self.model.predict(frame, conf=self.conf_, imgsz=self.size)
masks_dict=[result.names for result in results][0]
xyxys=[result.boxes.cpu().numpy().xyxy for result in results][0] #xyxy
mask_ids=[result.boxes.cpu().numpy().cls.astype(int).tolist() for result in results][0]
masks=[masks_dict[itr] for itr in mask_ids]
db_output=[check_(local_list,str(itr)) for itr in mask_ids if itr]
video_outp=cv2.imshow("_________", results[0].plot())
pt(mask_ids)
if cv2.waitKey(1) & 0xFF == ord('q'): break
def __del__():
cap.release()
cv2.destroyAllWindows()
def init_model(path: str) -> any: return YOLO(path)
'''