data_management/importers/save_the_elephants_survey_A.py [196:258]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        else:
            category_name = species
        
        # Special cases based on the 'photo type' field
        if 'vehicle' in photo_type:
            category_name = 'vehicle'
        # Various spellings of 'community'
        elif 'comm' in photo_type:
            category_name = 'human'
        elif 'camera' in photo_type or 'researcher' in photo_type:
            category_name = 'human'
        elif 'livestock' in photo_type:
            category_name = 'livestock'
        elif 'blank' in photo_type:
            category_name = 'empty'
        elif 'plant movement' in photo_type:
            category_name = 'empty'
            
        category_name = category_name.strip().lower()
            
        # Have we seen this category before?
        if category_name in category_name_to_category:
            category_id = category_name_to_category[category_name]['id'] 
        else:
            category_id = next_category_id
            category = {}
            category['id'] = category_id
            category['name'] = category_name
            category_name_to_category[category_name] = category
            categories.append(category)
            next_category_id += 1
        
        # Create an annotation
        ann = {}        
        ann['id'] = str(uuid.uuid1())
        ann['image_id'] = im['id']    
        ann['category_id'] = category_id
        
        # fieldname = list(mapped_fields.keys())[0]
        for fieldname in mapped_fields:
            target_field = mapped_fields[fieldname]
            val = row[fieldname]
            if isinstance(val,float) and np.isnan(val):
                val = ''
            else:
                val = str(val).strip()
            ann[target_field] = val
            
        annotations.append(ann)
        
    # ...for each row
                
# ...for each image
    
print('Finished creating CCT dictionaries in {}'.format(
      humanfriendly.format_timespan(elapsed)))
    

#%% Create info struct

info = {}
info['year'] = 2019
info['version'] = 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



data_management/importers/save_the_elephants_survey_B.py [208:270]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        else:
            category_name = species
        
        # Special cases based on the 'photo type' field
        if 'vehicle' in photo_type:
            category_name = 'vehicle'
        # Various spellings of 'community'
        elif 'comm' in photo_type:
            category_name = 'human'
        elif 'camera' in photo_type or 'researcher' in photo_type:
            category_name = 'human'
        elif 'livestock' in photo_type:
            category_name = 'livestock'
        elif 'blank' in photo_type:
            category_name = 'empty'
        elif 'plant movement' in photo_type:
            category_name = 'empty'
            
        category_name = category_name.strip().lower()
            
        # Have we seen this category before?
        if category_name in category_name_to_category:
            category_id = category_name_to_category[category_name]['id'] 
        else:
            category_id = next_category_id
            category = {}
            category['id'] = category_id
            category['name'] = category_name
            category_name_to_category[category_name] = category
            categories.append(category)
            next_category_id += 1
        
        # Create an annotation
        ann = {}        
        ann['id'] = str(uuid.uuid1())
        ann['image_id'] = im['id']    
        ann['category_id'] = category_id
        
        # fieldname = list(mapped_fields.keys())[0]
        for fieldname in mapped_fields:
            target_field = mapped_fields[fieldname]
            val = row[fieldname]
            if isinstance(val,float) and np.isnan(val):
                val = ''
            else:
                val = str(val).strip()
            ann[target_field] = val
            
        annotations.append(ann)
        
    # ...for each row
                
# ...for each image
    
print('Finished creating CCT dictionaries in {}'.format(
      humanfriendly.format_timespan(elapsed)))
    

#%% Create info struct

info = {}
info['year'] = 2019
info['version'] = 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



