datasci-rahul commited on
Commit
08ce356
1 Parent(s): c2aaa3d

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +49 -0
  2. application.py +39 -0
  3. classifyWaste.h5 +3 -0
  4. util.py +49 -0
  5. waste_classification.ipynb +0 -0
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Waste Management :india:
2
+
3
+ #### The world generates at least 3.5 million tons of waste per day and this number is still increasing day by day that's why we need to aware about waste.
4
+ #### This web application can classify waste with 9 different waste materials and it will show you the details of that particular waste materials. This will help to raise awareness for people to reduce and recycle waste.
5
+
6
+ ## Overview
7
+ - There are **LIGHT BLUBS, PAPER, PLASTIC, ORGANIC, GLASS, BATTERIES, CLOTHES, METAL, E-WASTE** total 9 different types of waste materials which are use for recycling.
8
+ - In this project i have collected and filtered data by my self from google images and dreamstime.com
9
+ - Here i have **8369 images** belonging **9 classes**.
10
+ - Here i have trained dataset using **VGG16** Transfer Learning technique of CNN for classification.
11
+ - Here i have trained this model till **28 epochs** and i got **69.77%** accuracy.
12
+ - Initially i had trained my model with **Inceptionv3** and it's gave me **90.34%** accuracy. But it was not accurate when i tested it on some images. But when i tested **VGG16** with **69.77%** accuracy it gives me accurate result.
13
+
14
+ ## Data Source
15
+ - In this project i have collected and filtered data by my self from google images and dreamstime.com
16
+ - I have uploaded my dataset on google drive.
17
+ - [click here to get dataset](https://drive.google.com/drive/folders/1I3nO4Z09VvrwCOJtWsxBvBZnhnw29Ypr?usp=sharing)
18
+
19
+
20
+
21
+ #### Here's simple steps to create an application on Elastic Bean Stalk
22
+ 1. Open the Elastic Beanstalk console using this link: https://console.aws.amazon.com/elasticbeanstalk/home#/gettingStarted?applicationName=getting-started-app
23
+ 2. Enter your application name.
24
+ 3. Application tags are optional so just ignore it.
25
+ 4. For Platform, choose a python platform.
26
+ 5. For Application code choose Upload your code.
27
+ 6. Upload a zip file of your project.
28
+ 7. Click on create application button.
29
+
30
+ - rest of the things will take care by aws elastic bean stalk and you will get deployed link.
31
+
32
+ ## Technologies Used
33
+ <code><img height="30" src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/python/python.png"></code>
34
+ <code><img height="30" src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/html/html.png"></code>
35
+ <code><img height="30" src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/css/css.png"></code>
36
+ <code><img height="30" src="https://raw.githubusercontent.com/numpy/numpy/7e7f4adab814b223f7f917369a72757cd28b10cb/branding/icons/numpylogo.svg"></code>
37
+ <code><img height="30" src="https://matplotlib.org/_static/logo2.svg"></code>
38
+ <code><img height="30" src="https://upload.wikimedia.org/wikipedia/commons/1/11/TensorFlowLogo.svg"></code>
39
+
40
+ ## Motivation
41
+ - My motivation watch is [here](https://www.youtube.com/watch?v=NhF4pXBNfq8)
42
+
43
+ ## Team
44
+ [![Rahul Sharma](https://github.com/datasci-rahul/personal/blob/main/DSC_0383-01.jpeg)](https://in.linkedin.com/in/datasci-rahul) |
45
+ -|
46
+ [Rahul Sharma](https://www.linkedin.com/in/datasci-rahul/) |)
47
+
48
+ ##
49
+ - If you like my work and it helped you in anyway then please do ⭐ the repository it will motivate me to make more amazing projects
application.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template, redirect, jsonify
2
+ from flask_jsglue import JSGlue # this is use for url_for() working inside javascript which is help us to navigate the url
3
+ import util
4
+ import os
5
+ from werkzeug.utils import secure_filename
6
+
7
+ application = Flask(__name__)
8
+
9
+ # JSGlue is use for url_for() working inside javascript which is help us to navigate the url
10
+ jsglue = JSGlue() # create a object of JsGlue
11
+ jsglue.init_app(application) # and assign the app as a init app to the instance of JsGlue
12
+
13
+ util.load_artifacts()
14
+ #home page
15
+ @application.route("/")
16
+ def home():
17
+ return render_template("home.html")
18
+
19
+ #classify waste
20
+ @application.route("/classifywaste", methods = ["POST"])
21
+ def classifywaste():
22
+ image_data = request.files["file"]
23
+ #save the image to upload
24
+ basepath = os.path.dirname(__file__)
25
+ image_path = os.path.join(basepath, "uploads", secure_filename(image_data.filename))
26
+ image_data.save(image_path)
27
+
28
+ predicted_value, details, video1, video2 = util.classify_waste(image_path)
29
+ os.remove(image_path)
30
+ return jsonify(predicted_value=predicted_value, details=details, video1=video1, video2=video2)
31
+
32
+ # here is route of 404 means page not found error
33
+ @application.errorhandler(404)
34
+ def page_not_found(e):
35
+ # here i created my own 404 page which will be redirect when 404 error occured in this web app
36
+ return render_template("404.html"), 404
37
+
38
+ if __name__ == "__main__":
39
+ application.run()
classifyWaste.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25a125ae36c90cf66426cf56175b0152507a94eb0d8d3a61f5f66e12de6caf15
3
+ size 61647696
util.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import numpy as np
3
+
4
+ model = None
5
+ output_class = ["Batteries", "Clothes", "E-waste", "Glass", "Light Blubs", "Metal", "Organic", "Paper", "Plastic"]
6
+ data = {
7
+ "Batteries":
8
+ ["Battery recycling is a recycling activity that aims to reduce the number of batteries being disposed as municipal solid waste. Batteries contain a number of heavy metals and toxic chemicals and disposing of them by the same process as regular household waste has raised concerns over soil contamination and water pollution.<br><br> Most types of batteries can be recycled. However, some batteries are recycled more readily than others, such as lead–acid automotive batteries (nearly 90% are recycled) and button cells (because of the value and toxicity of their chemicals). Rechargeable nickel–cadmium (Ni-Cd), nickel metal hydride (Ni-MH), lithium-ion (Li-ion) and nickel–zinc (Ni-Zn), can also be recycled. There is currently no cost-neutral recycling option available for disposable alkaline batteries, though consumer disposal guidelines vary by region.",
9
+ "4XOAGNzWvqY", "oKFOqMZmuA8"],
10
+ "Clothes":
11
+ ["Textile recycling is the process of recovering fiber, yarn or fabric and reprocessing the textile material into useful products. Textile waste products are gathered from different sources and are then sorted and processed depending on their condition, composition, and resale value. The end result of this processing can vary, from the production of energy and chemicals to new articles of clothing.<br><br>Due to a recent trend of over consumption and waste generation in global fashion culture, textile recycling has become a key focus of worldwide sustainability efforts. Globalization has led to a \"fast fashion\" trend where clothes are considered by many consumers to be disposable due to their increasingly lower prices. The development of recycled technology has allowed the textile industry to produce vast amounts of products that deplete natural resources.",
12
+ "Bhi7S06pwv4", "IHPBJySIXZw"],
13
+ "E-waste":
14
+ ["Electronic waste or e-waste describes discarded electrical or electronic devices. Used electronics which are destined for refurbishment, reuse, resale, salvage recycling through material recovery, or disposal are also considered e-waste. Informal processing of e-waste in developing countries can lead to adverse human health effects and environmental pollution.<br><br>Electronic scrap components, such as CPUs, contain potentially harmful materials such as lead, cadmium, beryllium, or brominated flame retardants. Recycling and disposal of e-waste may involve significant risk to health of workers and their communities.<br><br>E-waste or electronic waste is created when an electronic product is discarded after the end of its useful life. The rapid expansion of technology and the consumption driven society results in the creation of a very large amount of e-waste in every minute.",
15
+ "aUwFXDLOFO0","w0ikFMTuS9c"],
16
+ "Glass":
17
+ ["Glass recycling is the processing of waste glass into usable products. Glass that is crushed and ready to be remelted is called cullet. There are two types of cullet: internal and external. Internal cullet is composed of defective products detected and rejected by a quality control process during the industrial process of glass manufacturing, transition phases of product changes (such as thickness and colour changes) and production offcuts. External cullet is waste glass that has been collected or reprocessed with the purpose of recycling. External cullet (which can be pre- or post-consumer) is classified as waste. The word \"cullet\", when used in the context of end-of-waste, will always refer to external cullet.<br><br>To be recycled, glass waste needs to be purified and cleaned of contamination. Then, depending on the end use and local processing capabilities, it might also have to be separated into different colors. Many recyclers collect different colors of glass separately since glass retains its color after recycling.",
18
+ "bYVih298o1Y", "6R8YObQbE88"],
19
+ "Light Blubs":
20
+ ["Recycling prevents the release of hazardous materials into the environment. Mercury, an extremely toxic heavy metal, is used in fluorescent light bulbs to increase energy efficiency. In addition to mercury, some HID bulbs contain radioactive substances like Krypton-85 and thorium used for quick and easy light ignition.<br><br>LEDs on the other hand do not contain mercury; but, they do contain nickel, lead, and trace amounts of arsenic. Light bulbs often break when thrown into a dumpster, trash can or compactor, or when they end up in a landfill or incinerator. This causes the release of hazardous materials into the environment and can create serious public and environmental health concerns.<br><br>It’s also important to remember that recycling allows the reuse of the glass, metals and other materials that make up light bulbs. Virtually all components of light bulbs can be recycled.",
21
+ "GbE9C2tTW2k", "PkfX4sZwrQ4"],
22
+ "Metal":
23
+ ["Several kinds and also large amounts of metals are used in industrial processes every day. Since the industrial revolution period has taken place, our consumption levels skyrocketed due to the mass production of goods and the resulting low unit price.<br><br>The most consumed metal worldwide is aluminum, followed by copper, zinc, lead and nickel. Moreover, some precious materials like gold are used for our computers and other electronic devices.<br><br>Metal is therefore crucial to sustaining our living standard. However, metals are resources that are limited. The depletion of metals can be a big issue in the future since the world population grows rapidly and thus also the demand for goods made out of metal will increase.<br><br>To mitigate the problem of metal depletion, we have to look out for effective measures. One of those measures could be metal recycling.",
24
+ "qAGCI0-pQ3E", "rgEEXhbar3A"],
25
+ "Organic":
26
+ ["Organic wastes contain materials which originated from living organisms. There are many types of organic wastes and they can be found in municipal solid waste , industrial solid waste , agricultural waste, and wastewaters. Organic wastes are often disposed of with other wastes in landfills or incinerators, but since they are biodegradable , some organic wastes are suitable for composting and land application.<br><br>Organic materials found in municipal solid waste include food, paper, wood, sewage sludge , and yard waste. Because of recent shortages in landfill capacity, the number of municipal composting sites for yard wastes is increasing across the country, as is the number of citizens who compost yard wastes in their backyards. On a more limited basis, some mixed municipal waste composting is also taking place. In these systems, attempts to remove inorganic materials are made prior to composting.<br><br>Food waste from restaurants and grocery stores is typically disposed of through garbage disposals, therefore, it becomes a component of wastewater and sewage sludge.",
27
+ "lHyL41grGUo", "2I8Tjb4Fy-Q"],
28
+ "Paper":
29
+ ["The recycling of paper is the process by which waste paper is turned into new paper products. It has a number of important benefits: It saves waste paper from occupying homes of people and producing methane as it breaks down. Because paper fibre contains carbon (originally absorbed by the tree from which it was produced), recycling keeps the carbon locked up for longer and out of the atmosphere. Around two-thirds of all paper products in the US are now recovered and recycled, although it does not all become new paper. After repeated processing the fibres become too short for the production of new paper - this is why virgin fibre (from sustainably farmed trees) is frequently added to the pulp recipe.<br><br>Paper recycling pertains to the processes of reprocessing waste paper for reuse. Waste papers are either obtained from paper mill paper scraps, discarded paper materials, and waste paper material discarded after consumer use. Examples of the commonly known papers recycled are old newspapers and magazines.",
30
+ "jAqVxsEgWIM", "xhW0RTg8kRI"],
31
+ "Plastic":
32
+ ["Plastic recycling is the process of recovering scrap or waste plastic and reprocessing the material into useful products. Due to purposefully misleading symbols on plastic packaging and numerous technical hurdles, less than 10% of plastic has ever been recycled. Compared with the lucrative recycling of metal, and similar to the low value of glass recycling, plastic polymers recycling is often more challenging because of low density and low value.<br><br>Materials recovery facilities are responsible for sorting and processing plastics. As of 2019, due to limitations in their economic viability, these facilities have struggled to make a meaningful contribution to the plastic supply chain. The plastics industry has known since at least the 1970s that recycling of most plastics is unlikely because of these limitations. However, the industry has lobbied for the expansion of recycling while these companies have continued to increase the amount of virgin plastic being produced.",
33
+ "rYwBL_6hB2I", "I_fUpP-hq3A"]
34
+ }
35
+
36
+
37
+ def load_artifacts():
38
+ global model
39
+ model = tf.keras.models.load_model("classifyWaste.h5")
40
+
41
+ def classify_waste(image_path):
42
+ global model, output_class
43
+ test_image = tf.keras.preprocessing.image.load_img(image_path, target_size=(224, 224))
44
+ test_image = tf.keras.preprocessing.image.img_to_array(test_image) / 255
45
+ test_image = np.expand_dims(test_image, axis = 0)
46
+ predicted_array = model.predict(test_image)
47
+ predicted_value = output_class[np.argmax(predicted_array)]
48
+ return predicted_value, data[predicted_value][0], data[predicted_value][1], data[predicted_value][2]
49
+
waste_classification.ipynb ADDED
The diff for this file is too large to render. See raw diff