Exemplo n.º 1
0
def get_per_video_sift_data_old(split, subsample=1, nr_clusters=64, color=10):
    """ Loads the SIFT descriptors per video. `color` is a special flag; if it
    is set to 10 the descriptors are loaded unnormalized.

    """
    filename = ("/home/lear/oneata/tmp/trecvid11_sift/"
                "sift_per_video_%s_subsample%d_k%d_color%d.raw" % (
                    split, subsample, nr_clusters, color))

    if os.path.exists(filename):
        # Load data from cache file.
        print "Load per video data", filename
        with open(filename, "r") as ff:
            video_data = np.load(ff)
            video_labels = np.load(ff)
            video_names = cPickle.load(ff)
        return video_data, video_labels, video_names

    data, labels, limits = descriptors.load_dan_split(
        split, subsample, nr_clusters, color)
    # Get uniform weights within each video.
    weights = _normalize(np.ones_like(labels, dtype=np.float), limits, 'L1')
    # Load or compute data.
    video_data = aggregate(data, weights, limits)
    video_labels = np.array([labels[low] for low in limits[:-1]])
    video_names = descriptors.vid_names_dan_split(split)
    # Save data to file.
    with open(filename, "w") as ff:
        np.save(ff, video_data)
        np.save(ff, video_labels)
        cPickle.dump(video_names, ff)

    return video_data, video_labels, video_names
Exemplo n.º 2
0
 def test_aggregate_sstats(self):
     results = aggregate(self.sstats, self.norm_scores, self.limits)
     assert_allclose(results, self.aggregated_sstats)
Exemplo n.º 3
0
 def test_aggregate_sstats(self):
     results = aggregate(self.sstats, self.norm_scores, self.limits)
     assert_allclose(results, self.aggregated_sstats)