def __init__(self):
     stimuli = datasets.get_mit300()
     fixation_directory = os.path.dirname(MIT300_FIXATIONS)
     empirical_maps = pysaliency.SaliencyMapModelFromDirectory(
         stimuli, os.path.join(fixation_directory, 'FIXATIONMAPS'))
     super(MIT300Old, self).__init__(remove_doublicates=True,
                                     empirical_maps=empirical_maps)
예제 #2
0
def test_saliency_map_model_from_directory(file_stimuli,
                                           saliency_maps_in_directory):
    directory, predictions = saliency_maps_in_directory
    model = pysaliency.SaliencyMapModelFromDirectory(file_stimuli, directory)

    for stimulus_index, stimulus in enumerate(file_stimuli):
        expected = predictions[stimulus_index]
        actual = model.saliency_map(stimulus)
        np.testing.assert_equal(actual, expected)
 def __init__(self):
     stimuli = datasets.get_cat2000_test()
     fixation_directory = os.path.dirname(CAT2000_FIXATIONS)
     empirical_maps = pysaliency.SaliencyMapModelFromDirectory(
         stimuli,
         os.path.join(fixation_directory,
                      'ALIBORJI/TEST_DATA/FIXATIONMAPS'),
         caching=False)
     super(CAT2000Old, self).__init__(remove_doublicates=True,
                                      empirical_maps=empirical_maps)
예제 #4
0
def main(args):
    if len(args)!=5:
        print("Usage: score.py stimdir modeldir fixationfile goldstandarddir")
        return
    
    stimdir=args[1]
    modeldir=args[2]
    fixfile=args[3]
    goldstandarddir=args[4]
    # This expects a directory of pngs, jpgs, tiff, mats, or npys.
    # The stimulus list is given as a set of files.
    # More specifically, that set is given as a FileStimuli object
    stims=os.listdir(stimdir)
    # Assumption: we're dealing with an extracted norpix dataset or some such.
    sortedstims=[os.path.join(stimdir, s) for s in stims]
    stimuli=pysaliency.FileStimuli(sortedstims)
    #Further note: the number of model images must be equal to the number of stimuli. They must also se the same base naming convention (less file extensions) as said stimuli.
    print("Loading data into model...")
    model=pysaliency.SaliencyMapModelFromDirectory(stimuli, modeldir)
    
    print("Loading gold standard model...")
    goldstandard=pysaliency.SaliencyMapModelFromDirectory(stimuli, goldstandarddir)
    
    print("Reading fixations...")
    fixations=getFixations(fixfile)
    
    # To evaluate the model, we need to call one of the evaluation functions in the model itself.
    print("score:")
    print("AUC:")
    print(model.AUC(stimuli, fixations, nonfixations="uniform")) # nonfixations may also be "shuffled"
    print("Fixation based KL divergence:")
    print(model.fixation_based_KL_divergence(stimuli, fixations, nonfixations="uniform"))
    print("Image based KL divergence:")
    # TODO: consider setting the model parameter to false, since the passed gold standard *should* potentially be probabalistic.
    print(model.image_based_kl_divergence(stimuli, goldstandard))
    print("NSS:")
    print(model.NSS(stimuli, fixations))
import pysaliency
import datetime
from IPython import embed
dataset_location = 'datasets'
model_location = 'models'

start = datetime.datetime.now().replace(microsecond=0)
maps = pysaliency.external_datasets.get_SALICON(edition='2017',
                                                location=dataset_location)
saliency_maps = maps[1]
fixations_maps = maps[4]
print("The metrics are:")
embed()
my_model = pysaliency.SaliencyMapModelFromDirectory(
    saliency_maps, '/home/saliency_maps/salgan_salicon_baseline/')
auc = my_model.AUC(saliency_maps, fixations_maps)
print("AUC-JUDD is {}".format(auc))
# sauc = my_model.AUCs(saliency_maps, fixations_maps)
# print("AUC-SHUFFLED is {}".format(sauc))
nss = my_model.NSS(saliency_maps, fixations_maps)
print("NSS is {}".format(nss))
cc = my_model.CC(saliency_maps, my_model)
print("CC is {}".format(cc))
sim = my_model.SIM(saliency_maps, my_model)
print("SIM is {}".format(sim))

print("Time elapsed so far: {}".format(datetime.datetime.now().replace(
    microsecond=0) - start))