<jupyter_start><jupyter_text>Import Training Data<jupyter_code>train_df = pd.read_csv(PATH_TO_TRAIN_PAIRS)
train_df.head()<jupyter_output><empty_output><jupyter_text>Test Generator<jupyter_code>data_generator = CustomGen(train_df)
target_index = 1
batch_index = 300
[source_images, target_images], class_labels = data_generator[batch_index]
print(class_labels[target_index])
print_image_matrices((source_images[target_index], target_images[target_index]))
entry = train_df.iloc[batch_index * 32 + target_index]
print(entry['class_label'])
print_image_pair((entry["source_image"], entry["target_image"]))<jupyter_output>1.0<jupyter_text>How to Use Generator<jupyter_code>import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from random import randrange
from viz.image_printers import print_image_type, print_titles

data_generator = CustomGen(train_df) # Step 1. initialize it<jupyter_output>Found 163768 validated image filenames belonging to 2 classes.
Found 163768 validated image filenames belonging to 2 classes.<jupyter_text>Related Products<jupyter_code>related_indices = print_image_type(train_df, data_generator, "RELATED")
print_titles(train_df, related_indices)<jupyter_output><empty_output><jupyter_text>Unrelated but Similar Products<jupyter_code>unrelated_similar_indices = print_image_type(train_df, data_generator, "UNRELATED_SIMILAR")
print_titles(train_df, unrelated_similar_indices)<jupyter_output><empty_output><jupyter_text>Unrelateted and Distinct Products<jupyter_code>unrelated_notsimilar_indices = print_image_type(train_df, data_generator, "UNRELATED_NOTSIMILAR")
print_titles(train_df, unrelated_notsimilar_indices)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08549528301886793, 'fraction_numerical': 0.014150943396226415, 'mean_word_length': 14.017699115044248, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '127181', 'license': 'MIT', 'n_tokens_mistral': 609, 'n_tokens_neox': 575, 'n_words': 89, 'path': 'src/2. Test Generator.ipynb', 'repo_name': 'thearod5/kaggle-product-matching', 'size': '1696'}