<commit_before>from vision import Box
from scipy.io import loadmat

def exemplarsvm(filename):
    data = loadmat(filename)
    data = data['ds']

    boxes = []

    for frame, detections in enumerate(data):
        detections = detections[0][0,0][0]
        for i in range(detections.shape[0]):
            d = detections[i,:]
            xtl = max(0, d[0])
            ytl = max(0, d[1])
            xbr = d[2]
            ybr = d[3]
            score = d[-1]
            boxes.append(Box(xtl, ytl, xbr, ybr, frame, score = score))
    return boxes

boxes = exemplarsvm('/csail/vision-videolabelme/databases/video_adapt/demos/bottle_table/pedro-pascal-bottle.mat')

print boxes[-1]<commit_msg>detection reader is a generator<commit_after>from vision import Box
from scipy.io import loadmat

def exemplarsvm(filename):
    data = loadmat(filename)
    data = data['ds']

    boxes = []

    for frame, detections in enumerate(data):
        detections = detections[0][0,0][0]
        for i in range(detections.shape[0]):
            d = detections[i,:]
            xtl = max(0, d[0])
            ytl = max(0, d[1])
            xbr = d[2]
            ybr = d[3]
            score = d[-1]
            yield Box(xtl, ytl, xbr, ybr, frame, score = score)

boxes = exemplarsvm('/csail/vision-videolabelme/databases/video_adapt/demos/bottle_table/pedro-pascal-bottle.mat')
print boxes.next()
{'fraction_non_alphanumeric': 0.13193943763518384, 'fraction_numerical': 0.01802451333813987, 'mean_word_length': 2.3853658536585365, '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': '6057696', 'n_tokens_mistral': 501, 'n_tokens_neox': 477, 'n_words': 108}