megadetector 5.0.12__py3-none-any.whl → 5.0.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of megadetector might be problematic. Click here for more details.
- megadetector/api/batch_processing/api_core/server.py +1 -1
- megadetector/api/batch_processing/api_core/server_api_config.py +0 -1
- megadetector/api/batch_processing/api_core/server_job_status_table.py +0 -3
- megadetector/api/batch_processing/api_core/server_utils.py +0 -4
- megadetector/api/batch_processing/integration/eMammal/test_scripts/push_annotations_to_emammal.py +0 -1
- megadetector/api/synchronous/api_core/animal_detection_api/api_frontend.py +0 -3
- megadetector/classification/efficientnet/utils.py +0 -3
- megadetector/data_management/camtrap_dp_to_coco.py +0 -2
- megadetector/data_management/cct_json_utils.py +15 -6
- megadetector/data_management/coco_to_labelme.py +12 -1
- megadetector/data_management/databases/integrity_check_json_db.py +43 -27
- megadetector/data_management/importers/cacophony-thermal-importer.py +1 -4
- megadetector/data_management/ocr_tools.py +0 -4
- megadetector/data_management/read_exif.py +178 -44
- megadetector/data_management/rename_images.py +187 -0
- megadetector/data_management/wi_download_csv_to_coco.py +3 -2
- megadetector/data_management/yolo_output_to_md_output.py +7 -2
- megadetector/detection/process_video.py +548 -244
- megadetector/detection/pytorch_detector.py +33 -14
- megadetector/detection/run_detector.py +17 -5
- megadetector/detection/run_detector_batch.py +179 -65
- megadetector/detection/run_inference_with_yolov5_val.py +527 -357
- megadetector/detection/tf_detector.py +14 -3
- megadetector/detection/video_utils.py +284 -61
- megadetector/postprocessing/categorize_detections_by_size.py +16 -14
- megadetector/postprocessing/classification_postprocessing.py +716 -0
- megadetector/postprocessing/compare_batch_results.py +101 -93
- megadetector/postprocessing/convert_output_format.py +12 -5
- megadetector/postprocessing/merge_detections.py +18 -7
- megadetector/postprocessing/postprocess_batch_results.py +133 -127
- megadetector/postprocessing/repeat_detection_elimination/repeat_detections_core.py +236 -232
- megadetector/postprocessing/subset_json_detector_output.py +66 -62
- megadetector/taxonomy_mapping/preview_lila_taxonomy.py +0 -2
- megadetector/utils/ct_utils.py +5 -4
- megadetector/utils/md_tests.py +380 -128
- megadetector/utils/path_utils.py +39 -6
- megadetector/utils/process_utils.py +13 -4
- megadetector/visualization/visualization_utils.py +7 -2
- megadetector/visualization/visualize_db.py +79 -77
- megadetector/visualization/visualize_detector_output.py +0 -1
- {megadetector-5.0.12.dist-info → megadetector-5.0.14.dist-info}/LICENSE +0 -0
- {megadetector-5.0.12.dist-info → megadetector-5.0.14.dist-info}/METADATA +2 -2
- {megadetector-5.0.12.dist-info → megadetector-5.0.14.dist-info}/RECORD +45 -43
- {megadetector-5.0.12.dist-info → megadetector-5.0.14.dist-info}/top_level.txt +0 -0
- {megadetector-5.0.12.dist-info → megadetector-5.0.14.dist-info}/WHEEL +0 -0
|
@@ -43,29 +43,31 @@ class PairwiseBatchComparisonOptions:
|
|
|
43
43
|
pairwise options sets is stored in the BatchComparisonsOptions class.
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
rendering_confidence_threshold_a = 0.1
|
|
46
|
+
def __init__(self):
|
|
47
|
+
|
|
48
|
+
#: First filename to compare
|
|
49
|
+
self.results_filename_a = None
|
|
50
|
+
|
|
51
|
+
#: Second filename to compare
|
|
52
|
+
self.results_filename_b = None
|
|
53
|
+
|
|
54
|
+
#: Description to use in the output HTML for filename A
|
|
55
|
+
self.results_description_a = None
|
|
56
|
+
|
|
57
|
+
#: Description to use in the output HTML for filename B
|
|
58
|
+
self.results_description_b = None
|
|
59
|
+
|
|
60
|
+
#: Per-class detection thresholds to use for filename A (including a 'default' threshold)
|
|
61
|
+
self.detection_thresholds_a = {'animal':0.15,'person':0.15,'vehicle':0.15,'default':0.15}
|
|
62
|
+
|
|
63
|
+
#: Per-class detection thresholds to use for filename B (including a 'default' threshold)
|
|
64
|
+
self.detection_thresholds_b = {'animal':0.15,'person':0.15,'vehicle':0.15,'default':0.15}
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
#: Rendering threshold to use for all categories for filename A
|
|
67
|
+
self.rendering_confidence_threshold_a = 0.1
|
|
68
|
+
|
|
69
|
+
#: Rendering threshold to use for all categories for filename B
|
|
70
|
+
self.rendering_confidence_threshold_b = 0.1
|
|
69
71
|
|
|
70
72
|
# ...class PairwiseBatchComparisonOptions
|
|
71
73
|
|
|
@@ -75,58 +77,60 @@ class BatchComparisonOptions:
|
|
|
75
77
|
Defines the options for a set of (possibly many) pairwise comparisons.
|
|
76
78
|
"""
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
parallelize_rendering_with_threads = True
|
|
103
|
-
|
|
104
|
-
#: List of filenames to include in the comparison, or None to use all files
|
|
105
|
-
filenames_to_include = None
|
|
106
|
-
|
|
107
|
-
#: Compare only detections/non-detections, ignore categories (still renders categories)
|
|
108
|
-
class_agnostic_comparison = False
|
|
109
|
-
|
|
110
|
-
#: Width of images to render in the output HTML
|
|
111
|
-
target_width = 800
|
|
112
|
-
|
|
113
|
-
#: Number of workers to use for rendering, or <=1 to disable parallelization
|
|
114
|
-
n_rendering_workers = 20
|
|
115
|
-
|
|
116
|
-
#: Random seed for image sampling (not used if max_images_per_category is None)
|
|
117
|
-
random_seed = 0
|
|
118
|
-
|
|
119
|
-
#: Whether to sort results by confidence; if this is False, sorts by filename
|
|
120
|
-
sort_by_confidence = False
|
|
121
|
-
|
|
122
|
-
#: The expectation is that all results sets being compared will refer to the same images; if this
|
|
123
|
-
#: is True (default), we'll error if that's not the case, otherwise non-matching lists will just be
|
|
124
|
-
#: a warning.
|
|
125
|
-
error_on_non_matching_lists = True
|
|
126
|
-
|
|
127
|
-
#: List of PairwiseBatchComparisonOptions that defines the comparisons we'll render.
|
|
128
|
-
pairwise_options = []
|
|
80
|
+
def __init__(self):
|
|
81
|
+
|
|
82
|
+
#: Folder to which we should write HTML output
|
|
83
|
+
self.output_folder = None
|
|
84
|
+
|
|
85
|
+
#: Base folder for images (which are specified as relative files)
|
|
86
|
+
self.image_folder = None
|
|
87
|
+
|
|
88
|
+
#: Job name to use in the HTML output file
|
|
89
|
+
self.job_name = ''
|
|
90
|
+
|
|
91
|
+
#: Maximum number of images to render for each category, where a "category" here is
|
|
92
|
+
#: "detections_a_only", "detections_b_only", etc., or None to render all images.
|
|
93
|
+
self.max_images_per_category = 1000
|
|
94
|
+
|
|
95
|
+
#: Maximum number of images per HTML page (paginates if a category page goes beyond this),
|
|
96
|
+
#: or None to disable pagination.
|
|
97
|
+
self.max_images_per_page = None
|
|
98
|
+
|
|
99
|
+
#: Colormap to use for detections in file A (maps detection categories to colors)
|
|
100
|
+
self.colormap_a = ['Red']
|
|
101
|
+
|
|
102
|
+
#: Colormap to use for detections in file B (maps detection categories to colors)
|
|
103
|
+
self.colormap_b = ['RoyalBlue']
|
|
129
104
|
|
|
105
|
+
#: Process-based parallelization isn't supported yet; this must be "True"
|
|
106
|
+
self.parallelize_rendering_with_threads = True
|
|
107
|
+
|
|
108
|
+
#: List of filenames to include in the comparison, or None to use all files
|
|
109
|
+
self.filenames_to_include = None
|
|
110
|
+
|
|
111
|
+
#: Compare only detections/non-detections, ignore categories (still renders categories)
|
|
112
|
+
self.class_agnostic_comparison = False
|
|
113
|
+
|
|
114
|
+
#: Width of images to render in the output HTML
|
|
115
|
+
self.target_width = 800
|
|
116
|
+
|
|
117
|
+
#: Number of workers to use for rendering, or <=1 to disable parallelization
|
|
118
|
+
self.n_rendering_workers = 20
|
|
119
|
+
|
|
120
|
+
#: Random seed for image sampling (not used if max_images_per_category is None)
|
|
121
|
+
self.random_seed = 0
|
|
122
|
+
|
|
123
|
+
#: Whether to sort results by confidence; if this is False, sorts by filename
|
|
124
|
+
self.sort_by_confidence = False
|
|
125
|
+
|
|
126
|
+
#: The expectation is that all results sets being compared will refer to the same images; if this
|
|
127
|
+
#: is True (default), we'll error if that's not the case, otherwise non-matching lists will just be
|
|
128
|
+
#: a warning.
|
|
129
|
+
self.error_on_non_matching_lists = True
|
|
130
|
+
|
|
131
|
+
#: List of PairwiseBatchComparisonOptions that defines the comparisons we'll render.
|
|
132
|
+
self.pairwise_options = []
|
|
133
|
+
|
|
130
134
|
# ...class BatchComparisonOptions
|
|
131
135
|
|
|
132
136
|
|
|
@@ -135,22 +139,24 @@ class PairwiseBatchComparisonResults:
|
|
|
135
139
|
The results from a single pairwise comparison.
|
|
136
140
|
"""
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
html_content = None
|
|
140
|
-
|
|
141
|
-
#: Possibly-modified version of the PairwiseBatchComparisonOptions supplied as input.
|
|
142
|
-
pairwise_options = None
|
|
142
|
+
def __init__(self):
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
#: String of HTML content suitable for rendering to an HTML file
|
|
145
|
+
self.html_content = None
|
|
146
|
+
|
|
147
|
+
#: Possibly-modified version of the PairwiseBatchComparisonOptions supplied as input.
|
|
148
|
+
self.pairwise_options = None
|
|
149
|
+
|
|
150
|
+
#: A dictionary with keys including:
|
|
151
|
+
#:
|
|
152
|
+
#: common_detections
|
|
153
|
+
#: common_non_detections
|
|
154
|
+
#: detections_a_only
|
|
155
|
+
#: detections_b_only
|
|
156
|
+
#: class_transitions
|
|
157
|
+
#
|
|
158
|
+
#: Each of these maps a filename to a two-element list (the image in set A, the image in set B).
|
|
159
|
+
self.categories_to_image_pairs = None
|
|
154
160
|
|
|
155
161
|
# ...class PairwiseBatchComparisonResults
|
|
156
162
|
|
|
@@ -160,11 +166,13 @@ class BatchComparisonResults:
|
|
|
160
166
|
The results from a set of pairwise comparisons
|
|
161
167
|
"""
|
|
162
168
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
def __init__(self):
|
|
170
|
+
|
|
171
|
+
#: Filename containing HTML output
|
|
172
|
+
self.html_output_file = None
|
|
173
|
+
|
|
174
|
+
#: A list of PairwiseBatchComparisonResults
|
|
175
|
+
self.pairwise_results = None
|
|
168
176
|
|
|
169
177
|
# ...class BatchComparisonResults
|
|
170
178
|
|
|
@@ -30,8 +30,11 @@ CONF_DIGITS = 3
|
|
|
30
30
|
|
|
31
31
|
#%% Conversion functions
|
|
32
32
|
|
|
33
|
-
def convert_json_to_csv(input_path,
|
|
34
|
-
|
|
33
|
+
def convert_json_to_csv(input_path,
|
|
34
|
+
output_path=None,
|
|
35
|
+
min_confidence=None,
|
|
36
|
+
omit_bounding_boxes=False,
|
|
37
|
+
output_encoding=None,
|
|
35
38
|
overwrite=True):
|
|
36
39
|
"""
|
|
37
40
|
Converts a MD results .json file to a totally non-standard .csv format.
|
|
@@ -76,9 +79,9 @@ def convert_json_to_csv(input_path,output_path=None,min_confidence=None,
|
|
|
76
79
|
# n_non_empty_detection_categories = len(annotation_constants.annotation_bbox_categories) - 1
|
|
77
80
|
n_non_empty_detection_categories = annotation_constants.NUM_DETECTOR_CATEGORIES
|
|
78
81
|
detection_category_column_names = []
|
|
79
|
-
assert annotation_constants.
|
|
82
|
+
assert annotation_constants.detector_bbox_category_id_to_name[0] == 'empty'
|
|
80
83
|
for cat_id in range(1,n_non_empty_detection_categories+1):
|
|
81
|
-
cat_name = annotation_constants.
|
|
84
|
+
cat_name = annotation_constants.detector_bbox_category_id_to_name[cat_id]
|
|
82
85
|
detection_category_column_names.append('max_conf_' + cat_name)
|
|
83
86
|
|
|
84
87
|
n_classification_categories = 0
|
|
@@ -370,6 +373,8 @@ def main():
|
|
|
370
373
|
parser.add_argument('--output_path',type=str,default=None,
|
|
371
374
|
help='Output filename ending in .json or .csv (defaults to ' + \
|
|
372
375
|
'input file, with .json/.csv replaced by .csv/.json)')
|
|
376
|
+
parser.add_argument('--omit_bounding_boxes',action='store_true',
|
|
377
|
+
help='Output bounding box text from .csv output (large and usually not useful)')
|
|
373
378
|
|
|
374
379
|
if len(sys.argv[1:]) == 0:
|
|
375
380
|
parser.print_help()
|
|
@@ -386,9 +391,11 @@ def main():
|
|
|
386
391
|
raise ValueError('Illegal input file extension')
|
|
387
392
|
|
|
388
393
|
if args.input_path.endswith('.csv') and args.output_path.endswith('.json'):
|
|
394
|
+
assert not args.omit_bounding_boxes, \
|
|
395
|
+
'--omit_bounding_boxes does not apply to csv --> json conversion'
|
|
389
396
|
convert_csv_to_json(args.input_path,args.output_path)
|
|
390
397
|
elif args.input_path.endswith('.json') and args.output_path.endswith('.csv'):
|
|
391
|
-
convert_json_to_csv(args.input_path,args.output_path)
|
|
398
|
+
convert_json_to_csv(args.input_path,args.output_path,omit_bounding_boxes=args.omit_bounding_boxes)
|
|
392
399
|
else:
|
|
393
400
|
raise ValueError('Illegal format combination')
|
|
394
401
|
|
|
@@ -31,26 +31,37 @@ class MergeDetectionsOptions:
|
|
|
31
31
|
|
|
32
32
|
def __init__(self):
|
|
33
33
|
|
|
34
|
+
#: Maximum detection size to include in the merged output
|
|
34
35
|
self.max_detection_size = 1.01
|
|
36
|
+
|
|
37
|
+
#: Minimum detection size to include in the merged output
|
|
35
38
|
self.min_detection_size = 0
|
|
39
|
+
|
|
40
|
+
#: Exclude detections whose confidence in the source file(s) is less
|
|
41
|
+
#: than this. Should have the same length as the number of source files.
|
|
36
42
|
self.source_confidence_thresholds = [0.05]
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
#: Don't bother merging into target images if there is a similar detection
|
|
45
|
+
#: above this threshold (or if there is *any* detection above this threshold,
|
|
46
|
+
#: and merge_empty_only is True)
|
|
41
47
|
self.target_confidence_threshold = 0.2
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
#: If you want to merge only certain categories, specify one
|
|
50
|
+
#: (but not both) of these. These are category IDs, not names.
|
|
45
51
|
self.categories_to_include = None
|
|
52
|
+
|
|
53
|
+
#: If you want to merge only certain categories, specify one
|
|
54
|
+
#: (but not both) of these. These are category IDs, not names.
|
|
46
55
|
self.categories_to_exclude = None
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
#: Only merge detections into images that have *no* detections in the
|
|
58
|
+
#: target results file.
|
|
50
59
|
self.merge_empty_only = False
|
|
51
60
|
|
|
61
|
+
#: IoU threshold above which two detections are considered the same
|
|
52
62
|
self.iou_threshold = 0.65
|
|
53
63
|
|
|
64
|
+
#: Error if this is False and the output file exists
|
|
54
65
|
self.overwrite = False
|
|
55
66
|
|
|
56
67
|
|
|
@@ -72,135 +72,139 @@ class PostProcessingOptions:
|
|
|
72
72
|
Options used to parameterize process_batch_results().
|
|
73
73
|
"""
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
md_results_file = ''
|
|
75
|
+
def __init__(self):
|
|
76
|
+
|
|
77
|
+
### Required inputs
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#: Folder where images live (filenames in [md_results_file] should be relative to this folder)
|
|
86
|
-
image_base_dir = '.'
|
|
87
|
-
|
|
88
|
-
## These apply only when we're doing ground-truth comparisons
|
|
79
|
+
#: MD results .json file to process
|
|
80
|
+
self.md_results_file = ''
|
|
81
|
+
|
|
82
|
+
#: Folder to which we should write HTML output
|
|
83
|
+
self.output_dir = ''
|
|
89
84
|
|
|
90
|
-
|
|
91
|
-
ground_truth_json_file = ''
|
|
92
|
-
|
|
93
|
-
#: Classes we'll treat as negative
|
|
94
|
-
#:
|
|
95
|
-
#: Include the token "#NO_LABELS#" to indicate that an image with no annotations
|
|
96
|
-
#: should be considered empty.
|
|
97
|
-
negative_classes = DEFAULT_NEGATIVE_CLASSES
|
|
85
|
+
### Options
|
|
98
86
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#: A list of output sets that we should count, but not render images for.
|
|
103
|
-
#:
|
|
104
|
-
#: Typically used to preview sets with lots of empties, where you don't want to
|
|
105
|
-
#: subset but also don't want to render 100,000 empty images.
|
|
106
|
-
#:
|
|
107
|
-
#: detections, non_detections
|
|
108
|
-
#: detections_animal, detections_person, detections_vehicle
|
|
109
|
-
rendering_bypass_sets = []
|
|
110
|
-
|
|
111
|
-
#: If this is None, choose a confidence threshold based on the detector version.
|
|
112
|
-
#:
|
|
113
|
-
#: This can either be a float or a dictionary mapping category names (not IDs) to
|
|
114
|
-
#: thresholds. The category "default" can be used to specify thresholds for
|
|
115
|
-
#: other categories. Currently the use of a dict here is not supported when
|
|
116
|
-
#: ground truth is supplied.
|
|
117
|
-
confidence_threshold = None
|
|
87
|
+
#: Folder where images live (filenames in [md_results_file] should be relative to this folder)
|
|
88
|
+
self.image_base_dir = '.'
|
|
118
89
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
90
|
+
## These apply only when we're doing ground-truth comparisons
|
|
91
|
+
|
|
92
|
+
#: Optional .json file containing ground truth information
|
|
93
|
+
self.ground_truth_json_file = ''
|
|
94
|
+
|
|
95
|
+
#: Classes we'll treat as negative
|
|
96
|
+
#:
|
|
97
|
+
#: Include the token "#NO_LABELS#" to indicate that an image with no annotations
|
|
98
|
+
#: should be considered empty.
|
|
99
|
+
self.negative_classes = DEFAULT_NEGATIVE_CLASSES
|
|
100
|
+
|
|
101
|
+
#: Classes we'll treat as neither positive nor negative
|
|
102
|
+
self.unlabeled_classes = DEFAULT_UNKNOWN_CLASSES
|
|
103
|
+
|
|
104
|
+
#: A list of output sets that we should count, but not render images for.
|
|
105
|
+
#:
|
|
106
|
+
#: Typically used to preview sets with lots of empties, where you don't want to
|
|
107
|
+
#: subset but also don't want to render 100,000 empty images.
|
|
108
|
+
#:
|
|
109
|
+
#: detections, non_detections
|
|
110
|
+
#: detections_animal, detections_person, detections_vehicle
|
|
111
|
+
self.rendering_bypass_sets = []
|
|
112
|
+
|
|
113
|
+
#: If this is None, choose a confidence threshold based on the detector version.
|
|
114
|
+
#:
|
|
115
|
+
#: This can either be a float or a dictionary mapping category names (not IDs) to
|
|
116
|
+
#: thresholds. The category "default" can be used to specify thresholds for
|
|
117
|
+
#: other categories. Currently the use of a dict here is not supported when
|
|
118
|
+
#: ground truth is supplied.
|
|
119
|
+
self.confidence_threshold = None
|
|
120
|
+
|
|
121
|
+
#: Confidence threshold to apply to classification (not detection) results
|
|
122
|
+
#:
|
|
123
|
+
#: Only a float is supported here (unlike the "confidence_threshold" parameter, which
|
|
124
|
+
#: can be a dict).
|
|
125
|
+
self.classification_confidence_threshold = 0.5
|
|
139
126
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
#: Job name to include in big letters in the output HTML
|
|
144
|
-
job_name_string = None
|
|
127
|
+
#: Used for summary statistics only
|
|
128
|
+
self.target_recall = 0.9
|
|
145
129
|
|
|
146
|
-
|
|
147
|
-
|
|
130
|
+
#: Number of images to sample, -1 for "all images"
|
|
131
|
+
self.num_images_to_sample = 500
|
|
148
132
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
#: If True, images in the output HTML will be links back to the original images
|
|
153
|
-
link_images_to_originals = True
|
|
133
|
+
#: Random seed for sampling, or None
|
|
134
|
+
self.sample_seed = 0 # None
|
|
154
135
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
#: Currently only supported when ground truth is unavailable
|
|
158
|
-
separate_detections_by_category = True
|
|
159
|
-
|
|
160
|
-
#: Optionally replace one or more strings in filenames with other strings;
|
|
161
|
-
#: useful for taking a set of results generated for one folder structure
|
|
162
|
-
#: and applying them to a slightly different folder structure.
|
|
163
|
-
api_output_filename_replacements = {}
|
|
136
|
+
#: Image width for images in the HTML output
|
|
137
|
+
self.viz_target_width = 800
|
|
164
138
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
#: Allow bypassing API output loading when operating on previously-loaded
|
|
171
|
-
#: results. If present, this is a Pandas DataFrame. Almost never useful.
|
|
172
|
-
api_detection_results = None
|
|
139
|
+
#: Line width (in pixels) for rendering detections
|
|
140
|
+
self.line_thickness = 4
|
|
141
|
+
|
|
142
|
+
#: Box expansion (in pixels) for rendering detections
|
|
143
|
+
self.box_expansion = 0
|
|
173
144
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
145
|
+
#: Job name to include in big letters in the output HTML
|
|
146
|
+
self.job_name_string = None
|
|
147
|
+
|
|
148
|
+
#: Model version string to include in the output HTML
|
|
149
|
+
self.model_version_string = None
|
|
150
|
+
|
|
151
|
+
#: Sort order for the output, should be one of "filename", "confidence", or "random"
|
|
152
|
+
self.html_sort_order = 'filename'
|
|
153
|
+
|
|
154
|
+
#: If True, images in the output HTML will be links back to the original images
|
|
155
|
+
self.link_images_to_originals = True
|
|
156
|
+
|
|
157
|
+
#: Optionally separate detections into categories (animal/vehicle/human)
|
|
158
|
+
#:
|
|
159
|
+
#: Currently only supported when ground truth is unavailable
|
|
160
|
+
self.separate_detections_by_category = True
|
|
161
|
+
|
|
162
|
+
#: Optionally replace one or more strings in filenames with other strings;
|
|
163
|
+
#: useful for taking a set of results generated for one folder structure
|
|
164
|
+
#: and applying them to a slightly different folder structure.
|
|
165
|
+
self.api_output_filename_replacements = {}
|
|
166
|
+
|
|
167
|
+
#: Optionally replace one or more strings in filenames with other strings;
|
|
168
|
+
#: useful for taking a set of results generated for one folder structure
|
|
169
|
+
#: and applying them to a slightly different folder structure.
|
|
170
|
+
self.ground_truth_filename_replacements = {}
|
|
171
|
+
|
|
172
|
+
#: Allow bypassing API output loading when operating on previously-loaded
|
|
173
|
+
#: results. If present, this is a Pandas DataFrame. Almost never useful.
|
|
174
|
+
self.api_detection_results = None
|
|
175
|
+
|
|
176
|
+
#: Allow bypassing API output loading when operating on previously-loaded
|
|
177
|
+
#: results. If present, this is a str --> obj dict. Almost never useful.
|
|
178
|
+
self.api_other_fields = None
|
|
179
|
+
|
|
180
|
+
#: Should we also split out a separate report about the detections that were
|
|
181
|
+
#: just below our main confidence threshold?
|
|
182
|
+
#:
|
|
183
|
+
#: Currently only supported when ground truth is unavailable.
|
|
184
|
+
self.include_almost_detections = False
|
|
185
|
+
|
|
186
|
+
#: Only a float is supported here (unlike the "confidence_threshold" parameter, which
|
|
187
|
+
#: can be a dict).
|
|
188
|
+
self.almost_detection_confidence_threshold = None
|
|
183
189
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
#: Enable/disable rendering parallelization
|
|
191
|
+
self.parallelize_rendering = False
|
|
192
|
+
|
|
193
|
+
#: Number of threads/processes to use for rendering parallelization
|
|
194
|
+
self.parallelize_rendering_n_cores = 25
|
|
195
|
+
|
|
196
|
+
#: Whether to use threads (True) or processes (False) for rendering parallelization
|
|
197
|
+
self.parallelize_rendering_with_threads = True
|
|
198
|
+
|
|
199
|
+
#: When classification results are present, should be sort alphabetically by class name (False)
|
|
200
|
+
#: or in descending order by frequency (True)?
|
|
201
|
+
self.sort_classification_results_by_count = False
|
|
202
|
+
|
|
203
|
+
#: Should we split individual pages up into smaller pages if there are more than
|
|
204
|
+
#: N images?
|
|
205
|
+
self.max_figures_per_html_file = None
|
|
187
206
|
|
|
188
|
-
|
|
189
|
-
parallelize_rendering = False
|
|
190
|
-
|
|
191
|
-
#: Number of threads/processes to use for rendering parallelization
|
|
192
|
-
parallelize_rendering_n_cores = 25
|
|
193
|
-
|
|
194
|
-
#: Whether to use threads (True) or processes (False) for rendering parallelization
|
|
195
|
-
parallelize_rendering_with_threads = True
|
|
196
|
-
|
|
197
|
-
#: When classification results are present, should be sort alphabetically by class name (False)
|
|
198
|
-
#: or in descending order by frequency (True)?
|
|
199
|
-
sort_classification_results_by_count = False
|
|
200
|
-
|
|
201
|
-
#: Should we split individual pages up into smaller pages if there are more than
|
|
202
|
-
#: N images?
|
|
203
|
-
max_figures_per_html_file = None
|
|
207
|
+
# ...__init__()
|
|
204
208
|
|
|
205
209
|
# ...PostProcessingOptions
|
|
206
210
|
|
|
@@ -210,14 +214,16 @@ class PostProcessingResults:
|
|
|
210
214
|
Return format from process_batch_results
|
|
211
215
|
"""
|
|
212
216
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
def __init__(self):
|
|
218
|
+
|
|
219
|
+
#: HTML file to which preview information was written
|
|
220
|
+
self.output_html_file = ''
|
|
221
|
+
|
|
222
|
+
#: Pandas Dataframe containing detection results
|
|
223
|
+
self.api_detection_results = None
|
|
224
|
+
|
|
225
|
+
#: str --> obj dictionary containing other information loaded from the results file
|
|
226
|
+
self.api_other_fields = None
|
|
221
227
|
|
|
222
228
|
|
|
223
229
|
##%% Helper classes and functions
|
|
@@ -901,8 +907,8 @@ def process_batch_results(options):
|
|
|
901
907
|
this set of results; see the PostProcessingOptions class for details.
|
|
902
908
|
|
|
903
909
|
Returns:
|
|
904
|
-
PostProcessingResults: information about the results/preview, most importantly the
|
|
905
|
-
|
|
910
|
+
PostProcessingResults: information about the results/preview, most importantly the
|
|
911
|
+
HTML filename of the output. See the PostProcessingResults class for details.
|
|
906
912
|
"""
|
|
907
913
|
ppresults = PostProcessingResults()
|
|
908
914
|
|