Пример #1
0
		return self.images[i]
		
	def __len__(self):
		return len(self.images)
		
	def append(self, name, bow):
		self.images.append((name, bow))
		
	def top5Closest(self, bow):
		closest=sorted([(n, sp.distance.cosine(bow,b)) for (n,b) in self.images], key=lambda x:x[1])
		return closest[0:5]
	
	def __str__(self):
		s = ''
		for i in self:
			s += str(i[0]) + ' : ' + str(i[1]) + '\n'
		return s 
	
if __name__ == "__main__":
	print('Load library')
	lib = Library("SIFT")
	lib.loadLibrary("SIFTSaved")
	print('Load ok\nextract vector')
	vec = lib.extractVector(10)
	print('Create cluster')
	centroid = createCluster(vec, 1000)
	import pickle
	print('Save cluster')
	pickle.dump(centroid, open("Centroid_SIFT_1000_10", "wb"))
	print("BOW of ", lib.images[0][0], " is", image2BOW(centroid, lib.images[0][1][1]))
Пример #2
0
    def append(self, name, bow):
        self.images.append((name, bow))

    def top5Closest(self, bow):
        closest = sorted([(n, sp.distance.cosine(bow, b))
                          for (n, b) in self.images],
                         key=lambda x: x[1])
        return closest[0:5]

    def __str__(self):
        s = ''
        for i in self:
            s += str(i[0]) + ' : ' + str(i[1]) + '\n'
        return s


if __name__ == "__main__":
    print('Load library')
    lib = Library("SIFT")
    lib.loadLibrary("SIFTSaved")
    print('Load ok\nextract vector')
    vec = lib.extractVector(10)
    print('Create cluster')
    centroid = createCluster(vec, 1000)
    import pickle
    print('Save cluster')
    pickle.dump(centroid, open("Centroid_SIFT_1000_10", "wb"))
    print("BOW of ", lib.images[0][0], " is",
          image2BOW(centroid, lib.images[0][1][1]))
Пример #3
0
		# Security Group creation
		aws.createAllSG()
	elif sys.argv[1] == 'initKP':
		# Key pairs creation
		aws.createAllKP()
	else:
		print "Unknown operation !"
	sys.exit(1)
elif argc == 3:
	if sys.argv[1] == 'create':
		# Cluster creation
		cluster_name = sys.argv[2]
		stream = open('cassandgo.yaml','r')
		conf = yaml.load(stream)
		if cluster_name in conf:
			cluster.createCluster(conf[cluster_name],cluster_name)
		else:
			print cluster_name+' is not defined !'
	elif sys.argv[1] == 'destroy':
		# Cluster creation
		cluster_name = sys.argv[2]
		stream = open('cassandgo.yaml','r')
		conf = yaml.load(stream)
		if cluster_name in conf:
			cluster.destroyCluster(conf[cluster_name],cluster_name)
		else:
			print cluster_name+' is not defined !'

#for info in conf_HVM:
#	listInstancesRegionZone(info['region'],info['zone'])
#	ec2 = boto.ec2.connect_to_region(info['region']+'-'+info['zone'])
Пример #4
0
        # Security Group creation
        aws.createAllSG()
    elif sys.argv[1] == 'initKP':
        # Key pairs creation
        aws.createAllKP()
    else:
        print "Unknown operation !"
    sys.exit(1)
elif argc == 3:
    if sys.argv[1] == 'create':
        # Cluster creation
        cluster_name = sys.argv[2]
        stream = open('cassandgo.yaml', 'r')
        conf = yaml.load(stream)
        if cluster_name in conf:
            cluster.createCluster(conf[cluster_name], cluster_name)
        else:
            print cluster_name + ' is not defined !'
    elif sys.argv[1] == 'destroy':
        # Cluster creation
        cluster_name = sys.argv[2]
        stream = open('cassandgo.yaml', 'r')
        conf = yaml.load(stream)
        if cluster_name in conf:
            cluster.destroyCluster(conf[cluster_name], cluster_name)
        else:
            print cluster_name + ' is not defined !'

#for info in conf_HVM:
#	listInstancesRegionZone(info['region'],info['zone'])
#	ec2 = boto.ec2.connect_to_region(info['region']+'-'+info['zone'])