megadetector 5.0.12__py3-none-any.whl → 5.0.13__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 +171 -43
- 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 +360 -216
- megadetector/detection/pytorch_detector.py +17 -3
- megadetector/detection/run_inference_with_yolov5_val.py +527 -357
- megadetector/detection/tf_detector.py +3 -0
- megadetector/detection/video_utils.py +122 -30
- 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/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 +311 -115
- megadetector/utils/path_utils.py +1 -0
- megadetector/utils/process_utils.py +6 -3
- megadetector/visualization/visualize_db.py +79 -77
- {megadetector-5.0.12.dist-info → megadetector-5.0.13.dist-info}/LICENSE +0 -0
- {megadetector-5.0.12.dist-info → megadetector-5.0.13.dist-info}/METADATA +2 -2
- {megadetector-5.0.12.dist-info → megadetector-5.0.13.dist-info}/RECORD +40 -38
- {megadetector-5.0.12.dist-info → megadetector-5.0.13.dist-info}/top_level.txt +0 -0
- {megadetector-5.0.12.dist-info → megadetector-5.0.13.dist-info}/WHEEL +0 -0
|
@@ -8,11 +8,9 @@ Module to run MegaDetector v5, a PyTorch YOLOv5 animal detection model.
|
|
|
8
8
|
|
|
9
9
|
#%% Imports and constants
|
|
10
10
|
|
|
11
|
-
import sys
|
|
12
11
|
import torch
|
|
13
12
|
import numpy as np
|
|
14
13
|
import traceback
|
|
15
|
-
import builtins
|
|
16
14
|
|
|
17
15
|
from megadetector.detection.run_detector import CONF_DIGITS, COORD_DIGITS, FAILURE_INFER
|
|
18
16
|
from megadetector.utils import ct_utils
|
|
@@ -130,7 +128,20 @@ class PTDetector:
|
|
|
130
128
|
self.device = 'mps'
|
|
131
129
|
except AttributeError:
|
|
132
130
|
pass
|
|
133
|
-
|
|
131
|
+
try:
|
|
132
|
+
self.model = PTDetector._load_model(model_path, self.device)
|
|
133
|
+
except Exception as e:
|
|
134
|
+
# In a very estoeric scenario where an old version of YOLOv5 is used to run
|
|
135
|
+
# newer models, we run into an issue because the "Model" class became
|
|
136
|
+
# "DetectionModel". New YOLOv5 code handles this case by just setting them
|
|
137
|
+
# to be the same, so doing that via monkey-patch doesn't seem *that* rude.
|
|
138
|
+
if "Can't get attribute 'DetectionModel'" in str(e):
|
|
139
|
+
print('Forward-compatibility issue detected, patching')
|
|
140
|
+
from models import yolo
|
|
141
|
+
yolo.DetectionModel = yolo.Model
|
|
142
|
+
self.model = PTDetector._load_model(model_path, self.device)
|
|
143
|
+
else:
|
|
144
|
+
raise
|
|
134
145
|
if (self.device != 'cpu'):
|
|
135
146
|
print('Sending model to GPU')
|
|
136
147
|
self.model.to(self.device)
|
|
@@ -201,6 +212,9 @@ class PTDetector:
|
|
|
201
212
|
detections = []
|
|
202
213
|
max_conf = 0.0
|
|
203
214
|
|
|
215
|
+
if detection_threshold is None:
|
|
216
|
+
detection_threshold = 0
|
|
217
|
+
|
|
204
218
|
try:
|
|
205
219
|
|
|
206
220
|
img_original = np.asarray(img_original)
|