-
Notifications
You must be signed in to change notification settings - Fork 6
/
generate_ground_truth.py
83 lines (68 loc) · 2.25 KB
/
generate_ground_truth.py
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
79
80
81
82
83
import argparse
import logging
import pickle
from pathlib import Path
from pdb import set_trace
import coloredlogs
import enlighten
import networkx as nx
import torch
import yaml
from torchvision import io
from dnn.fasterrcnn_resnet50 import FasterRCNN_ResNet50_FPN
from utils.bbox_utils import jaccard
from utils.results_utils import clean_results, read_results, write_results
from utils.video_utils import read_bandwidth
def main(args):
logger = logging.getLogger("merge")
handler = logging.NullHandler()
logger.addHandler(handler)
application_bundle = [FasterRCNN_ResNet50_FPN()]
for application in application_bundle:
input_results = [
read_results(vname, application.name, logger) for vname in args.inputs
]
ground_truth_result = read_results(args.ground_truth, application.name, logger)
ground_truth_result = clean_results(
ground_truth_result, input_results, application, args
)
write_results(args.output, application.name, ground_truth_result, logger)
if __name__ == "__main__":
# set the format of the logger
coloredlogs.install(
fmt="%(asctime)s [%(levelname)s] %(name)s:%(funcName)s[%(lineno)s] -- %(message)s",
level="INFO",
)
parser = argparse.ArgumentParser()
parser.add_argument(
"-i",
"--inputs",
type=str,
help="The video file names to obtain inference results.",
required=True,
nargs="+",
)
parser.add_argument("-g", "--ground_truth", type=str, help="The base ground truth.")
parser.add_argument(
"-o", "--output", type=str, help="The output pseudo video name.", required=True,
)
parser.add_argument(
"--confidence_threshold",
type=float,
help="The confidence score threshold for calculating accuracy.",
default=0.5,
)
parser.add_argument(
"--gt_confidence_threshold",
type=float,
help="The confidence score threshold for calculating accuracy.",
default=0.1,
)
parser.add_argument(
"--iou_threshold",
type=float,
help="The IoU threshold for calculating accuracy in object detection.",
default=0.5,
)
args = parser.parse_args()
main(args)