CropVision AI Crop Identification System using CNN and Flask | Final Year Project with Source Code

CropVision AI Crop Identification System using CNN and Flask | Final Year Project with Source Code

Upload one photo of a crop, get the name back in under a second β€” plus a heat map showing exactly which pixels the CNN looked at. Complete Python final year project with training notebook, Flask app and source code.

Technology Used

Python 3.10 | TensorFlow 2.16 | Keras | MobileNetV2 | Grad-CAM | Flask 3 | Jupyter Notebook | scikit-learn | Pillow | Gunicorn | Nginx

codeAj
βœ“
codeAjVerified
πŸ†5K+ Projects Sold
Google Review
β‚Ή499β‚Ή1999

Get complete project source code + Installation guide + chat support


Abstract

Identifying a crop from a photograph sounds trivial until you're the one staring at an unlabelled field image. Extension officers, agri-tech data collectors and farm advisors do this every day, and it needs trained human eyes that aren't always standing where the camera is. CropVision AI automates that judgement using a Convolutional Neural Network.

The model is trained on the Agricultural Crops Image Dataset β€” roughly 800 photographs across 30 classes covering almond, banana, cardamom, chilli, clove, coconut, coffee, cotton, cucumber, fox nut, gram, jowar, jute, lemon, maize, mustard, olive and more. That works out to about 25 images per class, which is nowhere near enough to train a CNN from random weights. We tried. It stalled under 45% accuracy and refused to move.

So the project uses transfer learning instead: a MobileNetV2 convolutional backbone pretrained on ImageNet, extended with a custom conv and dense head, fine-tuned in two phases. Fully convolutional throughout, no LSTMs or attention blocks bolted on to look impressive. The final model hits roughly 90% top-1 accuracy and over 97% top-3 on held-out test images, against about 38% for the same-architecture-from-scratch baseline that's included in the notebook for comparison.

Predictions are explained with Grad-CAM, and the whole thing is served through a Flask web app with a JSON REST endpoint sitting alongside it.

What This Project Actually Does

Two pieces, and they're separate on purpose.

The first is crop_classification_training.ipynb, a Jupyter notebook that takes the raw dataset folder, cleans it, trains the model, evaluates it, and writes everything into an artifacts/ directory β€” the .keras model file, a labels.json, a metrics.json with per-class recall, plus training curves and a confusion matrix as PNGs.

The second is cropvision/, a Flask 3 application that loads those artifacts and turns them into a working website. You drag a photo onto the upload box, and you get back a ranked top-3 with confidence percentages, a Grad-CAM heat map overlaid on your image, and a toggle to flip between the original and the heat map.

Here's the part examiners actually like: the confidence threshold. If the model isn't sure, it doesn't fake it. Below 0.45 confidence the page says "closest match" instead of asserting an identification, because a closed-set classifier shown a random photo of a dog will still confidently tell you it's cardamom. Being honest about uncertainty is a design decision you can defend in a viva, and most student projects have nothing like it.

The duplicate problem (this is the part nobody expects)

The source dataset stores the same photograph under multiple file extensions. If you don't catch that, identical images end up in both your training and test sets, and your accuracy number becomes fiction. The notebook runs exact MD5 hashing and perceptual dHash before splitting, drops the duplicates, then does a stratified 70/15/15 split so every one of the 30 classes appears in all three partitions. Class imbalance is handled with computed class weights and augmentation β€” flip, rotation, zoom, translation, contrast, brightness β€” applied on-GPU during training.

If your accuracy ever comes out suspiciously close to 100%, duplicate removal got switched off. That's the first thing to check.

Key Features

  • Identifies 30 agricultural crop classes from one photograph, with inference landing between 100 and 200 ms on a plain CPU β€” no GPU needed to serve it
  • Ranked top-3 output with per-class confidence percentages, adjustable via a top_k query parameter
  • Grad-CAM heat map generated per prediction and painted over the uploaded image, so you can see the network is reading the crop and not the background wall behind it
  • Confidence thresholding that flags uncertain predictions rather than bluffing
  • Two-phase training: frozen backbone first, then fine-tuning of the deeper conv blocks at a reduced learning rate
  • Optional from-scratch CNN baseline so your report has a real 38% vs 90% comparison instead of an unsupported claim
  • Model card page at /model built automatically from metrics.json β€” test accuracy, dataset composition, per-class recall, training charts
  • JSON REST API at /api/predict accepting either a multipart file upload or a base64 string
  • EXIF orientation correction, because phone photos arrive rotated and a sideways image tanks the prediction
  • Uploads processed entirely in memory. Nothing written to disk
  • Preprocessing baked into the saved model, which kills the classic train/serve mismatch bug before it happens
  • A /health endpoint that returns 503 if the model didn't load
  • Graceful failure β€” if the artifacts are missing, every page tells you what to copy instead of dumping a stack trace on your evaluator's screen
  • Works with JavaScript disabled; the drag-and-drop is progressive enhancement, not a dependency
  • Gunicorn, systemd and Nginx configs included in deploy/

Real-World Applications

Agricultural extension and advisory work. A field officer photographs an unknown crop and gets an identification plus the visual evidence behind it, without waiting on a specialist to be available.

Farmer-facing mobile apps. The JSON API can back an Android or Flutter client directly. Crop identification becomes the entry point to variety-specific advice on irrigation, fertiliser scheduling and pest control.

Agri-marketplace verification. Produce listings with photos get checked automatically against the declared crop type, so mismatches get flagged before the listing goes live.

Dataset labelling at scale. Big unlabelled image collections get pre-sorted by predicted class, and only the low-confidence cases get routed to a human annotator. Saves an enormous amount of manual work.

Agronomy teaching. Horticulture students use it as a self-test tool, and the Grad-CAM overlay shows which morphological features separate one crop from another.

Drone and ground survey pipelines. Survey imagery gets crop-type tags automatically, feeding acreage estimation and crop-pattern analysis downstream.

And it's the obvious first stage for a crop disease detection system, since disease models are almost always crop-specific. Same training pipeline, different dataset. If your guide asks "what's the extension of this work," that's your answer.

What's Honestly Hard, and What's Easier Than It Looks

The hard part is Grad-CAM. Not running it β€” the code works out of the box and locates the backbone and final conv layer by inspection, so it survives a backbone swap. The hard part is explaining it in your viva when someone asks how gradients flowing back to a convolutional feature map turn into a heat map. Read that section of the notebook properly. Don't skip it the night before.

The easy part surprises people. Training the whole model takes 15 to 25 minutes on a normal laptop CPU, 3 to 5 minutes if you have a GPU. There's also smoke_test.py, which renders every single template against a stubbed model β€” so you can confirm the entire web app works without installing TensorFlow at all. Handy when your laptop is already struggling.

Who Should Buy This

If you're a student who needs a working project for your college submission, final-year project, semester project, internship, or academic demonstration, this is for you. Whether you're studying BCA, B.Tech, MCA, M.Tech, Computer Science, IT, AI, Data Science, or another related field, you can choose a project that fits your requirements. If you need the source code, project report, documentation, or help setting up and running the project, CodeAj gives you the resources and support to get started faster.

Why CodeAj

You get the complete source code β€” the training notebook, every Flask route, the templates, the deploy configs, all of it β€” along with a project report you can actually submit and setup support if something breaks on your machine. TensorFlow installs are the usual culprit, especially on Python 3.12 where 2.16 doesn't play nice on every platform. If you're browsing more options in this space, our machine learning projects with source code collection has similar CNN and deep learning builds, the AI final year projects hub covers everything from chatbots to detection systems, and there's a dedicated Flask projects section if you specifically want Python web deployment on your resume. Pick the one that matches your syllabus, not the one with the flashiest screenshot.

Frequently Asked Questions

You will get the complete source code along with an installation guide and chat support to help you set up and understand the project.
All our projects are thoroughly tested multiple times, so the code is completely error-free. But in case you still face any issue, you can reach out to us on WhatsApp (+91 8603862290) and we will fix it and provide you the updated code.
You can book a 1-on-1 Setup & Explanation Session where we connect via AnyDesk and Google Meet, set up the project on your laptop, and explain the complete code working and flow.
No, you cannot re-sell the project. This is completely illegal and a violation of our terms. If we find any such activity, we will take legal action.
It'll train fine. Budget 15 to 25 minutes on CPU, and around 3 to 5 minutes if you do have a GPU. You need roughly 4 GB free while it trains and 2 GB to run the Flask app afterwards. If you want it to finish sooner, set CFG['TRAIN_SCRATCH_BASELINE'] = False in the config cell, which skips the from-scratch comparison model. Just remember you'll lose the 38% vs 90% number for your report.
Say the dataset made that choice for you. There are only about 25 images per class, and a network trained from random weights overfits and stalls under 45% accuracy. The notebook actually trains that scratch baseline so you can show the number: roughly 38%. Transfer learning with a MobileNetV2 ImageNet backbone takes the same data to about 90%. That's not a shortcut, it's the correct method for a small dataset, and having the failed baseline in your report makes the argument for you.
That's Grad-CAM, and yes, understand it. It computes gradients of the predicted class flowing back into the last convolutional layer and turns them into a heat map over your photo, showing which regions pushed the model toward its answer. It's the difference between saying 'the model predicted maize' and proving the model looked at the maize instead of the wall behind it. Read that notebook section properly before your presentation.
Nope, that's a closed-set classifier working exactly as designed. It only knows 30 classes, so anything outside them gets mapped to the nearest one. That's precisely why the confidence threshold exists at 0.45 β€” a genuine out-of-class image usually falls below it and gets shown as an uncertain closest match. If you want to go further, adding an out-of-distribution check is a solid 'future scope' point for your report.
Check your Python version first. TensorFlow 2.16 doesn't support 3.12 on every platform, so drop to 3.10 or 3.11. On Apple Silicon skip the normal package entirely and install tensorflow-macos plus tensorflow-metal instead. And if you just want to confirm the web pages work while you sort this out, install flask, pillow and numpy and run smoke_test.py. It renders every template against a stubbed model with no TensorFlow anywhere.
Yes, and you don't need to retrain anything. The Flask app already exposes /api/predict which takes either a multipart file or a base64 image and returns JSON with the ranked predictions and confidence scores. Point a Flutter or Android client at it and you're done. There's also a TFLite export at around 7 MB in the artifacts folder if you'd rather run it fully on-device with no server.
No, don't trust it. That almost always means duplicate removal got switched off, which lets the same photo sit in both your training and test sets. The source dataset genuinely stores identical images under different file extensions. Set CFG['DROP_DUPLICATES'] = True, retrain, and you'll get an honest number in the 90% region. An examiner who spots an inflated figure will tear the whole report apart, so fix this before submission.
You get everything. The training notebook, app.py, config.py, model_service.py, all five Jinja templates, the CSS and JS, the deploy folder with the Gunicorn, systemd and Nginx configs, the requirements file, the .env example. Nothing is held back and nothing is obfuscated. The project report and documentation come along with it, plus setup help if something breaks on your machine.
Installation Guide

Extra Add-Ons Available – Elevate Your Project

Add any of these professional upgrades to save time and impress your evaluators.

Live 1-on-1 Mentorship

Personal session with an expert developer

Project Setup

We'll install and configure the project on your PC via remote session (Google Meet, Zoom, or AnyDesk).

Source Code Explanation

1-hour live session to explain logic, flow, database design, and key features.

Want to know exactly how the setup works? Review our detailed step-by-step process before scheduling your session.

β‚Ή999

Custom Documents (College-Tailored)

  • Custom Project Report: β‚Ή1,500
  • Custom Research Paper: β‚Ή1,000
  • Custom PPT: β‚Ή800

Fully customized to match your college format, guidelines, and submission standards.

Project Modification

Need feature changes, UI updates, or new features added?

Charges vary based on complexity.

We'll review your request and provide a clear quote before starting work.

Project Files

GoogleReviews

What Our Students Say

5(38+ reviews)
S
Sujit Chavan
a month ago

He explained the project clearly and thoroughly. He was very supportive throughout the process and was always available to help when needed. His guidance and assistance made it easier to understand the project and complete tasks effectively.

Y
Yash Baisware
4 months ago

I had a very good experience with CodeAj Marketplace. The team is professional and supportive, especially Ajay Pandit sir who guides clearly throughout the project. The work was completed neatly and according to requirements. A great place for learning and project development. Highly recommended for students and developers.

R
Ravi Singh
3 months ago

Excellent explanation! Concepts are explained in a very simple and understandable way. It really helped me a lot in improving my knowledge. Great work!

K
Keerthika S
a year ago

Codeaj was really helpful with my project, especially during the customization part. He didn't just do the work but also took the time to explain everything, from the project structure and database to the code itself. It was a huge help, especially for students trying to understand how everything fits together. I really appreciated his support and the way he made things easier to follow.

S
Sprillxstone
10 months ago

Working with CodeAj Marketplace has been such a positive experience. The projects delivered are original, carefully crafted from scratch, and tailored to meet expectations with impressive attention to detail. What really makes him stand out is his willingness to go the extra mile β€” not just in creating outstanding work, but also in helping others understand how everything functions. He explains things clearly, addresses questions patiently, and ensures the whole process feels like a learning journey instead of just a handover. On top of the technical expertise, his calm and approachable personality makes communication effortless. No unnecessary stress, just smooth collaboration and genuine support. I truly value the dedication he brings to his work and would highly recommend him to anyone in search of high-quality, authentic projects.

A
Abdullah ATK
11 months ago

I purchased a project from him recently and I have to say it's one of the best decisions I've made. The project was absolutely beautiful, built completely from scratch with no shortcuts, and perfectly matched what I wanted. What makes him stand out is not just his ability to create anything we ask for, no matter how complex, but also the way he helps us understand every part of it. He patiently explains the process, clears doubts, and makes sure we actually learn from the project instead of just using it. On top of his skills, his personality is amazing β€” he's calm, chill, and very friendly to talk to. There's no stress when working with him, only smooth communication and genuine support. I truly appreciate the effort he puts in and would highly recommend him to anyone looking for original, high-quality projects.

J
Jaya shree
9 months ago

I received my project from CodeAJ Marketplace on time, and the work was very neat and well-presented. The team maintained good communication and delivered everything as promised. I appreciate their timely completion and professional approach.

T
taha vohra
a year ago

I sincerely thank Mr. Ajay Pandit for his constant support and valuable guidance throughout the project. His timely advice, encouragement, and expertise greatly contributed to the successful completion of the work. I'm truly grateful for his mentorship.

S
Sonal
10 months ago

I had an outstanding experience with CodeAj while developing my mobile app. Their team was incredibly cooperative, ensuring every customization I requested was implemented flawlessly. The service was top-notch, and the final product exceeded my expectations. Highly recommend CodeAj for anyone seeking professional and reliable app development services! 11/10

R
Rutik Jagtap
a year ago

I would like to sincerely thank Ajay Pandit for providing me with the project. His guidance and explanation of the system's architecture, modules, and AI integration were extremely helpful in understanding the project thoroughly. Ajay's support played a key role in helping me implement the hotel booking and payment module effectively. His willingness to clarify concepts and walk me through complex logic made the learning process smooth and insightful. I truly appreciate his mentorship and the time he dedicated to ensuring I was well-prepared for both the development and presentation of this project.

P
Prachi Narkar
a year ago

I had a great experience with the project I purchased. It was well-structured and met all my expectations. The team was responsive and supportive throughout, addressing all my queries promptly. Highly recommended for anyone looking for quality projects and good service.

V
varshi v
11 months ago

I'm really thankful to Codeaj for helping me with my project explanation and guiding me throughout. Your support made everything much easier and clearer.

S
Sreekrutha Pasunuru
9 months ago

The project he made was wonderful, and the way he patiently listened, understood all my ideas and presented them so well in the project, was amazing. I would highly recommend him to everyone.

A
Anushka A
a year ago

I would like to sincerely thank Ajay Pandit for providing me with the project. His guidance and explanation of the system's architecture, modules, and AI integration were extremely helpful in understanding the project thoroughly.

M
Mohini Singh
11 months ago

Too good experience, I love their projects and they are available for you to help, they are incredible good. Must avail their services. I am happy customer.

R
Ramavath Parvathi
11 months ago

The team was very supportive and their explanation was very good, they are clarifying each and every doubts with lots of patience. Highly recommended for quality projects.

S
Soundarya S
6 months ago

I really like their work and they made good project in less amount.

S
Sambhaji Sonwane
a year ago

Thank you, CodeAj Bro, for supporting the Doctor Appointment System project. Your guidance during the project setup, installation, and report creation was very helpful and greatly appreciated.

M
Mukul Panwar
11 months ago

One of the best Software Developer provide the best setup environment for project, good explain skills, and good technical skills, step by step explain project through google meet and budgetly price project Available.

R
Rasika Tambe
a year ago

Thank you so much for your excellent work on our project! Your kindness and clear explanations made the entire process smooth and enjoyable. Highly recommend!

P
payal Tripathi
a year ago

Really very supportive, helpful and kind, loving nature. Available for any time for any query, highly recommend to get projects from him.

E
Evan Lavigne
a year ago

Awesome projects. They support on setting up the project after purchasing. Completely legal one. Affordable projects too.

S
Satesh kumar Nayak
a year ago

Code AJ guide team are very formal, friendly to setup project step by step and explain each question πŸ™‚

S
sanjay mp
a year ago

Thank you codeAj, Best site to get your project done quickly, with fast responses and instant clarification of any project-related doubts.

A
ahmedafa
a year ago

I really liked the work, and they solved my issues very well too.

G
Gauri Pandey
a year ago

They provide very good service and code also running condition and they fulfill all the queries it's very helpful.

D
DasHy
a year ago

Really helpful, makes things easy to understand and very kind nature, you can look forward to get help from here.

P
Prashant Undalli
10 months ago

Thank you so much for building the Project for my requirement.

S
Sunhith Reddy
11 months ago

Looking forward to many many collaborations and always tend to buy the projects.

H
Hemant kumar Kushwaha
a year ago

I am so satisfied with codeAJ because of his help.

A
Anjali
a year ago

Thank you so much sir for your support and help.

G
Govardhan Reddy
a year ago

Ajay bro has excellent knowledge and his response is nice.

J
Janet Ase
a year ago

This is a great app I love it with good functionality.

A
Anjali Varun
a year ago

Thank you so much for your help and support.

S
Sanskruti Kalshetti
a year ago

Highly recommended for the projects.

P
Purva Chavan
a year ago

Loved the project work.

P
p.p.s. raghavendra
11 months ago

It is super for students.

P
Pranita Sandim
a month ago

I recently purchased this project online and I am very satisfied with it. The project was well-designed, properly organized, and included all the necessary files and documentation. The source code was clean, easy to understand, and worked as expected. A special appreciation for the project explanation and setup session. The session was detailed and easy to understand, covering both the project implementation and the complete setup process. All my questions were answered clearly, which helped me understand the project much better. Thanks for giving your time.

⭐ 98% SUCCESS RATE
  • βœ“ Full Development
  • βœ“ Documentation
  • βœ“ Presentation Prep
  • βœ“ 24/7 Support