Agro Analytics

AI-driven crop monitoring and predictive analytics system

AI/ML
# source

Project Source Code

Browse the core Python modules that power the Agro Analytics platform.

Files
AgroAnalytics.pyPython
1import streamlit as st
2import mysql.connector
3from passlib.hash import pbkdf2_sha256
4from PIL import Image
5
6def create_connection():
7 return mysql.connector.connect(
8 host="localhost",
9 user="root",
10 password="",
11 database="crops"
12 )
13
14def create_users_table(connection):
15 cursor = connection.cursor()
16 cursor.execute('''
17 CREATE TABLE IF NOT EXISTS users (
18 id INT AUTO_INCREMENT PRIMARY KEY,
19 username VARCHAR(50) NOT NULL,
20 password VARCHAR(100) NOT NULL
21 )
22 ''')
23 connection.commit()
24
25def register_user(connection, username, password):
26 cursor = connection.cursor()
27 hashed_password = pbkdf2_sha256.hash(password)
28 cursor.execute('INSERT INTO users (username, password) VALUES (%s, %s)',
29 (username, hashed_password))
30 connection.commit()
31
32def authenticate_user(connection, username, password):
33 cursor = connection.cursor()
34 cursor.execute('SELECT password FROM users WHERE username = %s',
35 (username,))
36 result = cursor.fetchone()
37 if result:
38 return pbkdf2_sha256.verify(password, result[0])
39 return False
40
41def main():
42 st.set_page_config(layout="centered", page_icon="🌾")
43 st.title("Agro Analytics")
44 connection = create_connection()
45 create_users_table(connection)
46
47 page = st.sidebar.radio("", ["Login", "Register"])
48
49 if page == "Register":
50 st.header("Register")
51 new_username = st.text_input("Enter your username:")
52 new_password = st.text_input("Enter your password:", type="password")
53 if st.button("Register"):
54 register_user(connection, new_username, new_password)
55 st.success("Registration successful!")
56
57 elif page == "Login":
58 st.header("Login")
59 username = st.text_input("Enter your username:")
60 password = st.text_input("Enter your password:", type="password")
61 if st.button("Login"):
62 if authenticate_user(connection, username, password):
63 st.success("Login successful!")
64 st.session_state["my_input"] = "success"
65 else:
66 st.error("Authentication failed.")
67
68if __name__ == "__main__":
69 main()
# demo

Live Terminal Output

See the Agro Analytics platform in action. Click Run to simulate.

terminal — streamlit
$_â–‹
# repository

Get the Code

Clone the repository and start searching from your terminal.

Agro-Analytics

A Streamlit-based agricultural analytics platform with ML crop recommendation (RandomForest, XGBoost), YOLOv8 crop health detection, weather forecasting, and MySQL user authentication.

pythonstreamlitmachine-learningyolov8agriculturecrop-recommendation
Python
0
Quick Start
$ git clone https://github.com/prathapselvakumar/Agro-Analytics.git
$ cd Agro-Analytics
$ pip install -r requirements.txt
$ streamlit run AgroAnalytics.py

Team

The team behind the Agro Analytics platform, bridging AI and agriculture.

Prathap Selvakumar
Mrthunjai Dhanasekhar
Adithya
Prathap Selvakumar

Robotics & ML Engineer

Mrthunjai Dhanasekhar

Computer Vision Specialist

Adithya

Full Stack Developer