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


Java VFSGroupDataset类代码示例

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


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

示例1: getComponent

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final VFSGroupDataset<FImage> dataset = FaceDatasetProvider.getDataset();

	final FImage img = dataset.getRandomInstance().fill(0f);
	for (final FImage i : dataset) {
		img.addInplace(i);
	}
	img.divideInplace(dataset.numInstances()).processInplace(new ResizeProcessor(6.0f));

	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new GridBagLayout());

	final ImageComponent ic = new ImageComponent(true, false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setImage(ImageUtilities.createBufferedImageForDisplay(img));
	outer.add(ic);

	return outer;
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:26,代码来源:MeanFaceDemo.java

示例2: main

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
/**
	 *
	 *	@param args
	 * @throws IOException
	 */
	public static void main( final String[] args ) throws IOException
	{
		// Virtual file system for music speech corpus
		final GroupedDataset<String, ? extends ListDataset<List<SampleBuffer>>, List<SampleBuffer>>
			musicSpeechCorpus = new	VFSGroupDataset<List<SampleBuffer>>(
						"/data/music-speech-corpus/music-speech/wavfile/train",
						new OneSecondClipReader() );

		System.out.println( "Corpus size: "+musicSpeechCorpus.numInstances() );

		// Cross-validate the audio classifier trained on speech & music.
		final HashMap<String,String[]> regroup = new HashMap<String, String[]>();
		regroup.put( "speech", new String[]{ "speech" } );
		regroup.put( "non-speech", new String[]{ "music", "m+s", "other" } );
		AudioClassifierTest.crossValidate( DatasetAdaptors.getRegroupedDataset(
				musicSpeechCorpus, regroup ) );

//		// Create a new feature extractor for the sample buffer
//		final SamplesFeatureProvider extractor = new SamplesFeatureProvider();
//
//		// Create an SVM annotator
//		final SVMAnnotator<SampleBuffer,String> svm = new SVMAnnotator<SampleBuffer,String>( extractor );
//
//		AudioClassifier<String> ac = new AudioClassifier<String>( svm );
//
//		// Create the training data
//		final List<IndependentPair<AudioStream,String>> trainingData = new ArrayList<IndependentPair<AudioStream,String>>();
//		trainingData.add( new IndependentPair<AudioStream,String>( AudioDatasetHelper.getAudioStream(
//				musicSpeechCorpus.getInstances( "music" ) ), "non-speech" ) );
//		trainingData.add( new IndependentPair<AudioStream,String>( AudioDatasetHelper.getAudioStream(
//				musicSpeechCorpus.getInstances( "speech" ) ), "speech" ) );
//
//		// Train the classifier
//		ac.train( trainingData );
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:41,代码来源:AudioClassifierTest.java

示例3: getComponent

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final VFSGroupDataset<FImage> dataset = FaceDatasetProvider.getDataset();

	final EigenImages eigen = EigenFaceApproximationDemo.loadEigen(dataset, "eigenbasis.bin");

	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new GridBagLayout());

	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height - 50));
	base.setLayout(new FlowLayout());

	for (int i = 0; i < 60; i++) {
		final FImage img = eigen.visualisePC(i);
		final ImageComponent ic = new ImageComponent(true, false);
		ic.setAllowPanning(false);
		ic.setAllowZoom(false);
		ic.setShowPixelColours(false);
		ic.setShowXYPosition(false);
		ic.setImage(ImageUtilities.createBufferedImageForDisplay(img));
		base.add(ic);
	}
	outer.add(base);

	return outer;
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:31,代码来源:FacePrincipleComponentsDemo.java

示例4: getComponent

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final VFSGroupDataset<FImage> dataset = FaceDatasetProvider.getDataset();

	final FImage mean = dataset.getRandomInstance().fill(0f);
	for (final FImage i : dataset) {
		mean.addInplace(i);
	}
	mean.divideInplace(dataset.numInstances());

	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new GridBagLayout());

	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height - 50));
	base.setLayout(new FlowLayout());

	for (int i = 0; i < 60; i++) {
		final FImage img = dataset.getRandomInstance().subtract(mean).normalise();
		final ImageComponent ic = new ImageComponent(true, false);
		ic.setAllowPanning(false);
		ic.setAllowZoom(false);
		ic.setShowPixelColours(false);
		ic.setShowXYPosition(false);
		ic.setImage(ImageUtilities.createBufferedImageForDisplay(img));
		base.add(ic);
	}
	outer.add(base);

	return outer;
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:35,代码来源:MeanCenteredFacesDemo.java

示例5: getComponent

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final VFSGroupDataset<FImage> dataset = FaceDatasetProvider.getDataset();

	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new GridBagLayout());

	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height - 50));
	base.setLayout(new FlowLayout());

	for (int i = 0; i < 60; i++) {
		final FImage img = dataset.getRandomInstance();
		final ImageComponent ic = new ImageComponent(true, false);
		ic.setAllowPanning(false);
		ic.setAllowZoom(false);
		ic.setShowPixelColours(false);
		ic.setShowXYPosition(false);
		ic.setImage(ImageUtilities.createBufferedImageForDisplay(img));
		base.add(ic);
	}
	outer.add(base);

	return outer;
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:29,代码来源:FaceDatasetDemo.java

示例6: main

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
/**
 *	@param args
 * 	@throws FileSystemException
 */
public static void main( final String[] args ) throws FileSystemException
{
	// Use some images from a directory on the disk
	final VFSGroupDataset<MBFImage> i = new VFSGroupDataset<MBFImage>(
			"/data/faces/lfw", ImageUtilities.MBFIMAGE_READER );

	// Set up the diversity axis to plot thumbnail images.
	final ImageThumbnailPlotter itp = new ImageThumbnailPlotter();
	final DiversityAxis<MBFImage> dv = new DiversityAxis<MBFImage>( 1600, 800, itp )
	{
		/** */
		private static final long serialVersionUID = 1L;

		@Override
		public void bandSizeKnown( final int bandSize )
		{
			itp.setThumbnailSize( bandSize );
		}
	};
	dv.setDiversityAxisName( "Opinion" );

	int maxGroups = 10;
	int groupCount = 1;
	for( final String group: i.getGroups() )
	{
		for( final MBFImage img : i.get( group ) )
		{
			// Pretend we've found x number of duplicates for this image
			final int x = (int)(Math.random() * 3)+1;
			for( int j = 0; j < x; j++ )
			{
				// Mock-up an opinion value for each image
				final double opinionValue = (Math.random() - 0.5) * 2;

				// Add it to the diversity axis
				dv.addObject( groupCount, opinionValue, img );
			}

			groupCount++;

			// Let's not show too many groups
			maxGroups--;
			if( maxGroups == 0 ) break;
		}

		if( maxGroups == 0 ) break;
	}

	// Show the vis.
	dv.repaint();
	dv.showWindow( "Opinion VisualisationImpl" );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:57,代码来源:OpinionDiversityAxisVisExample.java

示例7: main

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
/**
 * Main method
 * 
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
	/**
	 * Build a dataset from images on disk
	 */
	final VFSListDataset<FImage> images = new VFSListDataset<FImage>("/images",
			ImageUtilities.FIMAGE_READER);
	System.out.println(images.size());
	DisplayUtilities.display(images.getRandomInstance(), "A random image from the dataset");
	DisplayUtilities.display("My images", images);

	/**
	 * Build a dataset from images in a zip file
	 */
	final VFSListDataset<FImage> faces = new VFSListDataset<FImage>("zip:http://datasets.openimaj.org/att_faces.zip",
			ImageUtilities.FIMAGE_READER);
	System.out.println(faces.size());
	DisplayUtilities.display("ATT faces", faces);

	/**
	 * Build a grouped dataset from images in directories in a zip file
	 */
	final VFSGroupDataset<FImage> groupedFaces = new VFSGroupDataset<FImage>(
			"zip:http://datasets.openimaj.org/att_faces.zip", ImageUtilities.FIMAGE_READER);
	for (final Entry<String, VFSListDataset<FImage>> entry : groupedFaces.entrySet()) {
		DisplayUtilities.display(entry.getKey(), entry.getValue());
	}

	/**
	 * Search for cats on Flickr
	 */
	final FlickrAPIToken flickrToken = DefaultTokenFactory.get(FlickrAPIToken.class);
	final FlickrImageDataset<FImage> cats = FlickrImageDataset.create(ImageUtilities.FIMAGE_READER, flickrToken,
			"cat", 10);
	DisplayUtilities.display("Cats", cats);

	/**
	 * Search for pics of Arnie on Bing
	 */
	final BingAPIToken bingToken = DefaultTokenFactory.get(BingAPIToken.class);
	final BingImageDataset<MBFImage> arnie = BingImageDataset.create(ImageUtilities.MBFIMAGE_READER, bingToken,
			"Arnold Schwarzenegger", 10);
	DisplayUtilities.display("Arnie", arnie);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:50,代码来源:App.java

示例8: main

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
/**
 * Main method
 * 
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
	/*
	 * Load the data, and create some training and test data
	 */
	final VFSGroupDataset<FImage> dataset =
			new VFSGroupDataset<FImage>("zip:http://datasets.openimaj.org/att_faces.zip",
					ImageUtilities.FIMAGE_READER);

	final GroupedRandomSplitter<String, FImage> splits = new GroupedRandomSplitter<String, FImage>(dataset, 5, 0, 5);
	final GroupedDataset<String, ListDataset<FImage>, FImage> training = splits.getTrainingDataset();
	final GroupedDataset<String, ListDataset<FImage>, FImage> testing = splits.getTestDataset();

	/*
	 * Configure recogniser
	 */
	final FaceAligner<DetectedFace> aligner = new IdentityAligner<DetectedFace>();
	final FaceDetector<DetectedFace, FImage> detector = new IdentityFaceDetector<FImage>();

	final EigenFaceRecogniser<DetectedFace, String> recogniser =
			EigenFaceRecogniser.create(100, aligner, 1, DoubleFVComparison.EUCLIDEAN);

	final FaceRecognitionEngine<DetectedFace, String> engine =
			new FaceRecognitionEngine<DetectedFace, String>(detector, recogniser);

	/*
	 * Train
	 */
	engine.train(training);

	/*
	 * Now we can test our performance on the test set
	 */
	double correct = 0, incorrect = 0;
	for (final String truePerson : testing.getGroups()) {
		for (final FImage face : testing.get(truePerson)) {
			System.out.println(engine.recogniseBest(face));
			final String bestPerson = engine.recogniseBest(face).get(0).secondObject().annotation;

			System.out.println("Actual: " + truePerson + "\tguess: " + bestPerson);

			if (truePerson.equals(bestPerson))
				correct++;
			else
				incorrect++;
		}
	}

	System.out.println("Accuracy: " + (correct / (correct + incorrect)));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:56,代码来源:App.java

示例9: getDataset

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
public static VFSGroupDataset<FImage> getDataset() throws FileSystemException {
	return new VFSGroupDataset<FImage>("zip:" + tmpFile.toURI(), ImageUtilities.FIMAGE_READER);
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:4,代码来源:FaceDatasetDemo.java

示例10: getComponent

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	// select random faces
	final VFSGroupDataset<FImage> dataset = FaceDatasetProvider.getDataset();
	for (int i = 0; i < faces.length; i++)
		faces[i] = dataset.getRandomInstance();

	// load basis
	eigen = loadEigen(dataset, "eigenbasis.bin");

	// setup display
	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new BoxLayout(outer, BoxLayout.Y_AXIS));

	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height - 50));
	base.setLayout(new FlowLayout());
	draw(10);
	createImageComponents(base);
	outer.add(base);

	final JPanel controls = new JPanel();
	controls.setOpaque(false);
	final JLabel label = new JLabel("Number of dimensions:");
	label.setFont(FONT);
	controls.add(label);

	final JTextField numDims = new JTextField(3);
	numDims.setFont(FONT);
	numDims.setEditable(false);
	numDims.setBorder(null);
	numDims.setText("10");

	final JSlider slider = new JSlider(0, eigen.getNumComponents(), 10);
	slider.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			final int nd = ((JSlider) e.getSource()).getValue();
			if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
				draw(nd);
				update();
			}
			numDims.setText(nd + "");
		}
	});
	controls.add(slider);
	controls.add(numDims);
	outer.add(controls);

	return outer;
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:55,代码来源:EigenFaceApproximationDemo.java

示例11: getImages

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
/**
 * Get a dataset of the Caltech 101 images. If the dataset hasn't been
 * downloaded, it will be fetched automatically and stored in the OpenIMAJ
 * data directory. The images in the dataset are grouped by their class.
 * 
 * @see DataUtils#getDataDirectory()
 * 
 * @param reader
 * @return a dataset of images
 * @throws IOException
 *             if a problem occurs loading the dataset
 */
public static <IMAGE extends Image<?, IMAGE>> VFSGroupDataset<IMAGE> getImages(InputStreamObjectReader<IMAGE> reader)
		throws IOException
{
	return new VFSGroupDataset<IMAGE>(downloadAndGetImagePath(), reader);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:Caltech101.java

示例12: getData

import org.openimaj.data.dataset.VFSGroupDataset; //导入依赖的package包/类
/**
 * Get a dataset of the Caltech 101 images and metadata. If the dataset
 * hasn't been downloaded, it will be fetched automatically and stored in
 * the OpenIMAJ data directory. The images in the dataset are grouped by
 * their class.
 * 
 * @see DataUtils#getDataDirectory()
 * 
 * @param reader
 *            a reader for reading images (usually a
 *            {@link ImageUtilities#FIMAGE_READER} or
 *            {@link ImageUtilities#MBFIMAGE_READER}).
 * @return a dataset of images and metadate
 * @throws IOException
 *             if a problem occurs loading the dataset
 */
public static <IMAGE extends Image<?, IMAGE>> VFSGroupDataset<Record<IMAGE>> getData(
		InputStreamObjectReader<IMAGE> reader) throws IOException
{
	return new VFSGroupDataset<Record<IMAGE>>(downloadAndGetImagePath(), new RecordReader<IMAGE>(reader));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:Caltech101.java


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