<commit_before>import math
import random
import numpy as np
from keras.utils import Sequence

from .preprocessing import load_image
from .preprocessing import B_MEAN, G_MEAN, R_MEAN
from .boxes import assign_prior_boxes
from .data_augmentation import SSDAugmentation


class SequenceManager(Sequence):

    def __init__(self, data, mode, prior_boxes,
                 batch_size=32, box_scale_factors=[.1, .1, .2, .2],
                 num_classes=21, seed=777):

        if mode not in ['train', 'val']:
            raise Exception('Invalide mode:', mode)

        random.seed(seed)
        self.data = list(data.items())
        random.shuffle(self.data)

        self.mode = mode
        self.num_classes = num_classes
        self.prior_boxes = prior_boxes
        self.box_scale_factors = box_scale_factors
        self.batch_size = batch_size
        self.transform = SSDAugmentation(mode, 300, (B_MEAN, G_MEAN, R_MEAN))

    def __len__(self):
        return math.ceil(len(self.data) / self.batch_size)

    def __getitem__(self, batch_arg):
        start_arg, end_arg = self._get_args(batch_arg)
        inputs, targets = [], []
        for sample_arg, batch_data in enumerate(self.data[start_arg:end_arg]):
            image_path, box_data = batch_data[0], batch_data[1]
            image_array = load_image(image_path, RGB=False).copy()
            data = (image_array, box_data[:, :4], box_data[:, 4:])
            image_array, box_corners, labels = self.transform(*data)<commit_msg>Correct typo<commit_after>import math
import random
import numpy as np
from keras.utils import Sequence

from .preprocessing import load_image
from .preprocessing import B_MEAN, G_MEAN, R_MEAN
from .boxes import assign_prior_boxes
from .data_augmentation import SSDAugmentation


class SequenceManager(Sequence):

    def __init__(self, data, mode, prior_boxes,
                 batch_size=32, box_scale_factors=[.1, .1, .2, .2],
                 num_classes=21, seed=777):

        if mode not in ['train', 'val']:
            raise Exception('Invalid mode:', mode)

        random.seed(seed)
        self.data = list(data.items())
        random.shuffle(self.data)

        self.mode = mode
        self.num_classes = num_classes
        self.prior_boxes = prior_boxes
        self.box_scale_factors = box_scale_factors
        self.batch_size = batch_size
        self.transform = SSDAugmentation(mode, 300, (B_MEAN, G_MEAN, R_MEAN))

    def __len__(self):
        return math.ceil(len(self.data) / self.batch_size)

    def __getitem__(self, batch_arg):
        start_arg, end_arg = self._get_args(batch_arg)
        inputs, targets = [], []
        for sample_arg, batch_data in enumerate(self.data[start_arg:end_arg]):
            image_path, box_data = batch_data[0], batch_data[1]
            image_array = load_image(image_path, RGB=False).copy()
            data = (image_array, box_data[:, :4], box_data[:, 4:])
            image_array, box_corners, labels = self.transform(*data)
{'fraction_non_alphanumeric': 0.10448760884125921, 'fraction_numerical': 0.012056262558606833, 'mean_word_length': 2.930263157894737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '3197837', 'n_tokens_mistral': 982, 'n_tokens_neox': 921, 'n_words': 218}