megadetector 5.0.5__py3-none-any.whl → 5.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of megadetector might be problematic. Click here for more details.

Files changed (132) hide show
  1. api/batch_processing/data_preparation/manage_local_batch.py +302 -263
  2. api/batch_processing/data_preparation/manage_video_batch.py +81 -2
  3. api/batch_processing/postprocessing/add_max_conf.py +1 -0
  4. api/batch_processing/postprocessing/categorize_detections_by_size.py +50 -19
  5. api/batch_processing/postprocessing/compare_batch_results.py +110 -60
  6. api/batch_processing/postprocessing/load_api_results.py +56 -70
  7. api/batch_processing/postprocessing/md_to_coco.py +1 -1
  8. api/batch_processing/postprocessing/md_to_labelme.py +2 -1
  9. api/batch_processing/postprocessing/postprocess_batch_results.py +240 -81
  10. api/batch_processing/postprocessing/render_detection_confusion_matrix.py +625 -0
  11. api/batch_processing/postprocessing/repeat_detection_elimination/find_repeat_detections.py +71 -23
  12. api/batch_processing/postprocessing/repeat_detection_elimination/remove_repeat_detections.py +1 -1
  13. api/batch_processing/postprocessing/repeat_detection_elimination/repeat_detections_core.py +227 -75
  14. api/batch_processing/postprocessing/subset_json_detector_output.py +132 -5
  15. api/batch_processing/postprocessing/top_folders_to_bottom.py +1 -1
  16. api/synchronous/api_core/animal_detection_api/detection/run_detector_batch.py +2 -2
  17. classification/prepare_classification_script.py +191 -191
  18. data_management/coco_to_yolo.py +68 -45
  19. data_management/databases/integrity_check_json_db.py +7 -5
  20. data_management/generate_crops_from_cct.py +3 -3
  21. data_management/get_image_sizes.py +8 -6
  22. data_management/importers/add_timestamps_to_icct.py +79 -0
  23. data_management/importers/animl_results_to_md_results.py +160 -0
  24. data_management/importers/auckland_doc_test_to_json.py +4 -4
  25. data_management/importers/auckland_doc_to_json.py +1 -1
  26. data_management/importers/awc_to_json.py +5 -5
  27. data_management/importers/bellevue_to_json.py +5 -5
  28. data_management/importers/carrizo_shrubfree_2018.py +5 -5
  29. data_management/importers/carrizo_trail_cam_2017.py +5 -5
  30. data_management/importers/cct_field_adjustments.py +2 -3
  31. data_management/importers/channel_islands_to_cct.py +4 -4
  32. data_management/importers/ena24_to_json.py +5 -5
  33. data_management/importers/helena_to_cct.py +10 -10
  34. data_management/importers/idaho-camera-traps.py +12 -12
  35. data_management/importers/idfg_iwildcam_lila_prep.py +8 -8
  36. data_management/importers/jb_csv_to_json.py +4 -4
  37. data_management/importers/missouri_to_json.py +1 -1
  38. data_management/importers/noaa_seals_2019.py +1 -1
  39. data_management/importers/pc_to_json.py +5 -5
  40. data_management/importers/prepare-noaa-fish-data-for-lila.py +4 -4
  41. data_management/importers/prepare_zsl_imerit.py +5 -5
  42. data_management/importers/rspb_to_json.py +4 -4
  43. data_management/importers/save_the_elephants_survey_A.py +5 -5
  44. data_management/importers/save_the_elephants_survey_B.py +6 -6
  45. data_management/importers/snapshot_safari_importer.py +9 -9
  46. data_management/importers/snapshot_serengeti_lila.py +9 -9
  47. data_management/importers/timelapse_csv_set_to_json.py +5 -7
  48. data_management/importers/ubc_to_json.py +4 -4
  49. data_management/importers/umn_to_json.py +4 -4
  50. data_management/importers/wellington_to_json.py +1 -1
  51. data_management/importers/wi_to_json.py +2 -2
  52. data_management/importers/zamba_results_to_md_results.py +181 -0
  53. data_management/labelme_to_coco.py +35 -7
  54. data_management/labelme_to_yolo.py +229 -0
  55. data_management/lila/add_locations_to_island_camera_traps.py +1 -1
  56. data_management/lila/add_locations_to_nacti.py +147 -0
  57. data_management/lila/create_lila_blank_set.py +474 -0
  58. data_management/lila/create_lila_test_set.py +2 -1
  59. data_management/lila/create_links_to_md_results_files.py +106 -0
  60. data_management/lila/download_lila_subset.py +46 -21
  61. data_management/lila/generate_lila_per_image_labels.py +23 -14
  62. data_management/lila/get_lila_annotation_counts.py +17 -11
  63. data_management/lila/lila_common.py +14 -11
  64. data_management/lila/test_lila_metadata_urls.py +116 -0
  65. data_management/ocr_tools.py +829 -0
  66. data_management/resize_coco_dataset.py +13 -11
  67. data_management/yolo_output_to_md_output.py +84 -12
  68. data_management/yolo_to_coco.py +38 -20
  69. detection/process_video.py +36 -14
  70. detection/pytorch_detector.py +23 -8
  71. detection/run_detector.py +76 -19
  72. detection/run_detector_batch.py +178 -63
  73. detection/run_inference_with_yolov5_val.py +326 -57
  74. detection/run_tiled_inference.py +153 -43
  75. detection/video_utils.py +34 -8
  76. md_utils/ct_utils.py +172 -1
  77. md_utils/md_tests.py +372 -51
  78. md_utils/path_utils.py +167 -39
  79. md_utils/process_utils.py +26 -7
  80. md_utils/split_locations_into_train_val.py +215 -0
  81. md_utils/string_utils.py +10 -0
  82. md_utils/url_utils.py +0 -2
  83. md_utils/write_html_image_list.py +9 -26
  84. md_visualization/plot_utils.py +12 -8
  85. md_visualization/visualization_utils.py +106 -7
  86. md_visualization/visualize_db.py +16 -8
  87. md_visualization/visualize_detector_output.py +208 -97
  88. {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/METADATA +3 -6
  89. {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/RECORD +98 -121
  90. {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/WHEEL +1 -1
  91. taxonomy_mapping/map_lila_taxonomy_to_wi_taxonomy.py +1 -1
  92. taxonomy_mapping/map_new_lila_datasets.py +43 -39
  93. taxonomy_mapping/prepare_lila_taxonomy_release.py +5 -2
  94. taxonomy_mapping/preview_lila_taxonomy.py +27 -27
  95. taxonomy_mapping/species_lookup.py +33 -13
  96. taxonomy_mapping/taxonomy_csv_checker.py +7 -5
  97. api/synchronous/api_core/yolov5/detect.py +0 -252
  98. api/synchronous/api_core/yolov5/export.py +0 -607
  99. api/synchronous/api_core/yolov5/hubconf.py +0 -146
  100. api/synchronous/api_core/yolov5/models/__init__.py +0 -0
  101. api/synchronous/api_core/yolov5/models/common.py +0 -738
  102. api/synchronous/api_core/yolov5/models/experimental.py +0 -104
  103. api/synchronous/api_core/yolov5/models/tf.py +0 -574
  104. api/synchronous/api_core/yolov5/models/yolo.py +0 -338
  105. api/synchronous/api_core/yolov5/train.py +0 -670
  106. api/synchronous/api_core/yolov5/utils/__init__.py +0 -36
  107. api/synchronous/api_core/yolov5/utils/activations.py +0 -103
  108. api/synchronous/api_core/yolov5/utils/augmentations.py +0 -284
  109. api/synchronous/api_core/yolov5/utils/autoanchor.py +0 -170
  110. api/synchronous/api_core/yolov5/utils/autobatch.py +0 -66
  111. api/synchronous/api_core/yolov5/utils/aws/__init__.py +0 -0
  112. api/synchronous/api_core/yolov5/utils/aws/resume.py +0 -40
  113. api/synchronous/api_core/yolov5/utils/benchmarks.py +0 -148
  114. api/synchronous/api_core/yolov5/utils/callbacks.py +0 -71
  115. api/synchronous/api_core/yolov5/utils/dataloaders.py +0 -1087
  116. api/synchronous/api_core/yolov5/utils/downloads.py +0 -178
  117. api/synchronous/api_core/yolov5/utils/flask_rest_api/example_request.py +0 -19
  118. api/synchronous/api_core/yolov5/utils/flask_rest_api/restapi.py +0 -46
  119. api/synchronous/api_core/yolov5/utils/general.py +0 -1018
  120. api/synchronous/api_core/yolov5/utils/loggers/__init__.py +0 -187
  121. api/synchronous/api_core/yolov5/utils/loggers/wandb/__init__.py +0 -0
  122. api/synchronous/api_core/yolov5/utils/loggers/wandb/log_dataset.py +0 -27
  123. api/synchronous/api_core/yolov5/utils/loggers/wandb/sweep.py +0 -41
  124. api/synchronous/api_core/yolov5/utils/loggers/wandb/wandb_utils.py +0 -577
  125. api/synchronous/api_core/yolov5/utils/loss.py +0 -234
  126. api/synchronous/api_core/yolov5/utils/metrics.py +0 -355
  127. api/synchronous/api_core/yolov5/utils/plots.py +0 -489
  128. api/synchronous/api_core/yolov5/utils/torch_utils.py +0 -314
  129. api/synchronous/api_core/yolov5/val.py +0 -394
  130. md_utils/matlab_porting_tools.py +0 -97
  131. {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/LICENSE +0 -0
  132. {megadetector-5.0.5.dist-info → megadetector-5.0.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,229 @@
1
+ ########
2
+ #
3
+ # labelme_to_yolo.py
4
+ #
5
+ # Create YOLO .txt files in a folder containing labelme .json files.
6
+ #
7
+ ########
8
+
9
+ #%% Imports
10
+
11
+ import os
12
+ import json
13
+
14
+ from md_utils.path_utils import recursive_file_list
15
+ from tqdm import tqdm
16
+
17
+
18
+ #%% Main function
19
+
20
+ def labelme_file_to_yolo_file(labelme_file,
21
+ category_name_to_category_id,
22
+ yolo_file=None,
23
+ required_token=None,
24
+ right_edge_quantization_threshold=None,
25
+ overwrite_behavior='overwrite'):
26
+ """
27
+ Convert the single .json file labelme_file to yolo format, writing the results to the text
28
+ file yolo_file (defaults to s/json/txt).
29
+
30
+ If required_token is not None and the labelme_file does not contain the key [required_token],
31
+ no-ops.
32
+
33
+ right_edge_quantization_threshold is an off-by-default hack to handle cases where
34
+ boxes that really should be running off the right side of the image only extend like 99%
35
+ of the way there, due to what appears to be a slight bias inherent to MD. If a box extends
36
+ within [right_edge_quantization_threshold] (a small number, from 0 to 1, but probably around
37
+ 0.02) of the right edge of the image, it will be extended to the far right edge.
38
+ """
39
+
40
+ assert os.path.isfile(labelme_file), 'Could not find labelme .json file {}'.format(labelme_file)
41
+ assert labelme_file.endswith('.json'), 'Illegal labelme .json file {}'.format(labelme_file)
42
+
43
+ if yolo_file is None:
44
+ yolo_file = os.path.splitext(labelme_file)[0] + '.txt'
45
+
46
+ if os.path.isfile(yolo_file):
47
+ if overwrite_behavior == 'skip':
48
+ return
49
+ else:
50
+ assert overwrite_behavior == 'overwrite', \
51
+ 'Unrecognized overwrite behavior {}'.format(overwrite_behavior)
52
+
53
+ with open(labelme_file,'r') as f:
54
+ labelme_data = json.load(f)
55
+
56
+ if required_token is not None and required_token not in labelme_data:
57
+ return
58
+
59
+ im_height = labelme_data['imageHeight']
60
+ im_width = labelme_data['imageWidth']
61
+
62
+ yolo_lines = []
63
+
64
+ for shape in labelme_data['shapes']:
65
+
66
+ assert shape['shape_type'] == 'rectangle', \
67
+ 'I only know how to convert rectangles to YOLO format'
68
+ assert shape['label'] in category_name_to_category_id, \
69
+ 'Category {} not in category mapping'.format(shape['label'])
70
+ assert len(shape['points']) == 2, 'Illegal rectangle'
71
+ category_id = category_name_to_category_id[shape['label']]
72
+
73
+ p0 = shape['points'][0]
74
+ p1 = shape['points'][1]
75
+
76
+ # LabelMe: [[x0,y0],[x1,y1]] (arbitrarily sorted) (absolute coordinates)
77
+ #
78
+ # YOLO: [class, x_center, y_center, width, height] (normalized coordinates)
79
+ minx_abs = min(p0[0],p1[0])
80
+ maxx_abs = max(p0[0],p1[0])
81
+ miny_abs = min(p0[1],p1[1])
82
+ maxy_abs = max(p0[1],p1[1])
83
+
84
+ if (minx_abs >= (im_width-1)) or (maxx_abs <= 0) or \
85
+ (miny_abs >= (im_height-1)) or (maxy_abs <= 0):
86
+ print('Skipping invalid shape in {}'.format(labelme_file))
87
+ continue
88
+
89
+ # Clip to [0,1]
90
+ maxx_abs = min(maxx_abs,im_width-1)
91
+ maxy_abs = min(maxy_abs,im_height-1)
92
+ minx_abs = max(minx_abs,0.0)
93
+ miny_abs = max(miny_abs,0.0)
94
+
95
+ minx_rel = minx_abs / (im_width-1)
96
+ maxx_rel = maxx_abs / (im_width-1)
97
+ miny_rel = miny_abs / (im_height-1)
98
+ maxy_rel = maxy_abs / (im_height-1)
99
+
100
+ if (right_edge_quantization_threshold is not None):
101
+ right_edge_distance = 1.0 - maxx_rel
102
+ if right_edge_distance < right_edge_quantization_threshold:
103
+ maxx_rel = 1.0
104
+
105
+ assert maxx_rel >= minx_rel
106
+ assert maxy_rel >= miny_rel
107
+
108
+ xcenter_rel = (maxx_rel + minx_rel) / 2.0
109
+ ycenter_rel = (maxy_rel + miny_rel) / 2.0
110
+ w_rel = maxx_rel - minx_rel
111
+ h_rel = maxy_rel - miny_rel
112
+
113
+ yolo_line = '{} {:.3f} {:.3f} {:.3f} {:.3f}'.format(category_id,
114
+ xcenter_rel, ycenter_rel, w_rel, h_rel)
115
+ yolo_lines.append(yolo_line)
116
+
117
+ # ...for each shape
118
+
119
+ with open(yolo_file,'w') as f:
120
+ for s in yolo_lines:
121
+ f.write(s + '\n')
122
+
123
+
124
+ def labelme_folder_to_yolo(labelme_folder,
125
+ category_name_to_category_id=None,
126
+ required_token=None,
127
+ right_edge_quantization_threshold=None,
128
+ overwrite_behavior='overwrite'):
129
+ """
130
+ Given a folder with images and labelme .json files, convert the .json files
131
+ to YOLO .txt format. If category_name_to_category_id is None, first reads
132
+ all the labels in the folder to build a zero-indexed name --> ID mapping.
133
+
134
+ If required_token is not None and a labelme_file does not contain the key [required_token],
135
+ it won't be converted.
136
+
137
+ right_edge_quantization_threshold is an off-by-default hack to handle cases where
138
+ boxes that really should be running off the right side of the image only extend like 99%
139
+ of the way there, due to what appears to be a slight bias inherent to MD. If a box extends
140
+ within [right_edge_quantization_threshold] (a small number, from 0 to 1, but probably around
141
+ 0.02) of the right edge of the image, it will be extended to the far right edge.
142
+
143
+ returns category_name_to_category_id, whether it was passed in or constructed.
144
+ """
145
+
146
+ labelme_files_relative = recursive_file_list(labelme_folder,return_relative_paths=True)
147
+ labelme_files_relative = [fn for fn in labelme_files_relative if fn.endswith('.json')]
148
+
149
+ if required_token is None:
150
+ valid_labelme_files_relative = labelme_files_relative
151
+ else:
152
+ valid_labelme_files_relative = []
153
+
154
+ # fn_relative = labelme_files_relative[-1]
155
+ for fn_relative in labelme_files_relative:
156
+
157
+ fn_abs = os.path.join(labelme_folder,fn_relative)
158
+
159
+ with open(fn_abs,'r') as f:
160
+ labelme_data = json.load(f)
161
+ if required_token not in labelme_data:
162
+ continue
163
+
164
+ valid_labelme_files_relative.append(fn_relative)
165
+
166
+ print('{} of {} files are valid'.format(len(valid_labelme_files_relative),
167
+ len(labelme_files_relative)))
168
+
169
+ del labelme_files_relative
170
+
171
+ if category_name_to_category_id is None:
172
+
173
+ category_name_to_category_id = {}
174
+
175
+ for fn_relative in valid_labelme_files_relative:
176
+
177
+ fn_abs = os.path.join(labelme_folder,fn_relative)
178
+ with open(fn_abs,'r') as f:
179
+ labelme_data = json.load(f)
180
+ for shape in labelme_data['shapes']:
181
+ label = shape['label']
182
+ if label not in category_name_to_category_id:
183
+ category_name_to_category_id[label] = len(category_name_to_category_id)
184
+ # ...for each file
185
+
186
+ # ...if we need to build a category mapping
187
+
188
+ for fn_relative in tqdm(valid_labelme_files_relative):
189
+
190
+ fn_abs = os.path.join(labelme_folder,fn_relative)
191
+ labelme_file_to_yolo_file(fn_abs,
192
+ category_name_to_category_id,
193
+ yolo_file=None,
194
+ required_token=required_token,
195
+ right_edge_quantization_threshold=\
196
+ right_edge_quantization_threshold,
197
+ overwrite_behavior=overwrite_behavior)
198
+
199
+ # ...for each file
200
+
201
+ print('Converted {} labelme .json files to YOLO'.format(
202
+ len(valid_labelme_files_relative)))
203
+
204
+ return category_name_to_category_id
205
+
206
+
207
+ #%% Interactive driver
208
+
209
+ if False:
210
+
211
+ pass
212
+
213
+ #%%
214
+
215
+ import os
216
+ labelme_file = os.path.expanduser('~/tmp/labels/x.json')
217
+ yolo_file = None
218
+ required_token = 'saved_by_labelme'
219
+ right_edge_quantization_threshold = 0.015
220
+ category_name_to_category_id = {'animal':0}
221
+
222
+ #%%
223
+
224
+ labelme_folder = os.path.expanduser('~/tmp/labels')
225
+
226
+
227
+ #%% Command-line driver
228
+
229
+ # TODO
@@ -80,7 +80,7 @@ viz_options.add_search_links = False
80
80
  viz_options.sort_by_filename = False
81
81
  viz_options.parallelize_rendering = True
82
82
  viz_options.classes_to_exclude = ['test']
83
- html_output_file, image_db = visualize_db.process_images(db_path=output_fn,
83
+ html_output_file, image_db = visualize_db.visualize_db(db_path=output_fn,
84
84
  output_dir=preview_folder,
85
85
  image_base_dir=image_directory,
86
86
  options=viz_options)
@@ -0,0 +1,147 @@
1
+ ########
2
+ #
3
+ # add_locations_to_nacti.py
4
+ #
5
+ # As of 10.2023, NACTI metadata only has very coarse location information (e.g. "Florida"),
6
+ # but camera IDs are embedded in filenames. This script pulls that information from filenames
7
+ # and adds it to metadata.
8
+ #
9
+ ########
10
+
11
+ #%% Imports and constants
12
+
13
+ import os
14
+ import json
15
+ import shutil
16
+
17
+ from tqdm import tqdm
18
+ from collections import defaultdict
19
+
20
+ input_file = r'd:\lila\nacti\nacti_metadata.json.1.13\nacti_metadata.json'
21
+ output_file = r'g:\temp\nacti_metadata.1.14.json'
22
+
23
+
24
+ #%% Read metadata
25
+
26
+ with open(input_file,'r') as f:
27
+ d = json.load(f)
28
+
29
+ assert d['info']['version'] == 1.13
30
+
31
+
32
+ #%% Map images to locations (according to the metadata)
33
+
34
+ file_name_to_original_location = {}
35
+
36
+ # im = dataset_labels['images'][0]
37
+ for im in tqdm(d['images']):
38
+ file_name_to_original_location[im['file_name']] = im['location']
39
+
40
+ original_locations = set(file_name_to_original_location.values())
41
+
42
+ print('Found {} locations in the original metadata:'.format(len(original_locations)))
43
+ for loc in original_locations:
44
+ print('[{}]'.format(loc))
45
+
46
+
47
+ #%% Map images to new locations
48
+
49
+ def path_to_location(relative_path):
50
+
51
+ relative_path = relative_path.replace('\\','/')
52
+ if relative_path in file_name_to_original_location:
53
+ location_name = file_name_to_original_location[relative_path]
54
+ if location_name == 'San Juan Mntns, Colorado':
55
+ # "part0/sub000/2010_Unit150_Ivan097_img0003.jpg"
56
+ tokens = relative_path.split('/')[-1].split('_')
57
+ assert tokens[1].startswith('Unit')
58
+ location_name = 'sanjuan_{}_{}_{}'.format(tokens[0],tokens[1],tokens[2])
59
+ elif location_name == 'Lebec, California':
60
+ # "part0/sub035/CA-03_08_13_2015_CA-03_0009738.jpg"
61
+ tokens = relative_path.split('/')[-1].split('_')
62
+ assert tokens[0].startswith('CA-') or tokens[0].startswith('TAG-')
63
+ location_name = 'lebec_{}'.format(tokens[0])
64
+ elif location_name == 'Archbold, FL':
65
+ # "part1/sub110/FL-01_01_25_2016_FL-01_0040421.jpg"
66
+ tokens = relative_path.split('/')[-1].split('_')
67
+ assert tokens[0].startswith('FL-')
68
+ location_name = 'archbold_{}'.format(tokens[0])
69
+ else:
70
+ assert location_name == ''
71
+ tokens = relative_path.split('/')[-1].split('_')
72
+ if tokens[0].startswith('CA-') or tokens[0].startswith('TAG-') or tokens[0].startswith('FL-'):
73
+ location_name = '{}'.format(tokens[0])
74
+
75
+ else:
76
+
77
+ location_name = 'unknown'
78
+
79
+ # print('Returning location {} for file {}'.format(location_name,relative_path))
80
+
81
+ return location_name
82
+
83
+ file_name_to_updated_location = {}
84
+ updated_location_to_count = defaultdict(int)
85
+ for im in tqdm(d['images']):
86
+
87
+ updated_location = path_to_location(im['file_name'])
88
+ file_name_to_updated_location[im['file_name']] = updated_location
89
+ updated_location_to_count[updated_location] += 1
90
+
91
+ updated_location_to_count = {k: v for k, v in sorted(updated_location_to_count.items(),
92
+ key=lambda item: item[1],
93
+ reverse=True)}
94
+
95
+ updated_locations = set(file_name_to_updated_location.values())
96
+
97
+ print('Found {} updated locations in the original metadata:'.format(len(updated_locations)))
98
+ for loc in updated_location_to_count:
99
+ print('{}: {}'.format(loc,updated_location_to_count[loc]))
100
+
101
+
102
+ #%% Re-write metadata
103
+
104
+ for im in d['images']:
105
+ im['location'] = file_name_to_updated_location[im['file_name']]
106
+ d['info']['version'] = 1.14
107
+
108
+ with open(output_file,'w') as f:
109
+ json.dump(d,f,indent=1)
110
+
111
+
112
+ #%% For each location, sample some random images to make sure they look consistent
113
+
114
+ input_base = r'd:\lila\nacti-unzipped'
115
+ assert os.path.isdir(input_base)
116
+
117
+ location_to_images = defaultdict(list)
118
+
119
+ for im in d['images']:
120
+ location_to_images[im['location']].append(im)
121
+
122
+ n_to_sample = 10
123
+ import random
124
+ random.seed(0)
125
+ sampling_folder_base = r'g:\temp\nacti_samples'
126
+
127
+ for location in tqdm(location_to_images):
128
+
129
+ images_this_location = location_to_images[location]
130
+ if len(images_this_location) > n_to_sample:
131
+ images_this_location = random.sample(images_this_location,n_to_sample)
132
+
133
+ for i_image,im in enumerate(images_this_location):
134
+
135
+ fn_relative = im['file_name']
136
+ source_fn_abs = os.path.join(input_base,fn_relative)
137
+ assert os.path.isfile(source_fn_abs)
138
+ ext = os.path.splitext(fn_relative)[1]
139
+ target_fn_abs = os.path.join(sampling_folder_base,'{}/{}'.format(
140
+ location,'image_{}{}'.format(str(i_image).zfill(2),ext)))
141
+ os.makedirs(os.path.dirname(target_fn_abs),exist_ok=True)
142
+ shutil.copyfile(source_fn_abs,target_fn_abs)
143
+
144
+ # ...for each image
145
+
146
+ # ...for each location
147
+