예제 #1
0
파일: annotation.py 프로젝트: genEM3/genEM3
def merge_json_from_data_dir(fnames: Sequence[str], output_fname: str):
    """
    Function concatenates the data directory to the list of file names and concatenats the related jsons
    """
    # Test concatenating jsons
    full_fnames = []
    for fname in fnames:
        full_fname = os.path.join(get_data_dir(), fname)
        full_fnames.append(full_fname)

    # Concatenate the test and training data sets
    full_output_name = os.path.join(get_data_dir(), output_fname)
    all_ds = WkwData.concat_datasources(json_paths_in=full_fnames,
                                        json_path_out=full_output_name)
    return all_ds
import os

from genEM3.data.wkwdata import WkwData
from genEM3.util.path import get_data_dir

# Read Json file
json_names = [
    'dense_3X_10_10_2_um/original_merged_double_binary_v01.json',
    '10x_test_bboxes/10X_9_9_1_um_double_binary_v01.json'
]
ds_names = [os.path.join(get_data_dir(), j_name) for j_name in json_names]
data_sources = WkwData.concat_datasources(ds_names)
# Get the short version of the data sources
output_name = os.path.join(get_data_dir(), 'combined',
                           'combined_20K_patches.json')
short_ds = WkwData.convert_to_short_ds(data_sources=data_sources)
# Write combined data source json file
WkwData.write_short_ds_json(datasources=short_ds, json_path=output_name)
예제 #3
0
from genEM3.util.path import get_data_dir
from genEM3.data.wkwdata import WkwData
import os

# Test concatenating jsons
test_json_path = os.path.join(get_data_dir(), 'test_data_three_bboxes.json')
train_json_path = os.path.join(
    get_data_dir(), 'debris_clean_added_bboxes2_wiggle_datasource.json')
# Concatenate the test and training data sets
output_name = os.path.join
all_ds = WkwData.concat_datasources([train_json_path, test_json_path],
                                    os.path.join(get_data_dir(),
                                                 'train_test_combined.json'))
assert len(all_ds) == len(WkwData.datasources_from_json(test_json_path)) + len(
    WkwData.datasources_from_json(train_json_path))