Project summary: Target classification of 100 small images based on tensorflow

Task introduction: use the tensorflow==1.14.0 framework to complete the target classification task of 100 small images

Picture format: The picture collection is stored in the form of folders. Each folder contains a category of pictures, a total of 100 categories of pictures. The resolution of each category of pictures is different, and the number of pictures is different. Each category of pictures is stored in the form of .jpg;

1(1) pictures

Generate training set and test set: Traverse the above directory to extract files and divide each category according to the ratio of 7:3, generate the training set text folder and the verification set val folder, and put them in the split_image folder;

Generate txt file: traverse the training set and test set, generate training text.txt file and val.txt file, including image address + space + classification label;

Data preprocessing: Preprocessing the pictures to obtain the required input size of the deep learning model, and performing image enhancement operations during training, and further obtaining next_batch and init_op, etc.;

Model: Select the model structure and reproduce the relevant code

Define some ops: define hyperparameters, process model output results, etc.

Create session: run these ops

Some problems encountered:

The format of the generated txt file is wrong:

The image path can be changed from '\' to '/'

Pay attention to the space position

You can use WordPad to do some processing: replace and other operations

The epoch runs longer and longer:

Try not to include tf operations in the session, which will occupy memory and cause slower time

Learn to use debug:

Pay attention to the format switching between tensor and ndarray, and pay attention to the requirements of feed_dict. I use sess.run() to complete the format conversion. There should be a better way. Welcome to tell me in the comment area, thank you very much;

Pay attention to the position of the get_next() function during iteration. It needs to be called for each epoch, and it cannot be run only once, otherwise there will be a situation where only one epoch can be run;

Summarize

Since getting started with deep learning, this is my first actual deep learning project. Although it is only a target classification of 100 small images, I have gained a lot, such as a complete understanding of the process of achieving a target classification task. Preprocessing, function writing and calling, etc., conversion of various formats, etc. This task is not difficult, but the twists and turns may only be experienced by individuals. When I finally see that the program can run, I want to say that all the hard work is worth it Wait, I will further optimize this algorithm to make it faster and more accurate.

There are not many words in this blog, so let’s take it as a small summary of my past month, record my mood at this time, and hope that it will be better in the future. The code is because I wrote it as an intern in the company, so I can’t share it with you. Everyone If you have any questions, you can ask me in the comment area or discuss with you. You are also welcome to give me some guidance for this beginner who is just getting started. Thank you in advance!

Guess you like

Origin blog.csdn.net/panghuzhenbang/article/details/125141506