In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use Python to easily complete garbage sorting". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Train of thought
There may be more than one way to solve this problem. Here is just to throw a brick to attract jade, to provide some superficial insights.
In the first scheme, the junk information can be turned into tabulated data, and then the traditional machine learning method can be used.
In the second scheme, all the garbage classification information is made into a knowledge graph, and each query is like looking up the information in a dictionary.
The third scheme, with the help of the current deep learning method, to identify and classify garbage. Each time we give a picture of garbage, let the model identify which category it belongs to: dry garbage, wet garbage, hazardous waste or recyclable waste.
Image classification
Image classification is a classic application of deep learning. Its input is a picture, and then after some processing, into a deep learning model, the model will return the category of garbage in the image. Here we consider four categories: dry waste, wet waste, hazardous waste or recyclable waste.
We classify the objects in the picture, which is the field of image processing and recognition. In artificial intelligence, convolution neural network (Convolutional Neural Network, CNN) is proposed to solve this kind of problem.
I will use the keras package and the Tensorflow backend to build the model. Due to the temporary lack of samples of the training set, we can only give a set of ideas and code here. There is also a wave of data collection before training the model.
Let's first look at what the code looks like.
Import some necessary packages first.
Do the preparatory work again.
In the above, we initialized some variables, batch size is 128 position numb classes = 4, because the number of categories to be classified is 4, there are four categories: dry garbage, wet garbage, hazardous waste and recyclable garbage. Epochs is the number of times we have to train. Next, img_rows, img_cols = 28,28, we give the latitude of the picture.
In .reshape (6000pc28 channel 1), 60000 is the number of pictures (variable), 28 is the size of the picture (adjustable), and 1 means channel, and reshape = 1 refers to black and white photos. The same is true of reshape (10000pc28pr 28jp1), except that the number of pictures is 10000.
In the last two lines, we convert the value of our target variable into a binary, which is represented by a vector (matrix). For example, [1] refers to dry rubbish, [0] refers to wet garbage, and so on.
Next comes the part of modeling.
We added convolution layer and pooling layer into the model. Activation functions are relu,relu functions that are almost widely used in convolution neural networks and deep learning. We also add dropout between layers to reduce overfitting. Dense layer is used to make category predictions.
After building the model, we need to verify the model to ensure the accuracy online.
"how to use Python to easily complete garbage sorting" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.