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
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
manage_video_batch.py
|
|
4
|
-
|
|
5
|
-
Notebook-esque script to manage the process of running a local batch of videos
|
|
6
|
-
through MD. Defers most of the heavy lifting to manage_local_batch.py .
|
|
7
|
-
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
#%% Imports and constants
|
|
11
|
-
|
|
12
|
-
import os
|
|
13
|
-
|
|
14
|
-
from md_utils import path_utils
|
|
15
|
-
from detection import video_utils
|
|
16
|
-
|
|
17
|
-
input_folder = '/datadrive/data'
|
|
18
|
-
output_folder_base = '/datadrive/frames'
|
|
19
|
-
|
|
20
|
-
assert os.path.isdir(input_folder)
|
|
21
|
-
os.makedirs(output_folder_base,exist_ok=True)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#%% Split videos into frames
|
|
25
|
-
|
|
26
|
-
assert os.path.isdir(input_folder)
|
|
27
|
-
os.makedirs(output_folder_base,exist_ok=True)
|
|
28
|
-
|
|
29
|
-
recursive = True
|
|
30
|
-
overwrite = True
|
|
31
|
-
n_threads = 4
|
|
32
|
-
every_n_frames = 10
|
|
33
|
-
|
|
34
|
-
frame_filenames_by_video,fs_by_video,video_filenames = \
|
|
35
|
-
video_utils.video_folder_to_frames(input_folder=input_folder,
|
|
36
|
-
output_folder_base=output_folder_base,
|
|
37
|
-
recursive=recursive,
|
|
38
|
-
overwrite=overwrite,
|
|
39
|
-
n_threads=n_threads,
|
|
40
|
-
every_n_frames=every_n_frames,
|
|
41
|
-
parallelization_uses_threads=False)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#%% List frame files, break into folders
|
|
45
|
-
|
|
46
|
-
from collections import defaultdict
|
|
47
|
-
|
|
48
|
-
frame_files = path_utils.find_images(output_folder_base,True)
|
|
49
|
-
frame_files = [s.replace('\\','/') for s in frame_files]
|
|
50
|
-
print('Enumerated {} total frames'.format(len(frame_files)))
|
|
51
|
-
|
|
52
|
-
# Find unique (relative) folders
|
|
53
|
-
folder_to_frame_files = defaultdict(list)
|
|
54
|
-
|
|
55
|
-
# fn = frame_files[0]
|
|
56
|
-
for fn in frame_files:
|
|
57
|
-
folder_name = os.path.dirname(fn)
|
|
58
|
-
folder_name = os.path.relpath(folder_name,output_folder_base)
|
|
59
|
-
folder_to_frame_files[folder_name].append(fn)
|
|
60
|
-
|
|
61
|
-
print('Found {} folders for {} files'.format(len(folder_to_frame_files),len(frame_files)))
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#%% List videos
|
|
65
|
-
|
|
66
|
-
video_filenames = video_utils.find_videos(input_folder,recursive=True)
|
|
67
|
-
video_filenames = [os.path.relpath(fn,input_folder) for fn in video_filenames]
|
|
68
|
-
print('Input folder contains {} videos'.format(len(video_filenames)))
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
#%% Check for videos that are missing entirely
|
|
72
|
-
|
|
73
|
-
# list(folder_to_frame_files.keys())[0]
|
|
74
|
-
# video_filenames[0]
|
|
75
|
-
|
|
76
|
-
missing_videos = []
|
|
77
|
-
|
|
78
|
-
# fn = video_filenames[0]
|
|
79
|
-
for relative_fn in video_filenames:
|
|
80
|
-
if relative_fn not in folder_to_frame_files:
|
|
81
|
-
missing_videos.append(relative_fn)
|
|
82
|
-
|
|
83
|
-
print('{} of {} folders are missing frames entirely'.format(len(missing_videos),
|
|
84
|
-
len(video_filenames)))
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
#%% Check for videos with very few frames
|
|
88
|
-
|
|
89
|
-
min_frames_for_valid_video = 10
|
|
90
|
-
|
|
91
|
-
low_frame_videos = []
|
|
92
|
-
|
|
93
|
-
for folder_name in folder_to_frame_files.keys():
|
|
94
|
-
frame_files = folder_to_frame_files[folder_name]
|
|
95
|
-
if len(frame_files) < min_frames_for_valid_video:
|
|
96
|
-
low_frame_videos.append(folder_name)
|
|
97
|
-
|
|
98
|
-
print('{} of {} folders have fewer than {} frames'.format(
|
|
99
|
-
len(low_frame_videos),len(video_filenames),min_frames_for_valid_video))
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#%% Print the list of videos that are problematic
|
|
103
|
-
|
|
104
|
-
print('Videos that could not be decoded:\n')
|
|
105
|
-
|
|
106
|
-
for fn in missing_videos:
|
|
107
|
-
print(fn)
|
|
108
|
-
|
|
109
|
-
print('\nVideos with fewer than {} decoded frames:\n'.format(min_frames_for_valid_video))
|
|
110
|
-
|
|
111
|
-
for fn in low_frame_videos:
|
|
112
|
-
print(fn)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
#%% Process images like we would for any other camera trap job
|
|
116
|
-
|
|
117
|
-
# ...typically using manage_local_batch.py or manage_local_batch.ipynb, but do this however
|
|
118
|
-
# you like, as long as you get a results file at the end.
|
|
119
|
-
#
|
|
120
|
-
# If you do RDE, remember to use the second folder from the bottom, rather than the
|
|
121
|
-
# bottom-most folder.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
#%% Convert frame results to video results
|
|
125
|
-
|
|
126
|
-
from detection.video_utils import frame_results_to_video_results
|
|
127
|
-
|
|
128
|
-
filtered_output_filename = '/results/organization/stuff.json'
|
|
129
|
-
video_output_filename = filtered_output_filename.replace('.json','_aggregated.json')
|
|
130
|
-
frame_results_to_video_results(filtered_output_filename,video_output_filename)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
#%% Confirm that the videos in the .json file are what we expect them to be
|
|
134
|
-
|
|
135
|
-
import json
|
|
136
|
-
|
|
137
|
-
with open(video_output_filename,'r') as f:
|
|
138
|
-
video_results = json.load(f)
|
|
139
|
-
|
|
140
|
-
video_filenames_set = set(video_filenames)
|
|
141
|
-
|
|
142
|
-
filenames_in_video_results_set = set([im['file'] for im in video_results['images']])
|
|
143
|
-
|
|
144
|
-
for fn in filenames_in_video_results_set:
|
|
145
|
-
assert fn in video_filenames_set
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
#%% Scrap
|
|
149
|
-
|
|
150
|
-
if False:
|
|
151
|
-
|
|
152
|
-
pass
|
|
153
|
-
|
|
154
|
-
#%% Render one or more sample videos...
|
|
155
|
-
|
|
156
|
-
# ...while we still have the frames and detections around
|
|
157
|
-
|
|
158
|
-
## Imports
|
|
159
|
-
|
|
160
|
-
from md_visualization import visualize_detector_output
|
|
161
|
-
from detection.video_utils import frames_to_video
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
## Constants and paths
|
|
165
|
-
|
|
166
|
-
confidence_threshold = 0.2
|
|
167
|
-
input_fs = 30
|
|
168
|
-
|
|
169
|
-
filtered_output_filename = '/a/b/c/blah_detections.filtered_rde_0.150_0.850_10_1.000.json'
|
|
170
|
-
video_fn_relative = '4.10cam6/IMG_0022.MP4'
|
|
171
|
-
output_video_base = os.path.expanduser('~/tmp/video_preview')
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
## Filename handling
|
|
175
|
-
|
|
176
|
-
video_fn_relative = video_fn_relative.replace('\\','/')
|
|
177
|
-
video_fn_flat = video_fn_relative.replace('/','#')
|
|
178
|
-
video_name = os.path.splitext(video_fn_flat)[0]
|
|
179
|
-
output_video = os.path.join(output_video_base,'{}_detections.mp4'.format(video_name))
|
|
180
|
-
output_fs = input_fs / every_n_frames
|
|
181
|
-
|
|
182
|
-
rendered_detections_folder = os.path.join(output_video_base,'rendered_detections_{}'.format(video_name))
|
|
183
|
-
os.makedirs(rendered_detections_folder,exist_ok=True)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
## Find frames corresponding to this video
|
|
187
|
-
|
|
188
|
-
with open(filtered_output_filename,'r') as f:
|
|
189
|
-
frame_results = json.load(f)
|
|
190
|
-
|
|
191
|
-
frame_results_this_video = []
|
|
192
|
-
|
|
193
|
-
# im = frame_results['images'][0]
|
|
194
|
-
for im in frame_results['images']:
|
|
195
|
-
if im['file'].replace('\\','/').startswith(video_fn_relative):
|
|
196
|
-
frame_results_this_video.append(im)
|
|
197
|
-
|
|
198
|
-
assert len(frame_results_this_video) > 0, \
|
|
199
|
-
'No frame results matched {}'.format(video_fn_relative)
|
|
200
|
-
print('Found {} matching frame results'.format(len(frame_results_this_video)))
|
|
201
|
-
|
|
202
|
-
frame_results['images'] = frame_results_this_video
|
|
203
|
-
|
|
204
|
-
frames_json = os.path.join(rendered_detections_folder,video_fn_flat + '.json')
|
|
205
|
-
|
|
206
|
-
with open(frames_json,'w') as f:
|
|
207
|
-
json.dump(frame_results,f,indent=1)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
## Render detections on those frames
|
|
211
|
-
|
|
212
|
-
detected_frame_files = visualize_detector_output.visualize_detector_output(
|
|
213
|
-
detector_output_path=frames_json,
|
|
214
|
-
out_dir=rendered_detections_folder,
|
|
215
|
-
images_dir=output_folder_base,
|
|
216
|
-
confidence_threshold=confidence_threshold,
|
|
217
|
-
preserve_path_structure=True,
|
|
218
|
-
output_image_width=-1)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
## Render the output video
|
|
222
|
-
|
|
223
|
-
frames_to_video(detected_frame_files, output_fs, output_video, codec_spec='h264')
|
|
224
|
-
|
|
225
|
-
# from md_utils.path_utils import open_file; open_file(output_video)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
#%% Test a possibly-broken video
|
|
229
|
-
|
|
230
|
-
fn = '/datadrive/tmp/video.AVI'
|
|
231
|
-
|
|
232
|
-
fs = video_utils.get_video_fs(fn)
|
|
233
|
-
print(fs)
|
|
234
|
-
|
|
235
|
-
tmpfolder = '/home/user/tmp/frametmp'
|
|
236
|
-
os.makedirs(tmpfolder,exist_ok=True)
|
|
237
|
-
|
|
238
|
-
video_utils.video_to_frames(fn, tmpfolder, verbose=True, every_n_frames=10)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
#%% List videos in a folder
|
|
242
|
-
|
|
243
|
-
input_folder = '/datadrive/tmp/organization/data'
|
|
244
|
-
video_filenames = video_utils.find_videos(input_folder,recursive=True)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
#%% End notebook: turn this script into a notebook (how meta!)
|
|
248
|
-
|
|
249
|
-
import os
|
|
250
|
-
import nbformat as nbf
|
|
251
|
-
|
|
252
|
-
if os.name == 'nt':
|
|
253
|
-
git_base = r'c:\git'
|
|
254
|
-
else:
|
|
255
|
-
git_base = os.path.expanduer('~/git')
|
|
256
|
-
|
|
257
|
-
input_py_file = git_base + '/MegaDetector/api/batch_processing/data_preparation/manage_video_batch.py'
|
|
258
|
-
assert os.path.isfile(input_py_file)
|
|
259
|
-
output_ipynb_file = input_py_file.replace('.py','.ipynb')
|
|
260
|
-
|
|
261
|
-
nb_header = '# Managing a local MegaDetector video batch'
|
|
262
|
-
|
|
263
|
-
nb_header += '\n'
|
|
264
|
-
|
|
265
|
-
nb_header += \
|
|
266
|
-
"""
|
|
267
|
-
This notebook represents an interactive process for running MegaDetector on large batches of videos, including typical and optional postprocessing steps.
|
|
268
|
-
|
|
269
|
-
This notebook is auto-generated from manage_video_batch.py (a cell-delimited .py file that is used the same way, typically in Spyder or VS Code).
|
|
270
|
-
|
|
271
|
-
"""
|
|
272
|
-
|
|
273
|
-
with open(input_py_file,'r') as f:
|
|
274
|
-
lines = f.readlines()
|
|
275
|
-
|
|
276
|
-
nb = nbf.v4.new_notebook()
|
|
277
|
-
nb['cells'].append(nbf.v4.new_markdown_cell(nb_header))
|
|
278
|
-
|
|
279
|
-
i_line = 0
|
|
280
|
-
|
|
281
|
-
# Exclude everything before the first cell
|
|
282
|
-
while(not lines[i_line].startswith('#%%')):
|
|
283
|
-
i_line += 1
|
|
284
|
-
|
|
285
|
-
current_cell = []
|
|
286
|
-
|
|
287
|
-
def write_code_cell(c):
|
|
288
|
-
|
|
289
|
-
first_non_empty_line = None
|
|
290
|
-
last_non_empty_line = None
|
|
291
|
-
|
|
292
|
-
for i_code_line,code_line in enumerate(c):
|
|
293
|
-
if len(code_line.strip()) > 0:
|
|
294
|
-
if first_non_empty_line is None:
|
|
295
|
-
first_non_empty_line = i_code_line
|
|
296
|
-
last_non_empty_line = i_code_line
|
|
297
|
-
|
|
298
|
-
# Remove the first [first_non_empty_lines] from the list
|
|
299
|
-
c = c[first_non_empty_line:]
|
|
300
|
-
last_non_empty_line -= first_non_empty_line
|
|
301
|
-
c = c[:last_non_empty_line+1]
|
|
302
|
-
|
|
303
|
-
nb['cells'].append(nbf.v4.new_code_cell('\n'.join(c)))
|
|
304
|
-
|
|
305
|
-
while(True):
|
|
306
|
-
|
|
307
|
-
line = lines[i_line].rstrip()
|
|
308
|
-
|
|
309
|
-
if 'end notebook' in line.lower():
|
|
310
|
-
break
|
|
311
|
-
|
|
312
|
-
if lines[i_line].startswith('#%% '):
|
|
313
|
-
if len(current_cell) > 0:
|
|
314
|
-
write_code_cell(current_cell)
|
|
315
|
-
current_cell = []
|
|
316
|
-
markdown_content = line.replace('#%%','##')
|
|
317
|
-
nb['cells'].append(nbf.v4.new_markdown_cell(markdown_content))
|
|
318
|
-
else:
|
|
319
|
-
current_cell.append(line)
|
|
320
|
-
|
|
321
|
-
i_line += 1
|
|
322
|
-
|
|
323
|
-
# Add the last cell
|
|
324
|
-
write_code_cell(current_cell)
|
|
325
|
-
|
|
326
|
-
nbf.write(nb,output_ipynb_file)
|
|
327
|
-
|
api/synchronous/api_core/animal_detection_api/data_management/annotations/annotation_constants.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
########
|
|
2
|
-
#
|
|
3
|
-
# annotation_constants.py
|
|
4
|
-
#
|
|
5
|
-
# Shared constants used to interpret annotation output
|
|
6
|
-
#
|
|
7
|
-
# Categories assigned to bounding boxes. Used throughout our repo; do not change unless
|
|
8
|
-
# you are Dan or Siyu. In fact, do not change unless you are both Dan *and* Siyu.
|
|
9
|
-
#
|
|
10
|
-
# We use integer indices here; this is different than the API output .json file,
|
|
11
|
-
# where indices are string integers.
|
|
12
|
-
#
|
|
13
|
-
########
|
|
14
|
-
|
|
15
|
-
NUM_DETECTOR_CATEGORIES = 3 # this is for choosing colors, so ignoring the "empty" class
|
|
16
|
-
|
|
17
|
-
# This is the label mapping used for our incoming iMerit annotations
|
|
18
|
-
# Only used to parse the incoming annotations. In our database, the string name is used to avoid confusion
|
|
19
|
-
annotation_bbox_categories = [
|
|
20
|
-
{'id': 0, 'name': 'empty'},
|
|
21
|
-
{'id': 1, 'name': 'animal'},
|
|
22
|
-
{'id': 2, 'name': 'person'},
|
|
23
|
-
{'id': 3, 'name': 'group'}, # group of animals
|
|
24
|
-
{'id': 4, 'name': 'vehicle'}
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
annotation_bbox_category_id_to_name = {}
|
|
28
|
-
annotation_bbox_category_name_to_id = {}
|
|
29
|
-
|
|
30
|
-
for cat in annotation_bbox_categories:
|
|
31
|
-
annotation_bbox_category_id_to_name[cat['id']] = cat['name']
|
|
32
|
-
annotation_bbox_category_name_to_id[cat['name']] = cat['id']
|
|
33
|
-
|
|
34
|
-
# MegaDetector outputs
|
|
35
|
-
detector_bbox_categories = [
|
|
36
|
-
{'id': 0, 'name': 'empty'},
|
|
37
|
-
{'id': 1, 'name': 'animal'},
|
|
38
|
-
{'id': 2, 'name': 'person'},
|
|
39
|
-
{'id': 3, 'name': 'vehicle'}
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
detector_bbox_category_id_to_name = {}
|
|
43
|
-
detector_bbox_category_name_to_id = {}
|
|
44
|
-
|
|
45
|
-
for cat in detector_bbox_categories:
|
|
46
|
-
detector_bbox_category_id_to_name[cat['id']] = cat['name']
|
|
47
|
-
detector_bbox_category_name_to_id[cat['name']] = cat['id']
|
api/synchronous/api_core/animal_detection_api/detection/detector_training/copy_checkpoints.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
########
|
|
2
|
-
#
|
|
3
|
-
# copy_checkpoints.py
|
|
4
|
-
#
|
|
5
|
-
# Run this script with specified source_dir and target_dir while the model is training to make a copy
|
|
6
|
-
# of every checkpoint (checkpoints are kept once an hour by default and is difficult to adjust)
|
|
7
|
-
#
|
|
8
|
-
########
|
|
9
|
-
|
|
10
|
-
#%% Imports and constants
|
|
11
|
-
|
|
12
|
-
import time
|
|
13
|
-
import os
|
|
14
|
-
import shutil
|
|
15
|
-
|
|
16
|
-
check_every_n_minutes = 10
|
|
17
|
-
|
|
18
|
-
source_dir = '/datadrive/megadetectorv3/experiments/190425'
|
|
19
|
-
target_dir = '/datadrive/megadetectorv3/experiments/0425_checkpoints'
|
|
20
|
-
|
|
21
|
-
os.makedirs(target_dir, exist_ok=True)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#%% Main loop
|
|
25
|
-
|
|
26
|
-
num_checks = 0
|
|
27
|
-
|
|
28
|
-
while True:
|
|
29
|
-
|
|
30
|
-
num_checks += 1
|
|
31
|
-
print('Checking round {}.'.format(num_checks))
|
|
32
|
-
|
|
33
|
-
for f in os.listdir(source_dir):
|
|
34
|
-
# do not copy event or evaluation results
|
|
35
|
-
if f.startswith('model') or f.startswith('graph'):
|
|
36
|
-
target_path = os.path.join(target_dir, f)
|
|
37
|
-
if not os.path.exists(target_path):
|
|
38
|
-
_ = shutil.copy(os.path.join(source_dir, f), target_path)
|
|
39
|
-
print('Copied {}.'.format(f))
|
|
40
|
-
|
|
41
|
-
print('End of round {}.'.format(num_checks))
|
|
42
|
-
|
|
43
|
-
time.sleep(check_every_n_minutes * 60)
|