Advertisement
slik1977

AllObjectsDetection v 1.0

Feb 20th, 2022
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import os
  2. os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
  3. from pixellib.instance import instance_segmentation
  4. from exif import Image
  5. import cv2
  6.  
  7.  
  8. def object_detection_on_an_image():
  9.     segment_image = instance_segmentation()
  10.     segment_image.load_model("C:/Users/dellx/PycharmProjects/pythonProject6/mask_rcnn_coco.h5")
  11.  
  12.     #target_class = segment_image.select_target_classes(tree=True)
  13.     result = segment_image.segmentImage(
  14.         image_path="img/pic9.jpg",
  15.         show_bboxes=True,
  16.         # segment_target_classes=target_class,
  17.         # extract_segmented_objects=True,
  18.         # save_extracted_objects=True,
  19.         output_image_name="output.jpg"
  20.     )
  21.  
  22.     # print(result[0]["scores"])
  23.     objects_count = len(result[0]["scores"])
  24.     print(f"founded: {objects_count}")
  25.  
  26.  
  27. def main():
  28.     object_detection_on_an_image()
  29.  
  30.  
  31. if __name__ == '__main__':
  32.     main()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement