|
33 | 33 | import atexit
|
34 | 34 | import subprocess
|
35 | 35 | import rich.progress
|
| 36 | +from queue import Empty |
36 | 37 | import pandas as pd
|
37 | 38 | from rich.pretty import pprint
|
38 | 39 | from collections import deque
|
@@ -424,8 +425,11 @@ def process_batch(ex):
|
424 | 425 | "{task.description}",
|
425 | 426 | rich.progress.BarColumn(),
|
426 | 427 | "[progress.percentage]{task.percentage:>3.0f}%",
|
| 428 | + rich.progress.MofNCompleteColumn(), |
427 | 429 | "ETA:",
|
428 | 430 | rich.progress.TimeRemainingColumn(),
|
| 431 | + "Elapsed:", |
| 432 | + rich.progress.TimeElapsedColumn(), |
429 | 433 | RateColumn(),
|
430 | 434 | auto_refresh=False,
|
431 | 435 | refresh_per_second=self.report_rate,
|
@@ -1555,9 +1559,26 @@ def _make_labeled_frames_from_generator(
|
1555 | 1559 | predicted_frames = []
|
1556 | 1560 |
|
1557 | 1561 | def _object_builder():
|
| 1562 | + n_timeouts = 0 |
1558 | 1563 | while True:
|
1559 |
| - ex = prediction_queue.get() |
| 1564 | + try: |
| 1565 | + # Get the next example from the queue. |
| 1566 | + ex = prediction_queue.get(timeout=10) |
| 1567 | + |
| 1568 | + except Empty: |
| 1569 | + n_timeouts += 1 |
| 1570 | + if n_timeouts >= 3: |
| 1571 | + # Too many timeouts, exit. |
| 1572 | + print( |
| 1573 | + "Timeout waiting for prediction queue, " |
| 1574 | + "exiting prediction loop." |
| 1575 | + ) |
| 1576 | + break |
| 1577 | + continue |
| 1578 | + |
1560 | 1579 | if ex is None:
|
| 1580 | + # Poison pill, exit. |
| 1581 | + print("Got poison pill, exiting prediction loop.") |
1561 | 1582 | break
|
1562 | 1583 |
|
1563 | 1584 | # Loop over frames.
|
@@ -1610,6 +1631,10 @@ def _object_builder():
|
1610 | 1631 | prediction_queue.put(None)
|
1611 | 1632 | object_builder.join()
|
1612 | 1633 |
|
| 1634 | + print( |
| 1635 | + f"Finished building {len(predicted_frames):,} predicted frames.", flush=True |
| 1636 | + ) |
| 1637 | + |
1613 | 1638 | return predicted_frames
|
1614 | 1639 |
|
1615 | 1640 | def export_model(
|
@@ -2617,9 +2642,26 @@ def _make_labeled_frames_from_generator(
|
2617 | 2642 | predicted_frames = []
|
2618 | 2643 |
|
2619 | 2644 | def _object_builder():
|
| 2645 | + n_timeouts = 0 |
2620 | 2646 | while True:
|
2621 |
| - ex = prediction_queue.get() |
| 2647 | + try: |
| 2648 | + # Get the next example from the queue. |
| 2649 | + ex = prediction_queue.get(timeout=10) |
| 2650 | + |
| 2651 | + except Empty: |
| 2652 | + n_timeouts += 1 |
| 2653 | + if n_timeouts >= 3: |
| 2654 | + # Too many timeouts, exit. |
| 2655 | + print( |
| 2656 | + "Timeout waiting for prediction queue, " |
| 2657 | + "exiting prediction loop." |
| 2658 | + ) |
| 2659 | + break |
| 2660 | + continue |
| 2661 | + |
2622 | 2662 | if ex is None:
|
| 2663 | + # Poison pill, exit. |
| 2664 | + print("Got poison pill, exiting prediction loop.") |
2623 | 2665 | break
|
2624 | 2666 |
|
2625 | 2667 | if "n_valid" in ex:
|
@@ -2699,8 +2741,15 @@ def _object_builder():
|
2699 | 2741 | prediction_queue.put(None)
|
2700 | 2742 | object_builder.join()
|
2701 | 2743 |
|
| 2744 | + print( |
| 2745 | + f"Finished building {len(predicted_frames):,} predicted frames.", flush=True |
| 2746 | + ) |
| 2747 | + |
2702 | 2748 | if self.tracker:
|
| 2749 | + t0 = time() |
| 2750 | + print("Starting final pass of the tracker...", flush=True) |
2703 | 2751 | self.tracker.final_pass(predicted_frames)
|
| 2752 | + print(f"Finished final pass of the tracker in {time() - t0:.2f} seconds.") |
2704 | 2753 |
|
2705 | 2754 | return predicted_frames
|
2706 | 2755 |
|
@@ -3253,9 +3302,26 @@ def _make_labeled_frames_from_generator(
|
3253 | 3302 | predicted_frames = []
|
3254 | 3303 |
|
3255 | 3304 | def _object_builder():
|
| 3305 | + n_timeouts = 0 |
3256 | 3306 | while True:
|
3257 |
| - ex = prediction_queue.get() |
| 3307 | + try: |
| 3308 | + # Get the next example from the queue. |
| 3309 | + ex = prediction_queue.get(timeout=10) |
| 3310 | + |
| 3311 | + except Empty: |
| 3312 | + n_timeouts += 1 |
| 3313 | + if n_timeouts >= 3: |
| 3314 | + # Too many timeouts, exit. |
| 3315 | + print( |
| 3316 | + "Timeout waiting for prediction queue, " |
| 3317 | + "exiting prediction loop." |
| 3318 | + ) |
| 3319 | + break |
| 3320 | + continue |
| 3321 | + |
3258 | 3322 | if ex is None:
|
| 3323 | + # Poison pill, exit. |
| 3324 | + print("Got poison pill, exiting prediction loop.") |
3259 | 3325 | break
|
3260 | 3326 |
|
3261 | 3327 | if "n_valid" in ex:
|
@@ -3342,8 +3408,15 @@ def _object_builder():
|
3342 | 3408 | prediction_queue.put(None)
|
3343 | 3409 | object_builder.join()
|
3344 | 3410 |
|
| 3411 | + print( |
| 3412 | + f"Finished building {len(predicted_frames):,} predicted frames.", flush=True |
| 3413 | + ) |
| 3414 | + |
3345 | 3415 | if self.tracker:
|
| 3416 | + t0 = time() |
| 3417 | + print("Starting final pass of the tracker...", flush=True) |
3346 | 3418 | self.tracker.final_pass(predicted_frames)
|
| 3419 | + print(f"Finished final pass of the tracker in {time() - t0:.2f} seconds.") |
3347 | 3420 |
|
3348 | 3421 | return predicted_frames
|
3349 | 3422 |
|
@@ -3792,10 +3865,27 @@ def _make_labeled_frames_from_generator(
|
3792 | 3865 | predicted_frames = []
|
3793 | 3866 |
|
3794 | 3867 | def _object_builder():
|
| 3868 | + n_timeouts = 0 |
3795 | 3869 | while True:
|
3796 |
| - ex = prediction_queue.get() |
| 3870 | + try: |
| 3871 | + # Get the next example from the queue. |
| 3872 | + ex = prediction_queue.get(timeout=10) |
| 3873 | + |
| 3874 | + except Empty: |
| 3875 | + n_timeouts += 1 |
| 3876 | + if n_timeouts >= 3: |
| 3877 | + # Too many timeouts, exit. |
| 3878 | + print( |
| 3879 | + "Timeout waiting for prediction queue, " |
| 3880 | + "exiting prediction loop." |
| 3881 | + ) |
| 3882 | + break |
| 3883 | + continue |
| 3884 | + |
3797 | 3885 | if ex is None:
|
3798 |
| - return |
| 3886 | + # Poison pill, exit. |
| 3887 | + print("Got poison pill, exiting prediction loop.") |
| 3888 | + break |
3799 | 3889 |
|
3800 | 3890 | # Loop over frames.
|
3801 | 3891 | for image, video_ind, frame_ind, points, confidences, scores in zip(
|
@@ -3857,6 +3947,10 @@ def _object_builder():
|
3857 | 3947 | prediction_queue.put(None)
|
3858 | 3948 | object_builder.join()
|
3859 | 3949 |
|
| 3950 | + print( |
| 3951 | + f"Finished building {len(predicted_frames):,} predicted frames.", flush=True |
| 3952 | + ) |
| 3953 | + |
3860 | 3954 | return predicted_frames
|
3861 | 3955 |
|
3862 | 3956 |
|
@@ -4499,9 +4593,26 @@ def _make_labeled_frames_from_generator(
|
4499 | 4593 | predicted_frames = []
|
4500 | 4594 |
|
4501 | 4595 | def _object_builder():
|
| 4596 | + n_timeouts = 0 |
4502 | 4597 | while True:
|
4503 |
| - ex = prediction_queue.get() |
| 4598 | + try: |
| 4599 | + # Get the next example from the queue. |
| 4600 | + ex = prediction_queue.get(timeout=10) |
| 4601 | + |
| 4602 | + except Empty: |
| 4603 | + n_timeouts += 1 |
| 4604 | + if n_timeouts >= 3: |
| 4605 | + # Too many timeouts, exit. |
| 4606 | + print( |
| 4607 | + "Timeout waiting for prediction queue, " |
| 4608 | + "exiting prediction loop." |
| 4609 | + ) |
| 4610 | + break |
| 4611 | + continue |
| 4612 | + |
4504 | 4613 | if ex is None:
|
| 4614 | + # Poison pill, exit. |
| 4615 | + print("Got poison pill, exiting prediction loop.") |
4505 | 4616 | break
|
4506 | 4617 |
|
4507 | 4618 | # Loop over frames.
|
@@ -4573,6 +4684,10 @@ def _object_builder():
|
4573 | 4684 | prediction_queue.put(None)
|
4574 | 4685 | object_builder.join()
|
4575 | 4686 |
|
| 4687 | + print( |
| 4688 | + f"Finished building {len(predicted_frames):,} predicted frames.", flush=True |
| 4689 | + ) |
| 4690 | + |
4576 | 4691 | return predicted_frames
|
4577 | 4692 |
|
4578 | 4693 | def export_model(
|
@@ -4801,9 +4916,26 @@ def _make_labeled_frames_from_generator(
|
4801 | 4916 | predicted_frames = []
|
4802 | 4917 |
|
4803 | 4918 | def _object_builder():
|
| 4919 | + n_timeouts = 0 |
4804 | 4920 | while True:
|
4805 |
| - ex = prediction_queue.get() |
| 4921 | + try: |
| 4922 | + # Get the next example from the queue. |
| 4923 | + ex = prediction_queue.get(timeout=10) |
| 4924 | + |
| 4925 | + except Empty: |
| 4926 | + n_timeouts += 1 |
| 4927 | + if n_timeouts >= 3: |
| 4928 | + # Too many timeouts, exit. |
| 4929 | + print( |
| 4930 | + "Timeout waiting for prediction queue, " |
| 4931 | + "exiting prediction loop." |
| 4932 | + ) |
| 4933 | + break |
| 4934 | + continue |
| 4935 | + |
4806 | 4936 | if ex is None:
|
| 4937 | + # Poison pill, exit. |
| 4938 | + print("Got poison pill, exiting prediction loop.") |
4807 | 4939 | break
|
4808 | 4940 |
|
4809 | 4941 | # Loop over frames.
|
@@ -4859,6 +4991,10 @@ def _object_builder():
|
4859 | 4991 | prediction_queue.put(None)
|
4860 | 4992 | object_builder.join()
|
4861 | 4993 |
|
| 4994 | + print( |
| 4995 | + f"Finished building {len(predicted_frames):,} predicted frames.", flush=True |
| 4996 | + ) |
| 4997 | + |
4862 | 4998 | return predicted_frames
|
4863 | 4999 |
|
4864 | 5000 |
|
|
0 commit comments