ImageAI icon indicating copy to clipboard operation
ImageAI copied to clipboard

Can i use a custom dection yolo model with VideoObjectDetection

Open sb3114 opened this issue 3 years ago • 0 comments

I have trained a Yolo model on a set of images. the new model works on image detection. i am trying to load same model for object detection but it is failing with below error: ValueError: Cannot assign to variable last1/kernel:0 due to variable shape (1, 1, 1024, 255) and value shape (24, 1024, 1, 1) are incompatible See my code: `from imageai.Detection import VideoObjectDetection import os import cv2 as cv execution_path = os.getcwd() camera = cv.VideoCapture(0)

if not camera.isOpened(): print("Cannot open camera") exit() while True: # Capture frame-by-frame ret, frame = camera.read() # if frame is read correctly ret is True if not ret: print("Can't receive frame (stream end?). Exiting ...") break

detector = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath("imageai/data/models/detection_model-ex-007--loss-0038.484.h5")
detector.loadModel()

video_path = detector.detectObjectsFromVideo(
                camera_input=camera,
                output_file_path=os.path.join(execution_path, "camera_detected_video"),
                frames_per_second=20, log_progress=True, minimum_percentage_probability=20)

`

sb3114 avatar Feb 18 '22 07:02 sb3114