I've tried to install pytorch but it failed. I've also downloaded all the libraries needed for it to run (opencv-python, numpy, scipy, among others) still, nothing... How can I solve this issue?
Error:
File "C:\Users\Home\PycharmProjects\XG -I programming(trial part 2)\Mask_detection(trial 6).py", line 1, in <module>
from imageai.Detection import VideoObjectDetection
File "C:\Users\Home\PycharmProjects\XG -I programming(trial part 2)\venv\lib\site-packages\imageai\Detection\__init__.py", line 17, in <module>
from imageai.Detection.YOLOv3.models import yolo_main, tiny_yolo_main
File "C:\Users\Home\PycharmProjects\XG -I programming(trial part 2)\venv\lib\site-packages\imageai\Detection\YOLOv3\models.py", line 8, in <module>
from keras.layers.normalization import BatchNormalization
ImportError: cannot import name 'BatchNormalization' from 'keras.layers.normalization' (C:\Users\Home\PycharmProjects\XG -I programming(trial part 2)\venv\lib\site-packages\keras\layers\normalization\__init__.py)
Code:
from imageai.Detection import VideoObjectDetection
import cv2
camera = cv2.VideoCapture(0)
detector = VideoObjectDetection()
model_path = "./Models/yolo.h5"
detector.setModelTypeAsYOLOv3()
detector.setModelPath(model_path)
detector.loadModel()
while True:
ret, frame = camera.read()
rgb_frame = frame[:, :, ::-1]
video_detection = detector.detectObjectsFromVideo(camera_input=camera, output_file_path ="./camera_detected_video", frames_per_second=28, log_progress=True, minimum_percentage_probability=40)
cv2.imshow('frame', frame)
print(video_detection)
if cv2.waitKey(1) & 0xff == ord('q'):
break
camera.release()
cv2.destroyAllWindows()
The problem is with the keras version, try installing older keras version
pip3 install keras==2.4.3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.