PKaushik commited on
Commit
65d9523
1 Parent(s): 4ee00b7
Files changed (1) hide show
  1. yolov6/utils/general.py +24 -0
yolov6/utils/general.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding:utf-8 -*-
3
+ import os
4
+ import glob
5
+ from pathlib import Path
6
+
7
+ def increment_name(path):
8
+ "increase save directory's id"
9
+ path = Path(path)
10
+ sep = ''
11
+ if path.exists():
12
+ path, suffix = (path.with_suffix(''), path.suffix) if path.is_file() else (path, '')
13
+ for n in range(1, 9999):
14
+ p = f'{path}{sep}{n}{suffix}'
15
+ if not os.path.exists(p):
16
+ break
17
+ path = Path(p)
18
+ return path
19
+
20
+
21
+ def find_latest_checkpoint(search_dir='.'):
22
+ # Find the most recent saved checkpoint in search_dir
23
+ checkpoint_list = glob.glob(f'{search_dir}/**/last*.pt', recursive=True)
24
+ return max(checkpoint_list, key=os.path.getctime) if checkpoint_list else ''