megadetector 10.0.1__py3-none-any.whl → 10.0.3__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.

@@ -1869,22 +1869,30 @@ country_code_to_country = None
1869
1869
 
1870
1870
  #%% Functions related to geofencing and taxonomy mapping
1871
1871
 
1872
- def taxonomy_info_to_taxonomy_string(taxonomy_info):
1872
+ def taxonomy_info_to_taxonomy_string(taxonomy_info, include_taxon_id_and_common_name=False):
1873
1873
  """
1874
- Convert a taxonomy record in dict format to a semicolon-delimited string
1874
+ Convert a taxonomy record in dict format to a five- or seven-token semicolon-delimited string
1875
1875
 
1876
1876
  Args:
1877
1877
  taxonomy_info (dict): dict in the format stored in, e.g., taxonomy_string_to_taxonomy_info
1878
+ include_taxon_id_and_common_name (bool, optional): by default, this function returns a
1879
+ five-token string of latin names; if this argument is True, it includes the leading
1880
+ (GUID) and trailing (common name) tokens
1878
1881
 
1879
1882
  Returns:
1880
1883
  str: string in the format used as keys in, e.g., taxonomy_string_to_taxonomy_info
1881
1884
  """
1882
- return taxonomy_info['class'] + ';' + \
1885
+ s = taxonomy_info['class'] + ';' + \
1883
1886
  taxonomy_info['order'] + ';' + \
1884
1887
  taxonomy_info['family'] + ';' + \
1885
1888
  taxonomy_info['genus'] + ';' + \
1886
1889
  taxonomy_info['species']
1887
1890
 
1891
+ if include_taxon_id_and_common_name:
1892
+ s = taxonomy_info['taxon_id'] + ';' + s + ';' + taxonomy_info['common_name']
1893
+
1894
+ return s
1895
+
1888
1896
 
1889
1897
  def initialize_taxonomy_info(taxonomy_file,force_init=False,encoding='cp1252'):
1890
1898
  """
@@ -2504,7 +2512,7 @@ if False:
2504
2512
  initialize_geofencing(geofencing_file, country_code_file, force_init=True)
2505
2513
  initialize_taxonomy_info(taxonomy_file, force_init=True, encoding=encoding)
2506
2514
 
2507
- from megadetector.utils.path_utils import open_file; open_file(geofencing_file)
2515
+ # from megadetector.utils.path_utils import open_file; open_file(geofencing_file)
2508
2516
 
2509
2517
 
2510
2518
  #%% Generate a block list
@@ -2530,6 +2538,14 @@ if False:
2530
2538
  print(rows)
2531
2539
 
2532
2540
 
2541
+ #%% Look up taxonomy info for a common name
2542
+
2543
+ common_name = 'domestic horse'
2544
+ info = common_name_to_taxonomy_info[common_name]
2545
+ s = taxonomy_info_to_taxonomy_string(info,include_taxon_id_and_common_name=True)
2546
+ print(s)
2547
+
2548
+
2533
2549
  #%% Generate a block-except list
2534
2550
 
2535
2551
  block_except_list = 'ALB,AND,ARM,AUT,AZE,BEL,BGR,BIH,BLR,CHE,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,GBR,GEO,GRC,HRV,HUN,IRL,IRN,IRQ,ISL,ISR,ITA,KAZ,LIE,LTU,LUX,LVA,MDA,MKD,MLT,MNE,NLD,NOR,POL,PRT,ROU,RUS,SMR,SRB,SVK,SVN,SWE,TUR,UKR,UZB'
@@ -321,7 +321,7 @@ def visualize_db(db_path, output_dir, image_base_dir, options=None):
321
321
  box_classes = []
322
322
  box_score_strings = []
323
323
 
324
- # All the class labels we've seen for this image (with out without bboxes)
324
+ # All the class labels we've seen for this image (with or without bboxes)
325
325
  image_categories = set()
326
326
 
327
327
  extra_annotation_field_string = ''
@@ -368,6 +368,7 @@ def visualize_db(db_path, output_dir, image_base_dir, options=None):
368
368
  category_name = category_name.replace('"','')
369
369
  category_name = '<a href="https://www.google.com/search?tbm=isch&q={}">{}</a>'.format(
370
370
  category_name,category_name)
371
+
371
372
  image_categories.add(category_name)
372
373
 
373
374
  assert not ('bbox' in anno and 'bbox_relative' in anno), \
@@ -522,7 +523,7 @@ def visualize_db(db_path, output_dir, image_base_dir, options=None):
522
523
 
523
524
  return True
524
525
 
525
- # ...def render_image_info
526
+ # ...def render_image_info(...)
526
527
 
527
528
  print('Rendering images')
528
529
  start_time = time.time()
@@ -589,7 +590,7 @@ def visualize_db(db_path, output_dir, image_base_dir, options=None):
589
590
 
590
591
  return html_output_file,image_db
591
592
 
592
- # def visualize_db(...)
593
+ # ...def visualize_db(...)
593
594
 
594
595
 
595
596
  #%% Command-line driver
@@ -603,8 +604,10 @@ def _args_to_object(args, obj):
603
604
  if not n.startswith('_'):
604
605
  setattr(obj, n, v)
605
606
 
606
-
607
- def main(): # noqa
607
+ def main():
608
+ """
609
+ Command-line driver for visualize_db
610
+ """
608
611
 
609
612
  parser = argparse.ArgumentParser()
610
613
  parser.add_argument('db_path', action='store', type=str,
@@ -642,20 +645,3 @@ def main(): # noqa
642
645
 
643
646
  if __name__ == '__main__':
644
647
  main()
645
-
646
-
647
- #%% Interactive driver
648
-
649
- if False:
650
-
651
- #%%
652
-
653
- db_path = r'e:\wildlife_data\missouri_camera_traps\missouri_camera_traps_set1.json'
654
- output_dir = r'e:\wildlife_data\missouri_camera_traps\preview'
655
- image_base_dir = r'e:\wildlife_data\missouri_camera_traps'
656
-
657
- options = DbVizOptions()
658
- options.num_to_visualize = 100
659
-
660
- html_output_file, db = visualize_db(db_path,output_dir,image_base_dir,options)
661
- # os.startfile(html_output_file)
@@ -397,7 +397,7 @@ def main(): # noqa
397
397
  '--category_names_to_blur', default=None, type=str,
398
398
  help='Comma-separated list of category names to blur (or a single category name, typically "person")')
399
399
  parser.add_argument(
400
- '--classification_confidence', type=float, default=0.1,
400
+ '--classification_confidence', type=float, default=0.3,
401
401
  help='If classification results are present, render results above this threshold')
402
402
 
403
403
  if len(sys.argv[1:]) == 0: