prj2106 commited on
Commit
b7f9508
1 Parent(s): d3b8910

Upload 5 files

Browse files
Files changed (5) hide show
  1. about.py +12 -0
  2. acc.py +177 -0
  3. home.py +53 -0
  4. pdd-project-2c531-9f12df2c0e46.json +13 -0
  5. pdd.py +92 -0
about.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def app():
4
+ st.subheader('This is a website created for users to:')
5
+ st.subheader('Detect disease of the plants and provide measure against it')
6
+ st.markdown('Tomato cultivation plays a crucial role in global agriculture, but its productivity is often threatened by various diseases. Early detection of these diseases is essential for timely intervention and mitigation. his study proposes an automated approach for the detection of tomato plant diseases using machine learning techniques. Firstly, a comprehensive dataset comprising images of healthy tomato plants and plants infected with common diseases such as early blight, late blight, and leaf mold is compiled. Preprocessing techniques including image enhancement and augmentation are applied to improve the quality and diversity of the dataset. Subsequently, a convolutional neural network (CNN) architecture is designed and trained on the dataset to classify the images into healthy or diseased categories. The performance of the proposed model is evaluated using various metrics such as accuracy, precision, recall, and F1-score. Additionally, transfer learning techniques are explored to enhance the model performance with limited training data. Experimental results demonstrate the effectiveness of the proposed approach in accurately identifying tomato plant diseases, thus providing a valuable tool for farmers and agricultural experts to monitor and manage crop health efficiently. This research contributes to the advancement of precision agriculture and promotes sustainable farming practices by facilitating early disease detection and intervention in tomato cultivation.')
7
+ st.subheader('Detect disease of the plants and provide measure against it')
8
+ st.markdown('CREATED BY: Parth, Mansi, Sabah')
9
+ st.markdown('Contact via mail: [jaiswalparth32@gmail.com]')
10
+
11
+
12
+
acc.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import firebase_admin
3
+ from firebase_admin import firestore
4
+ from firebase_admin import credentials
5
+ from firebase_admin import auth
6
+ import json
7
+ import requests
8
+
9
+
10
+ cred = credentials.Certificate("pdd-project-2c531-9f12df2c0e46.json")
11
+ firebase_admin.initialize_app(cred)
12
+ def app():
13
+ Username = []
14
+ st.title('Welcome to :violet[PDD] :sunglasses:')
15
+
16
+ if 'username' not in st.session_state:
17
+ st.session_state.username = ''
18
+ if 'useremail' not in st.session_state:
19
+ st.session_state.useremail = ''
20
+
21
+
22
+ def sign_up_with_email_and_password(email, password, username=None, return_secure_token=True):
23
+ try:
24
+ rest_api_url = "https://identitytoolkit.googleapis.com/v1/accounts:signUp"
25
+ payload = {
26
+ "email": email,
27
+ "password": password,
28
+ "returnSecureToken": return_secure_token
29
+ }
30
+ if username:
31
+ payload["displayName"] = username
32
+ payload = json.dumps(payload)
33
+ r = requests.post(rest_api_url, params={"key": "AIzaSyBeEqIwmjBzXKEGS5nQ7NbRCX-X5Cas2So"}, data=payload)
34
+ try:
35
+ return r.json()['email']
36
+ except:
37
+ st.warning(r.json())
38
+ except Exception as e:
39
+ st.warning(f'Signup failed: {e}')
40
+
41
+ def sign_in_with_email_and_password(email=None, password=None, return_secure_token=True):
42
+ rest_api_url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword"
43
+
44
+ try:
45
+ payload = {
46
+ "returnSecureToken": return_secure_token
47
+ }
48
+ if email:
49
+ payload["email"] = email
50
+ if password:
51
+ payload["password"] = password
52
+ payload = json.dumps(payload)
53
+ print('payload sigin',payload)
54
+ r = requests.post(rest_api_url, params={"key": " AIzaSyBeEqIwmjBzXKEGS5nQ7NbRCX-X5Cas2So"}, data=payload)
55
+ try:
56
+ data = r.json()
57
+ user_info = {
58
+ 'email': data['email'],
59
+ 'username': data.get('displayName') # Retrieve username if available
60
+ }
61
+ return user_info
62
+ except:
63
+ st.warning(data)
64
+ except Exception as e:
65
+ st.warning(f'Signin failed: {e}')
66
+
67
+ def reset_password(email):
68
+ try:
69
+ rest_api_url = "https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode"
70
+ payload = {
71
+ "email": email,
72
+ "requestType": "PASSWORD_RESET"
73
+ }
74
+ payload = json.dumps(payload)
75
+ r = requests.post(rest_api_url, params={"key": "AIzaSyBeEqIwmjBzXKEGS5nQ7NbRCX-X5Cas2So"}, data=payload)
76
+ if r.status_code == 200:
77
+ return True, "Reset email Sent"
78
+ else:
79
+ # Handle error response
80
+ error_message = r.json().get('error', {}).get('message')
81
+ return False, error_message
82
+ except Exception as e:
83
+ return False, str(e)
84
+
85
+ # Example usage
86
+ # email = "example@example.com"
87
+
88
+
89
+ def f():
90
+ try:
91
+ # user = auth.get_user_by_email(email)
92
+ # print(user.uid)
93
+ # st.session_state.username = user.uid
94
+ # st.session_state.useremail = user.email
95
+
96
+ userinfo = sign_in_with_email_and_password(st.session_state.email_input,st.session_state.password_input)
97
+ st.session_state.username = userinfo['username']
98
+ st.session_state.useremail = userinfo['email']
99
+
100
+
101
+ global Usernm
102
+ Usernm=(userinfo['username'])
103
+
104
+ st.session_state.signedout = True
105
+ st.session_state.signout = True
106
+
107
+
108
+ except:
109
+ st.warning('Login Failed')
110
+
111
+ def t():
112
+ st.session_state.signout = False
113
+ st.session_state.signedout = False
114
+ st.session_state.username = ''
115
+
116
+
117
+ def forget():
118
+ email = st.text_input('Email')
119
+ if st.button('Send Reset Link'):
120
+ print(email)
121
+ success, message = reset_password(email)
122
+ if success:
123
+ st.success("Password reset email sent successfully.")
124
+ else:
125
+ st.warning(f"Password reset failed: {message}")
126
+
127
+
128
+
129
+ if "signedout" not in st.session_state:
130
+ st.session_state["signedout"] = False
131
+ if 'signout' not in st.session_state:
132
+ st.session_state['signout'] = False
133
+
134
+
135
+
136
+
137
+ if not st.session_state["signedout"]: # only show if the state is False, hence the button has never been clicked
138
+ choice = st.selectbox('Login/Signup',['Login','Sign up'])
139
+ email = st.text_input('Email Address')
140
+ password = st.text_input('Password',type='password')
141
+ st.session_state.email_input = email
142
+ st.session_state.password_input = password
143
+
144
+
145
+
146
+
147
+ if choice == 'Sign up':
148
+ username = st.text_input("Enter your unique username")
149
+
150
+ if st.button('Create my account'):
151
+ # user = auth.create_user(email = email, password = password,uid=username)
152
+ user = sign_up_with_email_and_password(email=email,password=password,username=username)
153
+
154
+ st.success('Account created successfully!')
155
+ st.markdown('Please Login using your email and password')
156
+ st.balloons()
157
+ else:
158
+ # st.button('Login', on_click=f)
159
+ st.button('Login', on_click=f)
160
+ # if st.button('Forget'):
161
+ forget()
162
+ # st.button('Forget',on_click=forget)
163
+
164
+
165
+
166
+ if st.session_state.signout:
167
+ st.text('Name '+st.session_state.username)
168
+ st.text('Email id: '+st.session_state.useremail)
169
+ st.button('Sign out', on_click=t)
170
+
171
+
172
+
173
+
174
+
175
+ def ap():
176
+ st.write('Posts')
177
+
home.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from firebase_admin import firestore
3
+
4
+ def app():
5
+
6
+ if 'db' not in st.session_state:
7
+ st.session_state.db = ''
8
+
9
+ db=firestore.client()
10
+ st.session_state.db=db
11
+ # st.title(' :violet[disease detection] :sunglasses:')
12
+
13
+ ph = ''
14
+ if st.session_state.username=='':
15
+ ph = 'Login to be able to post!!'
16
+ else:
17
+ ph='Post your comments'
18
+ post=st.text_area(label=' :orange[+ COMMENTS]',placeholder=ph,height=None, max_chars=500)
19
+ if st.button('Post',use_container_width=20):
20
+ if post!='':
21
+
22
+ info = db.collection('Posts').document(st.session_state.username).get()
23
+ if info.exists:
24
+ info = info.to_dict()
25
+ if 'Content' in info.keys():
26
+
27
+ pos=db.collection('Posts').document(st.session_state.username)
28
+ pos.update({u'Content': firestore.ArrayUnion([u'{}'.format(post)])})
29
+ # st.write('Post uploaded!!')
30
+ else:
31
+
32
+ data={"Content":[post],'Username':st.session_state.username}
33
+ db.collection('Posts').document(st.session_state.username).set(data)
34
+ else:
35
+
36
+ data={"Content":[post],'Username':st.session_state.username}
37
+ db.collection('Posts').document(st.session_state.username).set(data)
38
+
39
+ st.success('Comment uploaded!!')
40
+
41
+ st.header(' :violet[Latest Posts] ')
42
+
43
+
44
+
45
+
46
+ docs = db.collection('Posts').get()
47
+
48
+ for doc in docs:
49
+ d=doc.to_dict()
50
+ try:
51
+ st.text_area(label=':green[Posted by:] '+':orange[{}]'.format(d['Username']),value=d['Content'][-1],height=20)
52
+ except: pass
53
+
pdd-project-2c531-9f12df2c0e46.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "pdd-project-2c531",
4
+ "private_key_id": "9f12df2c0e463cef406104459c03b689c8b1bb5f",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC2XB329O0mXg5q\n74wXjxlGmVffmfoOy5UDAMZaS5YIuctBl5Tpign8/3q27WVpmv+7ZYBoAfN5TOTt\nXQ1eP0+dAzryuV/8Rovri105OprEdyEEXW15Tzn/H/Y7TBFvtMlHBSTV+1HHHrrx\niMClfkHcEL4lSBmbdFuWRp2TtOtorW/g6A8bsXqbVyD/6hekwLHqqczJSEqWicBL\n/pHGUMyC1Ks3DRrkWlukHpqcKeISLw1BmmnwS/BxoowE7F9/aYyCrl4XCFdoyOpa\n49Qx9ct7mExD1rBTXqwO3wXJDVNwUu5z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gzV/YqMga\nRZaomBN/P8/jnhGLq59ijW9eDjxIA5Vizhl9gFBRAoGBANa71Gk8VD0CUoHTi264\nH3w0cjbiKFEG7K0ZUjFu7hmeKORH7nMNMpqbAKs3TZJysxduf/D37wLkmBzig3tl\nRE3LRFSDVaskcJFc9PQxsAVKtxZfyXFE5mBmRmecQNqBhqKIVG6B/OXyJLg7Ylpp\n/5GYZf3F6JKCyfgsQWTCJVYB\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "firebase-adminsdk-ge8od@pdd-project-2c531.iam.gserviceaccount.com",
7
+ "client_id": "107753681242575726679",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-ge8od%40pdd-project-2c531.iam.gserviceaccount.com",
12
+ "universe_domain": "googleapis.com"
13
+ }
pdd.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from firebase_admin import firestore
3
+
4
+ import pdd1
5
+
6
+ def app():
7
+
8
+ if 'db' not in st.session_state:
9
+ st.session_state.db = ''
10
+
11
+ db=firestore.client()
12
+ st.session_state.db=db
13
+ # st.title(' :violet[pdd] :sunglasses:')
14
+
15
+ ph = ''
16
+ if st.session_state.username=='':
17
+ st.subheader('Login to use Model')
18
+ else:
19
+ pdd1.app()
20
+
21
+ # import streamlit as st
22
+
23
+ #def app():
24
+ #st.markdown('<a href="https://prj2106-plantd.hf.space/">Go to Another Link</a>', unsafe_allow_html=True)
25
+ # import streamlit as st
26
+ # import tensorflow as tf
27
+ # from PIL import Image
28
+ # import numpy as np
29
+ # import os
30
+
31
+ # import io
32
+
33
+
34
+ # import google.generativeai as genai
35
+
36
+ # def app():
37
+ # def import_and_predict(image_data, model, class_labels):
38
+ # size = (256, 256)
39
+
40
+ # if image_data is not None:
41
+ # image = Image.open(io.BytesIO(image_data.read()))
42
+ # image = image.resize(size)
43
+ # image = np.array(image)
44
+ # img_reshape = image / 255.0
45
+ # img_reshape = np.expand_dims(img_reshape, axis=0)
46
+
47
+ # prediction = model.predict(img_reshape)
48
+ # st.image(image, width=300)
49
+ # predictions_label = class_labels[np.argmax(prediction[0])]
50
+ # return predictions_label
51
+ # else:
52
+ # st.warning("Please upload an image.")
53
+ # return None
54
+
55
+
56
+ # def get_info_from_gemini(prompt):
57
+ # genai.configure(api_key=os.environ.get('gemini_api'))
58
+ # model = genai.GenerativeModel('gemini-pro')
59
+ # response = model.generate_content(f"{prompt}")
60
+ # return response
61
+
62
+
63
+
64
+
65
+ # st.title("Plant Disease Detection")
66
+
67
+ # uploaded_image = st.file_uploader(f"Upload an image", type=["jpg", "jpeg", "png"])
68
+ # models_path = ['./best_model_100_subset.h5',]
69
+
70
+
71
+
72
+ # CLASS_LABELS = ['Tomato Early blight', 'Tomato Leaf Mold', 'Tomato YellowLeaf Curl Virus',
73
+ # 'Tomato mosaic virus', 'Tomato healthy']
74
+
75
+ # model = tf.keras.models.load_model(models_path[0])
76
+
77
+
78
+
79
+
80
+ # prediction = import_and_predict(uploaded_image, model, CLASS_LABELS)
81
+ # st.write("disease name: ", prediction)
82
+
83
+
84
+ # if prediction != None:
85
+ # new_title = '<p style="font-size: 38px">Measures you can take to control: </p>'
86
+ # st.markdown(new_title, unsafe_allow_html=True)
87
+ # if prediction == CLASS_LABELS[4]:
88
+ # st.write("Plant is healthy take good care of it")
89
+ # response = get_info_from_gemini(f"cure for the disease {prediction} tell in bulletpoints and estimated cost in inr at last give summary of each measures estimated cost")
90
+ # st.write(response.text)
91
+
92
+