@Override protected void setup(Context context) throws IOException, InterruptedException { indexer = VLADIndexerData.read(new File("./" + context.getConfiguration().get(VLAD_INDEXER_DATA_PATH_KEY))); }
@Override protected void setup(Context context) throws IOException, InterruptedException { indexer = VLADIndexerData.read(new File("vlad-data.bin")); mos = new MultipleOutputs<Text, BytesWritable>(context); }
public static void index() throws IOException { final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x-nohell.dat")); final List<IntObjectPair<float[]>> index = new ArrayList<IntObjectPair<float[]>>(); final List<IntObjectPair<float[]>> syncList = Collections.synchronizedList(index); Parallel.forEach(Arrays.asList(new File("/Users/jsh2/Data/ukbench/sift/").listFiles()), new Operation<File>() { @Override public void perform(File f) { try { System.out.println(f); final int id = Integer.parseInt(f.getName().replace("ukbench", "").replace(".jpg", "")); final MemoryLocalFeatureList<Keypoint> keys = MemoryLocalFeatureList.read(f, Keypoint.class); syncList.add(new IntObjectPair<float[]>(id, indexer.extractPcaVlad(keys))); } catch (final Exception e) { e.printStackTrace(); } } }); IOUtils.writeToFile(index, new File("/Users/jsh2/Desktop/ukb-nohell.idx")); }
public static void index() throws IOException { final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x-nohell.dat")); final List<IntObjectPair<float[]>> index = new ArrayList<IntObjectPair<float[]>>(); final List<IntObjectPair<float[]>> syncList = Collections.synchronizedList(index); Parallel.forEach(Arrays.asList(new File("/Users/jsh2/Data/ukbench/sift/").listFiles()), new Operation<File>() { @Override public void perform(File f) { try { System.out.println(f); final int id = Integer.parseInt(f.getName().replace("ukbench", "").replace(".jpg", "")); final MemoryLocalFeatureList<Keypoint> keys = MemoryLocalFeatureList.read(f, Keypoint.class); syncList.add(new IntObjectPair<float[]>(id, indexer.extractPcaVlad(keys))); } catch (final Exception e) { e.printStackTrace(); } } }); IOUtils.writeToFile(index, new File("/Users/jsh2/Desktop/ukb-nohell.idx")); }
public static void createPQADCNN() throws IOException { final File input = new File("/Volumes/My Book/flickr46m-vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x.dat"); final DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(input))); final VLADIndexerData indexer = VLADIndexerData.read(new File( "/Users/jsh2/vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x.dat")); final IncrementalFloatADCNearestNeighbours nn = new IncrementalFloatADCNearestNeighbours( indexer.getProductQuantiser(), 128, 46000000); final TLongArrayList indexes = new TLongArrayList(46000000); try { final float[] farr = new float[128]; for (int x = 0;; x++) { if (x % 100000 == 0) System.out.println(x); final long id = dis.readLong(); for (int i = 0; i < 128; i++) { farr[i] = dis.readFloat(); } nn.add(farr); indexes.add(id); } } catch (final EOFException e) { dis.close(); } IOUtils.writeBinary(new File( "/Volumes/My Book/flickr46m-vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x-pqadcnn.dat"), nn); IOUtils.writeToFile(indexes, new File( "/Volumes/My Book/flickr46m-vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x-pqadcnn-indexes.dat")); }
public static void createPQADCNN() throws IOException { final File input = new File("/Volumes/My Book/flickr46m-vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x.dat"); final DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(input))); final VLADIndexerData indexer = VLADIndexerData.read(new File( "/Users/jsh2/vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x.dat")); final IncrementalFloatADCNearestNeighbours nn = new IncrementalFloatADCNearestNeighbours( indexer.getProductQuantiser(), 128, 46000000); final TLongArrayList indexes = new TLongArrayList(46000000); try { final float[] farr = new float[128]; for (int x = 0;; x++) { if (x % 100000 == 0) System.out.println(x); final long id = dis.readLong(); for (int i = 0; i < 128; i++) { farr[i] = dis.readFloat(); } nn.add(farr); indexes.add(id); } } catch (final EOFException e) { dis.close(); } IOUtils.writeBinary(new File( "/Volumes/My Book/flickr46m-vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x-pqadcnn.dat"), nn); IOUtils.writeToFile(indexes, new File( "/Volumes/My Book/flickr46m-vlad64-pca128-pq16x8-indexer-mirflickr25k-sift1x-pqadcnn-indexes.dat")); }
public static void search() throws IOException { final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x-nohell.dat")); final List<IntObjectPair<float[]>> index = IOUtils.readFromFile(new
public static void search() throws IOException { final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x-nohell.dat")); final List<IntObjectPair<float[]>> index = IOUtils.readFromFile(new
final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x.dat"));
final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x.dat"));
public static void main(String[] args) throws IOException { final FImage image = ImageUtilities.readF(new File("/Users/jsh2/Data/ukbench/full/ukbench01001.jpg")); final DoGSIFTEngine engine = new DoGSIFTEngine(); engine.getOptions().setDoubleInitialImage(false); final LocalFeatureList<Keypoint> features = engine.findFeatures(image); final List<FloatKeypoint> fkeys = FloatKeypoint.convert(features); for (final FloatKeypoint k : fkeys) HellingerNormaliser.normalise(k.vector, 0); final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x.dat")); // final ByteCentroidsResult centroids = IOUtils.read(new // File("/Users/jsh2/Desktop/ukbench16.voc"), // ByteCentroidsResult.class); // final ExactByteAssigner assigner = new ExactByteAssigner(centroids); // final VLAD<byte[]> vlad = new VLAD<byte[]>(assigner, // centroids.centroids, true); // final MultidimensionalFloatFV agg = vlad.aggregate(features); final MultidimensionalFloatFV agg = indexer.getVLAD().aggregate(fkeys); System.out.println(agg); DisplayUtilities.display(VLAD.drawDescriptor(agg.values, 64, 4, 8)); } }
public static void main(String[] args) throws IOException { final FImage image = ImageUtilities.readF(new File("/Users/jsh2/Data/ukbench/full/ukbench01001.jpg")); final DoGSIFTEngine engine = new DoGSIFTEngine(); engine.getOptions().setDoubleInitialImage(false); final LocalFeatureList<Keypoint> features = engine.findFeatures(image); final List<FloatKeypoint> fkeys = FloatKeypoint.convert(features); for (final FloatKeypoint k : fkeys) HellingerNormaliser.normalise(k.vector, 0); final VLADIndexerData indexer = VLADIndexerData.read(new File("/Users/jsh2/vlad-indexer-ukbench-2x.dat")); // final ByteCentroidsResult centroids = IOUtils.read(new // File("/Users/jsh2/Desktop/ukbench16.voc"), // ByteCentroidsResult.class); // final ExactByteAssigner assigner = new ExactByteAssigner(centroids); // final VLAD<byte[]> vlad = new VLAD<byte[]>(assigner, // centroids.centroids, true); // final MultidimensionalFloatFV agg = vlad.aggregate(features); final MultidimensionalFloatFV agg = indexer.getVLAD().aggregate(fkeys); System.out.println(agg); DisplayUtilities.display(VLAD.drawDescriptor(agg.values, 64, 4, 8)); } }