Functions that prepare label files and split the data into train validation and test sets

createjson[source]

createjson(fn='', offset=0)

create a Labelme compatable json file

annotate_json[source]

annotate_json(data, shape_type='circle', points=None)

create_json_from_CSV[source]

create_json_from_CSV(csv_fn, load_jpg_fn, offset=0, height=0, width=0)

csv_to_json_dir[source]

csv_to_json_dir(src_path, dest_path, number_files='all')

Convert an entire directory of Techion CSV files to JSON files. Store in the dest directory CSV format is x,y,species_number 1383,1571,2 1687,1822,1 2036,1327,1

resize_json_file[source]

resize_json_file(fn, scale=1, offset=0)

resize_json_dir[source]

resize_json_dir(file_data, src_path, dest_path, number_files='all', height=800)

Resize src_path directory of JSON files and store in dest_path directory There needs to be resized jpg files in the dest_path directory. An example is 226260 - 1|0.436047|221|.jpg where |0.436047|221| marks the factor and offset factors to apply :param src_path: Source path where json files are :param dest_path: Destination path to store resized json files :param number_files: Number of json files to process, leave empty for all files in directory :return: number of file processed

Test create_json_from_CSV()

from json import JSONEncoder
json_object = create_json_from_CSV('nbs_test_data/235443 - 1.jpg.points.csv', 'nbs_test_data/235443 - 1.jpg')

b = prettyjson(json_object)
print(b)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-c64042ba4e79> in <module>
      2 json_object = create_json_from_CSV('nbs_test_data/235443 - 1.jpg.points.csv', 'nbs_test_data/235443 - 1.jpg')
      3 
----> 4 b = prettyjson(json_object)
      5 print(b)
      6 

NameError: name 'prettyjson' is not defined

prettyjson[source]

prettyjson(obj, indent=2, maxlinelength=80)

Renders JSON content with indentation and line splits/concatenations to fit maxlinelength. Only dicts, lists and basic types are supported