nicknochnack / RealTimeObjectDetection

368 stars 583 forks source link

```TypeError: expected string or bytes-like object``` in "8. Detect in Real-Time" #4

Open Meharaj002 opened 3 years ago

Meharaj002 commented 3 years ago

TypeError Traceback (most recent call last)

in 23 image_np_with_detections = image_np.copy() 24 ---> 25 viz_utils.visualize_boxes_and_labels_on_image_array( 26 image_np_with_detections, 27 detections['detection_boxes'], ~\anaconda3\lib\site-packages\object_detection\utils\visualization_utils.py in visualize_boxes_and_labels_on_image_array(image, boxes, classes, scores, category_index, instance_masks, instance_boundaries, keypoints, keypoint_scores, keypoint_edges, track_ids, use_normalized_coordinates, max_boxes_to_draw, min_score_thresh, agnostic_mode, line_thickness, mask_alpha, groundtruth_box_visualization_color, skip_boxes, skip_scores, skip_labels, skip_track_ids) 1245 alpha=1.0 1246 ) -> 1247 draw_bounding_box_on_image_array( 1248 image, 1249 ymin, ~\anaconda3\lib\site-packages\object_detection\utils\visualization_utils.py in draw_bounding_box_on_image_array(image, ymin, xmin, ymax, xmax, color, thickness, display_str_list, use_normalized_coordinates) 158 """ 159 image_pil = Image.fromarray(np.uint8(image)).convert('RGB') --> 160 draw_bounding_box_on_image(image_pil, ymin, xmin, ymax, xmax, color, 161 thickness, display_str_list, 162 use_normalized_coordinates) ~\anaconda3\lib\site-packages\object_detection\utils\visualization_utils.py in draw_bounding_box_on_image(image, ymin, xmin, ymax, xmax, color, thickness, display_str_list, use_normalized_coordinates) 210 fill=color) 211 try: --> 212 font = ImageFont.truetype('arial.ttf', 24) 213 except IOError: 214 font = ImageFont.load_default() ~\anaconda3\lib\site-packages\PIL\ImageFont.py in truetype(font, size, index, encoding, layout_engine) 850 851 try: --> 852 return freetype(font) 853 except OSError: 854 if not isPath(font): ~\anaconda3\lib\site-packages\PIL\ImageFont.py in freetype(font) 847 848 def freetype(font): --> 849 return FreeTypeFont(font, size, index, encoding, layout_engine) 850 851 try: ~\anaconda3\lib\site-packages\PIL\ImageFont.py in __init__(self, font, size, index, encoding, layout_engine) 171 pass 172 else: --> 173 freetype_version = parse_version(features.version_module("freetype2")) 174 if freetype_version < parse_version("2.8"): 175 warnings.warn( ~\anaconda3\lib\site-packages\packaging\version.py in parse(version) 54 """ 55 try: ---> 56 return Version(version) 57 except InvalidVersion: 58 return LegacyVersion(version) ~\anaconda3\lib\site-packages\packaging\version.py in __init__(self, version) 273 274 # Validate the version and parse it into pieces --> 275 match = self._regex.search(version) 276 if not match: 277 raise InvalidVersion("Invalid version: '{0}'".format(version)) TypeError: expected string or bytes-like object
Meharaj002 commented 3 years ago

hey! nick bro! love your teaching method! I'm facing this error! so expecting your kind help here @nicknochnack

nicknochnack commented 3 years ago

Looks like an issue with the input feed. What do you get if you print out image_np?

Meharaj002 commented 3 years ago

[[[8 8 8] [8 8 8] [8 8 8] ... [8 8 8] [8 8 8] [8 8 8]]

[[8 8 8] [8 8 8] [8 8 8] ... [8 8 8] [8 8 8] [8 8 8]]

[[8 8 8] [8 8 8] [8 8 8] ... [8 8 8] [8 8 8] [8 8 8]]

...

[[8 8 8] [8 8 8] [8 8 8] ... [8 8 8] [8 8 8] [8 8 8]]

[[8 8 8] [8 8 8] [8 8 8] ... [8 8 8] [8 8 8] [8 8 8]]

[[8 8 8] [8 8 8] [8 8 8] ... [8 8 8] [8 8 8] [8 8 8]]]

this is the print output of image_np before throwing error @nicknochnack

nicknochnack commented 3 years ago

Is your webcam activating? Can you also try restarting the kernel and just rerunning the detection code?

Meharaj002 commented 3 years ago

yes! the webcam turns on when i use jupyer notebook but the moment I put my hand I gets stuck and through error! also tried to rerun !

i tried in vscode also gives same error! but in vscode the camera turns on but cv2's frame don't turnon @nicknochnack

Meharaj002 commented 3 years ago

hey @nicknochnack bro! can you help me to solve it! any suggestion which I can try!

before giving the image_np output this>>>


2021-02-16 21:05:05.961641: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-02-16 21:05:05.973190: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2021-02-16 21:05:05.991176: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2021-02-16 21:05:06.006007: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-ED2GVQI
2021-02-16 21:05:06.037053: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-ED2GVQI
2021-02-16 21:05:06.124778: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-02-16 21:05:06.692467: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
[[[106 139  56]
  [105 137  55]
  [107 135  51]
  ...   ```

line prints out in vscode
Meharaj002 commented 3 years ago

hey bro @nicknochnack can you give me a suggestion about what can I do?