当前位置: 首页>>代码示例>>Java>>正文


Java IVFPQ类代码示例

本文整理汇总了Java中gr.iti.mklab.visual.datastructures.IVFPQ的典型用法代码示例。如果您正苦于以下问题:Java IVFPQ类的具体用法?Java IVFPQ怎么用?Java IVFPQ使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IVFPQ类属于gr.iti.mklab.visual.datastructures包,在下文中一共展示了IVFPQ类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: VisualIndex

import gr.iti.mklab.visual.datastructures.IVFPQ; //导入依赖的package包/类
public VisualIndex(String learningFolder, String indexFolder) throws Exception {
					
	int maximumNumVectors = 20000;

	int m = 128, k_c = 256, numCoarseCentroids = 8192;

	String[] codebookFiles = { 
		learningFolder + "surf_l2_128c_0.csv",
		learningFolder + "surf_l2_128c_1.csv", 
		learningFolder + "surf_l2_128c_2.csv",
		learningFolder + "surf_l2_128c_3.csv" 
	};
					
	String pcaFile = learningFolder + "pca_surf_4x128_32768to1024.txt";

	String coarseQuantizerFile = learningFolder + "qcoarse_1024d_8192k.csv";
	String productQuantizerFile = learningFolder + "pq_1024_128x8_rp_ivf_8192k.csv";

	ImageVectorization.setFeatureExtractor(new SURFExtractor());
	ImageVectorization.setVladAggregator(new VladAggregatorMultipleVocabularies(codebookFiles, numCentroids, AbstractFeatureExtractor.SURFLength));

	if (targetLengthMax < initialLength) {
		PCA pca = new PCA(targetLengthMax, 1, initialLength, true);
		pca.loadPCAFromFile(pcaFile);
		ImageVectorization.setPcaProjector(pca);
	}

	String linearIndexFolder = indexFolder + "/linear"; 
	String ivfpqIndexFolder = indexFolder + "/ivfpq"; 
	
	this.linearIndex = new Linear(targetLengthMax, maximumNumVectors, false, linearIndexFolder, true, true, 0);
	
	this.ivfpqIndex = new IVFPQ(targetLength, maximumNumVectors, false, ivfpqIndexFolder, m, k_c, PQ.TransformationType.RandomPermutation, numCoarseCentroids, true, 0);
	ivfpqIndex.loadCoarseQuantizer(coarseQuantizerFile);
	ivfpqIndex.loadProductQuantizer(productQuantizerFile);
	ivfpqIndex.setW(128); // how many (out of 8192) lists should be visited during search.
}
 
开发者ID:MKLab-ITI,项目名称:mgraph-summarization,代码行数:38,代码来源:VisualIndex.java

示例2: createIndex

import gr.iti.mklab.visual.datastructures.IVFPQ; //导入依赖的package包/类
public void createIndex(String name) throws Exception {
    //String ivfpqIndexFolder = "/home/kandreadou/webservice/reveal_indices/" + name + "_" + targetLengthMax;
    String ivfpqIndexFolder = "/home/iti-310/VisualIndex/data/"+name+"/ivfpq";
    File jeLck = new File(ivfpqIndexFolder, "je.lck");
    if (jeLck.exists()) {
        jeLck.delete();
    }
    else{
        jeLck.getParentFile().getParentFile().mkdirs();
    }

    int maximumNumVectors = 100000;
    int m2 = 64;
    int k_c = 256;
    int numCoarseCentroids = 8192;
    String coarseQuantizerFile2 = learningFolder + "qcoarse_1024d_8192k.csv";
    String productQuantizerFile2 = learningFolder + "pq_1024_64x8_rp_ivf_8192k.csv";

    IVFPQ index = new IVFPQ(targetLengthMax, maximumNumVectors, false, ivfpqIndexFolder, m2, k_c, PQ.TransformationType.RandomPermutation, numCoarseCentroids, true, 0);
    index.loadCoarseQuantizer(coarseQuantizerFile2);
    index.loadProductQuantizer(productQuantizerFile2);
    int w = 64; // larger values will improve results/increase seach time
    index.setW(w); // how many (out of 8192) lists should be visited during search.

    if (indices != null) {
        indices.put(name, index);
    }
}
 
开发者ID:kandreadou,项目名称:reveal-web-service,代码行数:29,代码来源:IndexingManager.java

示例3: index

import gr.iti.mklab.visual.datastructures.IVFPQ; //导入依赖的package包/类
public static void index(String directory, String linearIndexFolder, String ivfpqIndexFolder, String learningFolder) throws Exception {
	
	File dir = new File(directory);
	if(!dir.isDirectory())
		return;
	
	if(!learningFolder.endsWith("/"))
		learningFolder += "/";
	
	// parameters
	int maxNumPixels = 768 * 512;
	int[] numCentroids = { 128, 128, 128, 128 };
			
	int initialLength = numCentroids.length * numCentroids[0] * AbstractFeatureExtractor.SURFLength;
			
	int targetLengthMax = 1024;
	int targetLength = 1024;
			
	int maximumNumVectors = 20000;

	int m = 128, k_c = 256, numCoarseCentroids = 8192;

	String[] codebookFiles = { 
		learningFolder + "surf_l2_128c_0.csv",
		learningFolder + "surf_l2_128c_1.csv", 
		learningFolder + "surf_l2_128c_2.csv",
		learningFolder + "surf_l2_128c_3.csv" 
	};
			
	String pcaFile = learningFolder + "pca_surf_4x128_32768to1024.txt";

	String coarseQuantizerFile = learningFolder + "qcoarse_1024d_8192k.csv";
	String productQuantizerFile = learningFolder + "pq_1024_128x8_rp_ivf_8192k.csv";

	ImageVectorization.setFeatureExtractor(new SURFExtractor());
	ImageVectorization.setVladAggregator(new VladAggregatorMultipleVocabularies(codebookFiles,
					numCentroids, AbstractFeatureExtractor.SURFLength));

	if (targetLengthMax < initialLength) {
		PCA pca = new PCA(targetLengthMax, 1, initialLength, true);
		pca.loadPCAFromFile(pcaFile);
		ImageVectorization.setPcaProjector(pca);
	}

	Linear linear = new Linear(targetLengthMax, maximumNumVectors, false, linearIndexFolder, true, true, 0);
	IVFPQ ivfpq_1 = new IVFPQ(targetLength, maximumNumVectors, false, ivfpqIndexFolder, m, k_c, PQ.TransformationType.RandomPermutation, numCoarseCentroids, true, 0);
	ivfpq_1.loadCoarseQuantizer(coarseQuantizerFile);
	ivfpq_1.loadProductQuantizer(productQuantizerFile);
	ivfpq_1.setW(128); // how many (out of 8192) lists should be visited during search.
	
	for(String id : dir.list()) {
		System.out.println(id);
		
		ImageVectorization imvec = new ImageVectorization(dir.toString()+"/", id, targetLengthMax, maxNumPixels);
		
		ImageVectorizationResult imvr = imvec.call();
		double[] vector = imvr.getImageVector();
		
		// the full vector is indexed in the disk-based index
		linear.indexVector(id, vector);
		
		// the vector is truncated to the correct dimension and renormalized before sending to the ram-based index
		double[] newVector = Arrays.copyOf(vector, targetLength);
		if (newVector.length < vector.length) {
			Normalization.normalizeL2(newVector);
		}
		ivfpq_1.indexVector(id, newVector);
		
	}
	
}
 
开发者ID:MKLab-ITI,项目名称:mgraph-summarization,代码行数:72,代码来源:MultimediaHandler.java


注:本文中的gr.iti.mklab.visual.datastructures.IVFPQ类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。