OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.5k stars 2.19k forks source link

detectObjectsFromImage issue #156

Closed zane-commeatio closed 5 years ago

zane-commeatio commented 5 years ago

Hi, i'm trying to run a detection from a jpg file, after commenting the Try Except i have this traceback

  File "<ipython-input-92-4df8d236dd80>", line 11, in <module>
    detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "square1.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))

  File "C:\Users\antho\Anaconda3\lib\site-packages\imageai\Detection\__init__.py", line 327, in detectObjectsFromImage
    _, _, detections = model.predict_on_batch(np.expand_dims(image, axis=0))

  File "C:\Users\antho\Anaconda3\lib\site-packages\keras\engine\training.py", line 1274, in predict_on_batch
    outputs = self.predict_function(ins)

  File "C:\Users\antho\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)

  File "C:\Users\antho\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)

  File "C:\Users\antho\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1439, in __call__
    run_metadata_ptr)

  File "C:\Users\antho\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))

InternalError: WhereOp: Could not launch cub::DeviceReduce::Sum to count number of true / nonzero indices.  temp_storage_bytes: 1279, status: invalid configuration argument
     [[{{node nms_7/Where_4}} = Where[T=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0"](nms_7/Greater_4)]]

And here is my code

from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()

detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "square1.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))

for eachObject in detections:
    print(eachObject["name"] , " : " , eachObject["percentage_probability"] )

obviously my .jpg file is in the same folder than my .py file

Thanks for the help !

OlafenwaMoses commented 5 years ago

Kindly visit the thread linked below on the error.

https://github.com/tensorflow/serving/issues/627