Yolov8 people count

I am reaching out to you because I am currently working on a project that involves using YOLOv8 to count the number of people in a video stream.

I am struggling with implementing the code and would appreciate some assistance in getting started. Specifically, I need help with configuring the YOLOv8 model to detect people and then counting the total number of people in the video stream.
i am using thonny IDE and you will find below the code that i am using how to Add people counting to the code below

import cv2
import cvlib as cv
import pandas as pd

from numba import jit, cuda

import numpy as np
from vidgear.gears import CamGear
from cvlib.object_detection import draw_bbox
from ultralytics import YOLO

model=YOLO(‘visdrone_last.pt’)

@jit(target_backend=‘cuda’)

stream = CamGear(source=‘EarthCam Live: Times Square in 4K - YouTube’, stream_mode = True, logging=True).start() # YouTube Video URL Video URL as input

my_file = open(“coco.txt”, “r”)
data = my_file.read()
class_list = data.split(“\n”)
print(class_list)
count=0
while True:

frame = stream.read()
count += 1
if count % 15 != 0:
    continue
frame=cv2.resize(frame,(1020,600))

bbox,label,conf=cv.detect_common_objects(frame)

frame=draw_bbox(frame,bbox,label,conf)

c=label.count(‘car’)

cv2.putText(frame,str(‘cars:’),(30,480),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),2)

cv2.putText(frame,str(c),(130,480),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),3)

p=label.count(‘person’)

cv2.putText(frame,str(‘person:’),(30,510),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),2)

cv2.putText(frame,str(p),(170,510),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),3)

t=label.count(‘truck’)

cv2.putText(frame,str(‘truck:’),(28,544),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),2)

cv2.putText(frame,str(t),(150,544),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),3)

m=label.count(‘motorcycle’)

cv2.putText(frame,str(‘m.cycle:’),(30,574),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),2)

cv2.putText(frame,str(m),(180,574),cv2.FONT_HERSHEY_PLAIN,2,(255,255,255),3)

results=model.predict(frame, show=True)
       
#cv2.imshow("RGB", frame)
if cv2.waitKey(1)&0xFF==27:
    break

stream.release()
cv2.destroyAllWindows()