Ошибка: ValueError: Ensure you specified correct input image, input type, output type and/or output image path

Всем привет! Недавно решил написать программу по определению объектов через видео(камеру в режиме реального времени), ну все, почитал пару статеек, посмотрел видео разные, довольный написал код:

from imageai.Detection import ObjectDetection
import cv2 as vc
import time

camera = vc.VideoCapture("Alley.mp4")

detector = ObjectDetection()
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath("yolo-tiny.h5")
detector.loadModel()

finish = 0
array_detection = []

while camera.isOpened():
    ret, frame = camera.read()

    start = time.time()
    if start - finish > 1.2:
        _, array_detection = detector.detectObjectsFromImage(input_image=frame, input_type="array", output_image_path="array")
        finish = time.time()
    for obj in array_detection:
        coord = obj['box_points']
        vc.rectangle(frame, (coord[0], coord[1]), (coord[2], coord[3]), (0, 0, 255))
        vc.putText(frame, obj['name'], (coord[0], coord[1] - 6), vc.FONT_HERSHEY_DUPLEX, 1.0, (255, 0, 0), 1)

    vc.imshow('Vision', frame)
    if vc.waitKey(25) & 0xFF == ord('q'):
        break

vc.destroyAllWindows()

Решил попробовать на видео, так как камеры у себя нет и получил следующие ошибки:

2021-10-07 01:51:04.140110: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "F:\PRR\lib\site-packages\imageai\Detection\__init__.py", line 376, in detectObjectsFromImage
    cv2.imwrite(output_image_path, image_copy)
cv2.error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\modules\imgcodecs\src\loadsave.cpp:662: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'cv::imwrite_'


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:/Vision/main.py", line 20, in <module>
    _, array_detection = detector.detectObjectsFromImage(input_image=frame, input_type="array", output_image_path="array")
  File "F:\PRR\lib\site-packages\imageai\Detection\__init__.py", line 391, in detectObjectsFromImage
    raise ValueError(
ValueError: Ensure you specified correct input image, input type, output type and/or output image path 

Как я понял, вроде как, проблема в это: ValueError: Ensure you specified correct input image, input type, output type and/or output image path, посмотрел как решать и нашел для изображений (надо поставить расширение вот сюда: vc.imshow('Vision', frame)), но это не сработало, в чем еще проблема не знаю, если кто-нибудь сможет помочь, буду благодарен!:3


Ответы (1 шт):

Автор решения: Vasily

Занимался чем-то похожим в прошлом году, проблема былв в версиях Tensorflow. Попробуйте с 2.4.0 и c python3.6

Кстати, вот пример, как у меня получилось с imageai и yolo-tiny, можно просто взять версии библиотек из requirements.txt и попробовать с ними.

→ Ссылка