Translator| ##I wonder if you have noticed that the data set may be the most overlooked part of the machine learning project. To most people, a dataset is nothing more than a collection of pre-made images that have been quickly put together or downloaded. In fact, datasets are the cornerstone of any image-based artificial intelligence (AI) project. For any machine learning project aiming to achieve high accuracy, creating and managing a balanced and well-structured dataset is crucial.
# However, creating a dataset is not as simple as collecting hundreds of images. When we try to start an AI project, we are likely to encounter various hidden dangers. Below, I'll discuss seven typical steps you can take to create your own dataset so you can gain insight into the importance of dataset size, possible data omissions, and converting a dataset into a database.
#Note: These steps will mainly apply to object detection and classification projects that include image datasets. Other project types, such as NLP
or graphics projects, require a different approach.Steps
1: Image size
Normally, neural networks can only process images of a specific size, and images exceeding a threshold will be forced to be reduced. This means that before using the dataset, we need to choose a suitable neural network and resize the image accordinglyAs you know, if the image Reducing the size may lead to a significant decrease in accuracy or even the disappearance of small objects on the image, thus causing damage to the entire recognition process. As shown below, you need to detect the license plate number in the image captured by the security camera, and the license plate only accounts for a small part of the entire image. Therefore, when the neural network shrinks the image, the license plate number may become too small to be recognized
As shown in the figure below, if you can understand the image sizes that the network can use, it will help you to crop the appropriate data set images.
##Although the image size that most neural networks can handle is relatively small, such as
are capable of processing larger resolution images. For example, Yolo v5x
s6
can handle images up to 1280 pixels wide image. Step 2: Understandyourenvironment
In order to ensure that the data set can accurately reflect the real images that the neural network needs to recognize during operation, we need to pay attention to the following factors when collecting the data set: Type of camera, smartphone camera or security camera
Image The size
- The location of the camera, whether it is indoors or outdoors
- Weather conditions , such as light, rain, fog, snow, etc.
- With a clear understanding of the real images the neural network is processing, we can create a data set that accurately reflects those of interest. objects, and their environment.
- Collecting common images from Google might be considered the easiest and fastest way to assemble a large dataset. However, this method is actually difficult to achieve high accuracy requirements. As shown below, images from Google or photo databases are often "beautified" compared to images captured by real cameras
A data set that is too "beautiful" is likely to lead to higher test accuracy. This means that the neural network will only perform well on test data (a collection of images purified from the dataset), but will perform poorly in real-world conditions and result in poor accuracy.
Step
3:
Format and Comments
Another important aspect we need to pay attention to is: the format of the image. Before starting your project, check which formats your chosen framework supports and whether your images can meet these requirements. Although the current framework can support multiple image formats, there are still problems with formats such as .jfif.
Annotation data can be used to specify bounding boxes, file names, and the different structures that can be used. Generally, different neural networks and frameworks require different annotation methods. Some require absolute coordinates containing the bounding box location, others require relative coordinates; some require each image to be accompanied by a separate annotated .txt file, while others require Some require only one file containing all comments. As you can see, even if your dataset has good images, it won't help if your framework can't handle the annotations.
Step 4: Training and validation subsets
For training purposes, the data set is usually divided into two subsets:
- Training subset- It is a set of images. The neural network will be trained on this set of images. Its proportion is 70% to 80% of the total number of images.
- Validation subset- are smaller images used to check how well the neural network learns during training set. Its proportion is between 20% and 30% of the total number of images.
Typically, a neural network will use object features extracted from a training subset to "learn" The appearance of an object. That is, after a training period (epoch), the neural network looks at the validation subset data and tries to guess what it can "Look " to those objects. Whether it is a correct or wrong guess, its structure allows the neural network to learn further.
While this method has been widely used and proven to achieve good results, we prefer to adopt a different approach that combines the data The set is divided into the following subsets:
- Training subset - accounts for ## of the total number of images # 70%
- Validation subset - Accounting for the total number of images 20%
- Test data set - Approx. 10%
Step
5: Datamissing
If you use If the data used to train a machine learning algorithm contains exactly the information you are trying to predict, a data breach may occur. As shown in the figure below, from an image recognition perspective, data leakage occurs when photos of the same object in the training and validation subsets are very similar. Obviously, missing data is extremely detrimental to the quality of neural networks.
##Essentially, after the model sees an image in the training data set, it first extracts its features, Then go into the validation dataset and find the exact same (or very similar) images you saw. Therefore, rather than saying that the model is actually learning, it is better to say that it is just memorizing various information. Sometimes this results in ridiculously high accuracy on the validation dataset (e.g., as high as
98%), but very low accuracy in production. One of the most commonly used data set segmentation methods is to randomly shuffle the data and then select the top
70% images are put into the training subset, and the remaining 30% are put into the validation subset. This method can easily lead to data omissions. As shown in the figure below, our immediate priority is to remove all "duplicate" photos from the dataset and check whether similar photos exist in both subsets.
For this, we can use a simple script to automatically perform duplicate deletion. Of course, you can adjust the duplication threshold, for example: only delete completely duplicate pictures, or pictures with a similarity as high as 90% , etc. In general, the more duplicate content is removed, the more accurate the neural network will produce.
Step 6: Large Data Set Database
If your data set is quite large, for example: more than 10million images, and has dozens For object classes and subclasses, we recommend that you create a simple database to store data set information. The reason behind this is actually very simple: with large data sets, it is difficult to keep track of all the data. Therefore, without some structured processing of the data, we will not be able to analyze it accurately.
Through the database, you can quickly diagnose the data set and find out that: too few pictures in a specific category will make it difficult for the neural network to recognize the object; The distribution of images between categories is not even enough; there are too many Google images in a specific category, resulting in a low accuracy score for that category, etc.
With a simple database, we can include the following information:
- ## File name
- File path
- Comment data
- Class data
- Data source (from production environment, Google, etc.)
- Object type, name and other object-related information
The database is indispensable for collecting data sets and statistical data Tool of. It helps us quickly and easily see how balanced the dataset is and how many high-quality images are in each category (from a neural network perspective). With data like the one visualized below, we can analyze it faster and compare it to the recognition results to find the root cause of poor accuracy
What needs to be re-written is: One issue worth noting is that the reason for the low accuracy may be due to a smaller number of images or a higher proportion of Google Photos in a certain category. By creating such a database, the time for production, testing and model retraining can be greatly reduced
Step 7 :Dataset Augmentation
As a technique used to increase the number of images, data augmentation is the simple or complex transformation of the data Processes, such as through flipping or style transformation, we can improve the validity of the data. The effective data set obtained based on this does not require excessive training. As shown in the image below, such data transformations can be as simple as simply rotating the image by 90 degrees, or as complex as adding solar flares to the image to simulate a backlit photo or lens Flare.
Typically, these enhanced conversions are automated. For example, we can prepare a Python library specifically for data augmentation. Currently, there are two types of data augmentation:
- Pre-training augmentation- At the beginning of the training process Previously, the data was augmented and added to the training subset. Of course, we can make such additions only after the data set has been divided into training and validation subsets to avoid the data omissions mentioned earlier.
- In-training enhancement- Use something similar to PyTorch The frame has built-in image transformation technology.
It is worth noting that increasing the size of the data set ten times does not make the neural network ten times more efficient. In fact, this may actually make the network perform worse than before. Therefore, we should only use enhancements that are relevant to production environments. For example, a camera installed in a building will not be exposed to rain when it is operating normally. So there is absolutely no need to add "rain" enhancement to the image.
小 knot
Although for those looking to apply AI to business, the dataset is The least exciting part. But it is undeniable that data sets are an important part of any image recognition project. Moreover, in most image recognition projects, the management and organization of data sets often takes a lot of time from the team. Finally, let’s summarize how you can get the best results from your AI projects by properly handling your datasets:
- Crop or adjust The size of the image to meet the requirements of the neural network
- #Collect real images based on weather and lighting conditions
- Construct annotations according to the requirements of the neural network
- Avoid using all images to train the network. A part needs to be reserved for testing
- Delete duplicate images in the validation data set to avoid data omission
- Create a database to quickly diagnose the data set
- Use data augmentation as little as possible to increase the number of images
Translator introduction
Julian Chen, 51CTO community editor, has more than ten years of IT experience Project implementation experience, good at managing and controlling internal and external resources and risks, and focusing on disseminating network and information security knowledge and experience.
Original title: 7 Steps To Prepare A Dataset For An Image-Based AI Project by Oleg Kokorin
The above is the detailed content of Seven Steps to Prepare Datasets for Image AI Projects. For more information, please follow other related articles on the PHP Chinese website!

Harness the Power of On-Device AI: Building a Personal Chatbot CLI In the recent past, the concept of a personal AI assistant seemed like science fiction. Imagine Alex, a tech enthusiast, dreaming of a smart, local AI companion—one that doesn't rely

Their inaugural launch of AI4MH took place on April 15, 2025, and luminary Dr. Tom Insel, M.D., famed psychiatrist and neuroscientist, served as the kick-off speaker. Dr. Insel is renowned for his outstanding work in mental health research and techno

"We want to ensure that the WNBA remains a space where everyone, players, fans and corporate partners, feel safe, valued and empowered," Engelbert stated, addressing what has become one of women's sports' most damaging challenges. The anno

Introduction Python excels as a programming language, particularly in data science and generative AI. Efficient data manipulation (storage, management, and access) is crucial when dealing with large datasets. We've previously covered numbers and st

Before diving in, an important caveat: AI performance is non-deterministic and highly use-case specific. In simpler terms, Your Mileage May Vary. Don't take this (or any other) article as the final word—instead, test these models on your own scenario

Building a Standout AI/ML Portfolio: A Guide for Beginners and Professionals Creating a compelling portfolio is crucial for securing roles in artificial intelligence (AI) and machine learning (ML). This guide provides advice for building a portfolio

The result? Burnout, inefficiency, and a widening gap between detection and action. None of this should come as a shock to anyone who works in cybersecurity. The promise of agentic AI has emerged as a potential turning point, though. This new class

Immediate Impact versus Long-Term Partnership? Two weeks ago OpenAI stepped forward with a powerful short-term offer, granting U.S. and Canadian college students free access to ChatGPT Plus through the end of May 2025. This tool includes GPT‑4o, an a


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use