• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ImageTransform类的典型用法和代码示例

java 1次浏览

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

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

示例1: CifarLoader

点赞 3

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
public CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train,
                boolean useSpecialPreProcessCifar, File fullDir, long seed, boolean shuffle) {
    super(height, width, channels, imgTransform);
    this.height = height;
    this.width = width;
    this.channels = channels;
    this.train = train;
    this.useSpecialPreProcessCifar = useSpecialPreProcessCifar;
    this.seed = seed;
    this.shuffle = shuffle;

    if (fullDir == null) {
        this.fullDir = getDefaultDirectory();
    } else {
        this.fullDir = fullDir;
    }
    meanVarPath = new File(this.fullDir, "meanVarPath.txt");
    trainFilesSerialized = FilenameUtils.concat(this.fullDir.toString(), "cifar_train_serialized");
    testFilesSerialized = FilenameUtils.concat(this.fullDir.toString(), "cifar_test_serialized.ser");

    load();
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:23,
代码来源:CifarLoader.java

示例2: convertCifar

点赞 3

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * Preprocess and store cifar based on successful Torch approach by Sergey Zagoruyko
 * Reference: https://github.com/szagoruyko/cifar.torch
 */
public opencv_core.Mat convertCifar(Mat orgImage) {
    numExamples++;
    Mat resImage = new Mat();
    OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
    //        ImageTransform yuvTransform = new ColorConversionTransform(new Random(seed), COLOR_BGR2Luv);
    //        ImageTransform histEqualization = new EqualizeHistTransform(new Random(seed), COLOR_BGR2Luv);
    ImageTransform yuvTransform = new ColorConversionTransform(new Random(seed), COLOR_BGR2YCrCb);
    ImageTransform histEqualization = new EqualizeHistTransform(new Random(seed), COLOR_BGR2YCrCb);

    if (converter != null) {
        ImageWritable writable = new ImageWritable(converter.convert(orgImage));
        // TODO determine if need to normalize y before transform - opencv docs rec but currently doing after
        writable = yuvTransform.transform(writable); // Converts to chrome color to help emphasize image objects
        writable = histEqualization.transform(writable); // Normalizes values to further clarify object of interest
        resImage = converter.convert(writable.getFrame());
    }

    return resImage;
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:24,
代码来源:CifarLoader.java

示例3: getRecordReader

点赞 3

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
@Override
public RecordReader getRecordReader(long rngSeed, int[] imgDim, DataSetType set, ImageTransform imageTransform) {
    try {
        Random rng = new Random(rngSeed);
        File datasetPath = getDataSetPath(set);

        FileSplit data = new FileSplit(datasetPath, BaseImageLoader.ALLOWED_FORMATS, rng);
        ObjectDetectionRecordReader recordReader = new ObjectDetectionRecordReader(imgDim[1], imgDim[0], imgDim[2],
                        imgDim[4], imgDim[3], null);

        recordReader.initialize(data);
        return recordReader;
    } catch (IOException e) {
        throw new RuntimeException("Could not download SVHN", e);
    }
}
 

开发者ID:deeplearning4j,
项目名称:deeplearning4j,
代码行数:17,
代码来源:SvhnDataFetcher.java

示例4: getTransforms

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
private static ImageTransform[] getTransforms() {
	ImageTransform randCrop = new CropImageTransform(new Random(), 10);
	ImageTransform warpTransform = new WarpImageTransform(new Random(), 42);
	ImageTransform flip = new FlipImageTransform(new Random());
	ImageTransform scale = new ScaleImageTransform(new Random(), 1);
	return new ImageTransform[] { randCrop, warpTransform, flip, scale };
}
 

开发者ID:jesuino,
项目名称:java-ml-projects,
代码行数:8,
代码来源:NNTrainingUsingZoo.java

示例5: convert

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
@Override
public INDArray convert(BufferedImage bufferedImage) {
    try {
        ImageTransform transform = imageTransformFactory.create();
        int height = imageTransformConfigurationResource.getScaledHeight();
        int width = imageTransformConfigurationResource.getScaledWidth();
        int channels = imageTransformConfigurationResource.getChannels();
        return new NativeImageLoader(height, width, channels, transform).asMatrix(bufferedImage);
    } catch (IOException ex) {
        throw new ImageProcessingException(ex);
    }
}
 

开发者ID:scaliby,
项目名称:ceidg-captcha,
代码行数:13,
代码来源:BufferedImageToINDArrayConverterImpl.java

示例6: create

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
@Override
public ImageTransform create() {
    int width = imageTransformConfigurationResource.getScaledWidth();
    int height = imageTransformConfigurationResource.getScaledHeight();
    return new MultiImageTransform(
            new RangeImageTransform(random),
            new NotImageTransform(random),
            new CropImageTransform(random),
            new ResizeImageTransform(random, width, height)
    );
}
 

开发者ID:scaliby,
项目名称:ceidg-captcha,
代码行数:12,
代码来源:ImageTransformFactoryImpl.java

示例7: createInternal

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
private DataSetIterator createInternal(InputSplit inputSplit) throws IOException {
    ImageTransform imageTransform = imageTransformFactory.create();
    int width = imageTransformConfigurationResource.getScaledWidth();
    int height = imageTransformConfigurationResource.getScaledHeight();
    int channels = imageTransformConfigurationResource.getChannels();
    int batchSize = networkConfigurationResource.getBatchSize();
    int outputs = networkConfigurationResource.getOutputs();
    ImageRecordReader recordReader = new ImageRecordReader(height, width, channels, pathLabelGenerator);
    recordReader.initialize(inputSplit, imageTransform);
    RecordReaderDataSetIterator recordReaderDataSetIterator = new RecordReaderDataSetIterator(recordReader, batchSize, 1, outputs);
    DataNormalization scaler = new ImagePreProcessingScaler(0, 1);
    scaler.fit(recordReaderDataSetIterator);
    recordReaderDataSetIterator.setPreProcessor(scaler);
    return recordReaderDataSetIterator;
}
 

开发者ID:scaliby,
项目名称:ceidg-captcha,
代码行数:16,
代码来源:DataSetIteratorFactoryImpl.java

示例8: BaseImageRecordReader

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
public BaseImageRecordReader(int height, int width, int channels, PathLabelGenerator labelGenerator,
                ImageTransform imageTransform) {
    this.height = height;
    this.width = width;
    this.channels = channels;
    this.labelGenerator = labelGenerator;
    this.imageTransform = imageTransform;
    this.appendLabel = labelGenerator != null ? true : false;
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:10,
代码来源:BaseImageRecordReader.java

示例9: LFWLoader

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
public LFWLoader(int[] imgDim, ImageTransform imgTransform, boolean useSubset) {
    this.height = imgDim[0];
    this.width = imgDim[1];
    this.channels = imgDim[2];
    this.imageTransform = imgTransform;
    this.useSubset = useSubset;
    this.localDir = useSubset ? localSubDir : localDir;
    this.fullDir = new File(BASE_DIR, localDir);
    generateLfwMaps();
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:11,
代码来源:LFWLoader.java

示例10: createImageTransformList

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
private List<ImageTransform> createImageTransformList() {
  // TODO: consider a bunch of opencv filter based transforms here!
  ImageTransform flipTransform1 = new FlipImageTransform(rng);
  ImageTransform flipTransform2 = new FlipImageTransform(new Random(123));
  ImageTransform warpTransform = new WarpImageTransform(rng, 42);
  List<ImageTransform> transforms = Arrays.asList(new ImageTransform[]{flipTransform1, warpTransform, flipTransform2});
  return transforms;
}
 

开发者ID:MyRobotLab,
项目名称:myrobotlab,
代码行数:9,
代码来源:Deeplearning4j.java

示例11: CifarDataSetIterator

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * Create Cifar data specific iterator
 *
 * @param batchSize      the batch size of the examples
 * @param imgDim         an array of height, width and channels
 * @param numExamples    the overall number of examples
 * @param imageTransform the transformation to apply to the images
 * @param useSpecialPreProcessCifar use Zagoruyko's preprocess for Cifar
 * @param train          true if use training set and false for test
 */
public CifarDataSetIterator(int batchSize, int numExamples, int[] imgDim, int numPossibleLables,
                ImageTransform imageTransform, boolean useSpecialPreProcessCifar, boolean train) {
    super(null, batchSize, 1, numExamples);
    this.loader = new CifarLoader(imgDim[0], imgDim[1], imgDim[2], imageTransform, train,
                    useSpecialPreProcessCifar);
    int totalExamples = train ? CifarLoader.NUM_TRAIN_IMAGES : CifarLoader.NUM_TEST_IMAGES;
    this.numExamples = numExamples > totalExamples ? totalExamples : numExamples;
    this.numPossibleLabels = numPossibleLables;
    this.imageTransform = imageTransform;
    this.useSpecialPreProcessCifar = useSpecialPreProcessCifar;
    this.train = train;
}
 

开发者ID:deeplearning4j,
项目名称:deeplearning4j,
代码行数:23,
代码来源:CifarDataSetIterator.java

示例12: ImageRecordReader

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/** Loads images with given height, width, and channels, appending labels returned by the generator. */
public ImageRecordReader(int height, int width, int channels, PathLabelGenerator labelGenerator,
                ImageTransform imageTransform) {
    super(height, width, channels, labelGenerator, imageTransform);
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:6,
代码来源:ImageRecordReader.java

示例13: AndroidNativeImageLoader

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
public AndroidNativeImageLoader(int height, int width, int channels, ImageTransform imageTransform) {
    super(height, width, channels, imageTransform);
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:4,
代码来源:AndroidNativeImageLoader.java

示例14: Java2DNativeImageLoader

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
public Java2DNativeImageLoader(int height, int width, int channels, ImageTransform imageTransform) {
    super(height, width, channels, imageTransform);
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:4,
代码来源:Java2DNativeImageLoader.java

示例15: getRecordReader

点赞 2

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
@Override
public CSVSequenceRecordReader getRecordReader(long rngSeed, int[] shape, DataSetType set, ImageTransform transform) {
    return getRecordReader(rngSeed, set);
}
 

开发者ID:deeplearning4j,
项目名称:deeplearning4j,
代码行数:5,
代码来源:UciSequenceDataFetcher.java

示例16: ObjectDetectionRecordReader

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * When imageTransform != null, object is removed if new center is outside of transformed image bounds.
 *
 * @param height        Height of the output images
 * @param width         Width of the output images
 * @param channels      Number of channels for the output images
 * @param gridH         Grid/quantization size (along  height dimension) - Y axis
 * @param gridW         Grid/quantization size (along  height dimension) - X axis
 * @param labelProvider ImageObjectLabelProvider - used to look up which objects are in each image
 * @param imageTransform ImageTransform - used to transform image and coordinates
 */
public ObjectDetectionRecordReader(int height, int width, int channels, int gridH, int gridW,
            ImageObjectLabelProvider labelProvider, ImageTransform imageTransform) {
    super(height, width, channels, null);
    this.gridW = gridW;
    this.gridH = gridH;
    this.labelProvider = labelProvider;
    this.appendLabel = labelProvider != null;
    this.imageTransform = imageTransform;
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:21,
代码来源:ObjectDetectionRecordReader.java

示例17: initialize

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * Called once at initialization.
 *
 * @param conf           a configuration for initialization
 * @param split          the split that defines the range of records to read
 * @param imageTransform the image transform to use to transform images while loading them
 * @throws java.io.IOException
 * @throws InterruptedException
 */
public void initialize(Configuration conf, InputSplit split, ImageTransform imageTransform)
                throws IOException, InterruptedException {
    this.imageLoader = null;
    this.imageTransform = imageTransform;
    initialize(conf, split);
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:16,
代码来源:BaseImageRecordReader.java

示例18: LFWDataSetIterator

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * Create LFW data specific iterator
 * @param batchSize the batch size of the examples
 * @param numExamples the overall number of examples
 * @param imgDim an array of height, width and channels
 * @param numLabels the overall number of examples
 * @param useSubset use a subset of the LFWDataSet
 * @param labelGenerator path label generator to use
 * @param train true if use train value
 * @param splitTrainTest the percentage to split data for train and remainder goes to test
 * @param imageTransform how to transform the image

 * @param rng random number to lock in batch shuffling
 * */
public LFWDataSetIterator(int batchSize, int numExamples, int[] imgDim, int numLabels, boolean useSubset,
                PathLabelGenerator labelGenerator, boolean train, double splitTrainTest,
                ImageTransform imageTransform, Random rng) {
    super(new LFWLoader(imgDim, imageTransform, useSubset).getRecordReader(batchSize, numExamples, imgDim,
                    numLabels, labelGenerator, train, splitTrainTest, rng), batchSize, 1, numLabels);
}
 

开发者ID:deeplearning4j,
项目名称:deeplearning4j,
代码行数:21,
代码来源:LFWDataSetIterator.java

示例19: NativeImageLoader

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * Instantiate an image with the given
 * height and width
 * @param height the height to load
 * @param width  the width to load
 * @param channels the number of channels for the image*
 * @param imageTransform to use before rescaling and converting
 */
public NativeImageLoader(int height, int width, int channels, ImageTransform imageTransform) {
    this(height, width, channels);
    this.imageTransform = imageTransform;
}
 

开发者ID:deeplearning4j,
项目名称:DataVec,
代码行数:13,
代码来源:NativeImageLoader.java

示例20: TinyImageNetDataSetIterator

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
/**
 * Get the Tiny ImageNet iterator with specified train/test set and custom transform.
 *
 * @param batchSize Size of each patch
 * @param imgDim Dimensions of desired output
 * @param set Train, test, or validation
 * @param imageTransform Additional image transform for output
 * @param rngSeed random number generator seed to use when shuffling examples
 */
public TinyImageNetDataSetIterator(int batchSize, int[] imgDim, DataSetType set,
                                   ImageTransform imageTransform, long rngSeed) {
    super(new TinyImageNetFetcher().getRecordReader(rngSeed, imgDim, set, imageTransform), batchSize, 1, TinyImageNetFetcher.NUM_LABELS);
}
 

开发者ID:deeplearning4j,
项目名称:deeplearning4j,
代码行数:14,
代码来源:TinyImageNetDataSetIterator.java

示例21: create

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
ImageTransform create(); 

开发者ID:scaliby,
项目名称:ceidg-captcha,
代码行数:2,
代码来源:ImageTransformFactory.java

示例22: getRecordReader

点赞 1

import org.datavec.image.transform.ImageTransform; //导入依赖的package包/类
public RecordReader getRecordReader(long rngSeed, int[] imgDim, DataSetType set, ImageTransform imageTransform); 

开发者ID:deeplearning4j,
项目名称:deeplearning4j,
代码行数:2,
代码来源:CacheableDataSet.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)