<jupyter_start><jupyter_text>Install gwnet package:<jupyter_code>!pip install --upgrade git+git://github.com/Sunnesoft/g2net-challenge.git

from gwnet import GwEfficientNetB0, GwXception, GwLeNet, TfDevice<jupyter_output><empty_output><jupyter_text>Mount Google Drive folder with processed by whiten, bandpass and notch filters dataset:<jupyter_code>import os
from google.colab import drive

BASE_PATH = '/content/'
DRIVE_PATH = os.path.join(BASE_PATH, 'drive')
drive.mount(DRIVE_PATH)<jupyter_output><empty_output><jupyter_text>Set up the configuration and extract the test dataset from Google Drive to $BASE_PATH folder:<jupyter_code>IMAGE_SIZE = (512, 512, 3)
IMAGE_SCALE = 255.0
BATCH_SIZE = 64
EPOCHS = 20

INPUT_PATH = os.path.join(BASE_PATH, 'tfrecords/test/')
ZIP_GD_IN_FILE = os.path.join(DRIVE_PATH, 'MyDrive/g2net/tfrecords_test.zip')
EXPER_TPL = f'{"_".join(map(str, IMAGE_SIZE))}_{BATCH_SIZE}_{EPOCHS}'
OUT_PATH = os.path.join(BASE_PATH, f'model/{EXPER_TPL}')
GD_OUT_PATH = os.path.join(DRIVE_PATH, f'MyDrive/g2net/model/{EXPER_TPL}/')

!mkdir -p $INPUT_PATH
!mkdir -p $GD_OUT_PATH
!unzip -qq $ZIP_GD_IN_FILE -d '/'<jupyter_output><empty_output><jupyter_text>Test EffitientNetB0 model:<jupyter_code>solver = GwEfficientNetB0(
    name='eff_net_b0',
    mode=TfDevice.TPU,
    image_size=IMAGE_SIZE,
    image_scale_factor=IMAGE_SCALE,
    model_path=OUT_PATH)

solver.load_test_dataset(INPUT_PATH, batch_size=BATCH_SIZE)
solver.show_random_test_batch()

solver.compile()
solver.print_model()
solver.load_model()
solver.infer_test_dataset()
command = f'cp {solver.model_fullpath} {os.path.join(GD_OUT_PATH, solver.model_filename)}'
!{command}<jupyter_output><empty_output><jupyter_text>Test Xception model:<jupyter_code>solver = GwXception(
    name='xception',
    mode=TfDevice.TPU,
    image_size=IMAGE_SIZE,
    image_scale_factor=IMAGE_SCALE,
    model_path=OUT_PATH)

solver.load_test_dataset(INPUT_PATH, batch_size=BATCH_SIZE)
solver.show_random_test_batch()

solver.compile()
solver.print_model()
solver.load_model()
solver.infer_test_dataset()
command = f'cp {solver.model_fullpath} {os.path.join(GD_OUT_PATH, solver.model_filename)}'
!{command}<jupyter_output><empty_output><jupyter_text>Test LeNet model:<jupyter_code>solver = GwLeNet(
    name='le_net',
    mode=TfDevice.TPU,
    image_size=IMAGE_SIZE,
    image_scale_factor=IMAGE_SCALE,
    model_path=OUT_PATH)

solver.load_test_dataset(INPUT_PATH, batch_size=BATCH_SIZE)
solver.show_random_test_batch()

solver.compile(optimizer='adam',
               loss='binary_crossentropy',
               metrics=['AUC'])
solver.print_model()
solver.load_model()
solver.infer_test_dataset()
command = f'cp {solver.model_fullpath} {os.path.join(GD_OUT_PATH, solver.model_filename)}'
!{command}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12325331422429237, 'fraction_numerical': 0.007882479398065209, 'mean_word_length': 7.211764705882353, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '605200', 'license': 'MIT', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1091, 'n_words': 150, 'path': 'examples/gw_test_model.ipynb', 'repo_name': 'Sunnesoft/g2net-challenge', 'size': '2791'}