<commit_before>import numpy as _np


try:
    import cv2 as _cv2

    def imread(fname, dtype=_np.float32):
        im = _cv2.imread(fname, flags=_cv2.IMREAD_UNCHANGED)
        if im is None:
            raise IOError("Couldn't open image file {}".format(fname))
        return im.astype(dtype)

    def imresize(im, h, w):
        if im.shape[:2] == (h, w):
            return im
<commit_msg>Load images as RGB using OpenCV too. Fixes #78<commit_after>import numpy as _np


try:
    import cv2 as _cv2

    def imread(fname, dtype=_np.float32):
        im = _cv2.imread(fname, flags=_cv2.IMREAD_UNCHANGED)
        if im is None:
            raise IOError("Couldn't open image file {}".format(fname))
        # Convert BGR to RGB. OpenCV is weird like that.
        if im.ndim == 3 and im.shape[-1] == 3:
            im = im[:,:,::-1]
        return im.astype(dtype)

    def imresize(im, h, w):
        if im.shape[:2] == (h, w):
            return im

{'fraction_non_alphanumeric': 0.12277019937040923, 'fraction_numerical': 0.02098635886673662, 'mean_word_length': 2.190635451505017, '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': '2734983', 'n_tokens_mistral': 349, 'n_tokens_neox': 340, 'n_words': 99}