ipykernel
ipykernel copied to clipboard
FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
I write and run this code in Jupyter notebook.
with detection_graph.as_default():
with tf.Session(graph=detection_graph) as sess:
# Definite input and output Tensors for detection_graph
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
count1 = 0
count2 = 0
for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
try :
for orientation in ExifTags.TAGS.keys() :
if ExifTags.TAGS[orientation]=='Orientation' : break
exif=dict(image._getexif().items())
if exif[orientation] == 3 :
image=image.rotate(180, expand=True)
elif exif[orientation] == 6 :
image=image.rotate(270, expand=True)
elif exif[orientation] == 8 :
image=image.rotate(90, expand=True)
except:
print('no rotation')
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
objects = vis_util.visualize_boxes_and_labels_on_image_array(image_np,np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
if 'style' not object :
print(os.path.join(PATH_TO_TEST_IMAGES_DIR, 'not detected', '%04d.jpg' % count2))
imageio.imwrite(os.path.join(PATH_TO_TEST_IMAGES_DIR, 'not detected', '%04d.jpg' % count2),image_np)
count2 += 1
else:
print(os.path.join(PATH_TO_TEST_IMAGES_DIR, 'detected', '%04d.jpg' % count1))
imageio.imwrite(os.path.join(PATH_TO_TEST_IMAGES_DIR, 'detected', '%04d.jpg' % count1),image_np)
count1 += 1
and show error :
C:\Users\Dhito\Anaconda3\lib\site-packages\ipykernel_launcher.py:47: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
'style' was a name for image label. here is my system information :
'ipython_version': '6.4.0', 'os_name': 'nt', 'platform': 'Windows-10-1', 'sys_executable': 'C:\Users\Dhito\Anaconda3\python.exe', 'sys_platform': 'win32', 'sys_version': '3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) 64bit\
Anyone know where is the problem?
Solved with change:
print(classes)
if 39 is not in classes :