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
|
@@ -19,7 +19,7 @@ print('score.py, tf.test.is_gpu_available:', tf.test.is_gpu_available())
|
|
|
19
19
|
PRINT_EVERY = 500
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
#%% Helper functions *copied* from ct_utils.py and
|
|
22
|
+
#%% Helper functions *copied* from ct_utils.py and visualization/visualization_utils.py
|
|
23
23
|
|
|
24
24
|
IMAGE_ROTATIONS = {
|
|
25
25
|
3: 180,
|
|
@@ -237,7 +237,7 @@ class TFDetector:
|
|
|
237
237
|
image_id: a path to identify the image; will be in the "file" field of the output object
|
|
238
238
|
detection_threshold: confidence above which to include the detection proposal
|
|
239
239
|
Returns:
|
|
240
|
-
A dict with the following fields, see the 'images' key in https://github.com/agentmorris/MegaDetector/tree/
|
|
240
|
+
A dict with the following fields, see the 'images' key in https://github.com/agentmorris/MegaDetector/tree/main/megadetector/api/batch_processing#batch-processing-api-output-format
|
|
241
241
|
- 'file' (always present)
|
|
242
242
|
- 'max_detection_conf'
|
|
243
243
|
- 'detections', which is a list of detection objects containing keys 'category', 'conf' and 'bbox'
|
|
@@ -18,7 +18,7 @@ from io import BytesIO
|
|
|
18
18
|
|
|
19
19
|
from detection.run_detector import load_detector, convert_to_tf_coords
|
|
20
20
|
import config
|
|
21
|
-
import
|
|
21
|
+
import visualization.visualization_utils as vis_utils
|
|
22
22
|
|
|
23
23
|
#%% Initialization
|
|
24
24
|
|
|
@@ -21,7 +21,7 @@ from io import BytesIO
|
|
|
21
21
|
from flask import Flask, Response, jsonify, make_response, request
|
|
22
22
|
from requests_toolbelt.multipart.encoder import MultipartEncoder
|
|
23
23
|
|
|
24
|
-
import
|
|
24
|
+
import visualization.visualization_utils as vis_utils
|
|
25
25
|
import config
|
|
26
26
|
|
|
27
27
|
|
|
@@ -18,9 +18,9 @@ from PIL import Image, ImageFile
|
|
|
18
18
|
import requests
|
|
19
19
|
from tqdm import tqdm
|
|
20
20
|
|
|
21
|
-
from data_management.megadb.megadb_utils import MegadbUtils
|
|
22
|
-
from
|
|
23
|
-
from
|
|
21
|
+
from megadetector.data_management.megadb.megadb_utils import MegadbUtils
|
|
22
|
+
from megadetector.utils import path_utils
|
|
23
|
+
from megadetector.utils import sas_blob_utils
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
#%% Example usage
|
|
@@ -9,7 +9,7 @@ This script takes as input a detections JSON file, usually the output of
|
|
|
9
9
|
detection/run_tf_detector_batch.py or the output of the Batch API in the
|
|
10
10
|
"Batch processing API output format".
|
|
11
11
|
|
|
12
|
-
See https://github.com/agentmorris/MegaDetector/tree/
|
|
12
|
+
See https://github.com/agentmorris/MegaDetector/tree/main/megadetector/api/batch_processing.
|
|
13
13
|
|
|
14
14
|
The script can crop images that are either available locally or that need to be
|
|
15
15
|
downloaded from an Azure Blob Storage container.
|
|
@@ -113,11 +113,11 @@ from tqdm import tqdm
|
|
|
113
113
|
|
|
114
114
|
from api.batch_processing.data_preparation.prepare_api_submission import (
|
|
115
115
|
BatchAPIResponseError, Task, TaskStatus, divide_list_into_tasks)
|
|
116
|
-
from classification.cache_batchapi_outputs import cache_detections
|
|
117
|
-
from classification.crop_detections import load_and_crop
|
|
118
|
-
from data_management.megadb import megadb_utils
|
|
119
|
-
from
|
|
120
|
-
from
|
|
116
|
+
from megadetector.classification.cache_batchapi_outputs import cache_detections
|
|
117
|
+
from megadetector.classification.crop_detections import load_and_crop
|
|
118
|
+
from megadetector.data_management.megadb import megadb_utils
|
|
119
|
+
from megadetector.utils import path_utils
|
|
120
|
+
from megadetector.utils import sas_blob_utils
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
#%% Example usage
|
|
@@ -16,8 +16,8 @@ import os
|
|
|
16
16
|
|
|
17
17
|
from tqdm import tqdm
|
|
18
18
|
|
|
19
|
-
from data_management.megadb import megadb_utils
|
|
20
|
-
from
|
|
19
|
+
from megadetector.data_management.megadb import megadb_utils
|
|
20
|
+
from megadetector.utils import sas_blob_utils
|
|
21
21
|
|
|
22
22
|
images_dir = ''
|
|
23
23
|
queried_images_json_path = 'run_idfg2/queried_images.json'
|
|
@@ -65,26 +65,30 @@ exist in Azure Blob Storage. In total, we output the following files:
|
|
|
65
65
|
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
|
+
#%% Imports
|
|
69
|
+
|
|
68
70
|
from __future__ import annotations
|
|
69
71
|
|
|
70
72
|
import argparse
|
|
71
|
-
from collections import defaultdict
|
|
72
|
-
from collections.abc import Container, Iterable, Mapping, MutableMapping
|
|
73
|
-
from concurrent import futures
|
|
74
|
-
from datetime import datetime
|
|
75
73
|
import json
|
|
76
74
|
import os
|
|
77
75
|
import pprint
|
|
78
76
|
import random
|
|
79
|
-
from typing import Any
|
|
80
77
|
|
|
81
78
|
import pandas as pd
|
|
82
|
-
|
|
83
|
-
from md_utils import sas_blob_utils
|
|
79
|
+
|
|
84
80
|
from tqdm import tqdm
|
|
81
|
+
from collections import defaultdict
|
|
82
|
+
from collections.abc import Container, Iterable, Mapping, MutableMapping
|
|
83
|
+
from concurrent import futures
|
|
84
|
+
from datetime import datetime
|
|
85
|
+
from typing import Any
|
|
86
|
+
|
|
87
|
+
from megadetector.utils import path_utils
|
|
88
|
+
from megadetector.utils import sas_blob_utils
|
|
85
89
|
|
|
86
|
-
from data_management.megadb import megadb_utils
|
|
87
|
-
from taxonomy_mapping.taxonomy_graph import (
|
|
90
|
+
from megadetector.data_management.megadb import megadb_utils
|
|
91
|
+
from megadetector.taxonomy_mapping.taxonomy_graph import (
|
|
88
92
|
build_taxonomy_graph, dag_to_tree, TaxonNode)
|
|
89
93
|
|
|
90
94
|
|
|
@@ -25,6 +25,7 @@ from __future__ import annotations
|
|
|
25
25
|
import argparse
|
|
26
26
|
import json
|
|
27
27
|
import os
|
|
28
|
+
|
|
28
29
|
from tqdm import tqdm
|
|
29
30
|
from typing import Any
|
|
30
31
|
from collections.abc import Callable, Sequence
|
|
@@ -36,7 +37,7 @@ import torch.utils
|
|
|
36
37
|
import torchvision as tv
|
|
37
38
|
from torchvision.datasets.folder import default_loader
|
|
38
39
|
|
|
39
|
-
from classification import train_classifier
|
|
40
|
+
from megadetector.classification import train_classifier
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
#%% Example usage
|
|
@@ -16,28 +16,30 @@ During training, start tensorboard from within the classification/ directory:
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
+
import json
|
|
20
|
+
import os
|
|
19
21
|
import argparse
|
|
22
|
+
|
|
20
23
|
from collections import defaultdict
|
|
21
24
|
from collections.abc import Callable, Mapping, MutableMapping, Sequence
|
|
22
25
|
from datetime import datetime
|
|
23
|
-
import json
|
|
24
|
-
import os
|
|
25
26
|
from typing import Any
|
|
26
27
|
|
|
27
28
|
import numpy as np
|
|
28
29
|
import PIL.Image
|
|
29
30
|
import sklearn.metrics
|
|
31
|
+
import tqdm
|
|
32
|
+
|
|
30
33
|
import torch
|
|
31
34
|
from torch.utils import tensorboard
|
|
32
35
|
import torchvision as tv
|
|
33
36
|
from torchvision.datasets.folder import default_loader
|
|
34
|
-
import tqdm
|
|
35
37
|
|
|
36
|
-
from classification import efficientnet, evaluate_model
|
|
37
|
-
from classification.train_utils import (
|
|
38
|
+
from megadetector.classification import efficientnet, evaluate_model
|
|
39
|
+
from megadetector.classification.train_utils import (
|
|
38
40
|
HeapItem, recall_from_confusion_matrix, add_to_heap, fig_to_img,
|
|
39
41
|
imgs_with_confidences, load_dataset_csv, prefix_all_keys)
|
|
40
|
-
from
|
|
42
|
+
from megadetector.visualization import plot_utils
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
#%% Example usage
|
|
@@ -16,25 +16,26 @@ During training, start tensorboard from within the classification/ directory:
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
import argparse
|
|
20
|
-
from collections import defaultdict
|
|
21
|
-
from collections.abc import Callable, Mapping, MutableMapping, Sequence
|
|
22
|
-
from datetime import datetime
|
|
23
|
-
import json
|
|
24
19
|
import os
|
|
25
|
-
|
|
20
|
+
import json
|
|
26
21
|
import uuid
|
|
22
|
+
import argparse
|
|
27
23
|
|
|
24
|
+
import tqdm
|
|
28
25
|
import numpy as np
|
|
29
26
|
import sklearn.metrics
|
|
30
27
|
import tensorflow as tf
|
|
28
|
+
|
|
29
|
+
from collections import defaultdict
|
|
30
|
+
from collections.abc import Callable, Mapping, MutableMapping, Sequence
|
|
31
|
+
from datetime import datetime
|
|
32
|
+
from typing import Any, Optional
|
|
31
33
|
from tensorboard.plugins.hparams import api as hp
|
|
32
|
-
import tqdm
|
|
33
34
|
|
|
34
|
-
from classification.train_utils import (
|
|
35
|
+
from megadetector.classification.train_utils import (
|
|
35
36
|
HeapItem, recall_from_confusion_matrix, add_to_heap, fig_to_img,
|
|
36
37
|
imgs_with_confidences, load_dataset_csv, prefix_all_keys)
|
|
37
|
-
from
|
|
38
|
+
from megadetector.visualization import plot_utils
|
|
38
39
|
|
|
39
40
|
AUTOTUNE = tf.data.experimental.AUTOTUNE
|
|
40
41
|
|
|
@@ -13,12 +13,10 @@ especially be agnostic to PyTorch vs. TensorFlow.
|
|
|
13
13
|
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
|
-
from collections.abc import Mapping, Sequence
|
|
17
16
|
import dataclasses
|
|
18
17
|
import heapq
|
|
19
18
|
import io
|
|
20
19
|
import json
|
|
21
|
-
from typing import Any, Optional
|
|
22
20
|
|
|
23
21
|
import matplotlib.figure
|
|
24
22
|
import numpy as np
|
|
@@ -26,6 +24,9 @@ import pandas as pd
|
|
|
26
24
|
import PIL.Image
|
|
27
25
|
import scipy.interpolate
|
|
28
26
|
|
|
27
|
+
from collections.abc import Mapping, Sequence
|
|
28
|
+
from typing import Any, Optional
|
|
29
|
+
|
|
29
30
|
|
|
30
31
|
#%% Classes
|
|
31
32
|
|
|
@@ -200,7 +200,8 @@ if False:
|
|
|
200
200
|
|
|
201
201
|
#%% Validate
|
|
202
202
|
|
|
203
|
-
from data_management.databases.integrity_check_json_db import
|
|
203
|
+
from megadetector.data_management.databases.integrity_check_json_db import \
|
|
204
|
+
integrity_check_json_db, IntegrityCheckOptions
|
|
204
205
|
|
|
205
206
|
options = IntegrityCheckOptions()
|
|
206
207
|
|
|
@@ -217,7 +218,7 @@ if False:
|
|
|
217
218
|
|
|
218
219
|
#%% Preview
|
|
219
220
|
|
|
220
|
-
from
|
|
221
|
+
from megadetector.visualization.visualize_db import DbVizOptions, visualize_db
|
|
221
222
|
|
|
222
223
|
options = DbVizOptions()
|
|
223
224
|
options.parallelize_rendering = True
|
|
@@ -227,7 +228,7 @@ if False:
|
|
|
227
228
|
preview_dir = r'c:\temp\camtrapdp-preview'
|
|
228
229
|
htmlOutputFile,image_db = visualize_db(coco_file, preview_dir, camtrap_dp_folder, options=options)
|
|
229
230
|
|
|
230
|
-
from
|
|
231
|
+
from megadetector.utils.path_utils import open_file
|
|
231
232
|
open_file(htmlOutputFile)
|
|
232
233
|
|
|
233
234
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
cct_json_utils.py
|
|
4
4
|
|
|
5
|
-
Utilities for working with COCO Camera Traps .json databases
|
|
5
|
+
Utilities for working with COCO Camera Traps .json databases:
|
|
6
6
|
|
|
7
|
-
https://github.com/agentmorris/MegaDetector/blob/
|
|
7
|
+
https://github.com/agentmorris/MegaDetector/blob/main/megadetector/data_management/README.md#coco-cameratraps-format
|
|
8
8
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
@@ -164,7 +164,7 @@ if False:
|
|
|
164
164
|
|
|
165
165
|
#%%
|
|
166
166
|
|
|
167
|
-
from
|
|
167
|
+
from megadetector.visualization import visualize_detector_output
|
|
168
168
|
|
|
169
169
|
visualize_detector_output.visualize_detector_output(
|
|
170
170
|
detector_output_path=output_filename,
|
|
@@ -26,8 +26,8 @@ from multiprocessing.pool import ThreadPool
|
|
|
26
26
|
from operator import itemgetter
|
|
27
27
|
from tqdm import tqdm
|
|
28
28
|
|
|
29
|
-
from
|
|
30
|
-
from
|
|
29
|
+
from megadetector.visualization.visualization_utils import open_image
|
|
30
|
+
from megadetector.utils import ct_utils
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
#%% Classes and environment
|
|
@@ -12,15 +12,16 @@ every image, optionally writing the results to a new .json file.
|
|
|
12
12
|
import argparse
|
|
13
13
|
import json
|
|
14
14
|
import os
|
|
15
|
-
from PIL import Image
|
|
16
15
|
import sys
|
|
17
16
|
|
|
17
|
+
from PIL import Image
|
|
18
|
+
|
|
18
19
|
from multiprocessing.pool import ThreadPool
|
|
19
20
|
from multiprocessing.pool import Pool
|
|
20
21
|
from functools import partial
|
|
21
22
|
from tqdm import tqdm
|
|
22
23
|
|
|
23
|
-
from
|
|
24
|
+
from megadetector.utils.path_utils import find_images
|
|
24
25
|
|
|
25
26
|
image_base = ''
|
|
26
27
|
default_n_threads = 1
|
|
@@ -137,7 +138,7 @@ if False:
|
|
|
137
138
|
image_list_file = os.path.join(base_dir,'images.json')
|
|
138
139
|
relative_image_list_file = os.path.join(base_dir,'images_relative.json')
|
|
139
140
|
image_size_file = os.path.join(base_dir,'image_sizes.json')
|
|
140
|
-
from
|
|
141
|
+
from megadetector.utils import path_utils
|
|
141
142
|
image_names = path_utils.find_images(base_dir,recursive=True)
|
|
142
143
|
|
|
143
144
|
with open(image_list_file,'w') as f:
|
|
@@ -18,11 +18,12 @@ import datetime
|
|
|
18
18
|
import ntpath
|
|
19
19
|
import re
|
|
20
20
|
import numpy as np
|
|
21
|
+
|
|
21
22
|
from tqdm import tqdm
|
|
22
23
|
|
|
23
|
-
from
|
|
24
|
-
from data_management.databases import integrity_check_json_db
|
|
25
|
-
from
|
|
24
|
+
from megadetector.visualization import visualize_db
|
|
25
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
26
|
+
from megadetector.utils.path_utils import find_images
|
|
26
27
|
|
|
27
28
|
input_base_dir = r'e:\auckland-test\2_Testing'
|
|
28
29
|
|
|
@@ -342,8 +343,8 @@ os.startfile(html_output_file)
|
|
|
342
343
|
|
|
343
344
|
#%% Precision-recall analysis
|
|
344
345
|
|
|
345
|
-
from
|
|
346
|
-
from
|
|
346
|
+
from megadetector.postprocessing.postprocess_batch_results import PostProcessingOptions
|
|
347
|
+
from megadetector.postprocessing.postprocess_batch_results import process_batch_results
|
|
347
348
|
|
|
348
349
|
api_output_file = r'g:\auckland-doc\auckland-doc_20200801\combined_api_outputs\auckland-doc_202008012020.08.01_reformatMaukahuka_Auckland_Island2_TestingSummer_Trial_2019_detections.filtered_rde_0.60_0.85_5_0.05.json'
|
|
349
350
|
postprocessing_output_folder = r'G:\auckland-doc\auckland-doc_20200801\postprocessing'
|
|
@@ -13,11 +13,12 @@ import json
|
|
|
13
13
|
import os
|
|
14
14
|
import uuid
|
|
15
15
|
import datetime
|
|
16
|
+
|
|
16
17
|
from tqdm import tqdm
|
|
17
18
|
|
|
18
|
-
from
|
|
19
|
-
from data_management.databases import integrity_check_json_db
|
|
20
|
-
from
|
|
19
|
+
from megadetector.visualization import visualize_db
|
|
20
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
21
|
+
from megadetector.utils.path_utils import find_images, split_path, insert_before_extension
|
|
21
22
|
|
|
22
23
|
# Filenames will be stored in the output .json relative to this base dir
|
|
23
24
|
input_base_dir = 'y:\\'
|
|
@@ -12,12 +12,14 @@ import pandas as pd
|
|
|
12
12
|
import uuid
|
|
13
13
|
import json
|
|
14
14
|
import time
|
|
15
|
-
from tqdm import tqdm
|
|
16
15
|
import humanfriendly
|
|
17
16
|
import os
|
|
18
17
|
import PIL
|
|
19
|
-
|
|
20
|
-
from
|
|
18
|
+
|
|
19
|
+
from tqdm import tqdm
|
|
20
|
+
|
|
21
|
+
from megadetector.visualization import visualize_db
|
|
22
|
+
from megadetector.utils import path_utils
|
|
21
23
|
|
|
22
24
|
input_metadata_file = r"D:\wildlife_data\awc\awc_imageinfo.csv"
|
|
23
25
|
output_file = r"D:\wildlife_data\awc\awc_imageinfo.json"
|
|
@@ -170,7 +172,7 @@ print('Finished writing .json file with {} images, {} annotations, and {} catego
|
|
|
170
172
|
|
|
171
173
|
#%% Validate the database's integrity
|
|
172
174
|
|
|
173
|
-
from data_management.databases import integrity_check_json_db
|
|
175
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
174
176
|
|
|
175
177
|
options = integrity_check_json_db.IntegrityCheckOptions()
|
|
176
178
|
sortedCategories,data = integrity_check_json_db.integrity_check_json_db(output_file, options)
|
|
@@ -25,7 +25,7 @@ from PIL import Image
|
|
|
25
25
|
from PIL.ExifTags import TAGS
|
|
26
26
|
from tqdm import tqdm
|
|
27
27
|
|
|
28
|
-
from
|
|
28
|
+
from megadetector.utils.path_utils import find_images
|
|
29
29
|
|
|
30
30
|
# Filenames will be stored in the output .json relative to this base dir
|
|
31
31
|
base_dir = r'C:\temp\camera_trap_images_no_people'
|
|
@@ -244,7 +244,7 @@ print('Finished writing json to {}'.format(output_filename))
|
|
|
244
244
|
|
|
245
245
|
#%% Validate data
|
|
246
246
|
|
|
247
|
-
from data_management.databases import integrity_check_json_db
|
|
247
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
248
248
|
|
|
249
249
|
options = integrity_check_json_db.IntegrityCheckOptions()
|
|
250
250
|
options.baseDir = base_dir
|
|
@@ -257,7 +257,7 @@ sorted_categories = integrity_check_json_db.integrity_check_json_db(output_file
|
|
|
257
257
|
|
|
258
258
|
#%% Label previews
|
|
259
259
|
|
|
260
|
-
from
|
|
260
|
+
from megadetector.visualization import visualize_db
|
|
261
261
|
|
|
262
262
|
viz_options = visualize_db.DbVizOptions()
|
|
263
263
|
viz_options.num_to_visualize = None
|
|
@@ -29,8 +29,8 @@ from zipfile import ZipFile
|
|
|
29
29
|
|
|
30
30
|
import cv2
|
|
31
31
|
|
|
32
|
-
from
|
|
33
|
-
from
|
|
32
|
+
from megadetector.utils.ct_utils import truncate_float
|
|
33
|
+
from megadetector.utils import path_utils
|
|
34
34
|
|
|
35
35
|
base_dir = '/bigdata/home/sftp/cacophony-ferraro_/data/cacophony-thermal/'
|
|
36
36
|
output_base = os.path.expanduser('~/tmp/new-zealand-wildlife-thermal-imaging')
|
|
@@ -686,7 +686,7 @@ if False:
|
|
|
686
686
|
target_folder = os.path.expanduser('~/tmp/cacophony-thermal-out-individual-metadata')
|
|
687
687
|
assert os.path.isdir(source_folder) and os.path.isdir(target_folder)
|
|
688
688
|
|
|
689
|
-
from
|
|
689
|
+
from megadetector.utils import path_utils
|
|
690
690
|
all_files = path_utils.recursive_file_list(source_folder)
|
|
691
691
|
files_to_move = [fn for fn in all_files if '_metadata.json' in fn]
|
|
692
692
|
print('Moving {} of {} files'.format(len(files_to_move),len(all_files)))
|
|
@@ -726,7 +726,7 @@ if False:
|
|
|
726
726
|
filtered_video_filename = selected_clip['filtered_video_filename']
|
|
727
727
|
video_filename = selected_clip['video_filename']
|
|
728
728
|
|
|
729
|
-
from
|
|
729
|
+
from megadetector.utils.path_utils import open_file
|
|
730
730
|
# open_file(os.path.join(output_base,video_filename))
|
|
731
731
|
open_file(os.path.join(output_base,filtered_video_filename))
|
|
732
732
|
|
|
@@ -18,9 +18,10 @@ import humanfriendly
|
|
|
18
18
|
|
|
19
19
|
from tqdm import tqdm
|
|
20
20
|
from PIL import Image
|
|
21
|
+
|
|
21
22
|
import numpy as np
|
|
22
23
|
|
|
23
|
-
from
|
|
24
|
+
from megadetector.utils.path_utils import find_images
|
|
24
25
|
|
|
25
26
|
input_base = r'Z:\Shrub-free zone Carrizo 2018'
|
|
26
27
|
input_metadata_file = os.path.join(input_base,'shrub-free 2018.csv')
|
|
@@ -237,7 +238,7 @@ print('Finished writing .json file with {} images, {} annotations, and {} catego
|
|
|
237
238
|
|
|
238
239
|
#%% Validate output
|
|
239
240
|
|
|
240
|
-
from data_management.databases import integrity_check_json_db
|
|
241
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
241
242
|
|
|
242
243
|
options = integrity_check_json_db.IntegrityCheckOptions()
|
|
243
244
|
options.baseDir = image_directory
|
|
@@ -249,8 +250,8 @@ data = integrity_check_json_db.integrity_check_json_db(output_json_file,options)
|
|
|
249
250
|
|
|
250
251
|
#%% Preview labels
|
|
251
252
|
|
|
252
|
-
from
|
|
253
|
-
from data_management.databases import integrity_check_json_db
|
|
253
|
+
from megadetector.visualization import visualize_db
|
|
254
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
254
255
|
|
|
255
256
|
viz_options = visualize_db.DbVizOptions()
|
|
256
257
|
viz_options.num_to_visualize = None
|
|
@@ -9,17 +9,19 @@
|
|
|
9
9
|
|
|
10
10
|
#%% Constants and environment
|
|
11
11
|
|
|
12
|
-
import pandas as pd
|
|
13
12
|
import os
|
|
14
13
|
import json
|
|
15
14
|
import uuid
|
|
16
15
|
import time
|
|
17
16
|
import humanfriendly
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
import pandas as pd
|
|
19
19
|
import numpy as np
|
|
20
20
|
|
|
21
|
+
from PIL import Image
|
|
21
22
|
from tqdm import tqdm
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
from megadetector.utils.path_utils import find_images
|
|
23
25
|
|
|
24
26
|
input_base = r'Z:\Trail Cam Carrizo 2017'
|
|
25
27
|
open_metadata_file = os.path.join(input_base, 'Carrizo open 2017.csv')
|
|
@@ -256,7 +258,7 @@ print('Finished writing .json file with {} images, {} annotations, and {} catego
|
|
|
256
258
|
|
|
257
259
|
#%% Validate output
|
|
258
260
|
|
|
259
|
-
from data_management.databases import integrity_check_json_db
|
|
261
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
260
262
|
|
|
261
263
|
options = integrity_check_json_db.IntegrityCheckOptions()
|
|
262
264
|
options.baseDir = image_directory
|
|
@@ -268,8 +270,8 @@ data = integrity_check_json_db.integrity_check_json_db(output_json_file,options)
|
|
|
268
270
|
|
|
269
271
|
#%% Preview labels
|
|
270
272
|
|
|
271
|
-
from
|
|
272
|
-
from data_management.databases import integrity_check_json_db
|
|
273
|
+
from megadetector.visualization import visualize_db
|
|
274
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
273
275
|
|
|
274
276
|
viz_options = visualize_db.DbVizOptions()
|
|
275
277
|
viz_options.num_to_visualize = None
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
#%% Constants and environment
|
|
12
12
|
|
|
13
|
-
from data_management.databases import integrity_check_json_db
|
|
14
13
|
import json
|
|
15
14
|
import os
|
|
16
15
|
|
|
16
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
17
|
+
|
|
17
18
|
inputJsonFile = r"D:\temp\CaltechCameraTraps_v2.0.json"
|
|
18
19
|
outputJsonFile = r"D:\temp\CaltechCameraTraps_v2.1.json"
|
|
19
20
|
|
|
@@ -882,7 +882,7 @@ print('Finished writing .json file with {} images, {} annotations, and {} catego
|
|
|
882
882
|
|
|
883
883
|
#%% Validate output
|
|
884
884
|
|
|
885
|
-
from data_management.databases import integrity_check_json_db
|
|
885
|
+
from megadetector.data_management.databases import integrity_check_json_db
|
|
886
886
|
|
|
887
887
|
fn = output_file
|
|
888
888
|
options = integrity_check_json_db.IntegrityCheckOptions()
|
|
@@ -896,7 +896,7 @@ sortedCategories, data, error = integrity_check_json_db.integrity_check_json_db(
|
|
|
896
896
|
|
|
897
897
|
#%% Preview labels
|
|
898
898
|
|
|
899
|
-
from
|
|
899
|
+
from megadetector.visualization import visualize_db
|
|
900
900
|
|
|
901
901
|
viz_options = visualize_db.DbVizOptions()
|
|
902
902
|
viz_options.num_to_visualize = 159
|