WEATHER AND CROP PREDICTION
SYSTEM
A PROJECT REPORT
Submitted by
KARTHIKEYAN M (621522205027)
JEEVANATH A (621522205022)
IYYAPPAN G (621522205019)
BOOBALAN R (621522205010)
in partial fulfillment for the award of the degree
of
BACHELOR OF TECHNOLOGY
in
INFORMATION TECHNOLOGY
MAHENDRA COLLEGE OF ENGINEERING,
MAHENDRA SALEM CAMPUS-636106.
ANNA UNIVERSITY::CHENNAI 600 025
MAY 2025
i
ANNA UNIVERSITY: CHENNAI 600 025
BONAFIDE CERTIFICATE
Certified that this project report “WEATHER AND
CROP PREDICTION SYSTEM” is the bonafide work done by
KARTHIKEYAN M (621522205027)
JEEVANATH A (621522205022)
IYYAPPAN G (621522205019)
BOOBALAN R (621522205010)
Who carried out the project work under my supervision.
SIGNATURE SIGNATURE
Dr. T. AKILA, M.E, Ph.D., Dr. T. AKILA, M.E, Ph.D.,
PROFESSOR, PROFESSOR,
HEAD OF THE DEP3ARTMENT, SUPERVISIOR,
Department of Information Technology, Department of Information Technology,
Mahendra College of Engineering, Mahendra College of Engineering,
Minnampalli, Salem-636106. Minnampalli, Salem-636106.
Submitted to Project and Viva-Voce Examination held on.............................................. at
MCE
INTERNAL EXAMINER EXTERNAL EXAMINER
ii
ACKNOWLEDGEMENT
The Success and final outcome of this project required a lot of guidance and assistance
from many people and an extremely fortunate to have got this all along with the completion
of my project work.
We request and thank Thirumigu. M. G. BHARATHKUMAR, Founder &
Chairman, Shrimathi. VALLIYAMMAL BHARATHKUMAR, Secretary for their
guidance and blessings, also we express our deepest gratitude to Managing Directors Er. Ba.
MAHENDHIRAN, Er. B. MAHA AJAY PRASATH, who modeled us both technically and
morally for achieving greater success in life.
We were extremely grateful to Dr. N. MOHANASUNDARARAJU, Principal for his
constant encouragement, inspiration, presence, and blessings throughout our course,
especially for providing us with an environment to complete our project successfully.
We also extend my sincere appreciation to Dr. T.AKILA, Head of the Department of
Information Technology who provided her valuable suggestions and precious time in
accomplishing my project report.
We owe my profound gratitude to our guide, Dr. T.AKILA , Head of the Department
of Information Technology who took an interest in our projectwork and provided all the
necessary information for developing the project successfully. We also thank all the staff
members of our college and technicians for their help in making this project a successful one.
Lastly, we would like to thank the almighty and my parents for their moral support and
my friends with whom shared my day-to-day experience and received lots of suggestions that
improved my quality of work.
iii
ABSTRACT
The “Weather and Crop Prediction” project is an integrated web-based platform
designed to empower farmers and agricultural stakeholders with intelligent, data-driven
tools for modern farming. By leveraging real-time weather data, crop disease detection and
seasonal planning, the application aims to optimize crop yield, reduce losses, and enhance
decision-making in agriculture.
The platform offers a user-friendly interface with modules for weather-based crop
suggestions, automated crop disease identification, plant disease treatment
recommendations, seasonal crop planning. These features are accessible through a
centralized dashboard, making advanced agricultural insights available to users with
minimal technical expertise.
The backend is structured to handle data processing, storage, and integration with
external APIs or machine learning models, while the frontend provides an intuitive
navigation experience. The project’s scope includes supporting sustainable farming
practices, increasing productivity, and bridging the gap between traditional agriculture and
smart technology.
By providing actionable insights and recommendations, Weather and Crop Prediction
aims to contribute to food security, economic stability for farmers, and the adoption of
precision agriculture techniques.
iv
TABLE OF CONTENTS
CHAPTER CONTENTS PAGE
NO NO
ABSTRACT iv
1 INTRODUCTION 1
1.1 OVERVIEW 1
1.2 SCOPE OF PROJECT 1
1.3 OBJECTIVE OF THE PROJECT 2
2 LITERARTUTE REVIEW 3
2.1 WEATHER-BASED CROP SUGGESTION 3
SYSTEMS
2.2 MACHINE LEARNING FOR CROP DISEASE 3
DETECTION
2.3 DECISION SUPPORT SYSTEMS IN 3
AGRICULTURE
2.4 REAL-TIME MARKET DATA IN 4
AGRICULTURE
4
2.5 SOIL ANALYSIS USING DIGITAL
TOOLS
v
2.6 SEASONAL CROP PLANNING WITH ICT 5
2.7 INTEGRATION OF IoT IN SMART 5
FARMING
3 SYSTEM ANALYSIS 5
3.1 EXISTING SYSTEM 5
3.1.1 DISADVANTAGE OF EXISTING 5
SYSTEM
6
3.2 PROPOSED SYSTEM
3.2.1 ADVANTAGE OF PROPOSED SYSTEM 6
4 SYSTEM REQUIREMENTS 8
4.1 HARDWARE REQUIREMENTS 8
4.2 SOFTWARE REQUIREMENTS 8
SYSTEM DESIGN AND DEVELOPMENT 14
5
5.1 RCNNARCHITECURE 14
vi
5.2 SYSTEM ARCHITECURE 9
5.3 DATA COLLECTION SET 10
5.4 DATA PRE -PROCESSING 11
5.5 TESTING DATA SET 11
5.6 ALGORITHM SELECTION 12
5.6.1 ALGORITHM USED 12
5.6.2 CONVOLUTIONAL NEURAL 12
NETWORK (CNN)
5.6.3 MODEL ARCHITECTURE SELECTION 13
6 UML DIAGRAMS 14
6.1 CLASS DIAGRAM 14
6.2 USE CASE DIAGRAM 15
6.3 ACTIVITY DIAGRAM 15
vii
7 PERFORMANCE ANALYSIS 17
8.1 ABOUT THE DATASET 17
8.2 ACCURACY OF CNN ALGORITHM 17
8.3 METHODOLOGY 19
8 CONCULSION 20
9 FUTURE ENHANCEMENT 21
10 APPENDIX 22
10.1 SOURCE CODE 22
10.2 OUTPUT SCREENS 26
11 BIBLIOGRAPHY 28
viii
LIST OF FIGURES
S.N0 FIGURE TITLE PAGE
NO NO
1 5.1 RCNN Architecture 9
2 5.2 System Architecture 9
3 5.3 Data collection set 10
4 5.4 Texting data set 11
5 6.1 Class diagram 14
6 6.2 Use case diagram 15
7 6.3 Activity diagram 16
8 7.1 Accuracy of CNN 17
7.2 Accuracy of CNN 18
7.5 Accuracy of training validation loss and 18
validation accuracy
9 10.1 Home screen of the project 26
10.2 Weather related information and crop 26
suggesion
10.3 Crop disease treatments 27
10.4 Seasonal crop planning calender 27
ix
CHAPTER-1
INTRODUCTION
1.1 OVERVIEW
Weather and Crop Prediction is an innovative web-based platform designed to
assist farmers and agricultural stakeholders in making smarter, data-driven decisions for
their farming activities. The application brings together a suite of tools that address key
aspects of modern agriculture, including weather-based crop suggestions, crop disease
detection, treatment recommendations, seasonal crop planning. By integrating these
features into a single, user-friendly dashboard.
The heart of Weather and Crop Prediction is its ability to provide weather-
based crop suggestions. By analyzing real-time and forecasted weather data, the
platform recommends the most suitable crops for current and upcoming conditions,
helping farmers optimize their yields and reduce risks associated with unpredictable
weather patterns.
1.2 SCOPE OF THE PROJECT
The scope of the Weather and Crop Prediction project is to develop a
comprehensive web-based platform that empowers farmers and agricultural
professionals with intelligent, data-driven tools for modern farming. The platform
integrates multiple modules, including weather-based crop suggestions, crop disease
detection, plant disease treatment recommendations, and seasonal crop planning.
By leveraging real-time weather information, machine learning for disease
identification, and the application aims to support farmers in making informed
decisions that enhance productivity and sustainability.
1
1.3 OBJECTIVE OF THE PROJECT
In this study, Weather and Crop Prediction project is to empower farmers and
agricultural stakeholders by providing them with a comprehensive, data-driven
platform that supports smarter and more efficient decision-making in their farming
activities,user-friendly web application, the project aims to simplify complex
agricultural processes and make advanced technology accessible to users of all
backgrounds.
Weather and Crop Prediction is designed to promote sustainable and profitable
farming practices by offering personalized advice, timely alerts, and predictive
analytics, thereby reducing crop losses, improving yield quality, and optimizing
resource utilization. Ultimately, the platform seeks to bridge the gap between
traditional farming and modern digital agriculture.
2
CHAPTER-2
LITERATURE REVIEW
2.1 TITLE : WEATHER-BASED CROP SUGGESTION SYSTEMS
Authors : Dr. Rajesh Kumar
This literature review examines the development and effectiveness of weather-
based crop suggestion systems. It highlights how integrating real-time weather data
with crop recommendation algorithms can help farmers select optimal crops for
prevailing and forecasted conditions, thereby improving yield and reducing risk.
2.2 TITLE : MACHINE LEARNING FOR CROP DISEASE DETECTION
Authors : Dr. Priya Sharma
This review explores the use of machine learning techniques in the early
detection and classification of crop diseases. It covers image processing, feature
extraction, and the application of deep learning models such as CNNs for accurate
disease identification.
2.3TITLE : DECISION SUPPORT SYSTEMS IN AGRICULTURE
Authors : Prof. Michael Green
This literature review focuses on the evolution of decision support systems
(DSS) in agriculture. It discusses how DSS platforms integrate data from multiple
sources—weather, soil, market, and crop health—to provide actionable insights for
farmers.
3
2.4 TITLE : REAL-TIME MARKET DATA IN AGRICULTURE
Authors : Dr. Linda Wang
This review investigates the role of real-time market data platforms in
agricultural economics. It analyzes how access to up-to-date market prices and
trends empowers farmers to make informed selling decisions, optimize profits.
2.5 TITLE : SOIL ANALYSIS USING DIGITAL TOOLS
Authors : Dr. Anil Mehta
This literature review examines advancements in digital soil analysis, including
the use of sensors, remote sensing, and data analytics. It highlights how these
technologies provide precise soil health assessments.
2.6 TITLE : SEASONAL CROP PLANNING WITH ICT
Authors : Dr. Maria Lopez
This review explores the integration of Information and Communication
Technology (ICT) in seasonal crop planning. It discusses how digital platforms help
farmers plan crop cycles based on climate data, historical trends, and predictive
analytics.
2.7 TITLE : INTEGRATION OF IoT IN SMART FARMING
Authors : Dr. Peter Novak
This literature review examines the integration of Internet of Things (IoT) devices
in smart farming. It covers the deployment of sensors for real-time monitoring of
soil, weather, and crop health.
4
CHAPTER-3
SYSTEM ANALYSIS
3.1 EXISTING SYSTEM
In the traditional agricultural system, farmers predominantly depend on their
personal experience, generational knowledge, and manual observation to guide
critical decisions related to crop selection, disease management,. This approach,
while rooted in local wisdom and practical know-how, often lacks the precision and
adaptability required to address the rapidly changing challenges of modern
agriculture. For instance, when it comes to choosing which crops to plant, farmers
typically base their decisions on what has historically performed well in their
region, rather than on current or forecasted weather conditions.
3.1.1 DISADVANTAGE OF EXISTING SYSTEM
1. Lack of Real-Time Data
Farmers often operate without access to the latest information regarding
weather conditions, or emerging disease threats. .
2. Limited Disease Detection
The traditional approach to identifying crop diseases relies heavily on manual
inspection and the farmer’s own experience. This method is inherently limited, as
many diseases can present with similar symptoms or may not be easily recognized
in their early stages.
3. Inefficient Resource Utilization:
Without the benefit of scientific soil analysis or accurate prediction, farmers
often apply water, fertilizers, and pesticides based on guesswork or routine
schedules rather than actual crop needs
5
4. Market Uncertainty:
In the absence of real-time data, farmers typically rely on local traders or
intermediaries for information about crop prices and demand. This lack of
transparency can result in farmers their produce at suboptimal times or prices.
5. Lack of Personalized Recommendations:
Traditional agricultural advice is often generic and not tailored to the specific
conditions of an individual farm, such as local soil characteristics, microclimate, or
crop history.This lack of customization can prevent farmers from achieving the best
possible outcomes for their unique situations.
3.2 PROPOSED SYSTEM
The proposed system, Weather and Crop Prediction, is envisioned as a
comprehensive, integrated web-based platform that aims to transform traditional
agricultural practices by equipping farmers and agricultural stakeholders with a
suite of intelligent, real-time, and data-driven tools. Unlike conventional methods
that rely heavily on manual observation and experience, Weather and Crop
Prediction harnesses the power of modern digital technologies to provide a holistic
solution for farm management and decision-making. The platform also incorporates
automated crop disease detection, utilizing machine learning and image analysis to
identify diseases at an early stage. This enables timely intervention and reduces crop
losses.
3.2.1 ADVANTAGE OF PROPOSED SYSTEM
1. Real-Time Data Access
Weather and Crop Prediction provides farmers with immediate access to the
latest weather forecasts, current market prices, and timely disease alerts.
6
2. Accurate Disease Detection
The system leverages advanced algorithms and sophisticated image analysis
techniques to detect crop diseases at an early stage with high precision. This early
and accurate identification allows for prompt intervention, minimizing the spread of
disease and reducing crop losses.
3. Optimized Resource Utilization
Through scientific soil analysis and predictive yield modeling, Weather and
Crop Prediction helps farmers apply water, fertilizers, and pesticides in the most
efficient manner
4. Personalized Recommendations
By Weather and Crop Prediction delivers tailored advice for each user, taking
into account specific farm data, local environmental conditions, and individual crop
histories.
5. Time and Labor Efficiency
The automation of monitoring, data analysis, and reporting processes
significantly reduces the time and manual effort required from farmers. Tasks that
once demanded extensive observation and record-keeping can now be managed
quickly and accurately through the platform, freeing up valuable time
7
CHAPTER-4
SYSTEM REQUIREMENTS
4.1 HARDWARE REQUIREMENTS
PROCESSOR: MINIMUM DUAL-CORE CPU (QUAD-CORE OR HIGHER
RECOMMENDED)
RAM: MINIMUM 4 GB (8 GB OR HIGHER RECOMMENDED FOR
PRODUCTION)
STORAGE: MINIMUM 20 GB FREE DISK SPACE
NETWORK: RELIABLE BROADBAND CONNECTION
4.2 SOFTWARE REQUIREMENTS
OPERATING SYSTEM: WINDOWS, LINUX, OR MACOS
WEB BROWSER: LATEST VERSION OF CHROME, FIREFOX, EDGE, OR
SAFARI
NODE.JS: V14 OR HIGHER
NPM: V6 OR HIGHER
REACT.JS: TYPICALLY V17 OR HIGHER
8
CHAPTER-5
SYSTEM DESIGN AND DEVELOPMENT
5.1 RCNN ARCHITECURE
Figure 5.1 RCNN Architecture
5.2 SYSTEM ARCHITECURE
Figure 5.2 System Architecture
9
5.3 DATA COLLECTION SET
Collecting a comprehensive and high-quality dataset is essential for
developing accurate and reliable deep learning models in agricultural applications
such as crop disease recognition, yield prediction, and soil analysis. For Weather and
Crop Prediction , the data collection process should encompass a wide range of
sources, including images of crops affected by various diseases, weather data, soil
health records, and market prices. It is important to ensure that all data collection
activities comply with ethical guidelines, particularly with respect to the privacy and
consent of farmers and data contributors. Necessary permissions and approvals should
be obtained when collecting images from farms, sensor data, or any information that
could be considered sensitive or proprietary. Additionally, efforts should be made to
include diverse data from different regions, crop types, and environmental conditions
to enhance the robustness and generalizability of the models developed for the
platform.
Figure 5.3 Data set collection
10
5.4 DATA PRE-PROCESSING
Data preprocessing for deep learning in crop disease recognition is a crucial
step to ensure the quality and effectiveness of the models used in Weather and Crop
Prediction. Initially, all crop images should be resized to a uniform dimension, such
as 224x224 or 256x256 pixels, to maintain consistency across the dataset and
facilitate efficient model training. Normalizing pixel values to a standard range,
typically between 0 and 1, helps improve model convergence and stability during the
training process. To enhance the model’s ability to generalize and perform well on
unseen data, various augmentation techniques—such as image rotation, flipping,
scaling, and contrast adjustment—can be applied, thereby increasing the diversity of
the training set.
5.5 TESTING DATA SET
Figure 5.4 Testing data set
11
5.6 ALGORITHM SELECTION
5.6.1 Algorithm used
In the crop disease detection project, a Convolutional Neural Network (CNN)
is employed as the core algorithm for image-based classification. CNNs are a class
of deep learning models tailored for visual recognition and image analysis tasks.
Their ability to capture intricate patterns and localized features makes them highly
suitable for identifying diseases in crop leaf images.
5.6.2 Convolutional Neural Network (CNN)
A CNN is composed of multiple interconnected layers, including
convolutional layers, pooling layers, and fully connected layers. This architecture
mimics the structure of the human visual cortex, allowing the network to extract
hierarchical patterns in image data, such as color variations, textures, and lesions
characteristic of different plant diseases.
Convolutional Layers
The convolutional layers form the foundation of a CNN. These layers utilize
small filters (kernels) that slide over the image to extract localized features. In the
context of crop disease detection, these filters learn to identify features such as
spots, discolorations, or edge deformities that indicate infection or nutrient
deficiencyPooling Layers.
Fully Connected Layers
These layers consolidate the extracted features and learn the higher-order
relationships necessary for classification. In crop disease detection, the fully
connected layers help in distinguishing between various disease types and healthy
leaf conditions..
12
Activation Functions
Activation functions, such as ReLU (Rectified Linear Unit), introduce non-
linearity to the model, enabling it to learn complex relationships in the data.
Softmax Layer
The use of CNNs in this crop disease detection project is strongly justified
due to their robust performance in similar visual classification tasks. These
networks provide a powerful framework for automated, scalable, and accurate
diagnosis of plant health
5.6.3 MODEL ARCHITECTURE SELECTION
Select a suitable CNN architecture for crop disease classification—options
include VGG, ResNet, Inception, or a custom model..
Model Construction
Build the model with convolutional, pooling, and fully connected layers.
Apply dropout to reduce overfitting.
Training
Train on the preprocessed dataset, validate periodically, and adjust hyperparameters
based on validation results.
Model Evaluation
Test the model on unseen data and measure accuracy, precision, recall, and F1-
score.
13
CHAPTER-6
UML DIAGRAMS
6.1 CLASS DIAGRAM
The class diagram for the Crop Disease Identification System shows the static
structure of the project, highlighting key classes like ImageProcessor,
ModelTrainer, DatasetManager, PredictionEngine, and FileHandler. It visualizes
how these components interact—for example, ModelTrainer uses ImageProcessor
and DatasetManager, while PredictionEngine loads models using FileHandler. This
diagram provides a clear overview of the system's architecture and relationships,
useful for development and communication.
Figure 6.1 Class Diagram
14
6.2 USE CASE DIAGRAM
A A use case diagram for the Crop Disease Identification System illustrates
the interactions between users (e.g., farmers, admin) and the system to achieve tasks
like uploading images, identifying diseases, and viewing results. It provides a user-
focused view of system behavior, helping to define and communicate functional
requirements clearly during the analysis and design phases.
Figure 6.2 Use Case Diagram
15
6.3 ACTIVITY DIAGRAM
An activity diagram is a type of UML (Unified Modeling Language) diagram
that represents the dynamic aspects of a system by showing the flow of control or
data from activity to activity. For the Crop Disease Identification System, here's how
the activity diagram reflects the process.
Figure 6.3 Activity Diagram
16
CHAPTER-7
PERFORMANCE ANALYSIS
7.1 ABOUT THE DATASET
The data used in this project is made by enlarging and consolidating India’s
publicly available data sets such as weather, soil, etc. This data is simple compared to
very few factors but useful as opposed to complex factors that affect crop yields. The
data are rich in Nitrogen, Phosphorus, Potassium, and soil PH. Also, it contains
humidity, temperature and rainfall required for a particular plant.
7.2ACCURACY OF CNN ALGORITHM
On applying it to dataset, it gives accuracy of 99.26%
Figure 7.1 Accuracy of CNN
17
On applying it to dataset , it gives accuracy of 94.41%
Figure 7.2 accuracy of CNN
Figure 7.3 Accuracy of Training validation loss and validation Accuracy
Achieving 99.26% accuracy for crop disease using deep learning is an
impressive result, indicating a high level of performance. Here are some key points
and considerations regarding a 99.26% accuracy.
18
7.3 METHODOLOGY
The classical Convolutional Neural Network (CNN) methodology for crop
disease detection involves a series of systematic steps to achieve accurate
classification of plant health status, as illustrated in Figure 1, which depicts the CNN
workflow for determining whether a crop leaf is healthy or diseased. In this study,
the methodology is presented in a clear and accessible manner. The process begins
with the collection of a comprehensive image dataset of crop leaves, which
undergoes essential pre-processing steps such as resizing, normalization, and
augmentation to enhance data quality and variability.
To ensure robust performance, the newly trained model is evaluated by
comparing its predictions on a validation set with those of pre-trained models or
established benchmarks. The classification function is optimized to select the best
solution for each analysis, maximizing accuracy and reliability. In this study, input
images of size 256×256×3 were processed using a CNN architecture inspired by
models such as VGG19, which is known for its deep feature extraction capabilities.
This architecture creates millions of parameters for training, allowing the model to
capture intricate patterns associated with various crop diseases.
19
CHAPTER-8
CONCULSION
In The "Weather and Crop Prediction" project represents a significant step
forward in the digital transformation of agriculture. By integrating advanced web
technologies, data analytics, and user-friendly design, the platform empowers
farmers and agricultural professionals to make informed, data-driven decisions that
enhance productivity, sustainability, and profitability.
Through the use of React.js for the frontend and Node.js/Express.js for the
backend, Weather and Crop Prediction delivers a responsive, scalable, and
maintainable solution. Middleware tools like body-parser and cors ensure smooth
communication between the client and server, while the modular architecture allows
for future enhancements such as IoT integration, advanced AI, and mobile app
support.The project not only bridges the gap between traditional farming practices
and modern technology but also democratizes access to expert knowledge and real-
time data. This enables even small-scale farmers to benefit from precision
agriculture, optimize resource usage, and respond proactively to changing
environmental and market conditions.
Weather and Crop Prediction stands as a robust, extensible, and impactful
platform that has the potential to revolutionize agricultural practices, improve
livelihoods, and contribute to food security and sustainability. Its foundation paves
the way for continuous innovation and adaptation to the evolving needs of the
agricultural community.
20
CHAPTER-9
FUTURE ENHANCEMENT
1. Multi-Modal Fusion:
Description: Integrate multiple data sources such as leaf images, environmental
sensor data (e.g., humidity, temperature), and soil health metrics to improve disease
detection accuracy. Fusion methods like early fusion or attention-based models can
combine these inputs for more robust diagnosis.
2. Real-Time Disease Monitoring:
Description: Develop a mobile app with real-time camera input and edge AI to
allow farmers to detect diseases instantly in the field without needing internet
connectivity.
3. Explainable AI (XAI):
Description: Implement explainability techniques to highlight infected leaf regions
and provide visual cues explaining the model’s diagnosis, helping farmers
understand and trust the system’s predictions.
4. Predictive Disease Progression:
Description: Extend the model to predict the progression and severity of crop
diseases over time, enabling proactive management and treatment
recommendations.
21
CHAPTER-10
APPENDIX
10.1 SOURCE CODE
train.py
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications import MobileNetV2
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D
from tensorflow.keras.models import Model
import json
import os
import scipy
# Dataset path
TRAIN_PATH = "train"
MODEL_PATH = "model/clean_model.h5"
CLASS_NAMES_PATH = "model/class_names.json"
# Ensure model directory exists
os.makedirs(os.path.dirname(MODEL_PATH), exist_ok=True)
22
# Data preprocessing with error handling
try:
train_datagen = ImageDataGenerator(
rescale=1./255,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True,
validation_split=0.2
# Load and preprocess the data
train_generator = train_datagen.flow_from_directory(
TRAIN_PATH,
target_size=(224, 224),
batch_size=32,
class_mode='categorical'
# Get number of classes
num_classes = len(train_generator.class_indices)
23
# Create the model
base_model = MobileNetV2(weights='imagenet', include_top=False, input_shape=(224,
224, 3))
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(1024, activation='relu')(x)
predictions = Dense(num_classes, activation='softmax')(x)
model = Model(inputs=base_model.input, outputs=predictions)
# Freeze the base model layers
for layer in base_model.layers:
layer.trainable = False
# Compile the model
model.compile(
optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy']
# Train the model
history = model.fit(
train_generator,
24
epochs=5,
steps_per_epoch=len(train_generator)
# Save the model
model.save(MODEL_PATH, include_optimizer=False)
# Save class names
class_names = list(train_generator.class_indices.keys())
with open(CLASS_NAMES_PATH, 'w') as f:
json.dump(class_names, f)
print("Training completed! Model and class names saved.")
except Exception as e:
print(f"Error during training: {str(e)}")
raise
25
10.2 OUTPUT SCREENS
Figure 10.1 Home screen of the project
Figure 10.2 Weather related information and crop suggestions
26
Figure 10.3 Crop disease treatments
Figure 10.4 Seasonal crop planning Calender
27
CHAPTER-11
BIBLIOGRAPHY
REFERENCES
1. Smith, J. W., Schneider, S. H., Oppenheimer, M., Yohe, G. W., Hare, W.,
Mastrandrea, M. D., Patwardhan, A., Burton, I., Corfee-Morlot, J., & Magadza,
C. H. D. (2009). Assessing dangerous climate change through an update of the
Intergovernmental Panel on Climate Change (IPCC) "reasons for concern."
Proceedings of the National Academy of Sciences, 106(11), 4133-4137.
https://doi.org/10.1073/pnas.0812355106
2. Lobell, D. B., Burke, M. B., Tebaldi, C., Mastrandrea, M. D., Falcon, W. P., &
Naylor, R. L. (2008). Prioritizing Climate Change Adaptation Needs for Food
Security in 2030. Science, 319(5863), 607-610.
https://doi.org/10.1126/science.1152339
3. Vermeulen, S. J., Campbell, B. M., & Ingram, J. S. I. (2012). Climate Change
and Food Systems. Annual Review of Environment and Resources, 37(1), 195-
222. https://doi.org/10.1146/annurev-environ-020411-130608
4. Ray, D. K., Gerber, J. S., MacDonald, G. K., & West, P. C. (2015). Climate
variation explains a third of global crop yield variability. Nature
Communications, 6(1), 5989. https://doi.org/10.1038/ncomms6989
28
5. Wheeler, T., & von Braun, J. (2013). Climate Change Impacts on Global Food
Security. Science, 341(6145), 508-513 .
https://doi.org/10.1126/science.1239402
6. Battisti, D. S., & Naylor, R. L. (2009). Historical Warnings of Future Food
Insecurity with Unprecedented Seasonal Heat. Science, 323(5911), 240-244.
https://doi.org/10.1126/science.1164363
7. Thornton, P. K., Ericksen, P. J., Herrero, M., & Challinor, A. J. (2014). Climate
variability and vulnerability to climate change: a review. Global Change
Biology, 20(11), 3313-3328. https://doi.org/10.1111/gcb.12158
8. Lesk, C., Rowhani, P., & Ramankutty, N. (2016). Influence of extreme weather
disasters on global crop production. Nature, 529(7584), 84-87.
https://doi.org/10.1038/nature16467
9. Challinor, A. J., Watson, J., Lobell, D. B., Howden, S. M., Smith, D. R., &
Chhetri, N. (2014). A meta-analysis of crop yield under climate change and
adaptation. Nature Climate Change, 4(4), 287-291.
https://doi.org/10.1038/nclimate2153
10. Myers, S. S., Zanobetti, A., Kloog, I., Huybers, P., Leakey, A. D. B., Bloom, A.
J., Carlisle, E., Dietterich, L. H., Fitzgerald, G., & Hasegawa, T. (2014).
Increasing CO2 threatens human nutrition. Nature, 510(7503), 139-142.
https://doi.org/10.1038/nature13179
29