<commit_before>#!/usr/bin/env python

import argparse
import os
import numpy as np
import sys
sys.path.insert(1, '.')
from vdetlib.utils.protocol import proto_load
from vdetlib.utils.cython_nms import nms
import multiprocessing as mp
import glob
import scipy.io as sio

def image_name_at_frame(vid_proto, frame_idx):
    vid_name = vid_proto['video']
    for frame in vid_proto['frames']:
        if frame['frame'] == frame_idx:
            return os.path.join(vid_name, os.path.splitext(frame['path'])[0])

def single_vid_raw_det_eval(input_list):
    vid_file, det_folder, image_set = input_list
    vid_proto = proto_load(vid_file)
    det_files = glob.glob(os.path.join(det_folder, '*.mat'))
    print vid_proto['video']

    # dets are [frame_idx, class_index, cls_score, x1, y1, x2, y2]
    dets = []
    for frame, det_file in zip(vid_proto['frames'], det_files):
        local_idx = frame['frame']
        try:
            det = sio.loadmat(det_file)
        except ValueError:
            print "det_file {} has been corrupted.".format(det_file)
            continue
        boxes = det['boxes']
        scores = det['zs']
        image_name = image_name_at_frame(vid_proto, local_idx)
        frame_idx = image_set[image_name]
        cur_dets = []
        for reg_boxes, cls_scores in zip(boxes, scores):
            for cls_index, (cls_bbox, cls_score) in \
                enumerate(zip(reg_boxes, cls_scores)):<commit_msg>Fix a bug in raw_det_evaluate.py.<commit_after>#!/usr/bin/env python

import argparse
import os
import numpy as np
import sys
sys.path.insert(1, '.')
from vdetlib.utils.protocol import proto_load
from vdetlib.utils.cython_nms import nms
import multiprocessing as mp
import glob
import scipy.io as sio

def image_name_at_frame(vid_proto, frame_idx):
    vid_name = vid_proto['video']
    for frame in vid_proto['frames']:
        if frame['frame'] == frame_idx:
            return os.path.join(vid_name, os.path.splitext(frame['path'])[0])

def single_vid_raw_det_eval(input_list):
    vid_file, det_folder, image_set = input_list
    vid_proto = proto_load(vid_file)
    print vid_proto['video']

    # dets are [frame_idx, class_index, cls_score, x1, y1, x2, y2]
    dets = []
    for frame in vid_proto['frames']:
        frame_name = os.path.splitext(frame['path'])[0]
        det_file = os.path.join(det_folder, "{}.mat".format(frame_name))
        local_idx = frame['frame']
        try:
            det = sio.loadmat(det_file)
        except ValueError:
            print "det_file {} has been corrupted.".format(det_file)
            continue
        boxes = det['boxes']
        scores = det['zs']
        image_name = image_name_at_frame(vid_proto, local_idx)
        frame_idx = image_set[image_name]
        cur_dets = []
        for reg_boxes, cls_scores in zip(boxes, scores):
            for cls_index, (cls_bbox, cls_score) in \
                enumerate(zip(reg_boxes, cls_scores)):
{'fraction_non_alphanumeric': 0.11179277436946149, 'fraction_numerical': 0.004430811179277437, 'mean_word_length': 3.0877437325905293, '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': '4607063', 'n_tokens_mistral': 1000, 'n_tokens_neox': 1002, 'n_words': 225}