ich werde demnächst einen Vortrag über das Object detection model YOLO halten.
Dazu wurde ich dies gerne live demonstrieren anhand meiner Webcam.
Habe mich an diese Anleitung gehalten (https://towardsdatascience.com/how-to-d ... 2693c47bd8) und auch schon viele andere probiert. Keine einzige habe ich zum laufen bekommen.
Vielleicht könnt ihr mir da helfen.
Hier mal mein Code (Exakt das selbe aus dem Link oben, nur das yolo.h5 bei mir im selben Verzeichnis wie das Skript liegt)
Code: Alles auswählen
# https://towardsdatascience.com/how-to-detect-objects-with-your-webcam-82693c47bd8
#
# @ Mauro Di Pietro
from imageai import Detection
import cv2
modelpath = "yolo.h5"
yolo = Detection.ObjectDetection()
yolo.setModelTypeAsYOLOv3()
yolo.setModelPath(modelpath)
yolo.loadModel()
cam = cv2.VideoCapture(0) #0=front-cam, 1=back-cam
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1300)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 1500)
while True:
## read frames
ret, img = cam.read()
## predict yolo
img, preds = yolo.detectCustomObjectsFromImage(input_image=img,
custom_objects=None, input_type="array",
output_type="array",
minimum_percentage_probability=70,
display_percentage_probability=False,
display_object_name=True)
## display predictions
cv2.imshow("", img)
## press q or Esc to quit
if (cv2.waitKey(1) & 0xFF == ord("q")) or (cv2.waitKey(1)==27):
break
## close camera
cam.release()
cv2.destroyAllWindows()
Es ist auch OpenCV installiert wie man sieht.
Code: Alles auswählen
import cv2
print(cv2.__version__) # output 4.5.1
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/schda/Dropbox/Studium - Informatik/02 Master of Science/1. Semester - SS21/Seminar/mySeminar/yolo_webcam.py", line 5, in <module>
from imageai import Detection
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\imageai\Detection\__init__.py", line 8, in <module>
import tensorflow as tf
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\schda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Vielen Dank.
mfg werdas34