Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectDetection exception: int() argument must be a string, a bytes-like object or a number, not 'NoneType' #35

Closed
Airyzf opened this issue Jul 18, 2018 · 5 comments

Comments

@Airyzf
Copy link

Airyzf commented Jul 18, 2018

C:\Users\admin\Anaconda3\python.exe D:/tensorflow/pyimages/detect.py
C:\Users\admin\Anaconda3\lib\site-packages\h5py_init_.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as register_converters
Using TensorFlow backend.
Traceback (most recent call last):
File "D:/tensorflow/pyimages/day2-object-detect/detect.py", line 9, in
detector.loadModel(detection_speed="fast")
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection_init
.py", line 121, in loadModel
model = resnet50_retinanet(num_classes=80)
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection\keras_retinanet\models\resnet.py", line 86, in resnet50_retinanet
return resnet_retinanet(num_classes=num_classes, backbone='resnet50', inputs=inputs, **kwargs)
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection\keras_retinanet\models\resnet.py", line 80, in resnet_retinanet
model = retinanet.retinanet_bbox(inputs=inputs, num_classes=num_classes, backbone=resnet, **kwargs)
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection\keras_retinanet\models\retinanet.py", line 347, in retinanet_bbox
model = retinanet(inputs=inputs, num_classes=num_classes, **kwargs)
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection\keras_retinanet\models\retinanet.py", line 302, in retinanet
submodels = default_submodels(num_classes, anchor_parameters)
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection\keras_retinanet\models\retinanet.py", line 210, in default_submodels
('regression', default_regression_model(anchor_parameters.num_anchors())),
File "C:\Users\admin\Anaconda3\lib\site-packages\imageai\Detection\keras_retinanet\models\retinanet.py", line 125, in default_regression_model
outputs = keras.layers.Reshape((-1, 4), name='pyramid_regression_reshape')(outputs)
File "C:\Users\admin\Anaconda3\lib\site-packages\keras\engine\topology.py", line 602, in call
output = self.call(inputs, **kwargs)
File "C:\Users\admin\Anaconda3\lib\site-packages\keras\layers\core.py", line 391, in call
target_shape = self.compute_output_shape(input_shape)[1:]
File "C:\Users\admin\Anaconda3\lib\site-packages\keras\layers\core.py", line 376, in compute_output_shape
input_shape[1:], self.target_shape)
File "C:\Users\admin\Anaconda3\lib\site-packages\keras\layers\core.py", line 364, in _fix_unknown_dimension
original = np.prod(input_shape, dtype=int)
File "C:\Users\admin\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 2566, in prod
out=out, **kwargs)
File "C:\Users\admin\Anaconda3\lib\site-packages\numpy\core_methods.py", line 35, in _prod
return umr_prod(a, axis, dtype, out, keepdims)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

I copy the ObjectDetection demo codes and run, but it throws this exception.

@OlafenwaMoses
Copy link
Owner

Hello, did you ensure you downloaded the correct model file, set the correct model type and set the correct model path to the model file you downloaded? Ensure all of this is done before running your python code.

@Airyzf
Copy link
Author

Airyzf commented Jul 23, 2018

This is python code, resnet50_coco_best_v2.0.1.h5 model file in models folder

from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
model_path = os.path.join(execution_path, "models\resnet50_coco_best_v2.0.1.h5")
print("model path : {}".format(model_path))

detector.setModelPath(model_path)

img_path = os.path.join(execution_path, "image\5.jpg")
print("img path : {}".format(img_path))

detector.loadModel()

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

for eachObject in detections:
print(eachObject["name"] + " : " + eachObject["percentage_probability"])
print("--------------------------------")``

@OlafenwaMoses
Copy link
Owner

Please see discussion here #30

@Airyzf
Copy link
Author

Airyzf commented Jul 24, 2018

ok,thanks

@kushu9999
Copy link

i got this type of error anyone knows how to solve please tell me i searching about it's solution lasst 3 days , i applied all things but it didn't solved

TypeError Traceback (most recent call last)
in ()
83 (boxes, scores, classes, num) = sess.run(
84 [detection_boxes, detection_scores, detection_classes, num_detections],
---> 85 feed_dict={image_tensor: frame_expanded})
86
87 # Draw the results of the detection (aka 'visulaize the results')

2 frames
/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
83
84 """
---> 85 return array(a, dtype, copy=False, order=order)
86
87

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants