megadetector 5.0.5__py3-none-any.whl → 5.0.7__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.
- api/batch_processing/data_preparation/manage_local_batch.py +302 -263
- api/batch_processing/data_preparation/manage_video_batch.py +81 -2
- api/batch_processing/postprocessing/add_max_conf.py +1 -0
- api/batch_processing/postprocessing/categorize_detections_by_size.py +50 -19
- api/batch_processing/postprocessing/compare_batch_results.py +110 -60
- api/batch_processing/postprocessing/load_api_results.py +56 -70
- api/batch_processing/postprocessing/md_to_coco.py +1 -1
- api/batch_processing/postprocessing/md_to_labelme.py +2 -1
- api/batch_processing/postprocessing/postprocess_batch_results.py +240 -81
- api/batch_processing/postprocessing/render_detection_confusion_matrix.py +625 -0
- api/batch_processing/postprocessing/repeat_detection_elimination/find_repeat_detections.py +71 -23
- api/batch_processing/postprocessing/repeat_detection_elimination/remove_repeat_detections.py +1 -1
- api/batch_processing/postprocessing/repeat_detection_elimination/repeat_detections_core.py +227 -75
- api/batch_processing/postprocessing/subset_json_detector_output.py +132 -5
- api/batch_processing/postprocessing/top_folders_to_bottom.py +1 -1
- api/synchronous/api_core/animal_detection_api/detection/run_detector_batch.py +2 -2
- classification/prepare_classification_script.py +191 -191
- data_management/coco_to_yolo.py +68 -45
- data_management/databases/integrity_check_json_db.py +7 -5
- data_management/generate_crops_from_cct.py +3 -3
- data_management/get_image_sizes.py +8 -6
- data_management/importers/add_timestamps_to_icct.py +79 -0
- data_management/importers/animl_results_to_md_results.py +160 -0
- data_management/importers/auckland_doc_test_to_json.py +4 -4
- data_management/importers/auckland_doc_to_json.py +1 -1
- data_management/importers/awc_to_json.py +5 -5
- data_management/importers/bellevue_to_json.py +5 -5
- data_management/importers/carrizo_shrubfree_2018.py +5 -5
- data_management/importers/carrizo_trail_cam_2017.py +5 -5
- data_management/importers/cct_field_adjustments.py +2 -3
- data_management/importers/channel_islands_to_cct.py +4 -4
- data_management/importers/ena24_to_json.py +5 -5
- data_management/importers/helena_to_cct.py +10 -10
- data_management/importers/idaho-camera-traps.py +12 -12
- data_management/importers/idfg_iwildcam_lila_prep.py +8 -8
- data_management/importers/jb_csv_to_json.py +4 -4
- data_management/importers/missouri_to_json.py +1 -1
- data_management/importers/noaa_seals_2019.py +1 -1
- data_management/importers/pc_to_json.py +5 -5
- data_management/importers/prepare-noaa-fish-data-for-lila.py +4 -4
- data_management/importers/prepare_zsl_imerit.py +5 -5
- data_management/importers/rspb_to_json.py +4 -4
- data_management/importers/save_the_elephants_survey_A.py +5 -5
- data_management/importers/save_the_elephants_survey_B.py +6 -6
- data_management/importers/snapshot_safari_importer.py +9 -9
- data_management/importers/snapshot_serengeti_lila.py +9 -9
- data_management/importers/timelapse_csv_set_to_json.py +5 -7
- data_management/importers/ubc_to_json.py +4 -4
- data_management/importers/umn_to_json.py +4 -4
- data_management/importers/wellington_to_json.py +1 -1
- data_management/importers/wi_to_json.py +2 -2
- data_management/importers/zamba_results_to_md_results.py +181 -0
- data_management/labelme_to_coco.py +35 -7
- data_management/labelme_to_yolo.py +229 -0
- data_management/lila/add_locations_to_island_camera_traps.py +1 -1
- data_management/lila/add_locations_to_nacti.py +147 -0
- data_management/lila/create_lila_blank_set.py +474 -0
- data_management/lila/create_lila_test_set.py +2 -1
- data_management/lila/create_links_to_md_results_files.py +106 -0
- data_management/lila/download_lila_subset.py +46 -21
- data_management/lila/generate_lila_per_image_labels.py +23 -14
- data_management/lila/get_lila_annotation_counts.py +17 -11
- data_management/lila/lila_common.py +14 -11
- data_management/lila/test_lila_metadata_urls.py +116 -0
- data_management/ocr_tools.py +829 -0
- data_management/resize_coco_dataset.py +13 -11
- data_management/yolo_output_to_md_output.py +84 -12
- data_management/yolo_to_coco.py +38 -20
- detection/process_video.py +36 -14
- detection/pytorch_detector.py +23 -8
- detection/run_detector.py +76 -19
- detection/run_detector_batch.py +178 -63
- detection/run_inference_with_yolov5_val.py +326 -57
- detection/run_tiled_inference.py +153 -43
- detection/video_utils.py +34 -8
- md_utils/ct_utils.py +172 -1
- md_utils/md_tests.py +372 -51
- md_utils/path_utils.py +167 -39
- md_utils/process_utils.py +26 -7
- md_utils/split_locations_into_train_val.py +215 -0
- md_utils/string_utils.py +10 -0
- md_utils/url_utils.py +0 -2
- md_utils/write_html_image_list.py +9 -26
- md_visualization/plot_utils.py +12 -8
- md_visualization/visualization_utils.py +106 -7
- md_visualization/visualize_db.py +16 -8
- md_visualization/visualize_detector_output.py +208 -97
- {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/METADATA +3 -6
- {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/RECORD +98 -121
- {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/WHEEL +1 -1
- taxonomy_mapping/map_lila_taxonomy_to_wi_taxonomy.py +1 -1
- taxonomy_mapping/map_new_lila_datasets.py +43 -39
- taxonomy_mapping/prepare_lila_taxonomy_release.py +5 -2
- taxonomy_mapping/preview_lila_taxonomy.py +27 -27
- taxonomy_mapping/species_lookup.py +33 -13
- taxonomy_mapping/taxonomy_csv_checker.py +7 -5
- api/synchronous/api_core/yolov5/detect.py +0 -252
- api/synchronous/api_core/yolov5/export.py +0 -607
- api/synchronous/api_core/yolov5/hubconf.py +0 -146
- api/synchronous/api_core/yolov5/models/__init__.py +0 -0
- api/synchronous/api_core/yolov5/models/common.py +0 -738
- api/synchronous/api_core/yolov5/models/experimental.py +0 -104
- api/synchronous/api_core/yolov5/models/tf.py +0 -574
- api/synchronous/api_core/yolov5/models/yolo.py +0 -338
- api/synchronous/api_core/yolov5/train.py +0 -670
- api/synchronous/api_core/yolov5/utils/__init__.py +0 -36
- api/synchronous/api_core/yolov5/utils/activations.py +0 -103
- api/synchronous/api_core/yolov5/utils/augmentations.py +0 -284
- api/synchronous/api_core/yolov5/utils/autoanchor.py +0 -170
- api/synchronous/api_core/yolov5/utils/autobatch.py +0 -66
- api/synchronous/api_core/yolov5/utils/aws/__init__.py +0 -0
- api/synchronous/api_core/yolov5/utils/aws/resume.py +0 -40
- api/synchronous/api_core/yolov5/utils/benchmarks.py +0 -148
- api/synchronous/api_core/yolov5/utils/callbacks.py +0 -71
- api/synchronous/api_core/yolov5/utils/dataloaders.py +0 -1087
- api/synchronous/api_core/yolov5/utils/downloads.py +0 -178
- api/synchronous/api_core/yolov5/utils/flask_rest_api/example_request.py +0 -19
- api/synchronous/api_core/yolov5/utils/flask_rest_api/restapi.py +0 -46
- api/synchronous/api_core/yolov5/utils/general.py +0 -1018
- api/synchronous/api_core/yolov5/utils/loggers/__init__.py +0 -187
- api/synchronous/api_core/yolov5/utils/loggers/wandb/__init__.py +0 -0
- api/synchronous/api_core/yolov5/utils/loggers/wandb/log_dataset.py +0 -27
- api/synchronous/api_core/yolov5/utils/loggers/wandb/sweep.py +0 -41
- api/synchronous/api_core/yolov5/utils/loggers/wandb/wandb_utils.py +0 -577
- api/synchronous/api_core/yolov5/utils/loss.py +0 -234
- api/synchronous/api_core/yolov5/utils/metrics.py +0 -355
- api/synchronous/api_core/yolov5/utils/plots.py +0 -489
- api/synchronous/api_core/yolov5/utils/torch_utils.py +0 -314
- api/synchronous/api_core/yolov5/val.py +0 -394
- md_utils/matlab_porting_tools.py +0 -97
- {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/LICENSE +0 -0
- {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/top_level.txt +0 -0
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
|
|
2
|
-
"""
|
|
3
|
-
PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5/
|
|
4
|
-
|
|
5
|
-
Usage:
|
|
6
|
-
import torch
|
|
7
|
-
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
|
|
8
|
-
model = torch.hub.load('ultralytics/yolov5:master', 'custom', 'path/to/yolov5s.onnx') # file from branch
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import torch
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbose=True, device=None):
|
|
15
|
-
"""Creates or loads a YOLOv5 model
|
|
16
|
-
|
|
17
|
-
Arguments:
|
|
18
|
-
name (str): model name 'yolov5s' or path 'path/to/best.pt'
|
|
19
|
-
pretrained (bool): load pretrained weights into the model
|
|
20
|
-
channels (int): number of input channels
|
|
21
|
-
classes (int): number of model classes
|
|
22
|
-
autoshape (bool): apply YOLOv5 .autoshape() wrapper to model
|
|
23
|
-
verbose (bool): print all information to screen
|
|
24
|
-
device (str, torch.device, None): device to use for model parameters
|
|
25
|
-
|
|
26
|
-
Returns:
|
|
27
|
-
YOLOv5 model
|
|
28
|
-
"""
|
|
29
|
-
from pathlib import Path
|
|
30
|
-
|
|
31
|
-
from models.common import AutoShape, DetectMultiBackend
|
|
32
|
-
from models.yolo import Model
|
|
33
|
-
from utils.downloads import attempt_download
|
|
34
|
-
from utils.general import LOGGER, check_requirements, intersect_dicts, logging
|
|
35
|
-
from utils.torch_utils import select_device
|
|
36
|
-
|
|
37
|
-
if not verbose:
|
|
38
|
-
LOGGER.setLevel(logging.WARNING)
|
|
39
|
-
|
|
40
|
-
check_requirements(exclude=('tensorboard', 'thop', 'opencv-python'))
|
|
41
|
-
name = Path(name)
|
|
42
|
-
path = name.with_suffix('.pt') if name.suffix == '' and not name.is_dir() else name # checkpoint path
|
|
43
|
-
try:
|
|
44
|
-
device = select_device(('0' if torch.cuda.is_available() else 'cpu') if device is None else device)
|
|
45
|
-
|
|
46
|
-
if pretrained and channels == 3 and classes == 80:
|
|
47
|
-
model = DetectMultiBackend(path, device=device) # download/load FP32 model
|
|
48
|
-
# model = models.experimental.attempt_load(path, map_location=device) # download/load FP32 model
|
|
49
|
-
else:
|
|
50
|
-
cfg = list((Path(__file__).parent / 'models').rglob(f'{path.stem}.yaml'))[0] # model.yaml path
|
|
51
|
-
model = Model(cfg, channels, classes) # create model
|
|
52
|
-
if pretrained:
|
|
53
|
-
ckpt = torch.load(attempt_download(path), map_location=device) # load
|
|
54
|
-
csd = ckpt['model'].float().state_dict() # checkpoint state_dict as FP32
|
|
55
|
-
csd = intersect_dicts(csd, model.state_dict(), exclude=['anchors']) # intersect
|
|
56
|
-
model.load_state_dict(csd, strict=False) # load
|
|
57
|
-
if len(ckpt['model'].names) == classes:
|
|
58
|
-
model.names = ckpt['model'].names # set class names attribute
|
|
59
|
-
if autoshape:
|
|
60
|
-
model = AutoShape(model) # for file/URI/PIL/cv2/np inputs and NMS
|
|
61
|
-
return model.to(device)
|
|
62
|
-
|
|
63
|
-
except Exception as e:
|
|
64
|
-
help_url = 'https://github.com/ultralytics/yolov5/issues/36'
|
|
65
|
-
s = f'{e}. Cache may be out of date, try `force_reload=True` or see {help_url} for help.'
|
|
66
|
-
raise Exception(s) from e
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def custom(path='path/to/model.pt', autoshape=True, _verbose=True, device=None):
|
|
70
|
-
# YOLOv5 custom or local model
|
|
71
|
-
return _create(path, autoshape=autoshape, verbose=_verbose, device=device)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def yolov5n(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
75
|
-
# YOLOv5-nano model https://github.com/ultralytics/yolov5
|
|
76
|
-
return _create('yolov5n', pretrained, channels, classes, autoshape, _verbose, device)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def yolov5s(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
80
|
-
# YOLOv5-small model https://github.com/ultralytics/yolov5
|
|
81
|
-
return _create('yolov5s', pretrained, channels, classes, autoshape, _verbose, device)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def yolov5m(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
85
|
-
# YOLOv5-medium model https://github.com/ultralytics/yolov5
|
|
86
|
-
return _create('yolov5m', pretrained, channels, classes, autoshape, _verbose, device)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def yolov5l(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
90
|
-
# YOLOv5-large model https://github.com/ultralytics/yolov5
|
|
91
|
-
return _create('yolov5l', pretrained, channels, classes, autoshape, _verbose, device)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def yolov5x(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
95
|
-
# YOLOv5-xlarge model https://github.com/ultralytics/yolov5
|
|
96
|
-
return _create('yolov5x', pretrained, channels, classes, autoshape, _verbose, device)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def yolov5n6(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
100
|
-
# YOLOv5-nano-P6 model https://github.com/ultralytics/yolov5
|
|
101
|
-
return _create('yolov5n6', pretrained, channels, classes, autoshape, _verbose, device)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def yolov5s6(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
105
|
-
# YOLOv5-small-P6 model https://github.com/ultralytics/yolov5
|
|
106
|
-
return _create('yolov5s6', pretrained, channels, classes, autoshape, _verbose, device)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def yolov5m6(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
110
|
-
# YOLOv5-medium-P6 model https://github.com/ultralytics/yolov5
|
|
111
|
-
return _create('yolov5m6', pretrained, channels, classes, autoshape, _verbose, device)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def yolov5l6(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
115
|
-
# YOLOv5-large-P6 model https://github.com/ultralytics/yolov5
|
|
116
|
-
return _create('yolov5l6', pretrained, channels, classes, autoshape, _verbose, device)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def yolov5x6(pretrained=True, channels=3, classes=80, autoshape=True, _verbose=True, device=None):
|
|
120
|
-
# YOLOv5-xlarge-P6 model https://github.com/ultralytics/yolov5
|
|
121
|
-
return _create('yolov5x6', pretrained, channels, classes, autoshape, _verbose, device)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if __name__ == '__main__':
|
|
125
|
-
model = _create(name='yolov5s', pretrained=True, channels=3, classes=80, autoshape=True, verbose=True)
|
|
126
|
-
# model = custom(path='path/to/model.pt') # custom
|
|
127
|
-
|
|
128
|
-
# Verify inference
|
|
129
|
-
from pathlib import Path
|
|
130
|
-
|
|
131
|
-
import numpy as np
|
|
132
|
-
from PIL import Image
|
|
133
|
-
|
|
134
|
-
from utils.general import cv2
|
|
135
|
-
|
|
136
|
-
imgs = [
|
|
137
|
-
'data/images/zidane.jpg', # filename
|
|
138
|
-
Path('data/images/zidane.jpg'), # Path
|
|
139
|
-
'https://ultralytics.com/images/zidane.jpg', # URI
|
|
140
|
-
cv2.imread('data/images/bus.jpg')[:, :, ::-1], # OpenCV
|
|
141
|
-
Image.open('data/images/bus.jpg'), # PIL
|
|
142
|
-
np.zeros((320, 640, 3))] # numpy
|
|
143
|
-
|
|
144
|
-
results = model(imgs, size=320) # batched inference
|
|
145
|
-
results.print()
|
|
146
|
-
results.save()
|
|
File without changes
|