<commit_before>from src.detection.deep.Convnet import Convnet
import unittest
import glob
from PIL import Image


class testConvnet(unittest.TestCase):
    def testInitialize_model_is_loaded(self):
        net = Convnet.from_verbose(False)
        net.initialize()
        self.assertTrue(net.is_initialized())
        self.assertIsNotNone(net.model)

    def test_predict(self):
        images = self.load_test_images()
        net = Convnet.from_verbose(False)
        net.initialize()
        result = net.predict_crosswalks(images)
        self.assertEquals(len(images), len(result))

    def test_to_numpy_array(self):
        net = Convnet.from_verbose(False)
        images = self.load_test_images()
        np_arr = net._to_numpy_array(images)
        should_shape = (len(images), 50, 50, 3)
        self.assertEquals(np_arr.shape, should_shape)

    def test_normalize(self):
        net = Convnet.from_verbose(False)
        images = self.load_test_images()
        np_arr = net._to_numpy_array(images)<commit_msg>Added threshold test<commit_after>from src.detection.deep.Convnet import Convnet
import unittest
import glob
from PIL import Image


class testConvnet(unittest.TestCase):
    def testInitialize_model_is_loaded(self):
        net = Convnet.from_verbose(False)
        net.initialize()
        self.assertTrue(net.is_initialized())
        self.assertIsNotNone(net.model)

    def test_predict(self):
        images = self.load_test_images()
        net = Convnet.from_verbose(False)
        net.initialize()
        result = net.predict_crosswalks(images)
        self.assertEquals(len(images), len(result), msg="Number of images is unequal number of results")

    def test_threshold(self):
        images = self.load_test_images()
        net = Convnet.from_verbose(False)
        net.initialize()
        net.threshold = -1
        results = net.predict_crosswalks(images)

        for res in results:
            self.assertEquals(res, True)

    def test_to_numpy_array(self):
        net = Convnet.from_verbose(False)
        images = self.load_test_images()
        np_arr = net._to_numpy_array(images)
        should_shape = (len(images), 50, 50, 3)
        self.assertEquals(np_arr.shape, should_shape)

    def test_normalize(self):
        net = Convnet.from_verbose(False)
        images = self.load_test_images()
        np_arr = net._to_numpy_array(images)
{'fraction_non_alphanumeric': 0.09527789385708316, 'fraction_numerical': 0.00459674049310489, 'mean_word_length': 3.023529411764706, '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': '6701653', 'n_tokens_mistral': 751, 'n_tokens_neox': 718, 'n_words': 136}