Opencv object detection error

File “E:\machine learning\ML IP CV Course code\computer_vision\mobiledetection\Object_Detection_Files\mobile.py”, line 24, in
net = cv2.dnn_DetectionModel(weightsPath,configPath)

AttributeError: module ‘cv2’ has no attribute ‘dnn_DetectionModel’

SHOWING ERROR WHILE RUNNING CODE BELOW

import cv2
thres = 0.45 # Threshold to detect object

cap = cv2.VideoCapture(0)
cap.set(3,648)
cap.set(4,480)

classNames= []
classFile = ‘coco.names’
with open(classFile,‘rt’) as f:
classNames = f.read().rstrip("\n").split("\n")

configPath =‘ssdmobilenetv3largecoco20200114.pbtxt’
weightsPath =‘frozeninferencegraph.pb’

net = cv2.dnn_DetectionModel(weightsPath,configPath)
net.setInputSize(328,328)
net.setInputScale(1.0/ 127.5)
net.setInputMean((127.5, 127.5, 127.5))
net.setInputSwapRB(True)

HELP ME

this is only available with opencv 4.x