Уведомления

Группа в Telegram: @pythonsu

#1 Май 17, 2022 19:24:09

dankochkurov
Зарегистрирован: 2022-05-01
Сообщения: 15
Репутация: +  0  -
Профиль   Отправить e-mail  

object recognition on python

hello! I am doing object recognition on python here is my code:
# encoding:utf-8
# Imageai download address: https://github.com/OlafenwaMoses/ImageAI
# Resnet50_coco_best_v2.1.0.h5 model download address: https://github.com/fizyr/keras-retinanet/releases/
from imageai.Detection import ObjectDetection # Imported ImageAI target detection class
import cv2
import os
os.environ = ‘2’
import matplotlib.pyplot as plt

def targetDetection(imgArray,model_path):

return

path = os.path.abspath(model_path)
detector = ObjectDetection() # Defined target detection class detector.setModelTypeAsRetinaNet() # Model type is set to RetinaNet.
detector.setModelPath(path) # Set model path to RetinaNet model path
detector.loadModel() # The target detection class into which the model is loaded. # Call the target detection function to analyze the input and output image paths.
detections = detector.detectObjectsFromImage(input_image=imgArray,
input_type='array',output_type='array')
return detections

data = plt.imread('zebra.jpg')
model_path = ('resnet50_coco_best_v2.0.1.h5')
imgInfo = targetDetection(data,model_path)
plt.imshow(imgInfo)
plt.show()
this code throws an error:
Traceback (most recent call last):
File “C:\Users\Daniel\PycharmProjects\object_detection\real_time_object_detection.py”, line 25, in <module>
plt.imshow(imgInfo)
File “C:\Users\Daniel\PycharmProjects\object_detection\venv\lib\site-packages\matplotlib\_api\deprecation.py”, line 459, in wrapper
return func(*args, **kwargs)
File “C:\Users\Daniel\PycharmProjects\object_detection\venv\lib\site-packages\matplotlib\pyplot.py”, line 2652, in imshow
__ret = gca().imshow(
File “C:\Users\Daniel\PycharmProjects\object_detection\venv\lib\site-packages\matplotlib\_api\deprecation.py”, line 459, in wrapper
return func(*args, **kwargs)
File “C:\Users\Daniel\PycharmProjects\object_detection\venv\lib\site-packages\matplotlib\__init__.py”, line 1412, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File “C:\Users\Daniel\PycharmProjects\object_detection\venv\lib\site-packages\matplotlib\axes\_axes.py”, line 5481, in imshow
im.set_data(X)
File “C:\Users\Daniel\PycharmProjects\object_detection\venv\lib\site-packages\matplotlib\image.py”, line 706, in set_data
raise TypeError(“Image data of dtype {} cannot be converted to ”
TypeError: Image data of dtype object cannot be converted to float

Process finished with exit code 1
Please help me decide, thanks in advance

Прикреплённый файлы:
attachment real_time_object_detection.py (1,5 KБ)

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version