public class ImageSetUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
IMAGE_IDX_FILE |
static String |
LABELS_FILE |
static String |
TEST_FILE |
static String |
TRAIN_FILE |
Constructor and Description |
---|
ImageSetUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
balanceUpsample(ImageSet imageSet,
Map<String,Integer> clazzStats)
Balance specified data set by adding random images of each class, to get equal number of examples for each class.
|
static ImageSet |
createDataSetFromRawImages(String sourcePath,
String targetPath,
int targetWidth,
int targetHeight,
boolean useAbsolutePaths)
Creates image data set from raw images by resizing and randomly croping to target dimensions.
|
static File |
createImageIndex(String path)
Creates an index file with list of all files in all subdirectories and write them into single index.txt file.
|
static void |
createLabelsIndex(String path)
Creates a file with list of labels/categories from subdirectories at the specified given path.
|
static void |
createRandomlyCroppedImages(String srcPath,
String destPath,
int targetWidth,
int targetHeight,
int num) |
static File |
createSubSampledImageIndex(String srcDir,
String targetFileName,
int samplesPerClass,
boolean useFullPath)
Copies specified number of samples of each class from
|
static List<String> |
labelsFromSubDirectories(String path)
Returns a list of category/class labels from the names of subdirectories for the given path.
|
static void |
renameFilesAsClasses(String srcPath,
String className)
Renames files in specified directory.
|
static void |
writeToFile(List<String> list,
String fileName)
Writes a given list of strings to file.
|
public static final String LABELS_FILE
public static final String TRAIN_FILE
public static final String TEST_FILE
public static final String IMAGE_IDX_FILE
public static ImageSet createDataSetFromRawImages(String sourcePath, String targetPath, int targetWidth, int targetHeight, boolean useAbsolutePaths) throws IOException
sourcePath
- targetPath
- targetWidth
- targetHeight
- useAbsolutePaths
- IOException
public static void createRandomlyCroppedImages(String srcPath, String destPath, int targetWidth, int targetHeight, int num) throws IOException
IOException
public static List<String> labelsFromSubDirectories(String path)
path
- path to search for subirectoriespublic static void writeToFile(List<String> list, String fileName) throws IOException
list
- a list of strings to write to filefileName
- name of the file to write toIOException
public static void createLabelsIndex(String path) throws IOException
path
- path to directory which contains image categories/classesIOException
public static File createImageIndex(String path) throws IOException
path
- directory path to indexIOException
public static void balanceUpsample(ImageSet imageSet, Map<String,Integer> clazzStats)
imageSet
- imageSet to balanceclazzStats
- number of each classpublic static void renameFilesAsClasses(String srcPath, String className) throws FileNotFoundException
srcPath
- className
- FileNotFoundException
public static File createSubSampledImageIndex(String srcDir, String targetFileName, int samplesPerClass, boolean useFullPath) throws IOException
srcDir
- targetFileName
- samplesPerClass
- useFullPath
- IOException
Copyright © 2022. All rights reserved.