<jupyter_start><jupyter_text>Prepare data<jupyter_code>vggface2_light_path = '../data/vggface2/vggface2-light'
vggface2_path = '../data/vggface2/vggface2'
max_images_for_identity = 10
faces_valid_df = compile_faces_dataset(vggface2_light_path, pairs=max_images_for_identity, qty=-1)
faces_valid_df.describe()
faces_train_df = compile_faces_dataset(
    vggface2_light_path, folder='train', qty=-1)
faces_train_df.describe()
faces_df = pd.concat([faces_valid_df, faces_train_df])
faces_df.describe()
source_bunch = create_bunch(faces_df, cols='source', path=vggface2_light_path)
target_bunch = create_bunch(faces_df, cols='target', path=vggface2_light_path)
train_ds = TwinDataset(source_bunch.train_ds, target_bunch.train_ds)
valid_ds = TwinDataset(source_bunch.valid_ds, target_bunch.valid_ds)
twin_databunch = DataBunch.create(
    train_ds=train_ds, valid_ds=valid_ds, path=vggface2_light_path, bs=16)<jupyter_output><empty_output><jupyter_text>Train<jupyter_code>learner = Learner(twin_databunch,
                  SiameseNetwork(
                      architecture=fastai.vision.models.resnet152,
                      cut=-1,
                      nf=4096, nc=100,
                      lin_ftrs=[800, 500]),
                  loss_func=contrastive_loss, path='./models')
print(learner)
# freeze resnet
learner.freeze_to(363)
learner.fit_one_cycle(50)
learner.recorder.plot_losses()
learner.recorder.plot()
learner.save('resnet152-frozen-after50')
import torchvision
learner = Learner(twin_databunch,
                  SiameseNetwork(
                      architecture=torchvision.models.densenet121,
                      cut=-1,
                      nf=2048, nc=100,
                      lin_ftrs=[800, 500]),
                  loss_func=contrastive_loss, path='./models')
print(learner)
learner.freeze_to(365)
learner.fit_one_cycle(50)
learner.recorder.plot_losses()
learner.recorder.plot()
learner.save('densenet121-frozen-after50')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10987341772151898, 'fraction_numerical': 0.035949367088607596, 'mean_word_length': 3.94, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '49671', 'license': 'Apache-2.0', 'n_tokens_mistral': 765, 'n_tokens_neox': 701, 'n_words': 79, 'path': 'twin-databunch.ipynb', 'repo_name': 'webdizz/upass.ai', 'size': '1975'}