Memuat
Memuat
Watch every step above performed live, with English narration.
0 plays
Class book
Page 1 / 6
Cover: Class Transfer Learning Leaf Disease #6: Class-wise Evaluation, Confusion Matrix & Web Detection Application
Click a page or use ◀ ▶ to turn · swipe on mobile · to enlarge
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class Transfer Learning Leaf Disease #6: Class-wise Evaluation, Confusion Matrix & Leaf Detection Web Application”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
This is the final result, a web application for detecting tomato leaf diseases. Select or upload a leaf photo, and the optimized MobileNet V2 model directly displays the disease along with its confidence level. On the test data, the accuracy is 93.7%. Let's get started. Hello, welcome to the final episode of the leaf disease detection series using transfer learning and hyperparameter optimization. We have three models: feature extraction, manual fine-tuning, and fine-tuning with hyperparameter optimization using Optuna. Now we will evaluate all three on the unseen test data, analyze performance per class, and then convert the best model into a web application that anyone can use.
Create an evaluation file for leaf disease report. We load all three models from their respective PT files, predict 300 test images, and then calculate the accuracy. Run Feature extraction 75.3%, fine-tuning 92.3%, and Optuna model 93.7%. The order is the same as the validation results, meaning our model is not overfitting on the validation data.
Accuracy alone is not enough for research. The classification report displays precision, recall, and F1 per class. Leaf mold and virus mosaic are perfect with F1 1.0, healthy leaf 0.98. The hardest class is early blight with F1 0.867. Spider mite has recall 1 but precision 0.81, meaning some leaves from other classes are incorrectly predicted as spider mite. The confusion matrix clarifies this, with the green diagonal representing correct predictions, and for example, three target spot leaves are predicted as spider mite.
Let's look at an example of incorrect prediction. Out of 300 test images, 19 are incorrect. If you look closely, many errors occur on leaves with small spots that are similar across diseases, something that is sometimes also difficult for the human eye. At the end, we save one example leaf per class to the examples folder for the web application.
Now the web application. Create an app file for leaf disease with Streamlit. The model is loaded once with cache resource, so it is not reloaded on every interaction. The page contains a title, a select box to choose a leaf example, and a file uploader to upload your own photo.
In the prediction section, images are displayed in the left column, then processed with the same evaluation transformation as during evaluation, and softmax converts the model's output into probabilities. The right column displays the top prediction in the green box, plus the top three possibilities with a progress bar. We run it with streamlit run on the background, then open it in the browser at localhost port 8501.
The application is displayed. First example, bacterial spots, predicted correctly with confidence around 99%. We select another example from the select box, leaf mold, and the model updates its prediction correctly. This application is ready to be developed into a tool for farmers or agricultural extension workers. Done, and that concludes this series.
We have already built a complete leaf disease detection research, dataset plan village, augmentation and data pipeline, transfer learning with MobileNet V2 and ResNet 50 Fine-tuning with cosine annealing, hyperparameter optimization with Optuna, class-wise evaluation, up to web application. For further research, try photos of leaves from the field, other plant classes, or the efficient net model. Thank you for following this series. Working on a thesis, dissertation, or AI research in the field of agricultural AI? Cerdas Inovasi Digital helps implement deep learning, from transfer learning MobileNet and ResNet, Fine-tuning, hyperparameter optimization with Optuna, up to web application and result writing as well as opening a deep learning course with Pythor. Want to master the entire series, from the Plant Village dataset to the web app for leaf disease detection? All 6 episodes, complete with a step-by-step PDF guide and source code, Available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with 12-month package, or pay once Rp999.000 for lifetime access. Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →