Added --skip-existing-day to when using --daily to skip day already done
This commit is contained in:
@@ -128,7 +128,7 @@ def load_frames(zip_path: Path, max_frames: int):
|
||||
# MAIN APP
|
||||
# ─────────────────────────────────────────────
|
||||
class Annotator(QMainWindow):
|
||||
def __init__(self, data_dir: Path, out_dir: Path, clip: str = None, target_time: str = None, daily: bool = False, extras: bool = False):
|
||||
def __init__(self, data_dir: Path, out_dir: Path, clip: str = None, target_time: str = None, daily: bool = False, extras: bool = False, skip_existing_day: bool = False):
|
||||
super().__init__()
|
||||
|
||||
self.data_dir = Path(data_dir)
|
||||
@@ -136,6 +136,7 @@ class Annotator(QMainWindow):
|
||||
self.target_time = target_time
|
||||
self.daily = daily
|
||||
self.extras = extras
|
||||
self.skip_existing_day = skip_existing_day
|
||||
self.current_date = None
|
||||
|
||||
self.history = []
|
||||
@@ -214,6 +215,15 @@ class Annotator(QMainWindow):
|
||||
next_date = self.current_date + datetime.timedelta(days=1)
|
||||
df_remaining = df_remaining[df_remaining["date"] >= next_date]
|
||||
|
||||
# In daily mode, skip entire days that already have any annotated clip
|
||||
if self.daily and self.skip_existing_day:
|
||||
annotated_dates = set()
|
||||
for f in self.df["filename"]:
|
||||
if (self.out_dir / f.stem / "mask.png").exists():
|
||||
dt = self.df[self.df["filename"] == f]["datetime"].values[0]
|
||||
annotated_dates.add(pd.Timestamp(dt).date())
|
||||
df_remaining = df_remaining[~df_remaining["date"].isin(annotated_dates)]
|
||||
|
||||
if df_remaining.empty:
|
||||
raise RuntimeError("No remaining clips to annotate")
|
||||
|
||||
@@ -579,6 +589,7 @@ def parse_args():
|
||||
parser.add_argument("--time", default=None, help="Target time to filter clips by day (format: HH:MM, e.g. '14:30'). Selects the closest clip to this time for each day.")
|
||||
parser.add_argument("--daily", action="store_true", help="Load only 1 clip per day at the specified time (requires --time).")
|
||||
parser.add_argument("--extras", action="store_true", help="Also save GIFs, frame PNG, overlay PNG, and mask_vis PNG alongside the mask.")
|
||||
parser.add_argument("--skip-existing-day", action="store_true", help="In --daily mode, skip days that already have any annotated clip.")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -587,7 +598,7 @@ if __name__ == "__main__":
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
win = Annotator(Path(args.data), Path(args.out), clip=args.clip, target_time=args.time, daily=args.daily, extras=args.extras)
|
||||
win = Annotator(Path(args.data), Path(args.out), clip=args.clip, target_time=args.time, daily=args.daily, extras=args.extras, skip_existing_day=args.skip_existing_day)
|
||||
win.show()
|
||||
|
||||
app.exec()
|
||||
|
||||
Reference in New Issue
Block a user