(.venv) oleg@MacBook-Pro-Oleg 007_beet-detect % python -m memory_profiler beet-detect.py
8.899948120117188 sec
Count MASKS 83
Filename: beet-detect.py
Line # Mem usage Increment Occurrences Line Contents
=============================================================
12 240.391 MiB 240.391 MiB 1 @profile
13 def run_segment():
14 276.656 MiB 36.266 MiB 1 img = np.float32(cv2.imread('2023.12.10 (14_28_54)ishod.jpg'))
15
16 276.656 MiB 0.000 MiB 1 sam_checkpoint = "sam_vit_b_01ec64.pth"
17 276.656 MiB 0.000 MiB 1 model_type = "vit_b"
18 276.656 MiB 0.000 MiB 1 device = "cpu"
19
20 906.344 MiB 629.688 MiB 1 sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
21 906.422 MiB 0.078 MiB 1 sam.to(device=device)
22
23 906.438 MiB 0.016 MiB 2 mask_generator = SamAutomaticMaskGenerator(
24 906.422 MiB 0.000 MiB 1 sam,
25 906.422 MiB 0.000 MiB 1 points_per_batch = 8,
26 906.422 MiB 0.000 MiB 1 points_per_side = 8,
27 906.422 MiB 0.000 MiB 1 pred_iou_thresh = 0.2,
28 906.422 MiB 0.000 MiB 1 stability_score_thresh = 0.7
29 )
30
31
32 906.438 MiB 0.000 MiB 1 time_begin = time.time()
33 1465.719 MiB 559.281 MiB 1 masks = mask_generator.generate(img)
34 1465.922 MiB 0.203 MiB 1 print(time.time() - time_begin, 'sec')
35 1465.938 MiB 0.016 MiB 1 print('Count MASKS', len(masks))
(.venv) oleg@MacBook-Pro-Oleg 007_beet-detect % python -m memory_profiler beet-detect.py
17.080801010131836 sec
Count MASKS 83
Filename: beet-detect.py
Line # Mem usage Increment Occurrences Line Contents
=============================================================
12 276.406 MiB 276.406 MiB 1 @profile
13 def run_segment():
14 312.625 MiB 36.219 MiB 1 img = np.float32(cv2.imread('2023.12.10 (14_28_54)ishod.jpg'))
15
16 312.625 MiB 0.000 MiB 1 sam_checkpoint = "sam_vit_b_01ec64.pth"
17 312.625 MiB 0.000 MiB 1 model_type = "vit_b"
18 312.625 MiB 0.000 MiB 1 device = "cpu"
19
20 935.047 MiB 622.422 MiB 1 sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
21 935.125 MiB 0.078 MiB 1 sam.to(device=device)
22
23 935.125 MiB 0.000 MiB 2 mask_generator = SamAutomaticMaskGenerator(
24 935.125 MiB 0.000 MiB 1 sam,
25 935.125 MiB 0.000 MiB 1 points_per_batch = 8,
26 935.125 MiB 0.000 MiB 1 points_per_side = 8,
27 935.125 MiB 0.000 MiB 1 pred_iou_thresh = 0.2,
28 935.125 MiB 0.000 MiB 1 stability_score_thresh = 0.7
29 )
30
31
32 935.125 MiB 0.000 MiB 1 time_begin = time.time()
33 1541.625 MiB 606.500 MiB 1 masks = mask_generator.generate(img)
34 1541.703 MiB 0.078 MiB 1 print(time.time() - time_begin, 'sec')
35 1541.719 MiB 0.016 MiB 1 print('Count MASKS', len(masks))