forked from UGA-BSAIL/cotton_flower_mot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_image_to_annotate.py
More file actions
78 lines (63 loc) · 1.65 KB
/
copy_image_to_annotate.py
File metadata and controls
78 lines (63 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
A convenient helper script that selects and copies images
to use for active learning.
"""
import argparse
import shutil
from pathlib import Path
import yaml
def _make_parser() -> argparse.ArgumentParser:
"""
Returns:
The parser for CLI arguments.
"""
parser = argparse.ArgumentParser(
description="Copies files for active learning."
)
parser.add_argument(
"-b",
"--base-dir",
type=Path,
default=Path("data/05_model_input/mars_multi_camera"),
help="The base path of the MARS image dataset.",
)
parser.add_argument(
"-l",
"--image-list",
type=Path,
default=Path("data/08_reporting/image_order.yml"),
help="The path to the image ordering file.",
)
parser.add_argument(
"-o",
"--output",
type=Path,
default=Path("images"),
help="The output directory.",
)
parser.add_argument(
"-s",
"--start",
type=int,
default=0,
help="The image number to start at.",
)
parser.add_argument(
"-n",
"--num-images",
type=int,
required=True,
help="The number of images to copy.",
)
return parser
def main() -> None:
parser = _make_parser()
args = parser.parse_args()
with open(args.image_list) as f:
image_list = yaml.safe_load(f)
args.output.mkdir(exist_ok=True)
for i in range(args.start, args.start + args.num_images):
image_path = args.base_dir / f"{image_list[i]}.jpg"
shutil.copy(image_path, args.output / image_path.name)
if __name__ == "__main__":
main()