megadetector 5.0.10__py3-none-any.whl → 5.0.12__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 → megadetector/api}/batch_processing/api_core/batch_service/score.py +2 -2
- {api → megadetector/api}/synchronous/api_core/animal_detection_api/api_backend.py +1 -1
- {api → megadetector/api}/synchronous/api_core/animal_detection_api/api_frontend.py +1 -1
- {classification → megadetector/classification}/analyze_failed_images.py +3 -3
- {classification → megadetector/classification}/cache_batchapi_outputs.py +1 -1
- {classification → megadetector/classification}/create_classification_dataset.py +1 -1
- {classification → megadetector/classification}/crop_detections.py +1 -1
- {classification → megadetector/classification}/detect_and_crop.py +5 -5
- {classification → megadetector/classification}/evaluate_model.py +1 -1
- {classification → megadetector/classification}/json_to_azcopy_list.py +2 -2
- {classification → megadetector/classification}/json_validator.py +13 -9
- {classification → megadetector/classification}/map_classification_categories.py +1 -1
- {classification → megadetector/classification}/merge_classification_detection_output.py +1 -1
- {classification → megadetector/classification}/run_classifier.py +2 -1
- {classification → megadetector/classification}/train_classifier.py +8 -6
- {classification → megadetector/classification}/train_classifier_tf.py +10 -9
- {classification → megadetector/classification}/train_utils.py +3 -2
- {data_management → megadetector/data_management}/camtrap_dp_to_coco.py +4 -3
- {data_management → megadetector/data_management}/cct_json_utils.py +2 -2
- {data_management → megadetector/data_management}/cct_to_md.py +1 -1
- {data_management → megadetector/data_management}/coco_to_labelme.py +1 -1
- {data_management → megadetector/data_management}/coco_to_yolo.py +1 -1
- {data_management → megadetector/data_management}/databases/integrity_check_json_db.py +2 -2
- {data_management → megadetector/data_management}/get_image_sizes.py +4 -3
- {data_management → megadetector/data_management}/importers/auckland_doc_test_to_json.py +6 -5
- {data_management → megadetector/data_management}/importers/auckland_doc_to_json.py +4 -3
- {data_management → megadetector/data_management}/importers/awc_to_json.py +6 -4
- {data_management → megadetector/data_management}/importers/bellevue_to_json.py +3 -3
- {data_management → megadetector/data_management}/importers/cacophony-thermal-importer.py +4 -4
- {data_management → megadetector/data_management}/importers/carrizo_shrubfree_2018.py +5 -4
- {data_management → megadetector/data_management}/importers/carrizo_trail_cam_2017.py +8 -6
- {data_management → megadetector/data_management}/importers/cct_field_adjustments.py +2 -1
- {data_management → megadetector/data_management}/importers/channel_islands_to_cct.py +2 -2
- {data_management → megadetector/data_management}/importers/ena24_to_json.py +6 -5
- {data_management → megadetector/data_management}/importers/filenames_to_json.py +2 -1
- {data_management → megadetector/data_management}/importers/helena_to_cct.py +7 -6
- {data_management → megadetector/data_management}/importers/idaho-camera-traps.py +6 -6
- {data_management → megadetector/data_management}/importers/idfg_iwildcam_lila_prep.py +4 -4
- {data_management → megadetector/data_management}/importers/jb_csv_to_json.py +1 -1
- {data_management → megadetector/data_management}/importers/missouri_to_json.py +4 -3
- {data_management → megadetector/data_management}/importers/noaa_seals_2019.py +2 -2
- {data_management → megadetector/data_management}/importers/pc_to_json.py +5 -5
- {data_management → megadetector/data_management}/importers/prepare-noaa-fish-data-for-lila.py +3 -3
- {data_management → megadetector/data_management}/importers/prepare_zsl_imerit.py +3 -3
- {data_management → megadetector/data_management}/importers/rspb_to_json.py +2 -2
- {data_management → megadetector/data_management}/importers/save_the_elephants_survey_A.py +4 -4
- {data_management → megadetector/data_management}/importers/save_the_elephants_survey_B.py +6 -9
- {data_management → megadetector/data_management}/importers/snapshot_safari_importer.py +4 -4
- {data_management → megadetector/data_management}/importers/snapshot_safari_importer_reprise.py +2 -2
- {data_management → megadetector/data_management}/importers/snapshot_serengeti_lila.py +4 -4
- {data_management → megadetector/data_management}/importers/timelapse_csv_set_to_json.py +3 -3
- {data_management → megadetector/data_management}/importers/ubc_to_json.py +3 -3
- {data_management → megadetector/data_management}/importers/umn_to_json.py +2 -2
- {data_management → megadetector/data_management}/importers/wellington_to_json.py +3 -3
- {data_management → megadetector/data_management}/importers/wi_to_json.py +3 -2
- {data_management → megadetector/data_management}/labelme_to_coco.py +6 -7
- {data_management → megadetector/data_management}/labelme_to_yolo.py +2 -2
- {data_management → megadetector/data_management}/lila/add_locations_to_island_camera_traps.py +4 -4
- {data_management → megadetector/data_management}/lila/create_lila_blank_set.py +10 -9
- {data_management → megadetector/data_management}/lila/create_lila_test_set.py +3 -2
- {data_management → megadetector/data_management}/lila/create_links_to_md_results_files.py +1 -1
- {data_management → megadetector/data_management}/lila/download_lila_subset.py +5 -4
- {data_management → megadetector/data_management}/lila/generate_lila_per_image_labels.py +6 -5
- {data_management → megadetector/data_management}/lila/get_lila_annotation_counts.py +2 -2
- {data_management → megadetector/data_management}/lila/get_lila_image_counts.py +2 -1
- {data_management → megadetector/data_management}/lila/lila_common.py +5 -5
- {data_management → megadetector/data_management}/lila/test_lila_metadata_urls.py +2 -2
- {data_management → megadetector/data_management}/ocr_tools.py +6 -6
- {data_management → megadetector/data_management}/read_exif.py +2 -2
- {data_management → megadetector/data_management}/remap_coco_categories.py +1 -1
- {data_management → megadetector/data_management}/remove_exif.py +1 -1
- {data_management → megadetector/data_management}/resize_coco_dataset.py +4 -4
- {data_management → megadetector/data_management}/wi_download_csv_to_coco.py +3 -3
- {data_management → megadetector/data_management}/yolo_output_to_md_output.py +5 -5
- {data_management → megadetector/data_management}/yolo_to_coco.py +9 -9
- {detection → megadetector/detection}/process_video.py +9 -10
- {detection → megadetector/detection}/pytorch_detector.py +12 -8
- {detection → megadetector/detection}/run_detector.py +6 -6
- {detection → megadetector/detection}/run_detector_batch.py +12 -12
- {detection → megadetector/detection}/run_inference_with_yolov5_val.py +12 -12
- {detection → megadetector/detection}/run_tiled_inference.py +8 -9
- {detection → megadetector/detection}/tf_detector.py +3 -2
- {detection → megadetector/detection}/video_utils.py +2 -2
- {api/batch_processing → megadetector}/postprocessing/add_max_conf.py +1 -1
- {api/batch_processing → megadetector}/postprocessing/categorize_detections_by_size.py +1 -1
- {api/batch_processing → megadetector}/postprocessing/combine_api_outputs.py +1 -1
- {api/batch_processing → megadetector}/postprocessing/compare_batch_results.py +5 -5
- {api/batch_processing → megadetector}/postprocessing/convert_output_format.py +4 -5
- {api/batch_processing → megadetector}/postprocessing/load_api_results.py +1 -1
- {api/batch_processing → megadetector}/postprocessing/md_to_coco.py +3 -3
- {api/batch_processing → megadetector}/postprocessing/md_to_labelme.py +3 -3
- {api/batch_processing → megadetector}/postprocessing/merge_detections.py +1 -1
- {api/batch_processing → megadetector}/postprocessing/postprocess_batch_results.py +19 -21
- {api/batch_processing → megadetector}/postprocessing/remap_detection_categories.py +1 -1
- {api/batch_processing → megadetector}/postprocessing/render_detection_confusion_matrix.py +5 -6
- {api/batch_processing → megadetector}/postprocessing/repeat_detection_elimination/find_repeat_detections.py +3 -3
- {api/batch_processing → megadetector}/postprocessing/repeat_detection_elimination/remove_repeat_detections.py +3 -2
- {api/batch_processing → megadetector}/postprocessing/repeat_detection_elimination/repeat_detections_core.py +11 -11
- {api/batch_processing → megadetector}/postprocessing/separate_detections_into_folders.py +3 -4
- {api/batch_processing → megadetector}/postprocessing/subset_json_detector_output.py +2 -2
- {api/batch_processing → megadetector}/postprocessing/top_folders_to_bottom.py +1 -1
- {taxonomy_mapping → megadetector/taxonomy_mapping}/map_lila_taxonomy_to_wi_taxonomy.py +2 -2
- {taxonomy_mapping → megadetector/taxonomy_mapping}/map_new_lila_datasets.py +2 -6
- {taxonomy_mapping → megadetector/taxonomy_mapping}/preview_lila_taxonomy.py +6 -7
- {taxonomy_mapping → megadetector/taxonomy_mapping}/retrieve_sample_image.py +1 -1
- {taxonomy_mapping → megadetector/taxonomy_mapping}/simple_image_download.py +2 -1
- {taxonomy_mapping → megadetector/taxonomy_mapping}/species_lookup.py +1 -1
- {taxonomy_mapping → megadetector/taxonomy_mapping}/taxonomy_csv_checker.py +1 -1
- {taxonomy_mapping → megadetector/taxonomy_mapping}/validate_lila_category_mappings.py +1 -1
- {md_utils → megadetector/utils}/azure_utils.py +7 -3
- {md_utils → megadetector/utils}/directory_listing.py +1 -1
- {md_utils → megadetector/utils}/md_tests.py +29 -29
- {md_utils → megadetector/utils}/split_locations_into_train_val.py +1 -1
- {md_utils → megadetector/utils}/write_html_image_list.py +1 -1
- {md_visualization → megadetector/visualization}/render_images_with_thumbnails.py +3 -3
- {md_visualization → megadetector/visualization}/visualization_utils.py +6 -7
- {md_visualization → megadetector/visualization}/visualize_db.py +3 -4
- {md_visualization → megadetector/visualization}/visualize_detector_output.py +9 -10
- {megadetector-5.0.10.dist-info → megadetector-5.0.12.dist-info}/LICENSE +0 -0
- {megadetector-5.0.10.dist-info → megadetector-5.0.12.dist-info}/METADATA +12 -11
- megadetector-5.0.12.dist-info/RECORD +199 -0
- megadetector-5.0.12.dist-info/top_level.txt +1 -0
- api/batch_processing/data_preparation/manage_local_batch.py +0 -2391
- api/batch_processing/data_preparation/manage_video_batch.py +0 -327
- api/synchronous/api_core/animal_detection_api/data_management/annotations/annotation_constants.py +0 -47
- api/synchronous/api_core/animal_detection_api/detection/detector_training/copy_checkpoints.py +0 -43
- api/synchronous/api_core/animal_detection_api/detection/process_video.py +0 -543
- api/synchronous/api_core/animal_detection_api/detection/pytorch_detector.py +0 -304
- api/synchronous/api_core/animal_detection_api/detection/run_detector.py +0 -627
- api/synchronous/api_core/animal_detection_api/detection/run_detector_batch.py +0 -1029
- api/synchronous/api_core/animal_detection_api/detection/run_inference_with_yolov5_val.py +0 -581
- api/synchronous/api_core/animal_detection_api/detection/run_tiled_inference.py +0 -754
- api/synchronous/api_core/animal_detection_api/detection/tf_detector.py +0 -165
- api/synchronous/api_core/animal_detection_api/detection/video_utils.py +0 -495
- api/synchronous/api_core/animal_detection_api/md_utils/azure_utils.py +0 -174
- api/synchronous/api_core/animal_detection_api/md_utils/ct_utils.py +0 -262
- api/synchronous/api_core/animal_detection_api/md_utils/directory_listing.py +0 -251
- api/synchronous/api_core/animal_detection_api/md_utils/matlab_porting_tools.py +0 -97
- api/synchronous/api_core/animal_detection_api/md_utils/path_utils.py +0 -416
- api/synchronous/api_core/animal_detection_api/md_utils/process_utils.py +0 -110
- api/synchronous/api_core/animal_detection_api/md_utils/sas_blob_utils.py +0 -509
- api/synchronous/api_core/animal_detection_api/md_utils/string_utils.py +0 -59
- api/synchronous/api_core/animal_detection_api/md_utils/url_utils.py +0 -144
- api/synchronous/api_core/animal_detection_api/md_utils/write_html_image_list.py +0 -226
- api/synchronous/api_core/animal_detection_api/md_visualization/visualization_utils.py +0 -841
- detection/detector_training/model_main_tf2.py +0 -114
- docs/source/conf.py +0 -43
- megadetector-5.0.10.dist-info/RECORD +0 -224
- megadetector-5.0.10.dist-info/top_level.txt +0 -8
- {api → megadetector/api}/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/batch_service/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server_api_config.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server_app_config.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server_batch_job_manager.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server_job_status_table.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server_orchestration.py +0 -0
- {api → megadetector/api}/batch_processing/api_core/server_utils.py +0 -0
- {api → megadetector/api}/batch_processing/api_core_support/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/api_core_support/aggregate_results_manually.py +0 -0
- {api → megadetector/api}/batch_processing/api_support/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/api_support/summarize_daily_activity.py +0 -0
- {api → megadetector/api}/batch_processing/data_preparation/__init__.py +0 -0
- {api → megadetector/api}/batch_processing/integration/digiKam/setup.py +0 -0
- {api → megadetector/api}/batch_processing/integration/digiKam/xmp_integration.py +0 -0
- {api → megadetector/api}/batch_processing/integration/eMammal/test_scripts/config_template.py +0 -0
- {api → megadetector/api}/batch_processing/integration/eMammal/test_scripts/push_annotations_to_emammal.py +0 -0
- {api → megadetector/api}/batch_processing/integration/eMammal/test_scripts/select_images_for_testing.py +0 -0
- {api/batch_processing/postprocessing → megadetector/api/synchronous}/__init__.py +0 -0
- {api/synchronous → megadetector/api/synchronous/api_core/animal_detection_api}/__init__.py +0 -0
- {api → megadetector/api}/synchronous/api_core/animal_detection_api/config.py +0 -0
- {api/synchronous/api_core/animal_detection_api → megadetector/api/synchronous/api_core/tests}/__init__.py +0 -0
- {api → megadetector/api}/synchronous/api_core/tests/load_test.py +0 -0
- {api/synchronous/api_core/tests → megadetector/classification}/__init__.py +0 -0
- {classification → megadetector/classification}/aggregate_classifier_probs.py +0 -0
- {classification → megadetector/classification}/csv_to_json.py +0 -0
- {classification → megadetector/classification}/efficientnet/__init__.py +0 -0
- {classification → megadetector/classification}/efficientnet/model.py +0 -0
- {classification → megadetector/classification}/efficientnet/utils.py +0 -0
- {classification → megadetector/classification}/identify_mislabeled_candidates.py +0 -0
- {classification → megadetector/classification}/prepare_classification_script.py +0 -0
- {classification → megadetector/classification}/prepare_classification_script_mc.py +0 -0
- {classification → megadetector/classification}/save_mislabeled.py +0 -0
- {classification → megadetector/data_management}/__init__.py +0 -0
- {data_management → megadetector/data_management/annotations}/__init__.py +0 -0
- {data_management → megadetector/data_management}/annotations/annotation_constants.py +0 -0
- {data_management → megadetector/data_management}/cct_to_wi.py +0 -0
- {data_management/annotations → megadetector/data_management/databases}/__init__.py +0 -0
- {data_management → megadetector/data_management}/databases/add_width_and_height_to_db.py +0 -0
- {data_management → megadetector/data_management}/databases/combine_coco_camera_traps_files.py +0 -0
- {data_management → megadetector/data_management}/databases/subset_json_db.py +0 -0
- {data_management → megadetector/data_management}/generate_crops_from_cct.py +0 -0
- {data_management → megadetector/data_management}/importers/add_nacti_sizes.py +0 -0
- {data_management → megadetector/data_management}/importers/add_timestamps_to_icct.py +0 -0
- {data_management → megadetector/data_management}/importers/animl_results_to_md_results.py +0 -0
- {data_management → megadetector/data_management}/importers/eMammal/copy_and_unzip_emammal.py +0 -0
- {data_management → megadetector/data_management}/importers/eMammal/eMammal_helpers.py +0 -0
- {data_management → megadetector/data_management}/importers/eMammal/make_eMammal_json.py +0 -0
- {data_management → megadetector/data_management}/importers/mcgill_to_json.py +0 -0
- {data_management → megadetector/data_management}/importers/nacti_fieldname_adjustments.py +0 -0
- {data_management → megadetector/data_management}/importers/plot_wni_giraffes.py +0 -0
- {data_management → megadetector/data_management}/importers/snapshotserengeti/make_full_SS_json.py +0 -0
- {data_management → megadetector/data_management}/importers/snapshotserengeti/make_per_season_SS_json.py +0 -0
- {data_management → megadetector/data_management}/importers/sulross_get_exif.py +0 -0
- {data_management → megadetector/data_management}/importers/zamba_results_to_md_results.py +0 -0
- {data_management/databases → megadetector/data_management/lila}/__init__.py +0 -0
- {data_management → megadetector/data_management}/lila/add_locations_to_nacti.py +0 -0
- {data_management/lila → megadetector/detection}/__init__.py +0 -0
- {detection → megadetector/detection/detector_training}/__init__.py +0 -0
- {api/synchronous/api_core/animal_detection_api → megadetector}/detection/detector_training/model_main_tf2.py +0 -0
- {detection/detector_training → megadetector/postprocessing}/__init__.py +0 -0
- {md_utils → megadetector/taxonomy_mapping}/__init__.py +0 -0
- {taxonomy_mapping → megadetector/taxonomy_mapping}/prepare_lila_taxonomy_release.py +0 -0
- {taxonomy_mapping → megadetector/taxonomy_mapping}/taxonomy_graph.py +0 -0
- {md_visualization → megadetector/utils}/__init__.py +0 -0
- {md_utils → megadetector/utils}/ct_utils.py +0 -0
- {md_utils → megadetector/utils}/path_utils.py +0 -0
- {md_utils → megadetector/utils}/process_utils.py +0 -0
- {md_utils → megadetector/utils}/sas_blob_utils.py +0 -0
- {md_utils → megadetector/utils}/string_utils.py +0 -0
- {md_utils → megadetector/utils}/url_utils.py +0 -0
- {taxonomy_mapping → megadetector/visualization}/__init__.py +0 -0
- {md_visualization → megadetector/visualization}/plot_utils.py +0 -0
- {megadetector-5.0.10.dist-info → megadetector-5.0.12.dist-info}/WHEEL +0 -0
|
@@ -25,10 +25,10 @@ from multiprocessing.pool import ThreadPool
|
|
|
25
25
|
from urllib.parse import urlparse
|
|
26
26
|
from collections import defaultdict
|
|
27
27
|
|
|
28
|
-
from data_management.lila.lila_common import read_lila_all_images_file
|
|
29
|
-
from
|
|
30
|
-
from
|
|
31
|
-
from
|
|
28
|
+
from megadetector.data_management.lila.lila_common import read_lila_all_images_file
|
|
29
|
+
from megadetector.utils.url_utils import download_url
|
|
30
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
31
|
+
from megadetector.utils.path_utils import recursive_file_list
|
|
32
32
|
|
|
33
33
|
# We'll write images, metadata downloads, and temporary files here
|
|
34
34
|
lila_local_base = os.path.expanduser('~/lila')
|
|
@@ -137,7 +137,7 @@ for i_row,row in tqdm(df.iterrows(),total=len(df)):
|
|
|
137
137
|
|
|
138
138
|
#%% Look at the most common labels and common names
|
|
139
139
|
|
|
140
|
-
from
|
|
140
|
+
from megadetector.utils.ct_utils import sort_dictionary_by_value
|
|
141
141
|
common_name_to_count = sort_dictionary_by_value(common_name_to_count,reverse=True)
|
|
142
142
|
original_label_to_count = sort_dictionary_by_value(original_label_to_count,reverse=True)
|
|
143
143
|
|
|
@@ -283,7 +283,7 @@ print('Max samples per location: {}'.format(max_blanks_per_location))
|
|
|
283
283
|
#%% Download those image files (prep)
|
|
284
284
|
|
|
285
285
|
container_to_url_base = {
|
|
286
|
-
'
|
|
286
|
+
'lilawildlife.blob.core.windows.net':'/lila-wildlide/',
|
|
287
287
|
'storage.googleapis.com':'/public-datasets-lila/'
|
|
288
288
|
}
|
|
289
289
|
|
|
@@ -325,13 +325,14 @@ def download_relative_filename(url, output_base, verbose=False, url_base=None, o
|
|
|
325
325
|
result['status'] = 'success'
|
|
326
326
|
return result
|
|
327
327
|
|
|
328
|
+
|
|
328
329
|
def azure_url_to_gcp_http_url(url,error_if_not_azure_url=True):
|
|
329
330
|
"""
|
|
330
331
|
Most URLs point to Azure by default, but most files are available on both Azure and GCP.
|
|
331
332
|
This function converts an Azure URL to the corresponding GCP http:// url.
|
|
332
333
|
"""
|
|
333
334
|
|
|
334
|
-
lila_azure_storage_account = 'https://
|
|
335
|
+
lila_azure_storage_account = 'https://lilawildlife.blob.core.windows.net'
|
|
335
336
|
gcp_bucket_api_url = 'https://storage.googleapis.com/public-datasets-lila'
|
|
336
337
|
error_if_not_azure_url = False
|
|
337
338
|
|
|
@@ -469,7 +470,7 @@ assert len(removed_blank_images_relative) + len(remaining_images) == len(output_
|
|
|
469
470
|
|
|
470
471
|
#%% Copy only the confirmed blanks to the confirmed folder
|
|
471
472
|
|
|
472
|
-
from
|
|
473
|
+
from megadetector.utils.path_utils import is_image_file
|
|
473
474
|
|
|
474
475
|
all_candidate_blanks = recursive_file_list(candidate_blanks_base,return_relative_paths=True)
|
|
475
476
|
print('Found {} candidate blanks'.format(len(all_candidate_blanks)))
|
|
@@ -503,7 +504,7 @@ print('Skipped {} files ({} non-image files)'.format(len(skipped_images_relative
|
|
|
503
504
|
|
|
504
505
|
#%% Validate the folder of confirmed blanks
|
|
505
506
|
|
|
506
|
-
from
|
|
507
|
+
from megadetector.utils.path_utils import find_images
|
|
507
508
|
# all_confirmed_blanks = recursive_file_list(confirmed_blanks_base,return_relative_paths=True)
|
|
508
509
|
all_confirmed_blanks = find_images(confirmed_blanks_base,return_relative_paths=True,recursive=True)
|
|
509
510
|
assert len(all_confirmed_blanks) < len(all_candidate_blanks)
|
|
@@ -13,9 +13,10 @@ import json
|
|
|
13
13
|
import os
|
|
14
14
|
import random
|
|
15
15
|
|
|
16
|
-
from data_management.lila.lila_common import
|
|
16
|
+
from megadetector.data_management.lila.lila_common import \
|
|
17
|
+
read_lila_metadata, read_metadata_file_for_dataset
|
|
17
18
|
|
|
18
|
-
from
|
|
19
|
+
from megadetector.utils.url_utils import download_url
|
|
19
20
|
|
|
20
21
|
n_empty_images_per_dataset = 1
|
|
21
22
|
n_non_empty_images_per_dataset = 1
|
|
@@ -15,7 +15,8 @@ import random
|
|
|
15
15
|
from tqdm import tqdm
|
|
16
16
|
from collections import defaultdict
|
|
17
17
|
|
|
18
|
-
from data_management.lila.lila_common import
|
|
18
|
+
from megadetector.data_management.lila.lila_common import \
|
|
19
|
+
read_lila_all_images_file, is_empty, lila_base_urls
|
|
19
20
|
|
|
20
21
|
for s in lila_base_urls.values():
|
|
21
22
|
assert s.endswith('/')
|
|
@@ -102,7 +103,7 @@ else:
|
|
|
102
103
|
|
|
103
104
|
#%% Choose target files for each URL
|
|
104
105
|
|
|
105
|
-
from data_management.lila.lila_common import lila_base_urls
|
|
106
|
+
from megadetector.data_management.lila.lila_common import lila_base_urls
|
|
106
107
|
|
|
107
108
|
# We have a list of URLs per dataset, flatten that into a single list of URLs
|
|
108
109
|
urls_to_download = set()
|
|
@@ -134,7 +135,7 @@ for url in urls_to_download:
|
|
|
134
135
|
|
|
135
136
|
#%% Download image files
|
|
136
137
|
|
|
137
|
-
from
|
|
138
|
+
from megadetector.utils.url_utils import parallel_download_urls
|
|
138
139
|
|
|
139
140
|
download_results = parallel_download_urls(url_to_target_file=url_to_target_file,
|
|
140
141
|
verbose=False,
|
|
@@ -161,7 +162,7 @@ if False:
|
|
|
161
162
|
common_name_to_count[row['common_name']] += 1
|
|
162
163
|
dataset_to_count[row['dataset_name']] += 1
|
|
163
164
|
|
|
164
|
-
from
|
|
165
|
+
from megadetector.utils.ct_utils import sort_dictionary_by_value
|
|
165
166
|
|
|
166
167
|
print('Found {} reptiles\n'.format(len(reptile_rows)))
|
|
167
168
|
|
|
@@ -27,13 +27,14 @@ import csv
|
|
|
27
27
|
from collections import defaultdict
|
|
28
28
|
from tqdm import tqdm
|
|
29
29
|
|
|
30
|
-
from data_management.lila.lila_common import
|
|
30
|
+
from megadetector.data_management.lila.lila_common import \
|
|
31
|
+
read_lila_metadata, \
|
|
31
32
|
read_metadata_file_for_dataset, \
|
|
32
33
|
read_lila_taxonomy_mapping
|
|
33
34
|
|
|
34
|
-
from
|
|
35
|
-
from
|
|
36
|
-
from
|
|
35
|
+
from megadetector.utils import write_html_image_list
|
|
36
|
+
from megadetector.utils.path_utils import zip_file
|
|
37
|
+
from megadetector.utils.path_utils import open_file
|
|
37
38
|
|
|
38
39
|
# We'll write images, metadata downloads, and temporary files here
|
|
39
40
|
lila_local_base = os.path.expanduser('~/lila')
|
|
@@ -478,7 +479,7 @@ for i_image,image in tqdm(enumerate(images_to_download),total=len(images_to_down
|
|
|
478
479
|
|
|
479
480
|
#%% Download images (execution)
|
|
480
481
|
|
|
481
|
-
from
|
|
482
|
+
from megadetector.utils.url_utils import parallel_download_urls
|
|
482
483
|
download_results = parallel_download_urls(url_to_target_file,verbose=False,overwrite=True,
|
|
483
484
|
n_workers=20,pool_type='thread')
|
|
484
485
|
|
|
@@ -17,8 +17,8 @@ get_lila_image_counts.py counts the number of *images* for each category in each
|
|
|
17
17
|
import json
|
|
18
18
|
import os
|
|
19
19
|
|
|
20
|
-
from data_management.lila.lila_common import
|
|
21
|
-
read_metadata_file_for_dataset, read_lila_taxonomy_mapping
|
|
20
|
+
from megadetector.data_management.lila.lila_common import \
|
|
21
|
+
read_lila_metadata, read_metadata_file_for_dataset, read_lila_taxonomy_mapping
|
|
22
22
|
|
|
23
23
|
# cloud provider to use for downloading images; options are 'gcp', 'azure', or 'aws'
|
|
24
24
|
preferred_cloud = 'gcp'
|
|
@@ -17,7 +17,8 @@ import os
|
|
|
17
17
|
|
|
18
18
|
from collections import defaultdict
|
|
19
19
|
|
|
20
|
-
from data_management.lila.lila_common import
|
|
20
|
+
from megadetector.data_management.lila.lila_common import \
|
|
21
|
+
read_lila_metadata, read_metadata_file_for_dataset
|
|
21
22
|
|
|
22
23
|
# If None, will use all datasets
|
|
23
24
|
datasets_of_interest = None
|
|
@@ -15,9 +15,9 @@ import pandas as pd
|
|
|
15
15
|
|
|
16
16
|
from urllib.parse import urlparse
|
|
17
17
|
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
18
|
+
from megadetector.utils.url_utils import download_url
|
|
19
|
+
from megadetector.utils.path_utils import unzip_file
|
|
20
|
+
from megadetector.utils.ct_utils import is_empty
|
|
21
21
|
|
|
22
22
|
# LILA camera trap primary metadata file
|
|
23
23
|
lila_metadata_url = 'http://lila.science/wp-content/uploads/2023/06/lila_camera_trap_datasets.csv'
|
|
@@ -268,7 +268,7 @@ if False:
|
|
|
268
268
|
# LILA camera trap primary metadata file
|
|
269
269
|
urls = (lila_metadata_url,lila_taxonomy_mapping_url,lila_all_images_url,wildlife_insights_taxonomy_url)
|
|
270
270
|
|
|
271
|
-
from
|
|
271
|
+
from megadetector.utils import url_utils
|
|
272
272
|
|
|
273
273
|
status_codes = url_utils.test_urls(urls,timeout=2.0)
|
|
274
274
|
assert all([code == 200 for code in status_codes])
|
|
@@ -297,4 +297,4 @@ if False:
|
|
|
297
297
|
pool_type='process',
|
|
298
298
|
timeout=2.0)
|
|
299
299
|
assert all([code == 200 for code in status_codes])
|
|
300
|
-
|
|
300
|
+
|
|
@@ -16,7 +16,7 @@ Also picks an arbitrary image from each dataset's MD results and make sure the c
|
|
|
16
16
|
import json
|
|
17
17
|
import os
|
|
18
18
|
|
|
19
|
-
from data_management.lila.lila_common import read_lila_metadata,\
|
|
19
|
+
from megadetector.data_management.lila.lila_common import read_lila_metadata,\
|
|
20
20
|
read_metadata_file_for_dataset, read_lila_taxonomy_mapping
|
|
21
21
|
|
|
22
22
|
# We'll write images, metadata downloads, and temporary files here
|
|
@@ -115,7 +115,7 @@ for ds_name in metadata_table.keys():
|
|
|
115
115
|
|
|
116
116
|
#%% Test URLs
|
|
117
117
|
|
|
118
|
-
from
|
|
118
|
+
from megadetector.utils.url_utils import test_urls
|
|
119
119
|
|
|
120
120
|
urls_to_test = sorted(url_to_source.keys())
|
|
121
121
|
urls_to_test = [fn.replace('\\','/') for fn in urls_to_test]
|
|
@@ -54,11 +54,11 @@ import cv2
|
|
|
54
54
|
from PIL import Image, ImageFilter
|
|
55
55
|
from tqdm import tqdm
|
|
56
56
|
|
|
57
|
-
from
|
|
58
|
-
from
|
|
59
|
-
from
|
|
60
|
-
from
|
|
61
|
-
from
|
|
57
|
+
from megadetector.utils.path_utils import find_images
|
|
58
|
+
from megadetector.utils.path_utils import open_file
|
|
59
|
+
from megadetector.utils import write_html_image_list
|
|
60
|
+
from megadetector.utils.ct_utils import is_iterable
|
|
61
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
62
62
|
|
|
63
63
|
# pip install pytesseract
|
|
64
64
|
#
|
|
@@ -668,7 +668,7 @@ if False:
|
|
|
668
668
|
|
|
669
669
|
folder_name = r'g:\temp\island_conservation_camera_traps'
|
|
670
670
|
output_file = r'g:\temp\ocr_results.json'
|
|
671
|
-
from
|
|
671
|
+
from megadetector.utils.path_utils import insert_before_extension
|
|
672
672
|
output_file = insert_before_extension(output_file)
|
|
673
673
|
n_to_sample = -1
|
|
674
674
|
assert os.path.isdir(folder_name)
|
|
@@ -24,8 +24,8 @@ from multiprocessing.pool import Pool as Pool
|
|
|
24
24
|
from tqdm import tqdm
|
|
25
25
|
from PIL import Image, ExifTags
|
|
26
26
|
|
|
27
|
-
from
|
|
28
|
-
from
|
|
27
|
+
from megadetector.utils.path_utils import find_images, is_executable
|
|
28
|
+
from megadetector.utils.ct_utils import args_to_object
|
|
29
29
|
|
|
30
30
|
debug_max_images = None
|
|
31
31
|
|
|
@@ -16,8 +16,8 @@ import shutil
|
|
|
16
16
|
from tqdm import tqdm
|
|
17
17
|
from collections import defaultdict
|
|
18
18
|
|
|
19
|
-
from
|
|
20
|
-
from
|
|
19
|
+
from megadetector.utils.path_utils import insert_before_extension
|
|
20
|
+
from megadetector.visualization.visualization_utils import \
|
|
21
21
|
open_image, resize_image, exif_preserving_save
|
|
22
22
|
|
|
23
23
|
|
|
@@ -168,7 +168,7 @@ if False:
|
|
|
168
168
|
|
|
169
169
|
#%% Preview
|
|
170
170
|
|
|
171
|
-
from
|
|
171
|
+
from megadetector.visualization import visualize_db
|
|
172
172
|
options = visualize_db.DbVizOptions()
|
|
173
173
|
options.parallelize_rendering = True
|
|
174
174
|
options.viz_size = (900, -1)
|
|
@@ -179,7 +179,7 @@ if False:
|
|
|
179
179
|
output_folder,options)
|
|
180
180
|
|
|
181
181
|
|
|
182
|
-
from
|
|
182
|
+
from megadetector.utils import path_utils # noqa
|
|
183
183
|
path_utils.open_file(html_file)
|
|
184
184
|
|
|
185
185
|
|
|
@@ -17,8 +17,8 @@ import pandas as pd
|
|
|
17
17
|
from tqdm import tqdm
|
|
18
18
|
from collections import defaultdict
|
|
19
19
|
|
|
20
|
-
from
|
|
21
|
-
from
|
|
20
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
21
|
+
from megadetector.utils.ct_utils import isnan
|
|
22
22
|
|
|
23
23
|
wi_extra_annotation_columns = \
|
|
24
24
|
('is_blank','identified_by','wi_taxon_id','class','order','family','genus','species','uncertainty',
|
|
@@ -212,7 +212,7 @@ def wi_download_csv_to_coco(csv_file_in,
|
|
|
212
212
|
|
|
213
213
|
##%% Validate output
|
|
214
214
|
|
|
215
|
-
from data_management.databases.integrity_check_json_db import \
|
|
215
|
+
from megadetector.data_management.databases.integrity_check_json_db import \
|
|
216
216
|
IntegrityCheckOptions,integrity_check_json_db
|
|
217
217
|
options = IntegrityCheckOptions()
|
|
218
218
|
options.baseDir = image_folder
|
|
@@ -44,10 +44,10 @@ import re
|
|
|
44
44
|
from collections import defaultdict
|
|
45
45
|
from tqdm import tqdm
|
|
46
46
|
|
|
47
|
-
from
|
|
48
|
-
from
|
|
49
|
-
from
|
|
50
|
-
from detection.run_detector import CONF_DIGITS, COORD_DIGITS
|
|
47
|
+
from megadetector.utils import path_utils
|
|
48
|
+
from megadetector.utils import ct_utils
|
|
49
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
50
|
+
from megadetector.detection.run_detector import CONF_DIGITS, COORD_DIGITS
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
#%% Support functions
|
|
@@ -438,4 +438,4 @@ if False:
|
|
|
438
438
|
|
|
439
439
|
#%% Command-line driver
|
|
440
440
|
|
|
441
|
-
# TODO
|
|
441
|
+
# TODO
|
|
@@ -17,12 +17,12 @@ from functools import partial
|
|
|
17
17
|
|
|
18
18
|
from tqdm import tqdm
|
|
19
19
|
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from data_management.yolo_output_to_md_output import read_classes_from_yolo_dataset_file
|
|
20
|
+
from megadetector.utils.path_utils import find_images
|
|
21
|
+
from megadetector.utils.path_utils import recursive_file_list
|
|
22
|
+
from megadetector.utils.path_utils import find_image_strings
|
|
23
|
+
from megadetector.utils.ct_utils import invert_dictionary
|
|
24
|
+
from megadetector.visualization.visualization_utils import open_image
|
|
25
|
+
from megadetector.data_management.yolo_output_to_md_output import read_classes_from_yolo_dataset_file
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
#%% Support functions
|
|
@@ -639,7 +639,7 @@ if False:
|
|
|
639
639
|
|
|
640
640
|
#%% Check DB integrity
|
|
641
641
|
|
|
642
|
-
from data_management.databases import integrity_check_json_db
|
|
642
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
643
643
|
|
|
644
644
|
options = integrity_check_json_db.IntegrityCheckOptions()
|
|
645
645
|
options.baseDir = input_folder
|
|
@@ -652,7 +652,7 @@ if False:
|
|
|
652
652
|
|
|
653
653
|
#%% Preview some images
|
|
654
654
|
|
|
655
|
-
from
|
|
655
|
+
from megadetector.visualization import visualize_db
|
|
656
656
|
|
|
657
657
|
viz_options = visualize_db.DbVizOptions()
|
|
658
658
|
viz_options.num_to_visualize = None
|
|
@@ -667,7 +667,7 @@ if False:
|
|
|
667
667
|
image_base_dir=input_folder,
|
|
668
668
|
options=viz_options)
|
|
669
669
|
|
|
670
|
-
from
|
|
670
|
+
from megadetector.utils.path_utils import open_file
|
|
671
671
|
open_file(html_output_file)
|
|
672
672
|
|
|
673
673
|
|
|
@@ -26,16 +26,17 @@ import itertools
|
|
|
26
26
|
import json
|
|
27
27
|
import shutil
|
|
28
28
|
|
|
29
|
-
from detection import run_detector_batch
|
|
30
|
-
from md_visualization import visualize_detector_output
|
|
31
|
-
from md_utils.ct_utils import args_to_object
|
|
32
|
-
from detection.video_utils import video_to_frames
|
|
33
|
-
from detection.video_utils import frames_to_video
|
|
34
|
-
from detection.video_utils import frame_results_to_video_results
|
|
35
|
-
from detection.video_utils import video_folder_to_frames
|
|
36
29
|
from uuid import uuid1
|
|
37
30
|
|
|
38
|
-
from detection
|
|
31
|
+
from megadetector.detection import run_detector_batch
|
|
32
|
+
from megadetector.visualization import visualize_detector_output
|
|
33
|
+
from megadetector.utils.ct_utils import args_to_object
|
|
34
|
+
from megadetector.utils.path_utils import insert_before_extension
|
|
35
|
+
from megadetector.detection.video_utils import video_to_frames
|
|
36
|
+
from megadetector.detection.video_utils import frames_to_video
|
|
37
|
+
from megadetector.detection.video_utils import frame_results_to_video_results
|
|
38
|
+
from megadetector.detection.video_utils import video_folder_to_frames
|
|
39
|
+
from megadetector.detection.video_utils import default_fourcc
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
#%% Classes
|
|
@@ -433,8 +434,6 @@ def process_video_folder(options):
|
|
|
433
434
|
assert len(video_frame_files) > 0, 'Could not find rendered frames for video {}'.format(
|
|
434
435
|
input_video_file_relative)
|
|
435
436
|
|
|
436
|
-
from md_utils.path_utils import insert_before_extension
|
|
437
|
-
|
|
438
437
|
# Select the output filename for the rendered video
|
|
439
438
|
if output_folder_is_input_folder:
|
|
440
439
|
video_output_file = insert_before_extension(input_video_file_abs,'annotated','_')
|
|
@@ -8,12 +8,14 @@ Module to run MegaDetector v5, a PyTorch YOLOv5 animal detection model.
|
|
|
8
8
|
|
|
9
9
|
#%% Imports and constants
|
|
10
10
|
|
|
11
|
+
import sys
|
|
11
12
|
import torch
|
|
12
13
|
import numpy as np
|
|
13
14
|
import traceback
|
|
15
|
+
import builtins
|
|
14
16
|
|
|
15
|
-
from detection.run_detector import CONF_DIGITS, COORD_DIGITS, FAILURE_INFER
|
|
16
|
-
from
|
|
17
|
+
from megadetector.detection.run_detector import CONF_DIGITS, COORD_DIGITS, FAILURE_INFER
|
|
18
|
+
from megadetector.utils import ct_utils
|
|
17
19
|
|
|
18
20
|
# We support a few ways of accessing the YOLOv5 dependencies:
|
|
19
21
|
#
|
|
@@ -44,7 +46,8 @@ try_yolov5_import = True
|
|
|
44
46
|
# to use more recent YOLOv5 namespace conventions.
|
|
45
47
|
try_ultralytics_import = False
|
|
46
48
|
|
|
47
|
-
# First try importing from the yolov5 package
|
|
49
|
+
# First try importing from the yolov5 package; this is how the pip
|
|
50
|
+
# package finds YOLOv5 utilities.
|
|
48
51
|
if try_yolov5_import and not utils_imported:
|
|
49
52
|
|
|
50
53
|
try:
|
|
@@ -77,7 +80,7 @@ if try_ultralytics_import and not utils_imported:
|
|
|
77
80
|
# print('Ultralytics module import failed, falling back to yolov5 import')
|
|
78
81
|
pass
|
|
79
82
|
|
|
80
|
-
# If we haven't succeeded yet,
|
|
83
|
+
# If we haven't succeeded yet, assume the YOLOv5 repo is on our PYTHONPATH.
|
|
81
84
|
if not utils_imported:
|
|
82
85
|
|
|
83
86
|
try:
|
|
@@ -92,8 +95,9 @@ if not utils_imported:
|
|
|
92
95
|
from utils.general import scale_boxes as scale_coords
|
|
93
96
|
utils_imported = True
|
|
94
97
|
print('Imported YOLOv5 as utils.*')
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
|
|
99
|
+
except ModuleNotFoundError as e:
|
|
100
|
+
raise ModuleNotFoundError('Could not import YOLOv5 functions:\n{}'.format(str(e)))
|
|
97
101
|
|
|
98
102
|
assert utils_imported, 'YOLOv5 import error'
|
|
99
103
|
|
|
@@ -324,10 +328,10 @@ if __name__ == '__main__':
|
|
|
324
328
|
|
|
325
329
|
#%%
|
|
326
330
|
|
|
327
|
-
import md_visualization.visualization_utils as vis_utils
|
|
328
331
|
import os
|
|
332
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
329
333
|
|
|
330
|
-
model_file = 'MDV5A'
|
|
334
|
+
model_file = os.environ['MDV5A']
|
|
331
335
|
im_file = os.path.expanduser('~/git/MegaDetector/images/nacti.jpg')
|
|
332
336
|
|
|
333
337
|
detector = PTDetector(model_file)
|
|
@@ -30,12 +30,14 @@ import statistics
|
|
|
30
30
|
import sys
|
|
31
31
|
import time
|
|
32
32
|
import warnings
|
|
33
|
+
import tempfile
|
|
33
34
|
|
|
34
35
|
import humanfriendly
|
|
35
36
|
from tqdm import tqdm
|
|
36
37
|
|
|
37
|
-
import
|
|
38
|
-
import
|
|
38
|
+
from megadetector.utils import path_utils as path_utils
|
|
39
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
40
|
+
from megadetector.utils.url_utils import download_url
|
|
39
41
|
|
|
40
42
|
# ignoring all "PIL cannot read EXIF metainfo for the images" warnings
|
|
41
43
|
warnings.filterwarnings('ignore', '(Possibly )?corrupt EXIF data', UserWarning)
|
|
@@ -366,13 +368,13 @@ def load_detector(model_file, force_cpu=False):
|
|
|
366
368
|
|
|
367
369
|
start_time = time.time()
|
|
368
370
|
if model_file.endswith('.pb'):
|
|
369
|
-
from detection.tf_detector import TFDetector
|
|
371
|
+
from megadetector.detection.tf_detector import TFDetector
|
|
370
372
|
if force_cpu:
|
|
371
373
|
raise ValueError('force_cpu is not currently supported for TF detectors, ' + \
|
|
372
374
|
'use CUDA_VISIBLE_DEVICES=-1 instead')
|
|
373
375
|
detector = TFDetector(model_file)
|
|
374
376
|
elif model_file.endswith('.pt'):
|
|
375
|
-
from detection.pytorch_detector import PTDetector
|
|
377
|
+
from megadetector.detection.pytorch_detector import PTDetector
|
|
376
378
|
detector = PTDetector(model_file, force_cpu, USE_MODEL_NATIVE_CLASSES)
|
|
377
379
|
else:
|
|
378
380
|
raise ValueError('Unrecognized model format: {}'.format(model_file))
|
|
@@ -571,8 +573,6 @@ def download_model(model_name,force_download=False):
|
|
|
571
573
|
file already exists
|
|
572
574
|
"""
|
|
573
575
|
|
|
574
|
-
import tempfile
|
|
575
|
-
from md_utils.url_utils import download_url
|
|
576
576
|
model_tempdir = os.path.join(tempfile.gettempdir(), 'megadetector_models')
|
|
577
577
|
os.makedirs(model_tempdir,exist_ok=True)
|
|
578
578
|
|
|
@@ -5,10 +5,9 @@ run_detector_batch.py
|
|
|
5
5
|
Module to run MegaDetector on lots of images, writing the results
|
|
6
6
|
to a file in the MegaDetector results format.
|
|
7
7
|
|
|
8
|
-
https://github.com/agentmorris/MegaDetector/tree/main/api/batch_processing#megadetector-batch-output-format
|
|
8
|
+
https://github.com/agentmorris/MegaDetector/tree/main/megadetector/api/batch_processing#megadetector-batch-output-format
|
|
9
9
|
|
|
10
|
-
This enables the results to be used in our post-processing pipeline; see
|
|
11
|
-
api/batch_processing/postprocessing/postprocess_batch_results.py .
|
|
10
|
+
This enables the results to be used in our post-processing pipeline; see postprocess_batch_results.py.
|
|
12
11
|
|
|
13
12
|
This script can save results to checkpoints intermittently, in case disaster
|
|
14
13
|
strikes. To enable this, set --checkpoint_frequency to n > 0, and results
|
|
@@ -66,16 +65,18 @@ from multiprocessing import Process, Manager
|
|
|
66
65
|
# from multiprocessing.pool import ThreadPool as workerpool
|
|
67
66
|
from multiprocessing.pool import Pool as workerpool
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
from detection.run_detector import
|
|
68
|
+
from megadetector.detection import run_detector
|
|
69
|
+
from megadetector.detection.run_detector import \
|
|
70
|
+
is_gpu_available,\
|
|
71
71
|
load_detector,\
|
|
72
72
|
try_download_known_detector,\
|
|
73
73
|
get_detector_version_from_filename,\
|
|
74
74
|
get_detector_metadata_from_version_string
|
|
75
75
|
|
|
76
|
-
from
|
|
77
|
-
import
|
|
78
|
-
from data_management import read_exif
|
|
76
|
+
from megadetector.utils import path_utils
|
|
77
|
+
from megadetector.visualization import visualization_utils as vis_utils
|
|
78
|
+
from megadetector.data_management import read_exif
|
|
79
|
+
from megadetector.data_management.yolo_output_to_md_output import read_classes_from_yolo_dataset_file
|
|
79
80
|
|
|
80
81
|
# Numpy FutureWarnings from tensorflow import
|
|
81
82
|
warnings.filterwarnings('ignore', category=FutureWarning)
|
|
@@ -287,7 +288,7 @@ def process_images(im_files, detector, confidence_threshold, use_image_queue=Fal
|
|
|
287
288
|
|
|
288
289
|
Returns:
|
|
289
290
|
list: list of dicts, in which each dict represents detections on one image,
|
|
290
|
-
see the 'images' key in https://github.com/agentmorris/MegaDetector/tree/
|
|
291
|
+
see the 'images' key in https://github.com/agentmorris/MegaDetector/tree/main/megadetector/api/batch_processing#batch-processing-api-output-format
|
|
291
292
|
"""
|
|
292
293
|
|
|
293
294
|
if isinstance(detector, str):
|
|
@@ -346,7 +347,7 @@ def process_image(im_file, detector, confidence_threshold, image=None,
|
|
|
346
347
|
Returns:
|
|
347
348
|
dict: dict representing detections on one image,
|
|
348
349
|
see the 'images' key in
|
|
349
|
-
https://github.com/agentmorris/MegaDetector/tree/
|
|
350
|
+
https://github.com/agentmorris/MegaDetector/tree/main/megadetector/api/batch_processing#batch-processing-api-output-format
|
|
350
351
|
"""
|
|
351
352
|
|
|
352
353
|
if not quiet:
|
|
@@ -408,7 +409,6 @@ def _load_custom_class_mapping(class_mapping_filename):
|
|
|
408
409
|
with open(class_mapping_filename,'r') as f:
|
|
409
410
|
class_mapping = json.load(f)
|
|
410
411
|
elif (class_mapping_filename.endswith('.yml') or class_mapping_filename.endswith('.yaml')):
|
|
411
|
-
from data_management.yolo_output_to_md_output import read_classes_from_yolo_dataset_file
|
|
412
412
|
class_mapping = read_classes_from_yolo_dataset_file(class_mapping_filename)
|
|
413
413
|
# convert from ints to int-strings
|
|
414
414
|
class_mapping = {str(k):v for k,v in class_mapping.items()}
|
|
@@ -730,7 +730,7 @@ def write_results_to_file(results, output_file, relative_path_base=None,
|
|
|
730
730
|
"""
|
|
731
731
|
Writes list of detection results to JSON output file. Format matches:
|
|
732
732
|
|
|
733
|
-
https://github.com/agentmorris/MegaDetector/tree/
|
|
733
|
+
https://github.com/agentmorris/MegaDetector/tree/main/megadetector/api/batch_processing#batch-processing-api-output-format
|
|
734
734
|
|
|
735
735
|
Args:
|
|
736
736
|
results (list): list of dict, each dict represents detections on one image
|