megadetector 5.0.28__py3-none-any.whl → 10.0.0__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/integration/digiKam/xmp_integration.py +2 -2
- megadetector/api/batch_processing/integration/eMammal/test_scripts/push_annotations_to_emammal.py +1 -1
- megadetector/api/batch_processing/integration/eMammal/test_scripts/select_images_for_testing.py +1 -1
- megadetector/classification/aggregate_classifier_probs.py +3 -3
- megadetector/classification/analyze_failed_images.py +5 -5
- megadetector/classification/cache_batchapi_outputs.py +5 -5
- megadetector/classification/create_classification_dataset.py +11 -12
- megadetector/classification/crop_detections.py +10 -10
- megadetector/classification/csv_to_json.py +8 -8
- megadetector/classification/detect_and_crop.py +13 -15
- megadetector/classification/efficientnet/model.py +8 -8
- megadetector/classification/efficientnet/utils.py +6 -5
- megadetector/classification/evaluate_model.py +7 -7
- megadetector/classification/identify_mislabeled_candidates.py +6 -6
- megadetector/classification/json_to_azcopy_list.py +1 -1
- megadetector/classification/json_validator.py +29 -32
- megadetector/classification/map_classification_categories.py +9 -9
- megadetector/classification/merge_classification_detection_output.py +12 -9
- megadetector/classification/prepare_classification_script.py +19 -19
- megadetector/classification/prepare_classification_script_mc.py +26 -26
- megadetector/classification/run_classifier.py +4 -4
- megadetector/classification/save_mislabeled.py +6 -6
- megadetector/classification/train_classifier.py +1 -1
- megadetector/classification/train_classifier_tf.py +9 -9
- megadetector/classification/train_utils.py +10 -10
- megadetector/data_management/annotations/annotation_constants.py +1 -2
- megadetector/data_management/camtrap_dp_to_coco.py +79 -46
- megadetector/data_management/cct_json_utils.py +103 -103
- megadetector/data_management/cct_to_md.py +49 -49
- megadetector/data_management/cct_to_wi.py +33 -33
- megadetector/data_management/coco_to_labelme.py +75 -75
- megadetector/data_management/coco_to_yolo.py +210 -193
- megadetector/data_management/databases/add_width_and_height_to_db.py +86 -12
- megadetector/data_management/databases/combine_coco_camera_traps_files.py +40 -40
- megadetector/data_management/databases/integrity_check_json_db.py +228 -200
- megadetector/data_management/databases/subset_json_db.py +33 -33
- megadetector/data_management/generate_crops_from_cct.py +88 -39
- megadetector/data_management/get_image_sizes.py +54 -49
- megadetector/data_management/labelme_to_coco.py +133 -125
- megadetector/data_management/labelme_to_yolo.py +159 -73
- megadetector/data_management/lila/create_lila_blank_set.py +81 -83
- megadetector/data_management/lila/create_lila_test_set.py +32 -31
- megadetector/data_management/lila/create_links_to_md_results_files.py +18 -18
- megadetector/data_management/lila/download_lila_subset.py +21 -24
- megadetector/data_management/lila/generate_lila_per_image_labels.py +365 -107
- megadetector/data_management/lila/get_lila_annotation_counts.py +35 -33
- megadetector/data_management/lila/get_lila_image_counts.py +22 -22
- megadetector/data_management/lila/lila_common.py +73 -70
- megadetector/data_management/lila/test_lila_metadata_urls.py +28 -19
- megadetector/data_management/mewc_to_md.py +344 -340
- megadetector/data_management/ocr_tools.py +262 -255
- megadetector/data_management/read_exif.py +249 -227
- megadetector/data_management/remap_coco_categories.py +90 -28
- megadetector/data_management/remove_exif.py +81 -21
- megadetector/data_management/rename_images.py +187 -187
- megadetector/data_management/resize_coco_dataset.py +588 -120
- megadetector/data_management/speciesnet_to_md.py +41 -41
- megadetector/data_management/wi_download_csv_to_coco.py +55 -55
- megadetector/data_management/yolo_output_to_md_output.py +248 -122
- megadetector/data_management/yolo_to_coco.py +333 -191
- megadetector/detection/change_detection.py +832 -0
- megadetector/detection/process_video.py +340 -337
- megadetector/detection/pytorch_detector.py +358 -278
- megadetector/detection/run_detector.py +399 -186
- megadetector/detection/run_detector_batch.py +404 -377
- megadetector/detection/run_inference_with_yolov5_val.py +340 -327
- megadetector/detection/run_tiled_inference.py +257 -249
- megadetector/detection/tf_detector.py +24 -24
- megadetector/detection/video_utils.py +332 -295
- megadetector/postprocessing/add_max_conf.py +19 -11
- megadetector/postprocessing/categorize_detections_by_size.py +45 -45
- megadetector/postprocessing/classification_postprocessing.py +468 -433
- megadetector/postprocessing/combine_batch_outputs.py +23 -23
- megadetector/postprocessing/compare_batch_results.py +590 -525
- megadetector/postprocessing/convert_output_format.py +106 -102
- megadetector/postprocessing/create_crop_folder.py +347 -147
- megadetector/postprocessing/detector_calibration.py +173 -168
- megadetector/postprocessing/generate_csv_report.py +508 -499
- megadetector/postprocessing/load_api_results.py +48 -27
- megadetector/postprocessing/md_to_coco.py +133 -102
- megadetector/postprocessing/md_to_labelme.py +107 -90
- megadetector/postprocessing/md_to_wi.py +40 -40
- megadetector/postprocessing/merge_detections.py +92 -114
- megadetector/postprocessing/postprocess_batch_results.py +319 -301
- megadetector/postprocessing/remap_detection_categories.py +91 -38
- megadetector/postprocessing/render_detection_confusion_matrix.py +214 -205
- megadetector/postprocessing/repeat_detection_elimination/find_repeat_detections.py +57 -57
- megadetector/postprocessing/repeat_detection_elimination/remove_repeat_detections.py +27 -28
- megadetector/postprocessing/repeat_detection_elimination/repeat_detections_core.py +704 -679
- megadetector/postprocessing/separate_detections_into_folders.py +226 -211
- megadetector/postprocessing/subset_json_detector_output.py +265 -262
- megadetector/postprocessing/top_folders_to_bottom.py +45 -45
- megadetector/postprocessing/validate_batch_results.py +70 -70
- megadetector/taxonomy_mapping/map_lila_taxonomy_to_wi_taxonomy.py +52 -52
- megadetector/taxonomy_mapping/map_new_lila_datasets.py +18 -19
- megadetector/taxonomy_mapping/prepare_lila_taxonomy_release.py +54 -33
- megadetector/taxonomy_mapping/preview_lila_taxonomy.py +67 -67
- megadetector/taxonomy_mapping/retrieve_sample_image.py +16 -16
- megadetector/taxonomy_mapping/simple_image_download.py +8 -8
- megadetector/taxonomy_mapping/species_lookup.py +156 -74
- megadetector/taxonomy_mapping/taxonomy_csv_checker.py +14 -14
- megadetector/taxonomy_mapping/taxonomy_graph.py +10 -10
- megadetector/taxonomy_mapping/validate_lila_category_mappings.py +13 -13
- megadetector/utils/ct_utils.py +1049 -211
- megadetector/utils/directory_listing.py +21 -77
- megadetector/utils/gpu_test.py +22 -22
- megadetector/utils/md_tests.py +632 -529
- megadetector/utils/path_utils.py +1520 -431
- megadetector/utils/process_utils.py +41 -41
- megadetector/utils/split_locations_into_train_val.py +62 -62
- megadetector/utils/string_utils.py +148 -27
- megadetector/utils/url_utils.py +489 -176
- megadetector/utils/wi_utils.py +2658 -2526
- megadetector/utils/write_html_image_list.py +137 -137
- megadetector/visualization/plot_utils.py +34 -30
- megadetector/visualization/render_images_with_thumbnails.py +39 -74
- megadetector/visualization/visualization_utils.py +487 -435
- megadetector/visualization/visualize_db.py +232 -198
- megadetector/visualization/visualize_detector_output.py +82 -76
- {megadetector-5.0.28.dist-info → megadetector-10.0.0.dist-info}/METADATA +5 -2
- megadetector-10.0.0.dist-info/RECORD +139 -0
- {megadetector-5.0.28.dist-info → megadetector-10.0.0.dist-info}/WHEEL +1 -1
- megadetector/api/batch_processing/api_core/__init__.py +0 -0
- megadetector/api/batch_processing/api_core/batch_service/__init__.py +0 -0
- megadetector/api/batch_processing/api_core/batch_service/score.py +0 -439
- megadetector/api/batch_processing/api_core/server.py +0 -294
- megadetector/api/batch_processing/api_core/server_api_config.py +0 -97
- megadetector/api/batch_processing/api_core/server_app_config.py +0 -55
- megadetector/api/batch_processing/api_core/server_batch_job_manager.py +0 -220
- megadetector/api/batch_processing/api_core/server_job_status_table.py +0 -149
- megadetector/api/batch_processing/api_core/server_orchestration.py +0 -360
- megadetector/api/batch_processing/api_core/server_utils.py +0 -88
- megadetector/api/batch_processing/api_core_support/__init__.py +0 -0
- megadetector/api/batch_processing/api_core_support/aggregate_results_manually.py +0 -46
- megadetector/api/batch_processing/api_support/__init__.py +0 -0
- megadetector/api/batch_processing/api_support/summarize_daily_activity.py +0 -152
- megadetector/api/batch_processing/data_preparation/__init__.py +0 -0
- megadetector/api/synchronous/__init__.py +0 -0
- megadetector/api/synchronous/api_core/animal_detection_api/__init__.py +0 -0
- megadetector/api/synchronous/api_core/animal_detection_api/api_backend.py +0 -151
- megadetector/api/synchronous/api_core/animal_detection_api/api_frontend.py +0 -263
- megadetector/api/synchronous/api_core/animal_detection_api/config.py +0 -35
- megadetector/api/synchronous/api_core/tests/__init__.py +0 -0
- megadetector/api/synchronous/api_core/tests/load_test.py +0 -110
- megadetector/data_management/importers/add_nacti_sizes.py +0 -52
- megadetector/data_management/importers/add_timestamps_to_icct.py +0 -79
- megadetector/data_management/importers/animl_results_to_md_results.py +0 -158
- megadetector/data_management/importers/auckland_doc_test_to_json.py +0 -373
- megadetector/data_management/importers/auckland_doc_to_json.py +0 -201
- megadetector/data_management/importers/awc_to_json.py +0 -191
- megadetector/data_management/importers/bellevue_to_json.py +0 -272
- megadetector/data_management/importers/cacophony-thermal-importer.py +0 -793
- megadetector/data_management/importers/carrizo_shrubfree_2018.py +0 -269
- megadetector/data_management/importers/carrizo_trail_cam_2017.py +0 -289
- megadetector/data_management/importers/cct_field_adjustments.py +0 -58
- megadetector/data_management/importers/channel_islands_to_cct.py +0 -913
- megadetector/data_management/importers/eMammal/copy_and_unzip_emammal.py +0 -180
- megadetector/data_management/importers/eMammal/eMammal_helpers.py +0 -249
- megadetector/data_management/importers/eMammal/make_eMammal_json.py +0 -223
- megadetector/data_management/importers/ena24_to_json.py +0 -276
- megadetector/data_management/importers/filenames_to_json.py +0 -386
- megadetector/data_management/importers/helena_to_cct.py +0 -283
- megadetector/data_management/importers/idaho-camera-traps.py +0 -1407
- megadetector/data_management/importers/idfg_iwildcam_lila_prep.py +0 -294
- megadetector/data_management/importers/import_desert_lion_conservation_camera_traps.py +0 -387
- megadetector/data_management/importers/jb_csv_to_json.py +0 -150
- megadetector/data_management/importers/mcgill_to_json.py +0 -250
- megadetector/data_management/importers/missouri_to_json.py +0 -490
- megadetector/data_management/importers/nacti_fieldname_adjustments.py +0 -79
- megadetector/data_management/importers/noaa_seals_2019.py +0 -181
- megadetector/data_management/importers/osu-small-animals-to-json.py +0 -364
- megadetector/data_management/importers/pc_to_json.py +0 -365
- megadetector/data_management/importers/plot_wni_giraffes.py +0 -123
- megadetector/data_management/importers/prepare_zsl_imerit.py +0 -131
- megadetector/data_management/importers/raic_csv_to_md_results.py +0 -416
- megadetector/data_management/importers/rspb_to_json.py +0 -356
- megadetector/data_management/importers/save_the_elephants_survey_A.py +0 -320
- megadetector/data_management/importers/save_the_elephants_survey_B.py +0 -329
- megadetector/data_management/importers/snapshot_safari_importer.py +0 -758
- megadetector/data_management/importers/snapshot_serengeti_lila.py +0 -1067
- megadetector/data_management/importers/snapshotserengeti/make_full_SS_json.py +0 -150
- megadetector/data_management/importers/snapshotserengeti/make_per_season_SS_json.py +0 -153
- megadetector/data_management/importers/sulross_get_exif.py +0 -65
- megadetector/data_management/importers/timelapse_csv_set_to_json.py +0 -490
- megadetector/data_management/importers/ubc_to_json.py +0 -399
- megadetector/data_management/importers/umn_to_json.py +0 -507
- megadetector/data_management/importers/wellington_to_json.py +0 -263
- megadetector/data_management/importers/wi_to_json.py +0 -442
- megadetector/data_management/importers/zamba_results_to_md_results.py +0 -180
- megadetector/data_management/lila/add_locations_to_island_camera_traps.py +0 -101
- megadetector/data_management/lila/add_locations_to_nacti.py +0 -151
- megadetector/utils/azure_utils.py +0 -178
- megadetector/utils/sas_blob_utils.py +0 -509
- megadetector-5.0.28.dist-info/RECORD +0 -209
- /megadetector/{api/batch_processing/__init__.py → __init__.py} +0 -0
- {megadetector-5.0.28.dist-info → megadetector-10.0.0.dist-info}/licenses/LICENSE +0 -0
- {megadetector-5.0.28.dist-info → megadetector-10.0.0.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
directory_listing.py
|
|
4
4
|
|
|
5
|
-
Script for creating Apache-style HTML directory listings for a local directory
|
|
5
|
+
Script for creating Apache-style HTML directory listings for a local directory
|
|
6
6
|
and all its subdirectories.
|
|
7
7
|
|
|
8
8
|
Also includes a preview of a jpg file (the first in an alphabetical list),
|
|
@@ -15,7 +15,6 @@ if present.
|
|
|
15
15
|
import os
|
|
16
16
|
import sys
|
|
17
17
|
import argparse
|
|
18
|
-
import re
|
|
19
18
|
|
|
20
19
|
from megadetector.utils.path_utils import is_image_file
|
|
21
20
|
|
|
@@ -24,7 +23,7 @@ from megadetector.utils.path_utils import is_image_file
|
|
|
24
23
|
|
|
25
24
|
def create_plain_index(root, dirs, files, dirname=None):
|
|
26
25
|
"""
|
|
27
|
-
Creates the fairly plain HTML folder index including a preview of a single image file,
|
|
26
|
+
Creates the fairly plain HTML folder index including a preview of a single image file,
|
|
28
27
|
if any is present.
|
|
29
28
|
|
|
30
29
|
Args:
|
|
@@ -32,10 +31,10 @@ def create_plain_index(root, dirs, files, dirname=None):
|
|
|
32
31
|
[files] are relative to this root folder
|
|
33
32
|
dirs (list): list of strings, the directories in [root]
|
|
34
33
|
files (list): list of strings, the files in [root]
|
|
35
|
-
dirname (str, optional): name to print in the html,
|
|
34
|
+
dirname (str, optional): name to print in the html,
|
|
36
35
|
which may be different than [root]
|
|
37
36
|
|
|
38
|
-
Returns:
|
|
37
|
+
Returns:
|
|
39
38
|
str: HTML source of the directory listing
|
|
40
39
|
"""
|
|
41
40
|
|
|
@@ -67,7 +66,8 @@ def create_plain_index(root, dirs, files, dirname=None):
|
|
|
67
66
|
# jpg_file_sizes = [os.path.getsize(f) for f in jpg_files]
|
|
68
67
|
# largest_file_index = max(range(len(jpg_files)), key=lambda x: jpg_file_sizes[x])
|
|
69
68
|
|
|
70
|
-
html += "<a href='{0}'><img style='height:200px; float:right;' src='{0}' alt='Preview image'></a>\n"
|
|
69
|
+
html += "<a href='{0}'><img style='height:200px; float:right;' src='{0}' alt='Preview image'></a>\n".\
|
|
70
|
+
format(jpg_files[0])
|
|
71
71
|
else:
|
|
72
72
|
html += "\n"
|
|
73
73
|
# html += "<p style='width:15em; float:right; margin:0;'>[No preview available]</p>\n"
|
|
@@ -107,8 +107,10 @@ def create_plain_index(root, dirs, files, dirname=None):
|
|
|
107
107
|
# ...def create_plain_index(...)
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
def traverse_and_create_index(dir,
|
|
111
|
-
|
|
110
|
+
def traverse_and_create_index(dir,
|
|
111
|
+
overwrite_files=False,
|
|
112
|
+
template_fun=create_plain_index,
|
|
113
|
+
basepath=None):
|
|
112
114
|
"""
|
|
113
115
|
Recursively traverses the local directory [dir] and generates a index
|
|
114
116
|
file for each folder using [template_fun] to generate the HTML output.
|
|
@@ -116,13 +118,9 @@ def traverse_and_create_index(dir, sas_url=None, overwrite_files=False,
|
|
|
116
118
|
|
|
117
119
|
Args:
|
|
118
120
|
dir (str): directory to process
|
|
119
|
-
sas_url (str, optional): write-capable SAS URL that points to the same place as
|
|
120
|
-
[dir], used for the very esoteric scenario where [dir] is really a mounted
|
|
121
|
-
blob container, and we want to set the content-type on each file so the resulting
|
|
122
|
-
index can be viewed in a browser
|
|
123
121
|
overwrite_files (bool, optional): whether to over-write existing index file
|
|
124
|
-
template_fun (func, optional): function taking three arguments (string,
|
|
125
|
-
list of string, list of string) representing the current root, the list of folders,
|
|
122
|
+
template_fun (func, optional): function taking three arguments (string,
|
|
123
|
+
list of string, list of string) representing the current root, the list of folders,
|
|
126
124
|
and the list of files. Should return the HTML source of the index file.
|
|
127
125
|
basepath (str, optional): if not None, the name used for each subfolder in [dir]
|
|
128
126
|
in the output files will be relative to [basepath]
|
|
@@ -133,40 +131,6 @@ def traverse_and_create_index(dir, sas_url=None, overwrite_files=False,
|
|
|
133
131
|
# Make sure we remove the trailing /
|
|
134
132
|
dir = os.path.normpath(dir)
|
|
135
133
|
|
|
136
|
-
# If we want to set the content type in blob storage using a SAS URL
|
|
137
|
-
if sas_url:
|
|
138
|
-
|
|
139
|
-
from azure.storage.blob import BlobServiceClient, ContentSettings
|
|
140
|
-
|
|
141
|
-
# Example: sas_url = 'https://accname.blob.core.windows.net/bname/path/to/folder?st=...&se=...&sp=...&...'
|
|
142
|
-
if '?' in sas_url:
|
|
143
|
-
# 'https://accname.blob.core.windows.net/bname/path/to/folder' and 'st=...&se=...&sp=...&...'
|
|
144
|
-
base_url, sas_token = sas_url.split('?', 1)
|
|
145
|
-
else:
|
|
146
|
-
# 'https://accname.blob.core.windows.net/bname/path/to/folder' and None
|
|
147
|
-
base_url, sas_token = sas_url, None
|
|
148
|
-
# Remove https:// from base url
|
|
149
|
-
# 'accname.blob.core.windows.net/bname/path/to/folder'
|
|
150
|
-
base_url = base_url.split("//", 1)[1]
|
|
151
|
-
# Everything up to the first dot is account name
|
|
152
|
-
# 'accname'
|
|
153
|
-
account_name = base_url.split(".", 1)[0]
|
|
154
|
-
# get everything after the first /
|
|
155
|
-
# 'bname/path/to/folder'
|
|
156
|
-
query_string = base_url.split("/", 1)[1]
|
|
157
|
-
# Get container name and subfolder
|
|
158
|
-
if '/' in query_string:
|
|
159
|
-
# 'bname', 'path/to/folder'
|
|
160
|
-
container_name, container_folder = query_string.split("/", 1)
|
|
161
|
-
else:
|
|
162
|
-
container_name, container_folder = query_string, ''
|
|
163
|
-
|
|
164
|
-
# Prepare the storage access
|
|
165
|
-
target_settings = ContentSettings(content_type='text/html')
|
|
166
|
-
blob_service = BlobServiceClient(
|
|
167
|
-
account_url=f'{account_name}.blob.core.windows.net',
|
|
168
|
-
credential=sas_token)
|
|
169
|
-
|
|
170
134
|
# Traverse directory and all sub directories, excluding hidden files
|
|
171
135
|
for root, dirs, files in os.walk(dir):
|
|
172
136
|
|
|
@@ -193,40 +157,20 @@ def traverse_and_create_index(dir, sas_url=None, overwrite_files=False,
|
|
|
193
157
|
with open(output_file, 'wt') as fi:
|
|
194
158
|
fi.write(html)
|
|
195
159
|
|
|
196
|
-
# Set content type in blob storage
|
|
197
|
-
if sas_url:
|
|
198
|
-
import azure.common
|
|
199
|
-
if container_folder:
|
|
200
|
-
output_blob_path = container_folder + '/' + output_file[len(dir) + 1:]
|
|
201
|
-
else:
|
|
202
|
-
output_blob_path = output_file[len(dir) + 1:]
|
|
203
|
-
try:
|
|
204
|
-
blob_client = blob_service.get_blob_client(container_name, output_blob_path)
|
|
205
|
-
blob_client.set_http_headers(content_settings=target_settings)
|
|
206
|
-
except azure.common.AzureMissingResourceHttpError:
|
|
207
|
-
print('ERROR: It seems the SAS URL is incorrect or does not allow setting properties.')
|
|
208
|
-
return
|
|
209
|
-
|
|
210
160
|
# ...def traverse_and_create_index(...)
|
|
211
161
|
|
|
212
162
|
|
|
213
163
|
#%% Command-line driver
|
|
214
164
|
|
|
215
|
-
def main():
|
|
216
|
-
|
|
165
|
+
def main(): # noqa
|
|
166
|
+
|
|
217
167
|
parser = argparse.ArgumentParser()
|
|
218
|
-
|
|
219
|
-
parser.add_argument("directory", type=str,
|
|
168
|
+
|
|
169
|
+
parser.add_argument("directory", type=str,
|
|
220
170
|
help='Path to directory which should be traversed.')
|
|
221
|
-
parser.add_argument("--basepath", type=str,
|
|
222
|
-
help='Folder names will be printed relative to basepath, if specified',
|
|
171
|
+
parser.add_argument("--basepath", type=str,
|
|
172
|
+
help='Folder names will be printed relative to basepath, if specified',
|
|
223
173
|
default=None)
|
|
224
|
-
parser.add_argument("--sas_url", type=str,
|
|
225
|
-
help='Blobfuse does not set the content-type property ' + \
|
|
226
|
-
'properly and hence index.html won\'t be accessible in the browser. If you want to set the ' + \
|
|
227
|
-
'content-type in the corresponding blob storage, provide the SAS URL that corresponds to the ' + \
|
|
228
|
-
'directory, e.g. if *directory* is /mountpoint/path/to/folder, then *--sas_url* looks like ' + \
|
|
229
|
-
'"https://accname.blob.core.windows.net/bname/path/to/folder?st=...&se=...&sp=...&..."')
|
|
230
174
|
parser.add_argument("--enable_overwrite", action='store_true', default=False,
|
|
231
175
|
help='If set, the script will overwrite existing index.html files.')
|
|
232
176
|
|
|
@@ -237,10 +181,10 @@ def main():
|
|
|
237
181
|
args = parser.parse_args()
|
|
238
182
|
|
|
239
183
|
assert os.path.isdir(args.directory), "{} is not a valid directory".format(args.directory)
|
|
240
|
-
assert re.match(r'https?://[^\.]+\.blob\.core\.windows\.net/.+', args.sas_url), "--sas_url does not " + \
|
|
241
|
-
"match the format https://accname.blob.core.windows.net/bname/path/to/folder?..."
|
|
242
184
|
|
|
243
|
-
traverse_and_create_index(args.directory,
|
|
185
|
+
traverse_and_create_index(args.directory,
|
|
186
|
+
overwrite_files=args.enable_overwrite,
|
|
187
|
+
basepath=args.basepath)
|
|
244
188
|
|
|
245
189
|
if __name__ == '__main__':
|
|
246
190
|
main()
|
megadetector/utils/gpu_test.py
CHANGED
|
@@ -17,18 +17,18 @@ try:
|
|
|
17
17
|
except Exception:
|
|
18
18
|
pass
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
#%% Torch/TF test functions
|
|
22
22
|
|
|
23
23
|
def torch_test():
|
|
24
24
|
"""
|
|
25
25
|
Print diagnostic information about Torch/CUDA status, including Torch/CUDA versions
|
|
26
26
|
and all available CUDA device names.
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
Returns:
|
|
29
29
|
int: The number of CUDA devices reported by PyTorch.
|
|
30
30
|
"""
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
try:
|
|
33
33
|
import torch
|
|
34
34
|
except Exception as e: #noqa
|
|
@@ -43,11 +43,11 @@ def torch_test():
|
|
|
43
43
|
print('CuDNN version (according to PyTorch): {}'.format(torch.backends.cudnn.version()))
|
|
44
44
|
|
|
45
45
|
device_ids = list(range(torch.cuda.device_count()))
|
|
46
|
-
|
|
47
|
-
if len(device_ids) > 0:
|
|
46
|
+
|
|
47
|
+
if len(device_ids) > 0:
|
|
48
48
|
cuda_str = 'Found {} CUDA devices:'.format(len(device_ids))
|
|
49
49
|
print(cuda_str)
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
for device_id in device_ids:
|
|
52
52
|
device_name = 'unknown'
|
|
53
53
|
try:
|
|
@@ -57,33 +57,33 @@ def torch_test():
|
|
|
57
57
|
print('{}: {}'.format(device_id,device_name))
|
|
58
58
|
else:
|
|
59
59
|
print('No GPUs reported by PyTorch')
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
try:
|
|
62
62
|
if torch.backends.mps.is_built and torch.backends.mps.is_available():
|
|
63
63
|
print('PyTorch reports that Metal Performance Shaders are available')
|
|
64
64
|
except Exception:
|
|
65
|
-
pass
|
|
65
|
+
pass
|
|
66
66
|
return len(device_ids)
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def tf_test():
|
|
70
70
|
"""
|
|
71
71
|
Print diagnostic information about TF/CUDA status.
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
Returns:
|
|
74
|
-
int: The number of CUDA devices reported by PyTorch.
|
|
74
|
+
int: The number of CUDA devices reported by PyTorch.
|
|
75
75
|
"""
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
try:
|
|
78
78
|
import tensorflow as tf
|
|
79
79
|
except Exception as e: #noqa
|
|
80
80
|
print('TensorFlow unavailable, not running TF tests. TF import error was:\n{}'.format(
|
|
81
81
|
str(e)))
|
|
82
82
|
return
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
from tensorflow.python.platform import build_info as build
|
|
85
85
|
print(f"TF version: {tf.__version__}")
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
if 'cuda_version' not in build.build_info:
|
|
88
88
|
print('TF does not appear to be built with CUDA')
|
|
89
89
|
else:
|
|
@@ -98,28 +98,28 @@ def tf_test():
|
|
|
98
98
|
print("Linked TensorRT version: {}".format(trt.trt_utils._pywrap_py_utils.get_linked_tensorrt_version()))
|
|
99
99
|
except Exception:
|
|
100
100
|
print('Could not probe TensorRT version')
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
gpus = tf.config.list_physical_devices('GPU')
|
|
103
103
|
if gpus is None:
|
|
104
104
|
gpus = []
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
if len(gpus) > 0:
|
|
107
107
|
print('TensorFlow found the following GPUs:')
|
|
108
108
|
for gpu in gpus:
|
|
109
109
|
print(gpu.name)
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
else:
|
|
112
112
|
print('No GPUs reported by TensorFlow')
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
return len(gpus)
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
|
|
117
117
|
#%% Command-line driver
|
|
118
|
-
|
|
119
|
-
if __name__ == '__main__':
|
|
120
|
-
|
|
118
|
+
|
|
119
|
+
if __name__ == '__main__':
|
|
120
|
+
|
|
121
121
|
print('*** Running Torch tests ***\n')
|
|
122
122
|
torch_test()
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
print('\n*** Running TF tests ***\n')
|
|
125
125
|
tf_test()
|