Kush1211 commited on
Commit
dfee2b3
·
verified ·
1 Parent(s): dede5fb

Upload 5 files

Browse files
Files changed (5) hide show
  1. fruits-vegetables-banner.jpg +0 -0
  2. labels.txt +36 -0
  3. main.py +77 -0
  4. style.css +33 -0
  5. trained_model.h5 +3 -0
fruits-vegetables-banner.jpg ADDED
labels.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apple
2
+ banana
3
+ beetroot
4
+ bell pepper
5
+ cabbage
6
+ capsicum
7
+ carrot
8
+ cauliflower
9
+ chilli pepper
10
+ corn
11
+ cucumber
12
+ eggplant
13
+ garlic
14
+ ginger
15
+ grapes
16
+ jalepeno
17
+ kiwi
18
+ lemon
19
+ lettuce
20
+ mango
21
+ onion
22
+ orange
23
+ paprika
24
+ pear
25
+ peas
26
+ pineapple
27
+ pomegranate
28
+ potato
29
+ raddish
30
+ soy beans
31
+ spinach
32
+ sweetcorn
33
+ sweetpotato
34
+ tomato
35
+ turnip
36
+ watermelon
main.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_option_menu import option_menu
3
+ import tensorflow as tf
4
+ import numpy as np
5
+
6
+ # Tensorflow Model Prediction
7
+ def model_prediction(test_image):
8
+ model = tf.keras.models.load_model("trained_model.h5")
9
+ image = tf.keras.preprocessing.image.load_img(
10
+ test_image, target_size=(64, 64))
11
+ input_arr = tf.keras.preprocessing.image.img_to_array(image)
12
+ input_arr = np.array([input_arr]) # convert single image to batch
13
+ predictions = model.predict(input_arr)
14
+ return np.argmax(predictions) # return index of max element
15
+
16
+ # Sidebar
17
+ # st.sidebar.title("Dashboard")
18
+ # app_mode = st.sidebar.selectbox("Select Page",["Home","About Project","Prediction"])
19
+
20
+
21
+ with open("style.css") as f:
22
+ st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
23
+
24
+ app_mode = option_menu(
25
+ menu_title=None,
26
+ options=["Home", "Prediction"],
27
+ icons=["house-door", "graph-up-arrow"],
28
+ orientation="horizontal",
29
+ styles={
30
+ "container": {
31
+ "padding": "0!important",
32
+ },
33
+ "icon": {
34
+ "font-size": "20px",
35
+ },
36
+ "nav-link": {
37
+ "font-size": "20px",
38
+ "margin": "0px",
39
+ "padding": "7px 0 7px 0",
40
+ },
41
+ "nav-link-selected": {
42
+ "font-weight": "100",
43
+ }
44
+ }
45
+ )
46
+
47
+ # Home Page
48
+ if app_mode == "Home":
49
+ st.header("Fruits & Vegetables Recognition System")
50
+ image_path = "fruits-vegetables-banner.jpg"
51
+ st.image(image_path)
52
+ st.subheader("About Project")
53
+ st.markdown("The Fruits and Vegetables Recognition System is an innovative project leveraging Convolutional Neural Networks (CNN) in deep learning to accurately identify and classify various fruits and vegetables. The system utilizes CNN architecture to extract features from input images, enabling accurate classification of fruits and vegetables.")
54
+ st.markdown(
55
+ "This Model is able to identify 36 different classes of Fruits and Vegetables.")
56
+ st.markdown(
57
+ "Fruits - banana, apple, pear, grapes, orange, kiwi, watermelon, pomegranate, pineapple, mango.")
58
+ st.markdown("Vegetables - cucumber, carrot, capsicum, onion, potato, lemon, tomato, raddish, beetroot, cabbage, lettuce, spinach, soy bean, cauliflower, bell pepper, chilli pepper, turnip, corn, sweetcorn, sweet potato, paprika, jalepeño, ginger, garlic, peas, eggplant.")
59
+
60
+ # Prediction Page
61
+ elif app_mode == "Prediction":
62
+ st.header("Model Prediction")
63
+ # reading labels
64
+ with open("labels.txt") as f:
65
+ content = f.readlines()
66
+ label = []
67
+ for i in content:
68
+ label.append(i[:-1])
69
+ test_image = st.file_uploader(
70
+ "Choose an Image:", type=["jpg", "jpeg", "png"])
71
+ if test_image:
72
+ st.image(test_image, width=2, use_column_width=True)
73
+ # predict button
74
+ if st.button("Predict"):
75
+ result_index = model_prediction(test_image)
76
+ st.subheader(f"Model Prediction: {label[result_index]}")
77
+
style.css ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ div.block-container.st-emotion-cache-1y4p8pa.ea3mdgi5
2
+ {
3
+ padding-top:30px;
4
+ }
5
+ section.main.st-emotion-cache-uf99v8.ea3mdgi8
6
+ {
7
+ padding-left:0px;
8
+ padding-right:0px;
9
+ }
10
+ h2
11
+ {
12
+ padding-bottom:30px;
13
+ padding-top:0px;
14
+ font-size:40px;
15
+ }
16
+ h3
17
+ {
18
+ font-size:30px;
19
+ }
20
+ p
21
+ {
22
+ font-size:18px;
23
+ }
24
+ @media(max-width:450px) {
25
+ h2
26
+ {
27
+ font-size:33px;
28
+ }
29
+ h3
30
+ {
31
+ font-size:27px;
32
+ }
33
+ }
trained_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37635af4c895434d4994d9450053f61631993d778feb8bb3011f53659494ad1b
3
+ size 79620032