<jupyter_start><jupyter_text>1) Choose the tracker<jupyter_code>TRACKER = "hog" # ["mosse", "resnet", "mobilenet", "alexnet", "vgg16", "hog"]
device = "cuda:0" if torch.cuda.is_available() else "cpu"
if TRACKER == "mosse":
    tracker = MOSSETracker()
    squared = False
    bigger = True
elif TRACKER in ["resnet", "mobilenet", "alexnet", "vgg16", "hog"]:
    tracker = DCFMOSSETracker(dev = device, features = TRACKER)
    squared = True
    bigger = True
results = {}
for idx, seq in enumerate(dataset):
    print(f"----------------------------Evaluating video named {seq.sequence_name}----------------------------------")
    bboxes = []
    for frame_idx, frame in enumerate(seq):
        image_color = frame['image']
        if TRACKER == "mosse":
            image = np.sum(image_color, 2) / 3 # grayscale
        else:
            image = np.transpose(np.float64(image_color), (2, 0, 1))
        if frame_idx == 0:
            bbox = copy(frame['bounding_box'])
            aaaa = bbox
            if bbox.width % 2 == 0:
                bbox.width += 1
            if bbox.height % 2 == 0:
                bbox.height += 1
            roi = get_roi(bbox, squared = squared, bigger = bigger) # get roi slightly bigger that bbox
            tracker.start(image, bbox, roi) # first frame approach
        else:
            tracker.detect(image)
            tracker.update()
        bboxes.append(copy(tracker.bbox))
    ious = dataset.calculate_per_frame_iou(idx, bboxes)
    results[idx] = ious
result_file = f"../results/map/best_alexnet_2_layer.json"
with open(result_file, 'w') as fp:
    json.dump(results, fp)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1652542372881356, 'fraction_numerical': 0.012711864406779662, 'mean_word_length': 2.286282306163022, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '175679', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 572, 'n_tokens_neox': 539, 'n_words': 130, 'path': 'Module_2/code/results_map.ipynb', 'repo_name': 'tmralmeida/wasp-lfr-m2', 'size': '1652'}