Closed spurani closed 3 years ago
This is likely because: (a) you have specified --num-classes 3
, (b) but the model actually outputs a class id which is greater than or equal to 3.
{0: 'CLS0', 1: 'bottle', 2: 'cardboard', 3: 'clothing'}
this is the list of the classes in cls_dict so I changed --num-classes 4
still it didn't work. I am not sure about 0: 'CLS0'
is that for background? I can see this class gets added here along with the classes from label file /home/s/projects/tf_trt_models/utils/od_utils.py
def read_label_map(path_to_labels):
"""Read from the label map file and return a class dictionary which
maps class id (int) to the corresponding display name (string).
Reference:
https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
"""
from object_detection.utils import label_map_util
category_index = label_map_util.create_category_index_from_labelmap(
path_to_labels)
cls_dict = {int(x['id']): x['name'] for x in category_index.values()}
num_classes = max(c for c in cls_dict.keys()) + 1
# add missing classes as, say,'CLS12' if any
return {i: cls_dict.get(i, 'CLS{}'.format(i)) for i in range(num_classes)}
Can you please guide me through this? thank you
Sorry, the "--num_classes" command-line option is deprecated and not used. The code actually determines number of object classes by reading the labelmap file.
{0: 'CLS0', 1: 'bottle', 2: 'cardboard', 3: 'clothing'} this is the list of the classes in cls_dict so I changed --num-classes 4 still it didn't work. I am not sure about 0: 'CLS0' is that for background?
Yes, class id 0 of SSD models usually refers to the "background" class.
To debug the issue, please add a print() statement (or use pdb) to see what cls
value your model outputs. For example, add a print() after this line.
if cls > 3: print('ERROR: cls id is ', cls)
Hi I am getting this error
Gtk-Message: 15:23:01.286: Failed to load module "canberra-gtk-module"
Traceback (most recent call last):
File "camera_tf_trt.py", line 202, in <module>
main()
File "camera_tf_trt.py", line 192, in main
loop_and_detect(cam, tf_sess, args.conf_th, vis, od_type=od_type)
File "camera_tf_trt.py", line 126, in loop_and_detect
cv2.imshow(WINDOW_NAME, img)
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
Can you please guide me how to fix it?
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
This error message indicates the image you called cv2.imshow()
with is not valid. You could use, say, pdb to check what might have gone wrong.
Hi, Here is the command which I am executing for real time object detection using jetson tx2 onboard camera. After I execute this command I can see the my tf-trt graph.pb it loads successfully then I can see my webcam output which is inverted and after few seconds it freezes and throws the errror below. Can you please guide me through this so that i can continue learning these concepts and understand it? I have exactly 3 classes in my label file
python3 camera_tf_trt.py --latency 200 --model new_model_ssd_colab_v2_mobilenet_2020_29_12 --labelmap data/label_final.pbtxt --num-classes 3 --build
INFO:main:warming up the TRT graph with a dummy image INFO:main:starting to loop and detect Gtk-Message: 02:24:07.146: Failed to load module "canberra-gtk-module" Traceback (most recent call last): File "camera_tf_trt.py", line 198, in
main()
File "camera_tf_trt.py", line 188, in main
loop_and_detect(cam, tf_sess, args.conf_th, vis, od_type=od_type)
File "camera_tf_trt.py", line 120, in loop_and_detect
img = vis.draw_bboxes(img, box, conf, cls)
File "/home/s/projects/tf_trt_models/utils/visualization.py", line 96, in draw_bboxes
color = self.colors[cl]
IndexError: list index out of range
Killed
Thank you really great tutorial I am learning a lot. Please let me know if you require more details