Dataset Crop simplifies the crucial step of preparing image datasets for machine learning applications. This tool is essential when you need to crop multiple images to a specific resolution and/or aspect ratio, especially focusing on particular areas such as faces or objects. Dataset Crop streamlines the manual preparation process, setting the stage for efficient batch processing.
- Batch Cropping: Easily crop multiple images to a specified resolution or aspect ratio.
- Focus Area Selection: Manually select areas of interest (e.g., faces, objects) for precise cropping.
- Preview Functionality: View downscaled versions of images for quick cropping adjustments.
- Draggable Crop Panels: Intuitive UI with draggable panels for manually selecting of areas of interest (e.g., faces, objects) for precise cropping.
- Aspect Ratio Preservation: Automatically adjust images to maintain the aspect ratio during the crop.
- Selection Toggle: easily select or deselect which images to crop or not.
- Original Encoding Preservation: The cropped images are saved using the same image format as the input images.
- Theme: Light and Dark theme support.
Dataset Crop was built using Avalonia UI, so it is cross-platform and can be run on Linux, Windows, macOS. The process varies slightly depending on the operating system.
- Make sure you have the .NET 9.0 runtime installed. The process can differ based on your particular distro.
- Open a terminal and navigate to the directory where the application is located.
- Run the application using this command:
dotnet DatasetCrop.dll
- Depending on your Linux distribution, you might need to install additional dependencies. For instance, if you encounter issues related to
libSkiaSharp
, you might need to install specific libraries likelibice6
,libsm6
, andlibfontconfig1
. These dependencies are required forSkiaSharp
, which is used by Avalonia for rendering. Example for Debian/Ubuntu:sudo apt install libice6 sudo apt install libsm6 sudo apt install libfontconfig1
- Navigate to the directory where the application is located.
- Double click the
DatasetCrop.exe
file to run the application.
- Launch the application.
- For the Input Path field, browse and select the directory containing your images dataset, or manually paste the path in the text box.
- Set the desired crop parameters:
- Use original scale sizes: whether to use the original images sizes or the preview panel sizes to express the cropping parameters. If this is checked, a value of 100 for Crop Width would literally mean 100 pixels of the original image. If it's unchecked, it would mean 100 pixels of the scaled down preview panel. Example: for an image of 1000x1000 pixels, with a preview panel of 100x100 pixels, specifying a cropping width of 50 would mean half of the preview panel (50 = 100 / 2), which would translate to 500 pixels of the original image (1000 / (100 / 2)). So, for short, this specifies whether to use "real life" pixels of the image, or the "scaled down" pixels of the preview, when cropping.
- Crop width, Crop height: the width and height of the crop area, based on whether to use original scale sizes or not.
- Crop X, Crop Y: the X and Y carthesian coordinates where the crop region should start, based on whether to use original scale sizes or not.
- Preview width, Preview height: the width and height of the preview panels for images.
- Press the Refresh button. At this moment, the previews of the images in the specified input directory will be displayed (or you will get a validation error, if some parameter is wrong).
- Use the preview pane to adjust crop areas on each image. They can be positioned with the mouse.
- Checking the Selection mode option and clicking on the crop area of images will toggle their "selected" state. This allows you to exclude images from the crop process. Excluded images will turn their crop area preview's background to a semi-transparent red.
- When defining invalid parameters (for example, when setting crop width to 100 pixels, but the image width is just 84 pixels), the preview panes will be disabled and their background set to a semi-transparent red. These images cannot be selected, and they will not be cropped.
- For the Output Path field, browse and select a directory where the cropped images will be saved, or manually paste the path in the text box.
- Execute the batch crop process by clicking the Crop button.
- The cropped images should be ready to be used in the training process. The input images are not modified in any way.
This software welcomes community contributions. All forms of input, be it code, bug reports, or feature suggestions, are appreciated.
The application's icon was taken from OnlineWebFonts. It is licensed under CC BY 4.0.
The application was built using Avalonia UI, for easy cross-platform deployment.
The library used for image processing is SixLabors ImageSharp.
I greatly appreciate the creators and contributors for providing these assets, packages and technologies.
This project is licensed under the GPLv3.0. See the LICENSE file for details.