<jupyter_start><jupyter_text>Augment<jupyter_code>ZOOM_FACTOR=1.6
DIMEN=70
FILTERED_DATA_PATH = "/data/filtered/"
DATASETS_PATH = "/data/sets/"
def copy_files_of_set(df, dataset):
    print("Copying filtered files of " + dataset)
    if path.isdir(FILTERED_DATA_PATH + dataset) is False:
        makedirs(FILTERED_DATA_PATH + dataset, exist_ok=True)

    src_path = Template(DATA_PATH + "images_training/images_training_rev1/$name.jpg")

    for index, image in df.iterrows():
        dest_path = FILTERED_DATA_PATH + dataset + '/' + image['type']
        source_img = src_path.substitute(name=image["GalaxyID"])

        if path.isdir(dest_path) is False:
            mkdir(dest_path)

        copy(source_img, dest_path)
copy_files_of_set(train_df, "training")
copy_files_of_set(validation_df, "validation")
def resize_and_zoom(dataset):
    p = Augmentor.Pipeline(FILTERED_DATA_PATH + dataset, DATASETS_PATH + dataset)
    p.zoom(probability=1, max_factor=ZOOM_FACTOR, min_factor=ZOOM_FACTOR)
    p.resize(probability=1, width=DIMEN, height=DIMEN)
    p.process()
    
def augment_set(n, dataset = ""):
    p = Augmentor.Pipeline(FILTERED_DATA_PATH + "training/" + dataset, DATASETS_PATH + "training/" + dataset)
    p.zoom(probability=1, max_factor=ZOOM_FACTOR, min_factor=ZOOM_FACTOR)
    p.rotate_random_90(probability=0.2)
    p.flip_top_bottom(probability=0.5)
    p.flip_left_right(probability=0.5)
    p.random_contrast(probability=0.5, min_factor=0.7, max_factor=1.5)
    p.random_brightness(probability=0.5, min_factor=0.7, max_factor=1.8)
    p.resize(probability=1, width=DIMEN, height=DIMEN)
    p.sample(n)
resize_and_zoom("training")
resize_and_zoom("validation")
# augment_set(2500, "cigar_shaped")
# augment_set(1500, "spiral_barred")
augment_set(n = 15000)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12624584717607973, 'fraction_numerical': 0.023255813953488372, 'mean_word_length': 5.231034482758621, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '337542', 'license': 'MIT', 'n_tokens_mistral': 709, 'n_tokens_neox': 675, 'n_words': 95, 'path': 'src/vgg19_galaxies.ipynb', 'repo_name': 'madscientistCS/Comparison-performance-between-CNN-architectures', 'size': '1806'}